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
118cc7872eb306994131dfff1c3239b278ed3c4f
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
/PWGLF/FORWARD/analysis2/DrawAODSummary.C
82fca2151c85b996507227d25364571c85c8f7ca
[]
permissive
alisw/AliPhysics
91bf1bd01ab2af656a25ff10b25e618a63667d3e
5df28b2b415e78e81273b0d9bf5c1b99feda3348
refs/heads/master
2023-08-31T20:41:44.927176
2023-08-31T14:51:12
2023-08-31T14:51:12
61,661,378
129
1,150
BSD-3-Clause
2023-09-14T18:48:45
2016-06-21T19:31:29
C++
UTF-8
C
false
false
572
c
DrawAODSummary.C
/** * @file DrawAODSummary.C * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> * @date Tue Oct 30 09:47:30 2012 * * @brief Script to draw summary of AOD pass into a PDF * * */ //____________________________________________________________________ void DrawAODSummary(const char* fname="forward.root", UShort_t what=0x27F) { gROOT->SetMacroPath(Form("%s:$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts", gROOT->GetMacroPath())); gROOT->LoadMacro("SummaryAODDrawer.C+g"); SummaryAODDrawer d; d.Run(fname, what); } // // EOF //
f8b9e6bcc3fd9aecea4f5388f3a5899e423d665d
b98323f2b23a23d674bbb75c6f5db0b5aafbe57a
/tests/reinit/main.c
1ac0ce3ae3b206fbd9ea2a997a47cfefff18790b
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
grimfang4/sdl-gpu
f03f24fd84a8e2f61d8c9c331044a592f6bbfd97
e8ee3522ba0dbe72ca387d978e5f49a9f31e7ba0
refs/heads/master
2023-07-10T10:56:21.827473
2022-06-24T14:59:46
2022-06-24T15:00:01
32,435,968
1,269
175
MIT
2022-09-03T11:53:58
2015-03-18T03:33:13
C
UTF-8
C
false
false
1,708
c
main.c
#include "SDL.h" #include "SDL_gpu.h" #include <math.h> #include "common.h" #define IMAGE_FILE "data/test.bmp" int main_loop() { int result = -1; GPU_Target* screen; printRenderers(); screen = GPU_Init(800, 600, GPU_DEFAULT_INIT_FLAGS); if(screen == NULL) { GPU_LogError("Failed to init SDL_gpu.\n"); return -1; } printCurrentRenderer(); { Uint8 done; SDL_Event event; GPU_Image* image; GPU_LogError("Loading image\n"); image = GPU_LoadImage(IMAGE_FILE); if(image == NULL) { GPU_LogError("Failed to load image.\n"); return -1; } done = 0; while(!done) { while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) { done = 1; result = -1; } else if(event.type == SDL_KEYDOWN) { if(event.key.keysym.sym == SDLK_ESCAPE) { done = 1; result = -1; } else if(event.key.keysym.sym == SDLK_SPACE) { done = 1; result = 1; } } } GPU_Clear(screen); GPU_Blit(image, NULL, screen, 150, 150); GPU_Flip(screen); } GPU_FreeImage(image); } GPU_Quit(); return result; } int main(int argc, char* argv[]) { while(main_loop() > 0) { GPU_Log("\nReinitializing.\n\n"); } return 0; }
4baa63e0e2ce522583d7f919d30d8882b20e3fbb
e1cddfd754d952134e72dfd03522c5ea4fb6008e
/src/vnet/dpo/load_balance.h
3605d82a20717db5ff3be05dbf4884f2b673662e
[ "Apache-2.0" ]
permissive
FDio/vpp
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
f234b0d4626d7e686422cc9dfd25958584f4931e
refs/heads/master
2023-08-31T16:09:04.068646
2022-03-14T09:49:15
2023-08-31T09:50:00
96,556,718
1,048
630
Apache-2.0
2023-06-21T05:39:17
2017-07-07T16:29:40
C
UTF-8
C
false
false
7,420
h
load_balance.h
/* * Copyright (c) 2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * \brief * The load-balance object represents an ECMP choice. The buckets of a load * balance object point to the sub-graph after the choice is made. * THe load-balance object is also object type returned from a FIB table lookup. * As such it needs to represent the case where there is only one coice. It may * seem like overkill to use a load-balance object in this case, but the reason * is for performance. If the load-balance object were not the result of the FIB * lookup, then some other object would be. The case where there was ECMP * this other object would need a load-balance as a parent and hence just add * an unnecessary indirection. * * It is also the object in the DP that represents a via-fib-entry in a recursive * route. * */ #ifndef __LOAD_BALANCE_H__ #define __LOAD_BALANCE_H__ #include <vlib/vlib.h> #include <vnet/ip/lookup.h> #include <vnet/dpo/dpo.h> #include <vnet/fib/fib_types.h> #include <vnet/fib/fib_entry.h> /** * Load-balance main */ typedef struct load_balance_main_t_ { vlib_combined_counter_main_t lbm_to_counters; vlib_combined_counter_main_t lbm_via_counters; } load_balance_main_t; extern load_balance_main_t load_balance_main; /** * The maximum number of buckets that a load-balance object can have * This must not overflow the lb_n_buckets field */ #define LB_MAX_BUCKETS 8192 /** * The number of buckets that a load-balance object can have and still * fit in one cache-line */ #define LB_NUM_INLINE_BUCKETS 4 /** * @brief One path from an [EU]CMP set that the client wants to add to a * load-balance object */ typedef struct load_balance_path_t_ { /** * ID of the Data-path object. */ dpo_id_t path_dpo; /** * The index of the FIB path */ fib_node_index_t path_index; /** * weight for the path. */ u32 path_weight; } load_balance_path_t; /** * Flags controlling load-balance creation and modification */ typedef enum load_balance_attr_t_ { LOAD_BALANCE_ATTR_USES_MAP = 0, LOAD_BALANCE_ATTR_STICKY = 1, } load_balance_attr_t; #define LOAD_BALANCE_ATTR_NAMES { \ [LOAD_BALANCE_ATTR_USES_MAP] = "uses-map", \ [LOAD_BALANCE_ATTR_STICKY] = "sticky", \ } #define FOR_EACH_LOAD_BALANCE_ATTR(_attr) \ for (_attr = 0; _attr <= LOAD_BALANCE_ATTR_STICKY; _attr++) typedef enum load_balance_flags_t_ { LOAD_BALANCE_FLAG_NONE = 0, LOAD_BALANCE_FLAG_USES_MAP = (1 << 0), LOAD_BALANCE_FLAG_STICKY = (1 << 1), } __attribute__((packed)) load_balance_flags_t; /** * The FIB DPO provieds; * - load-balancing over the next DPOs in the chain/graph * - per-route counters */ typedef struct load_balance_t_ { /** * required for pool_get_aligned. * memebers used in the switch path come first! */ CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); /** * number of buckets in the load-balance. always a power of 2. */ u16 lb_n_buckets; /** * number of buckets in the load-balance - 1. used in the switch path * as part of the hash calculation. */ u16 lb_n_buckets_minus_1; /** * The protocol of packets that traverse this LB. * need in combination with the flow hash config to determine how to hash. * u8. */ dpo_proto_t lb_proto; /** * Flags concenring the LB's creation and modification */ load_balance_flags_t lb_flags; /** * Flags from the load-balance's associated fib_entry_t */ fib_entry_flag_t lb_fib_entry_flags; /** * The number of locks, which is approximately the number of users, * of this load-balance. * Load-balance objects of via-entries are heavily shared by recursives, * so the lock count is a u32. */ u32 lb_locks; /** * index of the load-balance map, INVALID if this LB does not use one */ index_t lb_map; /** * This is the index of the uRPF list for this LB */ index_t lb_urpf; /** * the hash config to use when selecting a bucket. this is a u16 */ flow_hash_config_t lb_hash_config; /** * Vector of buckets containing the next DPOs, sized as lbo_num */ dpo_id_t *lb_buckets; /** * The rest of the cache line is used for buckets. In the common case * where there there are less than 4 buckets, then the buckets are * on the same cachlie and we save ourselves a pointer dereferance in * the data-path. */ dpo_id_t lb_buckets_inline[LB_NUM_INLINE_BUCKETS]; } load_balance_t; STATIC_ASSERT(sizeof(load_balance_t) <= CLIB_CACHE_LINE_BYTES, "A load_balance object size exceeds one cacheline"); STATIC_ASSERT (LB_MAX_BUCKETS <= CLIB_U16_MAX, "Too many buckets for load_balance object"); STATIC_ASSERT (LB_MAX_BUCKETS && !(LB_MAX_BUCKETS & (LB_MAX_BUCKETS - 1)), "LB_MAX_BUCKETS must be a power of 2"); /** * Flags controlling load-balance formatting/display */ typedef enum load_balance_format_flags_t_ { LOAD_BALANCE_FORMAT_NONE, LOAD_BALANCE_FORMAT_DETAIL = (1 << 0), } load_balance_format_flags_t; extern index_t load_balance_create(u32 num_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc); extern flow_hash_config_t load_balance_get_default_flow_hash(dpo_proto_t lb_proto); extern void load_balance_multipath_update( const dpo_id_t *dpo, const load_balance_path_t * raw_next_hops, load_balance_flags_t flags); extern void load_balance_set_bucket(index_t lbi, u32 bucket, const dpo_id_t *next); extern void load_balance_set_urpf(index_t lbi, index_t urpf); extern void load_balance_set_fib_entry_flags(index_t lbi, fib_entry_flag_t flags); extern index_t load_balance_get_urpf(index_t lbi); extern u8* format_load_balance(u8 * s, va_list * args); extern const dpo_id_t *load_balance_get_bucket(index_t lbi, u32 bucket); extern int load_balance_is_drop(const dpo_id_t *dpo); extern u16 load_balance_n_buckets(index_t lbi); extern f64 load_balance_get_multipath_tolerance(void); /** * The encapsulation breakages are for fast DP access */ extern load_balance_t *load_balance_pool; static inline load_balance_t* load_balance_get (index_t lbi) { return (pool_elt_at_index(load_balance_pool, lbi)); } #define LB_HAS_INLINE_BUCKETS(_lb) \ ((_lb)->lb_n_buckets <= LB_NUM_INLINE_BUCKETS) static inline const dpo_id_t * load_balance_get_bucket_i (const load_balance_t *lb, u32 bucket) { ASSERT(bucket < lb->lb_n_buckets); if (PREDICT_TRUE(LB_HAS_INLINE_BUCKETS(lb))) { return (&lb->lb_buckets_inline[bucket]); } else { return (&lb->lb_buckets[bucket]); } } extern void load_balance_module_init(void); #endif
b49f3b3e67a3b292201cc537b4abd5d33ff7d628
70a79d90a6a037071c41236ca0498f3e313ff1ce
/parmys/parmys-plugin/netlist/netlist_statistic.h
91e7a516d930fc5eddc0f447df69e8d928fab7d9
[ "MIT", "MIT-Modern-Variant", "LicenseRef-scancode-unknown-license-reference" ]
permissive
verilog-to-routing/vtr-verilog-to-routing
7f327e74394fb35ca90d90c48e62df8db6080513
ef5f993959c6b6896f6821b14b361d581ebf46fe
refs/heads/master
2023-09-01T04:19:02.151710
2023-08-31T20:57:20
2023-08-31T20:57:20
38,118,370
898
403
NOASSERTION
2023-09-14T15:30:08
2015-06-26T15:24:42
C++
UTF-8
C
false
false
1,472
h
netlist_statistic.h
/* * Copyright 2022 CAS—Atlantic (University of New Brunswick, CASA) * * 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. * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _NETLIST_STATISTIC_H_ #define _NETLIST_STATISTIC_H_ #include "netlist_utils.h" static const unsigned int traversal_id = 0; static const uintptr_t mult_optimization_traverse_value = (uintptr_t)&traversal_id; stat_t *get_stats(nnode_t *node, netlist_t *netlist, uintptr_t traverse_mark_number); void init_stat(netlist_t *netlist); void compute_statistics(netlist_t *netlist, bool display); /** * @brief This function will calculate and assign weights related * to mixing hard and soft logic implementation for certain kind * of logic blocks * @param node * The node that needs its weight to be assigned * @param netlist * netlist, has to be passed to the counting functions */ void mixing_optimization_stats(nnode_t *node, netlist_t *netlist); #endif // _NETLIST_STATISTIC_H_
61e1fb15dbf36921f65cd537ba79dd6336a30f9c
94096248c1de2dcf46e69ca913cedfa290e44224
/tests/api/test-dev-finalizer-rerun.c
922fcba0e99f632f7b5072489afad1a3a1829321
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
svaarala/duktape
612110d1a6db46226c171cfd222974b1b3651ad5
5e169deafbbd12823665f5d30fb4c4c04e3dfa26
refs/heads/master
2023-08-06T16:43:33.014729
2022-11-17T21:02:08
2022-11-17T21:02:08
15,852,088
4,796
610
MIT
2023-09-11T17:13:01
2014-01-12T22:16:14
JavaScript
UTF-8
C
false
false
3,609
c
test-dev-finalizer-rerun.c
/* * A finalizer shouldn't be re-entered unless the finalizer explicitly * rescued the object. */ static duk_ret_t my_print(duk_context *ctx) { duk_push_string(ctx, " "); duk_insert(ctx, 0); duk_join(ctx, duk_get_top(ctx) - 1); printf("%s\n", duk_safe_to_string(ctx, -1)); return 0; } /*=== *** test_heap_destruction (duk_safe_call) creating heap heap created object 1 finalizer destroying heap heap destroyed ==> rc=0, result='undefined' ===*/ /* Create an object, force one round of GC and destroy heap immediately. * Object has been finalized but not yet rescued, and should not be * finalized again on destruction. */ static duk_ret_t test_heap_destruction(duk_context *ignored_ctx, void *udata) { duk_context *my_ctx; (void) udata; printf("creating heap\n"); fflush(stdout); my_ctx = duk_create_heap_default(); if (!my_ctx) { printf("failed to create heap\n"); fflush(stdout); return 0; } printf("heap created\n"); fflush(stdout); /* Dummy print() binding. */ duk_push_c_function(my_ctx, my_print, 1); duk_put_global_string(my_ctx, "print"); duk_eval_string_noresult(my_ctx, "(function () {\n" " var obj1 = {}; var obj2 = {};\n" " obj1.ref = obj2; obj2.ref = obj1;\n" " Duktape.fin(obj1, function obj1fin() { print('object 1 finalizer'); });\n" " obj1 = obj2 = null;\n" " Duktape.gc();\n" "})()"); printf("destroying heap\n"); fflush(stdout); duk_destroy_heap(my_ctx); printf("heap destroyed\n"); fflush(stdout); return 0; } #if 0 /* Disabled: this is too fragile because it relies on dangling references; * unfortunately the potential re-run scenario is difficult to confirm * otherwise. */ /* Create a circular reference with a finalizer, force a GC run which runs the * finalizer. Use a dangling (!) C heaphdr reference to break the loop so that * refzero code processes the object again. Finalization should not happen again * in the refcount path. */ static duk_ret_t test_markandsweep_finalize_then_refzero(duk_context *ignored_ctx) { duk_context *my_ctx; void *ptr; printf("creating heap\n"); fflush(stdout); my_ctx = duk_create_heap_default(); if (!my_ctx) { printf("failed to create heap\n"); fflush(stdout); return 0; } printf("heap created\n"); fflush(stdout); duk_eval_string(my_ctx, "(function () {\n" " var obj1 = {}; var obj2 = {};\n" " obj1.ref = obj2; obj2.ref = obj1;\n" " Duktape.fin(obj1, function obj1fin() { print('object 1 finalizer'); });\n" " return obj1;\n" "})()"); ptr = duk_get_heapptr(my_ctx, -1); duk_pop(my_ctx); if (!ptr) { printf("heap ptr was NULL\n"); fflush(stdout); } else { printf("forcing gc\n"); fflush(stdout); duk_gc(my_ctx, 0); printf("gc done\n"); fflush(stdout); /* Because 'ptr' has a finalizer it's been finalized but would * require a second round of mark-and-sweep the be actually freed. * So 'ptr' is reachable but technically dangling so this is not * fully safe. But it's safe enough to break the circular reference * unless something else triggers GC before that. */ duk_push_heapptr(my_ctx, ptr); duk_del_prop_string(my_ctx, -1, "ref"); printf("popping final reference after breaking cycle\n"); fflush(stdout); duk_pop(my_ctx); printf("pop completed\n"); fflush(stdout); } printf("destroying heap\n"); fflush(stdout); duk_destroy_heap(my_ctx); printf("heap destroyed\n"); fflush(stdout); return 0; } #endif /* 0 */ void test(duk_context *ctx) { TEST_SAFE_CALL(test_heap_destruction); #if 0 TEST_SAFE_CALL(test_markandsweep_finalize_then_refzero); #endif }
57725e294067d8b39991ed18b70780b4b59fb6f7
d6ad41fd61abf03ecf0d7ed8528cf0814d10712a
/platforms/embedded/fomu/src/time.c
c7ab3f74f7224905fd7b6d5a6fd1698f4ddb8d65
[ "MIT" ]
permissive
wasm3/wasm3
1a21775d63b3c6b0ac71586cce3146398ad37c2a
772f8f4648fcba75f77f894a6050db121e7651a2
refs/heads/main
2023-08-24T21:46:17.842356
2023-03-26T17:23:54
2023-03-26T17:23:54
212,152,900
6,339
449
MIT
2023-08-07T11:27:56
2019-10-01T17:06:03
C
UTF-8
C
false
false
774
c
time.c
#include <generated/csr.h> #include <time.h> void time_init(void) { int t; timer0_en_write(0); t = 2*SYSTEM_CLOCK_FREQUENCY; timer0_reload_write(t); timer0_load_write(t); timer0_en_write(1); } int elapsed(int *last_event, int period) { int t, dt; timer0_update_value_write(1); t = timer0_reload_read() - timer0_value_read(); if(period < 0) { *last_event = t; return 1; } dt = t - *last_event; if(dt < 0) dt += timer0_reload_read(); if((dt > period) || (dt < 0)) { *last_event = t; return 1; } else return 0; } void msleep(int ms) { timer0_en_write(0); timer0_reload_write(0); timer0_load_write(SYSTEM_CLOCK_FREQUENCY/1000*ms); timer0_en_write(1); timer0_update_value_write(1); while(timer0_value_read()) timer0_update_value_write(1); }
2e29ce767f424bc6b1ecc91c26dc8e40714b3637
37d4423c0b464a84f90b716ceb8e8bfd0510a295
/runtime/gc/generational.h
5f4bc6ad3860fff49d3a03a9f90f4ed3f3ee3b2e
[ "SMLNJ" ]
permissive
UBMLtonGroup/RTMLton
01963d13032cdc35fac81381e98537bb16627e40
846b826008085c12724adc3e65ddcceff6d4f75f
refs/heads/conc-stacklets
2023-03-08T06:36:22.743693
2021-12-13T20:39:41
2021-12-13T20:39:41
44,258,707
114
4
NOASSERTION
2022-01-03T21:15:53
2015-10-14T15:48:38
Standard ML
UTF-8
C
false
false
3,703
h
generational.h
/* Copyright (C) 2009,2012 Matthew Fluet. * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh * Jagannathan, and Stephen Weeks. * Copyright (C) 1997-2000 NEC Research Institute. * * MLton is released under a BSD-style license. * See the file MLton-LICENSE for details. */ #if (defined (MLTON_GC_INTERNAL_TYPES)) /* must agree w/ cardSizeLog2 in ssa-to-rssa.fun */ #define CARD_SIZE_LOG2 8 #define CARD_SIZE TWOPOWER(CARD_SIZE_LOG2) typedef uint8_t GC_cardMapElem; typedef uint8_t GC_crossMapElem; typedef GC_cardMapElem *GC_cardMap; typedef GC_crossMapElem *GC_crossMap; typedef size_t GC_cardMapIndex; typedef size_t GC_crossMapIndex; #define CARD_MAP_ELEM_SIZE sizeof(GC_cardMapElem) #define CROSS_MAP_ELEM_SIZE sizeof(GC_crossMapElem) #define CROSS_MAP_EMPTY ((GC_crossMapElem)255) #define CROSS_MAP_OFFSET_SCALE 4 #define FMTCME "%"PRIu8 struct GC_generationalMaps { /* cardMap is an array with cardinality equal to the size of the * heap divided by card size. Each element in the array is * interpreted as a boolean; true indicates that some mutable field * of some object in the corresponding card in the heap has been * written since the last minor GC; hence, the corresponding card * must be traced at the next minor GC. */ GC_cardMap cardMap; GC_cardMap cardMapAbsolute; GC_cardMapIndex cardMapLength; /* crossMap is an array with cardinality equal to the size of the * heap divided by card size. Each element in the array is * interpreted as a byte offset (scaled by CARD_MAP_OFFSET_SCALE); * the offset indicates the start of the last object in the * corresponding card from the start of the card. */ GC_crossMap crossMap; GC_crossMapIndex crossMapLength; /* crossMapValidSize the size of the prefix of the old generation * for which the crossMap is valid. */ size_t crossMapValidSize; }; #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */ #if (defined (MLTON_GC_INTERNAL_FUNCS)) static void displayGenerationalMaps (GC_state s, struct GC_generationalMaps *generational, FILE *stream); static inline GC_cardMapIndex sizeToCardMapIndex (size_t z); static inline size_t cardMapIndexToSize (GC_cardMapIndex i); static inline GC_cardMapIndex pointerToCardMapIndexAbsolute (pointer p); static inline GC_cardMapElem *pointerToCardMapAddr (GC_state s, pointer p); static inline GC_crossMapIndex sizeToCrossMapIndex (size_t z); #if ASSERT static inline bool isCardMarked (GC_state s, pointer p); #endif static inline void markCard (GC_state s, pointer p); static inline void markIntergenerationalPointer (GC_state s, pointer *pp); static inline void markIntergenerationalObjptr (GC_state s, objptr *opp); static inline void setCardMapAbsolute (GC_state s); #if ASSERT static inline pointer getCrossMapCardStart (GC_state s, pointer p); #endif static inline size_t sizeofCardMap (GC_state s, size_t heapSize); static inline GC_cardMapIndex lenofCardMap (GC_state s, size_t cardMapSize); static inline size_t sizeofCrossMap (GC_state s, size_t heapSize); static inline GC_crossMapIndex lenofCrossMap (GC_state s, size_t crossMapSize); static size_t sizeofCardMapAndCrossMap (GC_state s, size_t heapSize); static size_t invertSizeofCardMapAndCrossMap (GC_state s, size_t heapWithMapsSize); static inline void clearCardMap (GC_state s); static inline void clearCrossMap (GC_state s); static inline void clearCardMapAndCrossMap (GC_state s); static void setCardMapAndCrossMap (GC_state s); #if ASSERT static bool isCrossMapOk (GC_state s); #endif static void updateCrossMap (GC_state s); #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */
25eb58d4806089a558d3e40573e1c75dffb6573d
98ebf9cb3e47e54c9f5ca3a21574ae423d90081c
/sw/example/demo_crc/main.c
79a384e87993e6152bdda3b82d4f25ee63c3bcd0
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
stnolting/neorv32
4a42ceae7a6bcbee4044ca50ab88f138025f1813
4cc0b8c296517e4b7c22296fe95253816a1dae55
refs/heads/main
2023-09-05T00:29:41.538253
2023-09-03T18:44:00
2023-09-03T18:44:00
274,442,284
1,224
210
BSD-3-Clause
2023-09-12T05:45:14
2020-06-23T15:29:41
VHDL
UTF-8
C
false
false
8,761
c
main.c
// ################################################################################################# // # << NEORV32 - CRC Unit Demo Program >> # // # ********************************************************************************************* # // # BSD 3-Clause License # // # # // # Copyright (c) 2023, Stephan Nolting. 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. # // # ********************************************************************************************* # // # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # // ################################################################################################# /**********************************************************************//** * @file demo_crc/main.c * @author Stephan Nolting * @brief CRC demo program. **************************************************************************/ #include <neorv32.h> /**********************************************************************//** * @name User configuration **************************************************************************/ /**@{*/ /** UART BAUD rate */ #define BAUD_RATE 19200 /**@}*/ // CRC test array const uint8_t test_string[] = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00}; /**********************************************************************//** * Simple demo program to showcase the NEORV32 CRC unit. * * @note This program requires UART0 and the CRC unit to be synthesized. * The DMA controller is optional. * * @return Irrelevant. **************************************************************************/ int main() { // setup NEORV32 runtime environment neorv32_rte_setup(); // setup UART at default baud rate, no interrupts neorv32_uart0_setup(BAUD_RATE, 0); // intro neorv32_uart0_printf("\n<<< CRC Unit Demo Program >>>\n\n"); // check if CRC unit is implemented at all if (neorv32_crc_available() == 0) { neorv32_uart0_printf("ERROR! CRC unit not implemented!\n"); return 1; } uint32_t result, polynomial, reference, seed; neorv32_uart0_printf("Test string: '%s'\n", test_string); // CRC8 example polynomial = 0x07; reference = 0x5b; // generated by http://www.sunshine2k.de/coding/javascript/crc/crc_js.html seed = 0x00; neorv32_crc_setup(CRC_MODE8, polynomial, seed); result = neorv32_crc_block((uint8_t*)test_string, sizeof(test_string)) & 0xff; neorv32_uart0_printf("\n[CRC8]\n"); neorv32_uart0_printf("Polynomial = 0x%x\n", polynomial); neorv32_uart0_printf("Seed = 0x%x\n", seed); neorv32_uart0_printf("Result = 0x%x ", result); if (result == reference) { neorv32_uart0_printf("[OK]\n"); } else { neorv32_uart0_printf("[FAILED]\n"); } // CRC16 example polynomial = 0x1021; reference = 0x96B9; // generated by http://www.sunshine2k.de/coding/javascript/crc/crc_js.html seed = 0x0000; neorv32_crc_setup(CRC_MODE16, polynomial, seed); result = neorv32_crc_block((uint8_t*)test_string, sizeof(test_string)) & 0xffff; neorv32_uart0_printf("\n[CRC16]\n"); neorv32_uart0_printf("Polynomial = 0x%x\n", polynomial); neorv32_uart0_printf("Seed = 0x%x\n", seed); neorv32_uart0_printf("Result = 0x%x ", result); if (result == reference) { neorv32_uart0_printf("[OK]\n"); } else { neorv32_uart0_printf("[FAILED]\n"); } // CRC32 example polynomial = 0x04C11DB7; reference = 0xF58D7B78; // generated by http://www.sunshine2k.de/coding/javascript/crc/crc_js.html seed = 0xFFFFFFFF; neorv32_crc_setup(CRC_MODE32, polynomial, seed); result = neorv32_crc_block((uint8_t*)test_string, sizeof(test_string)) & 0xffffffff; neorv32_uart0_printf("\n[CRC32]\n"); neorv32_uart0_printf("Polynomial = 0x%x\n", polynomial); neorv32_uart0_printf("Seed = 0x%x\n", seed); neorv32_uart0_printf("Result = 0x%x ", result); if (result == reference) { neorv32_uart0_printf("[OK]\n"); } else { neorv32_uart0_printf("[FAILED]\n"); } // CRC8 example using the DMA if (neorv32_dma_available() != 0) { uint32_t cmd; int rc; polynomial = 0x07; reference = 0x5b; // generated by http://www.sunshine2k.de/coding/javascript/crc/crc_js.html seed = 0x00; neorv32_crc_setup(CRC_MODE8, polynomial, seed); neorv32_uart0_printf("\n[CRC8] using DMA\n"); neorv32_uart0_printf("Polynomial = 0x%x\n", polynomial); neorv32_uart0_printf("Seed = 0x%x\n", seed); neorv32_dma_enable(); // configure transfer type cmd = DMA_CMD_B2UW | // read source in byte quantities, write destination in WORD(!!) quantities DMA_CMD_SRC_INC | // auto-increment source address DMA_CMD_DST_CONST; // constant destination address // configure automatic DMA transfer neorv32_dma_transfer((uint32_t)(&test_string[0]), // source array base address (data = 0xff) (uint32_t)(&NEORV32_CRC->DATA), // destination address = CRC data register (32-bit!) sizeof(test_string), // number of elements to transfer cmd); // transfer type configuration // wait for transfer to complete using polling neorv32_uart0_printf("Waiting for DMA... "); while (1) { rc = neorv32_dma_status(); if (rc == DMA_STATUS_IDLE) { neorv32_uart0_printf("Transfer done.\n"); break; } else if ((rc == DMA_STATUS_ERR_RD) || (rc == DMA_STATUS_ERR_WR)) { neorv32_uart0_printf("Transfer failed!\n"); break; } } // check DMA status rc = neorv32_dma_status(); if ((rc == DMA_STATUS_ERR_RD) || (rc == DMA_STATUS_ERR_WR)) { neorv32_uart0_printf("Transfer failed!\n"); } result = neorv32_crc_get() & 0xff; neorv32_uart0_printf("Result = 0x%x ", result); if (result == reference) { neorv32_uart0_printf("[OK]\n"); } else { neorv32_uart0_printf("[FAILED]\n"); } } neorv32_uart0_printf("\nProgram completed.\n"); return 0; }
6b9610700608f78e9d8dfbb16a3f573c08e723eb
e19509bd2548f173aa492d7498812afa28fcfbb5
/alib3/mp3lame/lame-ff.h
9a710b07447fe8dfe458919b8db083f7ba9f3f95
[ "BSD-2-Clause" ]
permissive
stsaz/fmedia
ef28a25e88ef50411014cfc7faef8813a67cf486
6f6d05fde4a6eba2f1fa0d9e194cd2b405258c3e
refs/heads/master
2023-08-19T20:30:03.512098
2023-07-24T16:37:33
2023-07-24T16:37:33
36,122,394
194
28
BSD-2-Clause
2022-07-19T15:09:24
2015-05-23T12:32:52
C
UTF-8
C
false
false
894
h
lame-ff.h
/** libmp3lame interface 2016, Simon Zolin */ #include <stdlib.h> #ifdef WIN32 #define _EXPORT __declspec(dllexport) #else #define _EXPORT __attribute__((visibility("default"))) #endif typedef struct lame lame; typedef struct lame_params { unsigned int format; unsigned int interleaved; unsigned int channels; unsigned int rate; unsigned int quality; } lame_params; #ifdef __cplusplus extern "C" { #endif _EXPORT const char* lame_errstr(int e); /** Return 0 on success. */ _EXPORT int lame_create(lame **lm, lame_params *conf); _EXPORT void lame_free(lame *lm); /** Return the number of bytes written; 0 if more data is needed; <0 on error. */ _EXPORT int lame_encode(lame *lm, const void **pcm, unsigned int samples, char *buf, size_t cap); /** Get LAME-tag frame. */ _EXPORT int lame_lametag(lame *lm, char *buf, size_t cap); #ifdef __cplusplus } #endif #undef _EXPORT
6c55b6d19e6b17fd7697c3cf6e91402566932f4a
fb47ab6337a71029dee71933e449cf7f6805fc0f
/arch/arm/include/arch/spinlock.h
48a21fcbbbb22cea135acf863f54e8f5fca67fb2
[ "MIT" ]
permissive
littlekernel/lk
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
30dc320054f70910e1c1ee40a6948ee99672acec
refs/heads/master
2023-09-02T00:47:52.203963
2023-06-21T22:42:35
2023-06-21T22:42:35
3,058,456
3,077
618
MIT
2023-08-30T09:41:31
2011-12-27T19:19:36
C
UTF-8
C
false
false
3,678
h
spinlock.h
/* * Copyright (c) 2014 Travis Geiselbrecht * * Use of this source code is governed by a MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT */ #pragma once #include <lk/compiler.h> #include <assert.h> #include <arch/ops.h> #include <stdbool.h> __BEGIN_CDECLS #define SPIN_LOCK_INITIAL_VALUE (0) typedef unsigned long spin_lock_t; typedef unsigned long spin_lock_saved_state_t; typedef unsigned long spin_lock_save_flags_t; static inline void arch_spin_lock_init(spin_lock_t *lock) { *lock = SPIN_LOCK_INITIAL_VALUE; } static inline bool arch_spin_lock_held(spin_lock_t *lock) { return *lock != 0; } #if WITH_SMP void arch_spin_lock(spin_lock_t *lock); int arch_spin_trylock(spin_lock_t *lock); void arch_spin_unlock(spin_lock_t *lock); #else /* Non-SMP spinlocks are mostly vestigial to try to catch pending locking problems. */ static inline void arch_spin_lock(spin_lock_t *lock) { DEBUG_ASSERT(arch_ints_disabled()); DEBUG_ASSERT(*lock == 0); *lock = 1; } static inline int arch_spin_trylock(spin_lock_t *lock) { DEBUG_ASSERT(arch_ints_disabled()); DEBUG_ASSERT(*lock == 0); return 0; } static inline void arch_spin_unlock(spin_lock_t *lock) { DEBUG_ASSERT(arch_ints_disabled()); DEBUG_ASSERT(*lock != 0); *lock = 0; } #endif #if !(ARM_ISA_ARMV7M || ARM_ISA_ARMV6M) /* ARM specific flags */ #define SPIN_LOCK_FLAG_IRQ 0x40000000 #define SPIN_LOCK_FLAG_FIQ 0x80000000 /* Do not use unless IRQs are already disabled */ #define SPIN_LOCK_FLAG_IRQ_FIQ (SPIN_LOCK_FLAG_IRQ | SPIN_LOCK_FLAG_FIQ) /* default arm flag is to just disable plain irqs */ #define ARCH_DEFAULT_SPIN_LOCK_FLAG_INTERRUPTS SPIN_LOCK_FLAG_IRQ enum { /* private */ SPIN_LOCK_STATE_RESTORE_IRQ = 1, SPIN_LOCK_STATE_RESTORE_FIQ = 2, }; static inline void arch_interrupt_save(spin_lock_saved_state_t *statep, spin_lock_save_flags_t flags) { spin_lock_saved_state_t state = 0; if ((flags & SPIN_LOCK_FLAG_IRQ) && !arch_ints_disabled()) { state |= SPIN_LOCK_STATE_RESTORE_IRQ; arch_disable_ints(); } if ((flags & SPIN_LOCK_FLAG_FIQ) && !arch_fiqs_disabled()) { state |= SPIN_LOCK_STATE_RESTORE_FIQ; arch_disable_fiqs(); } *statep = state; } static inline void arch_interrupt_restore(spin_lock_saved_state_t old_state, spin_lock_save_flags_t flags) { if ((flags & SPIN_LOCK_FLAG_FIQ) && (old_state & SPIN_LOCK_STATE_RESTORE_FIQ)) arch_enable_fiqs(); if ((flags & SPIN_LOCK_FLAG_IRQ) && (old_state & SPIN_LOCK_STATE_RESTORE_IRQ)) arch_enable_ints(); } #else /* * slightly more optimized version of the interrupt save/restore bits for cortex-m * processors. */ /* arm-m flags are mostly meaningless */ #define ARCH_INTERRUPT_SAVE_IRQ 1 #define ARCH_DEFAULT_SPIN_LOCK_FLAG_INTERRUPTS ARCH_INTERRUPT_SAVE_IRQ __ALWAYS_INLINE static inline void arch_interrupt_save(spin_lock_saved_state_t *statep, spin_lock_save_flags_t flags) { unsigned int state = 0; if (flags == ARCH_INTERRUPT_SAVE_IRQ) { __asm__ volatile("mrs %0, primask" : "=r"(state)); /* always disable ints, may be faster than testing and branching around it */ arch_disable_ints(); } *statep = state; } __ALWAYS_INLINE static inline void arch_interrupt_restore(spin_lock_saved_state_t old_state, spin_lock_save_flags_t flags) { /* test the PRIMASK's one bit */ if (flags == ARCH_INTERRUPT_SAVE_IRQ) { if ((old_state & 0x1) == 0) { arch_enable_ints(); } } } #endif __END_CDECLS
282141eb08734701c7a799121add93978ede7b6a
f36fdf1955e7a0738dac3cb62f858d1b5f9d5c11
/src/spice2delay.c
734ff0741b96ebdd69c4b18e969d1ae52b3e6460
[]
no_license
RTimothyEdwards/qflow
52c1b573289baae35fd641267c69b1ad08a7ea53
b0f76bf4b7dddd59badd67f462e50ed8c9be484c
refs/heads/master
2023-08-05T23:27:33.802670
2022-11-29T16:30:47
2022-11-29T16:30:47
177,686,597
155
44
null
2022-03-31T19:38:25
2019-03-26T00:37:17
C
UTF-8
C
false
false
21,495
c
spice2delay.c
// spice2delay // // // // // // // // Todo // 2) double check all read in c and r values for units #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "hash.h" #include "readliberty.h" /* liberty file database */ #define SRC 0x01 // node is a driver #define SNK 0x02 // node is a receiver #define INT 0x03 // node is internal to an interconnect typedef struct _cell_io *cell_io_ptr; typedef struct _cell_io { char *name; pinptr *pins; cell_io_ptr next; } cell_io; typedef struct _r *rptr; typedef struct _node *nodeptr; typedef struct _r { char *name; nodeptr node1; nodeptr node2; double rval; } r; typedef struct _ritem* ritemptr; typedef struct _ritem { rptr r; ritemptr next; } ritem; typedef struct _node { char* name; int type; ritemptr rlist; double nodeCap; double totCapDownstream; short visited; } node; typedef struct _node_item *node_item_ptr; typedef struct _node_item { nodeptr node; node_item_ptr next; } node_item; typedef struct _snk* snkptr; typedef struct _snk { nodeptr snknode; double delay; snkptr next; } snk; typedef struct _elmdly* elmdlyptr; typedef struct _elmdly { nodeptr src; snkptr snklist; } elmdly; void print_help () { } char** tokenize_line (char *line, const char *delims, char*** tokens_ptr, int *num_toks) { int buff_sz = 4; char **tokens = calloc(buff_sz, sizeof(char*)); int i = 0; tokens[i] = strtok(line, delims); i++; for (i = 1; tokens[i-1] != NULL; i++) { if (i == buff_sz) { buff_sz *= 2; tokens = realloc(tokens, sizeof(char*) * buff_sz); } *num_toks = i; tokens[i] = strtok(NULL, delims); } /**tokens_ptr = tokens;*/ return tokens; } void process_subckt_def(char **tokens, int num_toks, Cell *cells, cell_io_ptr *cell_io_ptrptr) { int i; Cell *cell; cell_io_ptr new_cell_io = calloc(1, sizeof(cell_io)); new_cell_io->name = calloc((strlen(tokens[1]) + 1), sizeof(char)); new_cell_io->next = NULL; strcpy(new_cell_io->name, tokens[1]); new_cell_io->pins = calloc((num_toks - 2), sizeof(Pin*)); cell = get_cell_by_name(cells, tokens[1]); for (i = 2; i < num_toks; i++) { new_cell_io->pins[i-2] = get_pin_by_name(cell, tokens[i]); } if (*cell_io_ptrptr == NULL) { *cell_io_ptrptr = new_cell_io; } else { cell_io_ptr curr_cell_io = (*cell_io_ptrptr); while (curr_cell_io->next != NULL) { curr_cell_io = curr_cell_io->next; } curr_cell_io->next = new_cell_io; } } nodeptr create_node (char *name, int type, double nodeCap) { nodeptr new_node = calloc(1, sizeof(node)); new_node->name = calloc(strlen(name) + 1, sizeof(char)); strcpy(new_node->name, name); new_node->type = type; new_node->nodeCap = nodeCap; return new_node; } void add_ritem (ritemptr *ritem_list_ptr, rptr r) { ritemptr next = calloc(1, sizeof(ritem)); next->r = r; // list has no items if (*ritem_list_ptr == NULL) { *ritem_list_ptr = next; } else { // list has some items, we need to find the end ritemptr i; for (i = *ritem_list_ptr; i->next != NULL; i = i->next); i->next = next; } } void process_subckt_inst(char **tokens, int num_toks, cell_io_ptr cell_io, struct hashtable *Nodehash, node_item_ptr **last_driver_ptr, int *numDrivers) { nodeptr curr_node = NULL; node_item_ptr next_src_item = NULL; int pin_type = 0; // find cell name in cell_io_list to know about pin order while(strcmp(cell_io->name, tokens[num_toks-1])) { cell_io = cell_io->next; if (cell_io == NULL) { fprintf(stderr, "Did not find stdcell %s in cell IO linked list.\n", tokens[num_toks-1]); exit(1); } } // Iterate over list of pins processing ones that were found in Liberty file // foreach pin // -if not in hash, create and add to hash // -if in hash, update connections, verify polarity / pin type correct, etc int i; // skip instance name (first token) and std cell name (last token) for (i = 1; i < num_toks-1; i++) { if (cell_io->pins[i-1] != NULL) { curr_node = HashLookup(tokens[i], Nodehash); if (cell_io->pins[i-1]->type == PIN_INPUT) { pin_type = SNK; } else if (cell_io->pins[i-1]->type == PIN_OUTPUT) { pin_type = SRC; } else { fprintf(stderr, "Pin type is not recognized\n"); } if (curr_node == NULL) { // this is a new node we need to create and add to hash curr_node = create_node(tokens[i], pin_type, cell_io->pins[i-1]->cap); HashPtrInstall(curr_node->name, curr_node, Nodehash); printf("install new node\n"); curr_node = NULL; curr_node = HashLookup(tokens[i], Nodehash); } else { if ( ((curr_node->type == SRC) && (pin_type == SNK)) || ((curr_node->type == SNK) && (pin_type == SRC)) ) { fprintf(stderr, "Pin type for node %s changed polarity!\n", curr_node->name); } curr_node->type = pin_type; fprintf(stdout, "Node capacitance changed from %f to %f\n", curr_node->nodeCap, curr_node->nodeCap + cell_io->pins[i-1]->cap); curr_node->nodeCap += cell_io->pins[i-1]->cap; } // add node to list of drivers if the node is a SRC if (curr_node->type == SRC) { printf("found driver\n"); next_src_item = calloc(1, sizeof(node_item)); next_src_item->node = curr_node; **last_driver_ptr = next_src_item; *last_driver_ptr = &next_src_item->next; *numDrivers = *numDrivers + 1; } } } } double spiceValtoD(char *string) { char *endptr = string; double rtrnVal = 0; double suffix = 1; // find end of numbers int i = 0; while (string[i] != 0) { if ( string[i] == '.' || (string[i] >= 0x30 && string[i] <= 0x39) ) { i++; } else { i--; break; } } endptr += i * sizeof(char); rtrnVal = strtod(string, &endptr); if (endptr[0] == 'f') { suffix = 1E-15; } else if (endptr[0] == 'p') { suffix = 1E-12; } else if (endptr[0] == 'n') { suffix = 1E-9; } else if (endptr[0] == 'u') { suffix = 1E-6; } else if (endptr[0] == 'm') { suffix = 1E-3; } else if (endptr[0] == 'k') { suffix = 1E3; } else { suffix = 1; } rtrnVal *= suffix; return rtrnVal; } void process_r(char **tokens, int num_toks, struct hashtable *Nodehash, ritemptr *fullrlist) { // create ritem which captures the resistor and the connection between two nodes // for each node // if node does not exist, create it // add resistor to each node's list of resistors (connections to other nodes) // add resistor to global list of resistors rptr curr_r = NULL; nodeptr curr_node = NULL; curr_r = calloc(1, sizeof(r)); curr_r->name = calloc(strlen(tokens[0]) + 1, sizeof(char)); strcpy(curr_r->name, tokens[0]); curr_r->rval = spiceValtoD(tokens[num_toks-1]); int i; // skip instance name (first token) and resistance value (last token) for (i = 1; i < num_toks-1; i++) { curr_node = HashLookup(tokens[i], Nodehash); if (curr_node == NULL) { // this is a new node we need to create and add to hash curr_node = create_node(tokens[i], INT, 0); HashPtrInstall(curr_node->name, curr_node, Nodehash); printf("install new node\n"); curr_node = NULL; curr_node = HashLookup(tokens[i], Nodehash); } if (i == 1) { curr_r->node1 = curr_node; } else { curr_r->node2 = curr_node; } add_ritem(&curr_node->rlist, curr_r); } add_ritem(fullrlist, curr_r); } void process_c(char **tokens, int num_toks, struct hashtable *Nodehash) { // // change capacitance units to farads // // for each node // if node does not exist, create it // add capacitance value to node capacitance total nodeptr curr_node = NULL; // keep all capacitance values in fF to match readliberty.c double cVal = spiceValtoD(tokens[num_toks-1]) * 1E15; int i; // skip instance name (first token) and capacitance value (last token) for (i = 1; i < num_toks-1; i++) { curr_node = HashLookup(tokens[i], Nodehash); if (curr_node == NULL) { // this is a new node we need to create and add to hash curr_node = create_node(tokens[i], INT, 0); HashPtrInstall(curr_node->name, curr_node, Nodehash); printf("install new node\n"); curr_node = NULL; curr_node = HashLookup(tokens[i], Nodehash); } curr_node->nodeCap += cVal; } } // for multi-driver nets, must not recurse finding another driver void sum_downstream_cap(nodeptr curr_node, nodeptr prev_node, short breadcrumbVal) { ritemptr curr_ritem = curr_node->rlist; while (curr_ritem != NULL) { // make sure to not backtrack to previous node // make sure to not recurse on the current node if ( (curr_ritem->r->node1 != prev_node) && (curr_ritem->r->node1 != curr_node) ) { sum_downstream_cap(curr_ritem->r->node1, curr_node, breadcrumbVal); curr_node->totCapDownstream += (curr_ritem->r->node1->totCapDownstream + curr_ritem->r->node1->nodeCap); } else if ( (curr_ritem->r->node2 != prev_node) && (curr_ritem->r->node2 != curr_node) ) { sum_downstream_cap(curr_ritem->r->node2, curr_node, breadcrumbVal); curr_node->totCapDownstream += (curr_ritem->r->node2->totCapDownstream + curr_ritem->r->node2->nodeCap); } curr_ritem = curr_ritem->next; } } void add_snk (snkptr *snk_list_ptr, snkptr snk) { // list has no items if (*snk_list_ptr == NULL) { *snk_list_ptr = snk; } else { // list has some items, we need to find the end snkptr i; for (i = *snk_list_ptr; i->next != NULL; i = i->next); i->next = snk; } } void calculate_elmore_delay ( nodeptr curr_node, nodeptr prev_node, rptr prev_r, // the connection used to get curr_node elmdlyptr curr_elmdly, /*snkptr curr_snk,*/ double firstR, double elmdly, short breadcrumbVal ) { // -recursively walk each branch of nodes // -accumulate delay on each branch // -append to Elmore Delay list when sink node reached // accumulate delay // -first node uses a model resistor based on typical output drive strengths // of stdcell librarie // -subsequent nodes us the resistor that was traveled to arrive at current // node if (curr_node->type == SRC) { elmdly = firstR * (curr_node->nodeCap + curr_node->totCapDownstream); } else { elmdly = prev_r->rval * (curr_node->nodeCap + curr_node->totCapDownstream); } // -if current node is an input to another cell, this is an endpoint and the // current delay value needs to be saved // -there still might be other connections though that need to be traversed // to find other endpoints if (curr_node->type == SNK) { printf("Found SNK node %s with delay to it of %lf\n", curr_node->name, elmdly); snkptr curr_snk = calloc(1, sizeof(snk)); curr_snk->snknode = curr_node; curr_snk->delay = elmdly; add_snk(&curr_elmdly->snklist, curr_snk); } ritemptr curr_ritem = curr_node->rlist; while (curr_ritem != NULL) { // make sure to not backtrack to previous node // make sure to not recurse on the current node if ( (curr_ritem->r->node1 != prev_node) && (curr_ritem->r->node1 != curr_node) ) { calculate_elmore_delay(curr_ritem->r->node1, curr_node, curr_ritem->r, curr_elmdly, firstR, elmdly, breadcrumbVal); } else if ( (curr_ritem->r->node2 != prev_node) && (curr_ritem->r->node2 != curr_node) ) { calculate_elmore_delay(curr_ritem->r->node2, curr_node, curr_ritem->r, curr_elmdly, firstR, elmdly, breadcrumbVal); } curr_ritem = curr_ritem->next; } } int main (int argc, char* argv[]) { FILE* outfile = NULL; FILE* libfile = NULL; FILE* spcfile = NULL; int i, opt; int verbose = 0; Cell *cells, *newcell; Pin *newpin; char* libfilename; nodeptr currnode = NULL; // -Maintain a list of all nodes that are outputs / drivers. // -Iterate over the list to walk each interconnect to calculate // Elmore Delay node_item_ptr drivers = NULL; node_item_ptr *last_driver = &drivers; int numDrivers = 0; // list of all Rs for debugging and to easily free them at end ritemptr allrs = NULL; struct hashtable Nodehash; /* See hash.c for these routines and variables */ hashfunc = hash; matchfunc = match; /* Initialize net hash table */ InitializeHashTable(&Nodehash, LARGEHASHSIZE); // create first item in cell io list cell_io_ptr cell_io_list = NULL; while ((opt = getopt(argc, argv, "s:l:o:v:")) != -1) { switch (opt) { case 's': spcfile = fopen(optarg, "r"); if (!spcfile) { fprintf(stderr, "Can't open outfile`%s': %s\n", optarg, strerror(errno)); } break; case 'l': libfile = fopen(optarg, "r"); libfilename = strdup(optarg); if (!libfile) { fprintf(stderr, "Can't open outfile`%s': %s\n", optarg, strerror(errno)); } break; case 'o': if (!strcmp(optarg, "-")) { outfile = stdout; } else { outfile = fopen(optarg, "w"); } if (!outfile) { fprintf(stderr, "Can't open outfile`%s': %s\n", optarg, strerror(errno)); } break; case 'v': verbose = atoi(optarg); break; default: print_help(); break; } } // Read in Liberty File printf("%s\n", libfilename); cells = read_liberty(libfilename, 0); if (verbose > 0) { for (newcell = cells; newcell; newcell = newcell->next) { fprintf(stdout, "Cell: %s\n", newcell->name); fprintf(stdout, " Function: %s\n", newcell->function); for (newpin = newcell->pins; newpin; newpin = newpin->next) { fprintf(stdout, " Pin: %s cap=%g\n", newpin->name, newpin->cap); } fprintf(stdout, "\n"); } } char *line; size_t nbytes = LIB_LINE_MAX; line = calloc(1, LIB_LINE_MAX); int bytesRead = 0; const char delims[3] = " \n"; char **tokens; int num_toks = 0; bytesRead = getline(&line, &nbytes, spcfile); while (bytesRead > 0) { // skip blank lines if (bytesRead > 2) { tokens = tokenize_line(line, delims, &tokens, &num_toks); /*tokenize_line(line, delims, &tokens, &num_toks);*/ if (!(strncmp(line, "R", 1))) { printf("located resistor line\n"); process_r(tokens, num_toks, &Nodehash, &allrs); } else if (!(strncmp(line, "C", 1))) { printf("located capacitor line\n"); process_c(tokens, num_toks, &Nodehash); } else if (!(strncmp(line, "X", 1))) { printf("located subckt instantiation line\n"); printf("number of hash entries %d\n", RecurseHashTable(&Nodehash, CountHashTableEntries)); process_subckt_inst(tokens, num_toks, cell_io_list, &Nodehash, &last_driver, &numDrivers); printf("number of hash entries %d\n", RecurseHashTable(&Nodehash, CountHashTableEntries)); } else if (!(strncmp(line, ".subckt", 7))) { printf("located subckt definition line\n"); process_subckt_def(tokens, num_toks, cells, &cell_io_list); /*free(tokens);*/ // read through the rest of the subckt definition while (strncmp(line, ".ends", 4)) { getline(&line, &nbytes, spcfile); } /*break;*/ } else if (!(strncmp(line, "*", 1))) { printf("located comment line\n"); } } /*free(tokens);*/ bytesRead = getline(&line, &nbytes, spcfile); } // Walk each interconnect to calculate downstream capacitance at each node node_item_ptr curr_node_item = drivers; short breadcrumbVal = 1; elmdlyptr delays = calloc(numDrivers, sizeof(elmdly)); int driverIndex = 0; printf("Number of drivers is %d\n", numDrivers); printf("Sum downstream capacitance for each node\n"); printf("Calculate Elmore Delay for each driver\n"); while (curr_node_item != NULL) { sum_downstream_cap(curr_node_item->node, NULL, breadcrumbVal); if (curr_node_item->node->type == SRC) { (&delays[driverIndex])->src = curr_node_item->node; calculate_elmore_delay( curr_node_item->node, NULL, NULL, &delays[driverIndex], /*NULL,*/ 1, 0, breadcrumbVal ); driverIndex++; } breadcrumbVal++; curr_node_item = curr_node_item->next; } currnode = HashFirst(&Nodehash); while (currnode != NULL) { printf("%s\t\t%f\t%f\n", currnode->name, currnode->nodeCap, currnode->totCapDownstream); currnode = HashNext(&Nodehash); } node_item_ptr curr_driver = drivers; while (curr_driver != NULL) { curr_driver = curr_driver->next; } elmdlyptr curr_elmdly = NULL; snkptr tmp_snk = NULL; snkptr curr_snk = NULL; for (driverIndex = 0; driverIndex < numDrivers; driverIndex++) { curr_elmdly = &delays[driverIndex]; printf("%s\n%s %f\n", curr_elmdly->src->name, curr_elmdly->src->name, curr_elmdly->src->nodeCap + curr_elmdly->src->totCapDownstream); fprintf(outfile, "%s\n%s %f\n", curr_elmdly->src->name, curr_elmdly->src->name, curr_elmdly->src->nodeCap + curr_elmdly->src->totCapDownstream); curr_snk = curr_elmdly->snklist; while(curr_snk != NULL) { printf("%s %f\n", curr_snk->snknode->name, curr_snk->delay); fprintf(outfile, "%s %f\n", curr_snk->snknode->name, curr_snk->delay); curr_snk = curr_snk->next; } printf("\n"); fprintf(outfile, "\n"); } // Cleanup for (driverIndex = 0; driverIndex < numDrivers; driverIndex++) { curr_elmdly = &delays[driverIndex]; curr_snk = curr_elmdly->snklist; while(curr_snk != NULL) { tmp_snk = curr_snk->next; free(curr_snk); curr_snk = tmp_snk; } } free(delays); ritemptr tmp_ritem = allrs; rptr tmp_r = NULL; int numRs = 0; while(allrs != NULL) { numRs++; tmp_ritem = allrs->next; free(allrs->r->name); free(allrs->r); free(allrs); allrs = tmp_ritem; } printf("Number of Rs: %d\n", numRs); currnode = HashFirst(&Nodehash); int numNodes = 0; while (currnode != NULL) { numNodes++; numRs = 0; while(currnode->rlist != NULL) { numRs++; tmp_ritem = currnode->rlist->next; free(currnode->rlist); currnode->rlist = tmp_ritem; } printf("Node %s had %d Rs attached\n", currnode->name, numRs); free(currnode->name); free(currnode); currnode = HashNext(&Nodehash); } printf("Number of nodes: %d\n", numNodes); free(line); while(drivers != NULL) { curr_driver = drivers->next; free(drivers); drivers = curr_driver; } cell_io_ptr tmp_cell_io; while(cell_io_list != NULL) { tmp_cell_io = cell_io_list->next; free(cell_io_list->name); free(cell_io_list->pins); free(cell_io_list); cell_io_list = tmp_cell_io; } delete_cell_list(cells); fclose(spcfile); fclose(libfile); fclose(outfile); return 0; }
95f2743e948590fbf0aef6dbe97568cd62ff65c2
b01b4365ab6c9afeb6664563dd314df4f269014f
/libsh/exec.c
b977e5ce3f03d9e330c8c2d830d6de86fa82bc0a
[ "MIT" ]
permissive
malxau/yori
6208011ca60485cfbf141c7639e9f941a160e002
027f9b42c08cc5fcc682ecb7fb67e6de5363b8de
refs/heads/master
2023-09-01T13:11:19.083028
2023-08-28T00:00:02
2023-08-28T00:00:02
127,679,677
1,234
31
MIT
2023-04-23T04:54:56
2018-04-01T23:29:17
C
UTF-8
C
false
false
26,360
c
exec.c
/** * @file /libsh/exec.c * * Yori shell helper routines for executing programs * * Copyright (c) 2017-2021 Malcolm J. Smith * * 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 <yoripch.h> #include <yorilib.h> #include <yorish.h> /** Capture the current handles used for stdin/stdout/stderr. @param RedirectContext Pointer to the block to capture current state into. */ VOID YoriLibShCaptureRedirectContext( __out PYORI_LIBSH_PREVIOUS_REDIRECT_CONTEXT RedirectContext ) { RedirectContext->ResetInput = FALSE; RedirectContext->ResetOutput = FALSE; RedirectContext->ResetError = FALSE; RedirectContext->StdErrRedirectsToStdOut = FALSE; RedirectContext->StdOutRedirectsToStdErr = FALSE; // // Always duplicate as noninherited. If we don't override one of the // existing stdin/stdout/stderr values then the original inheritance // is still in effect. These are only used to restore our process. // RedirectContext->StdInput = GetStdHandle(STD_INPUT_HANDLE); RedirectContext->StdOutput = GetStdHandle(STD_OUTPUT_HANDLE); RedirectContext->StdError = GetStdHandle(STD_ERROR_HANDLE); } /** Revert the redirection context previously put in place by a call to @ref YoriLibShInitializeRedirection. @param PreviousRedirectContext The context to revert to. */ VOID YoriLibShRevertRedirection( __in PYORI_LIBSH_PREVIOUS_REDIRECT_CONTEXT PreviousRedirectContext ) { YORI_LIBSH_PREVIOUS_REDIRECT_CONTEXT CurrentRedirectContext; YoriLibCancelInheritedIgnore(); YoriLibShCaptureRedirectContext(&CurrentRedirectContext); if (PreviousRedirectContext->ResetInput) { SetStdHandle(STD_INPUT_HANDLE, PreviousRedirectContext->StdInput); CloseHandle(CurrentRedirectContext.StdInput); } if (PreviousRedirectContext->ResetOutput) { SetStdHandle(STD_OUTPUT_HANDLE, PreviousRedirectContext->StdOutput); if (!PreviousRedirectContext->StdOutRedirectsToStdErr) { CloseHandle(CurrentRedirectContext.StdOutput); } } if (PreviousRedirectContext->ResetError) { SetStdHandle(STD_ERROR_HANDLE, PreviousRedirectContext->StdError); if (!PreviousRedirectContext->StdErrRedirectsToStdOut) { CloseHandle(CurrentRedirectContext.StdError); } } } /** Temporarily set this process to have the same stdin/stdout/stderr as a a program that it intends to launch. Keep information about the current stdin/stdout/stderr in PreviousRedirectContext so that it can be restored with a later call to @ref YoriLibShRevertRedirection. If any error occurs, the Win32 error code is returned and redirection is restored to its original state. @param ExecContext The context of the program whose stdin/stdout/stderr should be initialized. @param PrepareForBuiltIn If TRUE, leave Ctrl+C handling suppressed. The builtin program is free to enable it if it has long running processing to perform, and it can install its own handler. @param PreviousRedirectContext On successful completion, this is populated with the current stdin/stdout/stderr information so that it can be restored later. @return ERROR_SUCCESS to indicate that redirection has been completely initialized, or a Win32 error code indicating if an error has occurred. */ DWORD YoriLibShInitializeRedirection( __in PYORI_LIBSH_SINGLE_EXEC_CONTEXT ExecContext, __in BOOL PrepareForBuiltIn, __out PYORI_LIBSH_PREVIOUS_REDIRECT_CONTEXT PreviousRedirectContext ) { SECURITY_ATTRIBUTES InheritHandle; HANDLE Handle; DWORD Error; ZeroMemory(&InheritHandle, sizeof(InheritHandle)); InheritHandle.nLength = sizeof(InheritHandle); InheritHandle.bInheritHandle = TRUE; YoriLibShCaptureRedirectContext(PreviousRedirectContext); // // MSFIX: What this is doing is allowing child processes to see Ctrl+C, // which is wrong, because we only want the foreground process to see it // which implies handling it in the shell. Unfortunately // GenerateConsoleCtrlEvent has a nasty bug where it can only safely be // called on console processes remaining in this console, which will // require more processing to determine. // if (!PrepareForBuiltIn) { YoriLibSetInputConsoleModeWithoutExtended(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); YoriLibCancelInheritedProcess(); } Error = ERROR_SUCCESS; if (ExecContext->StdInType == StdInTypeFile) { Handle = CreateFile(ExecContext->StdIn.File.FileName.StartOfString, GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetInput = TRUE; SetStdHandle(STD_INPUT_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdInType == StdInTypeNull) { Handle = CreateFile(_T("NUL"), GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetInput = TRUE; SetStdHandle(STD_INPUT_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdInType == StdInTypePipe) { if (ExecContext->StdIn.Pipe.PipeFromPriorProcess != NULL) { HANDLE NewHandle; if (!YoriLibMakeInheritableHandle(ExecContext->StdIn.Pipe.PipeFromPriorProcess, &NewHandle)) { Error = GetLastError(); } else { PreviousRedirectContext->ResetInput = TRUE; SetStdHandle(STD_INPUT_HANDLE, NewHandle); ExecContext->StdIn.Pipe.PipeFromPriorProcess = NULL; } } else { HANDLE ReadHandle; HANDLE WriteHandle; HANDLE NewHandle; if (CreatePipe(&ReadHandle, &WriteHandle, NULL, 0)) { if (!YoriLibMakeInheritableHandle(ReadHandle, &NewHandle)) { Error = GetLastError(); CloseHandle(ReadHandle); CloseHandle(WriteHandle); } else { PreviousRedirectContext->ResetInput = TRUE; SetStdHandle(STD_INPUT_HANDLE, NewHandle); CloseHandle(WriteHandle); } } else { Error = GetLastError(); } } } if (Error != ERROR_SUCCESS) { YoriLibShRevertRedirection(PreviousRedirectContext); return Error; } if (ExecContext->StdOutType == StdOutTypeOverwrite) { Handle = CreateFile(ExecContext->StdOut.Overwrite.FileName.StartOfString, GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetOutput = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdOutType == StdOutTypeAppend) { Handle = CreateFile(ExecContext->StdOut.Append.FileName.StartOfString, FILE_APPEND_DATA|SYNCHRONIZE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetOutput = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdOutType == StdOutTypeNull) { Handle = CreateFile(_T("NUL"), GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetOutput = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdOutType == StdOutTypePipe) { HANDLE ReadHandle; HANDLE WriteHandle; HANDLE NewHandle; if (ExecContext->NextProgram != NULL && ExecContext->NextProgram->StdInType == StdInTypePipe) { if (CreatePipe(&ReadHandle, &WriteHandle, NULL, 0)) { if (!YoriLibMakeInheritableHandle(WriteHandle, &NewHandle)) { Error = GetLastError(); CloseHandle(ReadHandle); CloseHandle(WriteHandle); } else { PreviousRedirectContext->ResetOutput = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, NewHandle); ExecContext->NextProgram->StdIn.Pipe.PipeFromPriorProcess = ReadHandle; } } else { Error = GetLastError(); } } } else if (ExecContext->StdOutType == StdOutTypeBuffer) { HANDLE ReadHandle; HANDLE WriteHandle; HANDLE NewHandle; if (CreatePipe(&ReadHandle, &WriteHandle, NULL, 0)) { if (!YoriLibMakeInheritableHandle(WriteHandle, &NewHandle)) { Error = GetLastError(); CloseHandle(ReadHandle); CloseHandle(WriteHandle); } else { PreviousRedirectContext->ResetOutput = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, NewHandle); ExecContext->StdOut.Buffer.PipeFromProcess = ReadHandle; } } else { Error = GetLastError(); } } if (Error != ERROR_SUCCESS) { YoriLibShRevertRedirection(PreviousRedirectContext); return Error; } if (ExecContext->StdErrType == StdErrTypeOverwrite) { Handle = CreateFile(ExecContext->StdErr.Overwrite.FileName.StartOfString, GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetError = TRUE; SetStdHandle(STD_ERROR_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdErrType == StdErrTypeAppend) { Handle = CreateFile(ExecContext->StdErr.Append.FileName.StartOfString, FILE_APPEND_DATA|SYNCHRONIZE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetError = TRUE; SetStdHandle(STD_ERROR_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdErrType == StdErrTypeNull) { Handle = CreateFile(_T("NUL"), GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ, &InheritHandle, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); if (Handle != INVALID_HANDLE_VALUE) { PreviousRedirectContext->ResetError = TRUE; SetStdHandle(STD_ERROR_HANDLE, Handle); } else { Error = GetLastError(); } } else if (ExecContext->StdErrType == StdErrTypeBuffer) { HANDLE ReadHandle; HANDLE WriteHandle; HANDLE NewHandle; if (CreatePipe(&ReadHandle, &WriteHandle, NULL, 0)) { if (!YoriLibMakeInheritableHandle(WriteHandle, &NewHandle)) { Error = GetLastError(); CloseHandle(ReadHandle); CloseHandle(WriteHandle); } else { PreviousRedirectContext->ResetError = TRUE; SetStdHandle(STD_ERROR_HANDLE, NewHandle); ExecContext->StdErr.Buffer.PipeFromProcess = ReadHandle; } } else { Error = GetLastError(); } } if (Error != ERROR_SUCCESS) { YoriLibShRevertRedirection(PreviousRedirectContext); return Error; } if (ExecContext->StdErrType == StdErrTypeStdOut) { ASSERT(ExecContext->StdOutType != StdOutTypeStdErr); PreviousRedirectContext->ResetError = TRUE; PreviousRedirectContext->StdErrRedirectsToStdOut = TRUE; SetStdHandle(STD_ERROR_HANDLE, GetStdHandle(STD_OUTPUT_HANDLE)); } else if (ExecContext->StdOutType == StdOutTypeStdErr) { PreviousRedirectContext->ResetOutput = TRUE; PreviousRedirectContext->StdOutRedirectsToStdErr = TRUE; SetStdHandle(STD_OUTPUT_HANDLE, GetStdHandle(STD_ERROR_HANDLE)); } return ERROR_SUCCESS; } /** Given a process that has been launched and is currently suspended, examine its in memory state to determine which subsystem the process will operate in. @param ProcessHandle Specifies the executing process. @param Subsystem On successful completion, indicates the subsystem that was marked in the executable's PE header. @return TRUE to indicate success, FALSE to indicate failure. */ __success(return) BOOLEAN YoriLibShGetSubsystemFromExecutingImage( __in HANDLE ProcessHandle, __out PWORD Subsystem ) { PROCESS_BASIC_INFORMATION BasicInfo; LONG Status; DWORD dwBytesReturned; SIZE_T BytesReturned; PVOID ImageBaseAddress; BOOL TargetProcess32BitPeb; PVOID PeHeaderPtr; // // Since only one is read at a time, use the same buffer for all. // union { YORI_LIB_PEB32_NATIVE ProcessPeb32; YORI_LIB_PEB64 ProcessPeb64; IMAGE_DOS_HEADER DosHeader; YORILIB_PE_HEADERS PeHeaders; } u; if (DllNtDll.pNtQueryInformationProcess == NULL) { return FALSE; } TargetProcess32BitPeb = YoriLibDoesProcessHave32BitPeb(ProcessHandle); Status = DllNtDll.pNtQueryInformationProcess(ProcessHandle, 0, &BasicInfo, sizeof(BasicInfo), &dwBytesReturned); if (Status != 0) { return FALSE; } if (TargetProcess32BitPeb) { if (!ReadProcessMemory(ProcessHandle, BasicInfo.PebBaseAddress, &u.ProcessPeb32, sizeof(u.ProcessPeb32), &BytesReturned)) { return FALSE; } ImageBaseAddress = (PVOID)(ULONG_PTR)u.ProcessPeb32.ImageBaseAddress; } else { if (!ReadProcessMemory(ProcessHandle, BasicInfo.PebBaseAddress, &u.ProcessPeb64, sizeof(u.ProcessPeb64), &BytesReturned)) { return FALSE; } ImageBaseAddress = (PVOID)(ULONG_PTR)u.ProcessPeb64.ImageBaseAddress; } if (!ReadProcessMemory(ProcessHandle, ImageBaseAddress, &u.DosHeader, sizeof(u.DosHeader), &BytesReturned)) { return FALSE; } if (BytesReturned < sizeof(u.DosHeader) || u.DosHeader.e_magic != IMAGE_DOS_SIGNATURE || u.DosHeader.e_lfanew == 0) { return FALSE; } PeHeaderPtr = YoriLibAddToPointer(ImageBaseAddress, u.DosHeader.e_lfanew); if (!ReadProcessMemory(ProcessHandle, PeHeaderPtr, &u.PeHeaders, sizeof(u.PeHeaders), &BytesReturned)) { return FALSE; } if (BytesReturned >= sizeof(YORILIB_PE_HEADERS) && u.PeHeaders.Signature == IMAGE_NT_SIGNATURE && u.PeHeaders.ImageHeader.SizeOfOptionalHeader >= FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, Subsystem) + sizeof(WORD)) { *Subsystem = u.PeHeaders.OptionalHeader.Subsystem; return TRUE; } return FALSE; } /** A wrapper around CreateProcess that sets up redirection and launches a process. The point of this function is that it can be called from the main thread or from a debugging thread. @param ExecContext Pointer to the ExecContext to attempt to launch via CreateProcess. @param CurrentDirectory Optionally points to a NULL terminated string indicating the current directory to apply. If NULL, the process current directory is used instead. @param FailedInRedirection Optionally points to a boolean value to be set to TRUE if any error originated while setting up redirection, and FALSE if it came from launching the process. @return Win32 error code, meaning zero indicates success. */ DWORD YoriLibShCreateProcess( __in PYORI_LIBSH_SINGLE_EXEC_CONTEXT ExecContext, __in_opt LPTSTR CurrentDirectory, __out_opt PBOOL FailedInRedirection ) { YORI_STRING CmdLine; PROCESS_INFORMATION ProcessInfo; STARTUPINFO StartupInfo; YORI_LIBSH_PREVIOUS_REDIRECT_CONTEXT PreviousRedirectContext; DWORD CreationFlags = 0; DWORD LastError; ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); if (FailedInRedirection != NULL) { *FailedInRedirection = FALSE; } YoriLibInitEmptyString(&CmdLine); if (!YoriLibShBuildCmdlineFromCmdContext(&ExecContext->CmdToExec, &CmdLine, !ExecContext->IncludeEscapesAsLiteral, NULL, NULL)) { return ERROR_OUTOFMEMORY; } ASSERT(YoriLibIsStringNullTerminated(&CmdLine)); memset(&StartupInfo, 0, sizeof(StartupInfo)); StartupInfo.cb = sizeof(StartupInfo); if (ExecContext->RunOnSecondConsole) { CreationFlags |= CREATE_NEW_CONSOLE; } if (ExecContext->CaptureEnvironmentOnExit) { CreationFlags |= DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS; } CreationFlags |= CREATE_NEW_PROCESS_GROUP | CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED; LastError = YoriLibShInitializeRedirection(ExecContext, FALSE, &PreviousRedirectContext); if (LastError != ERROR_SUCCESS) { YoriLibFreeStringContents(&CmdLine); if (FailedInRedirection != NULL) { *FailedInRedirection = TRUE; } return LastError; } if (!CreateProcess(NULL, CmdLine.StartOfString, NULL, NULL, TRUE, CreationFlags, NULL, CurrentDirectory, &StartupInfo, &ProcessInfo)) { LastError = GetLastError(); YoriLibShRevertRedirection(&PreviousRedirectContext); YoriLibFreeStringContents(&CmdLine); return LastError; } else { YoriLibShRevertRedirection(&PreviousRedirectContext); } // // The nice way to terminate console processes is via // GenerateConsoleCtrlEvent, which gives the child a chance to exit // gracefully. Unfortunately the console misbehaves very badly if this // is performed on a process that is not a console process. Default to // non-graceful termination, and see if we can upgrade to graceful // termination by verifying that the process is a console process. // ExecContext->TerminateGracefully = FALSE; if (!ExecContext->RunOnSecondConsole) { WORD Subsystem; if (YoriLibShGetSubsystemFromExecutingImage(ProcessInfo.hProcess, &Subsystem) && Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) { ExecContext->TerminateGracefully = TRUE; } } ResumeThread(ProcessInfo.hThread); ASSERT(ExecContext->hProcess == NULL); ExecContext->hProcess = ProcessInfo.hProcess; ExecContext->hPrimaryThread = ProcessInfo.hThread; ExecContext->dwProcessId = ProcessInfo.dwProcessId; YoriLibFreeStringContents(&CmdLine); return ERROR_SUCCESS; } /** Cleanup the ExecContext if the process failed to launch. @param ExecContext Pointer to the ExecContext to clean up. */ VOID YoriLibShCleanupFailedProcessLaunch( __in PYORI_LIBSH_SINGLE_EXEC_CONTEXT ExecContext ) { if (ExecContext->StdOutType == StdOutTypePipe && ExecContext->NextProgram != NULL && ExecContext->NextProgram->StdInType == StdInTypePipe) { CloseHandle(ExecContext->NextProgram->StdIn.Pipe.PipeFromPriorProcess); ExecContext->NextProgram->StdIn.Pipe.PipeFromPriorProcess = NULL; ExecContext->NextProgramType = NextProgramExecNever; } } /** Start buffering process output if the process is configured for it. @param ExecContext Pointer to the ExecContext to set up buffers for. */ VOID YoriLibShCommenceProcessBuffersIfNeeded( __in PYORI_LIBSH_SINGLE_EXEC_CONTEXT ExecContext ) { // // If we're buffering output, start that process now. If it succeeds, // the pipe is owned by the buffer pump and shouldn't be torn down // when the ExecContext is. // if (ExecContext->StdOutType == StdOutTypeBuffer || ExecContext->StdErrType == StdErrTypeBuffer) { if (ExecContext->StdOut.Buffer.ProcessBuffers != NULL) { ASSERT(ExecContext->StdErrType != StdErrTypeBuffer); if (YoriLibShAppendToExistingProcessBuffer(ExecContext)) { ExecContext->StdOut.Buffer.PipeFromProcess = NULL; } else { ExecContext->StdOut.Buffer.ProcessBuffers = NULL; } } else { if (YoriLibShCreateNewProcessBuffer(ExecContext)) { if (ExecContext->StdOutType == StdOutTypeBuffer) { ExecContext->StdOut.Buffer.PipeFromProcess = NULL; } if (ExecContext->StdErrType == StdErrTypeBuffer) { ExecContext->StdErr.Buffer.PipeFromProcess = NULL; } } } } } /** Construct a CmdContext that contains "cmd", "/c" and an arbitrary string. CMD uses this syntax to allow a whole pile of things, including redirects, to be encoded into a single argument. On success, the caller is expected to free this with @ref YoriLibShFreeCmdContext . @param CmdContext Pointer to a CmdContext to be populated within this routine. @param CmdLine Pointer to an arbitrary command to include. This is cloned (not copied) within this routine, so the caller is expected to not modify it or copy it if necessary. @return TRUE to indicate success, FALSE to indicate failure. */ BOOLEAN YoriLibShBuildCmdContextForCmdBuckPass ( __out PYORI_LIBSH_CMD_CONTEXT CmdContext, __in PYORI_STRING CmdLine ) { YORI_STRING Arg; YORI_STRING FoundInPath; // // Allocate three components, for "cmd", "/c" and "CmdLine" // CmdContext->ArgC = 3; CmdContext->MemoryToFree = YoriLibReferencedMalloc(CmdContext->ArgC * (sizeof(YORI_STRING) + sizeof(YORI_LIBSH_ARG_CONTEXT))); if (CmdContext->MemoryToFree == NULL) { return FALSE; } CmdContext->ArgV = CmdContext->MemoryToFree; CmdContext->ArgContexts = (PYORI_LIBSH_ARG_CONTEXT)YoriLibAddToPointer(CmdContext->ArgV, sizeof(YORI_STRING) * CmdContext->ArgC); ZeroMemory(CmdContext->ArgContexts, sizeof(YORI_LIBSH_ARG_CONTEXT) * CmdContext->ArgC); // // Locate "cmd" in PATH // YoriLibConstantString(&Arg, _T("cmd")); YoriLibInitEmptyString(&FoundInPath); if (YoriLibLocateExecutableInPath(&Arg, NULL, NULL, &FoundInPath) && FoundInPath.LengthInChars > 0) { memcpy(&CmdContext->ArgV[0], &FoundInPath, sizeof(YORI_STRING)); ASSERT(YoriLibIsStringNullTerminated(&CmdContext->ArgV[0])); YoriLibInitEmptyString(&FoundInPath); } else { YoriLibCloneString(&CmdContext->ArgV[0], &Arg); } YoriLibFreeStringContents(&FoundInPath); YoriLibConstantString(&CmdContext->ArgV[1], _T("/c")); // // Add user arg and enforce that it is always quoted. Note this isn't // a deep copy, just a clone; the caller is expected to copy if needed. // YoriLibCloneString(&CmdContext->ArgV[2], CmdLine); CmdContext->ArgContexts[2].Quoted = TRUE; CmdContext->ArgContexts[2].QuoteTerminated = TRUE; // // Initialize unused fields // CmdContext->CurrentArg = 0; CmdContext->CurrentArgOffset = 0; CmdContext->TrailingChars = FALSE; YoriLibShCheckIfArgNeedsQuotes(CmdContext, 0); return TRUE; } // vim:sw=4:ts=4:et:
7af5456a502e7ab9451c444413604c397d17f68b
3c883e1084f0a61e558c2d210bb1b4ae8a5e6a06
/third_party/nvxs-1.0.2/CLAPACK/TESTING/LIN/cerrvx.c
b907506714fa49a33534ea64ed31859be1487c41
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "Python-2.0", "BSD-3-Clause" ]
permissive
nya3jp/python-animeface
7e48aa333c9f365a80acdf43e5d516edc8d0b189
15caf8b1ca29847f0dceb54e4b91c77726c4111c
refs/heads/main
2022-04-29T20:17:01.198810
2022-04-04T10:17:59
2022-04-04T10:17:59
10,998,381
150
14
Apache-2.0
2022-04-03T07:18:40
2013-06-27T14:06:08
C
UTF-8
C
false
false
38,907
c
cerrvx.c
#include "f2c.h" #include "blaswrap.h" /* Common Block Declarations */ struct { integer infot, nout; logical ok, lerr; } infoc_; #define infoc_1 infoc_ struct { char srnamt[6]; } srnamc_; #define srnamc_1 srnamc_ /* Table of constant values */ static integer c__2 = 2; static integer c_n1 = -1; static integer c__0 = 0; static integer c__1 = 1; static integer c__3 = 3; static integer c__4 = 4; /* Subroutine */ int cerrvx_(char *path, integer *nunit) { /* Format strings */ static char fmt_9999[] = "(1x,a3,\002 drivers passed the tests of the er" "ror exits\002)"; static char fmt_9998[] = "(\002 *** \002,a3,\002 drivers failed the test" "s of the error \002,\002exits ***\002)"; /* System generated locals */ integer i__1; real r__1, r__2; complex q__1; /* Builtin functions */ integer s_wsle(cilist *), e_wsle(void); /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void); /* Local variables */ complex a[16] /* was [4][4] */, b[4]; real c__[4]; integer i__, j; real r__[4]; complex w[8], x[4]; char c2[2]; real r1[4], r2[4]; complex af[16] /* was [4][4] */; char eq[1]; real rf[4]; integer ip[4]; real rw[4]; integer info; extern /* Subroutine */ int cgbsv_(integer *, integer *, integer *, integer *, complex *, integer *, integer *, complex *, integer *, integer *); real rcond; extern /* Subroutine */ int cgesv_(integer *, integer *, complex *, integer *, integer *, complex *, integer *, integer *), chesv_( char *, integer *, integer *, complex *, integer *, integer *, complex *, integer *, complex *, integer *, integer *), cpbsv_(char *, integer *, integer *, integer *, complex *, integer *, complex *, integer *, integer *), chpsv_(char * , integer *, integer *, complex *, integer *, complex *, integer * , integer *), cgtsv_(integer *, integer *, complex *, complex *, complex *, complex *, integer *, integer *), cposv_( char *, integer *, integer *, complex *, integer *, complex *, integer *, integer *), cppsv_(char *, integer *, integer * , complex *, complex *, integer *, integer *), cspsv_( char *, integer *, integer *, complex *, integer *, complex *, integer *, integer *), cptsv_(integer *, integer *, real * , complex *, complex *, integer *, integer *), csysv_(char *, integer *, integer *, complex *, integer *, integer *, complex *, integer *, complex *, integer *, integer *); extern logical lsamen_(integer *, char *, char *); extern /* Subroutine */ int chkxer_(char *, integer *, integer *, logical *, logical *), cgbsvx_(char *, char *, integer *, integer *, integer *, integer *, complex *, integer *, complex *, integer *, integer *, char *, real *, real *, complex *, integer *, complex *, integer *, real *, real *, real *, complex *, real *, integer *), cgesvx_(char *, char *, integer *, integer *, complex *, integer *, complex *, integer *, integer *, char *, real *, real *, complex *, integer *, complex * , integer *, real *, real *, real *, complex *, real *, integer *), chesvx_(char *, char *, integer *, integer *, complex *, integer *, complex *, integer *, integer *, complex *, integer *, complex *, integer *, real *, real *, real * , complex *, integer *, real *, integer *), cpbsvx_(char *, char *, integer *, integer *, integer *, complex * , integer *, complex *, integer *, char *, real *, complex *, integer *, complex *, integer *, real *, real *, real *, complex * , real *, integer *), chpsvx_(char *, char *, integer *, integer *, complex *, complex *, integer *, complex *, integer *, complex *, integer *, real *, real *, real * , complex *, real *, integer *), cgtsvx_(char *, char *, integer *, integer *, complex *, complex *, complex *, complex *, complex *, complex *, complex *, integer *, complex *, integer *, complex *, integer *, real *, real *, real *, complex * , real *, integer *), cposvx_(char *, char *, integer *, integer *, complex *, integer *, complex *, integer *, char *, real *, complex *, integer *, complex *, integer *, real * , real *, real *, complex *, real *, integer *), cppsvx_(char *, char *, integer *, integer *, complex *, complex *, char *, real *, complex *, integer *, complex *, integer *, real *, real *, real *, complex *, real *, integer *), cspsvx_(char *, char *, integer *, integer *, complex *, complex *, integer *, complex *, integer *, complex *, integer *, real *, real *, real *, complex *, real *, integer *), cptsvx_(char *, integer *, integer *, real *, complex *, real *, complex *, complex *, integer *, complex *, integer *, real *, real *, real *, complex *, real *, integer *), csysvx_(char *, char *, integer *, integer *, complex *, integer *, complex *, integer *, integer *, complex *, integer *, complex *, integer *, real *, real *, real *, complex * , integer *, real *, integer *); /* Fortran I/O blocks */ static cilist io___1 = { 0, 0, 0, 0, 0 }; static cilist io___20 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___21 = { 0, 0, 0, fmt_9998, 0 }; /* -- LAPACK test routine (version 3.1.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* January 2007 */ /* .. Scalar Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* CERRVX tests the error exits for the COMPLEX driver routines */ /* for solving linear systems of equations. */ /* Arguments */ /* ========= */ /* PATH (input) CHARACTER*3 */ /* The LAPACK path name for the routines to be tested. */ /* NUNIT (input) INTEGER */ /* The unit number for output. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ infoc_1.nout = *nunit; io___1.ciunit = infoc_1.nout; s_wsle(&io___1); e_wsle(); s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2); /* Set the variables to innocuous values. */ for (j = 1; j <= 4; ++j) { for (i__ = 1; i__ <= 4; ++i__) { i__1 = i__ + (j << 2) - 5; r__1 = 1.f / (real) (i__ + j); r__2 = -1.f / (real) (i__ + j); q__1.r = r__1, q__1.i = r__2; a[i__1].r = q__1.r, a[i__1].i = q__1.i; i__1 = i__ + (j << 2) - 5; r__1 = 1.f / (real) (i__ + j); r__2 = -1.f / (real) (i__ + j); q__1.r = r__1, q__1.i = r__2; af[i__1].r = q__1.r, af[i__1].i = q__1.i; /* L10: */ } i__1 = j - 1; b[i__1].r = 0.f, b[i__1].i = 0.f; r1[j - 1] = 0.f; r2[j - 1] = 0.f; i__1 = j - 1; w[i__1].r = 0.f, w[i__1].i = 0.f; i__1 = j - 1; x[i__1].r = 0.f, x[i__1].i = 0.f; c__[j - 1] = 0.f; r__[j - 1] = 0.f; ip[j - 1] = j; /* L20: */ } *(unsigned char *)eq = ' '; infoc_1.ok = TRUE_; if (lsamen_(&c__2, c2, "GE")) { /* CGESV */ s_copy(srnamc_1.srnamt, "CGESV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgesv_(&c_n1, &c__0, a, &c__1, ip, b, &c__1, &info); chkxer_("CGESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgesv_(&c__0, &c_n1, a, &c__1, ip, b, &c__1, &info); chkxer_("CGESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cgesv_(&c__2, &c__1, a, &c__1, ip, b, &c__2, &info); chkxer_("CGESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cgesv_(&c__2, &c__1, a, &c__2, ip, b, &c__1, &info); chkxer_("CGESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CGESVX */ s_copy(srnamc_1.srnamt, "CGESVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgesvx_("/", "N", &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgesvx_("N", "/", &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cgesvx_("N", "N", &c_n1, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cgesvx_("N", "N", &c__0, &c_n1, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cgesvx_("N", "N", &c__2, &c__1, a, &c__1, af, &c__2, ip, eq, r__, c__, b, &c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cgesvx_("N", "N", &c__2, &c__1, a, &c__2, af, &c__1, ip, eq, r__, c__, b, &c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; *(unsigned char *)eq = '/'; cgesvx_("F", "N", &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; *(unsigned char *)eq = 'R'; cgesvx_("F", "N", &c__1, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 12; *(unsigned char *)eq = 'C'; cgesvx_("F", "N", &c__1, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 14; cgesvx_("N", "N", &c__2, &c__1, a, &c__2, af, &c__2, ip, eq, r__, c__, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 16; cgesvx_("N", "N", &c__2, &c__1, a, &c__2, af, &c__2, ip, eq, r__, c__, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "GB")) { /* CGBSV */ s_copy(srnamc_1.srnamt, "CGBSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgbsv_(&c_n1, &c__0, &c__0, &c__0, a, &c__1, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgbsv_(&c__1, &c_n1, &c__0, &c__0, a, &c__1, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cgbsv_(&c__1, &c__0, &c_n1, &c__0, a, &c__1, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cgbsv_(&c__0, &c__0, &c__0, &c_n1, a, &c__1, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cgbsv_(&c__1, &c__1, &c__1, &c__0, a, &c__3, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cgbsv_(&c__2, &c__0, &c__0, &c__0, a, &c__1, ip, b, &c__1, &info); chkxer_("CGBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CGBSVX */ s_copy(srnamc_1.srnamt, "CGBSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgbsvx_("/", "N", &c__0, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgbsvx_("N", "/", &c__0, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cgbsvx_("N", "N", &c_n1, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cgbsvx_("N", "N", &c__1, &c_n1, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cgbsvx_("N", "N", &c__1, &c__0, &c_n1, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cgbsvx_("N", "N", &c__0, &c__0, &c__0, &c_n1, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cgbsvx_("N", "N", &c__1, &c__1, &c__1, &c__0, a, &c__2, af, &c__4, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; cgbsvx_("N", "N", &c__1, &c__1, &c__1, &c__0, a, &c__3, af, &c__3, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 12; *(unsigned char *)eq = '/'; cgbsvx_("F", "N", &c__0, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 13; *(unsigned char *)eq = 'R'; cgbsvx_("F", "N", &c__1, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 14; *(unsigned char *)eq = 'C'; cgbsvx_("F", "N", &c__1, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 16; cgbsvx_("N", "N", &c__2, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 18; cgbsvx_("N", "N", &c__2, &c__0, &c__0, &c__0, a, &c__1, af, &c__1, ip, eq, r__, c__, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, & info); chkxer_("CGBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "GT")) { /* CGTSV */ s_copy(srnamc_1.srnamt, "CGTSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgtsv_(&c_n1, &c__0, a, &a[4], &a[8], b, &c__1, &info); chkxer_("CGTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgtsv_(&c__0, &c_n1, a, &a[4], &a[8], b, &c__1, &info); chkxer_("CGTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cgtsv_(&c__2, &c__0, a, &a[4], &a[8], b, &c__1, &info); chkxer_("CGTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CGTSVX */ s_copy(srnamc_1.srnamt, "CGTSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cgtsvx_("/", "N", &c__0, &c__0, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cgtsvx_("N", "/", &c__0, &c__0, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cgtsvx_("N", "N", &c_n1, &c__0, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cgtsvx_("N", "N", &c__0, &c_n1, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 14; cgtsvx_("N", "N", &c__2, &c__0, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 16; cgtsvx_("N", "N", &c__2, &c__0, a, &a[4], &a[8], af, &af[4], &af[8], & af[12], ip, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CGTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "PO")) { /* CPOSV */ s_copy(srnamc_1.srnamt, "CPOSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cposv_("/", &c__0, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPOSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cposv_("U", &c_n1, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPOSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cposv_("U", &c__0, &c_n1, a, &c__1, b, &c__1, &info); chkxer_("CPOSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cposv_("U", &c__2, &c__0, a, &c__1, b, &c__2, &info); chkxer_("CPOSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cposv_("U", &c__2, &c__0, a, &c__2, b, &c__1, &info); chkxer_("CPOSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOSVX */ s_copy(srnamc_1.srnamt, "CPOSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cposvx_("/", "U", &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cposvx_("N", "/", &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cposvx_("N", "U", &c_n1, &c__0, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cposvx_("N", "U", &c__0, &c_n1, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cposvx_("N", "U", &c__2, &c__0, a, &c__1, af, &c__2, eq, c__, b, & c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cposvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__1, eq, c__, b, & c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; *(unsigned char *)eq = '/'; cposvx_("F", "U", &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; *(unsigned char *)eq = 'Y'; cposvx_("F", "U", &c__1, &c__0, a, &c__1, af, &c__1, eq, c__, b, & c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 12; cposvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, eq, c__, b, & c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 14; cposvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, eq, c__, b, & c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPOSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "PP")) { /* CPPSV */ s_copy(srnamc_1.srnamt, "CPPSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cppsv_("/", &c__0, &c__0, a, b, &c__1, &info); chkxer_("CPPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cppsv_("U", &c_n1, &c__0, a, b, &c__1, &info); chkxer_("CPPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cppsv_("U", &c__0, &c_n1, a, b, &c__1, &info); chkxer_("CPPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cppsv_("U", &c__2, &c__0, a, b, &c__1, &info); chkxer_("CPPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPSVX */ s_copy(srnamc_1.srnamt, "CPPSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cppsvx_("/", "U", &c__0, &c__0, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cppsvx_("N", "/", &c__0, &c__0, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cppsvx_("N", "U", &c_n1, &c__0, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cppsvx_("N", "U", &c__0, &c_n1, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; *(unsigned char *)eq = '/'; cppsvx_("F", "U", &c__0, &c__0, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; *(unsigned char *)eq = 'Y'; cppsvx_("F", "U", &c__1, &c__0, a, af, eq, c__, b, &c__1, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; cppsvx_("N", "U", &c__2, &c__0, a, af, eq, c__, b, &c__1, x, &c__2, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 12; cppsvx_("N", "U", &c__2, &c__0, a, af, eq, c__, b, &c__2, x, &c__1, & rcond, r1, r2, w, rw, &info); chkxer_("CPPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "PB")) { /* CPBSV */ s_copy(srnamc_1.srnamt, "CPBSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cpbsv_("/", &c__0, &c__0, &c__0, a, &c__1, b, &c__1, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbsv_("U", &c_n1, &c__0, &c__0, a, &c__1, b, &c__1, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbsv_("U", &c__1, &c_n1, &c__0, a, &c__1, b, &c__1, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpbsv_("U", &c__0, &c__0, &c_n1, a, &c__1, b, &c__1, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cpbsv_("U", &c__1, &c__1, &c__0, a, &c__1, b, &c__2, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cpbsv_("U", &c__2, &c__0, &c__0, a, &c__1, b, &c__1, &info) ; chkxer_("CPBSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBSVX */ s_copy(srnamc_1.srnamt, "CPBSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cpbsvx_("/", "U", &c__0, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbsvx_("N", "/", &c__0, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbsvx_("N", "U", &c_n1, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpbsvx_("N", "U", &c__1, &c_n1, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpbsvx_("N", "U", &c__0, &c__0, &c_n1, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cpbsvx_("N", "U", &c__1, &c__1, &c__0, a, &c__1, af, &c__2, eq, c__, b, &c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cpbsvx_("N", "U", &c__1, &c__1, &c__0, a, &c__2, af, &c__1, eq, c__, b, &c__2, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; *(unsigned char *)eq = '/'; cpbsvx_("F", "U", &c__0, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; *(unsigned char *)eq = 'Y'; cpbsvx_("F", "U", &c__1, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 13; cpbsvx_("N", "U", &c__2, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 15; cpbsvx_("N", "U", &c__2, &c__0, &c__0, a, &c__1, af, &c__1, eq, c__, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPBSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "PT")) { /* CPTSV */ s_copy(srnamc_1.srnamt, "CPTSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cptsv_(&c_n1, &c__0, r__, a, b, &c__1, &info); chkxer_("CPTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cptsv_(&c__0, &c_n1, r__, a, b, &c__1, &info); chkxer_("CPTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cptsv_(&c__2, &c__0, r__, a, b, &c__1, &info); chkxer_("CPTSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPTSVX */ s_copy(srnamc_1.srnamt, "CPTSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cptsvx_("/", &c__0, &c__0, r__, a, rf, af, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cptsvx_("N", &c_n1, &c__0, r__, a, rf, af, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cptsvx_("N", &c__0, &c_n1, r__, a, rf, af, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cptsvx_("N", &c__2, &c__0, r__, a, rf, af, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CPTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; cptsvx_("N", &c__2, &c__0, r__, a, rf, af, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CPTSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "HE")) { /* CHESV */ s_copy(srnamc_1.srnamt, "CHESV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; chesv_("/", &c__0, &c__0, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CHESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; chesv_("U", &c_n1, &c__0, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CHESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; chesv_("U", &c__0, &c_n1, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CHESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; chesv_("U", &c__2, &c__0, a, &c__1, ip, b, &c__2, w, &c__1, &info); chkxer_("CHESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; chesv_("U", &c__2, &c__0, a, &c__2, ip, b, &c__1, w, &c__1, &info); chkxer_("CHESV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CHESVX */ s_copy(srnamc_1.srnamt, "CHESVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; chesvx_("/", "U", &c__0, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; chesvx_("N", "/", &c__0, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; chesvx_("N", "U", &c_n1, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; chesvx_("N", "U", &c__0, &c_n1, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; chesvx_("N", "U", &c__2, &c__0, a, &c__1, af, &c__2, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; chesvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__1, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; chesvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__1, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 13; chesvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__2, x, &c__1, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 18; chesvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__3, rw, &info); chkxer_("CHESVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "HP")) { /* CHPSV */ s_copy(srnamc_1.srnamt, "CHPSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; chpsv_("/", &c__0, &c__0, a, ip, b, &c__1, &info); chkxer_("CHPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; chpsv_("U", &c_n1, &c__0, a, ip, b, &c__1, &info); chkxer_("CHPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; chpsv_("U", &c__0, &c_n1, a, ip, b, &c__1, &info); chkxer_("CHPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; chpsv_("U", &c__2, &c__0, a, ip, b, &c__1, &info); chkxer_("CHPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CHPSVX */ s_copy(srnamc_1.srnamt, "CHPSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; chpsvx_("/", "U", &c__0, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; chpsvx_("N", "/", &c__0, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; chpsvx_("N", "U", &c_n1, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; chpsvx_("N", "U", &c__0, &c_n1, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; chpsvx_("N", "U", &c__2, &c__0, a, af, ip, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; chpsvx_("N", "U", &c__2, &c__0, a, af, ip, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CHPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "SY")) { /* CSYSV */ s_copy(srnamc_1.srnamt, "CSYSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; csysv_("/", &c__0, &c__0, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CSYSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; csysv_("U", &c_n1, &c__0, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CSYSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; csysv_("U", &c__0, &c_n1, a, &c__1, ip, b, &c__1, w, &c__1, &info); chkxer_("CSYSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; csysv_("U", &c__2, &c__0, a, &c__2, ip, b, &c__1, w, &c__1, &info); chkxer_("CSYSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CSYSVX */ s_copy(srnamc_1.srnamt, "CSYSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; csysvx_("/", "U", &c__0, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; csysvx_("N", "/", &c__0, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; csysvx_("N", "U", &c_n1, &c__0, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; csysvx_("N", "U", &c__0, &c_n1, a, &c__1, af, &c__1, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, &c__1, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; csysvx_("N", "U", &c__2, &c__0, a, &c__1, af, &c__2, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; csysvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__1, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; csysvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__1, x, &c__2, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 13; csysvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__2, x, &c__1, &rcond, r1, r2, w, &c__4, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 18; csysvx_("N", "U", &c__2, &c__0, a, &c__2, af, &c__2, ip, b, &c__2, x, &c__2, &rcond, r1, r2, w, &c__3, rw, &info); chkxer_("CSYSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "SP")) { /* CSPSV */ s_copy(srnamc_1.srnamt, "CSPSV ", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cspsv_("/", &c__0, &c__0, a, ip, b, &c__1, &info); chkxer_("CSPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cspsv_("U", &c_n1, &c__0, a, ip, b, &c__1, &info); chkxer_("CSPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cspsv_("U", &c__0, &c_n1, a, ip, b, &c__1, &info); chkxer_("CSPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cspsv_("U", &c__2, &c__0, a, ip, b, &c__1, &info); chkxer_("CSPSV ", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CSPSVX */ s_copy(srnamc_1.srnamt, "CSPSVX", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; cspsvx_("/", "U", &c__0, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cspsvx_("N", "/", &c__0, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cspsvx_("N", "U", &c_n1, &c__0, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cspsvx_("N", "U", &c__0, &c_n1, a, af, ip, b, &c__1, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cspsvx_("N", "U", &c__2, &c__0, a, af, ip, b, &c__1, x, &c__2, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; cspsvx_("N", "U", &c__2, &c__0, a, af, ip, b, &c__2, x, &c__1, &rcond, r1, r2, w, rw, &info); chkxer_("CSPSVX", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } /* Print a summary line. */ if (infoc_1.ok) { io___20.ciunit = infoc_1.nout; s_wsfe(&io___20); do_fio(&c__1, path, (ftnlen)3); e_wsfe(); } else { io___21.ciunit = infoc_1.nout; s_wsfe(&io___21); do_fio(&c__1, path, (ftnlen)3); e_wsfe(); } return 0; /* End of CERRVX */ } /* cerrvx_ */
d0e6f25160b815abbe46ec9e3c5ca83c80459ab5
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/tool/viz/lib/glyphs.c
a808166f9e3f111abb0706c0516e2b0a2013e6b1
[ "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
14,810
c
glyphs.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ // The modes below use various unicodes for 'progressive' pixelization: // each mode supersets the previous to increase resolution more and more. // Ideally, a fully dense mapping of the (Y*X) space defined by kGlyph size // would produce a picture perfect image, but at the cost of sampling speed. // Therefore, supersets are parsimonious: they only add the minimal set of // missing shapes that can increase resolution. // Ideally, this should be based on a study of the residual, but some logic // can go a long way: after some block pixelization, will need diagonals // FIXME: then shouldn't box drawing go right after braille? // TODO: explain the differences between each mode: // Mode A is full, empty, half blocks top and bottom: , █,▄,▀ // Mode B superset: with quadrants: ▐,▌,▝,▙,▗,▛,▖,▜,▘,▟,▞,▚, // Mode C superset: with fractional eights along X and Y // _,▁,▂,▃,▄,▅,▆,▇ :█:▉,▊,▋,▌,▍,▎,▏ // Mode X use box drawing, mode X use diagonal blocks, mode X use braille etc #define W(B, S) B##U << S #define G(AA, AB, AC, AD, BA, BB, BC, BD, CA, CB, CC, CD, DA, DB, DC, DD, EA, \ EB, EC, ED, FA, FB, FC, FD, GA, GB, GC, GD, HA, HB, HC, HD) \ (W(AA, 000) | W(AB, 001) | W(AC, 002) | W(AD, 003) | W(BA, 004) | \ W(BB, 005) | W(BC, 006) | W(BD, 007) | W(CA, 010) | W(CB, 011) | \ W(CC, 012) | W(CD, 013) | W(DA, 014) | W(DB, 015) | W(DC, 016) | \ W(DD, 017) | W(EA, 020) | W(EB, 021) | W(EC, 022) | W(ED, 023) | \ W(FA, 024) | W(FB, 025) | W(FC, 026) | W(FD, 027) | W(GA, 030) | \ W(GB, 031) | W(GC, 032) | W(GD, 033) | W(HA, 034) | W(HB, 035) | \ W(HC, 036) | W(HD, 037)) // The glyph size it set by the resolution of the most precise mode, ex: // - Mode C: along the X axis, need >= 8 steps for the 8 fractional width // FIXME: now we can only use 4 chars instead of the extra ▉,▊,▋,▌,▍,▎,▏ // // - Mode X: along the Y axis, need >= 8 steps to separate the maximal 6 dots // from the space left below, seen by overimposing an underline ⠿_ // along the 3 dots, the Y axis is least 1,0,1,0,1,0,0,1 so 8 steps // // Problem: fonts are taller than wider, and terminals are traditionally 80x24, so // - we shouldn't use square glyphs, 8x16 seems to be the minimal size // - we should adapt the conversion to BMP to avoid accidental Y downsampling const uint32_t kGlyphs[] = /* clang-format off */ { /* U+0020 ' ' empty block [ascii:20,cp437:20] */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* U+2588 '█' full block [cp437] */ G(1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+2584 '▄' lower half block [cp437:dc] */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+2580 '▀' upper half block [cp437] */ G(1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), // Mode B /* U+2590 '▐' right half block [cp437:de] */ G(0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1), /* U+258c '▌' left half block [cp437] */ G(1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0), /* U+259d '▝' quadrant upper right */ G(0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* U+2599 '▙' quadrant upper left and lower left and lower right */ G(1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,0), /* U+2597 '▗' quadrant lower right */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1), /* U+259b '▛' quadrant upper left and upper right and lower left */ G(1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,1), /* U+2596 '▖' quadrant lower left */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0), /* U+259c '▜' quadrant upper left and upper right and lower right */ G(1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,0), /* U+2598 '▘' quadrant upper left */ G(1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* U+259F '▟' quadrant upper right and lower left and lower right */ G(0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,0), /* U+259e '▞' quadrant upper right and lower left */ G(0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1, 1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0), /* U+259a '▚' quadrant upper left and lower right */ G(1,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,0, 0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,0), // Mode C /* U+2594 '▔' upper one eighth block */ G(1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* U+2581 '▁' lower one eighth block */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1), /* U+2582 '▂' lower one quarter block */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1), /* U+2583 '▃' lower three eighths block */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+2585 '▃' lower five eighths block */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+2586 '▆' lower three quarters block */ G(0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+2587 '▇' lower seven eighths block */ G(0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1), /* U+258e '▎' left one quarter block */ G(1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0), /* U+258a '▊' left three quarters block */ G(1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0, 1,1,1,0), /* ▁ *\ 2501▕━▎box drawings heavy horizontal \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 25019▕┉▎box drawings heavy quadruple dash horizontal \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,1,0, 0,1,0,1, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 2503▕┃▎box drawings heavy vertical \* ▔ */ G(0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0), /* ▁ *\ 254b▕╋▎box drawings heavy vertical and horizontal \* ▔ */ G(0,1,1,0, 0,1,1,0, 0,1,1,0, 1,1,1,1, 1,1,1,1, 0,1,1,0, 0,1,1,0, 0,1,1,0), /* ▁ *\ 2579▕╹▎box drawings heavy up \* ▔ */ G(0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 257a▕╺▎box drawings heavy right \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,1, 0,0,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 257b▕╻▎box drawings heavy down \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0), /* ▁ *\ 2578▕╸▎box drawings heavy left \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,0,0, 1,1,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 250f▕┏▎box drawings heavy down and right \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,1, 0,1,1,1, 0,1,1,0, 0,1,1,0, 0,1,1,0), /* ▁ *\ 251b▕┛▎box drawings heavy up and left \* ▔ */ G(0,1,1,0, 0,1,1,0, 0,1,1,0, 1,1,1,0, 1,1,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 2513▕┓▎box drawings heavy down and left \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,0, 1,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0), /* ▁ *\ 2517▕┗▎box drawings heavy up and right \* ▔ */ G(0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,1, 0,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 25E2▕◢▎black lower right triangle \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,1,1, 1,1,1,1, 0,0,0,0, 0,0,0,0), /* ▁ *\ 25E3▕◣▎black lower left triangle \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,0,0, 1,1,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0), /* ▁ *\ 25E4▕◥▎black upper right triangle \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,1,1, 0,0,0,1, 0,0,0,0, 0,0,0,0), /* ▁ *\ 25E5▕◤▎black upper left triangle \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,0,0, 1,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 2500▕═▎box drawings double horizontal \* ▔ */ G(0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 23BB▕⎻▎horizontal scan line 3 \* ▔ */ G(0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0), /* ▁ *\ 23BD▕⎼▎horizontal scan line 9 \* ▔ */ G(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,0,0, 0,0,0,0), } /* clang-format on */; const char16_t kRunes[] = { u' ', /* 0020 empty block [ascii:20,cp437:20] */ u'█', /* 2588 full block [cp437] */ u'▄', /* 2584 lower half block [cp437:dc] */ u'▀', /* 2580 upper half block [cp437] */ u'▐', /* 2590 right half block [cp437:de] */ u'▌', /* 258C left half block */ u'▝', /* 259D quadrant upper right */ u'▙', /* 2599 quadrant upper left and lower left and lower right */ u'▗', /* 2597 quadrant lower right */ u'▛', /* 259B quadrant upper left and upper right and lower left */ u'▖', /* 2596 quadrant lower left */ u'▜', /* 259C quadrant upper left and upper right and lower right */ u'▘', /* 2598 quadrant upper left */ u'▟', /* 259F quadrant upper right and lower left and lower right */ u'▞', /* 259E quadrant upper right and lower left */ u'▚', /* 259A quadrant upper left and lower right */ u'▔', /* 2594 upper one eighth block */ u'▁', /* 2581 lower one eighth block */ u'▂', /* 2582 lower one quarter block */ u'▃', /* 2583 lower three eighths block */ u'▅', /* 2585 lower five eighths block */ u'▆', /* 2586 lower three quarters block */ u'▇', /* 2587 lower seven eighths block */ u'▎', /* 258E left one quarter block */ u'▊', /* 258A left three quarters block */ u'━', /* 2501 box drawings heavy horizontal */ u'┉', /* 2509 box drawings heavy quadruple dash horizontal */ u'┃', /* 2503 box drawings heavy vertical */ u'╋', /* 254B box drawings heavy vertical & horiz. */ u'╹', /* 2579 box drawings heavy up */ u'╺', /* 257A box drawings heavy right */ u'╻', /* 257B box drawings heavy down */ u'╸', /* 2578 box drawings heavy left */ u'┏', /* 250F box drawings heavy down and right */ u'┛', /* 251B box drawings heavy up and left */ u'┓', /* 2513 box drawings heavy down and left */ u'┗', /* 2517 box drawings heavy up and right */ u'◢', /* 25E2 black lower right triangle */ u'◣', /* 25E3 black lower left triangle */ u'◥', /* 25E4 black upper right triangle */ u'◤', /* 25E5 black upper left triangle */ u'═', /* 2550 box drawings double horizontal */ u'⎻', /* 23BB horizontal scan line 3 */ u'⎼', /* 23BD horizontal scan line 9 */ };
3e4b34329fbbcde24f96b75f7ac1bf861ea910a5
ed7189bcb31973648dca4cb9f0d67cb4653d0e70
/sysdeps/ironclad/include/abi-bits/reboot.h
77013a41623a7acc474fe0f142ef840391b38e50
[ "MIT" ]
permissive
managarm/mlibc
6dedaa86ed74f26a52e300d97f6e5949bac0f93c
74efefb5e9e546adab60a5730d95165334d7ee15
refs/heads/master
2023-09-01T05:17:26.709378
2023-08-29T08:33:01
2023-08-29T08:33:01
63,353,495
717
173
MIT
2023-09-10T10:55:53
2016-07-14T16:46:51
C
UTF-8
C
false
false
31
h
reboot.h
../../../../abis/linux/reboot.h
998ff37e1a55cc35f43b04891be9c845b6172d1e
f9e7d65cb784c01a0200145ba8d289afe41d4a56
/core/nds32/cpu.h
3bd5a93efce1eb6b58701a85d39b9d8266a0d153
[ "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,681
h
cpu.h
/* 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. * * Registers map and definitions for Andes cores */ #ifndef __CROS_EC_CPU_H #define __CROS_EC_CPU_H /* * This is the space required by both irq_x_ and __switch_task to store all * of the caller and callee registers for each task context before switching. */ #define TASK_SCRATCHPAD_SIZE (18) /* Process Status Word bits */ #define PSW_GIE BIT(0) /* Global Interrupt Enable */ #define PSW_INTL_SHIFT 1 /* Interrupt Stack Level */ #define PSW_INTL_MASK (0x3 << PSW_INTL_SHIFT) #ifndef __ASSEMBLER__ #include <stdint.h> /* write Process Status Word privileged register */ static inline void set_psw(uint32_t val) { asm volatile ("mtsr %0, $PSW" : : "r"(val)); } /* read Process Status Word privileged register */ static inline uint32_t get_psw(void) { uint32_t ret; asm volatile ("mfsr %0, $PSW" : "=r"(ret)); return ret; } /* write Interruption Program Counter privileged register */ static inline void set_ipc(uint32_t val) { asm volatile ("mtsr %0, $IPC" : : "r"(val)); } /* read Interruption Program Counter privileged register */ static inline uint32_t get_ipc(void) { uint32_t ret; asm volatile ("mfsr %0, $IPC" : "=r"(ret)); return ret; } /* read Interruption Type privileged register */ static inline uint32_t get_itype(void) { uint32_t ret; asm volatile ("mfsr %0, $ITYPE" : "=r"(ret)); return ret; } /* Generic CPU core initialization */ void cpu_init(void); extern uint32_t ilp; extern uint32_t ec_reset_lp; #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_CPU_H */
b303d480b37da8dcd9897d3287c24d4d903ad7eb
17227ad12bc0826771ac6ac2b95dddd9517d0117
/PVSupport/Sources/retro/ui/drivers/ui_win32_resource.h
d47b1f1e17f055b6a6ac6ba1c7c762541bf394bc
[ "BSD-2-Clause" ]
permissive
Provenance-Emu/Provenance
e38f7c81e784455d4876f8a2ff999baca0135199
c6f49d7921ee27eb8c0c34ca95ec9dc7baf584c1
refs/heads/develop
2023-08-17T05:04:01.554294
2023-07-01T07:58:33
2023-07-01T07:58:33
12,416,862
2,367
364
NOASSERTION
2023-08-01T07:42:35
2013-08-27T20:34:36
C
UTF-8
C
false
false
1,661
h
ui_win32_resource.h
#define IDR_MENU 101 #define IDD_PICKCORE 103 #define ID_M_LOAD_CONTENT 40001 #define ID_CORELISTBOX 40002 #define ID_M_RESET 40002 #define ID_M_QUIT 40003 #define ID_M_MENU_TOGGLE 40004 #define ID_M_PAUSE_TOGGLE 40005 #define ID_M_LOAD_CORE 40006 #define ID_M_LOAD_STATE 40007 #define ID_M_SAVE_STATE 40008 #define ID_M_DISK_CYCLE 40009 #define ID_M_DISK_NEXT 40010 #define ID_M_DISK_PREV 40011 #define ID_M_WINDOW_SCALE_1X 40012 #define ID_M_WINDOW_SCALE_2X 40013 #define ID_M_WINDOW_SCALE_3X 40014 #define ID_M_WINDOW_SCALE_4X 40015 #define ID_M_WINDOW_SCALE_5X 40016 #define ID_M_WINDOW_SCALE_6X 40017 #define ID_M_WINDOW_SCALE_7X 40018 #define ID_M_WINDOW_SCALE_8X 40019 #define ID_M_WINDOW_SCALE_9X 40020 #define ID_M_WINDOW_SCALE_10X 40021 #define ID_M_FULL_SCREEN 40022 #define ID_M_MOUSE_GRAB 40023 #define ID_M_STATE_INDEX_AUTO 40024 #define ID_M_TAKE_SCREENSHOT 40025 #define ID_M_MUTE_TOGGLE 40026 #define ID_M_TOGGLE_DESKTOP 40027 #define IDR_ACCELERATOR1 104
81cdb1797bbf9c99353ceb16f401deee2033f83e
21319b6831e12b665dbc0844c852f95b3c1a39f6
/test/draw.mock.c
303aad1ae56be48f696123e8b11ca19977911808
[ "MIT" ]
permissive
rcr/rirc
9c1ceb6e376fd57387f0095fa8133fb9043ce3e1
df153ce2d12d575e8539f3afdaceb5f3bcc12046
refs/heads/dev
2023-07-06T01:53:35.478466
2023-06-29T23:59:58
2023-06-29T23:59:58
12,770,590
146
27
MIT
2023-04-07T18:31:46
2013-09-11T23:44:08
C
UTF-8
C
false
false
145
c
draw.mock.c
#ifndef DRAW_MOCK_C #define DRAW_MOCK_C void draw(enum draw_bit b) { UNUSED(b); } void draw_init(void) { ; } void draw_term(void) { ; } #endif
d8254cf0e2c34d183e9213f454fd3b66be693429
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.c
69c637c7649921b51495165a4748ace7de5665a1
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
9,609
c
FmpAuthenticationLibPkcs7.c
/** @file FMP Authentication PKCS7 handler. Provide generic FMP authentication functions for DXE/PEI post memory phase. Caution: This module requires additional review when modified. This module will have external input - capsule image. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. FmpAuthenticatedHandlerPkcs7(), AuthenticateFmpImage() will receive untrusted input and do basic validation. Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include <Uefi.h> #include <Guid/SystemResourceTable.h> #include <Guid/FirmwareContentsSigned.h> #include <Guid/WinCertificate.h> #include <Library/BaseLib.h> #include <Library/BaseMemoryLib.h> #include <Library/DebugLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/BaseCryptLib.h> #include <Library/FmpAuthenticationLib.h> #include <Library/PcdLib.h> #include <Protocol/FirmwareManagement.h> #include <Guid/SystemResourceTable.h> /** The handler is used to do the authentication for FMP capsule based upon EFI_FIRMWARE_IMAGE_AUTHENTICATION. Caution: This function may receive untrusted input. This function assumes the caller AuthenticateFmpImage() already did basic validation for EFI_FIRMWARE_IMAGE_AUTHENTICATION. @param[in] Image Points to an FMP authentication image, started from EFI_FIRMWARE_IMAGE_AUTHENTICATION. @param[in] ImageSize Size of the authentication image in bytes. @param[in] PublicKeyData The public key data used to validate the signature. @param[in] PublicKeyDataLength The length of the public key data. @retval RETURN_SUCCESS Authentication pass. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_SUCCESS. @retval RETURN_SECURITY_VIOLATION Authentication fail. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR. @retval RETURN_INVALID_PARAMETER The image is in an invalid format. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT. @retval RETURN_OUT_OF_RESOURCES No Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES. **/ RETURN_STATUS FmpAuthenticatedHandlerPkcs7 ( IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength ) { RETURN_STATUS Status; BOOLEAN CryptoStatus; VOID *P7Data; UINTN P7Length; VOID *TempBuffer; DEBUG((DEBUG_INFO, "FmpAuthenticatedHandlerPkcs7 - Image: 0x%08x - 0x%08x\n", (UINTN)Image, (UINTN)ImageSize)); P7Length = Image->AuthInfo.Hdr.dwLength - (OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, CertData)); P7Data = Image->AuthInfo.CertData; // It is a signature across the variable data and the Monotonic Count value. TempBuffer = AllocatePool(ImageSize - Image->AuthInfo.Hdr.dwLength); if (TempBuffer == NULL) { DEBUG((DEBUG_ERROR, "FmpAuthenticatedHandlerPkcs7: TempBuffer == NULL\n")); Status = RETURN_OUT_OF_RESOURCES; goto Done; } CopyMem( TempBuffer, (UINT8 *)Image + sizeof(Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength, ImageSize - sizeof(Image->MonotonicCount) - Image->AuthInfo.Hdr.dwLength ); CopyMem( (UINT8 *)TempBuffer + ImageSize - sizeof(Image->MonotonicCount) - Image->AuthInfo.Hdr.dwLength, &Image->MonotonicCount, sizeof(Image->MonotonicCount) ); CryptoStatus = Pkcs7Verify( P7Data, P7Length, PublicKeyData, PublicKeyDataLength, (UINT8 *)TempBuffer, ImageSize - Image->AuthInfo.Hdr.dwLength ); FreePool(TempBuffer); if (!CryptoStatus) { // // If PKCS7 signature verification fails, AUTH tested failed bit is set. // DEBUG((DEBUG_ERROR, "FmpAuthenticatedHandlerPkcs7: Pkcs7Verify() failed\n")); Status = RETURN_SECURITY_VIOLATION; goto Done; } DEBUG((DEBUG_INFO, "FmpAuthenticatedHandlerPkcs7: PASS verification\n")); Status = RETURN_SUCCESS; Done: return Status; } /** The function is used to do the authentication for FMP capsule based upon EFI_FIRMWARE_IMAGE_AUTHENTICATION. The FMP capsule image should start with EFI_FIRMWARE_IMAGE_AUTHENTICATION, followed by the payload. If the return status is RETURN_SUCCESS, the caller may continue the rest FMP update process. If the return status is NOT RETURN_SUCCESS, the caller should stop the FMP update process and convert the return status to LastAttemptStatus to indicate that FMP update fails. The LastAttemptStatus can be got from ESRT table or via EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo(). Caution: This function may receive untrusted input. @param[in] Image Points to an FMP authentication image, started from EFI_FIRMWARE_IMAGE_AUTHENTICATION. @param[in] ImageSize Size of the authentication image in bytes. @param[in] PublicKeyData The public key data used to validate the signature. @param[in] PublicKeyDataLength The length of the public key data. @retval RETURN_SUCCESS Authentication pass. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_SUCCESS. @retval RETURN_SECURITY_VIOLATION Authentication fail. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR. @retval RETURN_INVALID_PARAMETER The image is in an invalid format. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT. @retval RETURN_UNSUPPORTED No Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT. @retval RETURN_UNSUPPORTED Image or ImageSize is invalid. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT. @retval RETURN_OUT_OF_RESOURCES No Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES. **/ RETURN_STATUS EFIAPI AuthenticateFmpImage ( IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength ) { GUID *CertType; EFI_STATUS Status; if ((Image == NULL) || (ImageSize == 0)) { return RETURN_UNSUPPORTED; } if (ImageSize < sizeof(EFI_FIRMWARE_IMAGE_AUTHENTICATION)) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - ImageSize too small\n")); return RETURN_INVALID_PARAMETER; } if (Image->AuthInfo.Hdr.dwLength <= OFFSET_OF(WIN_CERTIFICATE_UEFI_GUID, CertData)) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - dwLength too small\n")); return RETURN_INVALID_PARAMETER; } if ((UINTN) Image->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof(UINT64)) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - dwLength too big\n")); return RETURN_INVALID_PARAMETER; } if (ImageSize <= sizeof(Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - ImageSize too small\n")); return RETURN_INVALID_PARAMETER; } if (Image->AuthInfo.Hdr.wRevision != 0x0200) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - wRevision: 0x%02x, expect - 0x%02x\n", (UINTN)Image->AuthInfo.Hdr.wRevision, (UINTN)0x0200)); return RETURN_INVALID_PARAMETER; } if (Image->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) { DEBUG((DEBUG_ERROR, "AuthenticateFmpImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (UINTN)Image->AuthInfo.Hdr.wCertificateType, (UINTN)WIN_CERT_TYPE_EFI_GUID)); return RETURN_INVALID_PARAMETER; } CertType = &Image->AuthInfo.CertType; DEBUG((DEBUG_INFO, "AuthenticateFmpImage - CertType: %g\n", CertType)); if (CompareGuid (&gEfiCertPkcs7Guid, CertType)) { // // Call the match handler to extract raw data for the input section data. // Status = FmpAuthenticatedHandlerPkcs7 ( Image, ImageSize, PublicKeyData, PublicKeyDataLength ); return Status; } // // Not found, the input guided section is not supported. // return RETURN_UNSUPPORTED; }
5d5684815f675e082b5f6bbc264eab4207179dc8
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/allwinner/libraries/sunxi-hal/hal/source/prcm/prcm-sun50iw11/ccu_regs.h
11465222055c7b4539c2e7a67e0cc49969b6dc3b
[ "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
17,902
h
ccu_regs.h
/* ********************************************************************************************************* * AR100 SYSTEM * AR100 Software System Develop Kits * clock control unit module * * (c) Copyright 2012-2016, Sunny China * All Rights Reserved * * File : ccu_regs.h * By : Sunny * Version : v1.0 * Date : 2012-5-7 * Descript: clock control unit register defines. * Update : date auther ver notes * 2012-5-7 8:47:58 Sunny 1.0 Create this file. ********************************************************************************************************* */ #ifndef __CCU_REGS_H__ #define __CCU_REGS_H__ #include <sunxi_hal_common.h> /* refer to prcm spec register description */ typedef struct ccu_cpus_clk_cfg_reg0000 { u32 factor_m:5; /* bit0, cpus clock ratio */ u32 reserved2:3; /* bit5, reserved */ u32 factor_n:2; /* bit8, cpus post divider */ u32 reserved1:14; /* bit10, reserved */ u32 src_sel:3; /* bit24, cpus source select */ u32 reserved0:5; /* bit27, reserved */ } ccu_cpus_clk_cfg_reg0000_t; typedef struct ccu_apbs1_cfg_reg000c { u32 factor_m:5; /* bit0, apbs1 clock divider ratio */ u32 reserved2:3; /* bit5, reserved */ u32 factor_n:2; /* bit8, cpus post divider */ u32 reserved1:14; /* bit10, reserved */ u32 src_sel:3; /* bit24, cpus source select */ u32 reserved0:5; /* bit27, reserved */ } ccu_apbs1_cfg_reg000c_t; typedef struct ccu_apbs2_cfg_reg0010 { u32 factor_m:5; /* bit0, cpus clock ratio */ u32 reserved2:3; /* bit5, reserved */ u32 factor_n:2; /* bit8, cpus post divider */ u32 reserved1:14; /* bit10, reserved */ u32 src_sel:3; /* bit24, cpus source select */ u32 reserved0:5; /* bit27, reserved */ } ccu_apbs2_cfg_reg0010_t; typedef struct ccu_mod_gate_reset_reg { u32 gate:1; /* bit0, gate */ u32 reserved1:15; /* bit1, reserved */ u32 reset:1; /* bit16, reset */ u32 reserved0:15; /* bit17, reserved */ } ccu_mod_gate_reset_reg_t; typedef struct ccu_mod_clk_reg { u32 factor_m:5; /* bit0, clock divider ratio m */ u32 reserved2:3; /* bit5, reserved */ u32 factor_n:2; /* bit8, clock pre-divider ratio n */ u32 reserved1:14; /* bit10, reserved */ u32 src_sel:1; /* bit24, clock source select */ u32 reserved0:6; /* bit25, reserved */ u32 sclk_gate:1; /* bit31, gating special clock(max clock = 24M) */ } ccu_mod_clk_reg_t; typedef struct ccu_mod_lpsd_clk_reg { u32 factor_m0:5; /* bit0, clock divider ratio m0 */ u32 reserved3:3; /* bit5, reserved */ u32 factor_m1:5; /* bit8 - bit12, clock pre-divider ratio m1 */ u32 reserved2:3; /* bit13 - bit15, reserved */ u32 factor_n:2; /* bit16 - bit17, clock pre-divider ratio n */ u32 reserved1:6; /* bit18 - bit23, reserved */ u32 src_sel:2; /* bit24, clock source select */ u32 reserved0:5; /* bit26, reserved */ u32 sclk_gate:1; /* bit31, gating */ } ccu_mod_lpsd_clk_reg_t; typedef struct ccu_mod_audio_clk_reg { u32 factor_m:5; /* bit0, clock divider ratio m */ u32 reserved2:3; /* bit5, reserved */ u32 factor_n:2; /* bit8, clock pre-divider ratio n */ u32 reserved1:14; /* bit10, reserved */ u32 src_sel:2; /* bit24, clock source select */ u32 reserved0:5; /* bit26, reserved */ u32 sclk_gate:1; /* bit31, gating */ } ccu_mod_audio_clk_reg_t; typedef struct ccu_pll_ctrl_reg0240 { u32 pll_bias_en:1; /* bit0, pll bias enbale */ u32 gm0:1; /* bit1, gm0 */ u32 gm1:1; /* bit2, gm1 */ u32 reserved1:21; /* bit3, reserved */ u32 test_clk_sel:1; /* bit24, test clock select */ u32 reserved0:7; /* bit25, reserved */ } ccu_pll_ctrl_reg0240_t; typedef struct ccu_pll_ctrl_reg0244 { u32 ldo_en:1; /* bit0, ldo enable, all pll digital power */ u32 reserved2:1; /* bit1, reserved */ u32 osc24M_en:1; /* bit2, osc24M enable */ u32 plltest_en:1; /* bit3, clock test enable, for verify */ u32 mbias_en:1; /* bit4, chip master bias enable */ u32 reserved1:11; /* bit5, reserved */ u32 pllvdd_ldo_out_ctrl:3; /* bit16, pllvdd ldo output control */ u32 reserved0:5; /* bit19, reserved */ u32 key_field:8; /* bit24, key field LDO enable bit */ } ccu_pll_ctrl_reg0244_t; typedef struct ccu_sys_pwroff_gate_reg0250 { u32 reserved2:2; /* bit0, reserved */ u32 vdd_cpus_gate:1; /* bit2, gating the corresponding modules to the * CPUS power domain when VDD_SYS power off */ u32 vdd_sys2usb_gate:1; /* bit3 */ u32 vdd_ddr_gate:1; /* bit4 */ u32 reserved1:3; /* bit5, reserved */ u32 vdd_usb2cpus_gate:1; /* bit8 */ u32 reserved0:23; /* bit9, reserved */ } ccu_sys_pwroff_gate_reg0250_t; typedef struct ccu_ana_pwroff_gate_reg0254 { u32 avcc_a_gate:1; /* bit0, gating the corresponding modules to the * AVCC_A power domain when VDD_SYS power off */ u32 res_vdd_on_ctrl:1; /* bit1 */ u32 reserved0:30; /* bit2, reserved */ } ccu_ana_pwroff_gate_reg0254_t; typedef struct ccu_ve_pwroff_gate_reg0258 { u32 poweroff_gate:1; /* bit0, gating the corresponding modules * when VE power off */ u32 reserved0:31; /* bit1, reserved */ } ccu_ve_pwroff_gate_reg0258_t; typedef struct ccu_sys_pwr_rst_reg0260 { u32 module_reset : 1; /* bit0, VDD_SYS power domain modules should be * reset before VDD_SYS power on */ u32 reserved0 : 31; /* bit1, reserved */ } ccu_sys_pwr_rst_reg0260_t; typedef struct ccu_prcm_sec_sw_cfg_reg0290 { u32 cpus_clk_sec:1; /* bit0, cpus clk relevant register's security */ u32 pll_sec:1; /* bit1, pll ctrl relevant register's security */ u32 power_sec:1; /* bit2, power relevant register' security */ u32 reserved0:29; /* bit3, reserved */ } ccu_prcm_sec_sw_cfg_reg0290_t; typedef struct ccu_reg_list { volatile ccu_cpus_clk_cfg_reg0000_t cpus_clk_cfg; /* 0x0000 */ volatile u32 reserved0[2]; /* 0x0004 */ volatile ccu_apbs1_cfg_reg000c_t apbs1_cfg; /* 0x000c */ volatile ccu_apbs2_cfg_reg0010_t apbs2_cfg; /* 0x0010 */ volatile u32 reserved1[47]; /* 0x0014 - 0x0D0 */ volatile ccu_mod_lpsd_clk_reg_t r_lpsd; /* 0x00D0 */ volatile u32 reserved2[18]; /* 0x00D4- 0x011c */ volatile ccu_mod_gate_reset_reg_t r_timer; /* 0x011c */ volatile u32 reserved3[3]; /* 0x0120 - 0x0128 */ volatile ccu_mod_gate_reset_reg_t r_twd; /* 0x012c */ volatile u32 reserved4[3]; /* 0x0130 - 0x0138 */ volatile ccu_mod_gate_reset_reg_t r_pwm; /* 0x013c */ volatile ccu_mod_audio_clk_reg_t r_ac_adc; /* 0x0140 */ volatile ccu_mod_audio_clk_reg_t r_ac_dac; /* 0x0144 */ volatile u32 reserved5[1]; /* 0x0148 */ volatile ccu_mod_gate_reset_reg_t r_ac_gate; /* 0x014c */ volatile ccu_mod_audio_clk_reg_t r_dmic; /* 0x0150 */ volatile u32 reserved6[2]; /* 0x0154 - 0x0158 */ volatile ccu_mod_gate_reset_reg_t r_dmic_gate; /* 0x015C */ volatile u32 reserved7[4]; /* 0x0160 - 0x016C */ volatile ccu_mod_audio_clk_reg_t r_i2s0; /* 0x0170 */ volatile ccu_mod_audio_clk_reg_t r_i2s0_asrc; /* 0x0174 */ volatile ccu_mod_audio_clk_reg_t r_i2s1; /* 0x0178 */ volatile u32 reserved8[4]; /* 0x017C - 0x0188 */ volatile ccu_mod_gate_reset_reg_t r_uart; /* 0x018c */ volatile u32 reserved9[3]; /* 0x0190 - 0x0198 */ volatile ccu_mod_gate_reset_reg_t r_twi; /* 0x019c */ volatile u32 reserved10[7]; /* 0x01a0 - 0x01b8 */ volatile ccu_mod_gate_reset_reg_t r_rsb; /* 0x01bc */ volatile ccu_mod_clk_reg_t r_ir_clk; /* 0x01c0 */ volatile u32 reserved11[2]; /* 0x01c4 - 0x01c8 */ volatile ccu_mod_gate_reset_reg_t r_ir; /* 0x01cc */ volatile u32 reserved12[4]; /* 0x01d0 - 0x01dc */ /* FIXME: no owc register */ volatile ccu_mod_clk_reg_t r_owc_clk; /* 0x01e0 */ volatile u32 reserved13[2]; /* 0x01e4 - 0x01e8 */ volatile ccu_mod_gate_reset_reg_t r_owc; /* 0x01ec */ volatile u32 reserved14[7]; /* 0x01f0 - 0x0208 */ volatile ccu_mod_gate_reset_reg_t r_rtc; /* 0x020c */ volatile u32 reserved15[12]; /* 0x0210 - 0x023c */ volatile ccu_pll_ctrl_reg0240_t pll_ctrl0; /* 0x0240 */ volatile ccu_pll_ctrl_reg0244_t pll_ctrl1; /* 0x0244 */ volatile u32 reserved16[2]; /* 0x0248 - 0x024c */ volatile ccu_sys_pwroff_gate_reg0250_t sys_pwroff_gate;/* 0x0250 */ volatile ccu_ana_pwroff_gate_reg0254_t ana_pwroff_gate;/* 0x0254 */ volatile ccu_ve_pwroff_gate_reg0258_t ve_pwroff_gate; /* 0x0258 */ volatile u32 reserved17; /* 0x025c */ volatile ccu_sys_pwr_rst_reg0260_t sys_pwr_rst; /* 0x0260 */ volatile u32 reserved18[3]; /* 0x0264 - 0x26c */ volatile u32 ram_cfg; /* 0x0270 */ volatile u32 ram_test; /* 0x0274 */ volatile u32 reserved19[6]; /* 0x0278 - 0x028c */ volatile ccu_prcm_sec_sw_cfg_reg0290_t prcm_sec_sw_cfg;/* 0x0290 */ volatile u32 reserved20[87]; /* 0x0294 - 0x03ec */ volatile u32 prcm_version; /* 0x03f0 */ } ccu_reg_list_t; /* refer to ccmu spec register description */ typedef struct ccu_pll_c0_cpux_reg0000 { volatile u32 factor_m:2; /* bit0, PLL1 Factor_M */ volatile u32 reserved3:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, PLL1 Factor_N */ volatile u32 factor_p:2; /* bit16, PLL1 Factor_P */ volatile u32 reserved2:6; /* bit18, reserved */ volatile u32 lock_time:3; /* bit24, lock time:freq scaling step */ volatile u32 reserved1:1; /* bit27, reserved */ volatile u32 lock_st:1; /* bit28, 0-unlocked, 1-locked(PLL has been stable) */ volatile u32 lock_en:1; /* bit29, 0-disable lock, 1-enable lock */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, (24Mhz*N*K)/(M) */ } ccu_pll_c0_cpux_reg0000_t; typedef struct ccu_pll_ddr0_reg0010 { volatile u32 factor_m0:1; /* bit0, factor_m0 */ volatile u32 factor_m1:1; /* bit1, factor_m1 */ volatile u32 reserved3:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, factor_n */ volatile u32 reserved2:8; /* bit16, reserved */ volatile u32 sdm_en:1; /* bit24, sdm enable */ volatile u32 reserved1:3; /* bit25, reserved */ volatile u32 lock_st:1; /* bit28, lock state */ volatile u32 lock_en:1; /* bit29, lock enable */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, (24Mhz*N*K)/(M) */ } ccu_pll_ddr0_reg0010_t; typedef struct ccu_pll_periph_reg0010 { volatile u32 reserved0:1; volatile u32 factor_m:1; volatile u32 reserved1:6; volatile u32 factor_n:8; volatile u32 factor_p0:3; volatile u32 reserved2:1; volatile u32 factor_p1:3; volatile u32 reserved3:1; volatile u32 sdm_en:1; volatile u32 reserved4:2; volatile u32 output_en:1; volatile u32 lock:1; volatile u32 lock_en:1; volatile u32 reserved5:1; volatile u32 enable:1; } ccu_pll_periph_reg0010_t; typedef struct ccu_pll_audio0_reg0020 { volatile u32 reserved0:1; volatile u32 factor_m:1; volatile u32 reserved1:6; volatile u32 factor_n:8; volatile u32 factor_p0:3; volatile u32 reserved2:1; volatile u32 factor_p1:3; volatile u32 reserved3:1; volatile u32 sdm_en:1; volatile u32 reserved4:2; volatile u32 output_en:1; volatile u32 lock:1; volatile u32 lock_en:1; volatile u32 reserved5:1; volatile u32 enable:1; } ccu_pll_audio0_reg0020_t; typedef struct ccu_pll_periph0_reg0020 { volatile u32 factor_m0:1; /* bit0, factor_m0 */ volatile u32 factor_m1:1; /* bit1, factor_m1 */ volatile u32 reserved2:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, factor_n */ volatile u32 reserved1:12; /* bit16, reserved */ volatile u32 lock_st:1; /* bit28, lock state */ volatile u32 lock_en:1; /* bit29, lock enable */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, (24Mhz*N*K)/(M) */ } ccu_pll_periph0_reg0020_t; typedef struct ccu_pll_periph1_reg0028 { volatile u32 factor_m0:1; /* bit0, factor_m0 */ volatile u32 factor_m1:1; /* bit1, factor_m1 */ volatile u32 reserved2:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, factor_n */ volatile u32 reserved1:12; /* bit16, reserved */ volatile u32 lock_st:1; /* bit28, lock state */ volatile u32 lock_en:1; /* bit29, lock enable */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, (24Mhz*N*K)/(M) */ } ccu_pll_periph1_reg0028_t; typedef struct ccu_pll_audio0_reg { volatile u32 factor_m0:1; /* bit0, factor_m0 */ volatile u32 factor_m1:1; /* bit1, factor_m1 */ volatile u32 reserved3:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, factor_n */ volatile u32 div_p0:3; /* bit16, post div-p0 */ volatile u32 reserved2:1; /* bit19, reserved */ volatile u32 div_p1:3; /* bit20, post div-p1 */ volatile u32 sdm_enable:1; /* bit24, pll sdm enable */ volatile u32 reserved1:2; /* bit25, reserved */ volatile u32 pll_out:1; /* bit27, pll output enable */ volatile u32 lock_st:1; /* bit28, lock state */ volatile u32 lock_en:1; /* bit29, lock enable */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, 1X:(24Mhz*N*M0/M1)/(P)/4 */ } ccu_pll_audio0_reg_t; typedef struct ccu_pll_audio1_reg { volatile u32 factor_m0:1; /* bit0, factor_m0 */ volatile u32 factor_m1:1; /* bit1, factor_m1 */ volatile u32 reserved3:6; /* bit2, reserved */ volatile u32 factor_n:8; /* bit8, factor_n */ volatile u32 div_p:6; /* bit16, post div-p */ volatile u32 reserved2:2; /* bit22, reserved */ volatile u32 sdm_enable:1; /* bit24, pll sdm enable */ volatile u32 reserved1:2; /* bit25, reserved */ volatile u32 pll_out:1; /* bit27, pll output enable */ volatile u32 lock_st:1; /* bit28, lock state */ volatile u32 lock_en:1; /* bit29, lock enable */ volatile u32 reserved0:1; /* bit30, reserved */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, 1X:(24Mhz*N*M0/M1)/(P)/4 */ } ccu_pll_audio1_reg_t; typedef struct ccu_pll_audio0_pat0_reg { volatile u32 wave_bot:17; /* bit0 - bit16, wave bottom */ volatile u32 freq:2; /* bit17 - bit18, frequency */ volatile u32 clk_sel:1; /* bit19, 0:24M, 1:12M, SDM clk select */ volatile u32 wave_step:9; /* bit20 - bit28, wave step */ volatile u32 freq_mode:2; /* bit29 - bit30, Spread frequency mode */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, Sigma-Delta Pattern Enable */ } ccu_pll_audio0_pat0_reg_t; typedef struct ccu_pll_audio1_pat0_reg { volatile u32 wave_bot:17; /* bit0 - bit16, wave bottom */ volatile u32 freq:2; /* bit17 - bit18, frequency */ volatile u32 clk_sel:1; /* bit19, 0:24M, 1:12M, SDM clk select */ volatile u32 wave_step:9; /* bit20 - bit28, wave step */ volatile u32 freq_mode:2; /* bit29 - bit30, Spread frequency mode */ volatile u32 enable:1; /* bit31, 0-disable, 1-enable, Sigma-Delta Pattern Enable */ } ccu_pll_audio1_pat0_reg_t; #endif /* __CCU_REGS_H__ */
9abd262c884ea623aec5a882ddf8225db641de4f
8126d163872d9c2e56c6628f41e259d88168fc9f
/src/lang.h
9f813d8bf0c9180a0f12f6bee0689c9dfa21f502
[ "BSD-2-Clause-Views", "BSD-2-Clause" ]
permissive
XProger/OpenLara
8c16a7cafdcd44c74356e0c6b7a1d0ab38c20191
d2e363db886b0aa2b666aa5d44a1beef321665d7
refs/heads/master
2023-08-31T14:13:08.805461
2023-06-28T22:54:59
2023-06-28T22:54:59
65,638,810
4,515
466
BSD-2-Clause
2023-09-10T18:01:09
2016-08-13T22:06:58
C
MacCyrillic
C
false
false
9,269
h
lang.h
#ifndef H_LANG #define H_LANG // Thanks: SuiKaze Raider enum StringID { STR_EMPTY // common , STR_LOADING , STR_HELP_PRESS , STR_HELP_TEXT , STR_LEVEL_STATS , STR_HINT_SAVING , STR_HINT_SAVING_DONE , STR_HINT_SAVING_ERROR , STR_YES , STR_NO , STR_OFF , STR_ON , STR_NO_STEREO , STR_SBS , STR_ANAGLYPH , STR_SPLIT , STR_VR , STR_QUALITY_LOW , STR_QUALITY_MEDIUM , STR_QUALITY_HIGH , STR_LANG_EN , STR_LANG_FR , STR_LANG_DE , STR_LANG_ES , STR_LANG_IT , STR_LANG_PL , STR_LANG_PT , STR_LANG_RU , STR_LANG_JA , STR_LANG_GR , STR_LANG_FI , STR_LANG_CZ , STR_LANG_CN , STR_LANG_HU , STR_LANG_SV , STR_APPLY , STR_GAMEPAD_1 , STR_GAMEPAD_2 , STR_GAMEPAD_3 , STR_GAMEPAD_4 , STR_NOT_READY , STR_PLAYER_1 , STR_PLAYER_2 , STR_PRESS_ANY_KEY , STR_HELP_SELECT , STR_HELP_BACK // inventory pages , STR_OPTION , STR_INVENTORY , STR_ITEMS // save game page , STR_SAVEGAME , STR_CURRENT_POSITION // inventory option , STR_GAME , STR_MAP , STR_COMPASS , STR_STOPWATCH , STR_HOME , STR_DETAIL , STR_SOUND , STR_CONTROLS , STR_GAMMA // passport menu , STR_LOAD_GAME , STR_START_GAME , STR_RESTART_LEVEL , STR_EXIT_TO_TITLE , STR_EXIT_GAME , STR_SELECT_LEVEL // detail options , STR_SELECT_DETAIL , STR_OPT_DETAIL_FILTER , STR_OPT_DETAIL_LIGHTING , STR_OPT_DETAIL_SHADOWS , STR_OPT_DETAIL_WATER , STR_OPT_DETAIL_VSYNC , STR_OPT_DETAIL_STEREO , STR_OPT_SIMPLE_ITEMS , STR_OPT_RESOLUTION , STR_SCALE_100 , STR_SCALE_75 , STR_SCALE_50 , STR_SCALE_25 // sound options , STR_SET_VOLUMES , STR_REVERBERATION , STR_OPT_SUBTITLES , STR_OPT_LANGUAGE // controls options , STR_SET_CONTROLS , STR_OPT_CONTROLS_KEYBOARD , STR_OPT_CONTROLS_GAMEPAD , STR_OPT_CONTROLS_VIBRATION , STR_OPT_CONTROLS_RETARGET , STR_OPT_CONTROLS_MULTIAIM // controls , STR_CTRL_FIRST , STR_CTRL_LAST = STR_CTRL_FIRST + cMAX - 1 // keys , STR_KEY_FIRST , STR_KEY_LAST = STR_KEY_FIRST + ikBack // gamepad , STR_JOY_FIRST , STR_JOY_LAST = STR_JOY_FIRST + jkMAX - 1 // inventory items , STR_UNKNOWN , STR_EXPLOSIVE , STR_PISTOLS , STR_SHOTGUN , STR_MAGNUMS , STR_UZIS , STR_AMMO_PISTOLS , STR_AMMO_SHOTGUN , STR_AMMO_MAGNUMS , STR_AMMO_UZIS , STR_MEDI_SMALL , STR_MEDI_BIG , STR_LEAD_BAR , STR_SCION // keys , STR_KEY , STR_KEY_SILVER , STR_KEY_RUSTY , STR_KEY_GOLD , STR_KEY_SAPPHIRE , STR_KEY_NEPTUNE , STR_KEY_ATLAS , STR_KEY_DAMOCLES , STR_KEY_THOR , STR_KEY_ORNATE // puzzles , STR_PUZZLE , STR_PUZZLE_GOLD_IDOL , STR_PUZZLE_GOLD_BAR , STR_PUZZLE_COG , STR_PUZZLE_FUSE , STR_PUZZLE_ANKH , STR_PUZZLE_HORUS , STR_PUZZLE_ANUBIS , STR_PUZZLE_SCARAB , STR_PUZZLE_PYRAMID // TR1 subtitles , STR_TR1_SUB_CAFE , STR_TR1_SUB_LIFT , STR_TR1_SUB_CANYON , STR_TR1_SUB_PRISON , STR_TR1_SUB_22 // CUT4 , STR_TR1_SUB_23 // CUT1 , STR_TR1_SUB_24 , STR_TR1_SUB_25 // CUT3 , STR_TR1_SUB_26 , STR_TR1_SUB_27 , STR_TR1_SUB_28 , STR_TR1_SUB_29 , STR_TR1_SUB_30 , STR_TR1_SUB_31 , STR_TR1_SUB_32 , STR_TR1_SUB_33 , STR_TR1_SUB_34 , STR_TR1_SUB_35 , STR_TR1_SUB_36 , STR_TR1_SUB_37 , STR_TR1_SUB_38 , STR_TR1_SUB_39 , STR_TR1_SUB_40 , STR_TR1_SUB_41 , STR_TR1_SUB_42 , STR_TR1_SUB_43 , STR_TR1_SUB_44 , STR_TR1_SUB_45 , STR_TR1_SUB_46 , STR_TR1_SUB_47 , STR_TR1_SUB_48 , STR_TR1_SUB_49 , STR_TR1_SUB_50 , STR_TR1_SUB_51 , STR_TR1_SUB_52 , STR_TR1_SUB_53 , STR_TR1_SUB_54 , STR_TR1_SUB_55 , STR_TR1_SUB_56 // TR1 levels , STR_TR1_GYM , STR_TR1_LEVEL1 , STR_TR1_LEVEL2 , STR_TR1_LEVEL3A , STR_TR1_LEVEL3B , STR_TR1_LEVEL4 , STR_TR1_LEVEL5 , STR_TR1_LEVEL6 , STR_TR1_LEVEL7A , STR_TR1_LEVEL7B , STR_TR1_LEVEL8A , STR_TR1_LEVEL8B , STR_TR1_LEVEL8C , STR_TR1_LEVEL10A , STR_TR1_LEVEL10B , STR_TR1_LEVEL10C , STR_TR1_EGYPT , STR_TR1_CAT , STR_TR1_END , STR_TR1_END2 // TR2 levels , STR_TR2_ASSAULT , STR_TR2_WALL , STR_TR2_BOAT , STR_TR2_VENICE , STR_TR2_OPERA , STR_TR2_RIG , STR_TR2_PLATFORM , STR_TR2_UNWATER , STR_TR2_KEEL , STR_TR2_LIVING , STR_TR2_DECK , STR_TR2_SKIDOO , STR_TR2_MONASTRY , STR_TR2_CATACOMB , STR_TR2_ICECAVE , STR_TR2_EMPRTOMB , STR_TR2_FLOATING , STR_TR2_XIAN , STR_TR2_HOUSE // TR3 levels , STR_TR3_HOUSE , STR_TR3_JUNGLE , STR_TR3_TEMPLE , STR_TR3_QUADCHAS , STR_TR3_TONYBOSS , STR_TR3_SHORE , STR_TR3_CRASH , STR_TR3_RAPIDS , STR_TR3_TRIBOSS , STR_TR3_ROOFS , STR_TR3_SEWER , STR_TR3_TOWER , STR_TR3_OFFICE , STR_TR3_NEVADA , STR_TR3_COMPOUND , STR_TR3_AREA51 , STR_TR3_ANTARC , STR_TR3_MINES , STR_TR3_CITY , STR_TR3_CHAMBER , STR_TR3_STPAUL , STR_MAX }; #ifdef _XBOX // TODO: illegal escape sequence #define STR_RUSSIAN "Russian" #else #define STR_RUSSIAN "–усски{и" #endif #define STR_LANGUAGES \ "English" \ , "Fran|cais" \ , "Deutsch" \ , "Espa+nol" \ , "Italiano" \ , "Polski" \ , "Portugu(es" \ , STR_RUSSIAN \ , "\x11\x02\x70\x01\x97\x01\xD6\xFF\xFF" \ , "\x11\x01\x22\x01\x0F\x01\x0F\x01\x0E\x01\x06\x01\x04\x01\x0C\x01\x0B\xFF\xFF" \ , "Suomi" \ , "{Cesky" \ , "\x11\x02\x8A\x02\x6C\x01\x54\x03\x02\xFF\xFF" \ , "Magyar" \ , "Svenska" #define LANG_PREFIXES "_EN", "_FR", "_DE", "_ES", "_IT", "_PL", "_PT", "_RU", "_JA", "_GR", "_FI", "_CZ", "_CN", "_HU", "_SV" #define STR_KEYS \ "NONE", "LEFT", "RIGHT", "UP", "DOWN", "SPACE", "TAB", "ENTER", "ESCAPE", "SHIFT", "CTRL", "ALT" \ , "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" \ , "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" \ , "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" \ , "PAD0", "PAD1", "PAD2", "PAD3", "PAD4", "PAD5", "PAD6", "PAD7", "PAD8", "PAD9", "PAD+", "PAD-", "PADx", "PAD/", "PAD." \ , "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" \ , "-", "+", "<", ">", "/", "\\", ",", ".", "$", ":", "'", "PGUP", "PGDN", "HOME", "END", "DEL", "INS", "BKSP" \ , "NONE", "A", "B", "X", "Y", "L BUMPER", "R BUMPER", "SELECT", "START", "L STICK", "R STICK", "L TRIGGER", "R TRIGGER", "D-LEFT", "D-RIGHT", "D-UP", "D-DOWN" #define STR_SCALE "25", "50", "75", "100" const char *helpText = "Start - add second player or restore Lara@" "H - Show or hide this help@" "ALT and ENTER - Fullscreen@" "5 - Save Game@" "9 - Load Game@" "C - Look@" "R - Slow motion@" "T - Fast motion@" "Roll - Up & Down@" "Step Left - Walk & Left@" "Step Right - Walk & Right@" "Out of water - Up & Action@" "Handstand - Up & Walk@" "Swan dive - Up & Walk & Jump@" "First Person View - Look & Action@" "DOZY on - Look & Duck & Action & Jump@" "DOZY off - Walk@" "Free Camera - hold L & R stick"; #include "lang/en.h" #include "lang/fr.h" #include "lang/de.h" #include "lang/es.h" #include "lang/it.h" #include "lang/pl.h" #include "lang/pt.h" #include "lang/ru.h" #include "lang/ja.h" #include "lang/gr.h" #include "lang/fi.h" #include "lang/cz.h" #include "lang/cn.h" #include "lang/hu.h" #include "lang/sv.h" char **STR = NULL; void ensureLanguage(int lang) { ASSERT(COUNT(STR_EN) == STR_MAX); ASSERT(COUNT(STR_FR) == STR_MAX); ASSERT(COUNT(STR_DE) == STR_MAX); ASSERT(COUNT(STR_ES) == STR_MAX); ASSERT(COUNT(STR_IT) == STR_MAX); ASSERT(COUNT(STR_PL) == STR_MAX); ASSERT(COUNT(STR_PT) == STR_MAX); ASSERT(COUNT(STR_RU) == STR_MAX); ASSERT(COUNT(STR_JA) == STR_MAX); ASSERT(COUNT(STR_GR) == STR_MAX); ASSERT(COUNT(STR_FI) == STR_MAX); ASSERT(COUNT(STR_CZ) == STR_MAX); ASSERT(COUNT(STR_CN) == STR_MAX); ASSERT(COUNT(STR_HU) == STR_MAX); ASSERT(COUNT(STR_SV) == STR_MAX); lang += STR_LANG_EN; switch (lang) { case STR_LANG_FR : STR = (char**)STR_FR; break; case STR_LANG_DE : STR = (char**)STR_DE; break; case STR_LANG_ES : STR = (char**)STR_ES; break; case STR_LANG_IT : STR = (char**)STR_IT; break; case STR_LANG_PL : STR = (char**)STR_PL; break; case STR_LANG_PT : STR = (char**)STR_PT; break; case STR_LANG_RU : STR = (char**)STR_RU; break; case STR_LANG_JA : STR = (char**)STR_JA; break; case STR_LANG_GR : STR = (char**)STR_GR; break; case STR_LANG_FI : STR = (char**)STR_FI; break; case STR_LANG_CZ : STR = (char**)STR_CZ; break; case STR_LANG_CN : STR = (char**)STR_CN; break; case STR_LANG_HU : STR = (char**)STR_HU; break; case STR_LANG_SV : STR = (char**)STR_SV; break; default : STR = (char**)STR_EN; break; } } #endif
f7c2c02985258ef5a7f0dda37e9af00ad5d0e74a
62bf09400de89c1aa77d8c2570d7f66cec0b5d36
/fnet_stack/port/cpu/mimxrt/fnet_mimxrt_eth.c
5a177a7e1a46ec290f6bd7f7f18b7597cff95d4d
[ "Apache-2.0" ]
permissive
butok/FNET
41b1d2ec4cc683c1b5c188a17ab6a4bb890a6af6
ea43715752e6f6823bfcc8bdc94e440443112e7c
refs/heads/master
2023-08-03T16:32:09.317085
2023-07-20T07:01:55
2023-07-20T07:01:55
50,664,554
115
40
Apache-2.0
2023-07-20T07:01:56
2016-01-29T13:39:30
C
UTF-8
C
false
false
18,700
c
fnet_mimxrt_eth.c
/************************************************************************** * * Copyright 2018 by Andrey Butok. FNET Community. * *************************************************************************** * * 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. * *************************************************************************** * * Ethernet driver interface. * ***************************************************************************/ #include "fnet.h" #if FNET_MIMXRT && FNET_CFG_CPU_ETH0 #include "port/netif/fec/fnet_fec.h" /* MCUX */ #include "fsl_iomuxc.h" #include "fsl_gpio.h" #include "fsl_clock.h" static fnet_return_t fnet_mimxrt_eth_init(fnet_netif_t *netif); static fnet_return_t fnet_mimxrt_eth_phy_init(fnet_netif_t *netif); /************************************************************************ * Ethernet interface structure. *************************************************************************/ static fnet_eth_if_t fnet_mimxrt_eth0_if = { .eth_prv = &fnet_fec0_if, /* Points to Ethernet driver-specific control data structure. */ .eth_mac_number = 0, /* MAC module number. */ .eth_output = fnet_fec_output, /* Ethernet driver output.*/ .eth_phy_addr = FNET_CFG_CPU_ETH0_PHY_ADDR, /* Set default PHY address */ .eth_cpu_init = fnet_mimxrt_eth_init, .eth_cpu_phy_init = fnet_mimxrt_eth_phy_init, #if FNET_CFG_MULTICAST .eth_multicast_join = fnet_fec_multicast_join, /* Ethernet driver join multicast group.*/ .eth_multicast_leave = fnet_fec_multicast_leave /* Ethernet driver leave multicast group.*/ #endif }; fnet_netif_t fnet_cpu_eth0_if = { .netif_name = FNET_CFG_CPU_ETH0_NAME, /* Network interface name.*/ .netif_mtu = FNET_CFG_CPU_ETH0_MTU, /* Maximum transmission unit.*/ .netif_prv = &fnet_mimxrt_eth0_if, /* Points to interface specific data structure.*/ .netif_api = &fnet_fec_api /* Interface API */ }; /************************************************************************ * DESCRIPTION: Ethernet IO initialization. *************************************************************************/ static fnet_return_t fnet_mimxrt_eth_init(fnet_netif_t *netif) { #if FNET_CFG_CPU_ETH_IO_INIT #if FNET_CFG_CPU_MIMXRT1052 || FNET_CFG_CPU_MIMXRT1062 CLOCK_EnableClock(kCLOCK_Iomuxc); /* iomuxc clock (iomuxc_clk_enable): 0x03u */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 is configured as ENET_RX_DATA00 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 is configured as ENET_RX_DATA01 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 is configured as ENET_RX_EN */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 is configured as ENET_TX_DATA00 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 is configured as ENET_TX_DATA01 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 is configured as ENET_TX_EN */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 is configured as ENET_REF_CLK */ 1U); /* Software Input On Field: Force input path of pad GPIO_B1_10 */ IOMUXC_SetPinMux( IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 is configured as ENET_RX_ER */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 is configured as ENET_MDC */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 is configured as ENET_MDIO */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_04_ENET_RX_DATA00, /* GPIO_B1_04 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_05_ENET_RX_DATA01, /* GPIO_B1_05 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_06_ENET_RX_EN, /* GPIO_B1_06 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_07_ENET_TX_DATA00, /* GPIO_B1_07 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_08_ENET_TX_DATA01, /* GPIO_B1_08 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_09_ENET_TX_EN, /* GPIO_B1_09 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_10_ENET_REF_CLK, /* GPIO_B1_10 PAD functional properties : */ 0x31u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/6 Speed Field: low(50MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Disabled Pull / Keep Select Field: Keeper Pull Up / Down Config. Field: 100K Ohm Pull Down Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_B1_11_ENET_RX_ER, /* GPIO_B1_11 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_EMC_40_ENET_MDC, /* GPIO_EMC_40 PAD functional properties : */ 0xB0E9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: max(200MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_EMC_41_ENET_MDIO, /* GPIO_EMC_41 PAD functional properties : */ 0xB829u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: low(50MHz) Open Drain Enable Field: Open Drain Enabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 is configured as GPIO1_IO09 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 is configured as GPIO1_IO10 */ 0U); /* Software Input On Field: Input Path is determined by functionality */ IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_09_GPIO1_IO09, /* GPIO_AD_B0_09 PAD functional properties : */ 0xB0A9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ IOMUXC_SetPinConfig( IOMUXC_GPIO_AD_B0_10_GPIO1_IO10, /* GPIO_AD_B0_10 PAD functional properties : */ 0xB0A9u); /* Slew Rate Field: Fast Slew Rate Drive Strength Field: R0/5 Speed Field: medium(100MHz) Open Drain Enable Field: Open Drain Disabled Pull / Keep Enable Field: Pull/Keeper Enabled Pull / Keep Select Field: Pull Pull Up / Down Config. Field: 100K Ohm Pull Up Hyst. Enable Field: Hysteresis Disabled */ #endif /* FNET_CFG_CPU_MIMXRT1052 || FNET_CFG_CPU_MIMXRT1062 */ #endif /*!FNET_CFG_CPU_ETH_IO_INIT*/ /* KSZ8081RNB PHY */ /* RMII 50 MHZ CLOCK MODE */ /* An external 50 MHz clock source (oscillator) connected to XI (Pin 9). Register 1Fh, Bit [7] is set to 1 to select 50 MHz clock mode.*/ /* For 50 MHz clock mode, the KSZ8081RNB takes in the 50 MHz RMII REF_CLK from the MAC or system board at XI (Pin 9) and leaves the REF_CLK (Pin 19) as a no connect.*/ { const clock_enet_pll_config_t config = {true, false, 1/* 50MHz*/}; CLOCK_InitEnetPll(&config); IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true); } /* Enable clock for ENET module */ CLOCK_EnableClock(kCLOCK_Enet); #if !FNET_CFG_CPU_CACHE /* To be sure that data cache is disabled. */ SCB_DisableDCache(); #endif return FNET_OK; } /************************************************************************ * DESCRIPTION: Ethernet Physical Transceiver initialization and/or reset. *************************************************************************/ static fnet_return_t fnet_mimxrt_eth_phy_init(fnet_netif_t *netif) { #if FNET_CFG_CPU_MIMXRT1052 || FNET_CFG_CPU_MIMXRT1062/* & KSZ8081RNB PHY */ gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode}; GPIO_PinInit(GPIO1, 9, &gpio_config); /* ENET_RST (active is low)*/ GPIO_PinInit(GPIO1, 10, &gpio_config); /* ENET_INT/NAND_TREE*/ /* Disable NAND tree mode. Pull up the ENET_INT/NAND_TREE# before RESET. At the de-assertion of reset, this pin value is latched by the chip*/ GPIO_WritePinOutput(GPIO1, 10, 1); /* UM: For warm reset, the reset (RST#) pin should be asserted low for a minimum of 500 us. The strap-in pin values are read and updated at the de-assertion of reset.*/ GPIO_WritePinOutput(GPIO1, 9, 0); fnet_timer_delay(100); GPIO_WritePinOutput(GPIO1, 9, 1); /* UM: After the de-assertion of reset, wait a minimum of 100 us before starting programming on the MIIM (MDC/MDIO) interface.*/ fnet_timer_delay(100); /* KSZ8081RNB PHY Register 1Fh, Bit [7] is set to 1 to select 50 MHz clock mode.*/ { #define KSZ8081RNB_PHY_CONTROL2_REG 0x1FU /* PHY Control 2 register. */ #define KSZ8081RNB_PHY_CONTROL2_REFCLK_SELECT_MASK 0x0080U /* PHY RMII reference clock select. 1 = RMII 50 MHz clock mode; clock input to XI (Pin 9) is 50 MHz */ fnet_uint16_t reg_value; while (_fnet_eth_phy_read(netif, KSZ8081RNB_PHY_CONTROL2_REG, &reg_value) != FNET_OK) {} /* If locked here, there is problem between ENET and PHY. */ _fnet_eth_phy_write(netif, KSZ8081RNB_PHY_CONTROL2_REG, (reg_value | KSZ8081RNB_PHY_CONTROL2_REFCLK_SELECT_MASK)); } #endif /* (FNET_CFG_CPU_MIMXRT1052 || FNET_CFG_CPU_MIMXRT1062) & KSZ8081RNB PHY */ return FNET_OK; } /* If vector table is in ROM, pre-install FNET ISR for ENET Receive Frame interrupt*/ #if !FNET_CFG_CPU_VECTOR_TABLE_IS_IN_RAM void ENET_IRQHandler (void) { FNET_ISR_HANDLER(); } #endif #endif /* FNET_MIMXRT && FNET_CFG_CPU_ETH0 */
506b2ad9825a4040c231010098800abb4825b268
35eeffd7c7b0567d58cbd38738935e5e21c4ffa4
/src/image.c
cbf73125eb4e81f9a64f06abecb73dd5938dd9ce
[ "LicenseRef-scancode-unknown-license-reference", "ISC" ]
permissive
francma/wob
8b6643295700c073e7feeee759420be4939cd046
75a65e6c33e916a5453d705ed5b3b21335587631
refs/heads/master
2023-04-05T05:08:20.969574
2023-02-02T13:30:44
2023-02-02T13:30:44
196,771,545
795
63
ISC
2023-03-17T14:37:26
2019-07-13T22:26:59
C
UTF-8
C
false
false
3,870
c
image.c
#define WOB_FILE "buffer.c" #define _POSIX_C_SOURCE 200112L #include <errno.h> #include <fcntl.h> #include <limits.h> #include <pixman.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <unistd.h> #include "image.h" #include "log.h" struct wob_image * wob_image_create_argb8888(size_t width, size_t height) { int shmid = -1; char shm_name[NAME_MAX]; for (int i = 0; i < UCHAR_MAX; ++i) { if (snprintf(shm_name, NAME_MAX, "/wob-%d", i) >= NAME_MAX) { break; } shmid = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0600); if (shmid > 0 || errno != EEXIST) { break; } } if (shmid < 0) { wob_log_error("shm_open() failed: %s", strerror(errno)); return NULL; } if (shm_unlink(shm_name) != 0) { wob_log_error("shm_unlink() failed: %s", strerror(errno)); return NULL; } size_t size = width * height * 8; if (ftruncate(shmid, size) != 0) { wob_log_error("ftruncate() failed: %s", strerror(errno)); return NULL; } void *buffer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0); if (buffer == MAP_FAILED) { wob_log_error("mmap() failed: %s", strerror(errno)); return NULL; } pixman_image_t *pixman = pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8, width, height, buffer, width * 4); struct wob_image *image = malloc(sizeof(struct wob_image)); image->shmid = shmid; image->width = width; image->height = height; image->size_in_bytes = width * height * 4; image->stride = width * 4; image->_data = pixman; return image; } void wob_image_destroy(struct wob_image *image) { pixman_image_t *pixman = image->_data; pixman_image_unref(pixman); free(image); } pixman_color_t wob_color_to_pixman(struct wob_color color) { return (pixman_color_t){ .red = (uint16_t) (color.r * UINT16_MAX), .green = (uint16_t) (color.g * UINT16_MAX), .blue = (uint16_t) (color.b * UINT16_MAX), .alpha = (uint16_t) (color.a * UINT16_MAX), }; } void wob_image_draw(struct wob_image *image, struct wob_colors colors, struct wob_dimensions dimensions, unsigned long percentage, unsigned long maximum) { pixman_image_t *pixman = image->_data; pixman_color_t bar_color = wob_color_to_pixman(wob_color_premultiply_alpha(colors.value)); pixman_color_t background_color = wob_color_to_pixman(wob_color_premultiply_alpha(colors.background)); pixman_color_t border_color = wob_color_to_pixman(wob_color_premultiply_alpha(colors.border)); size_t offset_border_padding = dimensions.border_offset + dimensions.border_size + dimensions.bar_padding; size_t bar_width = dimensions.width - 2 * offset_border_padding; size_t bar_height = dimensions.height - 2 * offset_border_padding; uint32_t offset = 0; pixman_image_fill_rectangles(PIXMAN_OP_SRC, pixman, &background_color, 1, &(pixman_rectangle16_t){0, 0, dimensions.width, dimensions.height}); offset += dimensions.border_offset; pixman_image_fill_rectangles(PIXMAN_OP_SRC, pixman, &border_color, 1, &(pixman_rectangle16_t){offset, offset, dimensions.width - 2 * offset, dimensions.height - 2 * offset}); offset += dimensions.border_size; pixman_image_fill_rectangles(PIXMAN_OP_SRC, pixman, &background_color, 1, &(pixman_rectangle16_t){offset, offset, dimensions.width - 2 * offset, dimensions.height - 2 * offset}); offset += dimensions.bar_padding; uint32_t filled_width = (bar_width * percentage) / maximum; uint32_t filled_height = (bar_height * percentage) / maximum; switch (dimensions.orientation) { case WOB_ORIENTATION_HORIZONTAL: pixman_image_fill_rectangles(PIXMAN_OP_SRC, pixman, &bar_color, 1, &(pixman_rectangle16_t){offset, offset, filled_width, bar_height}); break; case WOB_ORIENTATION_VERTICAL: pixman_image_fill_rectangles(PIXMAN_OP_SRC, pixman, &bar_color, 1, &(pixman_rectangle16_t){offset, offset + bar_height - filled_height, bar_width, filled_height}); break; } }
3232e11adc3bb93df7a091209035bc0549b600d9
fbdc48c28e54fb33ae4842ef95ff63893902c99a
/src/hal/mimxrt/MIMXRT1062/drivers/mimxrt_pads.h
7bfffaeb659c50d4d0a363a5027459b886f02067
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
openmv/openmv
44d4b79fc8693950a2e330e5e0fd95b5c36e230f
8a90e070a88b7fc14c87a00351b9c4a213278419
refs/heads/master
2023-08-30T20:59:57.227603
2023-08-23T16:50:55
2023-08-23T16:50:55
14,360,940
2,150
1,226
MIT
2023-09-14T07:18:15
2013-11-13T10:23:44
C
UTF-8
C
false
false
38,094
h
mimxrt_pads.h
// THIS FILE IS AUTO-GENERATED DO NOT EDIT. /* * This file is part of the OpenMV project. * * Copyright (c) 2023 Ibrahim Abdelkader <iabdalkader@openmv.io> * Copyright (c) 2023 Kwabena W. Agyeman <kwagyeman@openmv.io> * * This work is licensed under the MIT license, see the file LICENSE for details. */ #ifndef __IMXRT_PADS_H__ #define __IMXRT_PADS_H__ #define MIMXRT_PAD_COUNT 149 #define EMC_00_AF_SEMC_DATA00 0x0 #define EMC_00_AF_FLEXPWM4 0x1 #define EMC_00_AF_LPSPI2 0x2 #define EMC_00_AF_XBAR1 0x3 #define EMC_00_AF_FLEXIO1 0x4 #define EMC_00_AF_GPIO 0x5 #define EMC_01_AF_SEMC_DATA01 0x0 #define EMC_01_AF_FLEXPWM4 0x1 #define EMC_01_AF_LPSPI2 0x2 #define EMC_01_AF_XBAR1 0x3 #define EMC_01_AF_FLEXIO1 0x4 #define EMC_01_AF_GPIO 0x5 #define EMC_02_AF_SEMC_DATA02 0x0 #define EMC_02_AF_FLEXPWM4 0x1 #define EMC_02_AF_LPSPI2 0x2 #define EMC_02_AF_XBAR1 0x3 #define EMC_02_AF_FLEXIO1 0x4 #define EMC_02_AF_GPIO 0x5 #define EMC_03_AF_SEMC_DATA03 0x0 #define EMC_03_AF_FLEXPWM4 0x1 #define EMC_03_AF_LPSPI2 0x2 #define EMC_03_AF_XBAR1 0x3 #define EMC_03_AF_FLEXIO1 0x4 #define EMC_03_AF_GPIO 0x5 #define EMC_04_AF_SEMC_DATA04 0x0 #define EMC_04_AF_FLEXPWM4 0x1 #define EMC_04_AF_SAI2 0x2 #define EMC_04_AF_XBAR1 0x3 #define EMC_04_AF_FLEXIO1 0x4 #define EMC_04_AF_GPIO 0x5 #define EMC_05_AF_SEMC_DATA05 0x0 #define EMC_05_AF_FLEXPWM4 0x1 #define EMC_05_AF_SAI2 0x2 #define EMC_05_AF_XBAR1 0x3 #define EMC_05_AF_FLEXIO1 0x4 #define EMC_05_AF_GPIO 0x5 #define EMC_06_AF_SEMC_DATA06 0x0 #define EMC_06_AF_FLEXPWM2 0x1 #define EMC_06_AF_SAI2 0x2 #define EMC_06_AF_XBAR1 0x3 #define EMC_06_AF_FLEXIO1 0x4 #define EMC_06_AF_GPIO 0x5 #define EMC_07_AF_SEMC_DATA07 0x0 #define EMC_07_AF_FLEXPWM2 0x1 #define EMC_07_AF_SAI2 0x2 #define EMC_07_AF_XBAR1 0x3 #define EMC_07_AF_FLEXIO1 0x4 #define EMC_07_AF_GPIO 0x5 #define EMC_08_AF_SEMC_DM00 0x0 #define EMC_08_AF_FLEXPWM2 0x1 #define EMC_08_AF_SAI2 0x2 #define EMC_08_AF_XBAR1 0x3 #define EMC_08_AF_FLEXIO1 0x4 #define EMC_08_AF_GPIO 0x5 #define EMC_09_AF_SEMC_ADDR00 0x0 #define EMC_09_AF_FLEXPWM2 0x1 #define EMC_09_AF_SAI2 0x2 #define EMC_09_AF_FLEXCAN2 0x3 #define EMC_09_AF_FLEXIO1 0x4 #define EMC_09_AF_GPIO 0x5 #define EMC_09_AF_FLEXSPI2 0x8 #define EMC_10_AF_SEMC_ADDR01 0x0 #define EMC_10_AF_FLEXPWM2 0x1 #define EMC_10_AF_SAI2 0x2 #define EMC_10_AF_FLEXCAN2 0x3 #define EMC_10_AF_FLEXIO1 0x4 #define EMC_10_AF_GPIO 0x5 #define EMC_10_AF_FLEXSPI2 0x8 #define EMC_11_AF_SEMC_ADDR02 0x0 #define EMC_11_AF_FLEXPWM2 0x1 #define EMC_11_AF_LPI2C4 0x2 #define EMC_11_AF_USDHC2 0x3 #define EMC_11_AF_FLEXIO1 0x4 #define EMC_11_AF_GPIO 0x5 #define EMC_11_AF_FLEXSPI2 0x8 #define EMC_12_AF_SEMC_ADDR03 0x0 #define EMC_12_AF_XBAR1 0x1 #define EMC_12_AF_LPI2C4 0x2 #define EMC_12_AF_USDHC1 0x3 #define EMC_12_AF_FLEXPWM1 0x4 #define EMC_12_AF_GPIO 0x5 #define EMC_12_AF_FLEXSPI2 0x8 #define EMC_13_AF_SEMC_ADDR04 0x0 #define EMC_13_AF_XBAR1 0x1 #define EMC_13_AF_LPUART3 0x2 #define EMC_13_AF_MQS 0x3 #define EMC_13_AF_FLEXPWM1 0x4 #define EMC_13_AF_GPIO 0x5 #define EMC_13_AF_FLEXSPI2 0x8 #define EMC_14_AF_SEMC_ADDR05 0x0 #define EMC_14_AF_XBAR1 0x1 #define EMC_14_AF_LPUART3 0x2 #define EMC_14_AF_MQS 0x3 #define EMC_14_AF_LPSPI2 0x4 #define EMC_14_AF_GPIO 0x5 #define EMC_14_AF_FLEXSPI2 0x8 #define EMC_15_AF_SEMC_ADDR06 0x0 #define EMC_15_AF_XBAR1 0x1 #define EMC_15_AF_LPUART3 0x2 #define EMC_15_AF_SPDIF 0x3 #define EMC_15_AF_QTIMER3 0x4 #define EMC_15_AF_GPIO 0x5 #define EMC_15_AF_FLEXSPI2 0x8 #define EMC_16_AF_SEMC_ADDR07 0x0 #define EMC_16_AF_XBAR1 0x1 #define EMC_16_AF_LPUART3 0x2 #define EMC_16_AF_SPDIF 0x3 #define EMC_16_AF_QTIMER3 0x4 #define EMC_16_AF_GPIO 0x5 #define EMC_16_AF_FLEXSPI2 0x8 #define EMC_17_AF_SEMC_ADDR08 0x0 #define EMC_17_AF_FLEXPWM4 0x1 #define EMC_17_AF_LPUART4 0x2 #define EMC_17_AF_FLEXCAN1 0x3 #define EMC_17_AF_QTIMER3 0x4 #define EMC_17_AF_GPIO 0x5 #define EMC_18_AF_SEMC_ADDR09 0x0 #define EMC_18_AF_FLEXPWM4 0x1 #define EMC_18_AF_LPUART4 0x2 #define EMC_18_AF_FLEXCAN1 0x3 #define EMC_18_AF_QTIMER3 0x4 #define EMC_18_AF_GPIO 0x5 #define EMC_18_AF_SNVS 0x6 #define EMC_19_AF_SEMC_ADDR11 0x0 #define EMC_19_AF_FLEXPWM2 0x1 #define EMC_19_AF_LPUART4 0x2 #define EMC_19_AF_ENET_RDATA01 0x3 #define EMC_19_AF_QTIMER2 0x4 #define EMC_19_AF_GPIO 0x5 #define EMC_19_AF_SNVS 0x6 #define EMC_20_AF_SEMC_ADDR12 0x0 #define EMC_20_AF_FLEXPWM2 0x1 #define EMC_20_AF_LPUART4 0x2 #define EMC_20_AF_ENET_RDATA00 0x3 #define EMC_20_AF_QTIMER2 0x4 #define EMC_20_AF_GPIO 0x5 #define EMC_21_AF_SEMC_BA0 0x0 #define EMC_21_AF_FLEXPWM3 0x1 #define EMC_21_AF_LPI2C3 0x2 #define EMC_21_AF_ENET_TDATA01 0x3 #define EMC_21_AF_QTIMER2 0x4 #define EMC_21_AF_GPIO 0x5 #define EMC_22_AF_SEMC_BA1 0x0 #define EMC_22_AF_FLEXPWM3 0x1 #define EMC_22_AF_LPI2C3 0x2 #define EMC_22_AF_ENET_TDATA00 0x3 #define EMC_22_AF_QTIMER2 0x4 #define EMC_22_AF_GPIO 0x5 #define EMC_22_AF_FLEXSPI2 0x8 #define EMC_23_AF_SEMC_ADDR10 0x0 #define EMC_23_AF_FLEXPWM1 0x1 #define EMC_23_AF_LPUART5 0x2 #define EMC_23_AF_ENET_RX_EN 0x3 #define EMC_23_AF_GPT1 0x4 #define EMC_23_AF_GPIO 0x5 #define EMC_23_AF_FLEXSPI2 0x8 #define EMC_24_AF_SEMC_CAS 0x0 #define EMC_24_AF_FLEXPWM1 0x1 #define EMC_24_AF_LPUART5 0x2 #define EMC_24_AF_ENET_TX_EN 0x3 #define EMC_24_AF_GPT1 0x4 #define EMC_24_AF_GPIO 0x5 #define EMC_24_AF_FLEXSPI2 0x8 #define EMC_25_AF_SEMC_RAS 0x0 #define EMC_25_AF_FLEXPWM1 0x1 #define EMC_25_AF_LPUART6 0x2 #define EMC_25_AF_ENET_TX_CLK 0x3 #define EMC_25_AF_ENET_REF_CLK 0x4 #define EMC_25_AF_GPIO 0x5 #define EMC_25_AF_FLEXSPI2 0x8 #define EMC_26_AF_SEMC_CLK 0x0 #define EMC_26_AF_FLEXPWM1 0x1 #define EMC_26_AF_LPUART6 0x2 #define EMC_26_AF_ENET_RX_ER 0x3 #define EMC_26_AF_FLEXIO1 0x4 #define EMC_26_AF_GPIO 0x5 #define EMC_26_AF_FLEXSPI2 0x8 #define EMC_27_AF_SEMC_CKE 0x0 #define EMC_27_AF_FLEXPWM1 0x1 #define EMC_27_AF_LPUART5 0x2 #define EMC_27_AF_LPSPI1 0x3 #define EMC_27_AF_FLEXIO1 0x4 #define EMC_27_AF_GPIO 0x5 #define EMC_27_AF_FLEXSPI2 0x8 #define EMC_28_AF_SEMC_WE 0x0 #define EMC_28_AF_FLEXPWM1 0x1 #define EMC_28_AF_LPUART5 0x2 #define EMC_28_AF_LPSPI1 0x3 #define EMC_28_AF_FLEXIO1 0x4 #define EMC_28_AF_GPIO 0x5 #define EMC_28_AF_FLEXSPI2 0x8 #define EMC_29_AF_SEMC_CS0 0x0 #define EMC_29_AF_FLEXPWM3 0x1 #define EMC_29_AF_LPUART6 0x2 #define EMC_29_AF_LPSPI1 0x3 #define EMC_29_AF_FLEXIO1 0x4 #define EMC_29_AF_GPIO 0x5 #define EMC_29_AF_FLEXSPI2 0x8 #define EMC_30_AF_SEMC_DATA08 0x0 #define EMC_30_AF_FLEXPWM3 0x1 #define EMC_30_AF_LPUART6 0x2 #define EMC_30_AF_LPSPI1 0x3 #define EMC_30_AF_CSI 0x4 #define EMC_30_AF_GPIO 0x5 #define EMC_30_AF_ENET2_TDATA00 0x8 #define EMC_31_AF_SEMC_DATA09 0x0 #define EMC_31_AF_FLEXPWM3 0x1 #define EMC_31_AF_LPUART7 0x2 #define EMC_31_AF_LPSPI1 0x3 #define EMC_31_AF_CSI 0x4 #define EMC_31_AF_GPIO 0x5 #define EMC_31_AF_ENET2_TDATA01 0x8 #define EMC_32_AF_SEMC_DATA10 0x0 #define EMC_32_AF_FLEXPWM3 0x1 #define EMC_32_AF_LPUART7 0x2 #define EMC_32_AF_CCM 0x3 #define EMC_32_AF_CSI 0x4 #define EMC_32_AF_GPIO 0x5 #define EMC_32_AF_ENET2_TX_EN 0x8 #define EMC_33_AF_SEMC_DATA11 0x0 #define EMC_33_AF_FLEXPWM3 0x1 #define EMC_33_AF_USDHC1 0x2 #define EMC_33_AF_SAI3 0x3 #define EMC_33_AF_CSI 0x4 #define EMC_33_AF_GPIO 0x5 #define EMC_33_AF_ENET2_TX_CLK 0x8 #define EMC_33_AF_ENET2_REF_CLK2 0x9 #define EMC_34_AF_SEMC_DATA12 0x0 #define EMC_34_AF_FLEXPWM3 0x1 #define EMC_34_AF_USDHC1 0x2 #define EMC_34_AF_SAI3 0x3 #define EMC_34_AF_CSI 0x4 #define EMC_34_AF_GPIO 0x5 #define EMC_34_AF_ENET2_RX_ER 0x8 #define EMC_35_AF_SEMC_DATA13 0x0 #define EMC_35_AF_XBAR1 0x1 #define EMC_35_AF_GPT1 0x2 #define EMC_35_AF_SAI3 0x3 #define EMC_35_AF_CSI 0x4 #define EMC_35_AF_GPIO 0x5 #define EMC_35_AF_USDHC1 0x6 #define EMC_35_AF_ENET2_RDATA00 0x8 #define EMC_36_AF_SEMC_DATA14 0x0 #define EMC_36_AF_XBAR1 0x1 #define EMC_36_AF_GPT1 0x2 #define EMC_36_AF_SAI3 0x3 #define EMC_36_AF_CSI 0x4 #define EMC_36_AF_GPIO 0x5 #define EMC_36_AF_USDHC1 0x6 #define EMC_36_AF_ENET2_RDATA01 0x8 #define EMC_36_AF_FLEXCAN3 0x9 #define EMC_37_AF_SEMC_DATA15 0x0 #define EMC_37_AF_XBAR1 0x1 #define EMC_37_AF_GPT1 0x2 #define EMC_37_AF_SAI3 0x3 #define EMC_37_AF_CSI 0x4 #define EMC_37_AF_GPIO 0x5 #define EMC_37_AF_USDHC2 0x6 #define EMC_37_AF_ENET2_RX_EN 0x8 #define EMC_37_AF_FLEXCAN3 0x9 #define EMC_38_AF_SEMC_DM01 0x0 #define EMC_38_AF_FLEXPWM1 0x1 #define EMC_38_AF_LPUART8 0x2 #define EMC_38_AF_SAI3 0x3 #define EMC_38_AF_CSI 0x4 #define EMC_38_AF_GPIO 0x5 #define EMC_38_AF_USDHC2 0x6 #define EMC_38_AF_ENET2_MDC 0x8 #define EMC_39_AF_SEMC_DQS 0x0 #define EMC_39_AF_FLEXPWM1 0x1 #define EMC_39_AF_LPUART8 0x2 #define EMC_39_AF_SAI3 0x3 #define EMC_39_AF_WDOG1 0x4 #define EMC_39_AF_GPIO 0x5 #define EMC_39_AF_USDHC2 0x6 #define EMC_39_AF_ENET2_MDIO 0x8 #define EMC_39_AF_SEMC_DQS4 0x9 #define EMC_40_AF_SEMC_RDY 0x0 #define EMC_40_AF_GPT2 0x1 #define EMC_40_AF_LPSPI1 0x2 #define EMC_40_AF_USB 0x3 #define EMC_40_AF_ENET_MDC 0x4 #define EMC_40_AF_GPIO 0x5 #define EMC_40_AF_USDHC2 0x6 #define EMC_40_AF_SEMC_CLK5 0x9 #define EMC_41_AF_SEMC_CSX00 0x0 #define EMC_41_AF_GPT2 0x1 #define EMC_41_AF_LPSPI1 0x2 #define EMC_41_AF_USB 0x3 #define EMC_41_AF_ENET_MDIO 0x4 #define EMC_41_AF_GPIO 0x5 #define EMC_41_AF_USDHC1 0x6 #define AD_B0_00_AF_FLEXPWM2 0x0 #define AD_B0_00_AF_XBAR1 0x1 #define AD_B0_00_AF_REF 0x2 #define AD_B0_00_AF_USB 0x3 #define AD_B0_00_AF_LPI2C1 0x4 #define AD_B0_00_AF_GPIO 0x5 #define AD_B0_00_AF_USDHC1 0x6 #define AD_B0_00_AF_LPSPI3 0x7 #define AD_B0_01_AF_FLEXPWM2 0x0 #define AD_B0_01_AF_XBAR1 0x1 #define AD_B0_01_AF_REF 0x2 #define AD_B0_01_AF_USB 0x3 #define AD_B0_01_AF_LPI2C1 0x4 #define AD_B0_01_AF_GPIO 0x5 #define AD_B0_01_AF_EWM 0x6 #define AD_B0_01_AF_LPSPI3 0x7 #define AD_B0_02_AF_FLEXCAN2 0x0 #define AD_B0_02_AF_XBAR1 0x1 #define AD_B0_02_AF_LPUART6 0x2 #define AD_B0_02_AF_USB 0x3 #define AD_B0_02_AF_FLEXPWM1 0x4 #define AD_B0_02_AF_GPIO 0x5 #define AD_B0_02_AF_LPI2C1 0x6 #define AD_B0_02_AF_LPSPI3 0x7 #define AD_B0_03_AF_FLEXCAN2 0x0 #define AD_B0_03_AF_XBAR1 0x1 #define AD_B0_03_AF_LPUART6 0x2 #define AD_B0_03_AF_USB 0x3 #define AD_B0_03_AF_FLEXPWM1 0x4 #define AD_B0_03_AF_GPIO 0x5 #define AD_B0_03_AF_REF 0x6 #define AD_B0_03_AF_LPSPI3 0x7 #define AD_B0_04_AF_SRC 0x0 #define AD_B0_04_AF_MQS 0x1 #define AD_B0_04_AF_ENET_TX_DATA03 0x2 #define AD_B0_04_AF_SAI2 0x3 #define AD_B0_04_AF_CSI 0x4 #define AD_B0_04_AF_GPIO 0x5 #define AD_B0_04_AF_PIT 0x6 #define AD_B0_04_AF_LPSPI3 0x7 #define AD_B0_05_AF_SRC 0x0 #define AD_B0_05_AF_MQS 0x1 #define AD_B0_05_AF_ENET_TX_DATA02 0x2 #define AD_B0_05_AF_SAI2 0x3 #define AD_B0_05_AF_CSI 0x4 #define AD_B0_05_AF_GPIO 0x5 #define AD_B0_05_AF_XBAR1 0x6 #define AD_B0_05_AF_LPSPI3 0x7 #define AD_B0_06_AF_JTAG 0x0 #define AD_B0_06_AF_GPT2 0x1 #define AD_B0_06_AF_ENET_RX_CLK 0x2 #define AD_B0_06_AF_SAI2 0x3 #define AD_B0_06_AF_CSI 0x4 #define AD_B0_06_AF_GPIO 0x5 #define AD_B0_06_AF_XBAR1 0x6 #define AD_B0_06_AF_LPSPI3 0x7 #define AD_B0_07_AF_JTAG 0x0 #define AD_B0_07_AF_GPT2 0x1 #define AD_B0_07_AF_ENET_TX_ER 0x2 #define AD_B0_07_AF_SAI2 0x3 #define AD_B0_07_AF_CSI 0x4 #define AD_B0_07_AF_GPIO 0x5 #define AD_B0_07_AF_XBAR1 0x6 #define AD_B0_07_AF_ENET_1588_EVENT3_OUT 0x7 #define AD_B0_08_AF_JTAG 0x0 #define AD_B0_08_AF_GPT2 0x1 #define AD_B0_08_AF_ENET_RX_DATA03 0x2 #define AD_B0_08_AF_SAI2 0x3 #define AD_B0_08_AF_CSI 0x4 #define AD_B0_08_AF_GPIO 0x5 #define AD_B0_08_AF_XBAR1 0x6 #define AD_B0_08_AF_ENET_1588_EVENT3_IN 0x7 #define AD_B0_09_AF_JTAG 0x0 #define AD_B0_09_AF_FLEXPWM2 0x1 #define AD_B0_09_AF_ENET_RX_DATA02 0x2 #define AD_B0_09_AF_SAI2 0x3 #define AD_B0_09_AF_CSI 0x4 #define AD_B0_09_AF_GPIO 0x5 #define AD_B0_09_AF_XBAR1 0x6 #define AD_B0_09_AF_GPT2 0x7 #define AD_B0_09_AF_SEMC_DQS4 0x9 #define AD_B0_10_AF_JTAG 0x0 #define AD_B0_10_AF_FLEXPWM1 0x1 #define AD_B0_10_AF_ENET_CRS 0x2 #define AD_B0_10_AF_SAI2 0x3 #define AD_B0_10_AF_CSI 0x4 #define AD_B0_10_AF_GPIO 0x5 #define AD_B0_10_AF_XBAR1 0x6 #define AD_B0_10_AF_ENET_1588_EVENT0_OUT 0x7 #define AD_B0_10_AF_FLEXCAN3 0x8 #define AD_B0_10_AF_ARM 0x9 #define AD_B0_11_AF_JTAG 0x0 #define AD_B0_11_AF_FLEXPWM1 0x1 #define AD_B0_11_AF_ENET_COL 0x2 #define AD_B0_11_AF_WDOG1 0x3 #define AD_B0_11_AF_CSI 0x4 #define AD_B0_11_AF_GPIO 0x5 #define AD_B0_11_AF_XBAR1 0x6 #define AD_B0_11_AF_ENET_1588_EVENT0_IN 0x7 #define AD_B0_11_AF_FLEXCAN3 0x8 #define AD_B0_11_AF_SEMC_CLK6 0x9 #define AD_B0_12_AF_LPI2C4 0x0 #define AD_B0_12_AF_CCM 0x1 #define AD_B0_12_AF_LPUART1 0x2 #define AD_B0_12_AF_WDOG2 0x3 #define AD_B0_12_AF_FLEXPWM1 0x4 #define AD_B0_12_AF_GPIO 0x5 #define AD_B0_12_AF_ENET_1588_EVENT1_OUT 0x6 #define AD_B0_12_AF_NMI 0x7 #define AD_B0_13_AF_LPI2C4 0x0 #define AD_B0_13_AF_GPT1 0x1 #define AD_B0_13_AF_LPUART1 0x2 #define AD_B0_13_AF_EWM 0x3 #define AD_B0_13_AF_FLEXPWM1 0x4 #define AD_B0_13_AF_GPIO 0x5 #define AD_B0_13_AF_ENET_1588_EVENT1_IN 0x6 #define AD_B0_13_AF_REF 0x7 #define AD_B0_14_AF_USB 0x0 #define AD_B0_14_AF_XBAR1 0x1 #define AD_B0_14_AF_LPUART1 0x2 #define AD_B0_14_AF_ENET_1588_EVENT0_OUT 0x3 #define AD_B0_14_AF_CSI 0x4 #define AD_B0_14_AF_GPIO 0x5 #define AD_B0_14_AF_FLEXCAN2 0x6 #define AD_B0_14_AF_FLEXCAN3 0x8 #define AD_B0_15_AF_USB 0x0 #define AD_B0_15_AF_XBAR1 0x1 #define AD_B0_15_AF_LPUART1 0x2 #define AD_B0_15_AF_ENET_1588_EVENT0_IN 0x3 #define AD_B0_15_AF_CSI 0x4 #define AD_B0_15_AF_GPIO 0x5 #define AD_B0_15_AF_FLEXCAN2 0x6 #define AD_B0_15_AF_WDOG1 0x7 #define AD_B0_15_AF_FLEXCAN3 0x8 #define AD_B1_00_AF_USB 0x0 #define AD_B1_00_AF_QTIMER3 0x1 #define AD_B1_00_AF_LPUART2 0x2 #define AD_B1_00_AF_LPI2C1 0x3 #define AD_B1_00_AF_WDOG1 0x4 #define AD_B1_00_AF_GPIO 0x5 #define AD_B1_00_AF_USDHC1 0x6 #define AD_B1_00_AF_KPP 0x7 #define AD_B1_00_AF_ENET2_1588_EVENT0_OUT 0x8 #define AD_B1_00_AF_FLEXIO3 0x9 #define AD_B1_01_AF_USB 0x0 #define AD_B1_01_AF_QTIMER3 0x1 #define AD_B1_01_AF_LPUART2 0x2 #define AD_B1_01_AF_LPI2C1 0x3 #define AD_B1_01_AF_CCM 0x4 #define AD_B1_01_AF_GPIO 0x5 #define AD_B1_01_AF_USDHC1 0x6 #define AD_B1_01_AF_KPP 0x7 #define AD_B1_01_AF_ENET2_1588_EVENT0_IN 0x8 #define AD_B1_01_AF_FLEXIO3 0x9 #define AD_B1_02_AF_USB 0x0 #define AD_B1_02_AF_QTIMER3 0x1 #define AD_B1_02_AF_LPUART2 0x2 #define AD_B1_02_AF_SPDIF 0x3 #define AD_B1_02_AF_ENET_1588_EVENT2_OUT 0x4 #define AD_B1_02_AF_GPIO 0x5 #define AD_B1_02_AF_USDHC1 0x6 #define AD_B1_02_AF_KPP 0x7 #define AD_B1_02_AF_GPT2 0x8 #define AD_B1_02_AF_FLEXIO3 0x9 #define AD_B1_03_AF_USB 0x0 #define AD_B1_03_AF_QTIMER3 0x1 #define AD_B1_03_AF_LPUART2 0x2 #define AD_B1_03_AF_SPDIF 0x3 #define AD_B1_03_AF_ENET_1588_EVENT2_IN 0x4 #define AD_B1_03_AF_GPIO 0x5 #define AD_B1_03_AF_USDHC2 0x6 #define AD_B1_03_AF_KPP 0x7 #define AD_B1_03_AF_GPT2 0x8 #define AD_B1_03_AF_FLEXIO3 0x9 #define AD_B1_04_AF_FLEXSPIB 0x0 #define AD_B1_04_AF_ENET_MDC 0x1 #define AD_B1_04_AF_LPUART3 0x2 #define AD_B1_04_AF_SPDIF 0x3 #define AD_B1_04_AF_CSI 0x4 #define AD_B1_04_AF_GPIO 0x5 #define AD_B1_04_AF_USDHC2 0x6 #define AD_B1_04_AF_KPP 0x7 #define AD_B1_04_AF_GPT2 0x8 #define AD_B1_04_AF_FLEXIO3 0x9 #define AD_B1_05_AF_FLEXSPIB 0x0 #define AD_B1_05_AF_ENET_MDIO 0x1 #define AD_B1_05_AF_LPUART3 0x2 #define AD_B1_05_AF_SPDIF 0x3 #define AD_B1_05_AF_CSI 0x4 #define AD_B1_05_AF_GPIO 0x5 #define AD_B1_05_AF_USDHC2 0x6 #define AD_B1_05_AF_KPP 0x7 #define AD_B1_05_AF_GPT2 0x8 #define AD_B1_05_AF_FLEXIO3 0x9 #define AD_B1_06_AF_FLEXSPIB 0x0 #define AD_B1_06_AF_LPI2C3 0x1 #define AD_B1_06_AF_LPUART3 0x2 #define AD_B1_06_AF_SPDIF 0x3 #define AD_B1_06_AF_CSI 0x4 #define AD_B1_06_AF_GPIO 0x5 #define AD_B1_06_AF_USDHC2 0x6 #define AD_B1_06_AF_KPP 0x7 #define AD_B1_06_AF_GPT2 0x8 #define AD_B1_06_AF_FLEXIO3 0x9 #define AD_B1_07_AF_FLEXSPIB 0x0 #define AD_B1_07_AF_LPI2C3 0x1 #define AD_B1_07_AF_LPUART3 0x2 #define AD_B1_07_AF_SPDIF 0x3 #define AD_B1_07_AF_CSI 0x4 #define AD_B1_07_AF_GPIO 0x5 #define AD_B1_07_AF_USDHC2 0x6 #define AD_B1_07_AF_KPP 0x7 #define AD_B1_07_AF_GPT2 0x8 #define AD_B1_07_AF_FLEXIO3 0x9 #define AD_B1_08_AF_FLEXSPIA 0x0 #define AD_B1_08_AF_FLEXPWM4 0x1 #define AD_B1_08_AF_FLEXCAN1 0x2 #define AD_B1_08_AF_CCM 0x3 #define AD_B1_08_AF_CSI 0x4 #define AD_B1_08_AF_GPIO 0x5 #define AD_B1_08_AF_USDHC2 0x6 #define AD_B1_08_AF_KPP 0x7 #define AD_B1_08_AF_FLEXIO3 0x9 #define AD_B1_09_AF_FLEXSPIA 0x0 #define AD_B1_09_AF_FLEXPWM4 0x1 #define AD_B1_09_AF_FLEXCAN1 0x2 #define AD_B1_09_AF_SAI1 0x3 #define AD_B1_09_AF_CSI 0x4 #define AD_B1_09_AF_GPIO 0x5 #define AD_B1_09_AF_USDHC2 0x6 #define AD_B1_09_AF_KPP 0x7 #define AD_B1_09_AF_FLEXIO3 0x9 #define AD_B1_10_AF_FLEXSPIA 0x0 #define AD_B1_10_AF_WDOG1 0x1 #define AD_B1_10_AF_LPUART8 0x2 #define AD_B1_10_AF_SAI1 0x3 #define AD_B1_10_AF_CSI 0x4 #define AD_B1_10_AF_GPIO 0x5 #define AD_B1_10_AF_USDHC2 0x6 #define AD_B1_10_AF_KPP 0x7 #define AD_B1_10_AF_ENET2_1588_EVENT1_OUT 0x8 #define AD_B1_10_AF_FLEXIO3 0x9 #define AD_B1_11_AF_FLEXSPIA 0x0 #define AD_B1_11_AF_EWM 0x1 #define AD_B1_11_AF_LPUART8 0x2 #define AD_B1_11_AF_SAI1 0x3 #define AD_B1_11_AF_CSI 0x4 #define AD_B1_11_AF_GPIO 0x5 #define AD_B1_11_AF_USDHC2 0x6 #define AD_B1_11_AF_KPP 0x7 #define AD_B1_11_AF_ENET2_1588_EVENT1_IN 0x8 #define AD_B1_11_AF_FLEXIO3 0x9 #define AD_B1_12_AF_FLEXSPIA 0x0 #define AD_B1_12_AF_ACMP 0x1 #define AD_B1_12_AF_LPSPI3 0x2 #define AD_B1_12_AF_SAI1 0x3 #define AD_B1_12_AF_CSI 0x4 #define AD_B1_12_AF_GPIO 0x5 #define AD_B1_12_AF_USDHC2 0x6 #define AD_B1_12_AF_KPP 0x7 #define AD_B1_12_AF_ENET2_1588_EVENT2_OUT 0x8 #define AD_B1_12_AF_FLEXIO3 0x9 #define AD_B1_13_AF_FLEXSPIA 0x0 #define AD_B1_13_AF_ACMP 0x1 #define AD_B1_13_AF_LPSPI3 0x2 #define AD_B1_13_AF_SAI1 0x3 #define AD_B1_13_AF_CSI 0x4 #define AD_B1_13_AF_GPIO 0x5 #define AD_B1_13_AF_USDHC2 0x6 #define AD_B1_13_AF_KPP 0x7 #define AD_B1_13_AF_ENET2_1588_EVENT2_IN 0x8 #define AD_B1_13_AF_FLEXIO3 0x9 #define AD_B1_14_AF_FLEXSPIA 0x0 #define AD_B1_14_AF_ACMP 0x1 #define AD_B1_14_AF_LPSPI3 0x2 #define AD_B1_14_AF_SAI1 0x3 #define AD_B1_14_AF_CSI 0x4 #define AD_B1_14_AF_GPIO 0x5 #define AD_B1_14_AF_USDHC2 0x6 #define AD_B1_14_AF_KPP 0x7 #define AD_B1_14_AF_ENET2_1588_EVENT3_OUT 0x8 #define AD_B1_14_AF_FLEXIO3 0x9 #define AD_B1_15_AF_FLEXSPIA 0x0 #define AD_B1_15_AF_ACMP 0x1 #define AD_B1_15_AF_LPSPI3 0x2 #define AD_B1_15_AF_SAI1 0x3 #define AD_B1_15_AF_CSI 0x4 #define AD_B1_15_AF_GPIO 0x5 #define AD_B1_15_AF_USDHC2 0x6 #define AD_B1_15_AF_KPP 0x7 #define AD_B1_15_AF_ENET2_1588_EVENT3_IN 0x8 #define AD_B1_15_AF_FLEXIO3 0x9 #define B0_00_AF_LCD 0x0 #define B0_00_AF_QTIMER1 0x1 #define B0_00_AF_MQS 0x2 #define B0_00_AF_LPSPI4 0x3 #define B0_00_AF_FLEXIO2 0x4 #define B0_00_AF_GPIO 0x5 #define B0_00_AF_SEMC_CSX01 0x6 #define B0_00_AF_ENET2_MDC 0x8 #define B0_01_AF_LCD 0x0 #define B0_01_AF_QTIMER1 0x1 #define B0_01_AF_MQS 0x2 #define B0_01_AF_LPSPI4 0x3 #define B0_01_AF_FLEXIO2 0x4 #define B0_01_AF_GPIO 0x5 #define B0_01_AF_SEMC_CSX02 0x6 #define B0_01_AF_ENET2_MDIO 0x8 #define B0_02_AF_LCD 0x0 #define B0_02_AF_QTIMER1 0x1 #define B0_02_AF_FLEXCAN1 0x2 #define B0_02_AF_LPSPI4 0x3 #define B0_02_AF_FLEXIO2 0x4 #define B0_02_AF_GPIO 0x5 #define B0_02_AF_SEMC_CSX03 0x6 #define B0_02_AF_ENET2_1588_EVENT0_OUT 0x8 #define B0_03_AF_LCD 0x0 #define B0_03_AF_QTIMER2 0x1 #define B0_03_AF_FLEXCAN1 0x2 #define B0_03_AF_LPSPI4 0x3 #define B0_03_AF_FLEXIO2 0x4 #define B0_03_AF_GPIO 0x5 #define B0_03_AF_WDOG2 0x6 #define B0_03_AF_ENET2_1588_EVENT0_IN 0x8 #define B0_04_AF_LCD 0x0 #define B0_04_AF_QTIMER2 0x1 #define B0_04_AF_LPI2C2 0x2 #define B0_04_AF_ARM 0x3 #define B0_04_AF_FLEXIO2 0x4 #define B0_04_AF_GPIO 0x5 #define B0_04_AF_SRC 0x6 #define B0_04_AF_ENET2_TDATA03 0x8 #define B0_05_AF_LCD 0x0 #define B0_05_AF_QTIMER2 0x1 #define B0_05_AF_LPI2C2 0x2 #define B0_05_AF_ARM 0x3 #define B0_05_AF_FLEXIO2 0x4 #define B0_05_AF_GPIO 0x5 #define B0_05_AF_SRC 0x6 #define B0_05_AF_ENET2_TDATA02 0x8 #define B0_06_AF_LCD 0x0 #define B0_06_AF_QTIMER3 0x1 #define B0_06_AF_FLEXPWM2 0x2 #define B0_06_AF_ARM 0x3 #define B0_06_AF_FLEXIO2 0x4 #define B0_06_AF_GPIO 0x5 #define B0_06_AF_SRC 0x6 #define B0_06_AF_ENET2_RX_CLK 0x8 #define B0_07_AF_LCD 0x0 #define B0_07_AF_QTIMER3 0x1 #define B0_07_AF_FLEXPWM2 0x2 #define B0_07_AF_ARM 0x3 #define B0_07_AF_FLEXIO2 0x4 #define B0_07_AF_GPIO 0x5 #define B0_07_AF_SRC 0x6 #define B0_07_AF_ENET2_TX_ER 0x8 #define B0_08_AF_LCD 0x0 #define B0_08_AF_QTIMER3 0x1 #define B0_08_AF_FLEXPWM2 0x2 #define B0_08_AF_LPUART3 0x3 #define B0_08_AF_FLEXIO2 0x4 #define B0_08_AF_GPIO 0x5 #define B0_08_AF_SRC 0x6 #define B0_08_AF_ENET2_RDATA03 0x8 #define B0_09_AF_LCD 0x0 #define B0_09_AF_QTIMER4 0x1 #define B0_09_AF_FLEXPWM2 0x2 #define B0_09_AF_LPUART3 0x3 #define B0_09_AF_FLEXIO2 0x4 #define B0_09_AF_GPIO 0x5 #define B0_09_AF_SRC 0x6 #define B0_09_AF_ENET2_RDATA02 0x8 #define B0_10_AF_LCD 0x0 #define B0_10_AF_QTIMER4 0x1 #define B0_10_AF_FLEXPWM2 0x2 #define B0_10_AF_SAI1 0x3 #define B0_10_AF_FLEXIO2 0x4 #define B0_10_AF_GPIO 0x5 #define B0_10_AF_SRC 0x6 #define B0_10_AF_ENET2_CRS 0x8 #define B0_11_AF_LCD 0x0 #define B0_11_AF_QTIMER4 0x1 #define B0_11_AF_FLEXPWM2 0x2 #define B0_11_AF_SAI1 0x3 #define B0_11_AF_FLEXIO2 0x4 #define B0_11_AF_GPIO 0x5 #define B0_11_AF_SRC 0x6 #define B0_11_AF_ENET2_COL 0x8 #define B0_12_AF_LCD 0x0 #define B0_12_AF_XBAR1 0x1 #define B0_12_AF_ARM 0x2 #define B0_12_AF_SAI1 0x3 #define B0_12_AF_FLEXIO2 0x4 #define B0_12_AF_GPIO 0x5 #define B0_12_AF_SRC 0x6 #define B0_12_AF_ENET2_TDATA00 0x8 #define B0_13_AF_LCD 0x0 #define B0_13_AF_XBAR1 0x1 #define B0_13_AF_ARM 0x2 #define B0_13_AF_SAI1 0x3 #define B0_13_AF_FLEXIO2 0x4 #define B0_13_AF_GPIO 0x5 #define B0_13_AF_SRC 0x6 #define B0_13_AF_ENET2_TDATA01 0x8 #define B0_14_AF_LCD 0x0 #define B0_14_AF_XBAR1 0x1 #define B0_14_AF_ARM 0x2 #define B0_14_AF_SAI1 0x3 #define B0_14_AF_FLEXIO2 0x4 #define B0_14_AF_GPIO 0x5 #define B0_14_AF_SRC 0x6 #define B0_14_AF_ENET2_TX_EN 0x8 #define B0_15_AF_LCD 0x0 #define B0_15_AF_XBAR1 0x1 #define B0_15_AF_ARM 0x2 #define B0_15_AF_SAI1 0x3 #define B0_15_AF_FLEXIO2 0x4 #define B0_15_AF_GPIO 0x5 #define B0_15_AF_SRC 0x6 #define B0_15_AF_ENET2_TX_CLK 0x8 #define B0_15_AF_ENET2_REF_CLK2 0x9 #define B1_00_AF_LCD 0x0 #define B1_00_AF_XBAR1 0x1 #define B1_00_AF_LPUART4 0x2 #define B1_00_AF_SAI1 0x3 #define B1_00_AF_FLEXIO2 0x4 #define B1_00_AF_GPIO 0x5 #define B1_00_AF_FLEXPWM1 0x6 #define B1_00_AF_ENET2_RX_ER 0x8 #define B1_00_AF_FLEXIO3 0x9 #define B1_01_AF_LCD 0x0 #define B1_01_AF_XBAR1 0x1 #define B1_01_AF_LPUART4 0x2 #define B1_01_AF_SAI1 0x3 #define B1_01_AF_FLEXIO2 0x4 #define B1_01_AF_GPIO 0x5 #define B1_01_AF_FLEXPWM1 0x6 #define B1_01_AF_ENET2_RDATA00 0x8 #define B1_01_AF_FLEXIO3 0x9 #define B1_02_AF_LCD 0x0 #define B1_02_AF_XBAR1 0x1 #define B1_02_AF_LPSPI4 0x2 #define B1_02_AF_SAI1 0x3 #define B1_02_AF_FLEXIO2 0x4 #define B1_02_AF_GPIO 0x5 #define B1_02_AF_FLEXPWM2 0x6 #define B1_02_AF_ENET2_RDATA01 0x8 #define B1_02_AF_FLEXIO3 0x9 #define B1_03_AF_LCD 0x0 #define B1_03_AF_XBAR1 0x1 #define B1_03_AF_LPSPI4 0x2 #define B1_03_AF_SAI1 0x3 #define B1_03_AF_FLEXIO2 0x4 #define B1_03_AF_GPIO 0x5 #define B1_03_AF_FLEXPWM2 0x6 #define B1_03_AF_ENET2_RX_EN 0x8 #define B1_03_AF_FLEXIO3 0x9 #define B1_04_AF_LCD 0x0 #define B1_04_AF_LPSPI4 0x1 #define B1_04_AF_CSI 0x2 #define B1_04_AF_ENET_RX_DATA00 0x3 #define B1_04_AF_FLEXIO2 0x4 #define B1_04_AF_GPIO 0x5 #define B1_04_AF_GPT1 0x8 #define B1_04_AF_FLEXIO3 0x9 #define B1_05_AF_LCD 0x0 #define B1_05_AF_LPSPI4 0x1 #define B1_05_AF_CSI 0x2 #define B1_05_AF_ENET_RX_DATA01 0x3 #define B1_05_AF_FLEXIO2 0x4 #define B1_05_AF_GPIO 0x5 #define B1_05_AF_GPT1 0x8 #define B1_05_AF_FLEXIO3 0x9 #define B1_06_AF_LCD 0x0 #define B1_06_AF_LPSPI4 0x1 #define B1_06_AF_CSI 0x2 #define B1_06_AF_ENET_RX_EN 0x3 #define B1_06_AF_FLEXIO2 0x4 #define B1_06_AF_GPIO 0x5 #define B1_06_AF_GPT1 0x8 #define B1_06_AF_FLEXIO3 0x9 #define B1_07_AF_LCD 0x0 #define B1_07_AF_LPSPI4 0x1 #define B1_07_AF_CSI 0x2 #define B1_07_AF_ENET_TX_DATA00 0x3 #define B1_07_AF_FLEXIO2 0x4 #define B1_07_AF_GPIO 0x5 #define B1_07_AF_GPT1 0x8 #define B1_07_AF_FLEXIO3 0x9 #define B1_08_AF_LCD 0x0 #define B1_08_AF_QTIMER1 0x1 #define B1_08_AF_CSI 0x2 #define B1_08_AF_ENET_TX_DATA01 0x3 #define B1_08_AF_FLEXIO2 0x4 #define B1_08_AF_GPIO 0x5 #define B1_08_AF_FLEXCAN2 0x6 #define B1_08_AF_GPT1 0x8 #define B1_08_AF_FLEXIO3 0x9 #define B1_09_AF_LCD 0x0 #define B1_09_AF_QTIMER2 0x1 #define B1_09_AF_CSI 0x2 #define B1_09_AF_ENET_TX_EN 0x3 #define B1_09_AF_FLEXIO2 0x4 #define B1_09_AF_GPIO 0x5 #define B1_09_AF_FLEXCAN2 0x6 #define B1_09_AF_GPT1 0x8 #define B1_09_AF_FLEXIO3 0x9 #define B1_10_AF_LCD 0x0 #define B1_10_AF_QTIMER3 0x1 #define B1_10_AF_CSI 0x2 #define B1_10_AF_ENET_TX_CLK 0x3 #define B1_10_AF_FLEXIO2 0x4 #define B1_10_AF_GPIO 0x5 #define B1_10_AF_ENET_REF_CLK 0x6 #define B1_10_AF_FLEXIO3 0x9 #define B1_11_AF_LCD 0x0 #define B1_11_AF_QTIMER4 0x1 #define B1_11_AF_CSI 0x2 #define B1_11_AF_ENET_RX_ER 0x3 #define B1_11_AF_FLEXIO2 0x4 #define B1_11_AF_GPIO 0x5 #define B1_11_AF_LPSPI4 0x6 #define B1_11_AF_FLEXIO3 0x9 #define B1_12_AF_LPUART5 0x1 #define B1_12_AF_CSI 0x2 #define B1_12_AF_ENET_1588_EVENT0_IN 0x3 #define B1_12_AF_FLEXIO2 0x4 #define B1_12_AF_GPIO 0x5 #define B1_12_AF_USDHC1 0x6 #define B1_12_AF_FLEXIO3 0x9 #define B1_13_AF_WDOG1 0x0 #define B1_13_AF_LPUART5 0x1 #define B1_13_AF_CSI 0x2 #define B1_13_AF_ENET_1588_EVENT0_OUT 0x3 #define B1_13_AF_FLEXIO2 0x4 #define B1_13_AF_GPIO 0x5 #define B1_13_AF_USDHC1 0x6 #define B1_13_AF_SEMC_DQS4 0x8 #define B1_13_AF_FLEXIO3 0x9 #define B1_14_AF_ENET_MDC 0x0 #define B1_14_AF_FLEXPWM4 0x1 #define B1_14_AF_CSI 0x2 #define B1_14_AF_XBAR1 0x3 #define B1_14_AF_FLEXIO2 0x4 #define B1_14_AF_GPIO 0x5 #define B1_14_AF_USDHC1 0x6 #define B1_14_AF_ENET2_TDATA00 0x8 #define B1_14_AF_FLEXIO3 0x9 #define B1_15_AF_ENET_MDIO 0x0 #define B1_15_AF_FLEXPWM4 0x1 #define B1_15_AF_CSI 0x2 #define B1_15_AF_XBAR1 0x3 #define B1_15_AF_FLEXIO2 0x4 #define B1_15_AF_GPIO 0x5 #define B1_15_AF_USDHC1 0x6 #define B1_15_AF_ENET2_TDATA01 0x8 #define B1_15_AF_FLEXIO3 0x9 #define SD_B0_00_AF_USDHC1 0x0 #define SD_B0_00_AF_FLEXPWM1 0x1 #define SD_B0_00_AF_LPI2C3 0x2 #define SD_B0_00_AF_XBAR1 0x3 #define SD_B0_00_AF_LPSPI1 0x4 #define SD_B0_00_AF_GPIO 0x5 #define SD_B0_00_AF_FLEXSPIA 0x6 #define SD_B0_00_AF_ENET2_TX_EN 0x8 #define SD_B0_00_AF_SEMC_DQS4 0x9 #define SD_B0_01_AF_USDHC1 0x0 #define SD_B0_01_AF_FLEXPWM1 0x1 #define SD_B0_01_AF_LPI2C3 0x2 #define SD_B0_01_AF_XBAR1 0x3 #define SD_B0_01_AF_LPSPI1 0x4 #define SD_B0_01_AF_GPIO 0x5 #define SD_B0_01_AF_FLEXSPIB 0x6 #define SD_B0_01_AF_ENET2_TX_CLK 0x8 #define SD_B0_01_AF_ENET2_REF_CLK2 0x9 #define SD_B0_02_AF_USDHC1 0x0 #define SD_B0_02_AF_FLEXPWM1 0x1 #define SD_B0_02_AF_LPUART8 0x2 #define SD_B0_02_AF_XBAR1 0x3 #define SD_B0_02_AF_LPSPI1 0x4 #define SD_B0_02_AF_GPIO 0x5 #define SD_B0_02_AF_ENET2_RX_ER 0x8 #define SD_B0_02_AF_SEMC_CLK5 0x9 #define SD_B0_03_AF_USDHC1 0x0 #define SD_B0_03_AF_FLEXPWM1 0x1 #define SD_B0_03_AF_LPUART8 0x2 #define SD_B0_03_AF_XBAR1 0x3 #define SD_B0_03_AF_LPSPI1 0x4 #define SD_B0_03_AF_GPIO 0x5 #define SD_B0_03_AF_ENET2_RDATA00 0x8 #define SD_B0_03_AF_SEMC_CLK6 0x9 #define SD_B0_04_AF_USDHC1 0x0 #define SD_B0_04_AF_FLEXPWM1 0x1 #define SD_B0_04_AF_LPUART8 0x2 #define SD_B0_04_AF_XBAR1 0x3 #define SD_B0_04_AF_FLEXSPIB 0x4 #define SD_B0_04_AF_GPIO 0x5 #define SD_B0_04_AF_CCM 0x6 #define SD_B0_04_AF_ENET2_RDATA01 0x8 #define SD_B0_05_AF_USDHC1 0x0 #define SD_B0_05_AF_FLEXPWM1 0x1 #define SD_B0_05_AF_LPUART8 0x2 #define SD_B0_05_AF_XBAR1 0x3 #define SD_B0_05_AF_FLEXSPIB 0x4 #define SD_B0_05_AF_GPIO 0x5 #define SD_B0_05_AF_CCM 0x6 #define SD_B0_05_AF_ENET2_RX_EN 0x8 #define SD_B1_00_AF_USDHC2 0x0 #define SD_B1_00_AF_FLEXSPIB 0x1 #define SD_B1_00_AF_FLEXPWM1 0x2 #define SD_B1_00_AF_SAI1 0x3 #define SD_B1_00_AF_LPUART4 0x4 #define SD_B1_00_AF_GPIO 0x5 #define SD_B1_00_AF_SAI3 0x8 #define SD_B1_01_AF_USDHC2 0x0 #define SD_B1_01_AF_FLEXSPIB 0x1 #define SD_B1_01_AF_FLEXPWM1 0x2 #define SD_B1_01_AF_SAI1 0x3 #define SD_B1_01_AF_LPUART4 0x4 #define SD_B1_01_AF_GPIO 0x5 #define SD_B1_01_AF_SAI3 0x8 #define SD_B1_02_AF_USDHC2 0x0 #define SD_B1_02_AF_FLEXSPIB 0x1 #define SD_B1_02_AF_FLEXPWM2 0x2 #define SD_B1_02_AF_SAI1 0x3 #define SD_B1_02_AF_FLEXCAN1 0x4 #define SD_B1_02_AF_GPIO 0x5 #define SD_B1_02_AF_CCM 0x6 #define SD_B1_02_AF_SAI3 0x8 #define SD_B1_03_AF_USDHC2 0x0 #define SD_B1_03_AF_FLEXSPIB 0x1 #define SD_B1_03_AF_FLEXPWM2 0x2 #define SD_B1_03_AF_SAI1 0x3 #define SD_B1_03_AF_FLEXCAN1 0x4 #define SD_B1_03_AF_GPIO 0x5 #define SD_B1_03_AF_CCM 0x6 #define SD_B1_03_AF_SAI3 0x8 #define SD_B1_04_AF_USDHC2 0x0 #define SD_B1_04_AF_FLEXSPIB 0x1 #define SD_B1_04_AF_LPI2C1 0x2 #define SD_B1_04_AF_SAI1 0x3 #define SD_B1_04_AF_FLEXSPIA 0x4 #define SD_B1_04_AF_GPIO 0x5 #define SD_B1_04_AF_CCM 0x6 #define SD_B1_04_AF_SAI3 0x8 #define SD_B1_05_AF_USDHC2 0x0 #define SD_B1_05_AF_FLEXSPIA 0x1 #define SD_B1_05_AF_LPI2C1 0x2 #define SD_B1_05_AF_SAI1 0x3 #define SD_B1_05_AF_FLEXSPIB 0x4 #define SD_B1_05_AF_GPIO 0x5 #define SD_B1_05_AF_SAI3 0x8 #define SD_B1_06_AF_USDHC2 0x0 #define SD_B1_06_AF_FLEXSPIA 0x1 #define SD_B1_06_AF_LPUART7 0x2 #define SD_B1_06_AF_SAI1 0x3 #define SD_B1_06_AF_LPSPI2 0x4 #define SD_B1_06_AF_GPIO 0x5 #define SD_B1_06_AF_SAI3 0x8 #define SD_B1_07_AF_SEMC_CSX01 0x0 #define SD_B1_07_AF_FLEXSPIA 0x1 #define SD_B1_07_AF_LPUART7 0x2 #define SD_B1_07_AF_SAI1 0x3 #define SD_B1_07_AF_LPSPI2 0x4 #define SD_B1_07_AF_GPIO 0x5 #define SD_B1_08_AF_USDHC2 0x0 #define SD_B1_08_AF_FLEXSPIA 0x1 #define SD_B1_08_AF_LPUART7 0x2 #define SD_B1_08_AF_SAI1 0x3 #define SD_B1_08_AF_LPSPI2 0x4 #define SD_B1_08_AF_GPIO 0x5 #define SD_B1_08_AF_SEMC_CSX02 0x6 #define SD_B1_09_AF_USDHC2 0x0 #define SD_B1_09_AF_FLEXSPIA 0x1 #define SD_B1_09_AF_LPUART7 0x2 #define SD_B1_09_AF_SAI1 0x3 #define SD_B1_09_AF_LPSPI2 0x4 #define SD_B1_09_AF_GPIO 0x5 #define SD_B1_10_AF_USDHC2 0x0 #define SD_B1_10_AF_FLEXSPIA 0x1 #define SD_B1_10_AF_LPUART2 0x2 #define SD_B1_10_AF_LPI2C2 0x3 #define SD_B1_10_AF_LPSPI2 0x4 #define SD_B1_10_AF_GPIO 0x5 #define SD_B1_11_AF_USDHC2 0x0 #define SD_B1_11_AF_FLEXSPIA 0x1 #define SD_B1_11_AF_LPUART2 0x2 #define SD_B1_11_AF_LPI2C2 0x3 #define SD_B1_11_AF_LPSPI2 0x4 #define SD_B1_11_AF_GPIO 0x5 #define SPI_B0_00_AF_GPIO 0x5 #define SPI_B0_01_AF_FLEXSPI2 0x0 #define SPI_B0_01_AF_GPIO 0x5 #define SPI_B0_02_AF_FLEXSPI2 0x0 #define SPI_B0_02_AF_GPIO 0x5 #define SPI_B0_03_AF_FLEXSPI2 0x0 #define SPI_B0_03_AF_GPIO 0x5 #define SPI_B0_04_AF_FLEXSPI2 0x0 #define SPI_B0_04_AF_GPIO 0x5 #define SPI_B0_05_AF_FLEXSPI2 0x0 #define SPI_B0_05_AF_GPIO 0x5 #define SPI_B0_06_AF_FLEXSPI2 0x0 #define SPI_B0_06_AF_GPIO 0x5 #define SPI_B0_07_AF_FLEXSPI2 0x0 #define SPI_B0_07_AF_GPIO 0x5 #define SPI_B0_08_AF_FLEXSPI2 0x0 #define SPI_B0_08_AF_GPIO 0x5 #define SPI_B0_09_AF_FLEXSPI2 0x0 #define SPI_B0_09_AF_GPIO 0x5 #define SPI_B0_10_AF_FLEXSPI2 0x0 #define SPI_B0_10_AF_GPIO 0x5 #define SPI_B0_11_AF_FLEXSPI2 0x0 #define SPI_B0_11_AF_GPIO 0x5 #define SPI_B0_12_AF_FLEXSPI2 0x0 #define SPI_B0_12_AF_GPIO 0x5 #define SPI_B0_13_AF_GPIO 0x5 #define SPI_B1_00_AF_FLEXSPI2 0x0 #define SPI_B1_00_AF_GPIO 0x5 #define SPI_B1_01_AF_FLEXSPI2 0x0 #define SPI_B1_01_AF_GPIO 0x5 #define SPI_B1_02_AF_FLEXSPI2 0x0 #define SPI_B1_02_AF_GPIO 0x5 #define SPI_B1_03_AF_FLEXSPI2 0x0 #define SPI_B1_03_AF_GPIO 0x5 #define SPI_B1_04_AF_FLEXSPI2 0x0 #define SPI_B1_04_AF_GPIO 0x5 #define SPI_B1_05_AF_FLEXSPI2 0x0 #define SPI_B1_05_AF_GPIO 0x5 #define SPI_B1_06_AF_FLEXSPI2 0x0 #define SPI_B1_06_AF_GPIO 0x5 #define SPI_B1_07_AF_GPIO 0x5 #define WAKEUP_AF_GPIO 0x5 #define WAKEUP_AF_NMI 0x7 #define PMIC_ON_REQ_AF_SNVS 0x0 #define PMIC_ON_REQ_AF_GPIO 0x5 #define PMIC_STBY_REQ_AF_CCM 0x0 #define PMIC_STBY_REQ_AF_GPIO 0x5 extern const imxrt_pad_t imxrt_pad_EMC_00; extern const imxrt_pad_t imxrt_pad_EMC_01; extern const imxrt_pad_t imxrt_pad_EMC_02; extern const imxrt_pad_t imxrt_pad_EMC_03; extern const imxrt_pad_t imxrt_pad_EMC_04; extern const imxrt_pad_t imxrt_pad_EMC_05; extern const imxrt_pad_t imxrt_pad_EMC_06; extern const imxrt_pad_t imxrt_pad_EMC_07; extern const imxrt_pad_t imxrt_pad_EMC_08; extern const imxrt_pad_t imxrt_pad_EMC_09; extern const imxrt_pad_t imxrt_pad_EMC_10; extern const imxrt_pad_t imxrt_pad_EMC_11; extern const imxrt_pad_t imxrt_pad_EMC_12; extern const imxrt_pad_t imxrt_pad_EMC_13; extern const imxrt_pad_t imxrt_pad_EMC_14; extern const imxrt_pad_t imxrt_pad_EMC_15; extern const imxrt_pad_t imxrt_pad_EMC_16; extern const imxrt_pad_t imxrt_pad_EMC_17; extern const imxrt_pad_t imxrt_pad_EMC_18; extern const imxrt_pad_t imxrt_pad_EMC_19; extern const imxrt_pad_t imxrt_pad_EMC_20; extern const imxrt_pad_t imxrt_pad_EMC_21; extern const imxrt_pad_t imxrt_pad_EMC_22; extern const imxrt_pad_t imxrt_pad_EMC_23; extern const imxrt_pad_t imxrt_pad_EMC_24; extern const imxrt_pad_t imxrt_pad_EMC_25; extern const imxrt_pad_t imxrt_pad_EMC_26; extern const imxrt_pad_t imxrt_pad_EMC_27; extern const imxrt_pad_t imxrt_pad_EMC_28; extern const imxrt_pad_t imxrt_pad_EMC_29; extern const imxrt_pad_t imxrt_pad_EMC_30; extern const imxrt_pad_t imxrt_pad_EMC_31; extern const imxrt_pad_t imxrt_pad_EMC_32; extern const imxrt_pad_t imxrt_pad_EMC_33; extern const imxrt_pad_t imxrt_pad_EMC_34; extern const imxrt_pad_t imxrt_pad_EMC_35; extern const imxrt_pad_t imxrt_pad_EMC_36; extern const imxrt_pad_t imxrt_pad_EMC_37; extern const imxrt_pad_t imxrt_pad_EMC_38; extern const imxrt_pad_t imxrt_pad_EMC_39; extern const imxrt_pad_t imxrt_pad_EMC_40; extern const imxrt_pad_t imxrt_pad_EMC_41; extern const imxrt_pad_t imxrt_pad_AD_B0_00; extern const imxrt_pad_t imxrt_pad_AD_B0_01; extern const imxrt_pad_t imxrt_pad_AD_B0_02; extern const imxrt_pad_t imxrt_pad_AD_B0_03; extern const imxrt_pad_t imxrt_pad_AD_B0_04; extern const imxrt_pad_t imxrt_pad_AD_B0_05; extern const imxrt_pad_t imxrt_pad_AD_B0_06; extern const imxrt_pad_t imxrt_pad_AD_B0_07; extern const imxrt_pad_t imxrt_pad_AD_B0_08; extern const imxrt_pad_t imxrt_pad_AD_B0_09; extern const imxrt_pad_t imxrt_pad_AD_B0_10; extern const imxrt_pad_t imxrt_pad_AD_B0_11; extern const imxrt_pad_t imxrt_pad_AD_B0_12; extern const imxrt_pad_t imxrt_pad_AD_B0_13; extern const imxrt_pad_t imxrt_pad_AD_B0_14; extern const imxrt_pad_t imxrt_pad_AD_B0_15; extern const imxrt_pad_t imxrt_pad_AD_B1_00; extern const imxrt_pad_t imxrt_pad_AD_B1_01; extern const imxrt_pad_t imxrt_pad_AD_B1_02; extern const imxrt_pad_t imxrt_pad_AD_B1_03; extern const imxrt_pad_t imxrt_pad_AD_B1_04; extern const imxrt_pad_t imxrt_pad_AD_B1_05; extern const imxrt_pad_t imxrt_pad_AD_B1_06; extern const imxrt_pad_t imxrt_pad_AD_B1_07; extern const imxrt_pad_t imxrt_pad_AD_B1_08; extern const imxrt_pad_t imxrt_pad_AD_B1_09; extern const imxrt_pad_t imxrt_pad_AD_B1_10; extern const imxrt_pad_t imxrt_pad_AD_B1_11; extern const imxrt_pad_t imxrt_pad_AD_B1_12; extern const imxrt_pad_t imxrt_pad_AD_B1_13; extern const imxrt_pad_t imxrt_pad_AD_B1_14; extern const imxrt_pad_t imxrt_pad_AD_B1_15; extern const imxrt_pad_t imxrt_pad_B0_00; extern const imxrt_pad_t imxrt_pad_B0_01; extern const imxrt_pad_t imxrt_pad_B0_02; extern const imxrt_pad_t imxrt_pad_B0_03; extern const imxrt_pad_t imxrt_pad_B0_04; extern const imxrt_pad_t imxrt_pad_B0_05; extern const imxrt_pad_t imxrt_pad_B0_06; extern const imxrt_pad_t imxrt_pad_B0_07; extern const imxrt_pad_t imxrt_pad_B0_08; extern const imxrt_pad_t imxrt_pad_B0_09; extern const imxrt_pad_t imxrt_pad_B0_10; extern const imxrt_pad_t imxrt_pad_B0_11; extern const imxrt_pad_t imxrt_pad_B0_12; extern const imxrt_pad_t imxrt_pad_B0_13; extern const imxrt_pad_t imxrt_pad_B0_14; extern const imxrt_pad_t imxrt_pad_B0_15; extern const imxrt_pad_t imxrt_pad_B1_00; extern const imxrt_pad_t imxrt_pad_B1_01; extern const imxrt_pad_t imxrt_pad_B1_02; extern const imxrt_pad_t imxrt_pad_B1_03; extern const imxrt_pad_t imxrt_pad_B1_04; extern const imxrt_pad_t imxrt_pad_B1_05; extern const imxrt_pad_t imxrt_pad_B1_06; extern const imxrt_pad_t imxrt_pad_B1_07; extern const imxrt_pad_t imxrt_pad_B1_08; extern const imxrt_pad_t imxrt_pad_B1_09; extern const imxrt_pad_t imxrt_pad_B1_10; extern const imxrt_pad_t imxrt_pad_B1_11; extern const imxrt_pad_t imxrt_pad_B1_12; extern const imxrt_pad_t imxrt_pad_B1_13; extern const imxrt_pad_t imxrt_pad_B1_14; extern const imxrt_pad_t imxrt_pad_B1_15; extern const imxrt_pad_t imxrt_pad_SD_B0_00; extern const imxrt_pad_t imxrt_pad_SD_B0_01; extern const imxrt_pad_t imxrt_pad_SD_B0_02; extern const imxrt_pad_t imxrt_pad_SD_B0_03; extern const imxrt_pad_t imxrt_pad_SD_B0_04; extern const imxrt_pad_t imxrt_pad_SD_B0_05; extern const imxrt_pad_t imxrt_pad_SD_B1_00; extern const imxrt_pad_t imxrt_pad_SD_B1_01; extern const imxrt_pad_t imxrt_pad_SD_B1_02; extern const imxrt_pad_t imxrt_pad_SD_B1_03; extern const imxrt_pad_t imxrt_pad_SD_B1_04; extern const imxrt_pad_t imxrt_pad_SD_B1_05; extern const imxrt_pad_t imxrt_pad_SD_B1_06; extern const imxrt_pad_t imxrt_pad_SD_B1_07; extern const imxrt_pad_t imxrt_pad_SD_B1_08; extern const imxrt_pad_t imxrt_pad_SD_B1_09; extern const imxrt_pad_t imxrt_pad_SD_B1_10; extern const imxrt_pad_t imxrt_pad_SD_B1_11; extern const imxrt_pad_t imxrt_pad_SPI_B0_00; extern const imxrt_pad_t imxrt_pad_SPI_B0_01; extern const imxrt_pad_t imxrt_pad_SPI_B0_02; extern const imxrt_pad_t imxrt_pad_SPI_B0_03; extern const imxrt_pad_t imxrt_pad_SPI_B0_04; extern const imxrt_pad_t imxrt_pad_SPI_B0_05; extern const imxrt_pad_t imxrt_pad_SPI_B0_06; extern const imxrt_pad_t imxrt_pad_SPI_B0_07; extern const imxrt_pad_t imxrt_pad_SPI_B0_08; extern const imxrt_pad_t imxrt_pad_SPI_B0_09; extern const imxrt_pad_t imxrt_pad_SPI_B0_10; extern const imxrt_pad_t imxrt_pad_SPI_B0_11; extern const imxrt_pad_t imxrt_pad_SPI_B0_12; extern const imxrt_pad_t imxrt_pad_SPI_B0_13; extern const imxrt_pad_t imxrt_pad_SPI_B1_00; extern const imxrt_pad_t imxrt_pad_SPI_B1_01; extern const imxrt_pad_t imxrt_pad_SPI_B1_02; extern const imxrt_pad_t imxrt_pad_SPI_B1_03; extern const imxrt_pad_t imxrt_pad_SPI_B1_04; extern const imxrt_pad_t imxrt_pad_SPI_B1_05; extern const imxrt_pad_t imxrt_pad_SPI_B1_06; extern const imxrt_pad_t imxrt_pad_SPI_B1_07; extern const imxrt_pad_t imxrt_pad_WAKEUP; extern const imxrt_pad_t imxrt_pad_PMIC_ON_REQ; extern const imxrt_pad_t imxrt_pad_PMIC_STBY_REQ; #endif // __IMXRT_PADS_H__
4e7ce49dc837225816b973d38cf9708815bd7d5f
59864cbd213b5da6f50d6255b0a021564b3d5bd4
/challenges/COLLIDEOSCOPE/pov_2/pov_2.c
ae193f3625d89e0113fd0ad01c6d3abf469ba018
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-unknown", "BSD-2-Clause" ]
permissive
trailofbits/cb-multios
8af96a4fbc3b34644367faa135347f88e0e0d0a3
810d7b24b1f62f56ef49b148fe155b0d0629cad2
refs/heads/master
2023-09-05T03:56:20.229403
2022-12-27T15:47:54
2022-12-27T15:47:54
41,688,943
522
133
MIT
2023-06-29T02:47:13
2015-08-31T17:04:31
C
UTF-8
C
false
false
11,559
c
pov_2.c
/* * Copyright (C) Narf Industries <info@narfindustries.com> * * 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 "libpov.h" #include "cgc_conv.h" int main(int cgc_argc, char *cgc_argv[]) { cgc_negotiate_type2(); //*** delay cgc_delay(100); do { unsigned char *read_00000; unsigned int read_00000_len; unsigned int read_00000_ptr = 0; //**** length cgc_read read_00000_len = 2; read_00000 = (unsigned char*)cgc_malloc(read_00000_len); int read_00000_res = cgc_length_read(0, read_00000, read_00000_len); if (read_00000_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00000_00000[] = "\x3e\x20"; read_00000_ptr += cgc_data_match(read_00000 + read_00000_ptr, read_00000_len - read_00000_ptr, match_00000_00000, 2); cgc_free(read_00000); if (read_00000_ptr) {} //silence unused variable warning if any } while (0); do { //*** writing data static unsigned char write_00000_00000[] = "\x78\x20\x3d\x20\x30\x0a"; static unsigned int write_00000_00000_len = 6; unsigned char *write_00000 = NULL; unsigned int write_00000_len = 0; write_00000 = cgc_append_buf(write_00000, &write_00000_len, write_00000_00000, write_00000_00000_len); if (write_00000_len > 0) { cgc_transmit_all(1, write_00000, write_00000_len); } cgc_free(write_00000); } while (0); do { unsigned char *csum_read; unsigned int csum_read_len; csum_read_len = 9; csum_read = (unsigned char*)cgc_malloc(csum_read_len); cgc_length_read(0, csum_read, csum_read_len); cgc_free(csum_read); } while (0); do { unsigned char *read_00001; unsigned int read_00001_len; unsigned int read_00001_ptr = 0; //**** delimited cgc_read static unsigned char read_00001_delim[] = "\x0a"; read_00001 = NULL; read_00001_len = 0; int read_00001_res = cgc_delimited_read(0, &read_00001, &read_00001_len, read_00001_delim, 1); if (read_00001_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00001_00000[] = "\x5f\x20\x3d\x20\x30\x0a"; read_00001_ptr += cgc_data_match(read_00001 + read_00001_ptr, read_00001_len - read_00001_ptr, match_00001_00000, 6); cgc_free(read_00001); if (read_00001_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00002; unsigned int read_00002_len; unsigned int read_00002_ptr = 0; //**** length cgc_read read_00002_len = 2; read_00002 = (unsigned char*)cgc_malloc(read_00002_len); int read_00002_res = cgc_length_read(0, read_00002, read_00002_len); if (read_00002_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00002_00000[] = "\x3e\x20"; read_00002_ptr += cgc_data_match(read_00002 + read_00002_ptr, read_00002_len - read_00002_ptr, match_00002_00000, 2); cgc_free(read_00002); if (read_00002_ptr) {} //silence unused variable warning if any } while (0); do { //*** writing data static unsigned char write_00001_00000[] = "\x26\x78\x0a"; static unsigned int write_00001_00000_len = 3; unsigned char *write_00001 = NULL; unsigned int write_00001_len = 0; write_00001 = cgc_append_buf(write_00001, &write_00001_len, write_00001_00000, write_00001_00000_len); if (write_00001_len > 0) { cgc_transmit_all(1, write_00001, write_00001_len); } cgc_free(write_00001); } while (0); do { unsigned char *csum_read; unsigned int csum_read_len; csum_read_len = 9; csum_read = (unsigned char*)cgc_malloc(csum_read_len); cgc_length_read(0, csum_read, csum_read_len); cgc_free(csum_read); } while (0); do { unsigned char *read_00003; unsigned int read_00003_len; unsigned int read_00003_ptr = 0; //**** delimited cgc_read static unsigned char read_00003_delim[] = "\x0a"; read_00003 = NULL; read_00003_len = 0; int read_00003_res = cgc_delimited_read(0, &read_00003, &read_00003_len, read_00003_delim, 1); if (read_00003_res) {} //silence unused variable warning cgc_free(read_00003); if (read_00003_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00004; unsigned int read_00004_len; unsigned int read_00004_ptr = 0; //**** length cgc_read read_00004_len = 2; read_00004 = (unsigned char*)cgc_malloc(read_00004_len); int read_00004_res = cgc_length_read(0, read_00004, read_00004_len); if (read_00004_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00004_00000[] = "\x3e\x20"; read_00004_ptr += cgc_data_match(read_00004 + read_00004_ptr, read_00004_len - read_00004_ptr, match_00004_00000, 2); cgc_free(read_00004); if (read_00004_ptr) {} //silence unused variable warning if any } while (0); do { //*** writing data static unsigned char write_00002_00000[] = "\x7e\x7e\x31\x31\x32\x38\x37\x37\x35\x36\x38\x30\x0a"; static unsigned int write_00002_00000_len = 13; unsigned char *write_00002 = NULL; unsigned int write_00002_len = 0; write_00002 = cgc_append_buf(write_00002, &write_00002_len, write_00002_00000, write_00002_00000_len); if (write_00002_len > 0) { cgc_transmit_all(1, write_00002, write_00002_len); } cgc_free(write_00002); } while (0); do { unsigned char *csum_read; unsigned int csum_read_len; csum_read_len = 9; csum_read = (unsigned char*)cgc_malloc(csum_read_len); cgc_length_read(0, csum_read, csum_read_len); cgc_free(csum_read); } while (0); do { unsigned char *read_00005; unsigned int read_00005_len; unsigned int read_00005_ptr = 0; //**** delimited cgc_read static unsigned char read_00005_delim[] = "\x0a"; read_00005 = NULL; read_00005_len = 0; int read_00005_res = cgc_delimited_read(0, &read_00005, &read_00005_len, read_00005_delim, 1); if (read_00005_res) {} //silence unused variable warning cgc_free(read_00005); if (read_00005_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00006; unsigned int read_00006_len; unsigned int read_00006_ptr = 0; //**** length cgc_read read_00006_len = 2; read_00006 = (unsigned char*)cgc_malloc(read_00006_len); int read_00006_res = cgc_length_read(0, read_00006, read_00006_len); if (read_00006_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00006_00000[] = "\x3e\x20"; read_00006_ptr += cgc_data_match(read_00006 + read_00006_ptr, read_00006_len - read_00006_ptr, match_00006_00000, 2); cgc_free(read_00006); if (read_00006_ptr) {} //silence unused variable warning if any } while (0); do { //*** writing data static unsigned char write_00003_00000[] = "\x24\x5f\x0a"; static unsigned int write_00003_00000_len = 3; unsigned char *write_00003 = NULL; unsigned int write_00003_len = 0; write_00003 = cgc_append_buf(write_00003, &write_00003_len, write_00003_00000, write_00003_00000_len); if (write_00003_len > 0) { cgc_transmit_all(1, write_00003, write_00003_len); } cgc_free(write_00003); } while (0); do { unsigned char *csum_read; unsigned int csum_read_len; csum_read_len = 9; csum_read = (unsigned char*)cgc_malloc(csum_read_len); cgc_length_read(0, csum_read, csum_read_len); cgc_free(csum_read); } while (0); do { unsigned char *read_00007; unsigned int read_00007_len; unsigned int read_00007_ptr = 0; //**** length cgc_read read_00007_len = 4; read_00007 = (unsigned char*)cgc_malloc(read_00007_len); int read_00007_res = cgc_length_read(0, read_00007, read_00007_len); if (read_00007_res) {} //silence unused variable warning cgc_free(read_00007); if (read_00007_ptr) {} //silence unused variable warning if any } while (0); do { unsigned int flag; unsigned char *read_00008; unsigned int read_00008_len; unsigned int read_00008_ptr = 0; //**** delimited cgc_read static unsigned char read_00008_delim[] = "\x0a"; read_00008 = NULL; read_00008_len = 0; int read_00008_res = cgc_delimited_read(0, &read_00008, &read_00008_len, read_00008_delim, 1); if (read_00008_res) {} //silence unused variable warning cgc_strtoi((char *)read_00008, 10, (int *)&flag); cgc_putenv("TYPE2_VALUE", (unsigned char *)&flag, sizeof(unsigned int)); cgc_free(read_00008); if (read_00008_ptr) {} //silence unused variable warning if any } while (0); do { unsigned char *read_00009; unsigned int read_00009_len; unsigned int read_00009_ptr = 0; //**** length cgc_read read_00009_len = 2; read_00009 = (unsigned char*)cgc_malloc(read_00009_len); int read_00009_res = cgc_length_read(0, read_00009, read_00009_len); if (read_00009_res) {} //silence unused variable warning //**** cgc_read match data static unsigned char match_00009_00000[] = "\x3e\x20"; read_00009_ptr += cgc_data_match(read_00009 + read_00009_ptr, read_00009_len - read_00009_ptr, match_00009_00000, 2); cgc_free(read_00009); if (read_00009_ptr) {} //silence unused variable warning if any } while (0); do { //*** writing data static unsigned char write_00004_00000[] = "\x25\x71\x75\x69\x74\x0a"; static unsigned int write_00004_00000_len = 6; unsigned char *write_00004 = NULL; unsigned int write_00004_len = 0; write_00004 = cgc_append_buf(write_00004, &write_00004_len, write_00004_00000, write_00004_00000_len); if (write_00004_len > 0) { cgc_transmit_all(1, write_00004, write_00004_len); } cgc_free(write_00004); } while (0); //*** submitting type 2 POV results cgc_submit_type2(NULL); }
9cd6628a7ba368134331f6b5451565e126591619
31406f420f019a191a74b9288a6e37dcd89e8e82
/tools/node-hermes/third-party/libuv/src/unix/kqueue.c
092005161f45466aa2abafc7b2664cf9d785ac66
[ "CC-BY-4.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "ISC", "BSD-2-Clause" ]
permissive
facebook/hermes
b1bf3cb60b5946450c7c9a421ac8dad7a675e0f5
440578b31ecce46fcc5ba2ad745ffd5712d63a35
refs/heads/main
2023-09-06T04:16:02.263184
2023-09-05T20:12:54
2023-09-05T20:12:54
154,201,259
8,449
593
MIT
2023-09-14T21:25:56
2018-10-22T19:13:00
C++
UTF-8
C
false
false
13,874
c
kqueue.c
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #include "uv.h" #include "internal.h" #include <assert.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/sysctl.h> #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> #include <unistd.h> #include <fcntl.h> #include <time.h> /* * Required on * - Until at least FreeBSD 11.0 * - Older versions of Mac OS X * * http://www.boost.org/doc/libs/1_61_0/boost/asio/detail/kqueue_reactor.hpp */ #ifndef EV_OOBAND #define EV_OOBAND EV_FLAG1 #endif static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags); int uv__kqueue_init(uv_loop_t* loop) { loop->backend_fd = kqueue(); if (loop->backend_fd == -1) return UV__ERR(errno); uv__cloexec(loop->backend_fd, 1); return 0; } #if defined(__APPLE__) static int uv__has_forked_with_cfrunloop; #endif int uv__io_fork(uv_loop_t* loop) { int err; loop->backend_fd = -1; err = uv__kqueue_init(loop); if (err) return err; #if defined(__APPLE__) if (loop->cf_state != NULL) { /* We cannot start another CFRunloop and/or thread in the child process; CF aborts if you try or if you try to touch the thread at all to kill it. So the best we can do is ignore it from now on. This means we can't watch directories in the same way anymore (like other BSDs). It also means we cannot properly clean up the allocated resources; calling uv__fsevents_loop_delete from uv_loop_close will crash the process. So we sidestep the issue by pretending like we never started it in the first place. */ uv__has_forked_with_cfrunloop = 1; uv__free(loop->cf_state); loop->cf_state = NULL; } #endif return err; } int uv__io_check_fd(uv_loop_t* loop, int fd) { struct kevent ev; int rc; rc = 0; EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) rc = UV__ERR(errno); EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); if (rc == 0) if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) abort(); return rc; } void uv__io_poll(uv_loop_t* loop, int timeout) { struct kevent events[1024]; struct kevent* ev; struct timespec spec; unsigned int nevents; unsigned int revents; QUEUE* q; uv__io_t* w; sigset_t* pset; sigset_t set; uint64_t base; uint64_t diff; int have_signals; int filter; int fflags; int count; int nfds; int fd; int op; int i; if (loop->nfds == 0) { assert(QUEUE_EMPTY(&loop->watcher_queue)); return; } nevents = 0; while (!QUEUE_EMPTY(&loop->watcher_queue)) { q = QUEUE_HEAD(&loop->watcher_queue); QUEUE_REMOVE(q); QUEUE_INIT(q); w = QUEUE_DATA(q, uv__io_t, watcher_queue); assert(w->pevents != 0); assert(w->fd >= 0); assert(w->fd < (int) loop->nwatchers); if ((w->events & POLLIN) == 0 && (w->pevents & POLLIN) != 0) { filter = EVFILT_READ; fflags = 0; op = EV_ADD; if (w->cb == uv__fs_event) { filter = EVFILT_VNODE; fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; op = EV_ADD | EV_ONESHOT; /* Stop the event from firing repeatedly. */ } EV_SET(events + nevents, w->fd, filter, op, fflags, 0, 0); if (++nevents == ARRAY_SIZE(events)) { if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) abort(); nevents = 0; } } if ((w->events & POLLOUT) == 0 && (w->pevents & POLLOUT) != 0) { EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0); if (++nevents == ARRAY_SIZE(events)) { if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) abort(); nevents = 0; } } if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) { EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0); if (++nevents == ARRAY_SIZE(events)) { if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL)) abort(); nevents = 0; } } w->events = w->pevents; } pset = NULL; if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { pset = &set; sigemptyset(pset); sigaddset(pset, SIGPROF); } assert(timeout >= -1); base = loop->time; count = 48; /* Benchmarks suggest this gives the best throughput. */ for (;; nevents = 0) { if (timeout != -1) { spec.tv_sec = timeout / 1000; spec.tv_nsec = (timeout % 1000) * 1000000; } if (pset != NULL) pthread_sigmask(SIG_BLOCK, pset, NULL); nfds = kevent(loop->backend_fd, events, nevents, events, ARRAY_SIZE(events), timeout == -1 ? NULL : &spec); if (pset != NULL) pthread_sigmask(SIG_UNBLOCK, pset, NULL); /* Update loop->time unconditionally. It's tempting to skip the update when * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the * operating system didn't reschedule our process while in the syscall. */ SAVE_ERRNO(uv__update_time(loop)); if (nfds == 0) { assert(timeout != -1); return; } if (nfds == -1) { if (errno != EINTR) abort(); if (timeout == 0) return; if (timeout == -1) continue; /* Interrupted by a signal. Update timeout and poll again. */ goto update_timeout; } have_signals = 0; nevents = 0; assert(loop->watchers != NULL); loop->watchers[loop->nwatchers] = (void*) events; loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds; for (i = 0; i < nfds; i++) { ev = events + i; fd = ev->ident; /* Skip invalidated events, see uv__platform_invalidate_fd */ if (fd == -1) continue; w = loop->watchers[fd]; if (w == NULL) { /* File descriptor that we've stopped watching, disarm it. * TODO: batch up. */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) if (errno != EBADF && errno != ENOENT) abort(); continue; } if (ev->filter == EVFILT_VNODE) { assert(w->events == POLLIN); assert(w->pevents == POLLIN); w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */ nevents++; continue; } revents = 0; if (ev->filter == EVFILT_READ) { if (w->pevents & POLLIN) { revents |= POLLIN; w->rcount = ev->data; } else { /* TODO batch up */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) if (errno != ENOENT) abort(); } } if (ev->filter == EV_OOBAND) { if (w->pevents & UV__POLLPRI) { revents |= UV__POLLPRI; w->rcount = ev->data; } else { /* TODO batch up */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) if (errno != ENOENT) abort(); } } if (ev->filter == EVFILT_WRITE) { if (w->pevents & POLLOUT) { revents |= POLLOUT; w->wcount = ev->data; } else { /* TODO batch up */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) if (errno != ENOENT) abort(); } } if (ev->flags & EV_ERROR) revents |= POLLERR; if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) revents |= UV__POLLRDHUP; if (revents == 0) continue; /* Run signal watchers last. This also affects child process watchers * because those are implemented in terms of signal watchers. */ if (w == &loop->signal_io_watcher) have_signals = 1; else w->cb(loop, w, revents); nevents++; } if (have_signals != 0) loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; if (have_signals != 0) return; /* Event loop should cycle now so don't poll again. */ if (nevents != 0) { if (nfds == ARRAY_SIZE(events) && --count != 0) { /* Poll for more events but don't block this time. */ timeout = 0; continue; } return; } if (timeout == 0) return; if (timeout == -1) continue; update_timeout: assert(timeout > 0); diff = loop->time - base; if (diff >= (uint64_t) timeout) return; timeout -= diff; } } void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { struct kevent* events; uintptr_t i; uintptr_t nfds; assert(loop->watchers != NULL); assert(fd >= 0); events = (struct kevent*) loop->watchers[loop->nwatchers]; nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; if (events == NULL) return; /* Invalidate events with same file descriptor */ for (i = 0; i < nfds; i++) if ((int) events[i].ident == fd) events[i].ident = -1; } static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags) { uv_fs_event_t* handle; struct kevent ev; int events; const char* path; #if defined(F_GETPATH) /* MAXPATHLEN == PATH_MAX but the former is what XNU calls it internally. */ char pathbuf[MAXPATHLEN]; #endif handle = container_of(w, uv_fs_event_t, event_watcher); if (fflags & (NOTE_ATTRIB | NOTE_EXTEND)) events = UV_CHANGE; else events = UV_RENAME; path = NULL; #if defined(F_GETPATH) /* Also works when the file has been unlinked from the file system. Passing * in the path when the file has been deleted is arguably a little strange * but it's consistent with what the inotify backend does. */ if (fcntl(handle->event_watcher.fd, F_GETPATH, pathbuf) == 0) path = uv__basename_r(pathbuf); #endif handle->cb(handle, path, events, 0); if (handle->event_watcher.fd == -1) return; /* Watcher operates in one-shot mode, re-arm it. */ fflags = NOTE_ATTRIB | NOTE_WRITE | NOTE_RENAME | NOTE_DELETE | NOTE_EXTEND | NOTE_REVOKE; EV_SET(&ev, w->fd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, fflags, 0, 0); if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) abort(); } int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); return 0; } int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags) { int fd; if (uv__is_active(handle)) return UV_EINVAL; #if defined(__APPLE__) /* Nullify field to perform checks later */ handle->cf_cb = NULL; handle->realpath = NULL; handle->realpath_len = 0; handle->cf_flags = flags; if (!uv__has_forked_with_cfrunloop) { int r; /* The fallback fd is not used */ handle->event_watcher.fd = -1; handle->path = uv__strdup(path); if (handle->path == NULL) return UV_ENOMEM; handle->cb = cb; r = uv__fsevents_init(handle); if (r == 0) { uv__handle_start(handle); } else { uv__free(handle->path); handle->path = NULL; } return r; } #endif /* defined(__APPLE__) */ /* TODO open asynchronously - but how do we report back errors? */ fd = open(path, O_RDONLY); if (fd == -1) return UV__ERR(errno); handle->path = uv__strdup(path); if (handle->path == NULL) { uv__close_nocheckstdio(fd); return UV_ENOMEM; } handle->cb = cb; uv__handle_start(handle); uv__io_init(&handle->event_watcher, uv__fs_event, fd); uv__io_start(handle->loop, &handle->event_watcher, POLLIN); return 0; } int uv_fs_event_stop(uv_fs_event_t* handle) { int r; r = 0; if (!uv__is_active(handle)) return 0; uv__handle_stop(handle); #if defined(__APPLE__) if (!uv__has_forked_with_cfrunloop) r = uv__fsevents_close(handle); #endif if (handle->event_watcher.fd != -1) { uv__io_close(handle->loop, &handle->event_watcher); uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; } uv__free(handle->path); handle->path = NULL; return r; } void uv__fs_event_close(uv_fs_event_t* handle) { uv_fs_event_stop(handle); }
77771a9efbe564f7a8185617a93b498a27d7afee
fff6d13af91db925a94b3e3474108fafd519bba0
/src/Cog/sithCogExec.h
f5bfb2216ba012ca77c37597c34f7b913646f628
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
shinyquagsire23/OpenJKDF2
94f1364628924ac944466107606b91c6faeec3df
b79b8c210878b6f276ed3d1a5dad91d9219e6ce1
refs/heads/master
2023-07-08T16:41:38.986577
2023-06-28T08:47:39
2023-06-28T08:47:39
139,542,792
381
34
NOASSERTION
2023-06-28T08:47:40
2018-07-03T07:09:45
C
UTF-8
C
false
false
5,867
h
sithCogExec.h
#ifndef _COG_SITHCOGEXEC_H #define _COG_SITHCOGEXEC_H #include "types.h" #include "globals.h" #include "Engine/rdKeyframe.h" #include "World/sithThing.h" #include "Engine/rdMaterial.h" #define sithCogExec_Exec_ADDR (0x004E1F60) #define sithCogExec_ExecCog_ADDR (0x004E2350) #define sithCogExec_PopValue_ADDR (0x004E2440) #define sithCogExec_PopFlex_ADDR (0x004E24F0) #define sithCogExec_PopInt_ADDR (0x004E25C0) #define sithCogExec_PopSymbolIdx_ADDR (0x004E2690) #define sithCogExec_PopVector3_ADDR (0x004E26E0) #define sithCogExec_PopCog_ADDR (0x004E27B0) #define sithCogExec_PopThing_ADDR (0x004E28C0) #define sithCogExec_PopTemplate_ADDR (0x004E29C0) #define sithCogExec_PopSound_ADDR (0x004E2AD0) #define sithCogExec_PopSector_ADDR (0x004E2BD0) #define sithCogExec_PopSurface_ADDR (0x004E2CC0) #define sithCogExec_PopMaterial_ADDR (0x004E2DB0) #define sithCogExec_PopModel3_ADDR (0x004E2EB0) #define sithCogExec_PopKeyframe_ADDR (0x004E2FB0) #define sithCogExec_PopAIClass_ADDR (0x004E30B0) #define sithCogExec_PopSymbolFunc_ADDR (0x004E31B0) #define sithCogExec_PopString_ADDR (0x004E3260) #define sithCogExec_PushVar_ADDR (0x004E32D0) #define sithCogExec_PushInt_ADDR (0x004E3340) #define sithCogExec_PushFlex_ADDR (0x004E33C0) #define sithCogExec_PushVector3_ADDR (0x004E3450) #define sithCogExec_PopProgramVal_ADDR (0x004E34E0) #define sithCogExec_ResetStack_ADDR (0x004E3510) #define sithCogExec_Call_ADDR (0x004E3530) #define sithCogExec_Ret_ADDR (0x004E3590) #define sithCogExec_PopStackVar_ADDR (0x004E35E0) #define sithCogExec_BitOperation_ADDR (0x004E3630) #define sithCogExec_MathOperation_ADDR (0x004E3870) #define sithCogExec_AssignStackVar_ADDR (0x004E3B90) // MOTS added extern int sithCogExec_009d39b0; extern sithCog* sithCogExec_pIdkMotsCtx; extern sithCog* sithCog_pActionCog; extern int sithCog_actionCogIdk; void sithCogExec_Exec(sithCog *cog_ctx); void sithCogExec_ExecCog(sithCog *ctx, int trigIdx); int sithCogExec_PopValue(sithCog *ctx, sithCogStackvar *stackVar); float sithCogExec_PopFlex(sithCog *ctx); int sithCogExec_PopInt(sithCog *ctx); int sithCogExec_PopSymbolIdx(sithCog *ctx); int sithCogExec_PopVector3(sithCog *ctx, rdVector3* out); sithCog* sithCogExec_PopCog(sithCog *ctx); sithThing* sithCogExec_PopThing(sithCog *ctx); sithThing* sithCogExec_PopTemplate(sithCog *ctx); sithSound* sithCogExec_PopSound(sithCog *ctx); sithSector* sithCogExec_PopSector(sithCog *ctx); sithSurface* sithCogExec_PopSurface(sithCog *ctx); rdMaterial* sithCogExec_PopMaterial(sithCog *ctx); rdModel3* sithCogExec_PopModel3(sithCog *ctx); rdKeyframe* sithCogExec_PopKeyframe(sithCog *ctx); sithAIClass* sithCogExec_PopAIClass(sithCog *ctx); char* sithCogExec_PopString(sithCog *ctx); cogSymbolFunc_t sithCogExec_PopSymbolFunc(sithCog *cog_ctx); void sithCogExec_PushVar(sithCog *ctx, sithCogStackvar *val); void sithCogExec_PushInt(sithCog *ctx, int val); void sithCogExec_PushFlex(sithCog *ctx, float val); void sithCogExec_PushVector3(sithCog *ctx, const rdVector3* val); int sithCogExec_PopProgramVal(sithCog *ctx); void sithCogExec_ResetStack(sithCog *ctx); void sithCogExec_Call(sithCog *ctx); void sithCogExec_Ret(sithCog *cog_ctx); int sithCogExec_PopStackVar(sithCog *cog, sithCogStackvar *out); void sithCogExec_BitOperation(sithCog *cog_ctx, int op); void sithCogExec_MathOperation(sithCog *cog_ctx, int op); sithCogStackvar* sithCogExec_AssignStackVar(sithCogStackvar *out, sithCog *ctx, sithCogStackvar *in); //static void (__cdecl *sithCogExec_Ret)(sithCog *cog) = (void*)sithCogExec_Ret_ADDR; //static void (__cdecl *sithCogExec_Call)(sithCog *cog) = (void*)sithCogExec_Call_ADDR; //static int (__cdecl *sithCogExec_PopProgramVal)(sithCog *cog) = (void*)sithCogExec_PopProgramVal_ADDR; //static int (__cdecl *sithCogExec_PopStackVar)(sithCog *cog, sithCogStackvar *out) = (void*)sithCogExec_PopStackVar_ADDR; //static sithCogStackvar* (__cdecl *sithCogExec_AssignStackVar)(sithCogStackvar *a1, sithCog* a2, sithCogStackvar *a3) = (void*)sithCogExec_AssignStackVar_ADDR; //static void (__cdecl *sithCogExec_MathOperation)(sithCog *cog, int op) = (void*)sithCogExec_MathOperation_ADDR; //static void (__cdecl *sithCogExec_BitOperation)(sithCog *cog, int op) = (void*)sithCogExec_BitOperation_ADDR; //static int (__cdecl *sithCogExec_PopValue)(sithCog *ctx, int *out) = (void*)sithCogExec_PopValue_ADDR; //static float (__cdecl *sithCogExec_PopFlex)(sithCog *ctx) = (void*)sithCogExec_PopFlex_ADDR; //static int (__cdecl *sithCogExec_PopInt)(sithCog *ctx) = (void*)sithCogExec_PopInt_ADDR; //static int (__cdecl *sithCogExec_PopVector3)(sithCog *ctx, rdVector3* out) = (void*)sithCogExec_PopVector3_ADDR; //static char* (__cdecl *sithCogExec_PopString)(sithCog *ctx) = (void*)sithCogExec_PopString_ADDR; //static sithSurface* (__cdecl *sithCogExec_PopSurface)(sithCog* ctx) = (void*)sithCogExec_PopSurface_ADDR; //static void* (__cdecl *sithCogExec_PopMaterial)(sithCog* ctx) = (void*)sithCogExec_PopMaterial_ADDR; //static rdKeyframe* (__cdecl *sithCogExec_PopKeyframe_)(sithCog* ctx) = (void*)sithCogExec_PopKeyframe_ADDR; //static sithCog* (__cdecl *sithCogExec_PopCog)(sithCog* ctx) = (void*)sithCogExec_PopCog_ADDR; //static int (__cdecl *sithCogExec_PopSymbolIdx)(sithCog *ctx) = (void*)sithCogExec_PopSymbolIdx_ADDR; //static cogSymbolFunc_t (__cdecl *sithCogExec_PopSymbolFunc)(sithCog *cog_ctx) = (void*)sithCogExec_PopSymbolFunc_ADDR; //static void (__cdecl *sithCogExec_PushVar)(sithCog *ctx, sithCogStackvar *val) = (void*)sithCogExec_PushVar_ADDR; //static void (__cdecl *sithCogExec_PushInt)(sithCog *ctx, int val) = (void*)sithCogExec_PushInt_ADDR; //static void (__cdecl *sithCogExec_PushFlex)(sithCog *ctx, float val) = (void*)sithCogExec_PushFlex_ADDR; //static void (__cdecl *sithCogExec_PushVector3)(sithCog *ctx, const rdVector3 *val) = (void*)sithCogExec_PushVector3_ADDR; #endif // _COG_SITHCOGEXEC_H
cf4bfeafd8a1b71de64f141ff936e8aca1ce232e
e9911598c43e8526da22b2773a73d9b5966f602a
/lib/ptrarray.h
900668d9b9469f84c3de121fce3d3a1200137cbb
[ "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
cyrusimap/cyrus-imapd
07236dfd887ed92c147938cf1ed2591449d7e8fd
315441d067ba85814768f840f20bc3bb7f20ea6b
refs/heads/master
2023-09-05T09:57:10.683822
2023-09-05T06:09:43
2023-09-05T06:09:43
59,071,965
508
164
NOASSERTION
2023-09-13T04:34:31
2016-05-18T01:33:49
C
UTF-8
C
false
false
3,314
h
ptrarray.h
/* ptrarray.h -- an expanding array of pointers * * Copyright (c) 1994-2011 Carnegie Mellon University. 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 "Carnegie Mellon University" must not be used to * endorse or promote products derived from this software without * prior written permission. For permission or any legal * details, please contact * Carnegie Mellon University * Center for Technology Transfer and Enterprise Creation * 4615 Forbes Avenue * Suite 302 * Pittsburgh, PA 15213 * (412) 268-7393, fax: (412) 268-7395 * innovation@andrew.cmu.edu * * 4. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by Computing Services * at Carnegie Mellon University (http://www.cmu.edu/computing/)." * * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Greg Banks * Start Date: 2011/01/11 */ #ifndef __CYRUS_PTRARRAY_H__ #define __CYRUS_PTRARRAY_H__ #include <config.h> #include <sys/types.h> typedef struct { int count; int alloc; void **data; } ptrarray_t; #define PTRARRAY_INITIALIZER { 0, 0, NULL } #define ptrarray_init(pa) (memset((pa), 0, sizeof(ptrarray_t))) void ptrarray_fini(ptrarray_t *); ptrarray_t *ptrarray_new(void); void ptrarray_free(ptrarray_t *); void ptrarray_append(ptrarray_t *, void *); void ptrarray_add(ptrarray_t *, void *); void ptrarray_set(ptrarray_t *, int idx, void *); void ptrarray_insert(ptrarray_t *, int idx, void *); void *ptrarray_remove(ptrarray_t *, int idx); void *ptrarray_nth(const ptrarray_t *pa, int idx); void ptrarray_truncate(ptrarray_t *pa, int newlen); #define ptrarray_shift(pa) ptrarray_remove((pa), 0) #define ptrarray_unshift(pa, s) ptrarray_insert((pa), 0, (s)) #define ptrarray_pop(pa) ptrarray_remove((pa), -1) #define ptrarray_push(pa, s) ptrarray_append((pa), (s)) #define ptrarray_tail(pa) ptrarray_nth((pa), -1) #define ptrarray_head(pa) ptrarray_nth((pa), 0) void **ptrarray_takevf(ptrarray_t *pa); int ptrarray_find(const ptrarray_t *pa, void *match, int starting); void ptrarray_sort(ptrarray_t *pa, int (*compare)(const void **, const void **)); int ptrarray_size(const ptrarray_t *pa); #endif /* __CYRUS_PTRARRAY_H__ */
3632d20fde2ac8a9a303b1c75426b01c156992da
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/include/configs/armadillo-800eva.h
8bb932ce8c234ff28789e8eb5a3f5f997c996bac
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "GPL-2.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
4,115
h
armadillo-800eva.h
/* * Configuation settings for the bonito board * * Copyright (C) 2012 Renesas Solutions Corp. * * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __ARMADILLO_800EVA_H #define __ARMADILLO_800EVA_H #undef DEBUG #define CONFIG_ARMV7 #define CONFIG_R8A7740 #define CONFIG_RMOBILE #define CONFIG_RMOBILE_BOARD_STRING "Armadillo-800EVA Board\n" #define CONFIG_SH_GPIO_PFC #include <asm/arch/rmobile.h> #define CONFIG_CMD_MEMORY #define CONFIG_CMD_DFL #define CONFIG_CMD_SDRAM #define CONFIG_CMD_RUN #define CONFIG_CMD_LOADS #define CONFIG_CMD_NET #define CONFIG_CMD_MII #define CONFIG_CMD_PING #define CONFIG_CMD_DHCP #define CONFIG_CMD_NFS #define CONFIG_CMD_BOOTZ #define CONFIG_OF_LIBFDT #define BOARD_LATE_INIT #define CONFIG_BAUDRATE 115200 #define CONFIG_BOOTDELAY 3 #define CONFIG_BOOTARGS "" #define CONFIG_VERSION_VARIABLE #undef CONFIG_SHOW_BOOT_PROGRESS #define CONFIG_ARCH_CPU_INIT #define CONFIG_DISPLAY_CPUINFO #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_USE_ARCH_MEMSET #define CONFIG_USE_ARCH_MEMCPY #define CONFIG_TMU_TIMER #define CONFIG_SYS_DCACHE_OFF #define CONFIG_SYS_GENERIC_BOARD /* STACK */ #define CONFIG_SYS_INIT_SP_ADDR 0xE8083000 #define STACK_AREA_SIZE 0xC000 #define LOW_LEVEL_MERAM_STACK \ (CONFIG_SYS_INIT_SP_ADDR + STACK_AREA_SIZE - 4) /* MEMORY */ #define ARMADILLO_800EVA_SDRAM_BASE 0x40000000 #define ARMADILLO_800EVA_SDRAM_SIZE (512 * 1024 * 1024) #define CONFIG_SYS_LONGHELP #define CONFIG_SYS_CBSIZE 256 #define CONFIG_SYS_PBSIZE 256 #define CONFIG_SYS_MAXARGS 16 #define CONFIG_SYS_BARGSIZE 512 #define CONFIG_SYS_BAUDRATE_TABLE { 115200 } /* SCIF */ #define CONFIG_SCIF_CONSOLE #define CONFIG_CONS_SCIF1 #define SCIF0_BASE 0xe6c40000 #define SCIF1_BASE 0xe6c50000 #define SCIF2_BASE 0xe6c60000 #define SCIF4_BASE 0xe6c80000 #define CONFIG_SCIF_A #undef CONFIG_SYS_CONSOLE_INFO_QUIET #undef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE #undef CONFIG_SYS_CONSOLE_ENV_OVERWRITE #define CONFIG_SYS_MEMTEST_START (ARMADILLO_800EVA_SDRAM_BASE) #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + \ 504 * 1024 * 1024) #undef CONFIG_SYS_ALT_MEMTEST #undef CONFIG_SYS_MEMTEST_SCRATCH #undef CONFIG_SYS_LOADS_BAUD_CHANGE #define CONFIG_SYS_SDRAM_BASE (ARMADILLO_800EVA_SDRAM_BASE) #define CONFIG_SYS_SDRAM_SIZE (ARMADILLO_800EVA_SDRAM_SIZE) #define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + \ 64 * 1024 * 1024) #define CONFIG_NR_DRAM_BANKS 1 #define CONFIG_SYS_MONITOR_BASE 0x00000000 #define CONFIG_SYS_MONITOR_LEN (256 * 1024) #define CONFIG_SYS_MALLOC_LEN (1 * 1024 * 1024) #define CONFIG_SYS_BOOTMAPSZ (8 * 1024 * 1024) #define CONFIG_SYS_TEXT_BASE 0xE80C0000 /* FLASH */ #define CONFIG_SYS_NO_FLASH #define CONFIG_SYS_FLASH_CFI #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT #define CONFIG_SYS_FLASH_BASE 0x00000000 #define CONFIG_SYS_MAX_FLASH_SECT 512 #define CONFIG_SYS_MAX_FLASH_BANKS 1 #define CONFIG_SYS_FLASH_BANKS_LIST { (CONFIG_SYS_FLASH_BASE) } #define CONFIG_SYS_FLASH_ERASE_TOUT 3000 #define CONFIG_SYS_FLASH_WRITE_TOUT 3000 #define CONFIG_SYS_FLASH_LOCK_TOUT 3000 #define CONFIG_SYS_FLASH_UNLOCK_TOUT 3000 /* ENV setting */ #define CONFIG_ENV_IS_IN_FLASH #define CONFIG_ENV_OVERWRITE 1 #define CONFIG_ENV_SECT_SIZE (128 * 1024) #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + \ CONFIG_SYS_MONITOR_LEN) #define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR) #define CONFIG_ENV_SIZE (CONFIG_ENV_SECT_SIZE) #define CONFIG_ENV_SIZE_REDUND (CONFIG_ENV_SECT_SIZE) /* SH Ether */ #define CONFIG_NET_MULTI #define CONFIG_SH_ETHER #define CONFIG_SH_ETHER_USE_PORT 0 #define CONFIG_SH_ETHER_PHY_ADDR 0x0 #define CONFIG_SH_ETHER_BASE_ADDR 0xe9a00000 #define CONFIG_SH_ETHER_SH7734_MII (0x01) #define CONFIG_SH_ETHER_PHY_MODE PHY_INTERFACE_MODE_MII #define CONFIG_PHYLIB #define CONFIG_PHY_SMSC #define CONFIG_BITBANGMII #define CONFIG_BITBANGMII_MULTI /* Board Clock */ #define CONFIG_SYS_CLK_FREQ 50000000 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ #define CONFIG_SYS_TMU_CLK_DIV 4 #endif /* __ARMADILLO_800EVA_H */
e8a99851d029d49fda64b583492175d752cc353f
a5a99f646e371b45974a6fb6ccc06b0a674818f2
/CondFormats/EcalObjects/interface/EcalLinearCorrections.h
ba7c048f7dff7c9dfc8885e19f9fb778546c23cd
[ "Apache-2.0" ]
permissive
cms-sw/cmssw
4ecd2c1105d59c66d385551230542c6615b9ab58
19c178740257eb48367778593da55dcad08b7a4f
refs/heads/master
2023-08-23T21:57:42.491143
2023-08-22T20:22:40
2023-08-22T20:22:40
10,969,551
1,006
3,696
Apache-2.0
2023-09-14T19:14:28
2013-06-26T14:09:07
C++
UTF-8
C
false
false
413
h
EcalLinearCorrections.h
#ifndef CondFormats_EcalObjects_EcalLinearCorrections_H #define CondFormats_EcalObjects_EcalLinearCorrections_H /** * Author: Shahram Rahatlou, University of Rome & INFN * Created: 22 Feb 2006 * $Id: EcalLinearCorrections.h,v 1.1 2012/11/21 16:58:24 fra Exp $ **/ #include "CondFormats/EcalObjects/interface/EcalTimeDependentCorrections.h" typedef EcalTimeDependentCorrections EcalLinearCorrections; #endif
d92fbd7fd12490617d634f2c2a88b1dfc1163355
76f9898ff7a555f4a729d725056a317af818375d
/assets/textures/parameter_static/parameter_static.c
4e6d70a5529cc27cd2b78a7d0d352e2962c1f0ea
[]
no_license
z64proto/sw97
0b65837ab2f2a4073faca5670761d7fe0e74d29d
f571505ade2cefd4a5b5d19da06d33e7c6b02c60
refs/heads/master
2023-08-01T02:47:42.895871
2022-05-15T20:29:08
2022-05-15T20:29:08
430,216,978
208
29
null
2021-11-22T12:23:50
2021-11-20T21:52:59
C
UTF-8
C
false
false
6,289
c
parameter_static.c
#include "ultra64.h" #include "z64.h" #include "macros.h" #include "parameter_static.h" u64 gHUDHeartEmptyTex[] = { #include "assets/textures/parameter_static/hud_heart_empty.ia8.inc.c" }; u64 gHUDHeartQuarterTex[] = { #include "assets/textures/parameter_static/hud_heart_quarter.ia8.inc.c" }; u64 gHUDHeartHalfTex[] = { #include "assets/textures/parameter_static/hud_heart_half.ia8.inc.c" }; u64 gHUDHeartThreeQuarterTex[] = { #include "assets/textures/parameter_static/hud_heart_three_quarter.ia8.inc.c" }; u64 gHUDHeartFullTex[] = { #include "assets/textures/parameter_static/hud_heart_full.ia8.inc.c" }; u64 gHUDDefenseHeartEmptyTex[] = { #include "assets/textures/parameter_static/hud_defense_heart_empty.ia8.inc.c" }; u64 gHUDDefenseHeartQuarterTex[] = { #include "assets/textures/parameter_static/hud_defense_heart_quarter.ia8.inc.c" }; u64 gHUDDefenseHeartHalfTex[] = { #include "assets/textures/parameter_static/hud_defense_heart_half.ia8.inc.c" }; u64 gHUDDefenseHeartThreeQuarterTex[] = { #include "assets/textures/parameter_static/hud_defense_heart_three_quarter.ia8.inc.c" }; u64 gHUDDefenseHeartFullTex[] = { #include "assets/textures/parameter_static/hud_defense_heart_full.ia8.inc.c" }; u64 gHUDActionButtonTex[] = { #include "assets/textures/parameter_static/hud_action_button.ia8.inc.c" }; u64 gHUDEmptyMapTex[] = { #include "assets/textures/parameter_static/hud_empty_map.ia8.inc.c" }; u64 gHUDCButtonLeftArrowTex[] = { #include "assets/textures/parameter_static/hud_c_button_left_arrow.ia8.inc.c" }; u64 gHUDCButtonDownArrowTex[] = { #include "assets/textures/parameter_static/hud_c_button_down_arrow.ia8.inc.c" }; u64 gHUDCButtonRightArrowTex[] = { #include "assets/textures/parameter_static/hud_c_button_right_arrow.ia8.inc.c" }; u64 gHUDSmallKeyCounterTex[] = { #include "assets/textures/parameter_static/hud_small_key_counter.ia8.inc.c" }; u64 gHUDRupeeCounterTex[] = { #include "assets/textures/parameter_static/hud_rupee_counter.ia8.inc.c" }; u64 gHUDTimerClockTex[] = { #include "assets/textures/parameter_static/hud_timer_clock.ia8.inc.c" }; u64 gHUDCarrotTex[] = { #include "assets/textures/parameter_static/hud_carrot.rgba32.inc.c" }; u64 gHUDExitMarkerTex[] = { #include "assets/textures/parameter_static/hud_exit_marker.rgb5a1.inc.c" }; u64 gHUDTreasureMarkerTex[] = { #include "assets/textures/parameter_static/hud_treasure_marker.rgb5a1.inc.c" }; u64 gHUDArrowMinigameScore[] = { #include "assets/textures/parameter_static/hud_arrow_minigame_score.rgb5a1.inc.c" }; u64 gHUDBossMarkerTex[] = { #include "assets/textures/parameter_static/hud_boss_marker.ia8.inc.c" }; u64 gHUDButtonATex[] = { #include "assets/textures/parameter_static/hud_button_a.ia8.inc.c" }; u64 gHUDButtonCDownTex[] = { #include "assets/textures/parameter_static/hud_button_c_down.ia8.inc.c" }; u64 gHUDButtonCRightTex[] = { #include "assets/textures/parameter_static/hud_button_c_right.ia8.inc.c" }; u64 gHUDButtonCLeftTex[] = { #include "assets/textures/parameter_static/hud_button_c_left.ia8.inc.c" }; u64 gHUDButtonCUpTex[] = { #include "assets/textures/parameter_static/hud_button_c_up.ia8.inc.c" }; u64 gHUDTrebleClefTex[] = { #include "assets/textures/parameter_static/hud_treble_clef.i4.inc.c" }; u64 gHUDNaviJPTex[] = { #include "assets/textures/parameter_static/hud_navi_jp.ia4.inc.c" }; u64 gHUDNaviENGTex[] = { #include "assets/textures/parameter_static/hud_navi_eng.ia4.inc.c" }; u64 gHUDCounterDigit0Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_0.i8.inc.c" }; u64 gHUDCounterDigit1Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_1.i8.inc.c" }; u64 gHUDCounterDigit2Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_2.i8.inc.c" }; u64 gHUDCounterDigit3Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_3.i8.inc.c" }; u64 gHUDCounterDigit4Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_4.i8.inc.c" }; u64 gHUDCounterDigit5Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_5.i8.inc.c" }; u64 gHUDCounterDigit6Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_6.i8.inc.c" }; u64 gHUDCounterDigit7Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_7.i8.inc.c" }; u64 gHUDCounterDigit8Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_8.i8.inc.c" }; u64 gHUDCounterDigit9Tex[] = { #include "assets/textures/parameter_static/hud_counter_digit_9.i8.inc.c" }; u64 gHUDCounterColonTex[] = { #include "assets/textures/parameter_static/hud_counter_colon.i8.inc.c" }; u64 gHUDAmmo0Tex[] = { #include "assets/textures/parameter_static/hud_ammo_0.ia8.inc.c" }; u64 gHUDAmmo1Tex[] = { #include "assets/textures/parameter_static/hud_ammo_1.ia8.inc.c" }; u64 gHUDAmmo2Tex[] = { #include "assets/textures/parameter_static/hud_ammo_2.ia8.inc.c" }; u64 gHUDAmmo3Tex[] = { #include "assets/textures/parameter_static/hud_ammo_3.ia8.inc.c" }; u64 gHUDAmmo4Tex[] = { #include "assets/textures/parameter_static/hud_ammo_4.ia8.inc.c" }; u64 gHUDAmmo5Tex[] = { #include "assets/textures/parameter_static/hud_ammo_5.ia8.inc.c" }; u64 gHUDAmmo6Tex[] = { #include "assets/textures/parameter_static/hud_ammo_6.ia8.inc.c" }; u64 gHUDAmmo7Tex[] = { #include "assets/textures/parameter_static/hud_ammo_7.ia8.inc.c" }; u64 gHUDAmmo8Tex[] = { #include "assets/textures/parameter_static/hud_ammo_8.ia8.inc.c" }; u64 gHUDAmmo9Tex[] = { #include "assets/textures/parameter_static/hud_ammo_9.ia8.inc.c" }; u64 gHUDUnusedAmmoHalf[] = { #include "assets/textures/parameter_static/hud_unused_ammo_half.ia8.inc.c" }; u64 gHUDMagicBarEndTex[] = { #include "assets/textures/parameter_static/hud_magic_bar_end.ia8.inc.c" }; u64 gHUDMagicBarMidTex[] = { #include "assets/textures/parameter_static/hud_magic_bar_mid.ia8.inc.c" }; u64 gHUDMagicBarFillTex[] = { #include "assets/textures/parameter_static/hud_magic_bar_fill.ia8.inc.c" }; u64 gHUDTreasureMarkerOpenedTex[] = { #include "assets/textures/parameter_static/hud_treasure_marker_opened.ia8.inc.c" }; // 32x item icons u64 g32MapIconTex[] = { #include "assets/textures/parameter_static/map32.rgba32.inc.c" }; u64 g32CompassIconTex[] = { #include "assets/textures/parameter_static/compass32.rgba32.inc.c" };
44e365e9e123fd4b2eb97b507eebc50d63a23001
92b1f79b49b5c37ba82172febfeb577dc2ca7130
/src/ui/gpaste-ui-delete-item.c
0f83dfc871fa2911b77162a8e6dc221504e17de2
[ "BSD-2-Clause" ]
permissive
Keruspe/GPaste
67ce4080fe09b7d3ae716641f6611fd4272c02ce
734286a8bd76d3a76a9d5f2f1651b8be36be17f9
refs/heads/master
2023-09-03T00:18:06.425352
2023-08-29T11:31:09
2023-08-30T11:56:25
1,268,515
699
77
BSD-2-Clause
2023-05-10T12:44:04
2011-01-18T20:42:57
C
UTF-8
C
false
false
1,301
c
gpaste-ui-delete-item.c
/* * This file is part of GPaste. * * Copyright (c) 2010-2018, Marc-Antoine Perennou <Marc-Antoine@Perennou.com> */ #include <gpaste-ui-delete-item.h> struct _GPasteUiDeleteItem { GPasteUiItemAction parent_instance; }; G_PASTE_DEFINE_TYPE (UiDeleteItem, ui_delete_item, G_PASTE_TYPE_UI_ITEM_ACTION) static void g_paste_ui_delete_item_activate (GPasteUiItemAction *self G_GNUC_UNUSED, GPasteClient *client, const gchar *uuid) { g_paste_client_delete (client, uuid, NULL, NULL); } static void g_paste_ui_delete_item_class_init (GPasteUiDeleteItemClass *klass) { G_PASTE_UI_ITEM_ACTION_CLASS (klass)->activate = g_paste_ui_delete_item_activate; } static void g_paste_ui_delete_item_init (GPasteUiDeleteItem *self G_GNUC_UNUSED) { } /** * g_paste_ui_delete_item_new: * @client: a #GPasteClient * * Create a new instance of #GPasteUiDeleteItem * * Returns: a newly allocated #GPasteUiDeleteItem * free it with g_object_unref */ G_PASTE_VISIBLE GtkWidget * g_paste_ui_delete_item_new (GPasteClient *client) { g_return_val_if_fail (_G_PASTE_IS_CLIENT (client), NULL); return g_paste_ui_item_action_new (G_PASTE_TYPE_UI_DELETE_ITEM, client, "edit-delete-symbolic", _("Delete")); }
fd9367fa5c7897a64e4c0cc512bdb217d1cbee5d
9ceacf33fd96913cac7ef15492c126d96cae6911
/regress/lib/libc/sleep/sleep_test.c
4c7764375dde35282b560e15f71c891ea1a73a52
[]
no_license
openbsd/src
ab97ef834fd2d5a7f6729814665e9782b586c130
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
refs/heads/master
2023-09-02T18:54:56.624627
2023-09-02T15:16:12
2023-09-02T15:16:12
66,966,208
3,394
1,235
null
2023-08-08T02:42:25
2016-08-30T18:18:25
C
UTF-8
C
false
false
2,316
c
sleep_test.c
/* $OpenBSD: sleep_test.c,v 1.2 2015/10/18 23:27:43 guenther Exp $ */ /* * Copyright (c) 2009 Philip Guenther * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Test whether sleep returns the correct value */ #include <sys/types.h> #include <err.h> #include <errno.h> #include <limits.h> #include <signal.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static void handler(int sig) { return; } static void * garbage(void) { char buf[20]; strlcpy(buf, "012354678901235467890123546789", sizeof buf); return buf; } int main(int argc, char *argv[]) { struct sigaction sa; char const *errstr; int i; if (argc != 2) return (1); errno = 0; i = strtonum(argv[1], 0, INT_MAX, &errstr); if (i == 0 && errno != 0) { fprintf(stderr, "%s\n", errstr); return (1); } memset(&sa, 0, sizeof sa); sa.sa_handler = &handler; if (sigaction(SIGTERM, &sa, NULL)) err(3, "sigaction"); garbage(); printf("%d\n", sleep(i)); return (0); }
c5240b3c1ac993f4ce328bca309ccd2de0f64c95
cb6d0a660cfcb28ee9e8a1c0266925f8f541edfb
/libbpf-tools/gethostlatency.bpf.c
92e0118e712affefa17833484c06f519a43bf503
[ "Apache-2.0" ]
permissive
iovisor/bcc
0e002769364523caeb731216021b0a3c881a723f
ec49363e2e9daec026ee6cae4c5fc316f8fab0ff
refs/heads/master
2023-09-03T22:37:47.238198
2023-08-31T14:44:55
2023-09-01T11:21:30
34,921,116
18,467
3,907
Apache-2.0
2023-09-13T21:22:53
2015-05-01T19:52:32
C
UTF-8
C
false
false
1,750
c
gethostlatency.bpf.c
/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2021 Hengqi Chen */ #include <vmlinux.h> #include <bpf/bpf_helpers.h> #include <bpf/bpf_core_read.h> #include <bpf/bpf_tracing.h> #include "gethostlatency.h" #define MAX_ENTRIES 10240 const volatile pid_t target_pid = 0; struct { __uint(type, BPF_MAP_TYPE_HASH); __uint(max_entries, MAX_ENTRIES); __type(key, __u32); __type(value, struct event); } starts SEC(".maps"); struct { __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); __uint(key_size, sizeof(__u32)); __uint(value_size, sizeof(__u32)); } events SEC(".maps"); static int probe_entry(struct pt_regs *ctx) { if (!PT_REGS_PARM1(ctx)) return 0; __u64 pid_tgid = bpf_get_current_pid_tgid(); __u32 pid = pid_tgid >> 32; __u32 tid = (__u32)pid_tgid; struct event event = {}; if (target_pid && target_pid != pid) return 0; event.time = bpf_ktime_get_ns(); event.pid = pid; bpf_get_current_comm(&event.comm, sizeof(event.comm)); bpf_probe_read_user(&event.host, sizeof(event.host), (void *)PT_REGS_PARM1(ctx)); bpf_map_update_elem(&starts, &tid, &event, BPF_ANY); return 0; } static int probe_return(struct pt_regs *ctx) { __u32 tid = (__u32)bpf_get_current_pid_tgid(); struct event *eventp; eventp = bpf_map_lookup_elem(&starts, &tid); if (!eventp) return 0; /* update time from timestamp to delta */ eventp->time = bpf_ktime_get_ns() - eventp->time; bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, eventp, sizeof(*eventp)); bpf_map_delete_elem(&starts, &tid); return 0; } SEC("kprobe/handle_entry") int BPF_KPROBE(handle_entry) { return probe_entry(ctx); } SEC("kretprobe/handle_return") int BPF_KRETPROBE(handle_return) { return probe_return(ctx); } char LICENSE[] SEC("license") = "GPL";
35a0a879f08a0faa990bf5d90f529fbe49c72ce0
7744859512f027ef0da8b1bde0f8518e631b98eb
/soh/assets/scenes/misc/hakaana2/hakaana2_room_0.h
49607893abb5ebffaffc4fcbceefc55c8a409bbb
[]
no_license
HarbourMasters/Shipwright
7f70b9470e4f9a117f3fe2d6e4deb776b8742182
0e7c6585239c0d7ea2c039b8b8cb7eaedf8928a9
refs/heads/develop
2023-08-31T20:50:56.253521
2023-08-30T17:34:06
2023-08-30T17:34:06
472,575,717
2,104
459
null
2023-09-14T20:29:01
2022-03-22T01:42:52
C
UTF-8
C
false
false
416
h
hakaana2_room_0.h
#pragma once #include "align_asset_macro.h" #define dhakaana2_room_0DL_005DD8 "__OTR__scenes/nonmq/hakaana2_scene/hakaana2_room_0DL_005DD8" static const ALIGN_ASSET(2) char hakaana2_room_0DL_005DD8[] = dhakaana2_room_0DL_005DD8; #define dhakaana2_room_0DL_0067F8 "__OTR__scenes/nonmq/hakaana2_scene/hakaana2_room_0DL_0067F8" static const ALIGN_ASSET(2) char hakaana2_room_0DL_0067F8[] = dhakaana2_room_0DL_0067F8;
9434d97263d38e78243b3bb04af7971e65348b8e
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/ti/c28x/libraries/tms320f28379d/headers/include/F2837xD_mcbsp.h
0f94e760303aa881ac7b2426858725025ce57077
[ "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
14,321
h
F2837xD_mcbsp.h
//########################################################################### // // FILE: F2837xD_mcbsp.h // // TITLE: MCBSP 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_MCBSP_H__ #define __F2837xD_MCBSP_H__ #ifdef __cplusplus extern "C" { #endif //--------------------------------------------------------------------------- // MCBSP Individual Register Bit Definitions: struct DRR2_BITS { // bits description Uint16 HWLB:8; // 7:0 High word low byte Uint16 HWHB:8; // 15:8 High word high byte }; union DRR2_REG { Uint16 all; struct DRR2_BITS bit; }; struct DRR1_BITS { // bits description Uint16 LWLB:8; // 7:0 Low word low byte Uint16 LWHB:8; // 15:8 Low word high byte }; union DRR1_REG { Uint16 all; struct DRR1_BITS bit; }; struct DXR2_BITS { // bits description Uint16 HWLB:8; // 7:0 High word low byte Uint16 HWHB:8; // 15:8 High word high byte }; union DXR2_REG { Uint16 all; struct DXR2_BITS bit; }; struct DXR1_BITS { // bits description Uint16 LWLB:8; // 7:0 Low word low byte Uint16 LWHB:8; // 15:8 Low word high byte }; union DXR1_REG { Uint16 all; struct DXR1_BITS bit; }; struct SPCR2_BITS { // bits description Uint16 XRST:1; // 0 Transmitter reset Uint16 XRDY:1; // 1 Transmitter ready Uint16 XEMPTY:1; // 2 Transmitter empty Uint16 XSYNCERR:1; // 3 Transmit sync error INT flag Uint16 XINTM:2; // 5:4 Transmit Interupt mode bits Uint16 GRST:1; // 6 Sample rate generator reset Uint16 FRST:1; // 7 Frame sync logic reset Uint16 SOFT:1; // 8 SOFT bit Uint16 FREE:1; // 9 FREE bit Uint16 rsvd1:6; // 15:10 Reserved }; union SPCR2_REG { Uint16 all; struct SPCR2_BITS bit; }; struct SPCR1_BITS { // bits description Uint16 RRST:1; // 0 Receiver reset Uint16 RRDY:1; // 1 Receiver ready Uint16 RFULL:1; // 2 Receiver full Uint16 RSYNCERR:1; // 3 Receive sync error INT flag Uint16 RINTM:2; // 5:4 Receive Interupt mode bits Uint16 rsvd1:1; // 6 Reserved Uint16 DXENA:1; // 7 DX delay enable Uint16 rsvd2:3; // 10:8 Reserved Uint16 CLKSTP:2; // 12:11 Clock stop mode Uint16 RJUST:2; // 14:13 Rx sign extension and justification mode Uint16 DLB:1; // 15 Digital loopback }; union SPCR1_REG { Uint16 all; struct SPCR1_BITS bit; }; struct RCR2_BITS { // bits description Uint16 RDATDLY:2; // 1:0 Receive data delay Uint16 RFIG:1; // 2 Receive frame sync ignore Uint16 RCOMPAND:2; // 4:3 Receive Companding Mode selects Uint16 RWDLEN2:3; // 7:5 Receive word length 2 Uint16 RFRLEN2:7; // 14:8 Receive Frame length 2 Uint16 RPHASE:1; // 15 Receive Phase }; union RCR2_REG { Uint16 all; struct RCR2_BITS bit; }; struct RCR1_BITS { // bits description Uint16 rsvd1:5; // 4:0 Reserved Uint16 RWDLEN1:3; // 7:5 Receive word length 1 Uint16 RFRLEN1:7; // 14:8 Receive Frame length 1 Uint16 rsvd2:1; // 15 Reserved }; union RCR1_REG { Uint16 all; struct RCR1_BITS bit; }; struct XCR2_BITS { // bits description Uint16 XDATDLY:2; // 1:0 Transmit data delay Uint16 XFIG:1; // 2 Transmit frame sync ignore Uint16 XCOMPAND:2; // 4:3 Transmit Companding Mode selects Uint16 XWDLEN2:3; // 7:5 Transmit word length 2 Uint16 XFRLEN2:7; // 14:8 Transmit Frame length 2 Uint16 XPHASE:1; // 15 Transmit Phase }; union XCR2_REG { Uint16 all; struct XCR2_BITS bit; }; struct XCR1_BITS { // bits description Uint16 rsvd1:5; // 4:0 Reserved Uint16 XWDLEN1:3; // 7:5 Transmit word length 1 Uint16 XFRLEN1:7; // 14:8 Transmit Frame length 1 Uint16 rsvd2:1; // 15 Reserved }; union XCR1_REG { Uint16 all; struct XCR1_BITS bit; }; struct SRGR2_BITS { // bits description Uint16 FPER:12; // 11:0 Frame-sync period Uint16 FSGM:1; // 12 Frame sync generator mode Uint16 CLKSM:1; // 13 Sample rate generator mode Uint16 rsvd1:1; // 14 Reserved Uint16 GSYNC:1; // 15 CLKG sync }; union SRGR2_REG { Uint16 all; struct SRGR2_BITS bit; }; struct SRGR1_BITS { // bits description Uint16 CLKGDV:8; // 7:0 CLKG divider Uint16 FWID:8; // 15:8 Frame width }; union SRGR1_REG { Uint16 all; struct SRGR1_BITS bit; }; struct MCR2_BITS { // bits description Uint16 XMCM:2; // 1:0 Transmit data delay Uint16 XCBLK:3; // 4:2 Transmit frame sync ignore Uint16 XPABLK:2; // 6:5 Transmit Companding Mode selects Uint16 XPBBLK:2; // 8:7 Transmit word length 2 Uint16 XMCME:1; // 9 Transmit Frame length 2 Uint16 rsvd1:6; // 15:10 Reserved }; union MCR2_REG { Uint16 all; struct MCR2_BITS bit; }; struct MCR1_BITS { // bits description Uint16 RMCM:1; // 0 Receive multichannel mode Uint16 rsvd1:1; // 1 Reserved Uint16 RCBLK:3; // 4:2 eceive current block Uint16 RPABLK:2; // 6:5 Receive partition A Block Uint16 RPBBLK:2; // 8:7 Receive partition B Block Uint16 RMCME:1; // 9 Receive multi-channel enhance mode Uint16 rsvd2:6; // 15:10 Reserved }; union MCR1_REG { Uint16 all; struct MCR1_BITS bit; }; struct PCR_BITS { // bits description Uint16 CLKRP:1; // 0 Receive Clock polarity Uint16 CLKXP:1; // 1 Transmit clock polarity Uint16 FSRP:1; // 2 Receive Frame synchronization polarity Uint16 FSXP:1; // 3 Transmit Frame synchronization polarity Uint16 rsvd1:1; // 4 Reserved Uint16 rsvd2:1; // 5 Reserved Uint16 rsvd3:1; // 6 Reserved Uint16 SCLKME:1; // 7 Sample clock mode selection Uint16 CLKRM:1; // 8 Receiver Clock Mode Uint16 CLKXM:1; // 9 Transmit Clock Mode. Uint16 FSRM:1; // 10 Receive Frame Synchronization Mode Uint16 FSXM:1; // 11 Transmit Frame Synchronization Mode Uint16 rsvd4:4; // 15:12 Reserved }; union PCR_REG { Uint16 all; struct PCR_BITS bit; }; struct MFFINT_BITS { // bits description Uint16 XINT:1; // 0 Enable for Receive Interrupt Uint16 rsvd1:1; // 1 Reserved Uint16 RINT:1; // 2 Enable for transmit Interrupt Uint16 rsvd2:13; // 15:3 Reserved }; union MFFINT_REG { Uint16 all; struct MFFINT_BITS bit; }; struct McBSP_REGS { union DRR2_REG DRR2; // Data receive register bits 31-16 union DRR1_REG DRR1; // Data receive register bits 15-0 union DXR2_REG DXR2; // Data transmit register bits 31-16 union DXR1_REG DXR1; // Data transmit register bits 15-0 union SPCR2_REG SPCR2; // Control register 2 union SPCR1_REG SPCR1; // Control register 1 union RCR2_REG RCR2; // Receive Control register 2 union RCR1_REG RCR1; // Receive Control register 1 union XCR2_REG XCR2; // Transmit Control register 2 union XCR1_REG XCR1; // Transmit Control register 1 union SRGR2_REG SRGR2; // Sample rate generator register 2 union SRGR1_REG SRGR1; // Sample rate generator register 1 union MCR2_REG MCR2; // Multi-channel register 2 union MCR1_REG MCR1; // Multi-channel register 1 Uint16 RCERA; // Receive channel enable partition A Uint16 RCERB; // Receive channel enable partition B Uint16 XCERA; // Transmit channel enable partition A Uint16 XCERB; // Transmit channel enable partition B union PCR_REG PCR; // Pin Control register Uint16 RCERC; // Receive channel enable partition C Uint16 RCERD; // Receive channel enable partition D Uint16 XCERC; // Transmit channel enable partition C Uint16 XCERD; // Transmit channel enable partition D Uint16 RCERE; // Receive channel enable partition E Uint16 RCERF; // Receive channel enable partition F Uint16 XCERE; // Transmit channel enable partition E Uint16 XCERF; // Transmit channel enable partition F Uint16 RCERG; // Receive channel enable partition G Uint16 RCERH; // Receive channel enable partition H Uint16 XCERG; // Transmit channel enable partition G Uint16 XCERH; // Transmit channel enable partition H Uint16 rsvd1[4]; // Reserved union MFFINT_REG MFFINT; // Interrupt enable }; //--------------------------------------------------------------------------- // MCBSP External References & Function Declarations: // #ifdef CPU1 extern volatile struct McBSP_REGS McbspaRegs; extern volatile struct McBSP_REGS McbspbRegs; #endif #ifdef CPU2 extern volatile struct McBSP_REGS McbspaRegs; extern volatile struct McBSP_REGS McbspbRegs; #endif #ifdef __cplusplus } #endif /* extern "C" */ #endif //=========================================================================== // End of file. //===========================================================================
6973572ba92295561a28fb27cdf3f1321add78a4
0744dcc5394cebf57ebcba343747af6871b67017
/os/board/rtl8730e/src/component/ui/LVGL/lvgl/src/extra/widgets/lv_widgets.h
114181022cdf6afa0c2dfb769423bf37aa9d1ba0
[ "Apache-2.0", "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
1,124
h
lv_widgets.h
/** * @file lv_widgets.h * */ #ifndef LV_WIDGETS_H #define LV_WIDGETS_H #ifdef __cplusplus extern "C" { #endif /********************* * INCLUDES *********************/ #include "animimg/lv_animimg.h" #include "calendar/lv_calendar.h" #include "calendar/lv_calendar_header_arrow.h" #include "calendar/lv_calendar_header_dropdown.h" #include "chart/lv_chart.h" #include "keyboard/lv_keyboard.h" #include "list/lv_list.h" #include "menu/lv_menu.h" #include "msgbox/lv_msgbox.h" #include "meter/lv_meter.h" #include "spinbox/lv_spinbox.h" #include "spinner/lv_spinner.h" #include "tabview/lv_tabview.h" #include "tileview/lv_tileview.h" #include "win/lv_win.h" #include "colorwheel/lv_colorwheel.h" #include "led/lv_led.h" #include "imgbtn/lv_imgbtn.h" #include "span/lv_span.h" /********************* * DEFINES *********************/ /********************** * TYPEDEFS **********************/ /********************** * GLOBAL PROTOTYPES **********************/ /********************** * MACROS **********************/ #ifdef __cplusplus } /*extern "C"*/ #endif #endif /*LV_WIDGETS_H*/
3f42e1fcda159c0132a539f22fa3ea21c2842145
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/dma/ste_dma40.c
ca78044df4b597537ec5ac6dc153b113b6247c9c
[ "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
96,024
c
ste_dma40.c
/* * Copyright (C) Ericsson AB 2007-2008 * Copyright (C) ST-Ericsson SA 2008-2010 * Author: Per Forlin <per.forlin@stericsson.com> for ST-Ericsson * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson * License terms: GNU General Public License (GPL) version 2 */ #include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/export.h> #include <linux/dmaengine.h> #include <linux/platform_device.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/pm.h> #include <linux/pm_runtime.h> #include <linux/err.h> #include <linux/amba/bus.h> #include <linux/regulator/consumer.h> #include <linux/platform_data/dma-ste-dma40.h> #include "dmaengine.h" #include "ste_dma40_ll.h" #define D40_NAME "dma40" #define D40_PHY_CHAN -1 /* For masking out/in 2 bit channel positions */ #define D40_CHAN_POS(chan) (2 * (chan / 2)) #define D40_CHAN_POS_MASK(chan) (0x3 << D40_CHAN_POS(chan)) /* Maximum iterations taken before giving up suspending a channel */ #define D40_SUSPEND_MAX_IT 500 /* Milliseconds */ #define DMA40_AUTOSUSPEND_DELAY 100 /* Hardware requirement on LCLA alignment */ #define LCLA_ALIGNMENT 0x40000 /* Max number of links per event group */ #define D40_LCLA_LINK_PER_EVENT_GRP 128 #define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP /* Attempts before giving up to trying to get pages that are aligned */ #define MAX_LCLA_ALLOC_ATTEMPTS 256 /* Bit markings for allocation map */ #define D40_ALLOC_FREE (1 << 31) #define D40_ALLOC_PHY (1 << 30) #define D40_ALLOC_LOG_FREE 0 #define MAX(a, b) (((a) < (b)) ? (b) : (a)) /** * enum 40_command - The different commands and/or statuses. * * @D40_DMA_STOP: DMA channel command STOP or status STOPPED, * @D40_DMA_RUN: The DMA channel is RUNNING of the command RUN. * @D40_DMA_SUSPEND_REQ: Request the DMA to SUSPEND as soon as possible. * @D40_DMA_SUSPENDED: The DMA channel is SUSPENDED. */ enum d40_command { D40_DMA_STOP = 0, D40_DMA_RUN = 1, D40_DMA_SUSPEND_REQ = 2, D40_DMA_SUSPENDED = 3 }; /* * enum d40_events - The different Event Enables for the event lines. * * @D40_DEACTIVATE_EVENTLINE: De-activate Event line, stopping the logical chan. * @D40_ACTIVATE_EVENTLINE: Activate the Event line, to start a logical chan. * @D40_SUSPEND_REQ_EVENTLINE: Requesting for suspending a event line. * @D40_ROUND_EVENTLINE: Status check for event line. */ enum d40_events { D40_DEACTIVATE_EVENTLINE = 0, D40_ACTIVATE_EVENTLINE = 1, D40_SUSPEND_REQ_EVENTLINE = 2, D40_ROUND_EVENTLINE = 3 }; /* * These are the registers that has to be saved and later restored * when the DMA hw is powered off. * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works. */ static u32 d40_backup_regs[] = { D40_DREG_LCPA, D40_DREG_LCLA, D40_DREG_PRMSE, D40_DREG_PRMSO, D40_DREG_PRMOE, D40_DREG_PRMOO, }; #define BACKUP_REGS_SZ ARRAY_SIZE(d40_backup_regs) /* * since 9540 and 8540 has the same HW revision * use v4a for 9540 or ealier * use v4b for 8540 or later * HW revision: * DB8500ed has revision 0 * DB8500v1 has revision 2 * DB8500v2 has revision 3 * AP9540v1 has revision 4 * DB8540v1 has revision 4 * TODO: Check if all these registers have to be saved/restored on dma40 v4a */ static u32 d40_backup_regs_v4a[] = { D40_DREG_PSEG1, D40_DREG_PSEG2, D40_DREG_PSEG3, D40_DREG_PSEG4, D40_DREG_PCEG1, D40_DREG_PCEG2, D40_DREG_PCEG3, D40_DREG_PCEG4, D40_DREG_RSEG1, D40_DREG_RSEG2, D40_DREG_RSEG3, D40_DREG_RSEG4, D40_DREG_RCEG1, D40_DREG_RCEG2, D40_DREG_RCEG3, D40_DREG_RCEG4, }; #define BACKUP_REGS_SZ_V4A ARRAY_SIZE(d40_backup_regs_v4a) static u32 d40_backup_regs_v4b[] = { D40_DREG_CPSEG1, D40_DREG_CPSEG2, D40_DREG_CPSEG3, D40_DREG_CPSEG4, D40_DREG_CPSEG5, D40_DREG_CPCEG1, D40_DREG_CPCEG2, D40_DREG_CPCEG3, D40_DREG_CPCEG4, D40_DREG_CPCEG5, D40_DREG_CRSEG1, D40_DREG_CRSEG2, D40_DREG_CRSEG3, D40_DREG_CRSEG4, D40_DREG_CRSEG5, D40_DREG_CRCEG1, D40_DREG_CRCEG2, D40_DREG_CRCEG3, D40_DREG_CRCEG4, D40_DREG_CRCEG5, }; #define BACKUP_REGS_SZ_V4B ARRAY_SIZE(d40_backup_regs_v4b) static u32 d40_backup_regs_chan[] = { D40_CHAN_REG_SSCFG, D40_CHAN_REG_SSELT, D40_CHAN_REG_SSPTR, D40_CHAN_REG_SSLNK, D40_CHAN_REG_SDCFG, D40_CHAN_REG_SDELT, D40_CHAN_REG_SDPTR, D40_CHAN_REG_SDLNK, }; /** * struct d40_interrupt_lookup - lookup table for interrupt handler * * @src: Interrupt mask register. * @clr: Interrupt clear register. * @is_error: true if this is an error interrupt. * @offset: start delta in the lookup_log_chans in d40_base. If equals to * D40_PHY_CHAN, the lookup_phy_chans shall be used instead. */ struct d40_interrupt_lookup { u32 src; u32 clr; bool is_error; int offset; }; static struct d40_interrupt_lookup il_v4a[] = { {D40_DREG_LCTIS0, D40_DREG_LCICR0, false, 0}, {D40_DREG_LCTIS1, D40_DREG_LCICR1, false, 32}, {D40_DREG_LCTIS2, D40_DREG_LCICR2, false, 64}, {D40_DREG_LCTIS3, D40_DREG_LCICR3, false, 96}, {D40_DREG_LCEIS0, D40_DREG_LCICR0, true, 0}, {D40_DREG_LCEIS1, D40_DREG_LCICR1, true, 32}, {D40_DREG_LCEIS2, D40_DREG_LCICR2, true, 64}, {D40_DREG_LCEIS3, D40_DREG_LCICR3, true, 96}, {D40_DREG_PCTIS, D40_DREG_PCICR, false, D40_PHY_CHAN}, {D40_DREG_PCEIS, D40_DREG_PCICR, true, D40_PHY_CHAN}, }; static struct d40_interrupt_lookup il_v4b[] = { {D40_DREG_CLCTIS1, D40_DREG_CLCICR1, false, 0}, {D40_DREG_CLCTIS2, D40_DREG_CLCICR2, false, 32}, {D40_DREG_CLCTIS3, D40_DREG_CLCICR3, false, 64}, {D40_DREG_CLCTIS4, D40_DREG_CLCICR4, false, 96}, {D40_DREG_CLCTIS5, D40_DREG_CLCICR5, false, 128}, {D40_DREG_CLCEIS1, D40_DREG_CLCICR1, true, 0}, {D40_DREG_CLCEIS2, D40_DREG_CLCICR2, true, 32}, {D40_DREG_CLCEIS3, D40_DREG_CLCICR3, true, 64}, {D40_DREG_CLCEIS4, D40_DREG_CLCICR4, true, 96}, {D40_DREG_CLCEIS5, D40_DREG_CLCICR5, true, 128}, {D40_DREG_CPCTIS, D40_DREG_CPCICR, false, D40_PHY_CHAN}, {D40_DREG_CPCEIS, D40_DREG_CPCICR, true, D40_PHY_CHAN}, }; /** * struct d40_reg_val - simple lookup struct * * @reg: The register. * @val: The value that belongs to the register in reg. */ struct d40_reg_val { unsigned int reg; unsigned int val; }; static __initdata struct d40_reg_val dma_init_reg_v4a[] = { /* Clock every part of the DMA block from start */ { .reg = D40_DREG_GCC, .val = D40_DREG_GCC_ENABLE_ALL}, /* Interrupts on all logical channels */ { .reg = D40_DREG_LCMIS0, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCMIS1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCMIS2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCMIS3, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCICR0, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCICR1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCICR2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCICR3, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCTIS0, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCTIS1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCTIS2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_LCTIS3, .val = 0xFFFFFFFF} }; static __initdata struct d40_reg_val dma_init_reg_v4b[] = { /* Clock every part of the DMA block from start */ { .reg = D40_DREG_GCC, .val = D40_DREG_GCC_ENABLE_ALL}, /* Interrupts on all logical channels */ { .reg = D40_DREG_CLCMIS1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCMIS2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCMIS3, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCMIS4, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCMIS5, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCICR1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCICR2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCICR3, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCICR4, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCICR5, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCTIS1, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCTIS2, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCTIS3, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCTIS4, .val = 0xFFFFFFFF}, { .reg = D40_DREG_CLCTIS5, .val = 0xFFFFFFFF} }; /** * struct d40_lli_pool - Structure for keeping LLIs in memory * * @base: Pointer to memory area when the pre_alloc_lli's are not large * enough, IE bigger than the most common case, 1 dst and 1 src. NULL if * pre_alloc_lli is used. * @dma_addr: DMA address, if mapped * @size: The size in bytes of the memory at base or the size of pre_alloc_lli. * @pre_alloc_lli: Pre allocated area for the most common case of transfers, * one buffer to one buffer. */ struct d40_lli_pool { void *base; int size; dma_addr_t dma_addr; /* Space for dst and src, plus an extra for padding */ u8 pre_alloc_lli[3 * sizeof(struct d40_phy_lli)]; }; /** * struct d40_desc - A descriptor is one DMA job. * * @lli_phy: LLI settings for physical channel. Both src and dst= * points into the lli_pool, to base if lli_len > 1 or to pre_alloc_lli if * lli_len equals one. * @lli_log: Same as above but for logical channels. * @lli_pool: The pool with two entries pre-allocated. * @lli_len: Number of llis of current descriptor. * @lli_current: Number of transferred llis. * @lcla_alloc: Number of LCLA entries allocated. * @txd: DMA engine struct. Used for among other things for communication * during a transfer. * @node: List entry. * @is_in_client_list: true if the client owns this descriptor. * @cyclic: true if this is a cyclic job * * This descriptor is used for both logical and physical transfers. */ struct d40_desc { /* LLI physical */ struct d40_phy_lli_bidir lli_phy; /* LLI logical */ struct d40_log_lli_bidir lli_log; struct d40_lli_pool lli_pool; int lli_len; int lli_current; int lcla_alloc; struct dma_async_tx_descriptor txd; struct list_head node; bool is_in_client_list; bool cyclic; }; /** * struct d40_lcla_pool - LCLA pool settings and data. * * @base: The virtual address of LCLA. 18 bit aligned. * @base_unaligned: The orignal kmalloc pointer, if kmalloc is used. * This pointer is only there for clean-up on error. * @pages: The number of pages needed for all physical channels. * Only used later for clean-up on error * @lock: Lock to protect the content in this struct. * @alloc_map: big map over which LCLA entry is own by which job. */ struct d40_lcla_pool { void *base; dma_addr_t dma_addr; void *base_unaligned; int pages; spinlock_t lock; struct d40_desc **alloc_map; }; /** * struct d40_phy_res - struct for handling eventlines mapped to physical * channels. * * @lock: A lock protection this entity. * @reserved: True if used by secure world or otherwise. * @num: The physical channel number of this entity. * @allocated_src: Bit mapped to show which src event line's are mapped to * this physical channel. Can also be free or physically allocated. * @allocated_dst: Same as for src but is dst. * allocated_dst and allocated_src uses the D40_ALLOC* defines as well as * event line number. * @use_soft_lli: To mark if the linked lists of channel are managed by SW. */ struct d40_phy_res { spinlock_t lock; bool reserved; int num; u32 allocated_src; u32 allocated_dst; bool use_soft_lli; }; struct d40_base; /** * struct d40_chan - Struct that describes a channel. * * @lock: A spinlock to protect this struct. * @log_num: The logical number, if any of this channel. * @pending_tx: The number of pending transfers. Used between interrupt handler * and tasklet. * @busy: Set to true when transfer is ongoing on this channel. * @phy_chan: Pointer to physical channel which this instance runs on. If this * point is NULL, then the channel is not allocated. * @chan: DMA engine handle. * @tasklet: Tasklet that gets scheduled from interrupt context to complete a * transfer and call client callback. * @client: Cliented owned descriptor list. * @pending_queue: Submitted jobs, to be issued by issue_pending() * @active: Active descriptor. * @done: Completed jobs * @queue: Queued jobs. * @prepare_queue: Prepared jobs. * @dma_cfg: The client configuration of this dma channel. * @configured: whether the dma_cfg configuration is valid * @base: Pointer to the device instance struct. * @src_def_cfg: Default cfg register setting for src. * @dst_def_cfg: Default cfg register setting for dst. * @log_def: Default logical channel settings. * @lcpa: Pointer to dst and src lcpa settings. * @runtime_addr: runtime configured address. * @runtime_direction: runtime configured direction. * * This struct can either "be" a logical or a physical channel. */ struct d40_chan { spinlock_t lock; int log_num; int pending_tx; bool busy; struct d40_phy_res *phy_chan; struct dma_chan chan; struct tasklet_struct tasklet; struct list_head client; struct list_head pending_queue; struct list_head active; struct list_head done; struct list_head queue; struct list_head prepare_queue; struct stedma40_chan_cfg dma_cfg; bool configured; struct d40_base *base; /* Default register configurations */ u32 src_def_cfg; u32 dst_def_cfg; struct d40_def_lcsp log_def; struct d40_log_lli_full *lcpa; /* Runtime reconfiguration */ dma_addr_t runtime_addr; enum dma_transfer_direction runtime_direction; }; /** * struct d40_gen_dmac - generic values to represent u8500/u8540 DMA * controller * * @backup: the pointer to the registers address array for backup * @backup_size: the size of the registers address array for backup * @realtime_en: the realtime enable register * @realtime_clear: the realtime clear register * @high_prio_en: the high priority enable register * @high_prio_clear: the high priority clear register * @interrupt_en: the interrupt enable register * @interrupt_clear: the interrupt clear register * @il: the pointer to struct d40_interrupt_lookup * @il_size: the size of d40_interrupt_lookup array * @init_reg: the pointer to the struct d40_reg_val * @init_reg_size: the size of d40_reg_val array */ struct d40_gen_dmac { u32 *backup; u32 backup_size; u32 realtime_en; u32 realtime_clear; u32 high_prio_en; u32 high_prio_clear; u32 interrupt_en; u32 interrupt_clear; struct d40_interrupt_lookup *il; u32 il_size; struct d40_reg_val *init_reg; u32 init_reg_size; }; /** * struct d40_base - The big global struct, one for each probe'd instance. * * @interrupt_lock: Lock used to make sure one interrupt is handle a time. * @execmd_lock: Lock for execute command usage since several channels share * the same physical register. * @dev: The device structure. * @virtbase: The virtual base address of the DMA's register. * @rev: silicon revision detected. * @clk: Pointer to the DMA clock structure. * @phy_start: Physical memory start of the DMA registers. * @phy_size: Size of the DMA register map. * @irq: The IRQ number. * @num_phy_chans: The number of physical channels. Read from HW. This * is the number of available channels for this driver, not counting "Secure * mode" allocated physical channels. * @num_log_chans: The number of logical channels. Calculated from * num_phy_chans. * @dma_both: dma_device channels that can do both memcpy and slave transfers. * @dma_slave: dma_device channels that can do only do slave transfers. * @dma_memcpy: dma_device channels that can do only do memcpy transfers. * @phy_chans: Room for all possible physical channels in system. * @log_chans: Room for all possible logical channels in system. * @lookup_log_chans: Used to map interrupt number to logical channel. Points * to log_chans entries. * @lookup_phy_chans: Used to map interrupt number to physical channel. Points * to phy_chans entries. * @plat_data: Pointer to provided platform_data which is the driver * configuration. * @lcpa_regulator: Pointer to hold the regulator for the esram bank for lcla. * @phy_res: Vector containing all physical channels. * @lcla_pool: lcla pool settings and data. * @lcpa_base: The virtual mapped address of LCPA. * @phy_lcpa: The physical address of the LCPA. * @lcpa_size: The size of the LCPA area. * @desc_slab: cache for descriptors. * @reg_val_backup: Here the values of some hardware registers are stored * before the DMA is powered off. They are restored when the power is back on. * @reg_val_backup_v4: Backup of registers that only exits on dma40 v3 and * later * @reg_val_backup_chan: Backup data for standard channel parameter registers. * @gcc_pwr_off_mask: Mask to maintain the channels that can be turned off. * @initialized: true if the dma has been initialized * @gen_dmac: the struct for generic registers values to represent u8500/8540 * DMA controller */ struct d40_base { spinlock_t interrupt_lock; spinlock_t execmd_lock; struct device *dev; void __iomem *virtbase; u8 rev:4; struct clk *clk; phys_addr_t phy_start; resource_size_t phy_size; int irq; int num_phy_chans; int num_log_chans; struct device_dma_parameters dma_parms; struct dma_device dma_both; struct dma_device dma_slave; struct dma_device dma_memcpy; struct d40_chan *phy_chans; struct d40_chan *log_chans; struct d40_chan **lookup_log_chans; struct d40_chan **lookup_phy_chans; struct stedma40_platform_data *plat_data; struct regulator *lcpa_regulator; /* Physical half channels */ struct d40_phy_res *phy_res; struct d40_lcla_pool lcla_pool; void *lcpa_base; dma_addr_t phy_lcpa; resource_size_t lcpa_size; struct kmem_cache *desc_slab; u32 reg_val_backup[BACKUP_REGS_SZ]; u32 reg_val_backup_v4[MAX(BACKUP_REGS_SZ_V4A, BACKUP_REGS_SZ_V4B)]; u32 *reg_val_backup_chan; u16 gcc_pwr_off_mask; bool initialized; struct d40_gen_dmac gen_dmac; }; static struct device *chan2dev(struct d40_chan *d40c) { return &d40c->chan.dev->device; } static bool chan_is_physical(struct d40_chan *chan) { return chan->log_num == D40_PHY_CHAN; } static bool chan_is_logical(struct d40_chan *chan) { return !chan_is_physical(chan); } static void __iomem *chan_base(struct d40_chan *chan) { return chan->base->virtbase + D40_DREG_PCBASE + chan->phy_chan->num * D40_DREG_PCDELTA; } #define d40_err(dev, format, arg...) \ dev_err(dev, "[%s] " format, __func__, ## arg) #define chan_err(d40c, format, arg...) \ d40_err(chan2dev(d40c), format, ## arg) static int d40_pool_lli_alloc(struct d40_chan *d40c, struct d40_desc *d40d, int lli_len) { bool is_log = chan_is_logical(d40c); u32 align; void *base; if (is_log) align = sizeof(struct d40_log_lli); else align = sizeof(struct d40_phy_lli); if (lli_len == 1) { base = d40d->lli_pool.pre_alloc_lli; d40d->lli_pool.size = sizeof(d40d->lli_pool.pre_alloc_lli); d40d->lli_pool.base = NULL; } else { d40d->lli_pool.size = lli_len * 2 * align; base = kmalloc(d40d->lli_pool.size + align, GFP_NOWAIT); d40d->lli_pool.base = base; if (d40d->lli_pool.base == NULL) return -ENOMEM; } if (is_log) { d40d->lli_log.src = PTR_ALIGN(base, align); d40d->lli_log.dst = d40d->lli_log.src + lli_len; d40d->lli_pool.dma_addr = 0; } else { d40d->lli_phy.src = PTR_ALIGN(base, align); d40d->lli_phy.dst = d40d->lli_phy.src + lli_len; d40d->lli_pool.dma_addr = dma_map_single(d40c->base->dev, d40d->lli_phy.src, d40d->lli_pool.size, DMA_TO_DEVICE); if (dma_mapping_error(d40c->base->dev, d40d->lli_pool.dma_addr)) { kfree(d40d->lli_pool.base); d40d->lli_pool.base = NULL; d40d->lli_pool.dma_addr = 0; return -ENOMEM; } } return 0; } static void d40_pool_lli_free(struct d40_chan *d40c, struct d40_desc *d40d) { if (d40d->lli_pool.dma_addr) dma_unmap_single(d40c->base->dev, d40d->lli_pool.dma_addr, d40d->lli_pool.size, DMA_TO_DEVICE); kfree(d40d->lli_pool.base); d40d->lli_pool.base = NULL; d40d->lli_pool.size = 0; d40d->lli_log.src = NULL; d40d->lli_log.dst = NULL; d40d->lli_phy.src = NULL; d40d->lli_phy.dst = NULL; } static int d40_lcla_alloc_one(struct d40_chan *d40c, struct d40_desc *d40d) { unsigned long flags; int i; int ret = -EINVAL; spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); /* * Allocate both src and dst at the same time, therefore the half * start on 1 since 0 can't be used since zero is used as end marker. */ for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { int idx = d40c->phy_chan->num * D40_LCLA_LINK_PER_EVENT_GRP + i; if (!d40c->base->lcla_pool.alloc_map[idx]) { d40c->base->lcla_pool.alloc_map[idx] = d40d; d40d->lcla_alloc++; ret = i; break; } } spin_unlock_irqrestore(&d40c->base->lcla_pool.lock, flags); return ret; } static int d40_lcla_free_all(struct d40_chan *d40c, struct d40_desc *d40d) { unsigned long flags; int i; int ret = -EINVAL; if (chan_is_physical(d40c)) return 0; spin_lock_irqsave(&d40c->base->lcla_pool.lock, flags); for (i = 1 ; i < D40_LCLA_LINK_PER_EVENT_GRP / 2; i++) { int idx = d40c->phy_chan->num * D40_LCLA_LINK_PER_EVENT_GRP + i; if (d40c->base->lcla_pool.alloc_map[idx] == d40d) { d40c->base->lcla_pool.alloc_map[idx] = NULL; d40d->lcla_alloc--; if (d40d->lcla_alloc == 0) { ret = 0; break; } } } spin_unlock_irqrestore(&d40c->base->lcla_pool.lock, flags); return ret; } static void d40_desc_remove(struct d40_desc *d40d) { list_del(&d40d->node); } static struct d40_desc *d40_desc_get(struct d40_chan *d40c) { struct d40_desc *desc = NULL; if (!list_empty(&d40c->client)) { struct d40_desc *d; struct d40_desc *_d; list_for_each_entry_safe(d, _d, &d40c->client, node) { if (async_tx_test_ack(&d->txd)) { d40_desc_remove(d); desc = d; memset(desc, 0, sizeof(*desc)); break; } } } if (!desc) desc = kmem_cache_zalloc(d40c->base->desc_slab, GFP_NOWAIT); if (desc) INIT_LIST_HEAD(&desc->node); return desc; } static void d40_desc_free(struct d40_chan *d40c, struct d40_desc *d40d) { d40_pool_lli_free(d40c, d40d); d40_lcla_free_all(d40c, d40d); kmem_cache_free(d40c->base->desc_slab, d40d); } static void d40_desc_submit(struct d40_chan *d40c, struct d40_desc *desc) { list_add_tail(&desc->node, &d40c->active); } static void d40_phy_lli_load(struct d40_chan *chan, struct d40_desc *desc) { struct d40_phy_lli *lli_dst = desc->lli_phy.dst; struct d40_phy_lli *lli_src = desc->lli_phy.src; void __iomem *base = chan_base(chan); writel(lli_src->reg_cfg, base + D40_CHAN_REG_SSCFG); writel(lli_src->reg_elt, base + D40_CHAN_REG_SSELT); writel(lli_src->reg_ptr, base + D40_CHAN_REG_SSPTR); writel(lli_src->reg_lnk, base + D40_CHAN_REG_SSLNK); writel(lli_dst->reg_cfg, base + D40_CHAN_REG_SDCFG); writel(lli_dst->reg_elt, base + D40_CHAN_REG_SDELT); writel(lli_dst->reg_ptr, base + D40_CHAN_REG_SDPTR); writel(lli_dst->reg_lnk, base + D40_CHAN_REG_SDLNK); } static void d40_desc_done(struct d40_chan *d40c, struct d40_desc *desc) { list_add_tail(&desc->node, &d40c->done); } static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc) { struct d40_lcla_pool *pool = &chan->base->lcla_pool; struct d40_log_lli_bidir *lli = &desc->lli_log; int lli_current = desc->lli_current; int lli_len = desc->lli_len; bool cyclic = desc->cyclic; int curr_lcla = -EINVAL; int first_lcla = 0; bool use_esram_lcla = chan->base->plat_data->use_esram_lcla; bool linkback; /* * We may have partially running cyclic transfers, in case we did't get * enough LCLA entries. */ linkback = cyclic && lli_current == 0; /* * For linkback, we need one LCLA even with only one link, because we * can't link back to the one in LCPA space */ if (linkback || (lli_len - lli_current > 1)) { /* * If the channel is expected to use only soft_lli don't * allocate a lcla. This is to avoid a HW issue that exists * in some controller during a peripheral to memory transfer * that uses linked lists. */ if (!(chan->phy_chan->use_soft_lli && chan->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM)) curr_lcla = d40_lcla_alloc_one(chan, desc); first_lcla = curr_lcla; } /* * For linkback, we normally load the LCPA in the loop since we need to * link it to the second LCLA and not the first. However, if we * couldn't even get a first LCLA, then we have to run in LCPA and * reload manually. */ if (!linkback || curr_lcla == -EINVAL) { unsigned int flags = 0; if (curr_lcla == -EINVAL) flags |= LLI_TERM_INT; d40_log_lli_lcpa_write(chan->lcpa, &lli->dst[lli_current], &lli->src[lli_current], curr_lcla, flags); lli_current++; } if (curr_lcla < 0) goto out; for (; lli_current < lli_len; lli_current++) { unsigned int lcla_offset = chan->phy_chan->num * 1024 + 8 * curr_lcla * 2; struct d40_log_lli *lcla = pool->base + lcla_offset; unsigned int flags = 0; int next_lcla; if (lli_current + 1 < lli_len) next_lcla = d40_lcla_alloc_one(chan, desc); else next_lcla = linkback ? first_lcla : -EINVAL; if (cyclic || next_lcla == -EINVAL) flags |= LLI_TERM_INT; if (linkback && curr_lcla == first_lcla) { /* First link goes in both LCPA and LCLA */ d40_log_lli_lcpa_write(chan->lcpa, &lli->dst[lli_current], &lli->src[lli_current], next_lcla, flags); } /* * One unused LCLA in the cyclic case if the very first * next_lcla fails... */ d40_log_lli_lcla_write(lcla, &lli->dst[lli_current], &lli->src[lli_current], next_lcla, flags); /* * Cache maintenance is not needed if lcla is * mapped in esram */ if (!use_esram_lcla) { dma_sync_single_range_for_device(chan->base->dev, pool->dma_addr, lcla_offset, 2 * sizeof(struct d40_log_lli), DMA_TO_DEVICE); } curr_lcla = next_lcla; if (curr_lcla == -EINVAL || curr_lcla == first_lcla) { lli_current++; break; } } out: desc->lli_current = lli_current; } static void d40_desc_load(struct d40_chan *d40c, struct d40_desc *d40d) { if (chan_is_physical(d40c)) { d40_phy_lli_load(d40c, d40d); d40d->lli_current = d40d->lli_len; } else d40_log_lli_to_lcxa(d40c, d40d); } static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) { struct d40_desc *d; if (list_empty(&d40c->active)) return NULL; d = list_first_entry(&d40c->active, struct d40_desc, node); return d; } /* remove desc from current queue and add it to the pending_queue */ static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc) { d40_desc_remove(desc); desc->is_in_client_list = false; list_add_tail(&desc->node, &d40c->pending_queue); } static struct d40_desc *d40_first_pending(struct d40_chan *d40c) { struct d40_desc *d; if (list_empty(&d40c->pending_queue)) return NULL; d = list_first_entry(&d40c->pending_queue, struct d40_desc, node); return d; } static struct d40_desc *d40_first_queued(struct d40_chan *d40c) { struct d40_desc *d; if (list_empty(&d40c->queue)) return NULL; d = list_first_entry(&d40c->queue, struct d40_desc, node); return d; } static struct d40_desc *d40_first_done(struct d40_chan *d40c) { if (list_empty(&d40c->done)) return NULL; return list_first_entry(&d40c->done, struct d40_desc, node); } static int d40_psize_2_burst_size(bool is_log, int psize) { if (is_log) { if (psize == STEDMA40_PSIZE_LOG_1) return 1; } else { if (psize == STEDMA40_PSIZE_PHY_1) return 1; } return 2 << psize; } /* * The dma only supports transmitting packages up to * STEDMA40_MAX_SEG_SIZE << data_width. Calculate the total number of * dma elements required to send the entire sg list */ static int d40_size_2_dmalen(int size, u32 data_width1, u32 data_width2) { int dmalen; u32 max_w = max(data_width1, data_width2); u32 min_w = min(data_width1, data_width2); u32 seg_max = ALIGN(STEDMA40_MAX_SEG_SIZE << min_w, 1 << max_w); if (seg_max > STEDMA40_MAX_SEG_SIZE) seg_max -= (1 << max_w); if (!IS_ALIGNED(size, 1 << max_w)) return -EINVAL; if (size <= seg_max) dmalen = 1; else { dmalen = size / seg_max; if (dmalen * seg_max < size) dmalen++; } return dmalen; } static int d40_sg_2_dmalen(struct scatterlist *sgl, int sg_len, u32 data_width1, u32 data_width2) { struct scatterlist *sg; int i; int len = 0; int ret; for_each_sg(sgl, sg, sg_len, i) { ret = d40_size_2_dmalen(sg_dma_len(sg), data_width1, data_width2); if (ret < 0) return ret; len += ret; } return len; } #ifdef CONFIG_PM static void dma40_backup(void __iomem *baseaddr, u32 *backup, u32 *regaddr, int num, bool save) { int i; for (i = 0; i < num; i++) { void __iomem *addr = baseaddr + regaddr[i]; if (save) backup[i] = readl_relaxed(addr); else writel_relaxed(backup[i], addr); } } static void d40_save_restore_registers(struct d40_base *base, bool save) { int i; /* Save/Restore channel specific registers */ for (i = 0; i < base->num_phy_chans; i++) { void __iomem *addr; int idx; if (base->phy_res[i].reserved) continue; addr = base->virtbase + D40_DREG_PCBASE + i * D40_DREG_PCDELTA; idx = i * ARRAY_SIZE(d40_backup_regs_chan); dma40_backup(addr, &base->reg_val_backup_chan[idx], d40_backup_regs_chan, ARRAY_SIZE(d40_backup_regs_chan), save); } /* Save/Restore global registers */ dma40_backup(base->virtbase, base->reg_val_backup, d40_backup_regs, ARRAY_SIZE(d40_backup_regs), save); /* Save/Restore registers only existing on dma40 v3 and later */ if (base->gen_dmac.backup) dma40_backup(base->virtbase, base->reg_val_backup_v4, base->gen_dmac.backup, base->gen_dmac.backup_size, save); } #else static void d40_save_restore_registers(struct d40_base *base, bool save) { } #endif static int __d40_execute_command_phy(struct d40_chan *d40c, enum d40_command command) { u32 status; int i; void __iomem *active_reg; int ret = 0; unsigned long flags; u32 wmask; if (command == D40_DMA_STOP) { ret = __d40_execute_command_phy(d40c, D40_DMA_SUSPEND_REQ); if (ret) return ret; } spin_lock_irqsave(&d40c->base->execmd_lock, flags); if (d40c->phy_chan->num % 2 == 0) active_reg = d40c->base->virtbase + D40_DREG_ACTIVE; else active_reg = d40c->base->virtbase + D40_DREG_ACTIVO; if (command == D40_DMA_SUSPEND_REQ) { status = (readl(active_reg) & D40_CHAN_POS_MASK(d40c->phy_chan->num)) >> D40_CHAN_POS(d40c->phy_chan->num); if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP) goto done; } wmask = 0xffffffff & ~(D40_CHAN_POS_MASK(d40c->phy_chan->num)); writel(wmask | (command << D40_CHAN_POS(d40c->phy_chan->num)), active_reg); if (command == D40_DMA_SUSPEND_REQ) { for (i = 0 ; i < D40_SUSPEND_MAX_IT; i++) { status = (readl(active_reg) & D40_CHAN_POS_MASK(d40c->phy_chan->num)) >> D40_CHAN_POS(d40c->phy_chan->num); cpu_relax(); /* * Reduce the number of bus accesses while * waiting for the DMA to suspend. */ udelay(3); if (status == D40_DMA_STOP || status == D40_DMA_SUSPENDED) break; } if (i == D40_SUSPEND_MAX_IT) { chan_err(d40c, "unable to suspend the chl %d (log: %d) status %x\n", d40c->phy_chan->num, d40c->log_num, status); dump_stack(); ret = -EBUSY; } } done: spin_unlock_irqrestore(&d40c->base->execmd_lock, flags); return ret; } static void d40_term_all(struct d40_chan *d40c) { struct d40_desc *d40d; struct d40_desc *_d; /* Release completed descriptors */ while ((d40d = d40_first_done(d40c))) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } /* Release active descriptors */ while ((d40d = d40_first_active_get(d40c))) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } /* Release queued descriptors waiting for transfer */ while ((d40d = d40_first_queued(d40c))) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } /* Release pending descriptors */ while ((d40d = d40_first_pending(d40c))) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } /* Release client owned descriptors */ if (!list_empty(&d40c->client)) list_for_each_entry_safe(d40d, _d, &d40c->client, node) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } /* Release descriptors in prepare queue */ if (!list_empty(&d40c->prepare_queue)) list_for_each_entry_safe(d40d, _d, &d40c->prepare_queue, node) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } d40c->pending_tx = 0; } static void __d40_config_set_event(struct d40_chan *d40c, enum d40_events event_type, u32 event, int reg) { void __iomem *addr = chan_base(d40c) + reg; int tries; u32 status; switch (event_type) { case D40_DEACTIVATE_EVENTLINE: writel((D40_DEACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event)) | ~D40_EVENTLINE_MASK(event), addr); break; case D40_SUSPEND_REQ_EVENTLINE: status = (readl(addr) & D40_EVENTLINE_MASK(event)) >> D40_EVENTLINE_POS(event); if (status == D40_DEACTIVATE_EVENTLINE || status == D40_SUSPEND_REQ_EVENTLINE) break; writel((D40_SUSPEND_REQ_EVENTLINE << D40_EVENTLINE_POS(event)) | ~D40_EVENTLINE_MASK(event), addr); for (tries = 0 ; tries < D40_SUSPEND_MAX_IT; tries++) { status = (readl(addr) & D40_EVENTLINE_MASK(event)) >> D40_EVENTLINE_POS(event); cpu_relax(); /* * Reduce the number of bus accesses while * waiting for the DMA to suspend. */ udelay(3); if (status == D40_DEACTIVATE_EVENTLINE) break; } if (tries == D40_SUSPEND_MAX_IT) { chan_err(d40c, "unable to stop the event_line chl %d (log: %d)" "status %x\n", d40c->phy_chan->num, d40c->log_num, status); } break; case D40_ACTIVATE_EVENTLINE: /* * The hardware sometimes doesn't register the enable when src and dst * event lines are active on the same logical channel. Retry to ensure * it does. Usually only one retry is sufficient. */ tries = 100; while (--tries) { writel((D40_ACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event)) | ~D40_EVENTLINE_MASK(event), addr); if (readl(addr) & D40_EVENTLINE_MASK(event)) break; } if (tries != 99) dev_dbg(chan2dev(d40c), "[%s] workaround enable S%cLNK (%d tries)\n", __func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D', 100 - tries); WARN_ON(!tries); break; case D40_ROUND_EVENTLINE: BUG(); break; } } static void d40_config_set_event(struct d40_chan *d40c, enum d40_events event_type) { /* Enable event line connected to device (or memcpy) */ if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) || (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) { u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type); __d40_config_set_event(d40c, event_type, event, D40_CHAN_REG_SSLNK); } if (d40c->dma_cfg.dir != STEDMA40_PERIPH_TO_MEM) { u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type); __d40_config_set_event(d40c, event_type, event, D40_CHAN_REG_SDLNK); } } static u32 d40_chan_has_events(struct d40_chan *d40c) { void __iomem *chanbase = chan_base(d40c); u32 val; val = readl(chanbase + D40_CHAN_REG_SSLNK); val |= readl(chanbase + D40_CHAN_REG_SDLNK); return val; } static int __d40_execute_command_log(struct d40_chan *d40c, enum d40_command command) { unsigned long flags; int ret = 0; u32 active_status; void __iomem *active_reg; if (d40c->phy_chan->num % 2 == 0) active_reg = d40c->base->virtbase + D40_DREG_ACTIVE; else active_reg = d40c->base->virtbase + D40_DREG_ACTIVO; spin_lock_irqsave(&d40c->phy_chan->lock, flags); switch (command) { case D40_DMA_STOP: case D40_DMA_SUSPEND_REQ: active_status = (readl(active_reg) & D40_CHAN_POS_MASK(d40c->phy_chan->num)) >> D40_CHAN_POS(d40c->phy_chan->num); if (active_status == D40_DMA_RUN) d40_config_set_event(d40c, D40_SUSPEND_REQ_EVENTLINE); else d40_config_set_event(d40c, D40_DEACTIVATE_EVENTLINE); if (!d40_chan_has_events(d40c) && (command == D40_DMA_STOP)) ret = __d40_execute_command_phy(d40c, command); break; case D40_DMA_RUN: d40_config_set_event(d40c, D40_ACTIVATE_EVENTLINE); ret = __d40_execute_command_phy(d40c, command); break; case D40_DMA_SUSPENDED: BUG(); break; } spin_unlock_irqrestore(&d40c->phy_chan->lock, flags); return ret; } static int d40_channel_execute_command(struct d40_chan *d40c, enum d40_command command) { if (chan_is_logical(d40c)) return __d40_execute_command_log(d40c, command); else return __d40_execute_command_phy(d40c, command); } static u32 d40_get_prmo(struct d40_chan *d40c) { static const unsigned int phy_map[] = { [STEDMA40_PCHAN_BASIC_MODE] = D40_DREG_PRMO_PCHAN_BASIC, [STEDMA40_PCHAN_MODULO_MODE] = D40_DREG_PRMO_PCHAN_MODULO, [STEDMA40_PCHAN_DOUBLE_DST_MODE] = D40_DREG_PRMO_PCHAN_DOUBLE_DST, }; static const unsigned int log_map[] = { [STEDMA40_LCHAN_SRC_PHY_DST_LOG] = D40_DREG_PRMO_LCHAN_SRC_PHY_DST_LOG, [STEDMA40_LCHAN_SRC_LOG_DST_PHY] = D40_DREG_PRMO_LCHAN_SRC_LOG_DST_PHY, [STEDMA40_LCHAN_SRC_LOG_DST_LOG] = D40_DREG_PRMO_LCHAN_SRC_LOG_DST_LOG, }; if (chan_is_physical(d40c)) return phy_map[d40c->dma_cfg.mode_opt]; else return log_map[d40c->dma_cfg.mode_opt]; } static void d40_config_write(struct d40_chan *d40c) { u32 addr_base; u32 var; /* Odd addresses are even addresses + 4 */ addr_base = (d40c->phy_chan->num % 2) * 4; /* Setup channel mode to logical or physical */ var = ((u32)(chan_is_logical(d40c)) + 1) << D40_CHAN_POS(d40c->phy_chan->num); writel(var, d40c->base->virtbase + D40_DREG_PRMSE + addr_base); /* Setup operational mode option register */ var = d40_get_prmo(d40c) << D40_CHAN_POS(d40c->phy_chan->num); writel(var, d40c->base->virtbase + D40_DREG_PRMOE + addr_base); if (chan_is_logical(d40c)) { int lidx = (d40c->phy_chan->num << D40_SREG_ELEM_LOG_LIDX_POS) & D40_SREG_ELEM_LOG_LIDX_MASK; void __iomem *chanbase = chan_base(d40c); /* Set default config for CFG reg */ writel(d40c->src_def_cfg, chanbase + D40_CHAN_REG_SSCFG); writel(d40c->dst_def_cfg, chanbase + D40_CHAN_REG_SDCFG); /* Set LIDX for lcla */ writel(lidx, chanbase + D40_CHAN_REG_SSELT); writel(lidx, chanbase + D40_CHAN_REG_SDELT); /* Clear LNK which will be used by d40_chan_has_events() */ writel(0, chanbase + D40_CHAN_REG_SSLNK); writel(0, chanbase + D40_CHAN_REG_SDLNK); } } static u32 d40_residue(struct d40_chan *d40c) { u32 num_elt; if (chan_is_logical(d40c)) num_elt = (readl(&d40c->lcpa->lcsp2) & D40_MEM_LCSP2_ECNT_MASK) >> D40_MEM_LCSP2_ECNT_POS; else { u32 val = readl(chan_base(d40c) + D40_CHAN_REG_SDELT); num_elt = (val & D40_SREG_ELEM_PHY_ECNT_MASK) >> D40_SREG_ELEM_PHY_ECNT_POS; } return num_elt * (1 << d40c->dma_cfg.dst_info.data_width); } static bool d40_tx_is_linked(struct d40_chan *d40c) { bool is_link; if (chan_is_logical(d40c)) is_link = readl(&d40c->lcpa->lcsp3) & D40_MEM_LCSP3_DLOS_MASK; else is_link = readl(chan_base(d40c) + D40_CHAN_REG_SDLNK) & D40_SREG_LNK_PHYS_LNK_MASK; return is_link; } static int d40_pause(struct d40_chan *d40c) { int res = 0; unsigned long flags; if (!d40c->busy) return 0; pm_runtime_get_sync(d40c->base->dev); spin_lock_irqsave(&d40c->lock, flags); res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ); pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); spin_unlock_irqrestore(&d40c->lock, flags); return res; } static int d40_resume(struct d40_chan *d40c) { int res = 0; unsigned long flags; if (!d40c->busy) return 0; spin_lock_irqsave(&d40c->lock, flags); pm_runtime_get_sync(d40c->base->dev); /* If bytes left to transfer or linked tx resume job */ if (d40_residue(d40c) || d40_tx_is_linked(d40c)) res = d40_channel_execute_command(d40c, D40_DMA_RUN); pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); spin_unlock_irqrestore(&d40c->lock, flags); return res; } static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx) { struct d40_chan *d40c = container_of(tx->chan, struct d40_chan, chan); struct d40_desc *d40d = container_of(tx, struct d40_desc, txd); unsigned long flags; dma_cookie_t cookie; spin_lock_irqsave(&d40c->lock, flags); cookie = dma_cookie_assign(tx); d40_desc_queue(d40c, d40d); spin_unlock_irqrestore(&d40c->lock, flags); return cookie; } static int d40_start(struct d40_chan *d40c) { return d40_channel_execute_command(d40c, D40_DMA_RUN); } static struct d40_desc *d40_queue_start(struct d40_chan *d40c) { struct d40_desc *d40d; int err; /* Start queued jobs, if any */ d40d = d40_first_queued(d40c); if (d40d != NULL) { if (!d40c->busy) { d40c->busy = true; pm_runtime_get_sync(d40c->base->dev); } /* Remove from queue */ d40_desc_remove(d40d); /* Add to active queue */ d40_desc_submit(d40c, d40d); /* Initiate DMA job */ d40_desc_load(d40c, d40d); /* Start dma job */ err = d40_start(d40c); if (err) return NULL; } return d40d; } /* called from interrupt context */ static void dma_tc_handle(struct d40_chan *d40c) { struct d40_desc *d40d; /* Get first active entry from list */ d40d = d40_first_active_get(d40c); if (d40d == NULL) return; if (d40d->cyclic) { /* * If this was a paritially loaded list, we need to reloaded * it, and only when the list is completed. We need to check * for done because the interrupt will hit for every link, and * not just the last one. */ if (d40d->lli_current < d40d->lli_len && !d40_tx_is_linked(d40c) && !d40_residue(d40c)) { d40_lcla_free_all(d40c, d40d); d40_desc_load(d40c, d40d); (void) d40_start(d40c); if (d40d->lli_current == d40d->lli_len) d40d->lli_current = 0; } } else { d40_lcla_free_all(d40c, d40d); if (d40d->lli_current < d40d->lli_len) { d40_desc_load(d40c, d40d); /* Start dma job */ (void) d40_start(d40c); return; } if (d40_queue_start(d40c) == NULL) { d40c->busy = false; pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); } d40_desc_remove(d40d); d40_desc_done(d40c, d40d); } d40c->pending_tx++; tasklet_schedule(&d40c->tasklet); } static void dma_tasklet(unsigned long data) { struct d40_chan *d40c = (struct d40_chan *) data; struct d40_desc *d40d; unsigned long flags; bool callback_active; dma_async_tx_callback callback; void *callback_param; spin_lock_irqsave(&d40c->lock, flags); /* Get first entry from the done list */ d40d = d40_first_done(d40c); if (d40d == NULL) { /* Check if we have reached here for cyclic job */ d40d = d40_first_active_get(d40c); if (d40d == NULL || !d40d->cyclic) goto err; } if (!d40d->cyclic) dma_cookie_complete(&d40d->txd); /* * If terminating a channel pending_tx is set to zero. * This prevents any finished active jobs to return to the client. */ if (d40c->pending_tx == 0) { spin_unlock_irqrestore(&d40c->lock, flags); return; } /* Callback to client */ callback_active = !!(d40d->txd.flags & DMA_PREP_INTERRUPT); callback = d40d->txd.callback; callback_param = d40d->txd.callback_param; if (!d40d->cyclic) { if (async_tx_test_ack(&d40d->txd)) { d40_desc_remove(d40d); d40_desc_free(d40c, d40d); } else if (!d40d->is_in_client_list) { d40_desc_remove(d40d); d40_lcla_free_all(d40c, d40d); list_add_tail(&d40d->node, &d40c->client); d40d->is_in_client_list = true; } } d40c->pending_tx--; if (d40c->pending_tx) tasklet_schedule(&d40c->tasklet); spin_unlock_irqrestore(&d40c->lock, flags); if (callback_active && callback) callback(callback_param); return; err: /* Rescue manouver if receiving double interrupts */ if (d40c->pending_tx > 0) d40c->pending_tx--; spin_unlock_irqrestore(&d40c->lock, flags); } static irqreturn_t d40_handle_interrupt(int irq, void *data) { int i; u32 idx; u32 row; long chan = -1; struct d40_chan *d40c; unsigned long flags; struct d40_base *base = data; u32 regs[base->gen_dmac.il_size]; struct d40_interrupt_lookup *il = base->gen_dmac.il; u32 il_size = base->gen_dmac.il_size; spin_lock_irqsave(&base->interrupt_lock, flags); /* Read interrupt status of both logical and physical channels */ for (i = 0; i < il_size; i++) regs[i] = readl(base->virtbase + il[i].src); for (;;) { chan = find_next_bit((unsigned long *)regs, BITS_PER_LONG * il_size, chan + 1); /* No more set bits found? */ if (chan == BITS_PER_LONG * il_size) break; row = chan / BITS_PER_LONG; idx = chan & (BITS_PER_LONG - 1); if (il[row].offset == D40_PHY_CHAN) d40c = base->lookup_phy_chans[idx]; else d40c = base->lookup_log_chans[il[row].offset + idx]; if (!d40c) { /* * No error because this can happen if something else * in the system is using the channel. */ continue; } /* ACK interrupt */ writel(1 << idx, base->virtbase + il[row].clr); spin_lock(&d40c->lock); if (!il[row].is_error) dma_tc_handle(d40c); else d40_err(base->dev, "IRQ chan: %ld offset %d idx %d\n", chan, il[row].offset, idx); spin_unlock(&d40c->lock); } spin_unlock_irqrestore(&base->interrupt_lock, flags); return IRQ_HANDLED; } static int d40_validate_conf(struct d40_chan *d40c, struct stedma40_chan_cfg *conf) { int res = 0; u32 dst_event_group = D40_TYPE_TO_GROUP(conf->dst_dev_type); u32 src_event_group = D40_TYPE_TO_GROUP(conf->src_dev_type); bool is_log = conf->mode == STEDMA40_MODE_LOGICAL; if (!conf->dir) { chan_err(d40c, "Invalid direction.\n"); res = -EINVAL; } if (conf->dst_dev_type != STEDMA40_DEV_DST_MEMORY && d40c->base->plat_data->dev_tx[conf->dst_dev_type] == 0 && d40c->runtime_addr == 0) { chan_err(d40c, "Invalid TX channel address (%d)\n", conf->dst_dev_type); res = -EINVAL; } if (conf->src_dev_type != STEDMA40_DEV_SRC_MEMORY && d40c->base->plat_data->dev_rx[conf->src_dev_type] == 0 && d40c->runtime_addr == 0) { chan_err(d40c, "Invalid RX channel address (%d)\n", conf->src_dev_type); res = -EINVAL; } if (conf->dir == STEDMA40_MEM_TO_PERIPH && dst_event_group == STEDMA40_DEV_DST_MEMORY) { chan_err(d40c, "Invalid dst\n"); res = -EINVAL; } if (conf->dir == STEDMA40_PERIPH_TO_MEM && src_event_group == STEDMA40_DEV_SRC_MEMORY) { chan_err(d40c, "Invalid src\n"); res = -EINVAL; } if (src_event_group == STEDMA40_DEV_SRC_MEMORY && dst_event_group == STEDMA40_DEV_DST_MEMORY && is_log) { chan_err(d40c, "No event line\n"); res = -EINVAL; } if (conf->dir == STEDMA40_PERIPH_TO_PERIPH && (src_event_group != dst_event_group)) { chan_err(d40c, "Invalid event group\n"); res = -EINVAL; } if (conf->dir == STEDMA40_PERIPH_TO_PERIPH) { /* * DMAC HW supports it. Will be added to this driver, * in case any dma client requires it. */ chan_err(d40c, "periph to periph not supported\n"); res = -EINVAL; } if (d40_psize_2_burst_size(is_log, conf->src_info.psize) * (1 << conf->src_info.data_width) != d40_psize_2_burst_size(is_log, conf->dst_info.psize) * (1 << conf->dst_info.data_width)) { /* * The DMAC hardware only supports * src (burst x width) == dst (burst x width) */ chan_err(d40c, "src (burst x width) != dst (burst x width)\n"); res = -EINVAL; } return res; } static bool d40_alloc_mask_set(struct d40_phy_res *phy, bool is_src, int log_event_line, bool is_log, bool *first_user) { unsigned long flags; spin_lock_irqsave(&phy->lock, flags); *first_user = ((phy->allocated_src | phy->allocated_dst) == D40_ALLOC_FREE); if (!is_log) { /* Physical interrupts are masked per physical full channel */ if (phy->allocated_src == D40_ALLOC_FREE && phy->allocated_dst == D40_ALLOC_FREE) { phy->allocated_dst = D40_ALLOC_PHY; phy->allocated_src = D40_ALLOC_PHY; goto found; } else goto not_found; } /* Logical channel */ if (is_src) { if (phy->allocated_src == D40_ALLOC_PHY) goto not_found; if (phy->allocated_src == D40_ALLOC_FREE) phy->allocated_src = D40_ALLOC_LOG_FREE; if (!(phy->allocated_src & (1 << log_event_line))) { phy->allocated_src |= 1 << log_event_line; goto found; } else goto not_found; } else { if (phy->allocated_dst == D40_ALLOC_PHY) goto not_found; if (phy->allocated_dst == D40_ALLOC_FREE) phy->allocated_dst = D40_ALLOC_LOG_FREE; if (!(phy->allocated_dst & (1 << log_event_line))) { phy->allocated_dst |= 1 << log_event_line; goto found; } else goto not_found; } not_found: spin_unlock_irqrestore(&phy->lock, flags); return false; found: spin_unlock_irqrestore(&phy->lock, flags); return true; } static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src, int log_event_line) { unsigned long flags; bool is_free = false; spin_lock_irqsave(&phy->lock, flags); if (!log_event_line) { phy->allocated_dst = D40_ALLOC_FREE; phy->allocated_src = D40_ALLOC_FREE; is_free = true; goto out; } /* Logical channel */ if (is_src) { phy->allocated_src &= ~(1 << log_event_line); if (phy->allocated_src == D40_ALLOC_LOG_FREE) phy->allocated_src = D40_ALLOC_FREE; } else { phy->allocated_dst &= ~(1 << log_event_line); if (phy->allocated_dst == D40_ALLOC_LOG_FREE) phy->allocated_dst = D40_ALLOC_FREE; } is_free = ((phy->allocated_src | phy->allocated_dst) == D40_ALLOC_FREE); out: spin_unlock_irqrestore(&phy->lock, flags); return is_free; } static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) { int dev_type; int event_group; int event_line; struct d40_phy_res *phys; int i; int j; int log_num; int num_phy_chans; bool is_src; bool is_log = d40c->dma_cfg.mode == STEDMA40_MODE_LOGICAL; phys = d40c->base->phy_res; num_phy_chans = d40c->base->num_phy_chans; if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) { dev_type = d40c->dma_cfg.src_dev_type; log_num = 2 * dev_type; is_src = true; } else if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { /* dst event lines are used for logical memcpy */ dev_type = d40c->dma_cfg.dst_dev_type; log_num = 2 * dev_type + 1; is_src = false; } else return -EINVAL; event_group = D40_TYPE_TO_GROUP(dev_type); event_line = D40_TYPE_TO_EVENT(dev_type); if (!is_log) { if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { /* Find physical half channel */ if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel; if (d40_alloc_mask_set(&phys[i], is_src, 0, is_log, first_phy_user)) goto found_phy; } else { for (i = 0; i < num_phy_chans; i++) { if (d40_alloc_mask_set(&phys[i], is_src, 0, is_log, first_phy_user)) goto found_phy; } } } else for (j = 0; j < d40c->base->num_phy_chans; j += 8) { int phy_num = j + event_group * 2; for (i = phy_num; i < phy_num + 2; i++) { if (d40_alloc_mask_set(&phys[i], is_src, 0, is_log, first_phy_user)) goto found_phy; } } return -EINVAL; found_phy: d40c->phy_chan = &phys[i]; d40c->log_num = D40_PHY_CHAN; goto out; } if (dev_type == -1) return -EINVAL; /* Find logical channel */ for (j = 0; j < d40c->base->num_phy_chans; j += 8) { int phy_num = j + event_group * 2; if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel; if ((i != phy_num) && (i != phy_num + 1)) { dev_err(chan2dev(d40c), "invalid fixed phy channel %d\n", i); return -EINVAL; } if (d40_alloc_mask_set(&phys[i], is_src, event_line, is_log, first_phy_user)) goto found_log; dev_err(chan2dev(d40c), "could not allocate fixed phy channel %d\n", i); return -EINVAL; } /* * Spread logical channels across all available physical rather * than pack every logical channel at the first available phy * channels. */ if (is_src) { for (i = phy_num; i < phy_num + 2; i++) { if (d40_alloc_mask_set(&phys[i], is_src, event_line, is_log, first_phy_user)) goto found_log; } } else { for (i = phy_num + 1; i >= phy_num; i--) { if (d40_alloc_mask_set(&phys[i], is_src, event_line, is_log, first_phy_user)) goto found_log; } } } return -EINVAL; found_log: d40c->phy_chan = &phys[i]; d40c->log_num = log_num; out: if (is_log) d40c->base->lookup_log_chans[d40c->log_num] = d40c; else d40c->base->lookup_phy_chans[d40c->phy_chan->num] = d40c; return 0; } static int d40_config_memcpy(struct d40_chan *d40c) { dma_cap_mask_t cap = d40c->chan.device->cap_mask; if (dma_has_cap(DMA_MEMCPY, cap) && !dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = *d40c->base->plat_data->memcpy_conf_log; d40c->dma_cfg.src_dev_type = STEDMA40_DEV_SRC_MEMORY; d40c->dma_cfg.dst_dev_type = d40c->base->plat_data-> memcpy[d40c->chan.chan_id]; } else if (dma_has_cap(DMA_MEMCPY, cap) && dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = *d40c->base->plat_data->memcpy_conf_phy; } else { chan_err(d40c, "No memcpy\n"); return -EINVAL; } return 0; } static int d40_free_dma(struct d40_chan *d40c) { int res = 0; u32 event; struct d40_phy_res *phy = d40c->phy_chan; bool is_src; /* Terminate all queued and active transfers */ d40_term_all(d40c); if (phy == NULL) { chan_err(d40c, "phy == null\n"); return -EINVAL; } if (phy->allocated_src == D40_ALLOC_FREE && phy->allocated_dst == D40_ALLOC_FREE) { chan_err(d40c, "channel already free\n"); return -EINVAL; } if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type); is_src = false; } else if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) { event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type); is_src = true; } else { chan_err(d40c, "Unknown direction\n"); return -EINVAL; } pm_runtime_get_sync(d40c->base->dev); res = d40_channel_execute_command(d40c, D40_DMA_STOP); if (res) { chan_err(d40c, "stop failed\n"); goto out; } d40_alloc_mask_free(phy, is_src, chan_is_logical(d40c) ? event : 0); if (chan_is_logical(d40c)) d40c->base->lookup_log_chans[d40c->log_num] = NULL; else d40c->base->lookup_phy_chans[phy->num] = NULL; if (d40c->busy) { pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); } d40c->busy = false; d40c->phy_chan = NULL; d40c->configured = false; out: pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); return res; } static bool d40_is_paused(struct d40_chan *d40c) { void __iomem *chanbase = chan_base(d40c); bool is_paused = false; unsigned long flags; void __iomem *active_reg; u32 status; u32 event; spin_lock_irqsave(&d40c->lock, flags); if (chan_is_physical(d40c)) { if (d40c->phy_chan->num % 2 == 0) active_reg = d40c->base->virtbase + D40_DREG_ACTIVE; else active_reg = d40c->base->virtbase + D40_DREG_ACTIVO; status = (readl(active_reg) & D40_CHAN_POS_MASK(d40c->phy_chan->num)) >> D40_CHAN_POS(d40c->phy_chan->num); if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP) is_paused = true; goto _exit; } if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type); status = readl(chanbase + D40_CHAN_REG_SDLNK); } else if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) { event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type); status = readl(chanbase + D40_CHAN_REG_SSLNK); } else { chan_err(d40c, "Unknown direction\n"); goto _exit; } status = (status & D40_EVENTLINE_MASK(event)) >> D40_EVENTLINE_POS(event); if (status != D40_DMA_RUN) is_paused = true; _exit: spin_unlock_irqrestore(&d40c->lock, flags); return is_paused; } static u32 stedma40_residue(struct dma_chan *chan) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); u32 bytes_left; unsigned long flags; spin_lock_irqsave(&d40c->lock, flags); bytes_left = d40_residue(d40c); spin_unlock_irqrestore(&d40c->lock, flags); return bytes_left; } static int d40_prep_sg_log(struct d40_chan *chan, struct d40_desc *desc, struct scatterlist *sg_src, struct scatterlist *sg_dst, unsigned int sg_len, dma_addr_t src_dev_addr, dma_addr_t dst_dev_addr) { struct stedma40_chan_cfg *cfg = &chan->dma_cfg; struct stedma40_half_channel_info *src_info = &cfg->src_info; struct stedma40_half_channel_info *dst_info = &cfg->dst_info; int ret; ret = d40_log_sg_to_lli(sg_src, sg_len, src_dev_addr, desc->lli_log.src, chan->log_def.lcsp1, src_info->data_width, dst_info->data_width); ret = d40_log_sg_to_lli(sg_dst, sg_len, dst_dev_addr, desc->lli_log.dst, chan->log_def.lcsp3, dst_info->data_width, src_info->data_width); return ret < 0 ? ret : 0; } static int d40_prep_sg_phy(struct d40_chan *chan, struct d40_desc *desc, struct scatterlist *sg_src, struct scatterlist *sg_dst, unsigned int sg_len, dma_addr_t src_dev_addr, dma_addr_t dst_dev_addr) { struct stedma40_chan_cfg *cfg = &chan->dma_cfg; struct stedma40_half_channel_info *src_info = &cfg->src_info; struct stedma40_half_channel_info *dst_info = &cfg->dst_info; unsigned long flags = 0; int ret; if (desc->cyclic) flags |= LLI_CYCLIC | LLI_TERM_INT; ret = d40_phy_sg_to_lli(sg_src, sg_len, src_dev_addr, desc->lli_phy.src, virt_to_phys(desc->lli_phy.src), chan->src_def_cfg, src_info, dst_info, flags); ret = d40_phy_sg_to_lli(sg_dst, sg_len, dst_dev_addr, desc->lli_phy.dst, virt_to_phys(desc->lli_phy.dst), chan->dst_def_cfg, dst_info, src_info, flags); dma_sync_single_for_device(chan->base->dev, desc->lli_pool.dma_addr, desc->lli_pool.size, DMA_TO_DEVICE); return ret < 0 ? ret : 0; } static struct d40_desc * d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg, unsigned int sg_len, unsigned long dma_flags) { struct stedma40_chan_cfg *cfg = &chan->dma_cfg; struct d40_desc *desc; int ret; desc = d40_desc_get(chan); if (!desc) return NULL; desc->lli_len = d40_sg_2_dmalen(sg, sg_len, cfg->src_info.data_width, cfg->dst_info.data_width); if (desc->lli_len < 0) { chan_err(chan, "Unaligned size\n"); goto err; } ret = d40_pool_lli_alloc(chan, desc, desc->lli_len); if (ret < 0) { chan_err(chan, "Could not allocate lli\n"); goto err; } desc->lli_current = 0; desc->txd.flags = dma_flags; desc->txd.tx_submit = d40_tx_submit; dma_async_tx_descriptor_init(&desc->txd, &chan->chan); return desc; err: d40_desc_free(chan, desc); return NULL; } static dma_addr_t d40_get_dev_addr(struct d40_chan *chan, enum dma_transfer_direction direction) { struct stedma40_platform_data *plat = chan->base->plat_data; struct stedma40_chan_cfg *cfg = &chan->dma_cfg; dma_addr_t addr = 0; if (chan->runtime_addr) return chan->runtime_addr; if (direction == DMA_DEV_TO_MEM) addr = plat->dev_rx[cfg->src_dev_type]; else if (direction == DMA_MEM_TO_DEV) addr = plat->dev_tx[cfg->dst_dev_type]; return addr; } static struct dma_async_tx_descriptor * d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src, struct scatterlist *sg_dst, unsigned int sg_len, enum dma_transfer_direction direction, unsigned long dma_flags) { struct d40_chan *chan = container_of(dchan, struct d40_chan, chan); dma_addr_t src_dev_addr = 0; dma_addr_t dst_dev_addr = 0; struct d40_desc *desc; unsigned long flags; int ret; if (!chan->phy_chan) { chan_err(chan, "Cannot prepare unallocated channel\n"); return NULL; } spin_lock_irqsave(&chan->lock, flags); desc = d40_prep_desc(chan, sg_src, sg_len, dma_flags); if (desc == NULL) goto err; if (sg_next(&sg_src[sg_len - 1]) == sg_src) desc->cyclic = true; if (direction != DMA_TRANS_NONE) { dma_addr_t dev_addr = d40_get_dev_addr(chan, direction); if (direction == DMA_DEV_TO_MEM) src_dev_addr = dev_addr; else if (direction == DMA_MEM_TO_DEV) dst_dev_addr = dev_addr; } if (chan_is_logical(chan)) ret = d40_prep_sg_log(chan, desc, sg_src, sg_dst, sg_len, src_dev_addr, dst_dev_addr); else ret = d40_prep_sg_phy(chan, desc, sg_src, sg_dst, sg_len, src_dev_addr, dst_dev_addr); if (ret) { chan_err(chan, "Failed to prepare %s sg job: %d\n", chan_is_logical(chan) ? "log" : "phy", ret); goto err; } /* * add descriptor to the prepare queue in order to be able * to free them later in terminate_all */ list_add_tail(&desc->node, &chan->prepare_queue); spin_unlock_irqrestore(&chan->lock, flags); return &desc->txd; err: if (desc) d40_desc_free(chan, desc); spin_unlock_irqrestore(&chan->lock, flags); return NULL; } bool stedma40_filter(struct dma_chan *chan, void *data) { struct stedma40_chan_cfg *info = data; struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); int err; if (data) { err = d40_validate_conf(d40c, info); if (!err) d40c->dma_cfg = *info; } else err = d40_config_memcpy(d40c); if (!err) d40c->configured = true; return err == 0; } EXPORT_SYMBOL(stedma40_filter); static void __d40_set_prio_rt(struct d40_chan *d40c, int dev_type, bool src) { bool realtime = d40c->dma_cfg.realtime; bool highprio = d40c->dma_cfg.high_priority; u32 rtreg; u32 event = D40_TYPE_TO_EVENT(dev_type); u32 group = D40_TYPE_TO_GROUP(dev_type); u32 bit = 1 << event; u32 prioreg; struct d40_gen_dmac *dmac = &d40c->base->gen_dmac; rtreg = realtime ? dmac->realtime_en : dmac->realtime_clear; /* * Due to a hardware bug, in some cases a logical channel triggered by * a high priority destination event line can generate extra packet * transactions. * * The workaround is to not set the high priority level for the * destination event lines that trigger logical channels. */ if (!src && chan_is_logical(d40c)) highprio = false; prioreg = highprio ? dmac->high_prio_en : dmac->high_prio_clear; /* Destination event lines are stored in the upper halfword */ if (!src) bit <<= 16; writel(bit, d40c->base->virtbase + prioreg + group * 4); writel(bit, d40c->base->virtbase + rtreg + group * 4); } static void d40_set_prio_realtime(struct d40_chan *d40c) { if (d40c->base->rev < 3) return; if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) || (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) __d40_set_prio_rt(d40c, d40c->dma_cfg.src_dev_type, true); if ((d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH) || (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) __d40_set_prio_rt(d40c, d40c->dma_cfg.dst_dev_type, false); } /* DMA ENGINE functions */ static int d40_alloc_chan_resources(struct dma_chan *chan) { int err; unsigned long flags; struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); bool is_free_phy; spin_lock_irqsave(&d40c->lock, flags); dma_cookie_init(chan); /* If no dma configuration is set use default configuration (memcpy) */ if (!d40c->configured) { err = d40_config_memcpy(d40c); if (err) { chan_err(d40c, "Failed to configure memcpy channel\n"); goto fail; } } err = d40_allocate_channel(d40c, &is_free_phy); if (err) { chan_err(d40c, "Failed to allocate channel\n"); d40c->configured = false; goto fail; } pm_runtime_get_sync(d40c->base->dev); /* Fill in basic CFG register values */ d40_phy_cfg(&d40c->dma_cfg, &d40c->src_def_cfg, &d40c->dst_def_cfg, chan_is_logical(d40c)); d40_set_prio_realtime(d40c); if (chan_is_logical(d40c)) { d40_log_cfg(&d40c->dma_cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3); if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) d40c->lcpa = d40c->base->lcpa_base + d40c->dma_cfg.src_dev_type * D40_LCPA_CHAN_SIZE; else d40c->lcpa = d40c->base->lcpa_base + d40c->dma_cfg.dst_dev_type * D40_LCPA_CHAN_SIZE + D40_LCPA_CHAN_DST_DELTA; } dev_dbg(chan2dev(d40c), "allocated %s channel (phy %d%s)\n", chan_is_logical(d40c) ? "logical" : "physical", d40c->phy_chan->num, d40c->dma_cfg.use_fixed_channel ? ", fixed" : ""); /* * Only write channel configuration to the DMA if the physical * resource is free. In case of multiple logical channels * on the same physical resource, only the first write is necessary. */ if (is_free_phy) d40_config_write(d40c); fail: pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); spin_unlock_irqrestore(&d40c->lock, flags); return err; } static void d40_free_chan_resources(struct dma_chan *chan) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); int err; unsigned long flags; if (d40c->phy_chan == NULL) { chan_err(d40c, "Cannot free unallocated channel\n"); return; } spin_lock_irqsave(&d40c->lock, flags); err = d40_free_dma(d40c); if (err) chan_err(d40c, "Failed to free channel\n"); spin_unlock_irqrestore(&d40c->lock, flags); } static struct dma_async_tx_descriptor *d40_prep_memcpy(struct dma_chan *chan, dma_addr_t dst, dma_addr_t src, size_t size, unsigned long dma_flags) { struct scatterlist dst_sg; struct scatterlist src_sg; sg_init_table(&dst_sg, 1); sg_init_table(&src_sg, 1); sg_dma_address(&dst_sg) = dst; sg_dma_address(&src_sg) = src; sg_dma_len(&dst_sg) = size; sg_dma_len(&src_sg) = size; return d40_prep_sg(chan, &src_sg, &dst_sg, 1, DMA_NONE, dma_flags); } static struct dma_async_tx_descriptor * d40_prep_memcpy_sg(struct dma_chan *chan, struct scatterlist *dst_sg, unsigned int dst_nents, struct scatterlist *src_sg, unsigned int src_nents, unsigned long dma_flags) { if (dst_nents != src_nents) return NULL; return d40_prep_sg(chan, src_sg, dst_sg, src_nents, DMA_NONE, dma_flags); } static struct dma_async_tx_descriptor * d40_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction direction, unsigned long dma_flags, void *context) { if (!is_slave_direction(direction)) return NULL; return d40_prep_sg(chan, sgl, sgl, sg_len, direction, dma_flags); } static struct dma_async_tx_descriptor * dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, size_t period_len, enum dma_transfer_direction direction, unsigned long flags, void *context) { unsigned int periods = buf_len / period_len; struct dma_async_tx_descriptor *txd; struct scatterlist *sg; int i; sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT); for (i = 0; i < periods; i++) { sg_dma_address(&sg[i]) = dma_addr; sg_dma_len(&sg[i]) = period_len; dma_addr += period_len; } sg[periods].offset = 0; sg_dma_len(&sg[periods]) = 0; sg[periods].page_link = ((unsigned long)sg | 0x01) & ~0x02; txd = d40_prep_sg(chan, sg, sg, periods, direction, DMA_PREP_INTERRUPT); kfree(sg); return txd; } static enum dma_status d40_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); enum dma_status ret; if (d40c->phy_chan == NULL) { chan_err(d40c, "Cannot read status of unallocated channel\n"); return -EINVAL; } ret = dma_cookie_status(chan, cookie, txstate); if (ret != DMA_SUCCESS) dma_set_residue(txstate, stedma40_residue(chan)); if (d40_is_paused(d40c)) ret = DMA_PAUSED; return ret; } static void d40_issue_pending(struct dma_chan *chan) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); unsigned long flags; if (d40c->phy_chan == NULL) { chan_err(d40c, "Channel is not allocated!\n"); return; } spin_lock_irqsave(&d40c->lock, flags); list_splice_tail_init(&d40c->pending_queue, &d40c->queue); /* Busy means that queued jobs are already being processed */ if (!d40c->busy) (void) d40_queue_start(d40c); spin_unlock_irqrestore(&d40c->lock, flags); } static void d40_terminate_all(struct dma_chan *chan) { unsigned long flags; struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); int ret; spin_lock_irqsave(&d40c->lock, flags); pm_runtime_get_sync(d40c->base->dev); ret = d40_channel_execute_command(d40c, D40_DMA_STOP); if (ret) chan_err(d40c, "Failed to stop channel\n"); d40_term_all(d40c); pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); if (d40c->busy) { pm_runtime_mark_last_busy(d40c->base->dev); pm_runtime_put_autosuspend(d40c->base->dev); } d40c->busy = false; spin_unlock_irqrestore(&d40c->lock, flags); } static int dma40_config_to_halfchannel(struct d40_chan *d40c, struct stedma40_half_channel_info *info, enum dma_slave_buswidth width, u32 maxburst) { enum stedma40_periph_data_width addr_width; int psize; switch (width) { case DMA_SLAVE_BUSWIDTH_1_BYTE: addr_width = STEDMA40_BYTE_WIDTH; break; case DMA_SLAVE_BUSWIDTH_2_BYTES: addr_width = STEDMA40_HALFWORD_WIDTH; break; case DMA_SLAVE_BUSWIDTH_4_BYTES: addr_width = STEDMA40_WORD_WIDTH; break; case DMA_SLAVE_BUSWIDTH_8_BYTES: addr_width = STEDMA40_DOUBLEWORD_WIDTH; break; default: dev_err(d40c->base->dev, "illegal peripheral address width " "requested (%d)\n", width); return -EINVAL; } if (chan_is_logical(d40c)) { if (maxburst >= 16) psize = STEDMA40_PSIZE_LOG_16; else if (maxburst >= 8) psize = STEDMA40_PSIZE_LOG_8; else if (maxburst >= 4) psize = STEDMA40_PSIZE_LOG_4; else psize = STEDMA40_PSIZE_LOG_1; } else { if (maxburst >= 16) psize = STEDMA40_PSIZE_PHY_16; else if (maxburst >= 8) psize = STEDMA40_PSIZE_PHY_8; else if (maxburst >= 4) psize = STEDMA40_PSIZE_PHY_4; else psize = STEDMA40_PSIZE_PHY_1; } info->data_width = addr_width; info->psize = psize; info->flow_ctrl = STEDMA40_NO_FLOW_CTRL; return 0; } /* Runtime reconfiguration extension */ static int d40_set_runtime_config(struct dma_chan *chan, struct dma_slave_config *config) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); struct stedma40_chan_cfg *cfg = &d40c->dma_cfg; enum dma_slave_buswidth src_addr_width, dst_addr_width; dma_addr_t config_addr; u32 src_maxburst, dst_maxburst; int ret; src_addr_width = config->src_addr_width; src_maxburst = config->src_maxburst; dst_addr_width = config->dst_addr_width; dst_maxburst = config->dst_maxburst; if (config->direction == DMA_DEV_TO_MEM) { dma_addr_t dev_addr_rx = d40c->base->plat_data->dev_rx[cfg->src_dev_type]; config_addr = config->src_addr; if (dev_addr_rx) dev_dbg(d40c->base->dev, "channel has a pre-wired RX address %08x " "overriding with %08x\n", dev_addr_rx, config_addr); if (cfg->dir != STEDMA40_PERIPH_TO_MEM) dev_dbg(d40c->base->dev, "channel was not configured for peripheral " "to memory transfer (%d) overriding\n", cfg->dir); cfg->dir = STEDMA40_PERIPH_TO_MEM; /* Configure the memory side */ if (dst_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) dst_addr_width = src_addr_width; if (dst_maxburst == 0) dst_maxburst = src_maxburst; } else if (config->direction == DMA_MEM_TO_DEV) { dma_addr_t dev_addr_tx = d40c->base->plat_data->dev_tx[cfg->dst_dev_type]; config_addr = config->dst_addr; if (dev_addr_tx) dev_dbg(d40c->base->dev, "channel has a pre-wired TX address %08x " "overriding with %08x\n", dev_addr_tx, config_addr); if (cfg->dir != STEDMA40_MEM_TO_PERIPH) dev_dbg(d40c->base->dev, "channel was not configured for memory " "to peripheral transfer (%d) overriding\n", cfg->dir); cfg->dir = STEDMA40_MEM_TO_PERIPH; /* Configure the memory side */ if (src_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) src_addr_width = dst_addr_width; if (src_maxburst == 0) src_maxburst = dst_maxburst; } else { dev_err(d40c->base->dev, "unrecognized channel direction %d\n", config->direction); return -EINVAL; } if (src_maxburst * src_addr_width != dst_maxburst * dst_addr_width) { dev_err(d40c->base->dev, "src/dst width/maxburst mismatch: %d*%d != %d*%d\n", src_maxburst, src_addr_width, dst_maxburst, dst_addr_width); return -EINVAL; } if (src_maxburst > 16) { src_maxburst = 16; dst_maxburst = src_maxburst * src_addr_width / dst_addr_width; } else if (dst_maxburst > 16) { dst_maxburst = 16; src_maxburst = dst_maxburst * dst_addr_width / src_addr_width; } ret = dma40_config_to_halfchannel(d40c, &cfg->src_info, src_addr_width, src_maxburst); if (ret) return ret; ret = dma40_config_to_halfchannel(d40c, &cfg->dst_info, dst_addr_width, dst_maxburst); if (ret) return ret; /* Fill in register values */ if (chan_is_logical(d40c)) d40_log_cfg(cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3); else d40_phy_cfg(cfg, &d40c->src_def_cfg, &d40c->dst_def_cfg, false); /* These settings will take precedence later */ d40c->runtime_addr = config_addr; d40c->runtime_direction = config->direction; dev_dbg(d40c->base->dev, "configured channel %s for %s, data width %d/%d, " "maxburst %d/%d elements, LE, no flow control\n", dma_chan_name(chan), (config->direction == DMA_DEV_TO_MEM) ? "RX" : "TX", src_addr_width, dst_addr_width, src_maxburst, dst_maxburst); return 0; } static int d40_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned long arg) { struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); if (d40c->phy_chan == NULL) { chan_err(d40c, "Channel is not allocated!\n"); return -EINVAL; } switch (cmd) { case DMA_TERMINATE_ALL: d40_terminate_all(chan); return 0; case DMA_PAUSE: return d40_pause(d40c); case DMA_RESUME: return d40_resume(d40c); case DMA_SLAVE_CONFIG: return d40_set_runtime_config(chan, (struct dma_slave_config *) arg); default: break; } /* Other commands are unimplemented */ return -ENXIO; } /* Initialization functions */ static void __init d40_chan_init(struct d40_base *base, struct dma_device *dma, struct d40_chan *chans, int offset, int num_chans) { int i = 0; struct d40_chan *d40c; INIT_LIST_HEAD(&dma->channels); for (i = offset; i < offset + num_chans; i++) { d40c = &chans[i]; d40c->base = base; d40c->chan.device = dma; spin_lock_init(&d40c->lock); d40c->log_num = D40_PHY_CHAN; INIT_LIST_HEAD(&d40c->done); INIT_LIST_HEAD(&d40c->active); INIT_LIST_HEAD(&d40c->queue); INIT_LIST_HEAD(&d40c->pending_queue); INIT_LIST_HEAD(&d40c->client); INIT_LIST_HEAD(&d40c->prepare_queue); tasklet_init(&d40c->tasklet, dma_tasklet, (unsigned long) d40c); list_add_tail(&d40c->chan.device_node, &dma->channels); } } static void d40_ops_init(struct d40_base *base, struct dma_device *dev) { if (dma_has_cap(DMA_SLAVE, dev->cap_mask)) dev->device_prep_slave_sg = d40_prep_slave_sg; if (dma_has_cap(DMA_MEMCPY, dev->cap_mask)) { dev->device_prep_dma_memcpy = d40_prep_memcpy; /* * This controller can only access address at even * 32bit boundaries, i.e. 2^2 */ dev->copy_align = 2; } if (dma_has_cap(DMA_SG, dev->cap_mask)) dev->device_prep_dma_sg = d40_prep_memcpy_sg; if (dma_has_cap(DMA_CYCLIC, dev->cap_mask)) dev->device_prep_dma_cyclic = dma40_prep_dma_cyclic; dev->device_alloc_chan_resources = d40_alloc_chan_resources; dev->device_free_chan_resources = d40_free_chan_resources; dev->device_issue_pending = d40_issue_pending; dev->device_tx_status = d40_tx_status; dev->device_control = d40_control; dev->dev = base->dev; } static int __init d40_dmaengine_init(struct d40_base *base, int num_reserved_chans) { int err ; d40_chan_init(base, &base->dma_slave, base->log_chans, 0, base->num_log_chans); dma_cap_zero(base->dma_slave.cap_mask); dma_cap_set(DMA_SLAVE, base->dma_slave.cap_mask); dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask); d40_ops_init(base, &base->dma_slave); err = dma_async_device_register(&base->dma_slave); if (err) { d40_err(base->dev, "Failed to register slave channels\n"); goto failure1; } d40_chan_init(base, &base->dma_memcpy, base->log_chans, base->num_log_chans, base->plat_data->memcpy_len); dma_cap_zero(base->dma_memcpy.cap_mask); dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask); dma_cap_set(DMA_SG, base->dma_memcpy.cap_mask); d40_ops_init(base, &base->dma_memcpy); err = dma_async_device_register(&base->dma_memcpy); if (err) { d40_err(base->dev, "Failed to regsiter memcpy only channels\n"); goto failure2; } d40_chan_init(base, &base->dma_both, base->phy_chans, 0, num_reserved_chans); dma_cap_zero(base->dma_both.cap_mask); dma_cap_set(DMA_SLAVE, base->dma_both.cap_mask); dma_cap_set(DMA_MEMCPY, base->dma_both.cap_mask); dma_cap_set(DMA_SG, base->dma_both.cap_mask); dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask); d40_ops_init(base, &base->dma_both); err = dma_async_device_register(&base->dma_both); if (err) { d40_err(base->dev, "Failed to register logical and physical capable channels\n"); goto failure3; } return 0; failure3: dma_async_device_unregister(&base->dma_memcpy); failure2: dma_async_device_unregister(&base->dma_slave); failure1: return err; } /* Suspend resume functionality */ #ifdef CONFIG_PM static int dma40_pm_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct d40_base *base = platform_get_drvdata(pdev); int ret = 0; if (base->lcpa_regulator) ret = regulator_disable(base->lcpa_regulator); return ret; } static int dma40_runtime_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct d40_base *base = platform_get_drvdata(pdev); d40_save_restore_registers(base, true); /* Don't disable/enable clocks for v1 due to HW bugs */ if (base->rev != 1) writel_relaxed(base->gcc_pwr_off_mask, base->virtbase + D40_DREG_GCC); return 0; } static int dma40_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct d40_base *base = platform_get_drvdata(pdev); if (base->initialized) d40_save_restore_registers(base, false); writel_relaxed(D40_DREG_GCC_ENABLE_ALL, base->virtbase + D40_DREG_GCC); return 0; } static int dma40_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct d40_base *base = platform_get_drvdata(pdev); int ret = 0; if (base->lcpa_regulator) ret = regulator_enable(base->lcpa_regulator); return ret; } static const struct dev_pm_ops dma40_pm_ops = { .suspend = dma40_pm_suspend, .runtime_suspend = dma40_runtime_suspend, .runtime_resume = dma40_runtime_resume, .resume = dma40_resume, }; #define DMA40_PM_OPS (&dma40_pm_ops) #else #define DMA40_PM_OPS NULL #endif /* Initialization functions. */ static int __init d40_phy_res_init(struct d40_base *base) { int i; int num_phy_chans_avail = 0; u32 val[2]; int odd_even_bit = -2; int gcc = D40_DREG_GCC_ENA; val[0] = readl(base->virtbase + D40_DREG_PRSME); val[1] = readl(base->virtbase + D40_DREG_PRSMO); for (i = 0; i < base->num_phy_chans; i++) { base->phy_res[i].num = i; odd_even_bit += 2 * ((i % 2) == 0); if (((val[i % 2] >> odd_even_bit) & 3) == 1) { /* Mark security only channels as occupied */ base->phy_res[i].allocated_src = D40_ALLOC_PHY; base->phy_res[i].allocated_dst = D40_ALLOC_PHY; base->phy_res[i].reserved = true; gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(i), D40_DREG_GCC_SRC); gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(i), D40_DREG_GCC_DST); } else { base->phy_res[i].allocated_src = D40_ALLOC_FREE; base->phy_res[i].allocated_dst = D40_ALLOC_FREE; base->phy_res[i].reserved = false; num_phy_chans_avail++; } spin_lock_init(&base->phy_res[i].lock); } /* Mark disabled channels as occupied */ for (i = 0; base->plat_data->disabled_channels[i] != -1; i++) { int chan = base->plat_data->disabled_channels[i]; base->phy_res[chan].allocated_src = D40_ALLOC_PHY; base->phy_res[chan].allocated_dst = D40_ALLOC_PHY; base->phy_res[chan].reserved = true; gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(chan), D40_DREG_GCC_SRC); gcc |= D40_DREG_GCC_EVTGRP_ENA(D40_PHYS_TO_GROUP(chan), D40_DREG_GCC_DST); num_phy_chans_avail--; } /* Mark soft_lli channels */ for (i = 0; i < base->plat_data->num_of_soft_lli_chans; i++) { int chan = base->plat_data->soft_lli_chans[i]; base->phy_res[chan].use_soft_lli = true; } dev_info(base->dev, "%d of %d physical DMA channels available\n", num_phy_chans_avail, base->num_phy_chans); /* Verify settings extended vs standard */ val[0] = readl(base->virtbase + D40_DREG_PRTYP); for (i = 0; i < base->num_phy_chans; i++) { if (base->phy_res[i].allocated_src == D40_ALLOC_FREE && (val[0] & 0x3) != 1) dev_info(base->dev, "[%s] INFO: channel %d is misconfigured (%d)\n", __func__, i, val[0] & 0x3); val[0] = val[0] >> 2; } /* * To keep things simple, Enable all clocks initially. * The clocks will get managed later post channel allocation. * The clocks for the event lines on which reserved channels exists * are not managed here. */ writel(D40_DREG_GCC_ENABLE_ALL, base->virtbase + D40_DREG_GCC); base->gcc_pwr_off_mask = gcc; return num_phy_chans_avail; } static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) { struct stedma40_platform_data *plat_data; struct clk *clk = NULL; void __iomem *virtbase = NULL; struct resource *res = NULL; struct d40_base *base = NULL; int num_log_chans = 0; int num_phy_chans; int clk_ret = -EINVAL; int i; u32 pid; u32 cid; u8 rev; clk = clk_get(&pdev->dev, NULL); if (IS_ERR(clk)) { d40_err(&pdev->dev, "No matching clock found\n"); goto failure; } clk_ret = clk_prepare_enable(clk); if (clk_ret) { d40_err(&pdev->dev, "Failed to prepare/enable clock\n"); goto failure; } /* Get IO for DMAC base address */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "base"); if (!res) goto failure; if (request_mem_region(res->start, resource_size(res), D40_NAME " I/O base") == NULL) goto failure; virtbase = ioremap(res->start, resource_size(res)); if (!virtbase) goto failure; /* This is just a regular AMBA PrimeCell ID actually */ for (pid = 0, i = 0; i < 4; i++) pid |= (readl(virtbase + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8); for (cid = 0, i = 0; i < 4; i++) cid |= (readl(virtbase + resource_size(res) - 0x10 + 4 * i) & 255) << (i * 8); if (cid != AMBA_CID) { d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n"); goto failure; } if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) { d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n", AMBA_MANF_BITS(pid), AMBA_VENDOR_ST); goto failure; } /* * HW revision: * DB8500ed has revision 0 * ? has revision 1 * DB8500v1 has revision 2 * DB8500v2 has revision 3 * AP9540v1 has revision 4 * DB8540v1 has revision 4 */ rev = AMBA_REV_BITS(pid); plat_data = pdev->dev.platform_data; /* The number of physical channels on this HW */ if (plat_data->num_of_phy_chans) num_phy_chans = plat_data->num_of_phy_chans; else num_phy_chans = 4 * (readl(virtbase + D40_DREG_ICFG) & 0x7) + 4; dev_info(&pdev->dev, "hardware revision: %d @ 0x%x with %d physical channels\n", rev, res->start, num_phy_chans); if (rev < 2) { d40_err(&pdev->dev, "hardware revision: %d is not supported", rev); goto failure; } /* Count the number of logical channels in use */ for (i = 0; i < plat_data->dev_len; i++) if (plat_data->dev_rx[i] != 0) num_log_chans++; for (i = 0; i < plat_data->dev_len; i++) if (plat_data->dev_tx[i] != 0) num_log_chans++; base = kzalloc(ALIGN(sizeof(struct d40_base), 4) + (num_phy_chans + num_log_chans + plat_data->memcpy_len) * sizeof(struct d40_chan), GFP_KERNEL); if (base == NULL) { d40_err(&pdev->dev, "Out of memory\n"); goto failure; } base->rev = rev; base->clk = clk; base->num_phy_chans = num_phy_chans; base->num_log_chans = num_log_chans; base->phy_start = res->start; base->phy_size = resource_size(res); base->virtbase = virtbase; base->plat_data = plat_data; base->dev = &pdev->dev; base->phy_chans = ((void *)base) + ALIGN(sizeof(struct d40_base), 4); base->log_chans = &base->phy_chans[num_phy_chans]; if (base->plat_data->num_of_phy_chans == 14) { base->gen_dmac.backup = d40_backup_regs_v4b; base->gen_dmac.backup_size = BACKUP_REGS_SZ_V4B; base->gen_dmac.interrupt_en = D40_DREG_CPCMIS; base->gen_dmac.interrupt_clear = D40_DREG_CPCICR; base->gen_dmac.realtime_en = D40_DREG_CRSEG1; base->gen_dmac.realtime_clear = D40_DREG_CRCEG1; base->gen_dmac.high_prio_en = D40_DREG_CPSEG1; base->gen_dmac.high_prio_clear = D40_DREG_CPCEG1; base->gen_dmac.il = il_v4b; base->gen_dmac.il_size = ARRAY_SIZE(il_v4b); base->gen_dmac.init_reg = dma_init_reg_v4b; base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4b); } else { if (base->rev >= 3) { base->gen_dmac.backup = d40_backup_regs_v4a; base->gen_dmac.backup_size = BACKUP_REGS_SZ_V4A; } base->gen_dmac.interrupt_en = D40_DREG_PCMIS; base->gen_dmac.interrupt_clear = D40_DREG_PCICR; base->gen_dmac.realtime_en = D40_DREG_RSEG1; base->gen_dmac.realtime_clear = D40_DREG_RCEG1; base->gen_dmac.high_prio_en = D40_DREG_PSEG1; base->gen_dmac.high_prio_clear = D40_DREG_PCEG1; base->gen_dmac.il = il_v4a; base->gen_dmac.il_size = ARRAY_SIZE(il_v4a); base->gen_dmac.init_reg = dma_init_reg_v4a; base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4a); } base->phy_res = kzalloc(num_phy_chans * sizeof(struct d40_phy_res), GFP_KERNEL); if (!base->phy_res) goto failure; base->lookup_phy_chans = kzalloc(num_phy_chans * sizeof(struct d40_chan *), GFP_KERNEL); if (!base->lookup_phy_chans) goto failure; if (num_log_chans + plat_data->memcpy_len) { /* * The max number of logical channels are event lines for all * src devices and dst devices */ base->lookup_log_chans = kzalloc(plat_data->dev_len * 2 * sizeof(struct d40_chan *), GFP_KERNEL); if (!base->lookup_log_chans) goto failure; } base->reg_val_backup_chan = kmalloc(base->num_phy_chans * sizeof(d40_backup_regs_chan), GFP_KERNEL); if (!base->reg_val_backup_chan) goto failure; base->lcla_pool.alloc_map = kzalloc(num_phy_chans * sizeof(struct d40_desc *) * D40_LCLA_LINK_PER_EVENT_GRP, GFP_KERNEL); if (!base->lcla_pool.alloc_map) goto failure; base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc), 0, SLAB_HWCACHE_ALIGN, NULL); if (base->desc_slab == NULL) goto failure; return base; failure: if (!clk_ret) clk_disable_unprepare(clk); if (!IS_ERR(clk)) clk_put(clk); if (virtbase) iounmap(virtbase); if (res) release_mem_region(res->start, resource_size(res)); if (virtbase) iounmap(virtbase); if (base) { kfree(base->lcla_pool.alloc_map); kfree(base->reg_val_backup_chan); kfree(base->lookup_log_chans); kfree(base->lookup_phy_chans); kfree(base->phy_res); kfree(base); } return NULL; } static void __init d40_hw_init(struct d40_base *base) { int i; u32 prmseo[2] = {0, 0}; u32 activeo[2] = {0xFFFFFFFF, 0xFFFFFFFF}; u32 pcmis = 0; u32 pcicr = 0; struct d40_reg_val *dma_init_reg = base->gen_dmac.init_reg; u32 reg_size = base->gen_dmac.init_reg_size; for (i = 0; i < reg_size; i++) writel(dma_init_reg[i].val, base->virtbase + dma_init_reg[i].reg); /* Configure all our dma channels to default settings */ for (i = 0; i < base->num_phy_chans; i++) { activeo[i % 2] = activeo[i % 2] << 2; if (base->phy_res[base->num_phy_chans - i - 1].allocated_src == D40_ALLOC_PHY) { activeo[i % 2] |= 3; continue; } /* Enable interrupt # */ pcmis = (pcmis << 1) | 1; /* Clear interrupt # */ pcicr = (pcicr << 1) | 1; /* Set channel to physical mode */ prmseo[i % 2] = prmseo[i % 2] << 2; prmseo[i % 2] |= 1; } writel(prmseo[1], base->virtbase + D40_DREG_PRMSE); writel(prmseo[0], base->virtbase + D40_DREG_PRMSO); writel(activeo[1], base->virtbase + D40_DREG_ACTIVE); writel(activeo[0], base->virtbase + D40_DREG_ACTIVO); /* Write which interrupt to enable */ writel(pcmis, base->virtbase + base->gen_dmac.interrupt_en); /* Write which interrupt to clear */ writel(pcicr, base->virtbase + base->gen_dmac.interrupt_clear); /* These are __initdata and cannot be accessed after init */ base->gen_dmac.init_reg = NULL; base->gen_dmac.init_reg_size = 0; } static int __init d40_lcla_allocate(struct d40_base *base) { struct d40_lcla_pool *pool = &base->lcla_pool; unsigned long *page_list; int i, j; int ret = 0; /* * This is somewhat ugly. We need 8192 bytes that are 18 bit aligned, * To full fill this hardware requirement without wasting 256 kb * we allocate pages until we get an aligned one. */ page_list = kmalloc(sizeof(unsigned long) * MAX_LCLA_ALLOC_ATTEMPTS, GFP_KERNEL); if (!page_list) { ret = -ENOMEM; goto failure; } /* Calculating how many pages that are required */ base->lcla_pool.pages = SZ_1K * base->num_phy_chans / PAGE_SIZE; for (i = 0; i < MAX_LCLA_ALLOC_ATTEMPTS; i++) { page_list[i] = __get_free_pages(GFP_KERNEL, base->lcla_pool.pages); if (!page_list[i]) { d40_err(base->dev, "Failed to allocate %d pages.\n", base->lcla_pool.pages); for (j = 0; j < i; j++) free_pages(page_list[j], base->lcla_pool.pages); goto failure; } if ((virt_to_phys((void *)page_list[i]) & (LCLA_ALIGNMENT - 1)) == 0) break; } for (j = 0; j < i; j++) free_pages(page_list[j], base->lcla_pool.pages); if (i < MAX_LCLA_ALLOC_ATTEMPTS) { base->lcla_pool.base = (void *)page_list[i]; } else { /* * After many attempts and no succees with finding the correct * alignment, try with allocating a big buffer. */ dev_warn(base->dev, "[%s] Failed to get %d pages @ 18 bit align.\n", __func__, base->lcla_pool.pages); base->lcla_pool.base_unaligned = kmalloc(SZ_1K * base->num_phy_chans + LCLA_ALIGNMENT, GFP_KERNEL); if (!base->lcla_pool.base_unaligned) { ret = -ENOMEM; goto failure; } base->lcla_pool.base = PTR_ALIGN(base->lcla_pool.base_unaligned, LCLA_ALIGNMENT); } pool->dma_addr = dma_map_single(base->dev, pool->base, SZ_1K * base->num_phy_chans, DMA_TO_DEVICE); if (dma_mapping_error(base->dev, pool->dma_addr)) { pool->dma_addr = 0; ret = -ENOMEM; goto failure; } writel(virt_to_phys(base->lcla_pool.base), base->virtbase + D40_DREG_LCLA); failure: kfree(page_list); return ret; } static int __init d40_probe(struct platform_device *pdev) { int err; int ret = -ENOENT; struct d40_base *base; struct resource *res = NULL; int num_reserved_chans; u32 val; base = d40_hw_detect_init(pdev); if (!base) goto failure; num_reserved_chans = d40_phy_res_init(base); platform_set_drvdata(pdev, base); spin_lock_init(&base->interrupt_lock); spin_lock_init(&base->execmd_lock); /* Get IO for logical channel parameter address */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcpa"); if (!res) { ret = -ENOENT; d40_err(&pdev->dev, "No \"lcpa\" memory resource\n"); goto failure; } base->lcpa_size = resource_size(res); base->phy_lcpa = res->start; if (request_mem_region(res->start, resource_size(res), D40_NAME " I/O lcpa") == NULL) { ret = -EBUSY; d40_err(&pdev->dev, "Failed to request LCPA region 0x%x-0x%x\n", res->start, res->end); goto failure; } /* We make use of ESRAM memory for this. */ val = readl(base->virtbase + D40_DREG_LCPA); if (res->start != val && val != 0) { dev_warn(&pdev->dev, "[%s] Mismatch LCPA dma 0x%x, def 0x%x\n", __func__, val, res->start); } else writel(res->start, base->virtbase + D40_DREG_LCPA); base->lcpa_base = ioremap(res->start, resource_size(res)); if (!base->lcpa_base) { ret = -ENOMEM; d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); goto failure; } /* If lcla has to be located in ESRAM we don't need to allocate */ if (base->plat_data->use_esram_lcla) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcla_esram"); if (!res) { ret = -ENOENT; d40_err(&pdev->dev, "No \"lcla_esram\" memory resource\n"); goto failure; } base->lcla_pool.base = ioremap(res->start, resource_size(res)); if (!base->lcla_pool.base) { ret = -ENOMEM; d40_err(&pdev->dev, "Failed to ioremap LCLA region\n"); goto failure; } writel(res->start, base->virtbase + D40_DREG_LCLA); } else { ret = d40_lcla_allocate(base); if (ret) { d40_err(&pdev->dev, "Failed to allocate LCLA area\n"); goto failure; } } spin_lock_init(&base->lcla_pool.lock); base->irq = platform_get_irq(pdev, 0); ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base); if (ret) { d40_err(&pdev->dev, "No IRQ defined\n"); goto failure; } pm_runtime_irq_safe(base->dev); pm_runtime_set_autosuspend_delay(base->dev, DMA40_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(base->dev); pm_runtime_enable(base->dev); pm_runtime_resume(base->dev); if (base->plat_data->use_esram_lcla) { base->lcpa_regulator = regulator_get(base->dev, "lcla_esram"); if (IS_ERR(base->lcpa_regulator)) { d40_err(&pdev->dev, "Failed to get lcpa_regulator\n"); base->lcpa_regulator = NULL; goto failure; } ret = regulator_enable(base->lcpa_regulator); if (ret) { d40_err(&pdev->dev, "Failed to enable lcpa_regulator\n"); regulator_put(base->lcpa_regulator); base->lcpa_regulator = NULL; goto failure; } } base->initialized = true; err = d40_dmaengine_init(base, num_reserved_chans); if (err) goto failure; base->dev->dma_parms = &base->dma_parms; err = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE); if (err) { d40_err(&pdev->dev, "Failed to set dma max seg size\n"); goto failure; } d40_hw_init(base); dev_info(base->dev, "initialized\n"); return 0; failure: if (base) { if (base->desc_slab) kmem_cache_destroy(base->desc_slab); if (base->virtbase) iounmap(base->virtbase); if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { iounmap(base->lcla_pool.base); base->lcla_pool.base = NULL; } if (base->lcla_pool.dma_addr) dma_unmap_single(base->dev, base->lcla_pool.dma_addr, SZ_1K * base->num_phy_chans, DMA_TO_DEVICE); if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) free_pages((unsigned long)base->lcla_pool.base, base->lcla_pool.pages); kfree(base->lcla_pool.base_unaligned); if (base->phy_lcpa) release_mem_region(base->phy_lcpa, base->lcpa_size); if (base->phy_start) release_mem_region(base->phy_start, base->phy_size); if (base->clk) { clk_disable_unprepare(base->clk); clk_put(base->clk); } if (base->lcpa_regulator) { regulator_disable(base->lcpa_regulator); regulator_put(base->lcpa_regulator); } kfree(base->lcla_pool.alloc_map); kfree(base->lookup_log_chans); kfree(base->lookup_phy_chans); kfree(base->phy_res); kfree(base); } d40_err(&pdev->dev, "probe failed\n"); return ret; } static struct platform_driver d40_driver = { .driver = { .owner = THIS_MODULE, .name = D40_NAME, .pm = DMA40_PM_OPS, }, }; static int __init stedma40_init(void) { return platform_driver_probe(&d40_driver, d40_probe); } subsys_initcall(stedma40_init);
da088f9ca1e043f1601088c436233e548bd23560
6ff1ea5c8fb7534e1ce0c6d2aac273ffb1c5babd
/lib/Parser/globals.h
48a3511aae5d11455e1f5dd16826d0f6b4aa4063
[ "MIT" ]
permissive
chakra-core/ChakraCore
654e775f42e093e1ebbbc066212bbcdfccab15d5
c3ead3f8a6e0bb8e32e043adc091c68cba5935e9
refs/heads/master
2023-09-02T08:10:10.008146
2023-03-21T21:22:11
2023-03-22T08:47:02
49,086,513
855
185
MIT
2023-07-05T00:15:56
2016-01-05T19:05:31
JavaScript
UTF-8
C
false
false
543
h
globals.h
//------------------------------------------------------------------------------------------------------- // Copyright (C) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. //------------------------------------------------------------------------------------------------------- #pragma once // Builtin symbols. #define HASH_NAME(name, hashCS, hashCI) \ extern const StaticSymLen<sizeof(#name)> g_ssym_##name; #include "objnames.h" #undef HASH_NAME
7a06f6add09d551b7a205b2c18cc5b38c42eb494
1231e1bf4117cfaaa54bd4752cca1bdb71290cec
/ext/stub/requires/external3.zep.h
7bd936ea685c03dc2662656b3a7610e620bbcbd6
[ "MIT" ]
permissive
zephir-lang/zephir
ac53ec68e35d19860a4d80224d94f38a6a5e04b5
6773f19d9b272cafee96b9a30f9b152c28e982ea
refs/heads/development
2023-08-31T10:33:38.621586
2023-02-28T10:27:43
2023-02-28T10:27:43
11,478,636
291
47
MIT
2023-08-28T22:07:11
2013-07-17T14:49:27
PHP
UTF-8
C
false
true
477
h
external3.zep.h
extern zend_class_entry *stub_requires_external3_ce; ZEPHIR_INIT_CLASS(Stub_Requires_External3); PHP_METHOD(Stub_Requires_External3, req); ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stub_requires_external3_req, 0, 2, IS_VOID, 0) ZEND_ARG_INFO(0, path) ZEND_ARG_INFO(0, requires) ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(stub_requires_external3_method_entry) { PHP_ME(Stub_Requires_External3, req, arginfo_stub_requires_external3_req, ZEND_ACC_PUBLIC) PHP_FE_END };
33c5757b53379be45e9e9ad6a7eb43fbe3f03860
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/at91/at91sam9g45/drivers/at91_mci.h
3a4cc1705a48b65744a4842edb8c3893b83e2f32
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
5,813
h
at91_mci.h
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2011-06-09 weety first version */ #ifndef __AT91C_MCI_H__ #define __AT91C_MCI_H__ #define AT91C_MCI_CR 0x00 /* Control Register */ #define AT91C_MCI_MCIEN (1 << 0) /* Multi-Media Interface Enable */ #define AT91C_MCI_MCIDIS (1 << 1) /* Multi-Media Interface Disable */ #define AT91C_MCI_PWSEN (1 << 2) /* Power Save Mode Enable */ #define AT91C_MCI_PWSDIS (1 << 3) /* Power Save Mode Disable */ #define AT91C_MCI_SWRST (1 << 7) /* Software Reset */ #define AT91C_MCI_MR 0x04 /* Mode Register */ #define AT91C_MCI_CLKDIV (0xff << 0) /* Clock Divider */ #define AT91C_MCI_PWSDIV (7 << 8) /* Power Saving Divider */ #define AT91C_MCI_RDPROOF (1 << 11) /* Read Proof Enable [SAM926[03] only] */ #define AT91C_MCI_WRPROOF (1 << 12) /* Write Proof Enable [SAM926[03] only] */ #define AT91C_MCI_PDCFBYTE (1 << 13) /* PDC Force Byte Transfer [SAM926[03] only] */ #define AT91C_MCI_PDCPADV (1 << 14) /* PDC Padding Value */ #define AT91C_MCI_PDCMODE (1 << 15) /* PDC-orientated Mode */ #define AT91C_MCI_BLKLEN (0xfff << 18) /* Data Block Length */ #define AT91C_MCI_DTOR 0x08 /* Data Timeout Register */ #define AT91C_MCI_DTOCYC (0xf << 0) /* Data Timeout Cycle Number */ #define AT91C_MCI_DTOMUL (7 << 4) /* Data Timeout Multiplier */ #define AT91C_MCI_DTOMUL_1 (0 << 4) #define AT91C_MCI_DTOMUL_16 (1 << 4) #define AT91C_MCI_DTOMUL_128 (2 << 4) #define AT91C_MCI_DTOMUL_256 (3 << 4) #define AT91C_MCI_DTOMUL_1K (4 << 4) #define AT91C_MCI_DTOMUL_4K (5 << 4) #define AT91C_MCI_DTOMUL_64K (6 << 4) #define AT91C_MCI_DTOMUL_1M (7 << 4) #define AT91C_MCI_SDCR 0x0c /* SD Card Register */ #define AT91C_MCI_SDCSEL (3 << 0) /* SD Card Selector */ #define AT91C_MCI_SDCBUS (1 << 7) /* 1-bit or 4-bit bus */ #define AT91C_MCI_ARGR 0x10 /* Argument Register */ #define AT91C_MCI_CMDR 0x14 /* Command Register */ #define AT91C_MCI_CMDNB (0x3f << 0) /* Command Number */ #define AT91C_MCI_RSPTYP (3 << 6) /* Response Type */ #define AT91C_MCI_RSPTYP_NONE (0 << 6) #define AT91C_MCI_RSPTYP_48 (1 << 6) #define AT91C_MCI_RSPTYP_136 (2 << 6) #define AT91C_MCI_SPCMD (7 << 8) /* Special Command */ #define AT91C_MCI_SPCMD_NONE (0 << 8) #define AT91C_MCI_SPCMD_INIT (1 << 8) #define AT91C_MCI_SPCMD_SYNC (2 << 8) #define AT91C_MCI_SPCMD_ICMD (4 << 8) #define AT91C_MCI_SPCMD_IRESP (5 << 8) #define AT91C_MCI_OPDCMD (1 << 11) /* Open Drain Command */ #define AT91C_MCI_MAXLAT (1 << 12) /* Max Latency for Command to Response */ #define AT91C_MCI_TRCMD (3 << 16) /* Transfer Command */ #define AT91C_MCI_TRCMD_NONE (0 << 16) #define AT91C_MCI_TRCMD_START (1 << 16) #define AT91C_MCI_TRCMD_STOP (2 << 16) #define AT91C_MCI_TRDIR (1 << 18) /* Transfer Direction */ #define AT91C_MCI_TRTYP (3 << 19) /* Transfer Type */ #define AT91C_MCI_TRTYP_BLOCK (0 << 19) #define AT91C_MCI_TRTYP_MULTIPLE (1 << 19) #define AT91C_MCI_TRTYP_STREAM (2 << 19) #define AT91C_MCI_BLKR 0x18 /* Block Register */ #define AT91C_MCI_BLKR_BCNT(n) ((0xffff & (n)) << 0) /* Block count */ #define AT91C_MCI_BLKR_BLKLEN(n) ((0xffff & (n)) << 16) /* Block lenght */ #define AT91C_MCI_RSPR(n) (0x20 + ((n) * 4)) /* Response Registers 0-3 */ #define AT91C_MCR_RDR 0x30 /* Receive Data Register */ #define AT91C_MCR_TDR 0x34 /* Transmit Data Register */ #define AT91C_MCI_SR 0x40 /* Status Register */ #define AT91C_MCI_CMDRDY (1U << 0) /* Command Ready */ #define AT91C_MCI_RXRDY (1U << 1) /* Receiver Ready */ #define AT91C_MCI_TXRDY (1U << 2) /* Transmit Ready */ #define AT91C_MCI_BLKE (1U << 3) /* Data Block Ended */ #define AT91C_MCI_DTIP (1U << 4) /* Data Transfer in Progress */ #define AT91C_MCI_NOTBUSY (1U << 5) /* Data Not Busy */ #define AT91C_MCI_ENDRX (1U << 6) /* End of RX Buffer */ #define AT91C_MCI_ENDTX (1U << 7) /* End fo TX Buffer */ #define AT91C_MCI_SDIOIRQA (1U << 8) /* SDIO Interrupt for Slot A */ #define AT91C_MCI_SDIOIRQB (1U << 9) /* SDIO Interrupt for Slot B */ #define AT91C_MCI_RXBUFF (1U << 14) /* RX Buffer Full */ #define AT91C_MCI_TXBUFE (1U << 15) /* TX Buffer Empty */ #define AT91C_MCI_RINDE (1U << 16) /* Response Index Error */ #define AT91C_MCI_RDIRE (1U << 17) /* Response Direction Error */ #define AT91C_MCI_RCRCE (1U << 18) /* Response CRC Error */ #define AT91C_MCI_RENDE (1U << 19) /* Response End Bit Error */ #define AT91C_MCI_RTOE (1U << 20) /* Reponse Time-out Error */ #define AT91C_MCI_DCRCE (1U << 21) /* Data CRC Error */ #define AT91C_MCI_DTOE (1U << 22) /* Data Time-out Error */ #define AT91C_MCI_OVRE (1U << 30) /* Overrun */ #define AT91C_MCI_UNRE (1U << 31) /* Underrun */ #define AT91C_MCI_IER 0x44 /* Interrupt Enable Register */ #define AT91C_MCI_IDR 0x48 /* Interrupt Disable Register */ #define AT91C_MCI_IMR 0x4c /* Interrupt Mask Register */ extern int at91_mci_init(void); #endif
533ac164f5897d59bdfe9b6a8b613734964defb2
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
/src/native/external/libunwind/tests/Gtest-dyn1.c
bc7dc9cf7feb9373ea688cfeeda3c9ef28c740d0
[ "MIT" ]
permissive
dotnet/runtime
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
47bb554d298e1e34c4e3895d7731e18ad1c47d02
refs/heads/main
2023-09-03T15:35:46.493337
2023-09-03T08:13:23
2023-09-03T08:13:23
210,716,005
13,765
5,179
MIT
2023-09-14T21:58:52
2019-09-24T23:36:39
C#
UTF-8
C
false
false
5,849
c
Gtest-dyn1.c
/* libunwind - a platform-independent unwind library Copyright (C) 2002-2003 Hewlett-Packard Co Contributed by David Mosberger-Tang <davidm@hpl.hp.com> This file is part of libunwind. 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. */ /* This file tests dynamic code-generation via function-cloning. */ #include "flush-cache.h" #include "compiler.h" #include <libunwind.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/mman.h> #if UNW_TARGET_ARM #define MAX_FUNC_SIZE 96 /* FIXME: arch/compiler dependent */ #else #define MAX_FUNC_SIZE 2048 /* max. size of cloned function */ #endif #define panic(args...) \ { fprintf (stderr, args); exit (-1); } typedef void (*template_t) (int, void (*)(), int (*)(const char *, ...), const char *, const char **); int verbose; static const char *strarr[] = { "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", NULL }; #ifdef __ia64__ struct fdesc { long code; long gp; }; # define get_fdesc(fdesc,func) (fdesc = *(struct fdesc *) &(func)) # define get_funcp(fdesc) ((template_t) &(fdesc)) # define get_gp(fdesc) ((fdesc).gp) #elif __arm__ struct fdesc { long code; long is_thumb; }; /* Workaround GCC bug: https://bugs.launchpad.net/gcc-linaro/+bug/721531 */ # define get_fdesc(fdesc,func) ({long tmp = (long) &(func); \ (fdesc).code = (long) &(func) & ~0x1; \ (fdesc).is_thumb = tmp & 0x1;}) /*# define get_fdesc(fdesc,func) ({(fdesc).code = (long) &(func) & ~0x1; \ (fdesc).is_thumb = (long) &(func) & 0x1;})*/ # define get_funcp(fdesc) ((template_t) ((fdesc).code | (fdesc).is_thumb)) # define get_gp(fdesc) (0) #else struct fdesc { long code; }; # define get_fdesc(fdesc,func) (fdesc.code = (long) &(func)) # define get_funcp(fdesc) ((template_t) (fdesc).code) # define get_gp(fdesc) (0) #endif void template (int i, template_t self, int (*printer)(const char *, ...), const char *fmt, const char **arr) { (*printer) (fmt, arr[11 - i][0], arr[11 - i] + 1); if (i > 0) (*self) (i - 1, self, printer, fmt, arr); } static void sighandler (int signal) { unw_cursor_t cursor; char name[128], off[32]; unw_word_t ip, offset; unw_context_t uc; int count; if (verbose) printf ("caught signal %d\n", signal); unw_getcontext (&uc); unw_init_local (&cursor, &uc); count = 0; while (!unw_is_signal_frame (&cursor)) { if (unw_step (&cursor) < 0) panic ("failed to find signal frame!\n"); if (count++ > 20) { panic ("Too many steps to the signal frame (%d)\n", count); break; } } unw_step (&cursor); count = 0; do { unw_get_reg (&cursor, UNW_REG_IP, &ip); name[0] = '\0'; off[0] = '\0'; if (unw_get_proc_name (&cursor, name, sizeof (name), &offset) == 0 && offset > 0) snprintf (off, sizeof (off), "+0x%lx", (long) offset); if (verbose) printf ("ip = %lx <%s%s>\n", (long) ip, name, off); ++count; if (count > 20) { panic ("Too many steps (%d)\n", count); break; } } while (unw_step (&cursor) > 0); if (count != 13) panic ("FAILURE: expected 13, not %d frames below signal frame\n", count); if (verbose) printf ("SUCCESS\n"); exit (0); } int dev_null (const char *format UNUSED, ...) { return 0; } int main (int argc, char *argv[] UNUSED) { unw_dyn_region_info_t *region; unw_dyn_info_t di; struct fdesc fdesc; template_t funcp; void *mem; if (argc > 1) ++verbose; mem = malloc (getpagesize ()); get_fdesc (fdesc, template); if (verbose) printf ("old code @ %p, new code @ %p\n", (void *) fdesc.code, mem); memcpy (mem, (void *) fdesc.code, MAX_FUNC_SIZE); mprotect ((void *) ((long) mem & ~(getpagesize () - 1)), 2*getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC); flush_cache (mem, MAX_FUNC_SIZE); signal (SIGSEGV, sighandler); /* register the new function: */ region = alloca (_U_dyn_region_info_size (2)); region->next = NULL; region->insn_count = 3 * (MAX_FUNC_SIZE / 16); region->op_count = 2; _U_dyn_op_alias (&region->op[0], 0, -1, fdesc.code); _U_dyn_op_stop (&region->op[1]); memset (&di, 0, sizeof (di)); di.start_ip = (long) mem; di.end_ip = (long) mem + 16*region->insn_count/3; di.gp = get_gp (fdesc); di.format = UNW_INFO_FORMAT_DYNAMIC; di.u.pi.name_ptr = (unw_word_t) "copy_of_template"; di.u.pi.regions = region; _U_dyn_register (&di); /* call new function: */ fdesc.code = (long) mem; funcp = get_funcp (fdesc); if (verbose) (*funcp) (10, funcp, printf, "iteration %c%s\n", strarr); else (*funcp) (10, funcp, dev_null, "iteration %c%s\n", strarr); _U_dyn_cancel (&di); return -1; }
19e7e107e52740756c14012f7b50cd781d4e4c3c
5eff7a36d9a9917dce9111f0c3074375fe6f7656
/driver/xf86-video-intel/test/basic-tiledrect.c
9af86a9f909968022ed47ad2536252ebd1e7d380
[ "HPND-sell-variant", "MIT" ]
permissive
openbsd/xenocara
cb392d02ebba06f6ff7d826fd8a89aa3b8401779
a012b5de33ea0b977095d77316a521195b26cc6b
refs/heads/master
2023-08-25T12:16:58.862008
2023-08-12T16:16:25
2023-08-12T16:16:25
66,967,384
177
66
null
2023-07-22T18:12:37
2016-08-30T18:36:01
C
UTF-8
C
false
false
9,658
c
basic-tiledrect.c
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include "test.h" static const unsigned char data[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, }; static struct bitmap { int width, height; struct cache { Display *dpy; Pixmap pixmap; } cached[2]; } bitmaps[] = { { 1, 1, }, { 1, 2, }, { 2, 3, }, { 3, 2, }, { 4, 4, }, { 6, 6, }, { 8, 8, }, { 8, 4, }, { 8, 2, }, { 8, 1, }, { 4, 8, }, { 2, 8, }, { 1, 8, }, { 16, 16, }, { 15, 17, }, { 24, 24, }, { 32, 32, }, { 16, 8, }, { 16, 4, }, { 16, 2, }, { 16, 1, }, { 8, 16, }, { 4, 16, }, { 2, 16, }, { 1, 16, }, }; static void reset_cache(void) { int n, m; for (n = 0; n < sizeof(bitmaps)/sizeof(bitmaps[0]); n++) { for (m = 0; m < 2; m++) { if (bitmaps[n].cached[m].dpy) { XFreePixmap(bitmaps[n].cached[m].dpy, bitmaps[n].cached[m].pixmap); bitmaps[n].cached[m].dpy = NULL; } } } } static void fill_rect(struct test_target *t, uint8_t alu, XRectangle *clip, int nclip, uint8_t tile, int tx, int ty, int x, int y, int w, int h, uint32_t fg, uint32_t bg) { Display *dpy = t->dpy->dpy; struct bitmap *b = &bitmaps[(tile >> 1) % (sizeof(bitmaps)/sizeof(bitmaps[0]))]; XGCValues val; GC gc; int n; val.function = alu; val.function = GXcopy; val.fill_style = FillTiled; val.ts_x_origin = tx; val.ts_y_origin = ty; if (tile & 1) { val.tile = 0; for (n = 0; n < 2; n++) { if (b->cached[n].dpy == dpy) { val.tile = b->cached[n].pixmap; break; } } if (val.tile == 0) { val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, (char *)data, b->width, b->height, fg, bg, t->depth); for (n = 0; n < 2; n++) { if (b->cached[n].dpy == NULL) { b->cached[n].dpy = dpy; b->cached[n].pixmap = val.tile; break; } } } } else val.tile = XCreatePixmapFromBitmapData(dpy, t->draw, (char *)data, b->width, b->height, fg, bg, t->depth); gc = XCreateGC(dpy, t->draw, GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin | GCTile | GCFunction, &val); if (nclip) XSetClipRectangles(dpy, gc, 0, 0, clip, nclip, Unsorted); XFillRectangle(dpy, t->draw, gc, x, y, w, h); XFreeGC(dpy, gc); if ((tile & 1) == 0) XFreePixmap(dpy, val.tile); } static void clear(struct test_target *tt) { XRenderColor render_color = {0}; XRenderFillRectangle(tt->dpy->dpy, PictOpClear, tt->picture, &render_color, 0, 0, tt->width, tt->height); } static void small_tests(struct test *t, int reps, int sets, enum target target) { struct test_target out, ref; int r, s; printf("Testing small tiled fills (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->out, target, &out); clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { int x = rand() % out.width; int y = rand() % out.height; int w = rand() % out.width; int h = rand() % 8; int tx = rand() % (2*out.width) - out.width; int ty = rand() % (2*out.height) - out.height; uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); fill_rect(&ref, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, h, w, fg, bg); fill_rect(&ref, alu, NULL, 0, tile, tx, ty, x, y, h, w, fg, bg); } test_compare(t, out.draw, out.format, ref.draw, ref.format, 0, 0, out.width, out.height, ""); if (target == CHILD) { int x = rand() % (t->out.width-out.width); int y = rand() % (t->out.height-out.height); clear(&out); clear(&ref); XMoveWindow(out.dpy->dpy, out.draw, x, y); XMoveWindow(ref.dpy->dpy, ref.draw, x, y); clear(&out); clear(&ref); } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void unclipped_tests(struct test *t, int reps, int sets, enum target target) { struct test_target out, ref; int r, s; printf("Testing unclipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->out, target, &out); clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { int x = rand() % out.width; int y = rand() % out.height; int w = rand() % (out.width - x); int h = rand() % (out.height - y); int tx = rand() % (2*out.width) - out.width; int ty = rand() % (2*out.height) - out.height; uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); fill_rect(&ref, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); } test_compare(t, out.draw, out.format, ref.draw, ref.format, 0, 0, out.width, out.height, ""); if (target == CHILD) { int x = rand() % (t->out.width-out.width); int y = rand() % (t->out.height-out.height); clear(&out); clear(&ref); XMoveWindow(out.dpy->dpy, out.draw, x, y); XMoveWindow(ref.dpy->dpy, ref.draw, x, y); clear(&out); clear(&ref); } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void simple_clip_tests(struct test *t, int reps, int sets, enum target target) { struct test_target out, ref; int r, s; printf("Testing simple clipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->out, target, &out); clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { for (r = 0; r < reps; r++) { int x = rand() % (2*out.width) - out.width; int y = rand() % (2*out.height) - out.height; int w = rand() % (2*out.width); int h = rand() % (2*out.height); int tx = rand() % (2*out.width) - out.width; int ty = rand() % (2*out.height) - out.height; uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); fill_rect(&out, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); fill_rect(&ref, alu, NULL, 0, tile, tx, ty, x, y, w, h, fg, bg); } test_compare(t, out.draw, out.format, ref.draw, ref.format, 0, 0, out.width, out.height, ""); if (target == CHILD) { int x = rand() % (t->out.width-out.width); int y = rand() % (t->out.height-out.height); clear(&out); clear(&ref); XMoveWindow(out.dpy->dpy, out.draw, x, y); XMoveWindow(ref.dpy->dpy, ref.draw, x, y); clear(&out); clear(&ref); } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } static void complex_clip_tests(struct test *t, int reps, int sets, enum target target) { struct test_target out, ref; XRectangle *clip; int nclip, r, s; printf("Testing complex clipped tiled fills (%s): ", test_target_name(target)); fflush(stdout); test_target_create_render(&t->out, target, &out); clear(&out); test_target_create_render(&t->ref, target, &ref); clear(&ref); for (s = 0; s < sets; s++) { nclip = (rand() % 16) + 2; clip = malloc(sizeof(XRectangle)*nclip); for (r = 0; r < nclip; r++) { clip[r].x = rand() % out.width; clip[r].y = rand() % out.height; clip[r].width = rand() % (out.width - clip[r].x); clip[r].height = rand() % (out.height - clip[r].y); } for (r = 0; r < reps; r++) { int x = rand() % (2*out.width) - out.width; int y = rand() % (2*out.height) - out.height; int w = rand() % (2*out.width); int h = rand() % (2*out.height); int tx = rand() % (2*out.width) - out.width; int ty = rand() % (2*out.height) - out.height; uint8_t tile = rand(); uint8_t alu = rand() % (GXset + 1); uint32_t fg = rand(); uint32_t bg = rand(); fill_rect(&out, alu, clip, nclip, tile, tx, ty, x, y, w, h, fg, bg); fill_rect(&ref, alu, clip, nclip, tile, tx, ty, x, y, w, h, fg, bg); } test_compare(t, out.draw, out.format, ref.draw, ref.format, 0, 0, out.width, out.height, ""); free(clip); if (target == CHILD) { int x = rand() % (t->out.width-out.width); int y = rand() % (t->out.height-out.height); clear(&out); clear(&ref); XMoveWindow(out.dpy->dpy, out.draw, x, y); XMoveWindow(ref.dpy->dpy, ref.draw, x, y); clear(&out); clear(&ref); } } printf("passed [%d iterations x %d]\n", reps, sets); test_target_destroy_render(&t->out, &out); test_target_destroy_render(&t->ref, &ref); } int main(int argc, char **argv) { struct test test; int i; test_init(&test, argc, argv); for (i = 0; i <= DEFAULT_ITERATIONS; i++) { int reps = REPS(i), sets = SETS(i); enum target t; for (t = TARGET_FIRST; t <= TARGET_LAST; t++) { small_tests(&test, reps, sets, t); unclipped_tests(&test, reps, sets, t); simple_clip_tests(&test, reps, sets, t); complex_clip_tests(&test, reps, sets, t); reset_cache(); } } return 0; }
0b13277f5953025fc38a65c53c1791a8a3e1c181
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/sysutils/mate-power-manager/files/patch-src_gpm-backlight-helper.c
a3a21bd10aedf8c07cad7ae490d21e8975fd342a
[ "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
573
c
patch-src_gpm-backlight-helper.c
This code is linux specific. Disable it so users don't get warnings like this: ** (mate-power-backlight-helper:82740): WARNING **: failed to find any devices: Error opening directory '/sys/class/backlight': No such file or directory --- src/gpm-backlight-helper.c.orig 2015-07-22 11:33:09.058354000 +0200 +++ src/gpm-backlight-helper.c 2015-07-22 11:34:39.476169000 +0200 @@ -145,6 +145,10 @@ out: gint main (gint argc, gchar *argv[]) { +#ifdef __FreeBSD__ + return GCM_BACKLIGHT_HELPER_EXIT_CODE_FAILED; +#endif + GOptionContext *context; gint uid; gint euid;
6094139817c484cebc99c5bfc62a3b74c044666f
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/games/libretro-cap32/files/patch-libretro_retro__events.c
88aced901382c5511e30bcea01014632744926d0
[ "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
355
c
patch-libretro_retro__events.c
--- libretro/retro_events.c.orig 2021-02-19 01:54:05 UTC +++ libretro/retro_events.c @@ -56,6 +56,8 @@ const uint8_t bit_values[8] = {0x01, 0x02, 0x04, 0x08, #define MAX_BUTTONS 14 #define MAX_PADCFG 4 +bool (*ev_events)(void); + static uint8_t keyboard_translation[MAX_KEYSYMS]; unsigned int last_input[PORTS_NUMBER] = {0,0}; uint32_t padnum = 0;
34ebc86bfa279edd796406e45fbbf6648ba1cec4
42ab733e143d02091d13424fb4df16379d5bba0d
/third_party/libsdl2/src/audio/fusionsound/SDL_fsaudio.c
36fa5c54578b46b6977ee29986cbb13a7a8681dd
[ "Zlib", "Apache-2.0", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
google/filament
11cd37ac68790fcf8b33416b7d8d8870e48181f0
0aa0efe1599798d887fa6e33c412c09e81bea1bf
refs/heads/main
2023-08-29T17:58:22.496956
2023-08-28T17:27:38
2023-08-28T17:27:38
143,455,116
16,631
1,961
Apache-2.0
2023-09-14T16:23:39
2018-08-03T17:26:00
C++
UTF-8
C
false
false
8,730
c
SDL_fsaudio.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if SDL_AUDIO_DRIVER_FUSIONSOUND /* !!! FIXME: why is this is SDL_FS_* instead of FUSIONSOUND_*? */ /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H #include <signal.h> #endif #include <unistd.h> #include "SDL_timer.h" #include "SDL_audio.h" #include "../SDL_audio_c.h" #include "SDL_fsaudio.h" #include <fusionsound/fusionsound_version.h> /* #define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" */ #ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else #define SDL_NAME(X) X #endif #if (FUSIONSOUND_MAJOR_VERSION == 1) && (FUSIONSOUND_MINOR_VERSION < 1) typedef DFBResult DirectResult; #endif /* Buffers to use - more than 2 gives a lot of latency */ #define FUSION_BUFFERS (2) #ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC static const char *fs_library = SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC; static void *fs_handle = NULL; static DirectResult (*SDL_NAME(FusionSoundInit)) (int *argc, char *(*argv[])); static DirectResult (*SDL_NAME(FusionSoundCreate)) (IFusionSound ** ret_interface); #define SDL_FS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } static struct { const char *name; void **func; } fs_functions[] = { /* *INDENT-OFF* */ SDL_FS_SYM(FusionSoundInit), SDL_FS_SYM(FusionSoundCreate), /* *INDENT-ON* */ }; #undef SDL_FS_SYM static void UnloadFusionSoundLibrary() { if (fs_handle != NULL) { SDL_UnloadObject(fs_handle); fs_handle = NULL; } } static int LoadFusionSoundLibrary(void) { int i, retval = -1; if (fs_handle == NULL) { fs_handle = SDL_LoadObject(fs_library); if (fs_handle != NULL) { retval = 0; for (i = 0; i < SDL_arraysize(fs_functions); ++i) { *fs_functions[i].func = SDL_LoadFunction(fs_handle, fs_functions[i].name); if (!*fs_functions[i].func) { retval = -1; UnloadFusionSoundLibrary(); break; } } } } return retval; } #else static void UnloadFusionSoundLibrary() { return; } static int LoadFusionSoundLibrary(void) { return 0; } #endif /* SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */ /* This function waits until it is possible to write a full sound buffer */ static void SDL_FS_WaitDevice(_THIS) { this->hidden->stream->Wait(this->hidden->stream, this->hidden->mixsamples); } static void SDL_FS_PlayDevice(_THIS) { DirectResult ret; ret = this->hidden->stream->Write(this->hidden->stream, this->hidden->mixbuf, this->hidden->mixsamples); /* If we couldn't write, assume fatal error for now */ if (ret) { SDL_OpenedAudioDeviceDisconnected(this); } #ifdef DEBUG_AUDIO fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen); #endif } static Uint8 * SDL_FS_GetDeviceBuf(_THIS) { return (this->hidden->mixbuf); } static void SDL_FS_CloseDevice(_THIS) { if (this->hidden->stream) { this->hidden->stream->Release(this->hidden->stream); } if (this->hidden->fs) { this->hidden->fs->Release(this->hidden->fs); } SDL_free(this->hidden->mixbuf); SDL_free(this->hidden); } static int SDL_FS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) { int bytes; SDL_AudioFormat test_format = 0, format = 0; FSSampleFormat fs_format; FSStreamDescription desc; DirectResult ret; /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); /* Try for a closest match on audio format */ for (test_format = SDL_FirstAudioFormat(this->spec.format); !format && test_format;) { #ifdef DEBUG_AUDIO fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: fs_format = FSSF_U8; bytes = 1; format = 1; break; case AUDIO_S16SYS: fs_format = FSSF_S16; bytes = 2; format = 1; break; case AUDIO_S32SYS: fs_format = FSSF_S32; bytes = 4; format = 1; break; case AUDIO_F32SYS: fs_format = FSSF_FLOAT; bytes = 4; format = 1; break; default: format = 0; break; } if (!format) { test_format = SDL_NextAudioFormat(); } } if (format == 0) { return SDL_SetError("Couldn't find any hardware audio formats"); } this->spec.format = test_format; /* Retrieve the main sound interface. */ ret = SDL_NAME(FusionSoundCreate) (&this->hidden->fs); if (ret) { return SDL_SetError("Unable to initialize FusionSound: %d", ret); } this->hidden->mixsamples = this->spec.size / bytes / this->spec.channels; /* Fill stream description. */ desc.flags = FSSDF_SAMPLERATE | FSSDF_BUFFERSIZE | FSSDF_CHANNELS | FSSDF_SAMPLEFORMAT | FSSDF_PREBUFFER; desc.samplerate = this->spec.freq; desc.buffersize = this->spec.size * FUSION_BUFFERS; desc.channels = this->spec.channels; desc.prebuffer = 10; desc.sampleformat = fs_format; ret = this->hidden->fs->CreateStream(this->hidden->fs, &desc, &this->hidden->stream); if (ret) { return SDL_SetError("Unable to create FusionSoundStream: %d", ret); } /* See what we got */ desc.flags = FSSDF_SAMPLERATE | FSSDF_BUFFERSIZE | FSSDF_CHANNELS | FSSDF_SAMPLEFORMAT; ret = this->hidden->stream->GetDescription(this->hidden->stream, &desc); this->spec.freq = desc.samplerate; this->spec.size = desc.buffersize / FUSION_BUFFERS * bytes * desc.channels; this->spec.channels = desc.channels; /* Calculate the final parameters for this audio specification */ SDL_CalculateAudioSpec(&this->spec); /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); /* We're ready to rock and roll. :-) */ return 0; } static void SDL_FS_Deinitialize(void) { UnloadFusionSoundLibrary(); } static int SDL_FS_Init(SDL_AudioDriverImpl * impl) { if (LoadFusionSoundLibrary() < 0) { return 0; } else { DirectResult ret; ret = SDL_NAME(FusionSoundInit) (NULL, NULL); if (ret) { UnloadFusionSoundLibrary(); SDL_SetError ("FusionSound: SDL_FS_init failed (FusionSoundInit: %d)", ret); return 0; } } /* Set the function pointers */ impl->OpenDevice = SDL_FS_OpenDevice; impl->PlayDevice = SDL_FS_PlayDevice; impl->WaitDevice = SDL_FS_WaitDevice; impl->GetDeviceBuf = SDL_FS_GetDeviceBuf; impl->CloseDevice = SDL_FS_CloseDevice; impl->Deinitialize = SDL_FS_Deinitialize; impl->OnlyHasDefaultOutputDevice = 1; return 1; /* this audio target is available. */ } AudioBootStrap FUSIONSOUND_bootstrap = { "fusionsound", "FusionSound", SDL_FS_Init, 0 }; #endif /* SDL_AUDIO_DRIVER_FUSIONSOUND */ /* vi: set ts=4 sw=4 expandtab: */
7904076829f254340124fb793dbc112002212cae
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/third_party/python/Modules/config.c
1751e17be4bf278f88f37bc57f108ce1acbaabd4
[ "Python-2.0", "GPL-1.0-or-later", "LicenseRef-scancode-python-cwi", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-other-copyleft", "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
1,876
c
config.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "third_party/python/Include/import.h" #include "third_party/python/Include/object.h" /* clang-format off */ PyObject *PyInit_posix(void); PyObject *PyInit__codecs(void); PyObject *PyInit_itertools(void); PyObject *PyInit__io(void); PyObject *PyInit__weakref(void); PyObject *PyMarshal_Init(void); PyObject *PyInit__ast(void); PyObject *PyInit_gc(void); PyObject *_PyWarnings_Init(void); PyObject *PyInit__string(void); PyObject *PyInit__thread(void); _Alignas(16) _Section(".rodata.pytab.0") const struct _inittab _PyImport_Inittab[0]; _Alignas(16) _Section(".rodata.pytab.2") const struct _inittab _PyImport_Inittab2[] = { {"posix", PyInit_posix}, {"_codecs", PyInit__codecs}, {"itertools", PyInit_itertools}, {"_io", PyInit__io}, {"_thread", PyInit__thread}, {"_weakref", PyInit__weakref}, {"marshal", PyMarshal_Init}, {"_imp", PyInit_imp}, {"_ast", PyInit__ast}, {"builtins", NULL}, {"sys", NULL}, {"gc", PyInit_gc}, {"_warnings", _PyWarnings_Init}, {"_string", PyInit__string}, {0} };
4a4da71cf6d2790d4211ee3bbb975c5c9444b9d2
7c857119fe1505b1d80d6e62969661c06dc1a2f4
/NetworkPkg/Mtftp4Dxe/Mtftp4Option.c
d97f157f174472811bfc6cedf3c1727628e7801c
[ "BSD-2-Clause" ]
permissive
CloverHackyColor/CloverBootloader
7042ca7dd6b513d22be591a295e49071ae1482ee
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
refs/heads/master
2023-08-30T22:14:34.590134
2023-08-27T19:14:02
2023-08-27T19:14:02
205,810,121
4,734
770
BSD-2-Clause
2023-09-03T12:41:33
2019-09-02T08:22:14
C
UTF-8
C
false
false
13,704
c
Mtftp4Option.c
/** @file Routines to process MTFTP4 options. Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "Mtftp4Impl.h" CHAR8 *mMtftp4SupportedOptions[MTFTP4_SUPPORTED_OPTIONS] = { "blksize", "windowsize", "timeout", "tsize", "multicast" }; /** Check whether two ascii strings are equel, ignore the case. @param Str1 The first ascii string @param Str2 The second ascii string @retval TRUE Two strings are equal when case is ignored. @retval FALSE Two string are not equal. **/ BOOLEAN NetStringEqualNoCase ( IN UINT8 *Str1, IN UINT8 *Str2 ) { UINT8 Ch1; UINT8 Ch2; ASSERT ((Str1 != NULL) && (Str2 != NULL)); for (; (*Str1 != '\0') && (*Str2 != '\0'); Str1++, Str2++) { Ch1 = *Str1; Ch2 = *Str2; // // Convert them to lower case then compare two // if (('A' <= Ch1) && (Ch1 <= 'Z')) { Ch1 += 'a' - 'A'; } if (('A' <= Ch2) && (Ch2 <= 'Z')) { Ch2 += 'a' - 'A'; } if (Ch1 != Ch2) { return FALSE; } } return (BOOLEAN) (*Str1 == *Str2); } /** Convert a string to a UINT32 number. @param Str The string to convert from @return The number get from the string **/ UINT32 NetStringToU32 ( IN UINT8 *Str ) { UINT32 Num; ASSERT (Str != NULL); Num = 0; for (; NET_IS_DIGIT (*Str); Str++) { Num = Num * 10 + (*Str - '0'); } return Num; } /** Convert a string of the format "192.168.0.1" to an IP address. @param Str The string representation of IP @param Ip The varible to get IP. @retval EFI_INVALID_PARAMETER The IP string is invalid. @retval EFI_SUCCESS The IP is parsed into the Ip **/ EFI_STATUS NetStringToIp ( IN UINT8 *Str, OUT IP4_ADDR *Ip ) { UINT32 Byte; UINT32 Addr; UINTN Index; *Ip = 0; Addr = 0; for (Index = 0; Index < 4; Index++) { if (!NET_IS_DIGIT (*Str)) { return EFI_INVALID_PARAMETER; } Byte = NetStringToU32 (Str); if (Byte > 255) { return EFI_INVALID_PARAMETER; } Addr = (Addr << 8) | Byte; // // Skip all the digitals and check whether the sepeator is the dot // while (NET_IS_DIGIT (*Str)) { Str++; } if ((Index < 3) && (*Str != '.')) { return EFI_INVALID_PARAMETER; } Str++; } *Ip = Addr; return EFI_SUCCESS; } /** Go through the packet to fill the Options array with the start addresses of each MTFTP option name/value pair. @param Packet The packet to check @param PacketLen The packet's length @param Count The size of the Options on input. The actual options on output @param Options The option array to fill in @retval EFI_INVALID_PARAMETER The packet is mal-formated @retval EFI_BUFFER_TOO_SMALL The Options array is too small @retval EFI_SUCCESS The packet has been parsed into the Options array. **/ EFI_STATUS Mtftp4FillOptions ( IN EFI_MTFTP4_PACKET *Packet, IN UINT32 PacketLen, IN OUT UINT32 *Count, OUT EFI_MTFTP4_OPTION *Options OPTIONAL ) { UINT8 *Cur; UINT8 *Last; UINT8 Num; UINT8 *Name; UINT8 *Value; Num = 0; Cur = (UINT8 *) Packet + MTFTP4_OPCODE_LEN; Last = (UINT8 *) Packet + PacketLen - 1; // // process option name and value pairs. The last byte is always zero // while (Cur < Last) { Name = Cur; while (*Cur != 0) { Cur++; } if (Cur == Last) { return EFI_INVALID_PARAMETER; } Value = ++Cur; while (*Cur != 0) { Cur++; } Num++; if ((Options != NULL) && (Num <= *Count)) { Options[Num - 1].OptionStr = Name; Options[Num - 1].ValueStr = Value; } Cur++; } if ((*Count < Num) || (Options == NULL)) { *Count = Num; return EFI_BUFFER_TOO_SMALL; } *Count = Num; return EFI_SUCCESS; } /** Allocate and fill in a array of Mtftp options from the Packet. It first calls Mtftp4FillOption to get the option number, then allocate the array, at last, call Mtftp4FillOption again to save the options. @param Packet The packet to parse @param PacketLen The length of the packet @param OptionCount The number of options in the packet @param OptionList The point to get the option array. @retval EFI_INVALID_PARAMETER The parametera are invalid or packet isn't a well-formated OACK packet. @retval EFI_SUCCESS The option array is build @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the array **/ EFI_STATUS Mtftp4ExtractOptions ( IN EFI_MTFTP4_PACKET *Packet, IN UINT32 PacketLen, OUT UINT32 *OptionCount, OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL ) { EFI_STATUS Status; *OptionCount = 0; if (OptionList != NULL) { *OptionList = NULL; } if (NTOHS (Packet->OpCode) != EFI_MTFTP4_OPCODE_OACK) { return EFI_INVALID_PARAMETER; } if (PacketLen == MTFTP4_OPCODE_LEN) { return EFI_SUCCESS; } // // The last byte must be zero to terminate the options // if (*((UINT8 *) Packet + PacketLen - 1) != 0) { return EFI_INVALID_PARAMETER; } // // Get the number of options // Status = Mtftp4FillOptions (Packet, PacketLen, OptionCount, NULL); if ((Status == EFI_SUCCESS) || (Status != EFI_BUFFER_TOO_SMALL)) { return Status; } // // Allocate memory for the options, then call Mtftp4FillOptions to // fill it if caller want that. // if (OptionList == NULL) { return EFI_SUCCESS; } *OptionList = AllocatePool (*OptionCount * sizeof (EFI_MTFTP4_OPTION)); if (*OptionList == NULL) { return EFI_OUT_OF_RESOURCES; } Mtftp4FillOptions (Packet, PacketLen, OptionCount, *OptionList); return EFI_SUCCESS; } /** Parse the MTFTP multicast option. @param Value The Mtftp multicast value string @param Option The option to save the info into. @retval EFI_INVALID_PARAMETER The multicast value string is invalid. @retval EFI_SUCCESS The multicast value is parsed into the Option **/ EFI_STATUS Mtftp4ExtractMcast ( IN UINT8 *Value, IN OUT MTFTP4_OPTION *Option ) { EFI_STATUS Status; UINT32 Num; // // The multicast option is formated like "204.0.0.1,1857,1" // The server can also omit the ip and port, use ",,1" // if (*Value == ',') { Option->McastIp = 0; } else { Status = NetStringToIp (Value, &Option->McastIp); if (EFI_ERROR (Status)) { return Status; } while ((*Value != 0) && (*Value != ',')) { Value++; } } if (*Value != ',') { return EFI_INVALID_PARAMETER; } Value++; // // Convert the port setting. the server can send us a port number or // empty string. such as the port in ",,1" // if (*Value == ',') { Option->McastPort = 0; } else { Num = NetStringToU32 (Value); if (Num > 65535) { return EFI_INVALID_PARAMETER; } Option->McastPort = (UINT16) Num; while (NET_IS_DIGIT (*Value)) { Value++; } } if (*Value != ',') { return EFI_INVALID_PARAMETER; } Value++; // // Check the master/slave setting, 1 for master, 0 for slave. // Num = NetStringToU32 (Value); if ((Num != 0) && (Num != 1)) { return EFI_INVALID_PARAMETER; } Option->Master = (BOOLEAN) (Num == 1); while (NET_IS_DIGIT (*Value)) { Value++; } if (*Value != '\0') { return EFI_INVALID_PARAMETER; } return EFI_SUCCESS; } /** Parse the option in Options array to MTFTP4_OPTION which program can access directly. @param Options The option array, which contains addresses of each option's name/value string. @param Count The number of options in the Options @param Request Whether this is a request or OACK. The format of multicast is different according to this setting. @param Operation The current performed operation. @param MtftpOption The MTFTP4_OPTION for easy access. @retval EFI_INVALID_PARAMETER The option is mal-formated @retval EFI_UNSUPPORTED Some option isn't supported @retval EFI_SUCCESS The option are OK and has been parsed. **/ EFI_STATUS Mtftp4ParseOption ( IN EFI_MTFTP4_OPTION *Options, IN UINT32 Count, IN BOOLEAN Request, IN UINT16 Operation, OUT MTFTP4_OPTION *MtftpOption ) { EFI_STATUS Status; UINT32 Index; UINT32 Value; EFI_MTFTP4_OPTION *This; MtftpOption->Exist = 0; for (Index = 0; Index < Count; Index++) { This = Options + Index; if ((This->OptionStr == NULL) || (This->ValueStr == NULL)) { return EFI_INVALID_PARAMETER; } if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "blksize")) { // // block size option, valid value is between [8, 65464] // Value = NetStringToU32 (This->ValueStr); if ((Value < 8) || (Value > 65464)) { return EFI_INVALID_PARAMETER; } MtftpOption->BlkSize = (UINT16) Value; MtftpOption->Exist |= MTFTP4_BLKSIZE_EXIST; } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "timeout")) { // // timeout option, valid value is between [1, 255] // Value = NetStringToU32 (This->ValueStr); if ((Value < 1) || (Value > 255)) { return EFI_INVALID_PARAMETER; } MtftpOption->Timeout = (UINT8) Value; } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "tsize")) { // // tsize option, the biggest transfer supported is 4GB with block size option // MtftpOption->Tsize = NetStringToU32 (This->ValueStr); MtftpOption->Exist |= MTFTP4_TSIZE_EXIST; } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "multicast")) { // // Multicast option, if it is a request, the value must be a zero // length string, otherwise, it is formated like "204.0.0.1,1857,1\0" // if (Request) { if (*(This->ValueStr) != '\0') { return EFI_INVALID_PARAMETER; } } else { Status = Mtftp4ExtractMcast (This->ValueStr, MtftpOption); if (EFI_ERROR (Status)) { return Status; } } MtftpOption->Exist |= MTFTP4_MCAST_EXIST; } else if (NetStringEqualNoCase (This->OptionStr, (UINT8 *) "windowsize")) { if (Operation == EFI_MTFTP4_OPCODE_WRQ) { // // Currently, windowsize is not supported in the write operation. // return EFI_UNSUPPORTED; } Value = NetStringToU32 (This->ValueStr); if (Value < 1) { return EFI_INVALID_PARAMETER; } MtftpOption->WindowSize = (UINT16) Value; MtftpOption->Exist |= MTFTP4_WINDOWSIZE_EXIST; } else if (Request) { // // Ignore the unsupported option if it is a reply, and return // EFI_UNSUPPORTED if it's a request according to the UEFI spec. // return EFI_UNSUPPORTED; } } return EFI_SUCCESS; } /** Parse the options in the OACK packet to MTFTP4_OPTION which program can access directly. @param Packet The OACK packet to parse @param PacketLen The length of the packet @param Operation The current performed operation. @param MtftpOption The MTFTP_OPTION for easy access. @retval EFI_INVALID_PARAMETER The packet option is mal-formated @retval EFI_UNSUPPORTED Some option isn't supported @retval EFI_SUCCESS The option are OK and has been parsed. **/ EFI_STATUS Mtftp4ParseOptionOack ( IN EFI_MTFTP4_PACKET *Packet, IN UINT32 PacketLen, IN UINT16 Operation, OUT MTFTP4_OPTION *MtftpOption ) { EFI_MTFTP4_OPTION *OptionList; EFI_STATUS Status; UINT32 Count; MtftpOption->Exist = 0; Status = Mtftp4ExtractOptions (Packet, PacketLen, &Count, &OptionList); if (EFI_ERROR (Status) || (Count == 0)) { return Status; } ASSERT (OptionList != NULL); Status = Mtftp4ParseOption (OptionList, Count, FALSE, Operation, MtftpOption); FreePool (OptionList); return Status; }
7336f3e40fcdcb87d3135958017800f62e2b839f
38b996d8a8eed53176040a7abeaccd5774ef18b7
/android-videostreamdecodingsample/jni/include/fribidi/fribidi-flags.h
1ef386e60e998b326954cf59ba16b3230550ed2d
[ "MIT" ]
permissive
DJI-Mobile-SDK-Tutorials/Android-VideoStreamDecodingSample
0d413a247f2cf1a1797ec7a41810d466a7400ec9
7677b8d4f0bcd8ee3d0f380313b29362aa64c4c7
refs/heads/master
2022-11-10T18:33:30.986748
2021-12-17T06:40:56
2021-12-17T06:40:56
65,873,513
190
95
MIT
2021-12-17T06:40:57
2016-08-17T03:35:18
C
UTF-8
C
false
false
2,232
h
fribidi-flags.h
/* FriBidi * fribidi-flags.h - option flags * * $Id: fribidi-flags.h,v 1.1 2005/11/03 01:39:01 behdad Exp $ * $Author: behdad $ * $Date: 2005/11/03 01:39:01 $ * $Revision: 1.1 $ * $Source: /cvs/fribidi/fribidi2/lib/fribidi-flags.h,v $ * * Author: * Behdad Esfahbod, 2005 * * Copyright (C) 2005 Behdad Esfahbod * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library, in a file named COPYING; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA * * For licensing issues, contact <license@farsiweb.info>. */ #ifndef _FRIBIDI_FLAGS_H #define _FRIBIDI_FLAGS_H #include "fribidi-common.h" #include "fribidi-types.h" #include "fribidi-begindecls.h" typedef fribidi_uint32 FriBidiFlags; /* * Define option flags that various functions use. Each mask has * only one bit set. */ #define FRIBIDI_FLAG_SHAPE_MIRRORING 0x00000001 #define FRIBIDI_FLAG_REORDER_NSM 0x00000002 #define FRIBIDI_FLAG_SHAPE_ARAB_PRES 0x00000100 #define FRIBIDI_FLAG_SHAPE_ARAB_LIGA 0x00000200 #define FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE 0x00000400 #define FRIBIDI_FLAG_REMOVE_BIDI 0x00010000 #define FRIBIDI_FLAG_REMOVE_JOINING 0x00020000 #define FRIBIDI_FLAG_REMOVE_SPECIALS 0x00040000 /* * And their combinations. */ #define FRIBIDI_FLAGS_DEFAULT ( \ FRIBIDI_FLAG_SHAPE_MIRRORING | \ FRIBIDI_FLAG_REORDER_NSM | \ FRIBIDI_FLAG_REMOVE_SPECIALS ) #define FRIBIDI_FLAGS_ARABIC ( \ FRIBIDI_FLAG_SHAPE_ARAB_PRES | \ FRIBIDI_FLAG_SHAPE_ARAB_LIGA ) #include "fribidi-enddecls.h" #endif /* !_FRIBIDI_FLAGS_H */ /* Editor directions: * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent */
65bca14c99630c2999d1d36d03f9489d3df5a7b2
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/amiga/amiga/pmap_bootstrap.c
816dc48aa5234f71105f4adf4b26460c2a3c20c6
[]
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
6,715
c
pmap_bootstrap.c
/* $NetBSD: pmap_bootstrap.c,v 1.10 2016/12/22 14:47:54 cherry Exp $ */ /*- * Copyright (c) 1999 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. */ /* * Copyright (c) 1991 Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * the Systems Programming Group of the University of Utah Computer * Science Department. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pmap.c 7.5 (Berkeley) 5/10/91 */ #include <sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.10 2016/12/22 14:47:54 cherry Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/proc.h> #include <sys/malloc.h> #include <uvm/uvm.h> #include <machine/pte.h> #include <machine/cpu.h> #include <machine/vmparam.h> #include <m68k/cacheops.h> #include <amiga/amiga/memlist.h> extern paddr_t avail_start; extern paddr_t avail_end; extern paddr_t msgbufpa; u_long noncontig_enable; extern paddr_t z2mem_start; extern vaddr_t reserve_dumppages(vaddr_t); /* * All those kernel PT submaps that BSD is so fond of */ void *CADDR1, *CADDR2; char *vmmap; /* * Bootstrap the system enough to run with virtual memory. * * This is called after mapping has already been enabled * and just syncs the pmap module with what has already been done. */ void pmap_bootstrap(paddr_t firstaddr, paddr_t loadaddr) { vaddr_t va; int i; struct boot_memseg *sp, *esp; paddr_t fromads, toads; fromads = firstaddr; toads = maxmem << PGSHIFT; /* XXX: allow for msgbuf */ toads -= m68k_round_page(MSGBUFSIZE); msgbufpa = toads; /* * first segment of memory is always the one loadbsd found * for loading the kernel into. */ uvmexp.pagesize = NBPG; uvm_md_init(); /* * May want to check if first segment is Zorro-II? */ uvm_page_physload(atop(fromads), atop(toads), atop(fromads), atop(toads), VM_FREELIST_DEFAULT); sp = memlist->m_seg; esp = sp + memlist->m_nseg; i = 1; for (; noncontig_enable && sp < esp; sp++) { if ((sp->ms_attrib & MEMF_FAST) == 0) continue; /* skip if not FastMem */ if (firstaddr >= sp->ms_start && firstaddr < sp->ms_start + sp->ms_size) continue; /* skip kernel segment */ if (sp->ms_size == 0) continue; /* skip zero size segments */ fromads = sp->ms_start; toads = sp->ms_start + sp->ms_size; #ifdef DEBUG_A4000 /* * My A4000 doesn't seem to like Zorro II memory - this * hack is to skip the motherboard memory and use the * Zorro II memory. Only for trying to debug the problem. * Michael L. Hitch */ if (toads == 0x08000000) continue; /* skip A4000 motherboard mem */ #endif /* * Deal with Zorro II memory stolen for DMA bounce buffers. * This needs to be handled better. * * XXX is: disabled. This is handled now in amiga_init.c * by removing the stolen memory from the memlist. * * XXX is: enabled again, but check real size and position. * We check z2mem_start is in this segment, and set its end * to the z2mem_start. * */ if ((fromads <= z2mem_start) && (toads > z2mem_start)) toads = z2mem_start; uvm_page_physload(atop(fromads), atop(toads), atop(fromads), atop(toads), (fromads & 0xff000000) ? VM_FREELIST_DEFAULT : VM_FREELIST_ZORROII); physmem += (toads - fromads) / PAGE_SIZE; ++i; if (noncontig_enable == 1) break; /* Only two segments enabled */ } mem_size = physmem << PGSHIFT; avail_start = firstaddr; avail_end = toads; virtual_end = VM_MAX_KERNEL_ADDRESS; /* * Allocate all the submaps we need */ #define SYSMAP(c, v, n) \ v = (c)va; va += ((n)*PAGE_SIZE); va = virtual_avail; SYSMAP(void * ,CADDR1 ,1 ) SYSMAP(void * ,CADDR2 ,1 ) SYSMAP(void * ,vmmap ,1 ) SYSMAP(void * ,msgbufaddr ,btoc(MSGBUFSIZE) ) DCIS(); virtual_avail = reserve_dumppages(va); }
1e22e231c02b3db68a3e84799abb4d3f3972ad82
50dd46b8ece33f3cdd174284b15d1d51f89669d4
/third_party/edk2/EdkCompatibilityPkg/Foundation/Include/Ebc/EfiBind.h
7fc05ca17fe30451e54d4fc14a464f7dc2864710
[ "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause", "OpenSSL" ]
permissive
google/google-ctf
f99da1ee07729bbccb869fff1cbaed6a80e43bcc
df02323eaf945d15e124801c74abaadca2749dc7
refs/heads/master
2023-08-31T14:30:27.548081
2023-08-29T13:04:20
2023-08-29T13:04:20
131,317,137
4,136
607
Apache-2.0
2023-08-30T22:17:02
2018-04-27T15:56:03
Go
UTF-8
C
false
false
3,545
h
EfiBind.h
/*++ Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: EfiBind.h Abstract: Processor or compiler specific defines and types for EBC. --*/ #ifndef _EFI_BIND_H_ #define _EFI_BIND_H_ #define EFI_DRIVER_ENTRY_POINT(InitFunction) #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT // // Disable warning that make it impossible to compile at /W3 // This only works for Intel EBC Compiler tools // // // Disabling argument of type "TYPE **" is incompatible with parameter of type "void **" // #pragma warning ( disable : 167 ) // // Disabling pointless comparison of unsigned integer with zero // #pragma warning ( disable : 186 ) // // Disabling enumerated type mixed with another type // #pragma warning ( disable : 188 ) // // Native integer types // typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; // // "long" type scales to the processor native size with EBC compiler // typedef long intn_t; typedef unsigned long uintn_t; // // Scalable macro to set the most significant bit in a natural number // #define EFI_MAX_BIT ((UINTN)0x01 << ((sizeof (char *) * 8) - 1)) #define MAX_2_BITS (EFI_MAX_BIT | (EFI_MAX_BIT >> 1)) // // Maximum legal EBC address // #define EFI_MAX_ADDRESS (UINTN)~0 // // Bad pointer value to use in check builds. // if you see this value you are using uninitialized or free'ed data // #define EFI_BAD_POINTER (UINTN)0xAFAFAFAFAFAFAFAF #define EFI_BAD_POINTER_AS_BYTE (UINTN)0xAF // // _break() is an EBC compiler intrinsic function // extern uint64_t _break ( unsigned char BreakCode ); // // Macro to inject a break point in the code to assist debugging. // #define EFI_BREAKPOINT() _break ( 3 ) #define EFI_DEADLOOP() while (TRUE) // // Memory Fence forces serialization, and is needed to support out of order // memory transactions. The Memory Fence is mainly used to make sure IO // transactions complete in a deterministic sequence, and to syncronize locks // an other MP code. Currently no memory fencing is required. // #define MEMORY_FENCE() // // Some compilers don't support the forward reference construct: // typedef struct XXXXX. The forward reference is required for // ANSI compatibility. // // The following macro provide a workaround for such cases. // #ifdef EFI_NO_INTERFACE_DECL #define EFI_FORWARD_DECLARATION(x) #else #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x #endif #define _EFIAPI #endif // ifndef _EFI_BIND_H_
5675d54e65fd0c257b57750780ba65e1b67fecdf
f42190636add23ead6a5022d706a124032d66f92
/src/Microsoft.DotNet.Wpf/src/WpfGfx/shared/util/DllUtil/Precomp.h
c6182cf12088202572b24a658c67052085916a5d
[ "MIT" ]
permissive
dotnet/wpf
b8f73a99e03f87b4dee5db643e38e2c0704f707a
2ff355a607d79eef5fea7796de1f29cf9ea4fbed
refs/heads/main
2023-09-04T09:35:19.355384
2023-09-03T02:30:37
2023-09-03T02:30:37
153,711,945
6,927
1,397
MIT
2023-09-14T17:22:06
2018-10-19T01:55:23
C#
UTF-8
C
false
false
1,675
h
Precomp.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. //------------------------------------------------------------------------------ // // File: Precomp.h //------------------------------------------------------------------------------ #include <wpfsdl.h> #define AVALON_NOMEMSYSTEM #include "always.h" #ifdef __cplusplus extern "C" { #endif // Ensure that DBG is defined when being compiled // under dbg/chk mode #if !defined(DBG) && (defined(DEBUG) || defined(_DEBUG)) #define DBG #endif BOOL WINAPI _DllMainStartupImpl ( __in_ecount(1) HANDLE hDllHandle, DWORD dwReason, __in_ecount_opt(1) LPVOID lpreserved ); #if !defined(DBG) BOOL WINAPI _DllMainStartup ( __in_ecount(1) HANDLE hDllHandle, DWORD dwReason, __in_ecount_opt(1) LPVOID lpreserved ); #else extern __declspec(dllexport) BOOL g_fNoMeterChecks; void WINAPI InitDebugLib( __in_ecount_opt(1) HANDLE, __in_ecount_opt(1) BOOL(WINAPI *)(HANDLE, DWORD, LPVOID), BOOL fExe ); void TermDebugLib(__in_ecount(1) HANDLE, BOOL); BOOL WINAPI _DllMainStartupDebug ( __in_ecount(1) HANDLE hDllHandle, DWORD dwReason, __in_ecount_opt(1) LPVOID lpreserved ); #endif extern int avalonutil_proc_attached; extern BOOL g_fAlwaysDetach; extern BOOL WINAPI _DllMainCRTStartup( __in_ecount(1) HANDLE hDllHandle, DWORD dwReason, __in_ecount_opt(1) LPVOID lpreserved ); extern HRESULT AvCreateProcessHeap(); extern HRESULT AvDestroyProcessHeap(); #ifdef __cplusplus } #endif
b14eba408bf4638f29c790056319f21b237e52aa
fec41f425b51e73842bd37fe0720e9d633288d42
/hapcut2-src/hapcontig.h
f814ddc8543a2a6d43d4377438ad57d042236a5d
[ "BSD-2-Clause" ]
permissive
vibansal/HapCUT2
52434f72af703b4147baf966e00c2476d2c46d4c
0eb7075424afbb40259ced6b5b1cbd95d0cedf55
refs/heads/master
2022-10-21T19:16:58.785156
2022-10-14T21:50:21
2022-10-14T21:50:21
64,779,084
188
46
BSD-2-Clause
2022-10-14T21:56:42
2016-08-02T17:48:30
C
UTF-8
C
false
false
1,079
h
hapcontig.h
#ifndef _HAPCONTIG_H #define _HAPCONTIG_H #include <stdint.h> #include<stdio.h> #include <math.h> #include<stdlib.h> #include<time.h> #include<string.h> #include<ctype.h> #include "common.h" // haplotype block/connected component for phasing struct BLOCK { int offset; int length; int phased; char* haplotype; int* flist; int frags; float SCORE, bestSCORE, lastSCORE; int* slist; // ordered list of variants in this connected component int lastvar; // index of the first and last variants in this connected component int iters_since_improvement; }; void generate_contigs(struct fragment* Flist, int fragments, struct SNPfrags* snpfrag, int snps, int components, struct BLOCK* clist); //void update_score(struct BLOCK* contig,struct fragment* Flist,char* HAP1); int print_contigs(struct BLOCK* clist, int blocks, char* h1, struct fragment* Flist, int fragments, struct SNPfrags* snpfrag, char* outfile); float calculate_N50(struct BLOCK* clist, int blocks, struct SNPfrags* snpfrag, char* h1); // and other statistics, TBD #endif
10399321b248198c24d4a2e32a456067977b241b
46f7a44ef70b1f4c26760bab0e02fc9d097dcfe1
/src/Tracker/graph/fheap.c
98295fda01113bc587877483601538f301bff3fa
[ "Apache-2.0" ]
permissive
Smorodov/Multitarget-tracker
d9bf865ee4d842dfd858247f8baf304655c41c75
27fb61d15155591cc0be7d39daf0cc1a5c68284d
refs/heads/master
2023-08-30T09:26:40.310522
2023-08-10T15:17:29
2023-08-10T15:17:29
11,808,499
2,137
660
Apache-2.0
2023-08-10T15:17:31
2013-08-01T05:09:47
C++
UTF-8
C
false
false
12,585
c
fheap.c
// $Id: fheap.c,v 1.1.1.1 2003/11/05 15:19:14 rdmp1c Exp $ /** * @file fheap.c * * Fibonacci heap * */ /* This code comes from <A HREF="http://www.cosc.canterbury.ac.nz/research/reports/HonsReps/1999/hons_9907.pdf"> A Comparison of Data Structures for Dijkstra's Single Source Shortest Path Algorithm</A> by Shane Saunders (Department of Computer Science, University of Canterbury, NZ). The code itself is available from Tadao Takaoka's <A HREF="http://www.cosc.canterbury.ac.nz/~tad/alg/heaps/heaps.html"> Algorithm Repository Home Page</A> */ /*** Fibonacci Heap Implementation ***/ /* * Shane Saunders */ #include <stdlib.h> #include <math.h> #if FHEAP_DUMP #include <stdio.h> #endif #include "fheap.h" /*** Prototypes of functions only visible within this file. ***/ void fh_dump_nodes(fheap_node_t *ptr, int level); void fh_meld(fheap_t *h, fheap_node_t *tree_list); /*** Definitions for functions that are visible outside this file. ***/ /* fh_alloc() - creates and and returns a pointer to a F-heap which can contian * up to max_nodes nodes. */ fheap_t *fh_alloc(int max_nodes) { fheap_t *h; #if FHEAP_DUMP printf("alloc, "); #endif /* Create the heap. */ h = (fheap_t *)malloc(sizeof(fheap_t)); h->max_trees = (int)(1.0 + 1.44 * log(max_nodes)/log(2.0)); h->max_nodes = max_nodes; h->trees = (fheap_node_t **)calloc(h->max_trees, sizeof(fheap_node_t *)); h->nodes = (fheap_node_t **)calloc(max_nodes, sizeof(fheap_node_t *)); h->n = 0; /* The value of the heap helps to keep track of the maximum rank while * nodes are inserted or deleted. */ h->value = 0; /* For experimental purposes, we keep a count of the number of key * comparisons. */ h->key_comps = 0; #if FHEAP_DUMP printf("alloc-exited, "); #endif return h; } /* fh_free() - destroys the heap pointed to by h, freeing up any space that was * used by it. */ void fh_free(fheap_t *h) { int i; #if FHEAP_DUMP printf("free, "); #endif for(i = 0; i < h->max_nodes; i++) { free(h->nodes[i]); } free(h->nodes); free(h->trees); free(h); #if FHEAP_DUMP printf("free-exited, "); #endif } /* fh_insert() - creates and inserts new a node representing vertex_no with key * k into the heap h. */ void fh_insert(fheap_t *h, int vertex_no, long k) { fheap_node_t *newn; #if FHEAP_DUMP printf("insert, "); #endif /* Create an initialise the new node. */ newn = (fheap_node_t *)malloc(sizeof(fheap_node_t)); newn->child = NULL; newn->left = newn->right = newn; newn->rank = 0; newn->vertex_no = vertex_no; newn->key = k; /* Maintain a pointer vertex_no's new node in the heap. */ h->nodes[vertex_no] = newn; /* Meld the new node into the heap. */ fh_meld(h, newn); /* Update the heaps node count. */ h->n++; #if FHEAP_DUMP printf("insert-exited, "); #endif } /* fh_delete_min() - deletes the minimum node from the heap pointed to by h and * returns its vertex number. */ int fh_delete_min(fheap_t *h) { fheap_node_t *min_node, *child, *next; long k, k2; int r, v, vertex_no; #if FHEAP_DUMP printf("delete_min, "); #endif /* First we determine the maximum rank in the heap. */ v = h->value; r = -1; while(v) { v = v >> 1; r++; }; /* Now determine which root node is the minimum. */ min_node = h->trees[r]; k = min_node->key; while(r > 0) { r--; next = h->trees[r]; if(next) { if((k2 = next->key) < k) { k = k2; min_node = next; } h->key_comps++; } } /* We remove the minimum node from the heap but keep a pointer to it. */ r = min_node->rank; h->trees[r] = NULL; h->value -= (1 << r); child = min_node->child; if(child) fh_meld(h, child); /* Record the vertex no of the old minimum node before deleting it. */ vertex_no = min_node->vertex_no; h->nodes[vertex_no] = NULL; free(min_node); h->n--; #if FHEAP_DUMP printf("delete_min-exited, "); #endif return vertex_no; } /* fh_decrease_key() - decreases the key used for vertex, vertex_no, to * new_value. No check is made to ensure that new_value is in-fact less than * the current value so it is up to the user of this function to ensure that * it is. */ void fh_decrease_key(fheap_t *h, int vertex_no, long new_value) { fheap_node_t *cut_node, *parent, *new_roots, *r, *l; int prev_rank; #if FHEAP_DUMP printf("decrease_key on vn = %d, ", vertex_no); #endif /* Obtain a pointer to the decreased node and its parent then decrease the * nodes key. */ cut_node = h->nodes[vertex_no]; parent = cut_node->parent; cut_node->key = new_value; /* No reinsertion occurs if the node changed was a root. */ if(!parent) { #if FHEAP_DUMP printf("decrease_key-exited, "); #endif return; } /* Update the left and right pointers of cut_node and its two neighbouring * nodes. */ l = cut_node->left; r = cut_node->right; l->right = r; r->left = l; cut_node->left = cut_node->right = cut_node; /* Initially the list of new roots contains only one node. */ new_roots = cut_node; /* While there is a parent node that is marked a cascading cut occurs. */ while(parent && parent->marked) { /* Decrease the rank of cut_node's parent an update its child pointer. */ parent->rank--; if(parent->rank) { if(parent->child == cut_node) parent->child = r; } else { parent->child = NULL; } /* Update the cut_node and parent pointers to the parent. */ cut_node = parent; parent = cut_node->parent; /* Update the left and right pointers of cut_nodes two neighbouring * nodes. */ l = cut_node->left; r = cut_node->right; l->right = r; r->left = l; /* Add cut_node to the list of nodes to be reinserted as new roots. */ l = new_roots->left; new_roots->left = l->right = cut_node; cut_node->left = l; cut_node->right = new_roots; new_roots = cut_node; } /* If the root node is being relocated then update the trees[] array. * Otherwise mark the parent of the last node cut. */ if(!parent) { prev_rank = cut_node->rank + 1; h->trees[prev_rank] = NULL; h->value -= (1 << prev_rank); } else { /* Decrease the rank of cut_node's parent an update its child pointer. */ parent->rank--; if(parent->rank) { if(parent->child == cut_node) parent->child = r; } else { parent->child = NULL; } parent->marked = 1; } /* Meld the new roots into the heap. */ fh_meld(h, new_roots); #if FHEAP_DUMP printf("decrease_key-exited, "); #endif } /*** Definitions of functions that are only visible within this file. ***/ /* fh_meld() - melds the linked list of trees pointed to by *tree_list into * the heap pointed to by h. */ void fh_meld(fheap_t *h, fheap_node_t *tree_list) { fheap_node_t *first, *next, *node_ptr, *new_root, *temp, *temp2, *lc, *rc; int r; #if FHEAP_DUMP printf("meld: "); #endif /* We meld each tree in the circularly linked list back into the root level * of the heap. Each node in the linked list is the root node of a tree. * The circularly linked list uses the sibling pointers of nodes. This * makes melding of the child nodes from a delete_min operation simple. */ node_ptr = first = tree_list; do { #if FHEAP_DUMP printf("%d, ", GTL::node_ptr->vertex_no); #endif /* Keep a pointer to the next node and remove sibling and parent links * from the current node. node_ptr points to the current node. */ next = node_ptr->right; node_ptr->right = node_ptr->left = node_ptr; node_ptr->parent = NULL; /* We merge the current node, GTL::node_ptr, by inserting it into the * root level of the heap. */ new_root = node_ptr; r = node_ptr->rank; /* This loop inserts the new root into the heap, possibly restructuring * the heap to ensure that only one tree for each degree exists. */ do { /* Check if there is already a tree of degree r in the heap. * If there is then we need to link it with new_root so it will be * reinserted into a new place in the heap. */ if((temp = h->trees[r])) { /* temp will be linked to new_root and relocated so we no * longer will have a tree of degree r. */ h->trees[r] = NULL; h->value -= (1 << r); /* Swap temp and new_root if necessary so that new_root always * points to the root node which has the smaller key of the * two. */ if(temp->key < new_root->key) { temp2 = new_root; new_root = temp; temp = temp2; } h->key_comps++; /* Link temp with new_root, making sure that sibling pointers * get updated if rank is greater than 0. Also, increase r for * the next pass through the loop since the rank of new has * increased. */ if(r++ > 0) { rc = new_root->child; lc = rc->left; temp->left = lc; temp->right = rc; lc->right = rc->left = temp; } new_root->child = temp; new_root->rank = r; temp->parent = new_root; temp->marked = 0; } /* Otherwise if there is not a tree of degree r in the heap we * allow new_root, which possibly carries moved trees in the heap, * to be a tree of degree r in the heap. */ else { h->trees[r] = new_root; h->value += (1 << r);; /* NOTE: Because new_root is now a root we ensure it is * marked. */ new_root->marked = 1; } /* Note that temp will be NULL if and only if there was not a tree * of degree r. */ } while(temp); node_ptr = next; } while(node_ptr != first); #if FHEAP_DUMP printf("meld-exited, "); #endif } /*** Debugging functions ***/ /* Recursively print the nodes of a Fibonacci heap. */ #define FHEAP_DUMP 0 #if FHEAP_DUMP void fh_dump_nodes(fheap_node_t *ptr, int level) { fheap_node_t *child_ptr, *partner; int i, ch_count; /* Print leading whitespace for this level. */ for(i = 0; i < level; i++) printf(" "); printf("%d(%ld)[%d]\n", ptr->vertex_no, ptr->key, ptr->rank); if((child_ptr = ptr->child)) { child_ptr = ptr->child->right; ch_count = 0; do { fh_dump_nodes(child_ptr, level+1); if(child_ptr->dim > ptr->dim) { for(i = 0; i < level+1; i++) printf(" "); printf("error(dim)\n"); exit(1); } if(child_ptr->parent != ptr) { for(i = 0; i < level+1; i++) printf(" "); printf("error(parent)\n"); } child_ptr = child_ptr->right; ch_count++; } while(child_ptr != ptr->child->right); if(ch_count != ptr->dim) { for(i = 0; i < level; i++) printf(" "); printf("error(ch_count)\n"); exit(1); } } else { if(ptr->dim != 0) { for(i = 0; i < level; i++) printf(" "); printf("error(dim)\n"); exit(1); } } } #endif /* Print out a Fibonacci heap. */ #if FHEAP_DUMP void fh_dump(fheap_t *h) { int i; fheap_node_t *ptr; printf("\n"); printf("value = %d\n", h->value); printf("array entries 0..max_trees ="); for(i=0; i<h->max_trees; i++) { printf(" %d", h->trees[i] ? 1 : 0 ); } printf("\n\n"); for(i=0; i<h->max_trees; i++) { if((ptr = h->trees[i])) { printf("tree %d\n\n", i); fh_dump_nodes(ptr, 0); printf("\n"); } } fflush(stdout); } #endif
3481a697760bb6539fb6b7ad22e714c289ebc255
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/drivers/usb/host/xhci-exynos5.c
b4946a3f1cf5900614e7238f8033979876eac942
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "GPL-2.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
8,011
c
xhci-exynos5.c
/* * SAMSUNG EXYNOS5 USB HOST XHCI Controller * * Copyright (C) 2012 Samsung Electronics Co.Ltd * Vivek Gautam <gautam.vivek@samsung.com> * Vikas Sajjan <vikas.sajjan@samsung.com> * * SPDX-License-Identifier: GPL-2.0+ */ /* * This file is a conglomeration for DWC3-init sequence and further * exynos5 specific PHY-init sequence. */ #include <common.h> #include <fdtdec.h> #include <libfdt.h> #include <malloc.h> #include <usb.h> #include <watchdog.h> #include <asm/arch/cpu.h> #include <asm/arch/power.h> #include <asm/arch/xhci-exynos.h> #include <asm/gpio.h> #include <asm-generic/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> #include "xhci.h" /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; /** * Contains pointers to register base addresses * for the usb controller. */ struct exynos_xhci { struct exynos_usb3_phy *usb3_phy; struct xhci_hccr *hcd; struct dwc3 *dwc3_reg; struct fdt_gpio_state vbus_gpio; }; static struct exynos_xhci exynos; #ifdef CONFIG_OF_CONTROL static int exynos_usb3_parse_dt(const void *blob, struct exynos_xhci *exynos) { fdt_addr_t addr; unsigned int node; int depth; node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_XHCI); if (node <= 0) { debug("XHCI: Can't get device node for xhci\n"); return -ENODEV; } /* * Get the base address for XHCI controller from the device node */ addr = fdtdec_get_addr(blob, node, "reg"); if (addr == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; } exynos->hcd = (struct xhci_hccr *)addr; /* Vbus gpio */ fdtdec_decode_gpio(blob, node, "samsung,vbus-gpio", &exynos->vbus_gpio); depth = 0; node = fdtdec_next_compatible_subnode(blob, node, COMPAT_SAMSUNG_EXYNOS5_USB3_PHY, &depth); if (node <= 0) { debug("XHCI: Can't get device node for usb3-phy controller\n"); return -ENODEV; } /* * Get the base address for usbphy from the device node */ exynos->usb3_phy = (struct exynos_usb3_phy *)fdtdec_get_addr(blob, node, "reg"); if (exynos->usb3_phy == NULL) { debug("Can't get the usbphy register address\n"); return -ENXIO; } return 0; } #endif static void exynos5_usb3_phy_init(struct exynos_usb3_phy *phy) { u32 reg; /* enabling usb_drd phy */ set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_EN); /* Reset USB 3.0 PHY */ writel(0x0, &phy->phy_reg0); clrbits_le32(&phy->phy_param0, /* Select PHY CLK source */ PHYPARAM0_REF_USE_PAD | /* Set Loss-of-Signal Detector sensitivity */ PHYPARAM0_REF_LOSLEVEL_MASK); setbits_le32(&phy->phy_param0, PHYPARAM0_REF_LOSLEVEL); writel(0x0, &phy->phy_resume); /* * Setting the Frame length Adj value[6:1] to default 0x20 * See xHCI 1.0 spec, 5.2.4 */ setbits_le32(&phy->link_system, LINKSYSTEM_XHCI_VERSION_CONTROL | LINKSYSTEM_FLADJ(0x20)); /* Set Tx De-Emphasis level */ clrbits_le32(&phy->phy_param1, PHYPARAM1_PCS_TXDEEMPH_MASK); setbits_le32(&phy->phy_param1, PHYPARAM1_PCS_TXDEEMPH); setbits_le32(&phy->phy_batchg, PHYBATCHG_UTMI_CLKSEL); /* PHYTEST POWERDOWN Control */ clrbits_le32(&phy->phy_test, PHYTEST_POWERDOWN_SSP | PHYTEST_POWERDOWN_HSP); /* UTMI Power Control */ writel(PHYUTMI_OTGDISABLE, &phy->phy_utmi); /* Use core clock from main PLL */ reg = PHYCLKRST_REFCLKSEL_EXT_REFCLK | /* Default 24Mhz crystal clock */ PHYCLKRST_FSEL(FSEL_CLKSEL_24M) | PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF | PHYCLKRST_SSC_REFCLKSEL(0x88) | /* Force PortReset of PHY */ PHYCLKRST_PORTRESET | /* Digital power supply in normal operating mode */ PHYCLKRST_RETENABLEN | /* Enable ref clock for SS function */ PHYCLKRST_REF_SSP_EN | /* Enable spread spectrum */ PHYCLKRST_SSC_EN | /* Power down HS Bias and PLL blocks in suspend mode */ PHYCLKRST_COMMONONN; writel(reg, &phy->phy_clk_rst); /* giving time to Phy clock to settle before resetting */ udelay(10); reg &= ~PHYCLKRST_PORTRESET; writel(reg, &phy->phy_clk_rst); } static void exynos5_usb3_phy_exit(struct exynos_usb3_phy *phy) { setbits_le32(&phy->phy_utmi, PHYUTMI_OTGDISABLE | PHYUTMI_FORCESUSPEND | PHYUTMI_FORCESLEEP); clrbits_le32(&phy->phy_clk_rst, PHYCLKRST_REF_SSP_EN | PHYCLKRST_SSC_EN | PHYCLKRST_COMMONONN); /* PHYTEST POWERDOWN Control to remove leakage current */ setbits_le32(&phy->phy_test, PHYTEST_POWERDOWN_SSP | PHYTEST_POWERDOWN_HSP); /* disabling usb_drd phy */ set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_DISABLE); } void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode) { clrsetbits_le32(&dwc3_reg->g_ctl, DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG), DWC3_GCTL_PRTCAPDIR(mode)); } static void dwc3_core_soft_reset(struct dwc3 *dwc3_reg) { /* Before Resetting PHY, put Core in Reset */ setbits_le32(&dwc3_reg->g_ctl, DWC3_GCTL_CORESOFTRESET); /* Assert USB3 PHY reset */ setbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); /* Assert USB2 PHY reset */ setbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); mdelay(100); /* Clear USB3 PHY reset */ clrbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); /* Clear USB2 PHY reset */ clrbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); /* After PHYs are stable we can take Core out of reset state */ clrbits_le32(&dwc3_reg->g_ctl, DWC3_GCTL_CORESOFTRESET); } static int dwc3_core_init(struct dwc3 *dwc3_reg) { u32 reg; u32 revision; unsigned int dwc3_hwparams1; revision = readl(&dwc3_reg->g_snpsid); /* This should read as U3 followed by revision number */ if ((revision & DWC3_GSNPSID_MASK) != 0x55330000) { puts("this is not a DesignWare USB3 DRD Core\n"); return -EINVAL; } dwc3_core_soft_reset(dwc3_reg); dwc3_hwparams1 = readl(&dwc3_reg->g_hwparams1); reg = readl(&dwc3_reg->g_ctl); reg &= ~DWC3_GCTL_SCALEDOWN_MASK; reg &= ~DWC3_GCTL_DISSCRAMBLE; switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc3_hwparams1)) { case DWC3_GHWPARAMS1_EN_PWROPT_CLK: reg &= ~DWC3_GCTL_DSBLCLKGTNG; break; default: debug("No power optimization available\n"); } /* * WORKAROUND: DWC3 revisions <1.90a have a bug * where the device can fail to connect at SuperSpeed * and falls back to high-speed mode which causes * the device to enter a Connect/Disconnect loop */ if ((revision & DWC3_REVISION_MASK) < 0x190a) reg |= DWC3_GCTL_U2RSTECN; writel(reg, &dwc3_reg->g_ctl); return 0; } static int exynos_xhci_core_init(struct exynos_xhci *exynos) { int ret; exynos5_usb3_phy_init(exynos->usb3_phy); ret = dwc3_core_init(exynos->dwc3_reg); if (ret) { debug("failed to initialize core\n"); return -EINVAL; } /* We are hard-coding DWC3 core to Host Mode */ dwc3_set_mode(exynos->dwc3_reg, DWC3_GCTL_PRTCAP_HOST); return 0; } static void exynos_xhci_core_exit(struct exynos_xhci *exynos) { exynos5_usb3_phy_exit(exynos->usb3_phy); } int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) { struct exynos_xhci *ctx = &exynos; int ret; #ifdef CONFIG_OF_CONTROL exynos_usb3_parse_dt(gd->fdt_blob, ctx); #else ctx->usb3_phy = (struct exynos_usb3_phy *)samsung_get_base_usb3_phy(); ctx->hcd = (struct xhci_hccr *)samsung_get_base_usb_xhci(); #endif ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET); #ifdef CONFIG_OF_CONTROL /* setup the Vbus gpio here */ if (fdt_gpio_isvalid(&ctx->vbus_gpio) && !fdtdec_setup_gpio(&ctx->vbus_gpio)) gpio_direction_output(ctx->vbus_gpio.gpio, 1); #endif ret = exynos_xhci_core_init(ctx); if (ret) { puts("XHCI: failed to initialize controller\n"); return -EINVAL; } *hccr = (ctx->hcd); *hcor = (struct xhci_hcor *)((uint32_t) *hccr + HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); debug("Exynos5-xhci: init hccr %x and hcor %x hc_length %d\n", (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); return 0; } void xhci_hcd_stop(int index) { struct exynos_xhci *ctx = &exynos; exynos_xhci_core_exit(ctx); }
ef9ef8097d391091cd652874bc77bdb42619447c
d61b532db0d3e08818338cfaac530a1ced1ffe3b
/util/topgen/misc.h
cebdc44735bfc69274cb859cce90fc857eb7b707
[ "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
490
h
misc.h
/* $Id$ */ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* m i s c . h * * Some external declarations */ extern int countid; /* # of variables */ extern int countpat; /* # of patterns */ extern int lineno; /* line number */ extern FILE *genc, *genh; /* Output files */ extern char *inpfile; /* input file name */ extern char *linedir; /* line directive format */
b0191b1b6c1acd7c4c08713cbd1fdfe8c7d41ae6
f6e5f3c038fb15cb1bfd2e0a6e8038324656bd28
/3rdparty/openssl-win32/openssl/bf_pi.h
cba57bdccddb57b5892bde99a33577e3b0d21169
[ "OpenSSL", "MIT" ]
permissive
vslavik/winsparkle
c838830255f0fc0d0d1c4c6251e450ebf0eb9a45
415acf557e8c15a12d8168d298b3b577fdbc6d54
refs/heads/master
2023-09-01T13:39:55.053989
2023-08-31T16:20:45
2023-08-31T17:17:37
467,582
1,105
279
NOASSERTION
2023-09-13T21:46:13
2010-01-11T16:13:10
C++
UTF-8
C
false
false
43
h
bf_pi.h
#include "../../openssl/crypto/bf/bf_pi.h"
2192c72b9c7b57fcfe91cc31ad3c5f54b45217f5
7df190df28da7e4ff166e55dc8ce780f11236a9f
/src/router/ntfs3/file.c
0abd4ff51ee59866ec0d9c4fc3dd0190f1d0b21e
[]
no_license
mirror/dd-wrt
25416946e6132aa54b35809de61834a1825a9a36
8f2934a5a2adfbb59b471375aa3a38de5d036531
refs/heads/master
2023-08-31T14:54:47.496685
2023-08-30T17:40:54
2023-08-30T17:40:54
7,470,282
520
281
null
2023-05-29T20:56:24
2013-01-06T17:21:29
null
UTF-8
C
false
false
28,991
c
file.c
// SPDX-License-Identifier: GPL-2.0 /* * * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved. * * Regular file handling primitives for NTFS-based filesystems */ #include <linux/backing-dev.h> #include <linux/buffer_head.h> #include <linux/compat.h> #include <linux/falloc.h> #include <linux/fiemap.h> #include <linux/nls.h> #include "debug.h" #include "ntfs.h" #include "ntfs_fs.h" static int ntfs_ioctl_fitrim(struct ntfs_sb_info *sbi, unsigned long arg) { struct fstrim_range __user *user_range; struct fstrim_range range; struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev); int err; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (!blk_queue_discard(q)) return -EOPNOTSUPP; user_range = (struct fstrim_range __user *)arg; if (copy_from_user(&range, user_range, sizeof(range))) return -EFAULT; range.minlen = max_t(u32, range.minlen, q->limits.discard_granularity); err = ntfs_trim_fs(sbi, &range); if (err < 0) return err; if (copy_to_user(user_range, &range, sizeof(range))) return -EFAULT; return 0; } static long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg) { struct inode *inode = file_inode(filp); struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; switch (cmd) { case FITRIM: return ntfs_ioctl_fitrim(sbi, arg); } return -ENOTTY; /* Inappropriate ioctl for device. */ } #ifdef CONFIG_COMPAT static long ntfs_compat_ioctl(struct file *filp, u32 cmd, unsigned long arg) { return ntfs_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); } #endif /* * ntfs_getattr - inode_operations::getattr */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) int ntfs_getattr(const struct path *path, struct kstat *stat, u32 request_mask, u32 flags) #else int ntfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) #endif { #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) struct inode *inode = d_inode(path->dentry); struct ntfs_inode *ni = ntfs_i(inode); #else struct inode *inode = d_inode(dentry); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) if (is_compressed(ni)) stat->attributes |= STATX_ATTR_COMPRESSED; if (is_encrypted(ni)) stat->attributes |= STATX_ATTR_ENCRYPTED; stat->attributes_mask |= STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED; #endif generic_fillattr(inode, stat); #ifdef STATX_BTIME stat->result_mask |= STATX_BTIME; stat->btime = ni->i_crtime; stat->blksize = ni->mi.sbi->cluster_size; /* 512, 1K, ..., 2M */ #endif return 0; } static int ntfs_extend_initialized_size(struct file *file, struct ntfs_inode *ni, const loff_t valid, const loff_t new_valid) { struct inode *inode = &ni->vfs_inode; struct address_space *mapping = inode->i_mapping; struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; loff_t pos = valid; int err; if (is_resident(ni)) { ni->i_valid = new_valid; return 0; } WARN_ON(is_compressed(ni)); WARN_ON(valid >= new_valid); for (;;) { u32 zerofrom, len; struct page *page; void *fsdata; u8 bits; CLST vcn, lcn, clen; if (is_sparsed(ni)) { bits = sbi->cluster_bits; vcn = pos >> bits; err = attr_data_get_block(ni, vcn, 0, &lcn, &clen, NULL); if (err) goto out; if (lcn == SPARSE_LCN) { loff_t vbo = (loff_t)vcn << bits; loff_t to = vbo + ((loff_t)clen << bits); if (to <= new_valid) { ni->i_valid = to; pos = to; goto next; } if (vbo < pos) { pos = vbo; } else { to = (new_valid >> bits) << bits; if (pos < to) { ni->i_valid = to; pos = to; goto next; } } } } zerofrom = pos & (PAGE_SIZE - 1); len = PAGE_SIZE - zerofrom; if (pos + len > new_valid) len = new_valid - pos; err = pagecache_write_begin(file, mapping, pos, len, 0, &page, &fsdata); if (err) goto out; zero_user_segment(page, zerofrom, PAGE_SIZE); /* This function in any case puts page. */ err = pagecache_write_end(file, mapping, pos, len, len, page, fsdata); if (err < 0) goto out; pos += len; next: if (pos >= new_valid) break; balance_dirty_pages_ratelimited(mapping); cond_resched(); } return 0; out: ni->i_valid = valid; ntfs_inode_warn(inode, "failed to extend initialized size to %llx.", new_valid); return err; } /* * ntfs_zero_range - Helper function for punch_hole. * * It zeroes a range [vbo, vbo_to). */ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to) { int err = 0; struct address_space *mapping = inode->i_mapping; u32 blocksize = 1 << inode->i_blkbits; pgoff_t idx = vbo >> PAGE_SHIFT; u32 z_start = vbo & (PAGE_SIZE - 1); pgoff_t idx_end = (vbo_to + PAGE_SIZE - 1) >> PAGE_SHIFT; loff_t page_off; struct buffer_head *head, *bh; u32 bh_next, bh_off, z_end; sector_t iblock; struct page *page; for (; idx < idx_end; idx += 1, z_start = 0) { page_off = (loff_t)idx << PAGE_SHIFT; z_end = (page_off + PAGE_SIZE) > vbo_to ? (vbo_to - page_off) : PAGE_SIZE; iblock = page_off >> inode->i_blkbits; page = find_or_create_page(mapping, idx, mapping_gfp_constraint(mapping, ~__GFP_FS)); if (!page) return -ENOMEM; if (!page_has_buffers(page)) create_empty_buffers(page, blocksize, 0); bh = head = page_buffers(page); bh_off = 0; do { bh_next = bh_off + blocksize; if (bh_next <= z_start || bh_off >= z_end) continue; if (!buffer_mapped(bh)) { ntfs_get_block(inode, iblock, bh, 0); /* Unmapped? It's a hole - nothing to do. */ if (!buffer_mapped(bh)) continue; } /* Ok, it's mapped. Make sure it's up-to-date. */ if (PageUptodate(page)) set_buffer_uptodate(bh); if (!buffer_uptodate(bh)) { lock_buffer(bh); bh->b_end_io = end_buffer_read_sync; get_bh(bh); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) submit_bh(REQ_OP_READ, bh); #else submit_bh(REQ_OP_READ, 0, bh); #endif wait_on_buffer(bh); if (!buffer_uptodate(bh)) { unlock_page(page); put_page(page); err = -EIO; goto out; } } mark_buffer_dirty(bh); } while (bh_off = bh_next, iblock += 1, head != (bh = bh->b_this_page)); zero_user_segment(page, z_start, z_end); unlock_page(page); put_page(page); cond_resched(); } out: mark_inode_dirty(inode); return err; } /* * ntfs_sparse_cluster - Helper function to zero a new allocated clusters. * * NOTE: 512 <= cluster size <= 2M */ void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn, CLST len) { struct address_space *mapping = inode->i_mapping; struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; u64 vbo = (u64)vcn << sbi->cluster_bits; u64 bytes = (u64)len << sbi->cluster_bits; u32 blocksize = 1 << inode->i_blkbits; pgoff_t idx0 = page0 ? page0->index : -1; loff_t vbo_clst = vbo & sbi->cluster_mask_inv; loff_t end = ntfs_up_cluster(sbi, vbo + bytes); pgoff_t idx = vbo_clst >> PAGE_SHIFT; u32 from = vbo_clst & (PAGE_SIZE - 1); pgoff_t idx_end = (end + PAGE_SIZE - 1) >> PAGE_SHIFT; loff_t page_off; u32 to; bool partial; struct page *page; for (; idx < idx_end; idx += 1, from = 0) { page = idx == idx0 ? page0 : grab_cache_page(mapping, idx); if (!page) continue; page_off = (loff_t)idx << PAGE_SHIFT; to = (page_off + PAGE_SIZE) > end ? (end - page_off) : PAGE_SIZE; partial = false; if ((from || PAGE_SIZE != to) && likely(!page_has_buffers(page))) { create_empty_buffers(page, blocksize, 0); } if (page_has_buffers(page)) { struct buffer_head *head, *bh; u32 bh_off = 0; bh = head = page_buffers(page); do { u32 bh_next = bh_off + blocksize; if (from <= bh_off && bh_next <= to) { set_buffer_uptodate(bh); mark_buffer_dirty(bh); } else if (!buffer_uptodate(bh)) { partial = true; } bh_off = bh_next; } while (head != (bh = bh->b_this_page)); } zero_user_segment(page, from, to); if (!partial) { if (!PageUptodate(page)) SetPageUptodate(page); set_page_dirty(page); } if (idx != idx0) { unlock_page(page); put_page(page); } cond_resched(); } mark_inode_dirty(inode); } /* * ntfs_file_mmap - file_operations::mmap */ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma) { struct address_space *mapping = file->f_mapping; struct inode *inode = mapping->host; struct ntfs_inode *ni = ntfs_i(inode); u64 from = ((u64)vma->vm_pgoff << PAGE_SHIFT); bool rw = vma->vm_flags & VM_WRITE; int err; if (is_encrypted(ni)) { ntfs_inode_warn(inode, "mmap encrypted not supported"); return -EOPNOTSUPP; } if (is_dedup(ni)) { ntfs_inode_warn(inode, "mmap deduplicated not supported"); return -EOPNOTSUPP; } if (is_compressed(ni) && rw) { ntfs_inode_warn(inode, "mmap(write) compressed not supported"); return -EOPNOTSUPP; } if (rw) { u64 to = min_t(loff_t, i_size_read(inode), from + vma->vm_end - vma->vm_start); if (is_sparsed(ni)) { /* Allocate clusters for rw map. */ struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; CLST lcn, len; CLST vcn = from >> sbi->cluster_bits; CLST end = bytes_to_cluster(sbi, to); bool new; for (; vcn < end; vcn += len) { err = attr_data_get_block(ni, vcn, 1, &lcn, &len, &new); if (err) goto out; if (!new) continue; ntfs_sparse_cluster(inode, NULL, vcn, 1); } } if (ni->i_valid < to) { if (!inode_trylock(inode)) { err = -EAGAIN; goto out; } err = ntfs_extend_initialized_size(file, ni, ni->i_valid, to); inode_unlock(inode); if (err) goto out; } } err = generic_file_mmap(file, vma); out: return err; } static int ntfs_extend(struct inode *inode, loff_t pos, size_t count, struct file *file) { struct ntfs_inode *ni = ntfs_i(inode); struct address_space *mapping = inode->i_mapping; loff_t end = pos + count; bool extend_init = file && pos > ni->i_valid; int err; if (end <= inode->i_size && !extend_init) return 0; /* Mark rw ntfs as dirty. It will be cleared at umount. */ ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_DIRTY); if (end > inode->i_size) { err = ntfs_set_size(inode, end); if (err) goto out; inode->i_size = end; } if (extend_init && !is_compressed(ni)) { err = ntfs_extend_initialized_size(file, ni, ni->i_valid, pos); if (err) goto out; } else { err = 0; } inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); if (IS_SYNC(inode)) { int err2; err = filemap_fdatawrite_range(mapping, pos, end - 1); err2 = sync_mapping_buffers(mapping); if (!err) err = err2; err2 = write_inode_now(inode, 1); if (!err) err = err2; if (!err) err = filemap_fdatawait_range(mapping, pos, end - 1); } out: return err; } static int ntfs_truncate(struct inode *inode, loff_t new_size) { struct super_block *sb = inode->i_sb; struct ntfs_inode *ni = ntfs_i(inode); int err, dirty = 0; u64 new_valid; if (!S_ISREG(inode->i_mode)) return 0; if (is_compressed(ni)) { if (ni->i_valid > new_size) ni->i_valid = new_size; } else { err = block_truncate_page(inode->i_mapping, new_size, ntfs_get_block); if (err) return err; } new_valid = ntfs_up_block(sb, min_t(u64, ni->i_valid, new_size)); ni_lock(ni); truncate_setsize(inode, new_size); down_write(&ni->file.run_lock); err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, new_size, &new_valid, true, NULL); up_write(&ni->file.run_lock); if (new_valid < ni->i_valid) ni->i_valid = new_valid; ni_unlock(ni); ni->std_fa |= FILE_ATTRIBUTE_ARCHIVE; inode->i_ctime = inode->i_mtime = current_time(inode); if (!IS_DIRSYNC(inode)) { dirty = 1; } else { err = ntfs_sync_inode(inode); if (err) return err; } if (dirty) mark_inode_dirty(inode); /*ntfs_flush_inodes(inode->i_sb, inode, NULL);*/ return 0; } /* * ntfs_fallocate * * Preallocate space for a file. This implements ntfs's fallocate file * operation, which gets called from sys_fallocate system call. User * space requests 'len' bytes at 'vbo'. If FALLOC_FL_KEEP_SIZE is set * we just allocate clusters without zeroing them out. Otherwise we * allocate and zero out clusters via an expanding truncate. */ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len) { struct inode *inode = file->f_mapping->host; struct super_block *sb = inode->i_sb; struct ntfs_sb_info *sbi = sb->s_fs_info; struct ntfs_inode *ni = ntfs_i(inode); loff_t end = vbo + len; loff_t vbo_down = round_down(vbo, PAGE_SIZE); loff_t i_size; int err; /* No support for dir. */ if (!S_ISREG(inode->i_mode)) return -EOPNOTSUPP; /* Return error if mode is not supported. */ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE)) { ntfs_inode_warn(inode, "fallocate(0x%x) is not supported", mode); return -EOPNOTSUPP; } ntfs_set_state(sbi, NTFS_DIRTY_DIRTY); inode_lock(inode); i_size = inode->i_size; if (WARN_ON(ni->ni_flags & NI_FLAG_COMPRESSED_MASK)) { /* Should never be here, see ntfs_file_open. */ err = -EOPNOTSUPP; goto out; } if (mode & FALLOC_FL_PUNCH_HOLE) { u32 frame_size; loff_t mask, vbo_a, end_a, tmp; if (!(mode & FALLOC_FL_KEEP_SIZE)) { err = -EINVAL; goto out; } err = filemap_write_and_wait_range(inode->i_mapping, vbo, end - 1); if (err) goto out; err = filemap_write_and_wait_range(inode->i_mapping, end, LLONG_MAX); if (err) goto out; inode_dio_wait(inode); truncate_pagecache(inode, vbo_down); if (!is_sparsed(ni) && !is_compressed(ni)) { /* Normal file. */ err = ntfs_zero_range(inode, vbo, end); goto out; } ni_lock(ni); err = attr_punch_hole(ni, vbo, len, &frame_size); ni_unlock(ni); if (err != E_NTFS_NOTALIGNED) goto out; /* Process not aligned punch. */ mask = frame_size - 1; vbo_a = (vbo + mask) & ~mask; end_a = end & ~mask; tmp = min(vbo_a, end); if (tmp > vbo) { err = ntfs_zero_range(inode, vbo, tmp); if (err) goto out; } if (vbo < end_a && end_a < end) { err = ntfs_zero_range(inode, end_a, end); if (err) goto out; } /* Aligned punch_hole */ if (end_a > vbo_a) { ni_lock(ni); err = attr_punch_hole(ni, vbo_a, end_a - vbo_a, NULL); ni_unlock(ni); } } else if (mode & FALLOC_FL_COLLAPSE_RANGE) { if (mode & ~FALLOC_FL_COLLAPSE_RANGE) { err = -EINVAL; goto out; } /* * Write tail of the last page before removed range since * it will get removed from the page cache below. */ err = filemap_write_and_wait_range(inode->i_mapping, vbo_down, vbo); if (err) goto out; /* * Write data that will be shifted to preserve them * when discarding page cache below. */ err = filemap_write_and_wait_range(inode->i_mapping, end, LLONG_MAX); if (err) goto out; /* Wait for existing dio to complete. */ inode_dio_wait(inode); truncate_pagecache(inode, vbo_down); ni_lock(ni); err = attr_collapse_range(ni, vbo, len); ni_unlock(ni); } else { /* * Normal file: Allocate clusters, do not change 'valid' size. */ loff_t new_size = max(end, i_size); err = inode_newsize_ok(inode, new_size); if (err) goto out; err = ntfs_set_size(inode, new_size); if (err) goto out; if (is_sparsed(ni) || is_compressed(ni)) { CLST vcn_v = ni->i_valid >> sbi->cluster_bits; CLST vcn = vbo >> sbi->cluster_bits; CLST cend = bytes_to_cluster(sbi, end); CLST lcn, clen; bool new; /* * Allocate but do not zero new clusters. (see below comments) * This breaks security: One can read unused on-disk areas. * Zeroing these clusters may be too long. * Maybe we should check here for root rights? */ for (; vcn < cend; vcn += clen) { err = attr_data_get_block(ni, vcn, cend - vcn, &lcn, &clen, &new); if (err) goto out; if (!new || vcn >= vcn_v) continue; /* * Unwritten area. * NTFS is not able to store several unwritten areas. * Activate 'ntfs_sparse_cluster' to zero new allocated clusters. * * Dangerous in case: * 1G of sparsed clusters + 1 cluster of data => * valid_size == 1G + 1 cluster * fallocate(1G) will zero 1G and this can be very long * xfstest 016/086 will fail without 'ntfs_sparse_cluster'. */ ntfs_sparse_cluster(inode, NULL, vcn, min(vcn_v - vcn, clen)); } } if (mode & FALLOC_FL_KEEP_SIZE) { ni_lock(ni); /* True - Keep preallocated. */ err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, i_size, &ni->i_valid, true, NULL); ni_unlock(ni); } } out: if (err == -EFBIG) err = -ENOSPC; if (!err) { inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); } inode_unlock(inode); return err; } /* * ntfs3_setattr - inode_operations::setattr */ int ntfs3_setattr(struct dentry *dentry, struct iattr *attr) { struct super_block *sb = dentry->d_sb; struct ntfs_sb_info *sbi = sb->s_fs_info; struct inode *inode = d_inode(dentry); struct ntfs_inode *ni = ntfs_i(inode); u32 ia_valid = attr->ia_valid; umode_t mode = inode->i_mode; int err; if (sbi->options.no_acs_rules) { /* "No access rules" - Force any changes of time etc. */ attr->ia_valid |= ATTR_FORCE; /* and disable for editing some attributes. */ attr->ia_valid &= ~(ATTR_UID | ATTR_GID | ATTR_MODE); ia_valid = attr->ia_valid; } #if ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) && \ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 37))) || \ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) err = setattr_prepare(dentry, attr); #else err = inode_change_ok(inode, attr); #endif if (err) goto out; if (ia_valid & ATTR_SIZE) { loff_t oldsize = inode->i_size; if (WARN_ON(ni->ni_flags & NI_FLAG_COMPRESSED_MASK)) { /* Should never be here, see ntfs_file_open(). */ err = -EOPNOTSUPP; goto out; } inode_dio_wait(inode); if (attr->ia_size <= oldsize) err = ntfs_truncate(inode, attr->ia_size); else if (attr->ia_size > oldsize) err = ntfs_extend(inode, attr->ia_size, 0, NULL); if (err) goto out; ni->ni_flags |= NI_FLAG_UPDATE_PARENT; } setattr_copy(inode, attr); if (mode != inode->i_mode) { err = ntfs_acl_chmod(inode); if (err) goto out; /* Linux 'w' -> Windows 'ro'. */ if (0222 & inode->i_mode) ni->std_fa &= ~FILE_ATTRIBUTE_READONLY; else ni->std_fa |= FILE_ATTRIBUTE_READONLY; } if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) ntfs_save_wsl_perm(inode); mark_inode_dirty(inode); out: return err; } static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; struct ntfs_inode *ni = ntfs_i(inode); if (is_encrypted(ni)) { ntfs_inode_warn(inode, "encrypted i/o not supported"); return -EOPNOTSUPP; } if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) { ntfs_inode_warn(inode, "direct i/o + compressed not supported"); return -EOPNOTSUPP; } #ifndef CONFIG_NTFS3_LZX_XPRESS if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { ntfs_inode_warn( inode, "activate CONFIG_NTFS3_LZX_XPRESS to read external compressed files"); return -EOPNOTSUPP; } #endif if (is_dedup(ni)) { ntfs_inode_warn(inode, "read deduplicated not supported"); return -EOPNOTSUPP; } return generic_file_read_iter(iocb, iter); } /* * ntfs_get_frame_pages * * Return: Array of locked pages. */ static int ntfs_get_frame_pages(struct address_space *mapping, pgoff_t index, struct page **pages, u32 pages_per_frame, bool *frame_uptodate) { gfp_t gfp_mask = mapping_gfp_mask(mapping); u32 npages; *frame_uptodate = true; for (npages = 0; npages < pages_per_frame; npages++, index++) { struct page *page; page = find_or_create_page(mapping, index, gfp_mask); if (!page) { while (npages--) { page = pages[npages]; unlock_page(page); put_page(page); } return -ENOMEM; } if (!PageUptodate(page)) *frame_uptodate = false; pages[npages] = page; } return 0; } /* * ntfs_compress_write - Helper for ntfs_file_write_iter() (compressed files). */ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from) { int err; struct file *file = iocb->ki_filp; size_t count = iov_iter_count(from); loff_t pos = iocb->ki_pos; struct inode *inode = file_inode(file); loff_t i_size = inode->i_size; struct address_space *mapping = inode->i_mapping; struct ntfs_inode *ni = ntfs_i(inode); u64 valid = ni->i_valid; struct ntfs_sb_info *sbi = ni->mi.sbi; struct page *page, **pages = NULL; size_t written = 0; u8 frame_bits = NTFS_LZNT_CUNIT + sbi->cluster_bits; u32 frame_size = 1u << frame_bits; u32 pages_per_frame = frame_size >> PAGE_SHIFT; u32 ip, off; CLST frame; u64 frame_vbo; pgoff_t index; bool frame_uptodate; if (frame_size < PAGE_SIZE) { /* * frame_size == 8K if cluster 512 * frame_size == 64K if cluster 4096 */ ntfs_inode_warn(inode, "page size is bigger than frame size"); return -EOPNOTSUPP; } pages = kmalloc_array(pages_per_frame, sizeof(struct page *), GFP_NOFS); if (!pages) return -ENOMEM; current->backing_dev_info = inode_to_bdi(inode); err = file_remove_privs(file); if (err) goto out; err = file_update_time(file); if (err) goto out; /* Zero range [valid : pos). */ while (valid < pos) { CLST lcn, clen; frame = valid >> frame_bits; frame_vbo = valid & ~(frame_size - 1); off = valid & (frame_size - 1); err = attr_data_get_block(ni, frame << NTFS_LZNT_CUNIT, 0, &lcn, &clen, NULL); if (err) goto out; if (lcn == SPARSE_LCN) { ni->i_valid = valid = frame_vbo + ((u64)clen << sbi->cluster_bits); continue; } /* Load full frame. */ err = ntfs_get_frame_pages(mapping, frame_vbo >> PAGE_SHIFT, pages, pages_per_frame, &frame_uptodate); if (err) goto out; if (!frame_uptodate && off) { err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame); if (err) { for (ip = 0; ip < pages_per_frame; ip++) { page = pages[ip]; unlock_page(page); put_page(page); } goto out; } } ip = off >> PAGE_SHIFT; off = offset_in_page(valid); for (; ip < pages_per_frame; ip++, off = 0) { page = pages[ip]; zero_user_segment(page, off, PAGE_SIZE); flush_dcache_page(page); SetPageUptodate(page); } ni_lock(ni); err = ni_write_frame(ni, pages, pages_per_frame); ni_unlock(ni); for (ip = 0; ip < pages_per_frame; ip++) { page = pages[ip]; SetPageUptodate(page); unlock_page(page); put_page(page); } if (err) goto out; ni->i_valid = valid = frame_vbo + frame_size; } /* Copy user data [pos : pos + count). */ while (count) { size_t copied, bytes; off = pos & (frame_size - 1); bytes = frame_size - off; if (bytes > count) bytes = count; frame = pos >> frame_bits; frame_vbo = pos & ~(frame_size - 1); index = frame_vbo >> PAGE_SHIFT; if (unlikely(iov_iter_fault_in_readable(from, bytes))) { err = -EFAULT; goto out; } /* Load full frame. */ err = ntfs_get_frame_pages(mapping, index, pages, pages_per_frame, &frame_uptodate); if (err) goto out; if (!frame_uptodate) { loff_t to = pos + bytes; if (off || (to < i_size && (to & (frame_size - 1)))) { err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame); if (err) { for (ip = 0; ip < pages_per_frame; ip++) { page = pages[ip]; unlock_page(page); put_page(page); } goto out; } } } WARN_ON(!bytes); copied = 0; ip = off >> PAGE_SHIFT; off = offset_in_page(pos); /* Copy user data to pages. */ for (;;) { size_t cp, tail = PAGE_SIZE - off; page = pages[ip]; cp = iov_iter_copy_from_user_atomic(page, from, off, min(tail, bytes)); flush_dcache_page(page); iov_iter_advance(from, cp); copied += cp; bytes -= cp; if (!bytes || !cp) break; if (cp < tail) { off += cp; } else { ip++; off = 0; } } ni_lock(ni); err = ni_write_frame(ni, pages, pages_per_frame); ni_unlock(ni); for (ip = 0; ip < pages_per_frame; ip++) { page = pages[ip]; ClearPageDirty(page); SetPageUptodate(page); unlock_page(page); put_page(page); } if (err) goto out; /* * We can loop for a long time in here. Be nice and allow * us to schedule out to avoid softlocking if preempt * is disabled. */ cond_resched(); pos += copied; written += copied; count = iov_iter_count(from); } out: kfree(pages); current->backing_dev_info = NULL; if (err < 0) return err; iocb->ki_pos += written; if (iocb->ki_pos > ni->i_valid) ni->i_valid = iocb->ki_pos; return written; } /* * ntfs_file_write_iter - file_operations::write_iter */ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; struct address_space *mapping = file->f_mapping; struct inode *inode = mapping->host; ssize_t ret; struct ntfs_inode *ni = ntfs_i(inode); if (is_encrypted(ni)) { ntfs_inode_warn(inode, "encrypted i/o not supported"); return -EOPNOTSUPP; } if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) { ntfs_inode_warn(inode, "direct i/o + compressed not supported"); return -EOPNOTSUPP; } if (is_dedup(ni)) { ntfs_inode_warn(inode, "write into deduplicated not supported"); return -EOPNOTSUPP; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) if (!inode_trylock(inode)) { if (iocb->ki_flags & IOCB_NOWAIT) return -EAGAIN; inode_lock(inode); } #else inode_lock(inode); #endif ret = generic_write_checks(iocb, from); if (ret <= 0) goto out; if (WARN_ON(ni->ni_flags & NI_FLAG_COMPRESSED_MASK)) { /* Should never be here, see ntfs_file_open(). */ ret = -EOPNOTSUPP; goto out; } ret = ntfs_extend(inode, iocb->ki_pos, ret, file); if (ret) goto out; ret = is_compressed(ni) ? ntfs_compress_write(iocb, from) : __generic_file_write_iter(iocb, from); out: inode_unlock(inode); if (ret > 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) { ssize_t err; err = generic_write_sync(file, iocb->ki_pos - ret, ret); if (err < 0) ret = err; } #else ret = generic_write_sync(iocb, ret); #endif return ret; } /* * ntfs_file_open - file_operations::open */ int ntfs_file_open(struct inode *inode, struct file *file) { struct ntfs_inode *ni = ntfs_i(inode); if (unlikely((is_compressed(ni) || is_encrypted(ni)) && (file->f_flags & O_DIRECT))) { return -EOPNOTSUPP; } /* Decompress "external compressed" file if opened for rw. */ if ((ni->ni_flags & NI_FLAG_COMPRESSED_MASK) && (file->f_flags & (O_WRONLY | O_RDWR | O_TRUNC))) { #ifdef CONFIG_NTFS3_LZX_XPRESS int err = ni_decompress_file(ni); if (err) return err; #else ntfs_inode_warn( inode, "activate CONFIG_NTFS3_LZX_XPRESS to write external compressed files"); return -EOPNOTSUPP; #endif } return generic_file_open(inode, file); } /* * ntfs_file_release - file_operations::release */ static int ntfs_file_release(struct inode *inode, struct file *file) { struct ntfs_inode *ni = ntfs_i(inode); struct ntfs_sb_info *sbi = ni->mi.sbi; int err = 0; /* If we are last writer on the inode, drop the block reservation. */ if (sbi->options.prealloc && ((file->f_mode & FMODE_WRITE) && atomic_read(&inode->i_writecount) == 1)) { ni_lock(ni); down_write(&ni->file.run_lock); err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, inode->i_size, &ni->i_valid, false, NULL); up_write(&ni->file.run_lock); ni_unlock(ni); } return err; } /* * ntfs_fiemap - file_operations::fiemap */ int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, __u64 start, __u64 len) { int err; struct ntfs_inode *ni = ntfs_i(inode); if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) return -EOPNOTSUPP; ni_lock(ni); err = ni_fiemap(ni, fieinfo, start, len); ni_unlock(ni); return err; } // clang-format off const struct inode_operations ntfs_file_inode_operations = { .getattr = ntfs_getattr, .setattr = ntfs3_setattr, .listxattr = ntfs_listxattr, .permission = ntfs_permission, .get_acl = ntfs_get_acl, .set_acl = ntfs_set_acl, .fiemap = ntfs_fiemap, }; const struct file_operations ntfs_file_operations = { .llseek = generic_file_llseek, .read_iter = ntfs_file_read_iter, .write_iter = ntfs_file_write_iter, .unlocked_ioctl = ntfs_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = ntfs_compat_ioctl, #endif .splice_read = generic_file_splice_read, .mmap = ntfs_file_mmap, .open = ntfs_file_open, .fsync = generic_file_fsync, .splice_write = iter_file_splice_write, .fallocate = ntfs_fallocate, .release = ntfs_file_release, }; // clang-format on
6a28b821c2aae181d8129674e9db0c46a6258904
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/tests/lib/libm/t_asin.c
9b7a5922584f632a9e6a0f39e71dda017fcf697c
[]
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
6,887
c
t_asin.c
/* $NetBSD: t_asin.c,v 1.4 2018/11/07 03:59:36 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <atf-c.h> #include <float.h> #include <math.h> static const struct { double x; double y; } values[] = { { -1.0, -M_PI / 2, }, { -0.9, -1.119769514998634, }, { -0.5, -M_PI / 6, }, { -0.1, -0.1001674211615598, }, { 0.1, 0.1001674211615598, }, { 0.5, M_PI / 6, }, { 0.9, 1.119769514998634, }, { 1.0, M_PI / 2, }, }; /* * asin(3) */ ATF_TC(asin_nan); ATF_TC_HEAD(asin_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(NaN) == NaN"); } ATF_TC_BODY(asin_nan, tc) { const double x = 0.0L / 0.0L; if (isnan(asin(x)) == 0) atf_tc_fail_nonfatal("asin(NaN) != NaN"); } ATF_TC(asin_inf_neg); ATF_TC_HEAD(asin_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(-Inf) == NaN"); } ATF_TC_BODY(asin_inf_neg, tc) { const double x = -1.0L / 0.0L; if (isnan(asin(x)) == 0) atf_tc_fail_nonfatal("asin(-Inf) != NaN"); } ATF_TC(asin_inf_pos); ATF_TC_HEAD(asin_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(+Inf) == NaN"); } ATF_TC_BODY(asin_inf_pos, tc) { const double x = 1.0L / 0.0L; if (isnan(asin(x)) == 0) atf_tc_fail_nonfatal("asin(+Inf) != NaN"); } ATF_TC(asin_range); ATF_TC_HEAD(asin_range, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(x) == NaN, x < -1, x > 1"); } ATF_TC_BODY(asin_range, tc) { const double x[] = { -1.1, -1.000000001, 1.1, 1.000000001 }; size_t i; for (i = 0; i < __arraycount(x); i++) { if (isnan(asin(x[i])) == 0) atf_tc_fail_nonfatal("asin(%f) != NaN", x[i]); } } ATF_TC(asin_inrange); ATF_TC_HEAD(asin_inrange, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(x) for some values"); } ATF_TC_BODY(asin_inrange, tc) { const double eps = DBL_EPSILON; size_t i; for (i = 0; i < __arraycount(values); i++) { double x = values[i].x; double y = values[i].y; if (!(fabs((asin(x) - y)/y) <= eps)) atf_tc_fail_nonfatal("asin(%g) != %g", values[i].x, values[i].y); } } ATF_TC(asin_zero_neg); ATF_TC_HEAD(asin_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(-0.0) == -0.0"); } ATF_TC_BODY(asin_zero_neg, tc) { const double x = -0.0L; double y = asin(x); if (fabs(y) > 0.0 || signbit(y) == 0) atf_tc_fail_nonfatal("asin(-0.0) != -0.0"); } ATF_TC(asin_zero_pos); ATF_TC_HEAD(asin_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test asin(+0.0) == +0.0"); } ATF_TC_BODY(asin_zero_pos, tc) { const double x = 0.0L; double y = asin(x); if (fabs(y) > 0.0 || signbit(y) != 0) atf_tc_fail_nonfatal("asin(+0.0) != +0.0"); } /* * asinf(3) */ ATF_TC(asinf_nan); ATF_TC_HEAD(asinf_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(NaN) == NaN"); } ATF_TC_BODY(asinf_nan, tc) { const float x = 0.0L / 0.0L; if (isnan(asinf(x)) == 0) atf_tc_fail_nonfatal("asinf(NaN) != NaN"); } ATF_TC(asinf_inf_neg); ATF_TC_HEAD(asinf_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(-Inf) == NaN"); } ATF_TC_BODY(asinf_inf_neg, tc) { const float x = -1.0L / 0.0L; if (isnan(asinf(x)) == 0) atf_tc_fail_nonfatal("asinf(-Inf) != NaN"); } ATF_TC(asinf_inf_pos); ATF_TC_HEAD(asinf_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(+Inf) == NaN"); } ATF_TC_BODY(asinf_inf_pos, tc) { const float x = 1.0L / 0.0L; if (isnan(asinf(x)) == 0) atf_tc_fail_nonfatal("asinf(+Inf) != NaN"); } ATF_TC(asinf_range); ATF_TC_HEAD(asinf_range, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(x) == NaN, x < -1, x > 1"); } ATF_TC_BODY(asinf_range, tc) { const float x[] = { -1.1, -1.0000001, 1.1, 1.0000001 }; size_t i; for (i = 0; i < __arraycount(x); i++) { if (isnan(asinf(x[i])) == 0) atf_tc_fail_nonfatal("asinf(%f) != NaN", x[i]); } } ATF_TC(asinf_inrange); ATF_TC_HEAD(asinf_inrange, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(x) for some values"); } ATF_TC_BODY(asinf_inrange, tc) { const float eps = FLT_EPSILON; size_t i; for (i = 0; i < __arraycount(values); i++) { float x = values[i].x; float y = values[i].y; if (fabs(x) == 0.5) atf_tc_expect_fail("asinf is busted," " gives ~2ulp error"); if (!(fabsf((asinf(x) - y)/y) <= eps)) { atf_tc_fail_nonfatal("asinf(%.8g) = %.8g != %.8g," " error=~%.1fulp", x, asinf(x), y, fabsf(((asinf(x) - y)/y)/eps)); } if (fabs(x) == 0.5) atf_tc_expect_pass(); } } ATF_TC(asinf_zero_neg); ATF_TC_HEAD(asinf_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(-0.0) == -0.0"); } ATF_TC_BODY(asinf_zero_neg, tc) { const float x = -0.0L; float y = asinf(x); if (fabsf(y) > 0.0 || signbit(y) == 0) atf_tc_fail_nonfatal("asinf(-0.0) != -0.0"); } ATF_TC(asinf_zero_pos); ATF_TC_HEAD(asinf_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test asinf(+0.0) == +0.0"); } ATF_TC_BODY(asinf_zero_pos, tc) { const float x = 0.0L; float y = asinf(x); if (fabsf(y) > 0.0 || signbit(y) != 0) atf_tc_fail_nonfatal("asinf(+0.0) != +0.0"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, asin_nan); ATF_TP_ADD_TC(tp, asin_inf_neg); ATF_TP_ADD_TC(tp, asin_inf_pos); ATF_TP_ADD_TC(tp, asin_range); ATF_TP_ADD_TC(tp, asin_inrange); ATF_TP_ADD_TC(tp, asin_zero_neg); ATF_TP_ADD_TC(tp, asin_zero_pos); ATF_TP_ADD_TC(tp, asinf_nan); ATF_TP_ADD_TC(tp, asinf_inf_neg); ATF_TP_ADD_TC(tp, asinf_inf_pos); ATF_TP_ADD_TC(tp, asinf_range); ATF_TP_ADD_TC(tp, asinf_inrange); ATF_TP_ADD_TC(tp, asinf_zero_neg); ATF_TP_ADD_TC(tp, asinf_zero_pos); return atf_no_error(); }
b42d9048551b3f0f3ff20ae76bb455466ce0446f
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/include/any-windows-any/ddk/usbkern.h
56b0f74a1e1dfcb3a93a1360c3bbcbb433009194
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
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
36
h
usbkern.h
#pragma once #include "usbiodef.h"
7e6e5f8ba2223cf9fa2fa5df2ae1d8b72d283c44
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/mvme68k/stand/bootst/rawfs.h
ed5d3b7c03fa362be9abea0d0b15e17405c7c816
[]
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
535
h
rawfs.h
/* $NetBSD: rawfs.h,v 1.4 2008/01/12 09:54:30 tsutsui Exp $ */ /* * Raw file system - for stream devices like tapes. * No random access, only sequential read allowed. */ int rawfs_open(const char *path, struct open_file *f); int rawfs_close(struct open_file *f); int rawfs_read(struct open_file *f, void *buf, u_int size, u_int *resid); int rawfs_write(struct open_file *f, void *buf, u_int size, u_int *resid); off_t rawfs_seek(struct open_file *f, off_t offset, int where); int rawfs_stat(struct open_file *f, struct stat *sb);
1eed999262025f5b699351a39622ed7f280a1fdb
54563310baa8c9c4c13a0481136eccf81d11446c
/check/test/utils.h
afdbbfdf222b6a7b042fa00bd63f293029eb1e93
[ "MIT", "GPL-1.0-or-later" ]
permissive
Snaipe/libcsptr
7e48569ef35f1c81046d5b1681b59906607023f8
ac734512f97d42be728c457b8084ae5fd6ef50c6
refs/heads/master
2023-07-05T11:18:09.916275
2020-09-03T11:32:31
2022-01-05T13:55:45
29,017,019
1,034
128
MIT
2022-11-10T12:30:55
2015-01-09T13:16:42
CMake
UTF-8
C
false
false
1,094
h
utils.h
#ifndef UTILS_H_ # define UTILS_H_ #include <check.h> #include <inttypes.h> __attribute__((always_inline)) inline int is_aligned(void *ptr) { uintptr_t off = (uintptr_t) ptr; return !(off % sizeof (void *)); } __attribute__((always_inline)) inline void assert_valid_ptr(void *ptr) { ck_assert_msg(ptr != NULL, "Expected unique_ptr to return a non-null pointer."); ck_assert_msg(is_aligned(ptr), "Expected unique_ptr to return an aligned pointer."); } struct meta { int i; long l; double d; }; extern const struct meta m; __attribute__((always_inline)) inline void assert_valid_meta(const struct meta *m, const struct meta *m2) { ck_assert_msg(m2 != NULL, "Expected metadata to be present"); ck_assert_msg(m != m2, "Expected metadata to be copied"); const int intact = m->i == m2->i && m->l == m2->l && m->d == m2->d; ck_assert_msg(intact, "Expected metadata to be intact."); } #define lambda(RType, Body) ({ RType __fn__ Body; __fn__; }) #define UNUSED __attribute__ ((unused)) #endif /* !UTILS_H_ */
adbf7e40c8d1cfedbe73f254f7fb1fe5d7b69085
c474663ca0eb361b191e5462f484cd936f0930b2
/inc/dmyifix.h
ed58a287e8bc50694a49871a692f543f7210b270
[ "MIT" ]
permissive
foone/BRender-1997
bc0ea2b170305d18e8b8f573724e27913b39c5a5
4e319d61ee474cc5536ef52fe254c2d327d5ea98
refs/heads/main
2023-08-13T01:59:56.422996
2022-05-03T21:29:09
2022-05-03T21:31:40
488,368,857
134
12
null
null
null
null
UTF-8
C
false
false
249
h
dmyifix.h
/* * Copyright (c) 1992,1993-1995 by Argonaut Technologies Limited. All rights reserved. * * $Id: dmyifix.h 2.1 1996/03/12 12:37:18 sam Exp $ * $Locker: $ * * Dummy inline fixed ops. file to stop stupid dependency generators complaining */
baf9d817e4c253da444738f23e3a9374d129ca38
d579699e6728aa74084f8cc4dc435007b9f523a8
/tests/recompilation-tests/semi.c
0cb6a249d22cb7b0db896f5aabaf1d1ff13562d6
[ "BSD-3-Clause" ]
permissive
BoomerangDecompiler/boomerang
b3c6b4e88c152ac6d437f3dd3640fd9ffa157cb6
411041305f90d1d7c994f67255b5c03ea8666e60
refs/heads/develop
2023-08-31T03:50:56.112711
2020-12-28T12:11:55
2020-12-28T17:38:56
7,819,729
281
41
NOASSERTION
2020-12-27T17:59:52
2013-01-25T12:26:59
C++
UTF-8
C
false
false
1,440
c
semi.c
/* * This file is part of the Boomerang Decompiler. * * See the file "LICENSE.TERMS" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. */ /* * This test program has a case where a semidominator (node L/6) is not the * same as its dominator (semi[6] = 4, idom[6] = 2) */ #include <stdio.h> int main(int argc, char *argv[]) { int x = 1; /* A */ if (argc > 2) { do { x = 2; /* B */ if (argc > 2) goto nine; x = 3; /* D */ if (argc > 3) { x = 4; /* F */ if (argc > 4) { five: x = 5; /* I */ printf("5"); } else x = 8; /* K */ } else { nine: x = 9; /* G */ printf("9"); x = 10; /* J */ goto five; } x = 6; /* L */ } while (argc < 6); } else { do { x = 11; /* C */ if (argc == 11) goto thirteen; x = 12; } while (argc < 12); thirteen: x = 13; /* H */ } x = 7; /* M */ return x; }
afe60b1f54a71dc0a480a08c5aa2d6c2766dbda6
e7e2ee02a1cd3e0229346855c9aa6d931e3ca1c4
/src/epoch_gc.h
9fde39fb4fd6d019104565f0695e16c3cbab5b4c
[ "BSD-3-Clause" ]
permissive
danielealbano/cachegrand
7c2dd00424596796e52b62ca2e9eb107d06e0e5b
eb2df00feab7639a0327492c11a334a22dec7e60
refs/heads/main
2023-08-19T11:04:18.418711
2023-06-11T22:44:49
2023-06-11T22:44:49
125,234,630
904
33
BSD-3-Clause
2023-06-11T22:44:51
2018-03-14T15:33:02
C
UTF-8
C
false
false
4,268
h
epoch_gc.h
#ifndef CACHEGRAND_EPOCH_GC_H #define CACHEGRAND_EPOCH_GC_H #ifdef __cplusplus extern "C" { #endif #define EPOCH_GC_STAGED_OBJECTS_RING_SIZE (16 * 1024) // Tests depend on having a batch size of at least 4 #define EPOCH_GC_STAGED_OBJECT_DESTRUCTOR_CB_BATCH_SIZE (16) enum epoch_gc_object_type { EPOCH_GC_OBJECT_TYPE_HASHTABLE_KEY_VALUE, EPOCH_GC_OBJECT_TYPE_HASHTABLE_DATA, EPOCH_GC_OBJECT_TYPE_STORAGEDB_ENTRY_INDEX_XSMALL, // to be used with values smaller than 64kb EPOCH_GC_OBJECT_TYPE_STORAGEDB_ENTRY_INDEX_SMALL, // to be used with values smaller than 64kb EPOCH_GC_OBJECT_TYPE_STORAGEDB_ENTRY_INDEX_MEDIUM, // to be used with values smaller than 1MB EPOCH_GC_OBJECT_TYPE_STORAGEDB_ENTRY_INDEX_LARGE, // to be used with values smaller than 16MB EPOCH_GC_OBJECT_TYPE_STORAGEDB_ENTRY_INDEX_XLARGE, // to be used with rest of values bigger than 16MB EPOCH_GC_OBJECT_TYPE_MAX, }; typedef enum epoch_gc_object_type epoch_gc_object_type_t; typedef struct epoch_gc epoch_gc_t; struct epoch_gc { double_linked_list_t *thread_list; uint64_t thread_list_change_epoch; epoch_gc_object_type_t object_type; spinlock_lock_volatile_t thread_list_spinlock; }; typedef struct epoch_gc_thread epoch_gc_thread_t; struct epoch_gc_thread { ring_bounded_queue_spsc_uint128_t *staged_objects_ring_last; double_linked_list_t *staged_objects_ring_list; uint64_t epoch; epoch_gc_t *epoch_gc; spinlock_lock_volatile_t staged_objects_ring_list_spinlock; bool thread_terminated; }; typedef union epoch_gc_staged_object epoch_gc_staged_object_t; union epoch_gc_staged_object { struct { uint64_t epoch; void *object; } data; uint128_t _packed; }; typedef void (epoch_gc_staged_object_destructor_cb_t)( uint8_t, epoch_gc_staged_object_t[EPOCH_GC_STAGED_OBJECT_DESTRUCTOR_CB_BATCH_SIZE]); #if DEBUG == 1 // Used only for testing and debugging epoch_gc_thread_t** epoch_gc_get_thread_local_epoch_gc(); epoch_gc_staged_object_destructor_cb_t** epoch_gc_get_epoch_gc_staged_object_destructor_cb(); #endif epoch_gc_t *epoch_gc_init( epoch_gc_object_type_t object_type); void epoch_gc_free( epoch_gc_t *epoch_gc); void epoch_gc_register_object_type_destructor_cb( epoch_gc_object_type_t object_type, epoch_gc_staged_object_destructor_cb_t *destructor_cb); void epoch_gc_unregister_object_type_destructor_cb( epoch_gc_object_type_t object_type); void epoch_gc_thread_append_new_staged_objects_ring( epoch_gc_thread_t *epoch_gc_thread); epoch_gc_thread_t *epoch_gc_thread_init(); void epoch_gc_thread_free( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_register_global( epoch_gc_t *epoch_gc, epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_unregister_global( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_register_local( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_unregister_local( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_get_instance( epoch_gc_object_type_t object_type, epoch_gc_t **epoch_gc, epoch_gc_thread_t **epoch_gc_thread); bool epoch_gc_thread_is_terminated( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_terminate( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_set_epoch( epoch_gc_thread_t *epoch_gc_thread, uint64_t epoch); void epoch_gc_thread_advance_epoch_tsc( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_advance_epoch_by_one( epoch_gc_thread_t *epoch_gc_thread); void epoch_gc_thread_destruct_staged_objects_batch( epoch_gc_staged_object_destructor_cb_t *destructor_cb, uint8_t staged_objects_counter, epoch_gc_staged_object_t *staged_objects[EPOCH_GC_STAGED_OBJECT_DESTRUCTOR_CB_BATCH_SIZE]); uint32_t epoch_gc_thread_collect( epoch_gc_thread_t *epoch_gc_thread, uint32_t max_objects); uint32_t epoch_gc_thread_collect_all( epoch_gc_thread_t *epoch_gc_thread); bool epoch_gc_stage_object( epoch_gc_object_type_t object_type, void* object); #ifdef __cplusplus } #endif #endif //CACHEGRAND_EPOCH_GC_H
23b659c50927144e5707dc1ecd025cd75d7424a8
0ba2e5061577f6286ff9265ef1df9aca96769445
/math/root_finding/c/bisection_method.c
293b507555bc180dad20ead25612b39359eec891
[ "CC0-1.0" ]
permissive
ZoranPandovski/al-go-rithms
68d5d02f80a61de9baf8e50a81a52e7d0b3983a0
4ae6ba54e90af14af236e03e435eb0402dcac787
refs/heads/master
2023-09-04T16:04:04.321676
2023-06-06T15:22:16
2023-06-06T15:22:16
93,438,176
1,421
2,445
CC0-1.0
2023-06-15T14:24:28
2017-06-05T19:20:20
Jupyter Notebook
UTF-8
C
false
false
637
c
bisection_method.c
#include <stdio.h> #include <math.h> float function(float xi){ return pow (xi,2) + 2*xi - 4; } float bisection (float a, float b, int i){ static float x; float f; float f_a; while (i != 0){ x = (a+b)/2; i--; f = function(x); f_a = function(a); if (f*f_a < 0){ b = x; a = a; }else if (f*f_a > 0){ a = x; b = b; } else return x; } return x; } int main() { float a = 0; /* Low Interval */ float b = 5; /* High Interval */ int i = 50; /* Iterations */ float res; res = bisection(a, b, i); printf ("\nRoot of x^2+2*x-4: %5f\n", res); return 0; }
964136fa794473ba21803e667d0f08c2a6d08567
106589e0030bde6ca790a3e825667e1e8ef168f9
/lib/ssh_kdf.c
5f670cb19217b38c7fbf788b8d4ccc0775ffc1f9
[ "GPL-1.0-or-later", "BSD-3-Clause", "GPL-2.0-only", "BSD-2-Clause", "MIT" ]
permissive
microsoft/SymCrypt
bc97272fd79b5ed5fbd1b67bbf75dbddea8d6f72
4d3fd5136855648d2a5e987f3b95473b056876b1
refs/heads/main
2023-08-20T23:31:36.248359
2023-01-18T01:59:02
2023-01-18T01:59:02
175,901,565
258
49
MIT
2023-07-21T16:52:30
2019-03-15T22:57:01
C
UTF-8
C
false
false
4,435
c
ssh_kdf.c
// // ssh_kdf.c // // Copyright (c) Microsoft Corporation. Licensed under the MIT license. // // // This module implements SSH-KDF specified in RFC 4253 Section 7.2. // #include "precomp.h" SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSshKdfExpandKey( _Out_ PSYMCRYPT_SSHKDF_EXPANDED_KEY pExpandedKey, _In_ PCSYMCRYPT_HASH pHashFunc, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey) { pExpandedKey->pHashFunc = pHashFunc; SymCryptHashInit(pHashFunc, &pExpandedKey->hashState); SymCryptHashAppend(pHashFunc, &pExpandedKey->hashState, pbKey, cbKey); return SYMCRYPT_NO_ERROR; } SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSshKdfDerive( _In_ PCSYMCRYPT_SSHKDF_EXPANDED_KEY pExpandedKey, _In_reads_(cbHashValue) PCBYTE pbHashValue, SIZE_T cbHashValue, BYTE label, _In_reads_(cbSessionId) PCBYTE pbSessionId, SIZE_T cbSessionId, _Inout_updates_(cbOutput) PBYTE pbOutput, SIZE_T cbOutput) { SYMCRYPT_ERROR scError = SYMCRYPT_NO_ERROR; SYMCRYPT_HASH_STATE hashState; PCBYTE pcbOutputSave = pbOutput; PCSYMCRYPT_HASH pHashFunc = pExpandedKey->pHashFunc; SIZE_T cbHashResultSize = SymCryptHashResultSize(pHashFunc); while (cbOutput > 0) { SIZE_T cbGeneratedOutput = pbOutput - pcbOutputSave; SymCryptHashStateCopy(pHashFunc, &pExpandedKey->hashState, &hashState); SymCryptHashAppend(pHashFunc, &hashState, pbHashValue, cbHashValue); // hashState has (K || H) // label and session ID are appended only in the first iteration if (cbGeneratedOutput == 0) { SymCryptHashAppend(pHashFunc, &hashState, &label, 1); SymCryptHashAppend(pHashFunc, &hashState, pbSessionId, cbSessionId); } else { // We break the read-once write-once rule here by appending data to a // hash computation from pbOutput that was written by SymCryptHashResult() // below. // Modification of data in pbOutput buffer after it's written and before // used again will have uncontrolled disturbances in the hash output and cannot // be used to gain knowledge about the secret key. SymCryptHashAppend(pHashFunc, &hashState, pcbOutputSave, cbGeneratedOutput); // hashState has (K || H || K1 .. Ki) } SymCryptHashResult(pHashFunc, &hashState, pbOutput, cbOutput); SIZE_T bytesCopied = SYMCRYPT_MIN(cbOutput, cbHashResultSize); pbOutput += bytesCopied; cbOutput -= bytesCopied; } return scError; } SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSshKdf( _In_ PCSYMCRYPT_HASH pHashFunc, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey, _In_reads_(cbHashValue) PCBYTE pbHashValue, SIZE_T cbHashValue, BYTE label, _In_reads_(cbSessionId) PCBYTE pbSessionId, SIZE_T cbSessionId, _Out_writes_(cbOutput) PBYTE pbOutput, SIZE_T cbOutput) { SYMCRYPT_SSHKDF_EXPANDED_KEY expandedKey; SYMCRYPT_ERROR scError = SYMCRYPT_NO_ERROR; scError = SymCryptSshKdfExpandKey(&expandedKey, pHashFunc, pbKey, cbKey); if (scError != SYMCRYPT_NO_ERROR) { goto cleanup; } scError = SymCryptSshKdfDerive(&expandedKey, pbHashValue, cbHashValue, label, pbSessionId, cbSessionId, pbOutput, cbOutput); cleanup: SymCryptWipeKnownSize(&expandedKey, sizeof(expandedKey)); return scError; }
3de9d8e322087b45dfe67d817d1095aa04df9834
edccfef24a84712873938e24e138d2ce79834181
/third-party/zstd/tests/fuzz/dictionary_decompress.c
c37d14374ba45a22acfa8529d92108a1e42afd10
[ "MIT", "Zlib", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause", "GPL-2.0-only" ]
permissive
rui314/mold
aa746e60ee491af54b7753d35bef3d2b821ae0c6
f76d3e0d0c285fab4d770d4b57035d57690fade7
refs/heads/main
2023-08-31T22:14:27.427281
2023-08-31T09:16:26
2023-08-31T09:16:32
299,510,783
12,149
503
MIT
2023-09-14T03:54:12
2020-09-29T05:12:48
C++
UTF-8
C
false
false
2,599
c
dictionary_decompress.c
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under both the BSD-style license (found in the * LICENSE file in the root directory of this source tree) and the GPLv2 (found * in the COPYING file in the root directory of this source tree). * You may select, at your option, one of the above-listed licenses. */ /** * This fuzz target attempts to decompress the fuzzed data with the dictionary * decompression function to ensure the decompressor never crashes. It does not * fuzz the dictionary. */ #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include "fuzz_helpers.h" #include "zstd_helpers.h" #include "fuzz_data_producer.h" #include "fuzz_third_party_seq_prod.h" static ZSTD_DCtx *dctx = NULL; int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) { FUZZ_SEQ_PROD_SETUP(); /* Give a random portion of src data to the producer, to use for parameter generation. The rest will be used for (de)compression */ FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(src, size); size = FUZZ_dataProducer_reserveDataPrefix(producer); FUZZ_dict_t dict; ZSTD_DDict* ddict = NULL; if (!dctx) { dctx = ZSTD_createDCtx(); FUZZ_ASSERT(dctx); } dict = FUZZ_train(src, size, producer); if (FUZZ_dataProducer_uint32Range(producer, 0, 1) == 0) { ddict = ZSTD_createDDict(dict.buff, dict.size); FUZZ_ASSERT(ddict); } else { if (FUZZ_dataProducer_uint32Range(producer, 0, 1) == 0) FUZZ_ZASSERT(ZSTD_DCtx_loadDictionary_advanced( dctx, dict.buff, dict.size, (ZSTD_dictLoadMethod_e)FUZZ_dataProducer_uint32Range(producer, 0, 1), (ZSTD_dictContentType_e)FUZZ_dataProducer_uint32Range(producer, 0, 2))); else FUZZ_ZASSERT(ZSTD_DCtx_refPrefix_advanced( dctx, dict.buff, dict.size, (ZSTD_dictContentType_e)FUZZ_dataProducer_uint32Range(producer, 0, 2))); } { size_t const bufSize = FUZZ_dataProducer_uint32Range(producer, 0, 10 * size); void* rBuf = FUZZ_malloc(bufSize); if (ddict) { ZSTD_decompress_usingDDict(dctx, rBuf, bufSize, src, size, ddict); } else { ZSTD_decompressDCtx(dctx, rBuf, bufSize, src, size); } free(rBuf); } free(dict.buff); FUZZ_dataProducer_free(producer); ZSTD_freeDDict(ddict); #ifndef STATEFUL_FUZZING ZSTD_freeDCtx(dctx); dctx = NULL; #endif FUZZ_SEQ_PROD_TEARDOWN(); return 0; }
3c206ae6cb8793959bd83a90b22754996227ea56
bb38c44037a99d0a12a12d92059678f2faebbc80
/src/common/pl/plpgsql/src/pl_reserved_kwlist.h
a68210e37301a603b5b753ce39410a266751f614
[ "LicenseRef-scancode-mulanpsl-2.0-en", "LicenseRef-scancode-unknown-license-reference", "PostgreSQL", "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode", "LicenseRef-scancode-warranty-disclaimer", "curl", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LGPL-2.1-only", "CC-BY-4.0", "LicenseRef-scancode-protobuf", "OpenSSL", "LicenseRef-scancode-generic-export-compliance", "X11-distribute-modifications-variant", "LicenseRef-scancode-other-permissive", "MIT", "NCSA", "Python-2.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "CC-BY-3.0", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only", "BSL-1.0", "Apache-2.0", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Zlib" ]
permissive
opengauss-mirror/openGauss-server
a9c5a62908643492347830826c56da49f0942796
310e84631c68c8bf37b004148b66f94064f701e4
refs/heads/master
2023-07-26T19:29:12.495484
2023-07-17T12:23:32
2023-07-17T12:23:32
276,117,477
591
208
MulanPSL-2.0
2023-04-28T12:30:18
2020-06-30T14:08:59
C++
UTF-8
C
false
false
2,413
h
pl_reserved_kwlist.h
/*------------------------------------------------------------------------- * * pl_reserved_kwlist.h * * The keyword lists are kept in their own source files for use by * automatic tools. The exact representation of a keyword is determined * by the PG_KEYWORD macro, which is not defined in this file; it can * be defined by the caller for special purposes. * * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/pl/plpgsql/src/pl_reserved_kwlist.h * *------------------------------------------------------------------------- */ /* There is deliberately not an #ifndef PL_RESERVED_KWLIST_H here. */ /* * List of (keyword-name, keyword-token-value) pairs. * * Be careful not to put the same word into pl_unreserved_kwlist.h. * * Note: gen_keywordlist.pl requires the entries to appear in ASCII order. */ /* name, value */ PG_KEYWORD("all", K_ALL) PG_KEYWORD("begin", K_BEGIN) PG_KEYWORD("by", K_BY) PG_KEYWORD("case", K_CASE) PG_KEYWORD("close", K_CLOSE) PG_KEYWORD("collate", K_COLLATE) PG_KEYWORD("declare", K_DECLARE) PG_KEYWORD("default", K_DEFAULT) PG_KEYWORD("delete", K_DELETE) PG_KEYWORD("diagnostics", K_DIAGNOSTICS) PG_KEYWORD("else", K_ELSE) PG_KEYWORD("elseif", K_ELSIF) PG_KEYWORD("elsif", K_ELSIF) PG_KEYWORD("end", K_END) PG_KEYWORD("exception", K_EXCEPTION) PG_KEYWORD("execute", K_EXECUTE) PG_KEYWORD("exit", K_EXIT) PG_KEYWORD("fetch", K_FETCH) PG_KEYWORD("for", K_FOR) PG_KEYWORD("forall", K_FORALL) PG_KEYWORD("foreach", K_FOREACH) PG_KEYWORD("from", K_FROM) PG_KEYWORD("function", K_FUNCTION) PG_KEYWORD("get", K_GET) PG_KEYWORD("goto", K_GOTO) PG_KEYWORD("if", K_IF) PG_KEYWORD("in", K_IN) PG_KEYWORD("insert", K_INSERT) PG_KEYWORD("into", K_INTO) PG_KEYWORD("limit", K_LIMIT) PG_KEYWORD("loop", K_LOOP) PG_KEYWORD("move", K_MOVE) PG_KEYWORD("not", K_NOT) PG_KEYWORD("null", K_NULL) PG_KEYWORD("of", K_OF) PG_KEYWORD("open", K_OPEN) PG_KEYWORD("or", K_OR) PG_KEYWORD("out", K_OUT) PG_KEYWORD("procedure", K_PROCEDURE) PG_KEYWORD("raise", K_RAISE) PG_KEYWORD("ref", K_REF) PG_KEYWORD("return", K_RETURN) PG_KEYWORD("select", K_SELECT) PG_KEYWORD("strict", K_STRICT) PG_KEYWORD("then", K_THEN) PG_KEYWORD("to", K_TO) PG_KEYWORD("update", K_UPDATE) PG_KEYWORD("using", K_USING) PG_KEYWORD("when", K_WHEN) PG_KEYWORD("while", K_WHILE)
d5efe69d0f1312977047375b9b180d9140211bdb
75196819c910f3fd523f1a4d28e5d0fe12570ab1
/src/bdb53/examples/c/csv/DbRecord.c
6b7bf9157f8a05bffafd23034947cd53e983d4a6
[ "MIT", "BSD-3-Clause", "Sleepycat" ]
permissive
gridcoin-community/Gridcoin-Research
889967579b5b05bcc3ae836697a0f173b5ae91ea
21414dd0f63c9a34060f7f762f08d1a52aeb9e87
refs/heads/development
2023-09-04T09:21:55.006935
2023-09-03T17:45:20
2023-09-03T17:45:20
23,332,350
292
117
MIT
2023-09-11T10:22:10
2014-08-25T23:41:04
HTML
UTF-8
C
false
false
11,258
c
DbRecord.c
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ #include "csv.h" #include "csv_local.h" #include "csv_extern.h" static int DbRecord_field(DbRecord *, u_int, void *, datatype); static int DbRecord_search_field(DbField *, char *, OPERATOR); static int DbRecord_search_recno(char *, OPERATOR); /* * DbRecord_print -- * Display a DbRecord structure. */ void DbRecord_print(DbRecord *recordp, FILE *fp) { DbField *f; void *faddr; if (fp == NULL) fp = stdout; fprintf(fp, "Record: %lu:\n", (u_long)recordp->recno); for (f = fieldlist; f->name != NULL; ++f) { faddr = (u_int8_t *)recordp + f->offset; fprintf(fp, "\t%s: ", f->name); switch (f->type) { case NOTSET: /* NOTREACHED */ abort(); break; case DOUBLE: fprintf(fp, "%f\n", *(double *)faddr); break; case STRING: fprintf(fp, "%s\n", *(char **)faddr); break; case UNSIGNED_LONG: fprintf(fp, "%lu\n", *(u_long *)faddr); break; } } } /* * DbRecord_read -- * Read a specific record from the database. */ int DbRecord_read(u_long recno_ulong, DbRecord *recordp) { DBT key, data; u_int32_t recno; int ret; /* * XXX * This code assumes a record number (typed as u_int32_t) is the same * size as an unsigned long, and there's no reason to believe that. */ recno = recno_ulong; /* * Retrieve the requested record from the primary database. Have * Berkeley DB allocate memory for us, keeps the DB handle thread * safe. * * We have the Berkeley DB library allocate memory for the record, * which we own and must eventually free. The reason is so we can * have the string fields in the structure point into the actual * record, rather than allocating structure local memory to hold them * and copying them out of the record. */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); key.data = &recno; key.size = sizeof(recno); data.flags = DB_DBT_MALLOC; if ((ret = db->get(db, NULL, &key, &data, 0)) != 0) return (ret); if ((ret = DbRecord_init(&key, &data, recordp)) != 0) return (ret); return (0); } /* * DbRecord_discard -- * Discard a DbRecord structure. */ int DbRecord_discard(DbRecord *recordp) { /* Free the allocated memory. */ free(recordp->raw); recordp->raw = NULL; return (0); } /* * DbRecord_init -- * Fill in a DbRecord from the database key/data pair. */ int DbRecord_init(const DBT *key, const DBT *data, DbRecord *recordp) { DbField *f; u_int32_t skip; void *faddr; /* Initialize the structure (get the pre-set index values). */ *recordp = DbRecord_base; /* Fill in the ID and version. */ memcpy(&recordp->recno, key->data, sizeof(u_int32_t)); memcpy(&recordp->version, (u_int32_t *)data->data + 1, sizeof(u_int32_t)); /* Set up the record references. */ recordp->raw = data->data; recordp->offset = (u_int32_t *)data->data + 1; skip = (recordp->field_count + 2) * sizeof(u_int32_t); recordp->record = (u_int8_t *)data->data + skip; recordp->record_len = data->size - skip; for (f = fieldlist; f->name != NULL; ++f) { faddr = (u_int8_t *)recordp + f->offset; if (DbRecord_field( recordp, f->fieldno, faddr, f->type) != 0) return (1); } return (0); } /* * DbRecord_field -- * Fill in an individual field of the DbRecord. */ static int DbRecord_field( DbRecord *recordp, u_int field, void *addr, datatype type) { size_t len; char number_buf[20]; /* * The offset table is 0-based, the field numbers are 1-based. * Correct. */ --field; switch (type) { case NOTSET: /* NOTREACHED */ abort(); break; case STRING: *((u_char **)addr) = recordp->record + recordp->offset[field]; recordp->record[recordp->offset[field] + OFFSET_LEN(recordp->offset, field)] = '\0'; break; case DOUBLE: case UNSIGNED_LONG: /* This shouldn't be possible -- 2^32 is only 10 digits. */ len = OFFSET_LEN(recordp->offset, field); if (len > sizeof(number_buf) - 1) { dbenv->errx(dbenv, "record %lu field %lu: numeric field is %lu bytes and too large to copy", recordp->recno, field, (u_long)len); return (1); } memcpy(number_buf, recordp->record + recordp->offset[field], len); number_buf[len] = '\0'; if (type == DOUBLE) { if (len == 0) *(double *)addr = 0; else if (strtod_err(number_buf, (double *)addr) != 0) goto fmt_err; } else if (len == 0) *(u_long *)addr = 0; else if (strtoul_err(number_buf, (u_long *)addr) != 0) { fmt_err: dbenv->errx(dbenv, "record %lu: numeric field %u error: %s", recordp->recno, field, number_buf); return (1); } break; } return (0); } /* * DbRecord_search_field_name -- * Search, looking for a record by field name. */ int DbRecord_search_field_name(char *field, char *value, OPERATOR op) { DbField *f; for (f = fieldlist; f->name != NULL; ++f) if (strcasecmp(field, f->name) == 0) return (DbRecord_search_field(f, value, op)); /* Record numbers aren't handled as fields. */ if (strcasecmp(field, "id") == 0) return (DbRecord_search_recno(value, op)); dbenv->errx(dbenv, "unknown field name: %s", field); return (1); } /* * DbRecord_search_field_number -- * Search, looking for a record by field number. */ int DbRecord_search_field_number(u_int32_t fieldno, char *value, OPERATOR op) { DbField *f; for (f = fieldlist; f->name != NULL; ++f) if (fieldno == f->fieldno) return (DbRecord_search_field(f, value, op)); dbenv->errx(dbenv, "field number %lu not configured", (u_long)fieldno); return (1); } /* * DbRecord_search_recno -- * Search, looking for a record by record number. */ static int DbRecord_search_recno(char *value, OPERATOR op) { DBC *dbc; DbRecord record; DBT key, data; u_int32_t recno; u_long recno_ulong; int ret; /* * XXX * This code assumes a record number (typed as u_int32_t) is the same * size as an unsigned long, and there's no reason to believe that. */ if (strtoul_err(value, &recno_ulong) != 0) return (1); memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); key.data = &recno; key.size = sizeof(recno); if ((ret = db->cursor(db, NULL, &dbc, 0)) != 0) return (ret); /* * Retrieve the first record that interests us. The range depends on * the operator: * * ~ error * != beginning to end * < beginning to first match * <= beginning to last match * = first match to last match * > record after last match to end * >= first match to end */ if (op == LT || op == LTEQ || op == NEQ || op == WC || op == NWC) recno = 1; else if (op == WC || op == NWC) { dbenv->errx(dbenv, "wildcard operator only supported for string fields"); return (1); } else { recno = recno_ulong; if (op == GT) ++recno; } if ((ret = dbc->c_get(dbc, &key, &data, DB_SET)) != 0) goto err; for (;;) { if ((ret = DbRecord_init(&key, &data, &record)) != 0) break; if (field_cmp_ulong(&record.recno, &recno_ulong, op)) DbRecord_print(&record, NULL); else if (op == LT || op == LTEQ || op == EQ) break; if ((ret = dbc->c_get(dbc, &key, &data, DB_NEXT)) != 0) break; } err: return (ret == DB_NOTFOUND ? 0 : ret); } /* * DbRecord_search_field -- * Search, looking for a record by field. */ static int DbRecord_search_field(DbField *f, char *value, OPERATOR op) { #ifdef HAVE_WILDCARD_SUPPORT regex_t preq; #endif DBC *dbc; DbRecord record; DBT key, data, pkey; double value_double; u_long value_ulong; u_int32_t cursor_flags; int ret, t_ret; int (*cmp)(void *, void *, OPERATOR); void *faddr, *valuep; dbc = NULL; memset(&key, 0, sizeof(key)); memset(&pkey, 0, sizeof(pkey)); memset(&data, 0, sizeof(data)); /* * Initialize the comparison function, crack the value. Wild cards * are always strings, otherwise we follow the field type. */ if (op == WC || op == NWC) { #ifdef HAVE_WILDCARD_SUPPORT if (f->type != STRING) { dbenv->errx(dbenv, "wildcard operator only supported for string fields"); return (1); } if (regcomp(&preq, value, 0) != 0) { dbenv->errx(dbenv, "regcomp of pattern failed"); return (1); } valuep = &preq; cmp = field_cmp_re; #else dbenv->errx(dbenv, "wildcard operators not supported in this build"); return (1); #endif } else switch (f->type) { case DOUBLE: if (strtod_err(value, &value_double) != 0) return (1); cmp = field_cmp_double; valuep = &value_double; key.size = sizeof(double); break; case STRING: valuep = value; cmp = field_cmp_string; key.size = (u_int32_t)strlen(value); break; case UNSIGNED_LONG: if (strtoul_err(value, &value_ulong) != 0) return (1); cmp = field_cmp_ulong; valuep = &value_ulong; key.size = sizeof(u_long); break; default: case NOTSET: abort(); /* NOTREACHED */ } /* * Retrieve the first record that interests us. The range depends on * the operator: * * ~ beginning to end * != beginning to end * < beginning to first match * <= beginning to last match * = first match to last match * > record after last match to end * >= first match to end * * If we have a secondary, set a cursor in the secondary, else set the * cursor to the beginning of the primary. * * XXX * If the wildcard string has a leading non-magic character we should * be able to do a range search instead of a full-database search. * * Step through records to the first non-match or to the end of the * database, depending on the operation. If the comparison function * returns success for a key/data pair, print the pair. */ if (f->secondary == NULL || op == NEQ || op == WC || op == NWC) { if ((ret = db->cursor(db, NULL, &dbc, 0)) != 0) goto err; while ((ret = dbc->c_get(dbc, &key, &data, DB_NEXT)) == 0) { if ((ret = DbRecord_init(&key, &data, &record)) != 0) break; faddr = (u_int8_t *)&record + f->offset; if (cmp(faddr, valuep, op)) DbRecord_print(&record, NULL); else if (op == EQ || op == LT || op == LTEQ) break; } } else { if ((ret = f->secondary->cursor(f->secondary, NULL, &dbc, 0)) != 0) goto err; key.data = valuep; cursor_flags = op == LT || op == LTEQ ? DB_FIRST : DB_SET_RANGE; if ((ret = dbc->c_pget(dbc, &key, &pkey, &data, cursor_flags)) != 0) goto done; if (op == GT) { while ((ret = dbc->c_pget( dbc, &key, &pkey, &data, DB_NEXT)) == 0) { if ((ret = DbRecord_init(&pkey, &data, &record)) != 0) break; faddr = (u_int8_t *)&record + f->offset; if (cmp(faddr, valuep, op) != 0) break; } if (ret != 0) goto done; } do { if ((ret = DbRecord_init(&pkey, &data, &record)) != 0) break; faddr = (u_int8_t *)&record + f->offset; if (cmp(faddr, valuep, op)) DbRecord_print(&record, NULL); else if (op == EQ || op == LT || op == LTEQ) break; } while ((ret = dbc->c_pget(dbc, &key, &pkey, &data, DB_NEXT)) == 0); } done: if (ret == DB_NOTFOUND) ret = 0; err: if (dbc != NULL && (t_ret = dbc->c_close(dbc)) != 0 && ret == 0) ret = t_ret; #ifdef HAVE_WILDCARD_SUPPORT if (op == WC || op == NWC) regfree(&preq); #endif return (ret); }
37dd9681137db47778ca89a614d40444efb6f3e8
f62ddee2dcadcae0e90f969be513b04e16dabf58
/data/source/yaltools/mount_handle/set_keys.c
8754a98e8d15df0cf5ecf8d0c8806937b1a9baae
[ "Apache-2.0" ]
permissive
libyal/libyal
30bccf56471dbf874292fe32d5d9173fd470df0e
124111953917f65782a66a80e96a502ce2331b09
refs/heads/main
2023-07-25T09:25:46.068071
2023-07-08T09:56:44
2023-07-08T09:56:44
23,780,738
196
30
Apache-2.0
2022-11-27T19:01:42
2014-09-08T05:57:58
C
UTF-8
C
false
false
1,890
c
set_keys.c
/* Sets the keys * Returns 1 if successful or -1 on error */ int mount_handle_set_keys( mount_handle_t *mount_handle, const system_character_t *string, libcerror_error_t **error ) { static char *function = "mount_handle_set_keys"; size_t string_length = 0; uint32_t base16_variant = 0; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } string_length = system_string_length( string ); if( memory_set( mount_handle->key_data, 0, 16 ) == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_SET_FAILED, "%s: unable to clear key data.", function ); goto on_error; } base16_variant = LIBUNA_BASE16_VARIANT_RFC4648; #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) if( _BYTE_STREAM_HOST_IS_ENDIAN_BIG ) { base16_variant |= LIBUNA_BASE16_VARIANT_ENCODING_UTF16_BIG_ENDIAN; } else { base16_variant |= LIBUNA_BASE16_VARIANT_ENCODING_UTF16_LITTLE_ENDIAN; } #endif if( string_length != 32 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, "%s: unsupported string length.", function ); goto on_error; } if( libuna_base16_stream_copy_to_byte_stream( (uint8_t *) string, string_length, mount_handle->key_data, 16, base16_variant, 0, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_COPY_FAILED, "%s: unable to copy key data.", function ); goto on_error; } mount_handle->key_size = 16; return( 1 ); on_error: memory_set( mount_handle->key_data, 0, 16 ); mount_handle->key_size = 0; return( -1 ); }
73d0ee6838a395c47b020d427a365eec219db235
908814829c9c568ae9994c49c372af9151e91576
/net/utils/net_chksum.c
13737714a4c7c039d63e43d2f5db780da43a40b2
[ "HPND-sell-variant", "MIT-open-group", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause", "MIT-0", "LicenseRef-scancode-gary-s-brown", "GPL-1.0-or-later", "MIT", "LicenseRef-scancode-bsd-atmel", "HPND", "ISC", "LicenseRef-scancode-other-permissive", "SunPro", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-proprietary-license", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
PX4/NuttX
53c93fc5ff9c6443df23efc8a7f3380e2120048e
c23b72dffeb0de0d1a836ab561eb9169c4a9e58e
refs/heads/px4_firmware_nuttx-10.3.0+
2023-09-04T07:35:46.839633
2023-08-10T18:47:04
2023-08-14T16:53:04
39,532,678
121
203
Apache-2.0
2023-08-15T15:11:35
2015-07-22T22:06:58
C
UTF-8
C
false
false
3,755
c
net_chksum.c
/**************************************************************************** * net/utils/net_chksum.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #ifdef CONFIG_NET #include "utils/utils.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: chksum * * Description: * Calculate the raw change sum over the memory region described by * data and len. * * Input Parameters: * sum - Partial calculations carried over from a previous call to * chksum(). This should be zero on the first time that check * sum is called. * data - Beginning of the data to include in the checksum. * len - Length of the data to include in the checksum. * * Returned Value: * The updated checksum value. * ****************************************************************************/ #ifndef CONFIG_NET_ARCH_CHKSUM uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len) { FAR const uint8_t *dataptr; FAR const uint8_t *last_byte; uint16_t t; dataptr = data; last_byte = data + len - 1; while (dataptr < last_byte) { /* At least two more bytes */ t = ((uint16_t)dataptr[0] << 8) + dataptr[1]; sum += t; if (sum < t) { sum++; /* carry */ } dataptr += 2; } if (dataptr == last_byte) { t = (dataptr[0] << 8) + 0; sum += t; if (sum < t) { sum++; /* carry */ } } /* Return sum in host byte order. */ return sum; } #endif /* CONFIG_NET_ARCH_CHKSUM */ /**************************************************************************** * Name: net_chksum * * Description: * Calculate the Internet checksum over a buffer. * * The Internet checksum is the one's complement of the one's complement * sum of all 16-bit words in the buffer. * * See RFC1071. * * If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be * provided by architecture-specific logic. * * Input Parameters: * * buf - A pointer to the buffer over which the checksum is to be computed. * * len - The length of the buffer over which the checksum is to be * computed. * * Returned Value: * The Internet checksum of the buffer. * ****************************************************************************/ #ifndef CONFIG_NET_ARCH_CHKSUM uint16_t net_chksum(FAR uint16_t *data, uint16_t len) { return HTONS(chksum(0, (uint8_t *)data, len)); } #endif /* CONFIG_NET_ARCH_CHKSUM */ #endif /* CONFIG_NET */
b95e555f96f898fcab3de19f1686c36d25c87b71
00c64e0967d197d8c6fc3427954e2d0b2ff13ca0
/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vluxseg6ei64.c
efabb3a28e373a99457af30810dfc4c2449183b5
[ "Apache-2.0", "LLVM-exception", "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
triSYCL/sycl
893048e80158cf3359c1ad8912da9ccf493faf69
5a95a7136a11b75f01ef839d9229780032bbeecf
refs/heads/sycl/unified/master
2023-08-23T22:06:46.238209
2023-05-24T22:54:31
2023-05-24T22:54:31
178,923,006
103
17
NOASSERTION
2023-09-12T20:03:26
2019-04-01T18:29:01
null
UTF-8
C
false
false
135,459
c
vluxseg6ei64.c
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // REQUIRES: riscv-registered-target // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \ // RUN: -target-feature +experimental-zvfh -disable-O0-optnone \ // RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \ // RUN: FileCheck --check-prefix=CHECK-RV64 %s #include <riscv_vector.h> // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16mf4( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } @llvm.riscv.vluxseg6.nxv1f16.nxv1i64.i64(<vscale x 1 x half> poison, <vscale x 1 x half> poison, <vscale x 1 x half> poison, <vscale x 1 x half> poison, <vscale x 1 x half> poison, <vscale x 1 x half> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16mf4(vfloat16mf4_t *v0, vfloat16mf4_t *v1, vfloat16mf4_t *v2, vfloat16mf4_t *v3, vfloat16mf4_t *v4, vfloat16mf4_t *v5, const _Float16 *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } @llvm.riscv.vluxseg6.nxv2f16.nxv2i64.i64(<vscale x 2 x half> poison, <vscale x 2 x half> poison, <vscale x 2 x half> poison, <vscale x 2 x half> poison, <vscale x 2 x half> poison, <vscale x 2 x half> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16mf2(vfloat16mf2_t *v0, vfloat16mf2_t *v1, vfloat16mf2_t *v2, vfloat16mf2_t *v3, vfloat16mf2_t *v4, vfloat16mf2_t *v5, const _Float16 *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } @llvm.riscv.vluxseg6.nxv4f16.nxv4i64.i64(<vscale x 4 x half> poison, <vscale x 4 x half> poison, <vscale x 4 x half> poison, <vscale x 4 x half> poison, <vscale x 4 x half> poison, <vscale x 4 x half> poison, ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16m1(vfloat16m1_t *v0, vfloat16m1_t *v1, vfloat16m1_t *v2, vfloat16m1_t *v3, vfloat16m1_t *v4, vfloat16m1_t *v5, const _Float16 *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f32mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } @llvm.riscv.vluxseg6.nxv1f32.nxv1i64.i64(<vscale x 1 x float> poison, <vscale x 1 x float> poison, <vscale x 1 x float> poison, <vscale x 1 x float> poison, <vscale x 1 x float> poison, <vscale x 1 x float> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f32mf2(vfloat32mf2_t *v0, vfloat32mf2_t *v1, vfloat32mf2_t *v2, vfloat32mf2_t *v3, vfloat32mf2_t *v4, vfloat32mf2_t *v5, const float *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f32m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } @llvm.riscv.vluxseg6.nxv2f32.nxv2i64.i64(<vscale x 2 x float> poison, <vscale x 2 x float> poison, <vscale x 2 x float> poison, <vscale x 2 x float> poison, <vscale x 2 x float> poison, <vscale x 2 x float> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f32m1(vfloat32m1_t *v0, vfloat32m1_t *v1, vfloat32m1_t *v2, vfloat32m1_t *v3, vfloat32m1_t *v4, vfloat32m1_t *v5, const float *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f64m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } @llvm.riscv.vluxseg6.nxv1f64.nxv1i64.i64(<vscale x 1 x double> poison, <vscale x 1 x double> poison, <vscale x 1 x double> poison, <vscale x 1 x double> poison, <vscale x 1 x double> poison, <vscale x 1 x double> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f64m1(vfloat64m1_t *v0, vfloat64m1_t *v1, vfloat64m1_t *v2, vfloat64m1_t *v3, vfloat64m1_t *v4, vfloat64m1_t *v5, const double *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf8( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } @llvm.riscv.vluxseg6.nxv1i8.nxv1i64.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf8(vint8mf8_t *v0, vint8mf8_t *v1, vint8mf8_t *v2, vint8mf8_t *v3, vint8mf8_t *v4, vint8mf8_t *v5, const int8_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf4( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } @llvm.riscv.vluxseg6.nxv2i8.nxv2i64.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf4(vint8mf4_t *v0, vint8mf4_t *v1, vint8mf4_t *v2, vint8mf4_t *v3, vint8mf4_t *v4, vint8mf4_t *v5, const int8_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } @llvm.riscv.vluxseg6.nxv4i8.nxv4i64.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf2(vint8mf2_t *v0, vint8mf2_t *v1, vint8mf2_t *v2, vint8mf2_t *v3, vint8mf2_t *v4, vint8mf2_t *v5, const int8_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } @llvm.riscv.vluxseg6.nxv8i8.nxv8i64.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, ptr [[BASE:%.*]], <vscale x 8 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8m1(vint8m1_t *v0, vint8m1_t *v1, vint8m1_t *v2, vint8m1_t *v3, vint8m1_t *v4, vint8m1_t *v5, const int8_t *base, vuint64m8_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16mf4( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } @llvm.riscv.vluxseg6.nxv1i16.nxv1i64.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16mf4(vint16mf4_t *v0, vint16mf4_t *v1, vint16mf4_t *v2, vint16mf4_t *v3, vint16mf4_t *v4, vint16mf4_t *v5, const int16_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } @llvm.riscv.vluxseg6.nxv2i16.nxv2i64.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16mf2(vint16mf2_t *v0, vint16mf2_t *v1, vint16mf2_t *v2, vint16mf2_t *v3, vint16mf2_t *v4, vint16mf2_t *v5, const int16_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } @llvm.riscv.vluxseg6.nxv4i16.nxv4i64.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16m1(vint16m1_t *v0, vint16m1_t *v1, vint16m1_t *v2, vint16m1_t *v3, vint16m1_t *v4, vint16m1_t *v5, const int16_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i32mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.riscv.vluxseg6.nxv1i32.nxv1i64.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i32mf2(vint32mf2_t *v0, vint32mf2_t *v1, vint32mf2_t *v2, vint32mf2_t *v3, vint32mf2_t *v4, vint32mf2_t *v5, const int32_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i32m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.riscv.vluxseg6.nxv2i32.nxv2i64.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i32m1(vint32m1_t *v0, vint32m1_t *v1, vint32m1_t *v2, vint32m1_t *v3, vint32m1_t *v4, vint32m1_t *v5, const int32_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i64m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } @llvm.riscv.vluxseg6.nxv1i64.nxv1i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i64m1(vint64m1_t *v0, vint64m1_t *v1, vint64m1_t *v2, vint64m1_t *v3, vint64m1_t *v4, vint64m1_t *v5, const int64_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf8( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } @llvm.riscv.vluxseg6.nxv1i8.nxv1i64.i64(<vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, <vscale x 1 x i8> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf8(vuint8mf8_t *v0, vuint8mf8_t *v1, vuint8mf8_t *v2, vuint8mf8_t *v3, vuint8mf8_t *v4, vuint8mf8_t *v5, const uint8_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf4( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } @llvm.riscv.vluxseg6.nxv2i8.nxv2i64.i64(<vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, <vscale x 2 x i8> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf4(vuint8mf4_t *v0, vuint8mf4_t *v1, vuint8mf4_t *v2, vuint8mf4_t *v3, vuint8mf4_t *v4, vuint8mf4_t *v5, const uint8_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } @llvm.riscv.vluxseg6.nxv4i8.nxv4i64.i64(<vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, <vscale x 4 x i8> poison, ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf2(vuint8mf2_t *v0, vuint8mf2_t *v1, vuint8mf2_t *v2, vuint8mf2_t *v3, vuint8mf2_t *v4, vuint8mf2_t *v5, const uint8_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } @llvm.riscv.vluxseg6.nxv8i8.nxv8i64.i64(<vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, <vscale x 8 x i8> poison, ptr [[BASE:%.*]], <vscale x 8 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8m1(vuint8m1_t *v0, vuint8m1_t *v1, vuint8m1_t *v2, vuint8m1_t *v3, vuint8m1_t *v4, vuint8m1_t *v5, const uint8_t *base, vuint64m8_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16mf4( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } @llvm.riscv.vluxseg6.nxv1i16.nxv1i64.i64(<vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, <vscale x 1 x i16> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16mf4(vuint16mf4_t *v0, vuint16mf4_t *v1, vuint16mf4_t *v2, vuint16mf4_t *v3, vuint16mf4_t *v4, vuint16mf4_t *v5, const uint16_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } @llvm.riscv.vluxseg6.nxv2i16.nxv2i64.i64(<vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, <vscale x 2 x i16> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16mf2(vuint16mf2_t *v0, vuint16mf2_t *v1, vuint16mf2_t *v2, vuint16mf2_t *v3, vuint16mf2_t *v4, vuint16mf2_t *v5, const uint16_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } @llvm.riscv.vluxseg6.nxv4i16.nxv4i64.i64(<vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, <vscale x 4 x i16> poison, ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16m1(vuint16m1_t *v0, vuint16m1_t *v1, vuint16m1_t *v2, vuint16m1_t *v3, vuint16m1_t *v4, vuint16m1_t *v5, const uint16_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u32mf2( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.riscv.vluxseg6.nxv1i32.nxv1i64.i64(<vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, <vscale x 1 x i32> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u32mf2(vuint32mf2_t *v0, vuint32mf2_t *v1, vuint32mf2_t *v2, vuint32mf2_t *v3, vuint32mf2_t *v4, vuint32mf2_t *v5, const uint32_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u32m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.riscv.vluxseg6.nxv2i32.nxv2i64.i64(<vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, <vscale x 2 x i32> poison, ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u32m1(vuint32m1_t *v0, vuint32m1_t *v1, vuint32m1_t *v2, vuint32m1_t *v3, vuint32m1_t *v4, vuint32m1_t *v5, const uint32_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u64m1( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } @llvm.riscv.vluxseg6.nxv1i64.nxv1i64.i64(<vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, <vscale x 1 x i64> poison, ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], i64 [[VL:%.*]]) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u64m1(vuint64m1_t *v0, vuint64m1_t *v1, vuint64m1_t *v2, vuint64m1_t *v3, vuint64m1_t *v4, vuint64m1_t *v5, const uint64_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16mf4_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } @llvm.riscv.vluxseg6.mask.nxv1f16.nxv1i64.i64(<vscale x 1 x half> [[MASKEDOFF0:%.*]], <vscale x 1 x half> [[MASKEDOFF1:%.*]], <vscale x 1 x half> [[MASKEDOFF2:%.*]], <vscale x 1 x half> [[MASKEDOFF3:%.*]], <vscale x 1 x half> [[MASKEDOFF4:%.*]], <vscale x 1 x half> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half>, <vscale x 1 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16mf4_m(vfloat16mf4_t *v0, vfloat16mf4_t *v1, vfloat16mf4_t *v2, vfloat16mf4_t *v3, vfloat16mf4_t *v4, vfloat16mf4_t *v5, vbool64_t mask, vfloat16mf4_t maskedoff0, vfloat16mf4_t maskedoff1, vfloat16mf4_t maskedoff2, vfloat16mf4_t maskedoff3, vfloat16mf4_t maskedoff4, vfloat16mf4_t maskedoff5, const _Float16 *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } @llvm.riscv.vluxseg6.mask.nxv2f16.nxv2i64.i64(<vscale x 2 x half> [[MASKEDOFF0:%.*]], <vscale x 2 x half> [[MASKEDOFF1:%.*]], <vscale x 2 x half> [[MASKEDOFF2:%.*]], <vscale x 2 x half> [[MASKEDOFF3:%.*]], <vscale x 2 x half> [[MASKEDOFF4:%.*]], <vscale x 2 x half> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half>, <vscale x 2 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16mf2_m(vfloat16mf2_t *v0, vfloat16mf2_t *v1, vfloat16mf2_t *v2, vfloat16mf2_t *v3, vfloat16mf2_t *v4, vfloat16mf2_t *v5, vbool32_t mask, vfloat16mf2_t maskedoff0, vfloat16mf2_t maskedoff1, vfloat16mf2_t maskedoff2, vfloat16mf2_t maskedoff3, vfloat16mf2_t maskedoff4, vfloat16mf2_t maskedoff5, const _Float16 *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f16m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } @llvm.riscv.vluxseg6.mask.nxv4f16.nxv4i64.i64(<vscale x 4 x half> [[MASKEDOFF0:%.*]], <vscale x 4 x half> [[MASKEDOFF1:%.*]], <vscale x 4 x half> [[MASKEDOFF2:%.*]], <vscale x 4 x half> [[MASKEDOFF3:%.*]], <vscale x 4 x half> [[MASKEDOFF4:%.*]], <vscale x 4 x half> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half>, <vscale x 4 x half> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x half> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f16m1_m(vfloat16m1_t *v0, vfloat16m1_t *v1, vfloat16m1_t *v2, vfloat16m1_t *v3, vfloat16m1_t *v4, vfloat16m1_t *v5, vbool16_t mask, vfloat16m1_t maskedoff0, vfloat16m1_t maskedoff1, vfloat16m1_t maskedoff2, vfloat16m1_t maskedoff3, vfloat16m1_t maskedoff4, vfloat16m1_t maskedoff5, const _Float16 *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f32mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } @llvm.riscv.vluxseg6.mask.nxv1f32.nxv1i64.i64(<vscale x 1 x float> [[MASKEDOFF0:%.*]], <vscale x 1 x float> [[MASKEDOFF1:%.*]], <vscale x 1 x float> [[MASKEDOFF2:%.*]], <vscale x 1 x float> [[MASKEDOFF3:%.*]], <vscale x 1 x float> [[MASKEDOFF4:%.*]], <vscale x 1 x float> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x float> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f32mf2_m(vfloat32mf2_t *v0, vfloat32mf2_t *v1, vfloat32mf2_t *v2, vfloat32mf2_t *v3, vfloat32mf2_t *v4, vfloat32mf2_t *v5, vbool64_t mask, vfloat32mf2_t maskedoff0, vfloat32mf2_t maskedoff1, vfloat32mf2_t maskedoff2, vfloat32mf2_t maskedoff3, vfloat32mf2_t maskedoff4, vfloat32mf2_t maskedoff5, const float *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f32m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } @llvm.riscv.vluxseg6.mask.nxv2f32.nxv2i64.i64(<vscale x 2 x float> [[MASKEDOFF0:%.*]], <vscale x 2 x float> [[MASKEDOFF1:%.*]], <vscale x 2 x float> [[MASKEDOFF2:%.*]], <vscale x 2 x float> [[MASKEDOFF3:%.*]], <vscale x 2 x float> [[MASKEDOFF4:%.*]], <vscale x 2 x float> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float>, <vscale x 2 x float> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x float> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f32m1_m(vfloat32m1_t *v0, vfloat32m1_t *v1, vfloat32m1_t *v2, vfloat32m1_t *v3, vfloat32m1_t *v4, vfloat32m1_t *v5, vbool32_t mask, vfloat32m1_t maskedoff0, vfloat32m1_t maskedoff1, vfloat32m1_t maskedoff2, vfloat32m1_t maskedoff3, vfloat32m1_t maskedoff4, vfloat32m1_t maskedoff5, const float *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_f64m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } @llvm.riscv.vluxseg6.mask.nxv1f64.nxv1i64.i64(<vscale x 1 x double> [[MASKEDOFF0:%.*]], <vscale x 1 x double> [[MASKEDOFF1:%.*]], <vscale x 1 x double> [[MASKEDOFF2:%.*]], <vscale x 1 x double> [[MASKEDOFF3:%.*]], <vscale x 1 x double> [[MASKEDOFF4:%.*]], <vscale x 1 x double> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double>, <vscale x 1 x double> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x double> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_f64m1_m(vfloat64m1_t *v0, vfloat64m1_t *v1, vfloat64m1_t *v2, vfloat64m1_t *v3, vfloat64m1_t *v4, vfloat64m1_t *v5, vbool64_t mask, vfloat64m1_t maskedoff0, vfloat64m1_t maskedoff1, vfloat64m1_t maskedoff2, vfloat64m1_t maskedoff3, vfloat64m1_t maskedoff4, vfloat64m1_t maskedoff5, const double *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf8_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } @llvm.riscv.vluxseg6.mask.nxv1i8.nxv1i64.i64(<vscale x 1 x i8> [[MASKEDOFF0:%.*]], <vscale x 1 x i8> [[MASKEDOFF1:%.*]], <vscale x 1 x i8> [[MASKEDOFF2:%.*]], <vscale x 1 x i8> [[MASKEDOFF3:%.*]], <vscale x 1 x i8> [[MASKEDOFF4:%.*]], <vscale x 1 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf8_m(vint8mf8_t *v0, vint8mf8_t *v1, vint8mf8_t *v2, vint8mf8_t *v3, vint8mf8_t *v4, vint8mf8_t *v5, vbool64_t mask, vint8mf8_t maskedoff0, vint8mf8_t maskedoff1, vint8mf8_t maskedoff2, vint8mf8_t maskedoff3, vint8mf8_t maskedoff4, vint8mf8_t maskedoff5, const int8_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf4_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } @llvm.riscv.vluxseg6.mask.nxv2i8.nxv2i64.i64(<vscale x 2 x i8> [[MASKEDOFF0:%.*]], <vscale x 2 x i8> [[MASKEDOFF1:%.*]], <vscale x 2 x i8> [[MASKEDOFF2:%.*]], <vscale x 2 x i8> [[MASKEDOFF3:%.*]], <vscale x 2 x i8> [[MASKEDOFF4:%.*]], <vscale x 2 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf4_m(vint8mf4_t *v0, vint8mf4_t *v1, vint8mf4_t *v2, vint8mf4_t *v3, vint8mf4_t *v4, vint8mf4_t *v5, vbool32_t mask, vint8mf4_t maskedoff0, vint8mf4_t maskedoff1, vint8mf4_t maskedoff2, vint8mf4_t maskedoff3, vint8mf4_t maskedoff4, vint8mf4_t maskedoff5, const int8_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } @llvm.riscv.vluxseg6.mask.nxv4i8.nxv4i64.i64(<vscale x 4 x i8> [[MASKEDOFF0:%.*]], <vscale x 4 x i8> [[MASKEDOFF1:%.*]], <vscale x 4 x i8> [[MASKEDOFF2:%.*]], <vscale x 4 x i8> [[MASKEDOFF3:%.*]], <vscale x 4 x i8> [[MASKEDOFF4:%.*]], <vscale x 4 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8mf2_m(vint8mf2_t *v0, vint8mf2_t *v1, vint8mf2_t *v2, vint8mf2_t *v3, vint8mf2_t *v4, vint8mf2_t *v5, vbool16_t mask, vint8mf2_t maskedoff0, vint8mf2_t maskedoff1, vint8mf2_t maskedoff2, vint8mf2_t maskedoff3, vint8mf2_t maskedoff4, vint8mf2_t maskedoff5, const int8_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i8m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } @llvm.riscv.vluxseg6.mask.nxv8i8.nxv8i64.i64(<vscale x 8 x i8> [[MASKEDOFF0:%.*]], <vscale x 8 x i8> [[MASKEDOFF1:%.*]], <vscale x 8 x i8> [[MASKEDOFF2:%.*]], <vscale x 8 x i8> [[MASKEDOFF3:%.*]], <vscale x 8 x i8> [[MASKEDOFF4:%.*]], <vscale x 8 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 8 x i64> [[BINDEX:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i8m1_m(vint8m1_t *v0, vint8m1_t *v1, vint8m1_t *v2, vint8m1_t *v3, vint8m1_t *v4, vint8m1_t *v5, vbool8_t mask, vint8m1_t maskedoff0, vint8m1_t maskedoff1, vint8m1_t maskedoff2, vint8m1_t maskedoff3, vint8m1_t maskedoff4, vint8m1_t maskedoff5, const int8_t *base, vuint64m8_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16mf4_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } @llvm.riscv.vluxseg6.mask.nxv1i16.nxv1i64.i64(<vscale x 1 x i16> [[MASKEDOFF0:%.*]], <vscale x 1 x i16> [[MASKEDOFF1:%.*]], <vscale x 1 x i16> [[MASKEDOFF2:%.*]], <vscale x 1 x i16> [[MASKEDOFF3:%.*]], <vscale x 1 x i16> [[MASKEDOFF4:%.*]], <vscale x 1 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16mf4_m(vint16mf4_t *v0, vint16mf4_t *v1, vint16mf4_t *v2, vint16mf4_t *v3, vint16mf4_t *v4, vint16mf4_t *v5, vbool64_t mask, vint16mf4_t maskedoff0, vint16mf4_t maskedoff1, vint16mf4_t maskedoff2, vint16mf4_t maskedoff3, vint16mf4_t maskedoff4, vint16mf4_t maskedoff5, const int16_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } @llvm.riscv.vluxseg6.mask.nxv2i16.nxv2i64.i64(<vscale x 2 x i16> [[MASKEDOFF0:%.*]], <vscale x 2 x i16> [[MASKEDOFF1:%.*]], <vscale x 2 x i16> [[MASKEDOFF2:%.*]], <vscale x 2 x i16> [[MASKEDOFF3:%.*]], <vscale x 2 x i16> [[MASKEDOFF4:%.*]], <vscale x 2 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16mf2_m(vint16mf2_t *v0, vint16mf2_t *v1, vint16mf2_t *v2, vint16mf2_t *v3, vint16mf2_t *v4, vint16mf2_t *v5, vbool32_t mask, vint16mf2_t maskedoff0, vint16mf2_t maskedoff1, vint16mf2_t maskedoff2, vint16mf2_t maskedoff3, vint16mf2_t maskedoff4, vint16mf2_t maskedoff5, const int16_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i16m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } @llvm.riscv.vluxseg6.mask.nxv4i16.nxv4i64.i64(<vscale x 4 x i16> [[MASKEDOFF0:%.*]], <vscale x 4 x i16> [[MASKEDOFF1:%.*]], <vscale x 4 x i16> [[MASKEDOFF2:%.*]], <vscale x 4 x i16> [[MASKEDOFF3:%.*]], <vscale x 4 x i16> [[MASKEDOFF4:%.*]], <vscale x 4 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i16m1_m(vint16m1_t *v0, vint16m1_t *v1, vint16m1_t *v2, vint16m1_t *v3, vint16m1_t *v4, vint16m1_t *v5, vbool16_t mask, vint16m1_t maskedoff0, vint16m1_t maskedoff1, vint16m1_t maskedoff2, vint16m1_t maskedoff3, vint16m1_t maskedoff4, vint16m1_t maskedoff5, const int16_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i32mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.riscv.vluxseg6.mask.nxv1i32.nxv1i64.i64(<vscale x 1 x i32> [[MASKEDOFF0:%.*]], <vscale x 1 x i32> [[MASKEDOFF1:%.*]], <vscale x 1 x i32> [[MASKEDOFF2:%.*]], <vscale x 1 x i32> [[MASKEDOFF3:%.*]], <vscale x 1 x i32> [[MASKEDOFF4:%.*]], <vscale x 1 x i32> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i32mf2_m(vint32mf2_t *v0, vint32mf2_t *v1, vint32mf2_t *v2, vint32mf2_t *v3, vint32mf2_t *v4, vint32mf2_t *v5, vbool64_t mask, vint32mf2_t maskedoff0, vint32mf2_t maskedoff1, vint32mf2_t maskedoff2, vint32mf2_t maskedoff3, vint32mf2_t maskedoff4, vint32mf2_t maskedoff5, const int32_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i32m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.riscv.vluxseg6.mask.nxv2i32.nxv2i64.i64(<vscale x 2 x i32> [[MASKEDOFF0:%.*]], <vscale x 2 x i32> [[MASKEDOFF1:%.*]], <vscale x 2 x i32> [[MASKEDOFF2:%.*]], <vscale x 2 x i32> [[MASKEDOFF3:%.*]], <vscale x 2 x i32> [[MASKEDOFF4:%.*]], <vscale x 2 x i32> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i32m1_m(vint32m1_t *v0, vint32m1_t *v1, vint32m1_t *v2, vint32m1_t *v3, vint32m1_t *v4, vint32m1_t *v5, vbool32_t mask, vint32m1_t maskedoff0, vint32m1_t maskedoff1, vint32m1_t maskedoff2, vint32m1_t maskedoff3, vint32m1_t maskedoff4, vint32m1_t maskedoff5, const int32_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_i64m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } @llvm.riscv.vluxseg6.mask.nxv1i64.nxv1i64.i64(<vscale x 1 x i64> [[MASKEDOFF0:%.*]], <vscale x 1 x i64> [[MASKEDOFF1:%.*]], <vscale x 1 x i64> [[MASKEDOFF2:%.*]], <vscale x 1 x i64> [[MASKEDOFF3:%.*]], <vscale x 1 x i64> [[MASKEDOFF4:%.*]], <vscale x 1 x i64> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_i64m1_m(vint64m1_t *v0, vint64m1_t *v1, vint64m1_t *v2, vint64m1_t *v3, vint64m1_t *v4, vint64m1_t *v5, vbool64_t mask, vint64m1_t maskedoff0, vint64m1_t maskedoff1, vint64m1_t maskedoff2, vint64m1_t maskedoff3, vint64m1_t maskedoff4, vint64m1_t maskedoff5, const int64_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf8_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } @llvm.riscv.vluxseg6.mask.nxv1i8.nxv1i64.i64(<vscale x 1 x i8> [[MASKEDOFF0:%.*]], <vscale x 1 x i8> [[MASKEDOFF1:%.*]], <vscale x 1 x i8> [[MASKEDOFF2:%.*]], <vscale x 1 x i8> [[MASKEDOFF3:%.*]], <vscale x 1 x i8> [[MASKEDOFF4:%.*]], <vscale x 1 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8>, <vscale x 1 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf8_m(vuint8mf8_t *v0, vuint8mf8_t *v1, vuint8mf8_t *v2, vuint8mf8_t *v3, vuint8mf8_t *v4, vuint8mf8_t *v5, vbool64_t mask, vuint8mf8_t maskedoff0, vuint8mf8_t maskedoff1, vuint8mf8_t maskedoff2, vuint8mf8_t maskedoff3, vuint8mf8_t maskedoff4, vuint8mf8_t maskedoff5, const uint8_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf4_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } @llvm.riscv.vluxseg6.mask.nxv2i8.nxv2i64.i64(<vscale x 2 x i8> [[MASKEDOFF0:%.*]], <vscale x 2 x i8> [[MASKEDOFF1:%.*]], <vscale x 2 x i8> [[MASKEDOFF2:%.*]], <vscale x 2 x i8> [[MASKEDOFF3:%.*]], <vscale x 2 x i8> [[MASKEDOFF4:%.*]], <vscale x 2 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf4_m(vuint8mf4_t *v0, vuint8mf4_t *v1, vuint8mf4_t *v2, vuint8mf4_t *v3, vuint8mf4_t *v4, vuint8mf4_t *v5, vbool32_t mask, vuint8mf4_t maskedoff0, vuint8mf4_t maskedoff1, vuint8mf4_t maskedoff2, vuint8mf4_t maskedoff3, vuint8mf4_t maskedoff4, vuint8mf4_t maskedoff5, const uint8_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } @llvm.riscv.vluxseg6.mask.nxv4i8.nxv4i64.i64(<vscale x 4 x i8> [[MASKEDOFF0:%.*]], <vscale x 4 x i8> [[MASKEDOFF1:%.*]], <vscale x 4 x i8> [[MASKEDOFF2:%.*]], <vscale x 4 x i8> [[MASKEDOFF3:%.*]], <vscale x 4 x i8> [[MASKEDOFF4:%.*]], <vscale x 4 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8>, <vscale x 4 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8mf2_m(vuint8mf2_t *v0, vuint8mf2_t *v1, vuint8mf2_t *v2, vuint8mf2_t *v3, vuint8mf2_t *v4, vuint8mf2_t *v5, vbool16_t mask, vuint8mf2_t maskedoff0, vuint8mf2_t maskedoff1, vuint8mf2_t maskedoff2, vuint8mf2_t maskedoff3, vuint8mf2_t maskedoff4, vuint8mf2_t maskedoff5, const uint8_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u8m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } @llvm.riscv.vluxseg6.mask.nxv8i8.nxv8i64.i64(<vscale x 8 x i8> [[MASKEDOFF0:%.*]], <vscale x 8 x i8> [[MASKEDOFF1:%.*]], <vscale x 8 x i8> [[MASKEDOFF2:%.*]], <vscale x 8 x i8> [[MASKEDOFF3:%.*]], <vscale x 8 x i8> [[MASKEDOFF4:%.*]], <vscale x 8 x i8> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 8 x i64> [[BINDEX:%.*]], <vscale x 8 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP1]], ptr [[V0:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP2]], ptr [[V1:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP3]], ptr [[V2:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP4]], ptr [[V3:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP5]], ptr [[V4:%.*]], align 1 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 8 x i8> [[TMP6]], ptr [[V5:%.*]], align 1 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u8m1_m(vuint8m1_t *v0, vuint8m1_t *v1, vuint8m1_t *v2, vuint8m1_t *v3, vuint8m1_t *v4, vuint8m1_t *v5, vbool8_t mask, vuint8m1_t maskedoff0, vuint8m1_t maskedoff1, vuint8m1_t maskedoff2, vuint8m1_t maskedoff3, vuint8m1_t maskedoff4, vuint8m1_t maskedoff5, const uint8_t *base, vuint64m8_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16mf4_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } @llvm.riscv.vluxseg6.mask.nxv1i16.nxv1i64.i64(<vscale x 1 x i16> [[MASKEDOFF0:%.*]], <vscale x 1 x i16> [[MASKEDOFF1:%.*]], <vscale x 1 x i16> [[MASKEDOFF2:%.*]], <vscale x 1 x i16> [[MASKEDOFF3:%.*]], <vscale x 1 x i16> [[MASKEDOFF4:%.*]], <vscale x 1 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16>, <vscale x 1 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16mf4_m(vuint16mf4_t *v0, vuint16mf4_t *v1, vuint16mf4_t *v2, vuint16mf4_t *v3, vuint16mf4_t *v4, vuint16mf4_t *v5, vbool64_t mask, vuint16mf4_t maskedoff0, vuint16mf4_t maskedoff1, vuint16mf4_t maskedoff2, vuint16mf4_t maskedoff3, vuint16mf4_t maskedoff4, vuint16mf4_t maskedoff5, const uint16_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } @llvm.riscv.vluxseg6.mask.nxv2i16.nxv2i64.i64(<vscale x 2 x i16> [[MASKEDOFF0:%.*]], <vscale x 2 x i16> [[MASKEDOFF1:%.*]], <vscale x 2 x i16> [[MASKEDOFF2:%.*]], <vscale x 2 x i16> [[MASKEDOFF3:%.*]], <vscale x 2 x i16> [[MASKEDOFF4:%.*]], <vscale x 2 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16>, <vscale x 2 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16mf2_m(vuint16mf2_t *v0, vuint16mf2_t *v1, vuint16mf2_t *v2, vuint16mf2_t *v3, vuint16mf2_t *v4, vuint16mf2_t *v5, vbool32_t mask, vuint16mf2_t maskedoff0, vuint16mf2_t maskedoff1, vuint16mf2_t maskedoff2, vuint16mf2_t maskedoff3, vuint16mf2_t maskedoff4, vuint16mf2_t maskedoff5, const uint16_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u16m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } @llvm.riscv.vluxseg6.mask.nxv4i16.nxv4i64.i64(<vscale x 4 x i16> [[MASKEDOFF0:%.*]], <vscale x 4 x i16> [[MASKEDOFF1:%.*]], <vscale x 4 x i16> [[MASKEDOFF2:%.*]], <vscale x 4 x i16> [[MASKEDOFF3:%.*]], <vscale x 4 x i16> [[MASKEDOFF4:%.*]], <vscale x 4 x i16> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 4 x i64> [[BINDEX:%.*]], <vscale x 4 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP1]], ptr [[V0:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP2]], ptr [[V1:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP3]], ptr [[V2:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP4]], ptr [[V3:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP5]], ptr [[V4:%.*]], align 2 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16>, <vscale x 4 x i16> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 4 x i16> [[TMP6]], ptr [[V5:%.*]], align 2 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u16m1_m(vuint16m1_t *v0, vuint16m1_t *v1, vuint16m1_t *v2, vuint16m1_t *v3, vuint16m1_t *v4, vuint16m1_t *v5, vbool16_t mask, vuint16m1_t maskedoff0, vuint16m1_t maskedoff1, vuint16m1_t maskedoff2, vuint16m1_t maskedoff3, vuint16m1_t maskedoff4, vuint16m1_t maskedoff5, const uint16_t *base, vuint64m4_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u32mf2_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } @llvm.riscv.vluxseg6.mask.nxv1i32.nxv1i64.i64(<vscale x 1 x i32> [[MASKEDOFF0:%.*]], <vscale x 1 x i32> [[MASKEDOFF1:%.*]], <vscale x 1 x i32> [[MASKEDOFF2:%.*]], <vscale x 1 x i32> [[MASKEDOFF3:%.*]], <vscale x 1 x i32> [[MASKEDOFF4:%.*]], <vscale x 1 x i32> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32>, <vscale x 1 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u32mf2_m(vuint32mf2_t *v0, vuint32mf2_t *v1, vuint32mf2_t *v2, vuint32mf2_t *v3, vuint32mf2_t *v4, vuint32mf2_t *v5, vbool64_t mask, vuint32mf2_t maskedoff0, vuint32mf2_t maskedoff1, vuint32mf2_t maskedoff2, vuint32mf2_t maskedoff3, vuint32mf2_t maskedoff4, vuint32mf2_t maskedoff5, const uint32_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u32m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } @llvm.riscv.vluxseg6.mask.nxv2i32.nxv2i64.i64(<vscale x 2 x i32> [[MASKEDOFF0:%.*]], <vscale x 2 x i32> [[MASKEDOFF1:%.*]], <vscale x 2 x i32> [[MASKEDOFF2:%.*]], <vscale x 2 x i32> [[MASKEDOFF3:%.*]], <vscale x 2 x i32> [[MASKEDOFF4:%.*]], <vscale x 2 x i32> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 2 x i64> [[BINDEX:%.*]], <vscale x 2 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP1]], ptr [[V0:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP2]], ptr [[V1:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP3]], ptr [[V2:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP4]], ptr [[V3:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP5]], ptr [[V4:%.*]], align 4 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 2 x i32> [[TMP6]], ptr [[V5:%.*]], align 4 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u32m1_m(vuint32m1_t *v0, vuint32m1_t *v1, vuint32m1_t *v2, vuint32m1_t *v3, vuint32m1_t *v4, vuint32m1_t *v5, vbool32_t mask, vuint32m1_t maskedoff0, vuint32m1_t maskedoff1, vuint32m1_t maskedoff2, vuint32m1_t maskedoff3, vuint32m1_t maskedoff4, vuint32m1_t maskedoff5, const uint32_t *base, vuint64m2_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); } // CHECK-RV64-LABEL: @test_vluxseg6ei64_v_u64m1_m( // CHECK-RV64-NEXT: entry: // CHECK-RV64-NEXT: [[TMP0:%.*]] = call { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } @llvm.riscv.vluxseg6.mask.nxv1i64.nxv1i64.i64(<vscale x 1 x i64> [[MASKEDOFF0:%.*]], <vscale x 1 x i64> [[MASKEDOFF1:%.*]], <vscale x 1 x i64> [[MASKEDOFF2:%.*]], <vscale x 1 x i64> [[MASKEDOFF3:%.*]], <vscale x 1 x i64> [[MASKEDOFF4:%.*]], <vscale x 1 x i64> [[MASKEDOFF5:%.*]], ptr [[BASE:%.*]], <vscale x 1 x i64> [[BINDEX:%.*]], <vscale x 1 x i1> [[MASK:%.*]], i64 [[VL:%.*]], i64 0) // CHECK-RV64-NEXT: [[TMP1:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 0 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP1]], ptr [[V0:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 1 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP2]], ptr [[V1:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 2 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP3]], ptr [[V2:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 3 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP4]], ptr [[V3:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP5:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 4 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP5]], ptr [[V4:%.*]], align 8 // CHECK-RV64-NEXT: [[TMP6:%.*]] = extractvalue { <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64>, <vscale x 1 x i64> } [[TMP0]], 5 // CHECK-RV64-NEXT: store <vscale x 1 x i64> [[TMP6]], ptr [[V5:%.*]], align 8 // CHECK-RV64-NEXT: ret void // void test_vluxseg6ei64_v_u64m1_m(vuint64m1_t *v0, vuint64m1_t *v1, vuint64m1_t *v2, vuint64m1_t *v3, vuint64m1_t *v4, vuint64m1_t *v5, vbool64_t mask, vuint64m1_t maskedoff0, vuint64m1_t maskedoff1, vuint64m1_t maskedoff2, vuint64m1_t maskedoff3, vuint64m1_t maskedoff4, vuint64m1_t maskedoff5, const uint64_t *base, vuint64m1_t bindex, size_t vl) { return vluxseg6ei64(v0, v1, v2, v3, v4, v5, mask, maskedoff0, maskedoff1, maskedoff2, maskedoff3, maskedoff4, maskedoff5, base, bindex, vl); }
6ddc67f7bb553382c83e2e26a5b9e8c5c6604d02
8b98cd47f934d2a4a8d0b2842d3277b01f3fb7fa
/applications/obsolete/starman/dsx_genc.c
252e2485067021ea217210edefeda257087dcb13
[]
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
96,426
c
dsx_genc.c
/****************************************************************************** * DSX_GENC.C - Contains:- - DSX_VTIM Display part of virtual image - Fortran interface (Xwindows) DSX_PTTIT Put image title on display - fortran interface (Xwindows) DSX_PSCUR Put the cursor at screen position - fortran interface (Xwindows) DSX_GETCURPB Get cursor posn and button state - fortran interface (XWindows) DSX_PAINTOV(AB) Paint moving oval - erase last - Fortran interface (X windows) DSX_INIT Initialise window - Fortran interface (Xwindows) DSX_ID_INIT Initialise window IDs - Fortran interface (XWindows) DSX_SCOL Set line colour - Fortran interface (XWindows) DSX_CLOSE Close window - Fortran interface (XWindows) DSX_ERASE Erase display - Fortran interface (XWindows) DSX_SCUR Start the cursor - Fortran interface (XWindows) DSX_PCUR Put the cursor at position - Fortran interface (XWindows) DSX_OVAL Paint an oval - Fortran interface (Xwindows) DSX_OSIZE X, Y size of tilted oval DSX_CROSS Put a cross at a position - Fortran interface (Xwindows) DSX_LINE Put a line at a position - Fortran interface (Xwindows) DSX_UPDOWN Raise' or 'lower' a window - Fortran interface (Xwindows) DSX_ACIM(RS) Display part of an actual (real:short) image - Fortran interface (X window) DSX_MSWAIT Wait X millisecs - Fortran interface (Xwindows) - DSXC_INIT Initialise window (Xwindows) DSXC_ID_INIT Initialise window IDs (XWindows) DSXC_OPCOLMAP Open colour map (Xwindows) DSXC_BYTECOL Calc byte equivalents of PC_ID (Xwindows) DSXC_CICON Set up corner icon (Xwindows) DSXC_SCOL Set line colour (XWindows) DSXC_SETCOL Set up colour display for image display (Xwindows) DSXC_VTIM Display part of virtual image (Xwindows) DSXC_VTIMA Display part of virtual image (Xwindows) DSXC_VTLOAD Load part of virtual image into a zoomed array (Xwindows) DSXC_CLOSE Close window (XWindows) DSXC_PTTIT Put image title on display (XWindows) DSXC_ERASE Erase display (XWindows) DSXC_CLEAR Clear screen (XWindows) DSXC_CLEARPIX Clear pixmap (XWindows) DSXC_SCUR Start the cursor (XWindows) DSXC_PCUR Put the cursor at position (XWindows) DSXC_PSCUR Put the cursor at screen position (XWindows) DSXC_GETCURPB Get cursor posn and button state (XWindows) DSXC_WAITBUT Wait for button to be pressed or to be up (Xwindows) - DSXC_PUTIM Put an image (Xwindows) - DSXC_PAINTOV(AB) Paint moving oval - erase last (X windows) DSXC_OVAL Paint an oval (Xwindows) DSXC_OVALA Paint an oval at X/Y normals (Xwindows) DSXC_OVALB Paint an oval at angle (Xwindows) DSXC_OSIZE X, Y size of tilted oval DSXC_CROSS Put a cross at a position (Xwindows) DSXC_SCOLNUM Calc colour pixel number from colour number (Xwindows) DSXC_LINE Put a line at a position (Xwindows) DSXC_SETTHECOL Set writing colour (Xwindows) - DSXC_UPDOWN 'Raise' or 'lower' a window (Xwindows) DSXC_ACIM(RS) Display part of an actual (real:short) image (X window) DSXC_MSWAIT Wait X millisecs (Xwindows) */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <errno.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/X.h> #include <sys/time.h> #include <malloc.h> #include "f77.h" #include "cnf.h" #include "image.h" #include "ds_gen.h" #include "ds_lut.h" #include "ds_panel.h" #include "dsx_gen.h" /* Prototypes */ int imax ( int, int ); int imin ( int, int ); float fmax ( float, float ); float fmin ( float, float ); /* External C functions */ extern void dsxc_lutcol (); extern void dsxc_lutacol (); extern void dsxc_p_putim ( char*, int, int, int, int ); extern void dsxc_p_puttxt ( char*, int, int, int, int ); extern void dsxc_p_hstat ( int ); extern void c_printo ( char* ); extern void c_get1i ( char*, int*, int, int, int ); extern void c_get2i ( char*, int*, int*, Bool, int, int ); extern void vtc_tis ( int, int, int*, int* ); extern void vtc_tsv ( int, int, int*, int* ); extern void vtc_tvs ( int, int, int*, int* ); /* Panel Globals */ int PNKXS; int PNKYS; int PNKXO; int PNKYO; int KXO; /* X Last cursor X posn */ int KYO; /* Y Last cursor Y posn */ char TEXTAA[200]; /* (void) sprintf ( TEXTAA, " F1XXX %d %d %d %d %d ", PDSOPEN, DSNXS, DSNXE, DSNYS, DSNYE ); (void) c_printo ( TEXTAA ); */ /*********************************************************************** DSX_PTTIT -- Put image title on display - FORTRAN interface (Xwindows) alan penny ral 1990-01-31 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_pttit) ( CHARACTER(title) TRAIL(title) ) { GENPTR_CHARACTER(title) /* i: Title to put up */ /* C-- */ char *name; /* Cbegin */ name = cnf_creim ( title, title_length ); (void) dsxc_pttit ( name ); cnf_free (name); } /****************************************************************** DSX_VTIM -- Display part of virtual image - Fortran interface (Xwindows) alan penny ral 1990-02-01 */ F77_SUBROUTINE(dsx_vtim) ( INTEGER(jvxs), INTEGER(jvxe), INTEGER(jvys), INTEGER(jvye), INTEGER(kcl) ) { GENPTR_INTEGER(jvxs) /* i: X start of virtual area to display */ GENPTR_INTEGER(jvxe) /* i: X end of virtual area to display */ GENPTR_INTEGER(jvys) /* i: Y start of virtual area to display */ GENPTR_INTEGER(jvye) /* i: Y end of virtual area to display */ GENPTR_INTEGER(kcl) /* i: Flag to clear screen before (0=no) */ /* C-- */ /* Cbegin */ (void) dsxc_vtim ( *jvxs, *jvxe, *jvys, *jvye, *kcl ); } /********************************************************************** DSX_PSCUR -- Put the cursor at screen position - Fortran Interface (Xwindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_pscur) ( REAL(x), REAL(y) ) { GENPTR_REAL(x) /* i: X position to put cursor at */ GENPTR_REAL(y) /* i: Y position to put cursor at */ /* C-- */ /* Cbegin */ (void) dsxc_pscur ( *x, *y ); } /******************************************************************* DSX_GETCURPB -- Get cursor posn and button state - Fortran interface (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_getcurpb) ( LOGICAL(isimage), INTEGER(kx), INTEGER(ky), INTEGER_ARRAY(kb), INTEGER(ierr) ) { GENPTR_LOGICAL(isimage) /* i: Image (T) or panel (F) ? */ GENPTR_INTEGER(kx) /* o: Cursor X position */ GENPTR_INTEGER(ky) /* o: Cursor Y position */ GENPTR_INTEGER_ARRAY(kb) /* o: Cursor Button states (0=up;1=down) */ GENPTR_INTEGER(ierr) /* o: Error flag ( 0=ok; 1=bad) */ /* C-- */ Bool la; int ikx, iky, iierr; /* Cbegin */ la = *isimage; (void) dsxc_getcurpb ( la, &ikx, &iky, kb, &iierr ); *kx = ikx; *ky = iky; *ierr = iierr; } /******************************************************************* DSX_PAINTOVA -- Paint moving oval at X/Y normal - erase last - Fortran interface (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_paintova) ( REAL(pxo), REAL(pyo), REAL(rxo), REAL(ryo), REAL(px), REAL(py), REAL(rax1), REAL(ray1), INTEGER(kc1), REAL_ARRAY(rax2), REAL_ARRAY(ray2), INTEGER(kc2) ) { GENPTR_REAL(pxo) /* i: Old screen X posn */ GENPTR_REAL(pyo) /* i: Old screen Y posn */ GENPTR_REAL(rxo) /* i: Old max X radius (image scale) */ GENPTR_REAL(ryo) /* i: Old max Y radius (image scale) */ GENPTR_REAL(px) /* i: New screen X posn */ GENPTR_REAL(py) /* i: New screen Y posn */ GENPTR_REAL(rax1) /* i: Inner X oval radius (image scale) */ GENPTR_REAL(ray1) /* i: Inner Y oval radius (image scale) */ GENPTR_INTEGER(kc1) /* i: Inner oval colour (1-8) */ GENPTR_REAL_ARRAY(rax2) /* i: Inner/outer annular X oval radii */ GENPTR_REAL_ARRAY(ray2) /* i: Inner/outer annular Y oval radii */ GENPTR_INTEGER(kc2) /* i: Outer oval colour (1-8) */ /* C-- */ /* Cbegin */ (void) dsxc_paintova ( *pxo, *pyo, *rxo, *ryo, *px, *py, *rax1, *ray1, *kc1, rax2, ray2, *kc2 ); } /******************************************************************* DSX_PAINTOVB -- Paint moving oval - erase last - Fortran interface (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_paintovb) ( INTEGER_ARRAY(kcx), INTEGER_ARRAY(kcy), INTEGER(kc1), INTEGER(kc2), REAL(pxo), REAL(pyo), REAL(rxo), REAL(ryo) ) { GENPTR_INTEGER_ARRAY(kcx) /* i: Centre/Inner/outer annular X oval */ GENPTR_INTEGER_ARRAY(kcy) /* i: Centre/Inner/outer annular Y oval */ GENPTR_INTEGER(kc1) /* i: Centre oval colour (1-8) */ GENPTR_INTEGER(kc2) /* i: Inner/Outer oval colour (1-8) */ GENPTR_REAL(pxo) /* i: Old screen X posn */ GENPTR_REAL(pyo) /* i: Old screen Y posn */ GENPTR_REAL(rxo) /* i: Old max X radius (image scale) */ GENPTR_REAL(ryo) /* i: Old max Y radius (image scale) */ /* C-- */ /* Cbegin */ (void) dsxc_paintovb ( kcx, kcy, *kc1, *kc2, *pxo, *pyo, *rxo, *ryo ); } /*********************************************************************** DSX_INIT -- Initialise window - Fortran interface (XWindows) alan penny ral 1990 Aug patrick Morris leeds 1992 Jan */ F77_SUBROUTINE(dsx_init) ( CHARACTER(title), INTEGER(kscreen), INTEGER(ierr) TRAIL(title) ) { GENPTR_CHARACTER(title) /* i: Title of image */ GENPTR_INTEGER(kscreen) /* i: Ask for screen size flag (0=yes;1=no) */ GENPTR_INTEGER(ierr) /* o: Error flag (0=ok;1=bad) */ /* C-- */ char *name; int iierr; /* Cbegin */ name = cnf_creim ( title, title_length ); (void) dsxc_init ( name, *kscreen, &iierr ); *ierr = iierr; cnf_free ( name ); } /*********************************************************************** DSX_ID_INIT -- Initialise window IDs - Fortran interface (XWindows) alan penny ral 1990 Aug patrick Morris leeds 1992 Jan */ F77_SUBROUTINE(dsx_id_init) ( void ) { /* C-- */ /* Cbegin */ (void) dsxc_id_init ( ); } /****************************************************************** DSX_SCOL -- Set line colour - Fortran interface (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_scol) ( REAL(w), INTEGER(kc) ) { GENPTR_REAL(w) /* i: Line width */ GENPTR_INTEGER(kc) /* i: Colour (1=red;2=green;3=blue;4=yellow 5=cyan;6=mauve;7=tan;8=pink) */ /* C-- */ /* Cbegin */ (void) dsxc_scol ( *w, *kc ); } /*********************************************************************** DSX_CLOSE -- Close window - Fortran interface (XWindows) alan penny ral 1990 jan pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_close) ( INTEGER(ierr) ) { GENPTR_INTEGER(ierr) /* o: Error flag (0=ok;1=bad) */ /* C-- */ int iierr; /* Cbegin */ (void) dsxc_close ( &iierr ); *ierr = iierr; } /************************************************************************** DSX_ERASE -- Erase display - Fortran interface (XWindows) a j penny ral 1990 jan */ F77_SUBROUTINE(dsx_erase) (void) /* C-- */ { /* Cbegin */ (void) dsxc_erase (); } /********************************************************************* DSX_SCUR -- Start the cursor - Fortran interface (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_scur) (void) /* C-- */ { /* Cbegin */ (void) dsxc_scur (); } /********************************************************************** DSX_PCUR -- Put the cursor at position - Fortran interface (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_pcur) ( INTEGER(kx), INTEGER(ky) ) { GENPTR_INTEGER(kx) /*i: X position to put cursor at */ GENPTR_INTEGER(ky) /*i: Y position to put cursor at */ /* C-- */ /* Cbegin */ (void) dsxc_pcur ( *kx, *ky ); } /******************************************************************** DSX_OVAL -- Paint an oval - Fortran interface (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_oval) ( REAL(xp), REAL(yp), REAL(radx), REAL(angle), REAL(elli), INTEGER(kc) ) { GENPTR_REAL(xp) /* i: Image X position */ GENPTR_REAL(yp) /* i: Image Y position */ GENPTR_REAL(radx) /* i: Image pixel X radius */ GENPTR_REAL(angle) /* i: Oval angle to X-axis */ GENPTR_REAL(elli) /* i: Oval ellipticity */ GENPTR_INTEGER(kc) /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ /* Cbegin */ (void) dsxc_oval ( *xp, *yp, *radx, *angle, *elli, *kc ); } /******************************************************************** DSX_OSIZE -- X, Y Size of tilted oval - Fortran interface (XWindows) alan penny ral 1994 */ F77_SUBROUTINE(dsx_osize) ( REAL(rad), REAL(ang), REAL(elli), REAL(xs), REAL(ys) ) { GENPTR_REAL(rad) /* i: Oval maj radius */ GENPTR_REAL(ang) /* i: Angle to X-axis in degrees */ GENPTR_REAL(elli) /* i: Ellipticity */ GENPTR_REAL(xs) /* o: X coverage */ GENPTR_REAL(ys) /* o: Y coverage */ /* C-- */ float xxs, yys; /* Cbegin */ (void) dsxc_osize ( *rad, *ang, *elli, &xxs, &yys ); *xs = xxs; *ys = yys; } /**************************************************************** DSX_CROSS -- Put a cross at a position - Fortran interface (XWindows) alan penny ral 1990 Jan pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_cross) ( REAL(x), REAL(y), REAL(crs), INTEGER(kc) ) { GENPTR_REAL(x) /* i: X position(image pixels) */ GENPTR_REAL(y) /* i: Y position (image pixels) */ GENPTR_REAL(crs) /* i: Cross size (end-to-end) (image pixels) */ GENPTR_INTEGER(kc) /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ /* Cbegin */ (void) dsxc_cross ( *x, *y, *crs, *kc ); } /********************************************************************** DSX_LINE -- Put a line at a position - Fortran interface (XWindows) alan penny ral 1990 May pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_line) ( REAL(xs), REAL(ys), REAL(xe), REAL(ye), INTEGER(kc) ) { GENPTR_REAL(xs) /* i: Line start X position(image pixels) */ GENPTR_REAL(ys) /* i: Line start Y position (image pixels) */ GENPTR_REAL(xe) /* i: Line end X position(image pixels) */ GENPTR_REAL(ye) /* i: Line end Y position (image pixels) */ GENPTR_INTEGER(kc) /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ /* Cbegin */ (void) dsxc_line ( *xs, *ys, *xe, *ye, *kc ); } /**************************************************************************** DSX_UPDOWN -- Raise' or 'lower' a window - Fortran interface (Xwindows) alan penny ral 1990-06-09 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_updown) ( INTEGER(kf) ) { GENPTR_INTEGER(kf) /* i: raise=1; lower=2 */ /* C-- */ /* Cbegin */ (void) dsxc_updown ( *kf ); } /************************************************************************** DSX_ACIMR -- Display part of an actual real image (loads virtual image) alan penny ral 1990 jan pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_acimr) ( REAL_ARRAY(im), INTEGER(mx), INTEGER(my), INTEGER(ixs), INTEGER(ixe), INTEGER(iys), INTEGER(iye), INTEGER(ix), INTEGER(iy), LOGICAL(wrap) ) GENPTR_INTEGER(mx) /* i: Actual image X size */ GENPTR_INTEGER(my) /* i: Actual image Y size */ GENPTR_REAL_ARRAY(im) /* i: Actual image */ GENPTR_INTEGER(ixs) /* i: Actual image area X start */ GENPTR_INTEGER(ixe) /* i: Actual image area X end */ GENPTR_INTEGER(iys) /* i: Actual image area Y start */ GENPTR_INTEGER(iye) /* i: Actual image area Y end */ GENPTR_INTEGER(ix) /* i: Position in virtual image of X start */ GENPTR_INTEGER(iy) /* i: Position in virtual image of Y start */ GENPTR_LOGICAL(wrap) /* i: Flag to wrap values round display limits */ { (void) dsxc_acimr ( im, *mx, *my, *ixs, *ixe, *iys, *iye, *ix, *iy, *wrap ); } /**************************************************************** DSX_ACIMS -- Display part of an actual int*2 image (loads virtual image) alan penny ral 1990 jan pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_acims) ( WORD_ARRAY(im), INTEGER(mx), INTEGER(my), INTEGER(ixs), INTEGER(ixe), INTEGER(iys), INTEGER(iye), INTEGER(ix), INTEGER(iy), LOGICAL(wrap) ) GENPTR_INTEGER(mx) /* i: Actual image X size */ GENPTR_INTEGER(my) /* i: Actual image Y size */ GENPTR_WORD_ARRAY(im) /* i: Actual image */ GENPTR_INTEGER(ixs) /* i: Actual image area X start */ GENPTR_INTEGER(ixe) /* i: Actual image area X end */ GENPTR_INTEGER(iys) /* i: Actual image area Y start */ GENPTR_INTEGER(iye) /* i: Actual image area Y end */ GENPTR_INTEGER(ix) /* i: Position in virtual image of X start */ GENPTR_INTEGER(iy) /* i: Position in virtual image of Y start */ GENPTR_LOGICAL(wrap) /* i: Flag to wrap values round display limits*/ { (void) dsxc_acims ( im, *mx, *my, *ixs, *ixe, *iys, *iye, *ix, *iy, *wrap ); } /**************************************************************************** DSX_MSWAIT -- Wait N milliseconds an image - Fortran interface (Xwindows) alan penny ral 1990-06-09 pat morris leeds 1992 jan */ F77_SUBROUTINE(dsx_mswait) ( INTEGER(msecs) ) { GENPTR_INTEGER(msecs) /* i: Milliseconds to wait */ /* C-- */ /* Cbegin */ (void) dsxc_mswait ( *msecs ); } /*********************************************************************** DSXC_INIT -- Initialise window (XWindows) alan penny ral 1990 Aug patrick Morris leeds 1992 Jan */ dsxc_init ( title, kscreenopt, ierr ) char *title; /* i: Title of image */ int *kscreenopt; /* i: Ask for screen size? (0=yes;1=no)*/ int *ierr; /* o: Error flag (0=ok;1=bad) */ /* C-- */ { char texta[100]; Bool func = True ; /* Synchronous behaour */ unsigned long attr_mask; /* attributes mask */ long event_mask; int iv, ivx, ivy, jx, jy, lxy, nxa, nya, k, kka, kkb; int kxa, kya, nnxa, nnya; float rvx, rvy; XFontStruct *font; /* font structure */ XSetWindowAttributes xswda; /* window attributes */ XGCValues xgcvl; /* gc values */ XSizeHints xszhn; /* size hints */ /* char *font_name = "-adobe-new century schoolbook-medium-r-normal--*-120-*-*-p*"; char *font_name = "-adobe-new century schoolbook-medium-r-normal--*-80-*-*-p*"; */ char *font_name = "-adobe-new century schoolbook-medium-r-normal--*-100-*-*-p*"; char *display_name = NULL; char buf1[32], buf2[32]; char *argv[8]; XEvent event; Status status; XVisualInfo vinfo; /* Cbegin */ *ierr = 0; PDSOPEN = F77_NAMED_COMMON(ds_panelb).pdsopen; DSNXS = F77_NAMED_COMMON(ds_gen).dsnxs; DSNXE = F77_NAMED_COMMON(ds_gen).dsnxe; DSNYS = F77_NAMED_COMMON(ds_gen).dsnys; DSNYE = F77_NAMED_COMMON(ds_gen).dsnye; if ( PDSOPEN ) { if ( VD_ID == NULL ) { (void) c_printo ( "ERROR: Cant open Xwindows display" ); *ierr = 1; return ; } } else { if ( (VD_ID = XOpenDisplay(display_name)) == NULL ) { (void) c_printo ( "ERROR: Cant open Xwindows display" ); *ierr = 1; return; } (void) c_get1i ( "NUMBUTT", &iv, 3, 2, 3 ); NUMXBUTTONS = iv; F77_NAMED_COMMON(ds_gen).numxbuttons = iv; } DSOPEN = True; F77_NAMED_COMMON(ds_genb).dsopen = F77_TRUE; (void) XSynchronize ( VD_ID, func ); SC_ID = DefaultScreen ( VD_ID ); RW_ID = RootWindow ( VD_ID, SC_ID ); nxa = DisplayWidth ( VD_ID, SC_ID ) ; nya = DisplayHeight( VD_ID, SC_ID ) ; nnxa = nxa - 6 ; nnya = nya - 25 ; if ( nnxa*nnya > MAXVIRT ) { (void) sprintf ( texta, " WARNING: Total screen size is %5d x %5d :", nxa, nya ); (void) c_printo ( texta ); (void) sprintf ( texta, " Opening a window with more than 8%d pixels ", MAXVIRT ); (void) c_printo ( texta ); (void) c_printo ( " will crash this program" ); } jx = DSNXE - DSNXS + 1 ; /* Get screen pixel size */ jy = DSNYE - DSNYS + 1 ; if ( jx<16 || jy<16 ) { (void) sprintf ( texta, " WARNING: Window size asked for was %5d x %5d :", jx, jy); (void) c_printo ( texta ); (void) c_printo ( " For technical reasons, display sides must be > 15" ); if ( jx<16 ) jx = 16; if ( jy<16 ) jy = 16; (void) sprintf ( texta, " Window will be opened as size %5d x %5d :", jx, jy); (void) c_printo ( texta ); } DSSNX = jx ; DSSNY = jy ; if ( (jx > nnxa) || (jy > nnya) ) { kka = jx - 1; if ( kka<0 ) kka = -1*kka; kkb = jy - 1; if ( kkb<0 ) kkb = -1*kkb; lxy = 1 + imax((kka/nnxa),(kkb/nnya)); DSSNX = 1 + ((jx-1)/lxy); DSSNY = 1 + ((jy-1)/lxy); (void) sprintf ( texta, " Image size %5d x %5d is too large for screen size - %5d x %5d", jx, jy, nnxa, nnya ); (void) c_printo ( texta ); (void) sprintf ( texta, " Displayed image will be compressed by %5d x %5d", lxy, lxy); (void) c_printo ( texta ); } if ( kscreenopt==0 ) { k = imax(nnxa,nnya); ivx = DSSNX; ivy = DSSNY; (void) c_get2i ( "SCREEN", &ivx, &ivy, True, 1, k ); DSSNX = ivx; DSSNY = ivy; } if ( DSSNX > nnxa ) { (void) sprintf ( texta, " X size too large - set to max X size of %d", nnxa); (void) c_printo ( texta ); DSSNX = nnxa; } if ( DSSNY > nnya ) { (void) sprintf ( texta, " Y size too large - set to max Y size of %d", nnya); (void) c_printo ( texta ); DSSNY = nnya; } F77_NAMED_COMMON(ds_gen).dssnx = DSSNX; F77_NAMED_COMMON(ds_gen).dssny = DSSNY; if ( ( DEPTH = DefaultDepth (VD_ID, SC_ID) ) < 8 ) { (void) c_printo ( "ERROR: Screen pixel depth must be at least 8" ); *ierr = 1; return ; } D_VISUAL = DefaultVisual (VD_ID, SC_ID); status = XMatchVisualInfo ( VD_ID, SC_ID, DEPTH, PseudoColor, &vinfo ); if ( status == 0 ) { (void) c_printo ( "ERROR: Cant allocate colours - display type has to be pseudo color" ); *ierr = 1; return ; } if ( vinfo.visual != D_VISUAL ) (void) c_printo ( "Not default visual" ); if (!PDSOPEN) (void) dsxc_opcolmap (); /* Open colour map */ attr_mask = CWEventMask | CWBackPixel | CWBorderPixel | CWColormap; xswda.event_mask = ExposureMask; xswda.background_pixel = BlackPixel(VD_ID,SC_ID); xswda.border_pixel = WhitePixel(VD_ID,SC_ID); xswda.colormap = CM_ID; kxa = nnxa - DSSNX - DSWINDX; /* Position */ kya = DSWINDY ; WD_ID = XCreateWindow ( VD_ID, RW_ID, kxa, kya, DSSNX, DSSNY, 0, DEPTH, InputOutput, D_VISUAL, attr_mask, &xswda ); (void) dsxc_cicon (); /* Set up corner icon */ DSWINDX = DSWINDX + DSSNX + 20; DSWINDXM = DSWINDX; F77_NAMED_COMMON(ds_gen).dswindx = DSWINDX; F77_NAMED_COMMON(ds_gen).dswindxm = DSWINDXM; xgcvl.foreground = WhitePixel(VD_ID,SC_ID); /* Create graphics context */ xgcvl.background = WhitePixel(VD_ID,SC_ID); GC_ID = XCreateGC ( VD_ID, WD_ID, (GCForeground | GCBackground), &xgcvl ); if ( (font = XLoadQueryFont ( VD_ID, font_name ) ) == NULL ) { /* Load the font for text writing */ (void) c_printo ( "WARNING: Couldn\'t open fonts - any text may be wrong size"); }else{ XSetFont ( VD_ID, GC_ID, font->fid ); } XSetForeground ( VD_ID, GC_ID, WhitePixel(VD_ID,SC_ID) ); xszhn.x = kxa; /* Define the size and name of the WD_ID window */ xszhn.y = kya; xszhn.width = DSSNX; xszhn.height = DSSNY; xszhn.flags = PPosition | PSize ; XSetNormalHints ( VD_ID, WD_ID, &xszhn ); XFlush ( VD_ID ); PIXMAP = XCreatePixmap ( VD_ID, RW_ID, DSSNX, DSSNY, DEPTH ); (void) dsxc_clearpix () ; XSelectInput ( VD_ID, WD_ID, ( StructureNotifyMask | ButtonReleaseMask | ButtonPressMask | PointerMotionMask | SubstructureNotifyMask | ExposureMask) ); PID = vfork(); if ( PID != 0 ) { /* We are child so do exposure monitor */ if ( PID == -1 ) (void) c_printo ( "ERROR: Refresh not started" ); } else { display_name = DisplayString ( VD_ID ); argv[0] = "s_refresh"; sprintf ( buf1, "%lu", WD_ID ); argv[1] = buf1; sprintf ( buf2, "%lu", PIXMAP ); argv[2] = buf2; argv[3] = display_name; argv[4] = '\0'; execvp ( "s_refresh", argv ); _exit ( errno ); } XMapWindow ( VD_ID, WD_ID ); /* Map the windows */ XFlush ( VD_ID ); (void) dsxc_pttit ( title ); (void) dsxc_erase () ; event_mask = StructureNotifyMask | SubstructureNotifyMask; XWindowEvent ( VD_ID, WD_ID, event_mask, &event ); /* Wait for window to appear */ XFlush ( VD_ID ); rvx = DSSNX/2; /* Cursor position */ rvy = DSSNY/2; DSCURPOSX = rvx; DSCURPOSY = rvy; DSCURSET = False; DSZM = 1; /* Set Zoom factors */ DSZPX = 1; DSZPY = 1; DSIXS = 1; /* Default image blh corner X */ DSIYS = 1; /* and Y virtual image posn */ F77_NAMED_COMMON(ds_gen).dscurposx = rvx; F77_NAMED_COMMON(ds_gen).dscurposy = rvy; F77_NAMED_COMMON(ds_genb).dscurset = F77_FALSE; F77_NAMED_COMMON(ds_gen).dszm = DSZM; F77_NAMED_COMMON(ds_gen).dszpx = DSZPX; F77_NAMED_COMMON(ds_gen).dszpy = DSZPY; F77_NAMED_COMMON(ds_gen).dsiys = DSIYS; F77_NAMED_COMMON(ds_gen).dsixs = DSIXS; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; } /************************************************************************** DSXC_ID_INIT -- Initialise window IDs (XWindows) alan penny ral 1990 jan pat morris leeds 1992 jan */ dsxc_id_init (void) { VD_ID = NULL; } /************************************************************************** DSXC_OPCOLMAP -- Open colour map (Xwindows) alan penny ral 1990 Aug patrick Morris leeds 1992 Jan */ dsxc_opcolmap (void) /* C-- */ { Status istat; int iv; unsigned long plane_mask; /* Cbegin */ CM_ID = DefaultColormap ( VD_ID, SC_ID ); /* Get colormap */ OWNCOL = True; NUMDDCOL = NUMDCOL; istat = XAllocColorCells ( VD_ID, CM_ID, False, &plane_mask, 0, PC_ID, (15+NUMDDCOL) ); if ( istat == 0 ) { NUMDDCOL = NUMDCOL/2; istat = XAllocColorCells ( VD_ID, CM_ID, False, &plane_mask, 0, PC_ID, 15+NUMDDCOL ); if ( istat == 0 ) { NUMDDCOL = NUMDCOL/3; istat = XAllocColorCells ( VD_ID, CM_ID, False, &plane_mask, 0, PC_ID, 15+NUMDDCOL ); if ( istat == 0 ) { NUMDDCOL = NUMDCOL; (void) c_printo ( "WARNING: Cant allocate own colours - will take available ones" ); (void) c_printo ( " LUT Rotation and Scaling will not work" ); (void) c_printo ( " Any change to the LUT will also need to have the image redisplayed" ); OWNCOL = False; } else (void) c_printo ( "WARNING: Only 50 steps in image display" ); } else (void) c_printo ( "WARNING: Only 75 steps in image display" ); } F77_NAMED_COMMON(lutacom).numddcol = NUMDDCOL; (void) dsxc_setcol (); (void) dsxc_bytecol (); } /********************************************************************* DSXC_BYTECOL -- Calc byte equivalents of PC_ID (Xwindows) alan penny ral 1990 Aug pat morris leeds 1992 jan */ dsxc_bytecol (void) /* C-- */ { int k, iv, ka, kdiv; /* Cbegin */ NUMDDCOL = F77_NAMED_COMMON(lutacom).numddcol; kdiv = NUMDCOL/NUMDDCOL ; for ( k = 1; k <= (15+NUMDCOL) ; k++ ) { ka = k; if ( k > 15 ) ka = 16 + ((ka-16)/kdiv); iv = PC_ID[ka-1]; if ( iv>255 ) BY_PC_ID[k-1] = -1; else if ( iv>127 ) BY_PC_ID[k-1] = -256 + iv; else if ( iv<0 ) BY_PC_ID[k-1] = 0; else BY_PC_ID[k-1] = iv; } } /************************************************************************* DSXC_CICON -- Set up corner icon (Xwindows) alan penny ral 1990 Aug pat morris leeds 1992 jan */ dsxc_cicon (void) /* C-- */ { XWMHints xwmhn; /* Window manager hints */ XWMHints xwmhints; Pixmap icon_pixmap; Atom wmatom; static unsigned char icon_bits[512] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x1f, 0x63, 0x23, 0x62, 0x88, 0x00, 0x00, 0x02, 0x04, 0x43, 0x64, 0x63, 0x88, 0x00, 0x00, 0x02, 0x84, 0x44, 0x64, 0x93, 0x98, 0x00, 0x00, 0x02, 0x84, 0x64, 0xa3, 0x92, 0xa8, 0x00, 0x00, 0x1c, 0x84, 0x44, 0x21, 0x92, 0xa8, 0x00, 0x00, 0x20, 0x84, 0x47, 0x22, 0xf2, 0xc8, 0x00, 0x00, 0x20, 0x44, 0x48, 0x22, 0x0a, 0x89, 0x00, 0x00, 0x1e, 0x44, 0x48, 0x24, 0x0a, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x84, 0x20, 0x30, 0x1e, 0x00, 0x00, 0x00, 0x80, 0xcc, 0x20, 0x48, 0x02, 0x00, 0x00, 0x00, 0x80, 0xcc, 0x48, 0x08, 0x02, 0x00, 0x00, 0x00, 0x80, 0xb4, 0x48, 0x04, 0x02, 0x00, 0x00, 0x00, 0x80, 0x84, 0x48, 0x64, 0x0e, 0x00, 0x00, 0x00, 0x80, 0x84, 0x68, 0x48, 0x02, 0x00, 0x00, 0x00, 0x80, 0x84, 0x84, 0x48, 0x02, 0x00, 0x00, 0x00, 0x80, 0x84, 0x84, 0x30, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ; /* Cbegin */ icon_pixmap = XCreateBitmapFromData ( VD_ID, WD_ID, icon_bits, 64, 64 ); xwmhn.flags = IconPixmapHint | IconMaskHint ; xwmhn.icon_pixmap = icon_pixmap ; xwmhn.icon_mask = icon_pixmap ; XSetWMHints ( VD_ID, WD_ID, &xwmhn ); wmatom = XInternAtom ( VD_ID, "XA_WM_HINTS", 0 ) ; if ( wmatom != None ) { xwmhints.flags = IconPixmapHint ; xwmhints.icon_pixmap = icon_pixmap ; XChangeProperty ( VD_ID, WD_ID, wmatom, wmatom, 32, PropModeReplace, (char *) &xwmhints, 9 ) ; } XFlush ( VD_ID ); } /****************************************************************** DSXC_SCOL -- Set line colour (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ dsxc_scol ( w, kc ) float w; /* i: Line width */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow 5=cyan;6=mauve;7=tan;8=pink) */ /* C-- */ { /* Cbegin */ } /********************************************************************* DSXC_SETCOL -- Set up color display for image display (Xwindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_setcol (void) /* C-- */ { int k, ka; Status istat; char flags; unsigned short int j; static float rr[10]={0.8, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.5}; static float gg[10]={0.8, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.5, 1.0}; static float bb[10]={0.8, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0}; static float sgr[5]={0.0, 0.5, 0.75, 0.89, 1.0}; /* Starman greys */ static float sgg[5]={0.0, 0.5, 0.75, 0.89, 1.0}; static float sgb[5]={0.0, 0.5, 0.75, 0.89, 1.0}; /* Cbegin */ flags = DoRed | DoGreen | DoBlue ; if ( OWNCOL ) { for ( k = 0; k<10; k++ ) { /* Pgplot colours */ COLOUR[k].pixel = PC_ID[k]; COLOUR[k].flags = flags; j = (short) (rr[k]*65535.0) ; COLOUR[k].red = j; j = (short) (gg[k]*65535.0) ; COLOUR[k].green = j; j = (short) (bb[k]*65535.0) ; COLOUR[k].blue = j; } for ( k = 10; k<15; k++ ) { /* Starman greys */ COLOUR[k].pixel = PC_ID[k]; COLOUR[k].flags = flags; ka = k - 10; j = (short) (sgr[ka]*65535.0) ; COLOUR[k].red = j; j = (short) (sgg[ka]*65535.0) ; COLOUR[k].green = j; j = (short) (sgb[ka]*65535.0) ; COLOUR[k].blue = j; } for ( k = 15; k<15+NUMDDCOL ; k++ ) { /* Starman grey scale */ COLOUR[k].pixel = PC_ID[k]; COLOUR[k].flags = flags; j = 65535.0 * (k-15)/(NUMDDCOL-1); COLOUR[k].red = j; COLOUR[k].green = j; COLOUR[k].blue = j; } XStoreColors ( VD_ID, CM_ID, COLOUR, (15+NUMDDCOL) ); XInstallColormap ( VD_ID, CM_ID ); XFlush ( VD_ID ); (void) dsxc_lutacol () ; /* Set up LUT */ (void) dsxc_lutcol () ; } else { for ( k = 0; k<10 ; k++ ) { /* Pgplot colours */ COLOUR[k].flags = flags; j = (short) (rr[k]*65535.0); COLOUR[k].red = j; j = (short) (gg[k]*65535.0); COLOUR[k].green = j; j = (short) (bb[k]*65535.0); COLOUR[k].blue = j; istat = XAllocColor ( VD_ID, CM_ID, &COLOUR[k] ); if ( istat == 0 ) { (void) c_printo ( "ERROR: Colour pixel not allocated" ) ; PC_ID[k] = 0 ; } else PC_ID[k] = COLOUR[k].pixel ; } for ( k = 10; k<15 ; k++ ) { /* Starman greys */ COLOUR[k].flags = flags; ka = k - 10; j = (short) (sgr[ka]*65535.0) ; COLOUR[k].red = j; j = (short) (sgg[ka]*65535.0) ; COLOUR[k].green = j; j = (short) (sgb[ka]*65535.0) ; COLOUR[k].blue = j; istat = XAllocColor ( VD_ID, CM_ID, &COLOUR[k] ); if ( istat == 0 ) { (void) c_printo ( "ERROR: Colour pixel not allocated" ); PC_ID[k] = 0; } else PC_ID[k] = COLOUR[k].pixel ; } for ( k = 15; k<15+NUMDCOL ; k++ ) { /* Starman grey scale */ COLOUR[k].flags = flags ; j = (short) (( (float) (k-15)/ (float) (NUMDCOL-1))*65535.0) ; COLOUR[k].red = j; COLOUR[k].green = j; COLOUR[k].blue = j; istat = XAllocColor ( VD_ID, CM_ID, &COLOUR[k] ) ; if ( istat == 0 ) { (void) c_printo ( "ERROR: Colour pixel not allocated" ); PC_ID[k] = 0; } else PC_ID[k] = COLOUR[k].pixel; } XFlush ( VD_ID ); (void) dsxc_lutacol () ; /* Set up LUT */ (void) dsxc_lutcol () ; } } /****************************************************************** DSXC_VTIM -- Display part of virtual image (Xwindows) alan penny ral 1990-02-01 */ dsxc_vtim ( jvxs, jvxe, jvys, jvye, kcl ) int jvxs; /* i: X start of virtual area to display */ int jvxe; /* i: X end of virtual area to display */ int jvys; /* i: Y start of virtual area to display */ int jvye; /* i: Y end of virtual area to display */ int kcl; /* i: Flag to clear screen before (0=no) */ /* C-- */ { int j, isxs, isxe, isys, isye, ksxs, ksxe, ksys, ksye, ivxs, ivxe, ivys, ivye, kvxs, kvxe, kvys, kvye; long nn; char *ptr; char texta[100]; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; ivxe = imax( jvxs, jvxe ); /* Get +ve version of area*/ ivxs = imin( jvxs, jvxe ); ivye = imax( jvys, jvye ); ivys = imin( jvys, jvye ); if ( ivxe<1 || ivxs>DSSNX || ivye<1 || ivys>DSSNY ) { /* Check in virtual image */ if ( kcl != 0 ) (void) dsxc_clear(); /* If told to, clear */ return; } (void) vtc_tvs ( ivxs, ivys, &isxs, &isys ); /*Get screen positions */ isye = isye + (DSZM-1); (void) vtc_tvs ( ivxe, ivye, &isxe, &isye ); isxe = isxe + (DSZM-1); if ( (isxe+DSZM-1)<1 || isxs>DSSNX || /* Check in screen image */ (isye+DSZM-1)<1 || isys>DSSNY ) { if ( kcl != 0 ) (void) dsxc_clear(); /* If told to, clear */ return; } kvxs = imax(1,ivxs); /* Get area to display on screen*/ kvys = imax(1,ivys); kvxe = imin(DSSNX,ivxe); kvye = imin(DSSNY,ivye); (void) vtc_tvs ( kvxs, kvys, &ksxs, &ksys ); (void) vtc_tvs ( kvxe, kvye, &ksxe, &ksye ); ksxe = ksxe + (DSZM-1); ksye = ksye + (DSZM-1); if ( ksys<1 ) { ksys = 1; (void) vtc_tsv ( 0, ksys, &j, &kvys ); } if ( ksye>DSSNY ) { ksye = DSSNY; (void) vtc_tsv ( 0, ksye, &j, &kvye ); } if ( ksxs<1 ) { ksxs = 1; (void) vtc_tsv ( ksxs, 0, &kvxs, &j ); } if ( ksxe>DSSNX ) { ksxe = DSSNX; (void) vtc_tsv ( ksxe, 0, &kvxe, &j ); } if ( DSZM==1 && kvxs==1 && kvxe==DSSNX && kvys==1 /* Display whole vitual image */ && kvye==DSSNY ) { nn = 1; (void) dsxc_vtima ( ptr, nn, kcl, ksxs, ksxe, ksys, ksye, kvxs, kvxe, kvys, kvye ); } else { nn = DSZM*DSZM*(kvxe-kvxs+1)*(kvye-kvys+1); if ( nn<=0 ) { (void) sprintf ( texta, "ERROR: %d size workspace asked in - s/r dsxc_vtim", nn); (void ) c_printo ( texta ); return; } ptr = calloc ( nn, sizeof(char) ); if ( ptr==NULL ) { (void ) c_printo ( "ERROR: cant get workspace - in s/r dsxc_vtim" ); return; } (void) dsxc_vtima ( ptr, nn, kcl, ksxs, ksxe, ksys, ksye, kvxs, kvxe, kvys, kvye ); free ( ptr); } } /****************************************************************** DSXC_VTIMA -- Display part of virtual image (Xwindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ dsxc_vtima ( vt, nn, kcl, ksxs, ksxe, ksys, ksye, kvxs, kvxe, kvys, kvye ) char vt[]; /* o: Work area */ long nn; /* i: size of work area */ int kcl; /* i: Flag to clear screen before display (0=no) */ int ksxs; /* i: X start of screen area */ int ksxe; /* i: X end of screen area */ int ksys; /* i: Y start of screen area */ int ksye; /* i: Y end of screen area */ int kvxs; /* i: X start of virtual area to display */ int kvxe; /* i: X end of virtual area to display */ int kvys; /* i: Y start of virtual area to display */ int kvye; /* i: Y end of virtual area to display */ /* C-- */ { XImage *image; int k, kx, ky, jkx, jky; unsigned int ukx, uky; char *ipd; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; if ( kcl != 0 && ( ksxs > 1 || ksxe < DSSNX || /* If not fill screen and told to, clear first */ ksys > 1 || ksye < DSSNY ) ) (void) dsxc_clear(); kx = ksxe - ksxs + 1; ky = ksye - ksys + 1; ukx = kx; uky = ky; jkx = ksxs - 1; jky = DSSNY - ksye; if ( (DSZM==1) && (kvxs==1) && (kvxe==DSSNX) && /* Display whole vitual image */ (kvys==1) && (kvye==DSSNY) ) { ipd = malloc ( kx*ky ); for ( k=0;k<kx*ky;k++ ) ipd[k] = VT_IM[k]; } else { (void) dsxc_vtload ( vt, nn, kvxs, kvxe, kvys, kvye, ksxs ); /* Load array */ ipd = malloc ( kx*ky ); for ( k=0; k<kx*ky; k++ ) ipd[k] = vt[k]; } image = XCreateImage ( VD_ID, D_VISUAL, DEPTH, ZPixmap, 0, /* Point to image */ ipd, ukx, uky, 8, kx); if ( image == NULL ) { (void) c_printo ( "ERROR: Could not get image - in s/r dsxc_vtima" ); return; } XPutImage ( VD_ID, PIXMAP,GC_ID, image, 0, 0, jkx, jky, ukx, /* Put image in pixmap */ uky ); XCopyArea ( VD_ID, PIXMAP, WD_ID, GC_ID, jkx, jky, ukx, uky, /* Put pixmap area on screen */ jkx, jky ); XDestroyImage ( image ); XFlush ( VD_ID ); free (ipd); } /*********************************************************************** DSXC_VTLOAD -- Load part of virtual image into a zoomed array (Xwindows) Output array sides are size of input part array times the zoom factor. Output array starts at [0,0]. The area is defined in the standard 'virtual' array - the 'VT_IM' input and 'vt' output are Y-reversed from this. If the 'right' of the new (perhaps enlarged) array lies outside the screen, then the array is filled up only to the edge. The output array is usually sized so that it is big enough to hold the whole zoomed aray. alan penny ral 1991 Aug */ dsxc_vtload ( vt, nn, kvxs, kvxe, kvys, kvye, ksxs ) int nn; /* i: Size of work array */ char vt[]; /* o: Array to put image into */ int kvxs; /* i: X start of virtual area */ int kvxe; /* i: X end of virtual area */ int kvys; /* i: Y start of virtual area */ int kvye; /* i: Y end of virtual area */ int ksxs; /* i: X screen start of output array */ /* C-- */ { int j, k, jj, kk, ja, ka, kxd, kxf, kyd, kyf, kxs, kxe, kys, kye; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; kxs = kvxs - 1; /* VT_IM and vt coordinates */ kxe = kvxe - 1; kys = DSSNY - kvye; kye = DSSNY - kvys; if ( DSZM == 1 ) { ka = 0; /* Unzoomed is easy */ for ( j = kys; j <= kye; j++ ) { ja = j*DSSNX; for ( k = kxs; k <= kxe; k++ ) { vt[ka] = VT_IM[ja+k]; ka = ka + 1; } } } else { kxf = DSZM; /* Fraction of zoomed pixel */ kxd = ksxs + (kvxe-kvxs+1)*DSZM - 1; /* at right edge */ if ( kxd>DSSNX ) kxf = DSZM - (kxd-DSSNX); ka = 0; for ( j = kys; j <= kye; j++ ) { /* Y rows */ ja = j*DSSNX; for ( jj=1; jj <= DSZM; jj++ ) { if ( kxs != kxe ) { /* 1st N-1 X pixels */ for ( k = kxs; k <= kxe-1; k++ ) { for ( kk = 1; kk<= DSZM; kk++ ) { vt[ka] = VT_IM[ja+k]; ka = ka + 1; } } } if ( kxf >= 1 ) { for ( kk = 1; kk <= kxf; kk++ ) { /* Last X pixel (or fraction) */ vt[ka] = VT_IM[ja+kxe]; ka = ka + 1; } } } } } } /*********************************************************************** DSXC_CLOSE -- Close window (XWindows) alan penny ral 1990 jan pat morris leeds 1992 jan */ dsxc_close ( ierr ) int *ierr; /* o: Error flag (0=ok;1=bad) */ /* C-- */ { /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSWINDX = F77_NAMED_COMMON(ds_gen).dswindx; DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; PDSOPEN = F77_NAMED_COMMON(ds_panelb).pdsopen; *ierr = 0; /* Cant fail! */ if (!DSOPEN) return; DSWINDX = DSWINDX - DSSNX - 20; XUnmapWindow ( VD_ID, WD_ID ); XDestroyWindow ( VD_ID, WD_ID ); XFreePixmap ( VD_ID, PIXMAP ); if ( !PDSOPEN ) XCloseDisplay ( VD_ID ); XFlush ( VD_ID ); DSOPEN = False; DSSCUR = False; F77_NAMED_COMMON(ds_genb).dsopen = F77_FALSE; /* Display not open */ F77_NAMED_COMMON(ds_genb).dsscur = F77_FALSE; F77_NAMED_COMMON(ds_gen).dswindx = DSWINDX; } /*********************************************************************** DSXC_PTTIT -- Put image title on display (XWindows) alan penny ral 1990-01-31 pat morris leeds 1992 jan */ dsxc_pttit ( title ) char *title; /* i: Title to put up */ /* C-- */ { /* Cbegin */ XStoreName ( VD_ID, WD_ID, title ); } /************************************************************************** DSXC_ERASE -- Erase display (XWindows) a j penny ral 1990 jan */ dsxc_erase () /* C-- */ { int k; unsigned int udssnx, udssny; XImage *image; char kbya; char *ipd; /* Cbegin */ DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; if (!DSOPEN) return; udssnx = DSSNX; udssny = DSSNY; kbya = BY_PC_ID[9+4]; ipd = malloc (DSSNX*DSSNY); /* Clear virtual screen */ for ( k=0 ; k<(DSSNX*DSSNY) ; k++ ) { ipd[k] = kbya; VT_IM[k] = kbya; } image = XCreateImage ( VD_ID, D_VISUAL, DEPTH, ZPixmap, 0, /* Point to image */ ipd, udssnx, udssny, 8, DSSNX ); XPutImage ( VD_ID, PIXMAP, GC_ID, image, 0, 0, 0, 0, udssnx, /* Put image in pixmap */ udssny ); XCopyArea ( VD_ID, PIXMAP, WD_ID, GC_ID, 0, 0, udssnx, udssny, /* Put pixmap area on screen */ 0, 0 ); XDestroyImage ( image ); XFlush ( VD_ID ); free (ipd); } /************************************************************ DSXC_CLEAR -- Clear screen (XWindows) a j penny ral 1990 jan patrick morris leeds 1992 jan */ dsxc_clear (void) /* C-- */ { int k; unsigned int udssnx, udssny; XImage *image; char kbya; char *ipd; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; udssnx = DSSNX; udssny = DSSNY; kbya = BY_PC_ID[13]; k = (DSSNX*DSSNY)+1; ipd = calloc( k, sizeof(char) ); /* Get workspace */ if ( ipd == NULL ) { (void) c_printo ( "Error:Cant allocate memory in dsxc_clear" ); return; } for ( k=0 ; k<DSSNX*DSSNY ; k++ ) /* Clear temp virtual screen */ ipd[k] = kbya; image = XCreateImage ( VD_ID, D_VISUAL, DEPTH, ZPixmap, 0, /* Point to image */ ipd, udssnx, udssny, 8, DSSNX ); XPutImage ( VD_ID, PIXMAP, GC_ID, image, 0, 0, 0, 0, udssnx, /* Put image in pixmap */ udssny ); XCopyArea ( VD_ID, PIXMAP, WD_ID, GC_ID, 0, 0, udssnx, udssny, /* Put pixmap area on screen */ 0, 0 ); XDestroyImage ( image ); XFlush ( VD_ID ); free (ipd); } /*************************************************************** DSXC_CLEARPIX -- Clear pixmap (XWindows) a j penny ral 1990 jan patrick morris leeds 1992 feb */ dsxc_clearpix (void) /* C-- */ { int k; unsigned int udssnx, udssny; XImage *image; char kbya; char *ipd; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; udssnx = DSSNX; udssny = DSSNY; kbya = BY_PC_ID[13]; k = (DSSNX*DSSNY)+1 ; ipd = calloc( k, sizeof(char) ); /* Get workspace */ if ( ipd == NULL ) { (void) c_printo ( "Error:Cant allocate memory in dsxc_clearpix" ); return; } for ( k=0 ; k<DSSNX*DSSNY ; k++ ) /* Clear temp virtual screen */ ipd[k] = kbya; image = XCreateImage ( VD_ID, D_VISUAL, DEPTH, ZPixmap, 0, /* Point to image */ ipd, udssnx, udssny, 8, DSSNX ); XPutImage ( VD_ID, PIXMAP, GC_ID, image, 0, 0, 0, 0, udssnx, /* Put image in pixmap */ udssny ); XDestroyImage ( image ); XFlush ( VD_ID ); free (ipd); } /********************************************************************* DSXC_SCUR -- Start the cursor (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_scur (void) /* C-- */ { int kxi, kyi, kxo, kyo, jxo, jyo; float xo, yo; Cursor cursor; Pixmap cursor_pixmap; static unsigned char cursor_bits[32] = { 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xff, 0xff, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00 } ; XColor cursor_dummy; XColor cursor_foreground; XColor cursor_background; /* Cbegin */ DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSNXS = F77_NAMED_COMMON(ds_gen).dsnxs; DSNXE = F77_NAMED_COMMON(ds_gen).dsnxe; DSNYS = F77_NAMED_COMMON(ds_gen).dsnys; DSNYE = F77_NAMED_COMMON(ds_gen).dsnye; cursor_pixmap = XCreatePixmapFromBitmapData ( VD_ID, RW_ID, cursor_bits, 16, 16, 1, 0, 1 ); XLookupColor ( VD_ID, DefaultColormap(VD_ID, SC_ID), "red", &cursor_dummy, &cursor_foreground ); XLookupColor ( VD_ID, DefaultColormap(VD_ID, SC_ID), "black", &cursor_dummy, &cursor_background ); cursor = XCreatePixmapCursor ( VD_ID, cursor_pixmap, cursor_pixmap, &cursor_foreground, &cursor_background, 7, 7 ); /* Use same bitmap for shape and mask so cursor background is transparent */ XDefineCursor ( VD_ID, WD_ID, cursor ); XFreePixmap ( VD_ID, cursor_pixmap ); kxi = (DSNXS+DSNXE)/2; /*Set pointer position*/ kyi = (DSNYS+DSNYE)/2; (void) vtc_tis ( kxi, kyi, &kxo, &kyo ); jxo = kxo - 1; jyo = DSSNY - kyo; XWarpPointer ( VD_ID, None, WD_ID, 0, 0, 0, 0, jxo, jyo ); XFlush ( VD_ID ); xo = kxo; yo = kyo; DSCURPOSX = xo; DSCURPOSY = yo; DSSCUR = True; F77_NAMED_COMMON(ds_gen).dscurposx = xo; F77_NAMED_COMMON(ds_gen).dscurposy = yo; F77_NAMED_COMMON(ds_genb).dsscur = F77_TRUE; } /********************************************************************** DSXC_PCUR -- Put the cursor at position (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_pcur ( kx, ky ) int kx; /*i: X position to put cursor at */ int ky; /*i: Y position to put cursor at */ /* C-- */ { int kxo, kyo, jxo, jyo; float xo, yo; /* Cbegin */ DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; DSSCUR = F77_NAMED_COMMON(ds_genb).dsscur; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; if (!DSOPEN) return; if (!DSSCUR) (void) dsxc_scur (); (void) vtc_tis ( kx, ky, &kxo, &kyo ); xo = kxo; yo = kyo; jxo = kxo - 1; jyo = DSSNY - kyo; XWarpPointer ( VD_ID, None, WD_ID, 0, 0, 0, 0, jxo, jyo ); XFlush ( VD_ID ); DSCURPOSX = xo; DSCURPOSY = yo; DSCURSET = True; F77_NAMED_COMMON(ds_gen).dscurposx = xo; F77_NAMED_COMMON(ds_gen).dscurposy = yo; F77_NAMED_COMMON(ds_genb).dscurset = F77_TRUE; } /********************************************************************** DSXC_PSCUR -- Put the cursor at screen position (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_pscur ( x, y ) float x; /* i: X position to put cursor at */ float y; /* i: Y position to put cursor at */ /* C-- */ { int kx, ky; /* Cbegin */ DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; DSSCUR = F77_NAMED_COMMON(ds_genb).dsscur; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; if (!DSOPEN) return; if (!DSSCUR) (void) dsxc_scur (); kx = x - 1; ky = DSSNY - y; XWarpPointer ( VD_ID, None, WD_ID, 0, 0, 0, 0, kx, ky ); XFlush ( VD_ID ); DSCURPOSX = x; DSCURPOSY = y; DSCURSET = True; F77_NAMED_COMMON(ds_gen).dscurposx = x; F77_NAMED_COMMON(ds_gen).dscurposy = y; F77_NAMED_COMMON(ds_genb).dscurset = F77_TRUE; } /******************************************************************* DSXC_GETCURPB -- Get cursor posn and button state (XWindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_getcurpb ( isimage, kx, ky, kb, ierr ) Bool isimage; /* i: Image (T) or panel (F) ? */ int *kx; /* o: Cursor X position (start at 1,1) */ int *ky; /* o: Cursor Y position (start at 1,1) */ int kb[]; /* o: Cursor Button states (0=up;1=down) */ int *ierr; /* o: Error flag ( 0=ok; 1=bad) */ /* C-- */ { int n, kwx, kwy, jkx, jky; Window win, root, child; XEvent event; XWindowAttributes xwattr; /* Window Attributes */ unsigned int kbstat; Bool istat, loop; /* Cbegin */ DSSNY = F77_NAMED_COMMON(ds_gen).dssny; PNSNY = F77_NAMED_COMMON(ds_panel).pnsny; NUMXBUTTONS = F77_NAMED_COMMON(ds_gen).numxbuttons; *ierr = 0; if ( isimage ) win = WD_ID; else win = WD_P_ID; XGetWindowAttributes ( VD_ID, win, & xwattr ); if ( xwattr.map_state != IsViewable ) { *kx = 0 ; *ky = 0 ; kb[0] = 0 ; kb[1] = 0 ; kb[2] = 0 ; return; } istat = XQueryPointer ( VD_ID, win, &root, &child, &kwx, &kwy, &jkx, &jky, &kbstat ); XFlush ( VD_ID ); jkx = jkx + 1; if ( isimage ) jky = DSSNY - jky; else jky = PNSNY - jky; *kx = jkx; *ky = jky; if ( istat!=1 ) *ierr = 1; kb[0] = (kbstat-512*(kbstat/512))/256; kb[1] = (kbstat-1024*(kbstat/1024))/512; kb[2] = (kbstat-2048*(kbstat/2048))/1024; if ( *ierr == 0 && NUMXBUTTONS==2 && kb[1]==1 ) { (void) dsxc_mswait ( 400 ); istat = XQueryPointer ( VD_ID, win, &root, &child, &kwx, &kwy, &jkx, &jky, &kbstat ); XFlush ( VD_ID ); jkx = jkx + 1; if ( isimage ) jky = DSSNY - jky; else jky = PNSNY - jky; *kx = jkx; *ky = jky; if ( istat!=1 ) *ierr = 1; kb[0] = (kbstat-512*(kbstat/512))/256; kb[1] = (kbstat-1204*(kbstat/1024))/512; if ( kb[0]==1 && kb[1]==1 ) { kb[0] = 0; kb[1] = 0; kb[2] = 1; } } } /*********************************************************** DSXC_WAITBUT -- Wait for button to be pressed or to be up (Xwindows) alan penny ral 1990-02-03 pat morris leeds 1992 jan */ dsxc_waitbut ( isimage, down, kbut, kpx, kpy ) Bool isimage; /* i: Looking in the image (T) or panel (F)? */ Bool down; /* i: Flag to wait till button pressed (True) or all up (False) */ int *kbut; /* o: Which button pressed */ int *kpx; /* o: X screen position */ int *kpy; /* o: Y screen position */ /* C-- */ { int kb[3], istat, kpxa, kpya; Bool loop; /* Cbegin */ loop = True; while ( loop ) { (void) dsxc_mswait ( 20 ); (void) dsxc_getcurpb ( isimage, &kpxa, &kpya, kb, &istat ); if ( istat == 0 ) { if ( down ) { if ( (kb[0]==1) || (kb[1]==1) || (kb[2]==1) ) loop = False; if ( kb[0]==1 ) *kbut = 1; if ( kb[1]==1 ) *kbut = 2; if ( kb[2]==1 ) *kbut = 3; } else { *kbut = 0 ; if ( (kb[0]==0) && (kb[1]==0) && (kb[2]==0) ) loop= False; } } } *kpx = kpxa; *kpy = kpya; } /************************************************************** DSXC_PUTIM -- Put an image (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ void dsxc_putim ( data, kx, ky, ksxs, ksys ) char *data; /* i: Input data */ int kx; /* i: X size of data */ int ky; /* i: Y size of data */ int ksxs; /* i: X screen start of data position */ int ksys; /* i: Y screen start of data position */ /* C-- */ { int k, jkx, jky; unsigned int ukx, uky; XImage *image; char *ipd; /* Cbegin */ DSSNY = F77_NAMED_COMMON(ds_gen).dssny; ukx = kx; uky = ky; ipd = malloc (kx*ky); for ( k=0;k<kx*ky;k++ ) ipd[k] = data[k]; image = XCreateImage ( VD_ID, D_VISUAL, DEPTH, ZPixmap, 0, ipd, /* Point to image */ ukx, uky, 8, kx ); XFlush ( VD_ID ); jkx = ksxs - 1; jky = DSSNY - (ky-1) - ksys; XPutImage ( VD_ID, PIXMAP, GC_ID, image, 0, 0, jkx, jky, ukx, uky ); /* Put image in pixmap */ XCopyArea ( VD_ID, PIXMAP, WD_ID, GC_ID, jkx, jky, ukx, uky, jkx, jky ); /* Put pixmap area on screen */ XDestroyImage ( image ); XFlush ( VD_ID ); free ( ipd); } /************************************************************************ DSXC_PAINTOVA -- Paint moving oval at X/Y normals - erase last (Xwindows) alan penny ral 1990 Jan pat morris leeds 1992 jan */ dsxc_paintova ( pxo, pyo, rxo, ryo, px, py, rx1, ry1, kc1, rx2, ry2, kc2 ) float pxo; /* i: Old screen X posn */ float pyo; /* i: Old screen Y posn */ float rxo; /* i: Old max X oval radius (image scale) */ float ryo; /* i: Old max Y oval radius (image scale) */ float px; /* i: New screen X posn */ float py; /* i: New screen Y posn */ float rx1; /* i: Inner X oval radius (image scale) */ float ry1; /* i: Inner Y oval radius (image scale) */ int kc1; /* i: Inner oval colour (1-8) */ float rx2[]; /* i: Inner/outer annular X oval radii */ float ry2[]; /* i: Inner/outer annular Y oval radii */ int kc2; /* i: Outer oval colour (1-8) */ /* C-- */ { int kvxs, kvxe, kvys, kvye, kvx, kvy, kpxo, kpyo, jx, jy, jxs, jys, jxe, jye; unsigned int krx, kry; float rx, ry, pxi, pyi; /* Cbegin */ DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; kpxo = pxo; kpyo = pyo; (void) vtc_tsv ( kpxo, kpyo, &kvx, &kvy ); /* Get old image pos */ kvxs = kvx - (int) ((rxo/DSCOMFX)+6.0); /* Restore old area */ kvxe = kvxs + (int) ((2.0*rxo/DSCOMFX)+12.0); kvys = kvy - (int) ((ryo/DSCOMFY)+6.0); kvye = kvys + (int) ((2.0*ryo/DSCOMFY)+12.0); (void) dsxc_vtim ( kvxs, kvxe, kvys, kvye, 0 ); if ( kc1!=-1 ) { /* Paint new oval */ pxi = px + (DSZM/2); pyi = py + (DSZM/2); (void) dsxc_setthecol ( kc1 ); rx = (float) (DSZM) * rx1/ (float) (DSCOMFX); ry = (float) (DSZM) * ry1/ (float) (DSCOMFY); krx = 2.0*rx; kry = 2.0*ry; jx = pxi - rx - 1; jy = DSSNY - pyi - ry; XDrawArc ( VD_ID, WD_ID, GC_ID, jx, jy, krx, kry, 0, 64*360 ); } if ( kc2!=-1 ) { /* Paint new oval */ pxi = px + (DSZM/2); pyi = py + (DSZM/2); (void) dsxc_setthecol ( kc2 ); rx = (float) (DSZM) * rx2[0]/ (float) (DSCOMFX); ry = (float) (DSZM) * ry2[0]/ (float) (DSCOMFY); krx = 2.0*rx; kry = 2.0*ry; jx = pxi - rx - 1; jy = DSSNY - pyi - ry; XDrawArc ( VD_ID, WD_ID, GC_ID, jx, jy, krx, kry, 0, 64*360 ); rx = (float) (DSZM)* rx2[1]/(float) (DSCOMFX); ry = (float) (DSZM)* ry2[1]/(float) (DSCOMFY); krx = 2.0*rx; kry = 2.0*ry; jx = pxi - rx - 1; jy = DSSNY - pyi - ry; XDrawArc ( VD_ID, WD_ID, GC_ID, jx, jy, krx, kry, 0, 64*360 ); XFlush ( VD_ID ); } } /************************************************************************ DSXC_PAINTOVB -- Paint moving oval (XY) - erase last (Xwindows) alan penny ral 1990 Jan pat morris leeds 1992 jan */ dsxc_paintovb ( kcx, kcy, kc1, kc2, pxo, pyo, rxo, ryo ) int kcx[]; /* i: Centre/Inner/Outer oval X posns (image scale) */ int kcy[]; /* i: Centre/Inner/Outer oval Y posns (image scale) */ int kc1; /* i: Inner oval colour (1-8) */ int kc2; /* i: Outer oval colour (1-8) */ float pxo; /* i: Old screen X posn */ float pyo; /* i: Old screen Y posn */ float rxo; /* i: Old max X oval radius (image scale) */ float ryo; /* i: Old max Y oval radius (image scale) */ /* C-- */ { int kvxs, kvxe, kvys, kvye, kvx, kvy, kpxo, kpyo, kpxi, kpyi, k; XPoint theline[185]; /* Cbegin */ kpxo = pxo; kpyo = pyo; (void) vtc_tsv ( kpxo, kpyo, &kvx, &kvy ); /* Get old image pos */ kvxs = kvx - (int) ((rxo/DSCOMFX)+6.0); /* Restore old area */ kvxe = kvxs + (int) ((2.0*rxo/DSCOMFX)+12.0); kvys = kvy - (int) ((ryo/DSCOMFY)+6.0); kvye = kvys + (int) ((2.0*ryo/DSCOMFY)+12.0); (void) dsxc_vtim ( kvxs, kvxe, kvys, kvye, 0 ); XFlush ( VD_ID ); if ( kc1!=-1 ) { /* Paint new oval */ (void) dsxc_setthecol ( kc1 ); for ( k=0; k<=180; k++ ) { theline[k].x = kcx[k]; theline[k].y = DSSNY - kcy[k]; } XDrawLines ( VD_ID, WD_ID, GC_ID, theline, 181, CoordModeOrigin ); XFlush ( VD_ID ); } if ( kc2!=-1 ) { /* Paint new oval */ (void) dsxc_setthecol ( kc2 ); for ( k=0; k<=180; k++ ) { theline[k].x = kcx[181+k]; theline[k].y = DSSNY - kcy[181+k]; } XDrawLines ( VD_ID, WD_ID, GC_ID, theline, 181, CoordModeOrigin ); for ( k=0; k<=180; k++ ) { theline[k].x = kcx[362+k]; theline[k].y = DSSNY - kcy[362+k]; } XDrawLines ( VD_ID, WD_ID, GC_ID, theline, 181, CoordModeOrigin ); XFlush ( VD_ID ); } } /******************************************************************** DSXC_OVAL -- Paint an oval (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ dsxc_oval ( xp, yp, radx, rangle, elli, kc ) float xp; /* i: Image X position */ float yp; /* i: Image Y position */ float radx; /* i: Image pixel X radius */ float rangle; /* i: Oval angle to X-axis */ float elli; /* i: Oval ellipticity */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ { float angle; int k; /* Cbegin */ DSZM = F77_NAMED_COMMON(ds_gen).dszm; if ( radx<=0.0 || elli<0.0 || elli>1.0 ) return ; angle = rangle; if ( rangle<0.0 ) angle = -1.0*rangle; k = angle/180.0; angle = angle - 180.0*(float)k; if ( angle>90.0 ) angle = angle - 180.0; if ( rangle<0.0 ) angle = -1.0*angle; (void) dsxc_setthecol ( kc ); if ( angle==0.0 || angle==90.0 || angle==-90.0 || elli==0.0 ) { (void) dsxc_ovala ( xp, yp, radx, angle, elli, kc ); } else { (void) dsxc_ovalb ( xp, yp, radx, angle, elli, kc ); } } /******************************************************************** DSXC_OVALA -- Paint an oval at X/Y normals (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ dsxc_ovala ( xp, yp, radx, angle, elli, kc ) float xp; /* i: Image X position */ float yp; /* i: Image Y position */ float radx; /* i: Image pixel X radius */ float angle; /* i: Oval angle to X-axis */ float elli; /* i: Oval ellipticity */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ { float rx, ry, da, rxx, ryy, dx1, dy1, rx1, ry1, tt, sdx[5], sdy[5]; int j, k, nxv, nyv, kkcol, kp, jx, jy, krv, krva, ivx, ivy, kvx, kvy, kxp, kyp, kpx, kpy, kpxi, kpyi, krx, kry, ns; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; kxp = xp; kyp = yp; (void) vtc_tis ( kxp, kyp, &kpx, &kpy ); /* Get screen pos, rad */ kpx = kpx + (DSZM/2); kpy = kpy + (DSZM/2); if ( angle==0.0 ) { rx = radx; ry = radx*(1.0-elli); } else if ( elli==0.0) { rx = radx; ry = radx; } else { rx = radx*(1.0-elli); ry = radx; } rx = (float) (DSZM)*(rx)/(float) (DSCOMFX); ry = (float) (DSZM)*(ry)/(float) (DSCOMFY); krx = rx; /* Paint oval */ kry = ry; jx = kpx - rx - 1; jy = DSSNY - kpy - ry; XDrawArc ( VD_ID, WD_ID, GC_ID, jx, jy, 2*krx, 2*kry, 0, 64*360 ); (void) vtc_tsv ( kpx, kpy, &kvx, &kvy ); /*Put oval in virtual memory */ ivx = kpx + (int) rx; ivy = kpy + (int) ry; (void) vtc_tsv ( ivx, ivy, &krv, &krva ); rx1 = krv - kvx; ry1 = krva - kvy; (void) dsxc_scolnum ( kc, &kkcol ); if ( radx<=0.0 ) { nxv = kvx; nyv = kvy; kp = nxv + (DSSNY-nyv)*DSSNX; if ( (nxv>=1) && (nxv<=DSSNX) && (nyv>=1) && (nyv<=DSSNY) ) { VT_IM[kp-1] = (char) kkcol; } } else { nxv = kvx + rx1; nyv = kvy; kp = nxv + (DSSNY-nyv)*DSSNX; if ( (nxv>=1) && (nxv<=DSSNX) && (nyv>=1) && (nyv<=DSSNY) ) { VT_IM[kp-1] = (char) kkcol; } sdx[1] = 1.0; sdx[2] = 1.0; sdx[3] = -1.0; sdx[4] = -1.0; sdy[1] = 1.0; sdy[2] = -1.0; sdy[3] = -1.0; sdy[4] = 1.0; da = 0.3/rx1; ns = 3.14159/(2.0*da); ns = imin(90,ns); da = (3.14159/2.0)/(float) (ns); rxx = 1.0/(rx1*rx1); ryy = 1.0/(ry1*ry1); for ( j=1; j<=4; j++ ) { for ( k = 1; k<=ns+1 ; k++ ) { tt = tan(da*(float)(k)); tt = tt*tt; dx1 = sqrt(1.0/(rxx+(tt*ryy))); dy1 = sqrt(1.0/(ryy+(rxx/tt))); nxv = kvx + sdx[j]*dx1; nyv = kvy + sdy[j]*dy1; kp = nxv + (DSSNY-nyv)*DSSNX; if ( (nxv>=1) && (nxv<=DSSNX) && (nyv>=1) && (nyv<=DSSNY) ){ VT_IM[kp-1] = (char) kkcol; } } } } XFlush ( VD_ID ); } /******************************************************************** DSXC_OVALB -- Paint an oval at an angle (XWindows) alan penny ral 1990-02-01 pat morris leeds 1992 jan */ dsxc_ovalb ( xp, yp, radx, angle, elli, kc ) float xp; /* i: Image X position */ float yp; /* i: Image Y position */ float radx; /* i: Image pixel X radius */ float angle; /* i: Oval angle to X-axis */ float elli; /* i: Oval ellipticity */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ { float ry, sav, cav, ryy, trv, ttrv, dx, dy, rv, afx, afy, ax1, ax2, ay1, ay2, dfx, dfy, dax[48], day[48], sdx[5], sdy[5], f1, f2, f3, f4; int k, kk, kkcol, kp, ka, kcx[185], kcy[185], kcxa[185], kcya[185], kpx, kpy, kxp, kyp, nxv, nyv, nxva, nyva; XPoint theline[185]; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; DSZPX = F77_NAMED_COMMON(ds_gen).dszpx; DSZPY = F77_NAMED_COMMON(ds_gen).dszpy; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; kxp = xp; kyp = yp; (void) vtc_tis ( kxp, kyp, &kpx, &kpy ); /* Get screen pos, rad */ kpx = kpx + (DSZM/2); kpy = kpy + (DSZM/2); sav = -1.0*sin(angle*3.14159/180.0); cav = cos(angle*3.14159/180.0); sdx[1] = 1.0; sdx[2] = 1.0; sdx[3] = -1.0; sdx[4] = -1.0; sdy[1] = 1.0; sdy[2] = -1.0; sdy[3] = -1.0; sdy[4] = 1.0; ry = 1.0 - elli; ry = fmin(1.0,fmax(1.0e-6,ry)); ryy = 1.0/(ry*ry); for ( k=1; k<=45; k++ ) { rv = ((float)(k-1))*2.0*3.14159/180.0; trv = tan(rv); ttrv = trv*trv; if ( trv>-1.0e-5 && trv<1.0e-5) { dax[k] = 0.0; day[k] = ry; } else if ( trv>1.0e5 || trv<-1.0e5 ) { dax[k] = 1.0; day[k] = 0.0; } else { dax[k] = sqrt(1.0/(1.0+(ryy/ttrv))); day[k] = sqrt(1.0/(ryy+(1.0*ttrv))); } } afx = (float)DSZM/(float)DSCOMFX; afy = (float)DSZM/(float)DSCOMFY; dfx = kpx; dfy = kpy; ax1 = (float) DSZPX; ax2 = (float) DSZM; ay1 = (float) DSZPY; ay2 = (float) DSZM; for ( kk=1; kk<=4; kk++ ) { ka = (kk-1)*45 - 1; f1 = cav*radx*sdx[kk]; f2 = sav*radx*sdy[kk]; f3 = -1.0*sav*radx*sdx[kk]; f4 = cav*radx*sdy[kk]; for ( k=1; k<=45; k++ ) { if ( kk==2 || kk==4 ) { dx = f1*dax[46-k] + f2*day[46-k]; dy = f3*dax[46-k] + f4*day[46-k]; } else { dx = f1*dax[k] + f2*day[k]; dy = f3*dax[k] + f4*day[k]; } kcx[k+ka] = dx*afx + dfx; kcy[k+ka] = dy*afy + dfy; kcxa[k+ka] = ax1 + (float) (kcx[k+ka]-1)/ax2; kcya[k+ka] = ay1 + (float) (kcy[k+ka]-1)/ay2; } } kcxa[180] = kcxa[0]; kcya[180] = kcya[0]; kcx[180] = kcx[0]; kcy[180] = kcy[0]; for ( k=0; k<=180; k++ ) { theline[k].x = kcx[k]; theline[k].y = DSSNY - kcy[k]; } XDrawLines ( VD_ID, WD_ID, GC_ID, theline, 181, CoordModeOrigin ); (void) dsxc_scolnum ( kc, &kkcol ); /* Put in virtual image */ for ( k = 0; k<=180 ; k++ ) { nxv = kcxa[k]; nyv = kcya[k]; if ( (nxv>=1) && (nxv<=DSSNX) && (nyv>=1) && (nyv<=DSSNY) ) { kp = nxv + (DSSNY-nyv)*DSSNX; VT_IM[kp-1] = (char) kkcol; } } XFlush ( VD_ID ); } /******************************************************************** DSXC_OSIZE -- X, Y size of tilted oval alan penny ral 1994 */ dsxc_osize ( rad, ang, ell, xs, ys ) float rad; /* i: Major axis size */ float ang; /* i: Angle to x-axis in degrees */ float ell; /* i: Ellipticity */ float *xs; /* o: X size (total) */ float *ys; /* o: Y size (total) */ /* C-- */ { /* Cbegin */ *xs = 2.0*rad; *ys = 2.0*rad; } /**************************************************************** DSXC_CROSS -- Put a cross at a position (XWindows) alan penny ral 1990 Jan pat morris leeds 1992 jan */ dsxc_cross ( x, y, crs, kc ) float x; /* i: X position(image pixels) */ float y; /* i: Y position (image pixels) */ float crs; /* i: Cross size (end-to-end) (image pixels) */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ { int iv, jx, jxs, jxe, jy, jys, jye, k, kxa, kxb, kya, kyb, kkcol, kjs, kje, kx, ky, kpx, kpy, kdx, kdy; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; (void) dsxc_setthecol ( kc ); kx = x; ky = y; (void) vtc_tis ( kx, ky, &kpx, &kpy ); /* Get screen position*/ kpx = kpx + (DSZM/2); kpy = kpy + (DSZM/2); kdx = (float) (DSZM)*(crs/2.0); kdy = (float) (DSZM)*(crs/2.0); jxs = kpx - kdx - 1; /* Paint cross */ jxe = kpx + kdx - 1; jy = DSSNY - kpy; XDrawLine ( VD_ID, WD_ID, GC_ID, jxs, jy, jxe, jy ); XDrawLine ( VD_ID, PIXMAP, GC_ID, jxs, jy, jxe, jy ); jx = kpx - 1; jys = DSSNY - (kpy-kdy); jye = DSSNY - (kpy+kdy); XDrawLine ( VD_ID, WD_ID, GC_ID, jx, jye, jx, jys ); XDrawLine ( VD_ID, PIXMAP, GC_ID, jx, jye, jx, jys ); XFlush ( VD_ID ); iv = kpx - kdx; (void) vtc_tsv ( iv, kpy, &kxa, &kya ); /*Put in virtual image*/ iv = kpx + kdx; (void) vtc_tsv ( iv, kpy, &kxb, &kya ); (void) dsxc_scolnum ( kc, &kkcol ); if( (kxa<=DSSNX) && (kxb>=1) && (kya>=1) && (kya<=DSSNY) ) { kxa = imin(DSSNX,imax(1,kxa)); kxb = imin(DSSNX,imax(1,kxb)); kya = imin(DSSNY,imax(1,kya)); kjs = kxa + (DSSNY-kya)*DSSNX; kje = kjs + kxb - kxa ; for ( k = kjs; k<=kje ; k++ ) VT_IM[k-1] = (char) kkcol; } iv = kpy - kdy; (void) vtc_tsv ( kpx, iv, &kxa, &kya ); iv = kpy + kdy; (void) vtc_tsv ( kpx, iv, &kxa, &kyb ); if( (kxa<=DSSNX) && (kxb>=1) && (kya>=1) && (kya<=DSSNY) ) { kxa = imin(DSSNX,imax(1,kxa)); kya = imin(DSSNY,imax(1,kya)); kyb = imin(DSSNY,imax(1,kyb)); kje = (DSSNY-kya)*DSSNX + kxa; kjs = (DSSNY-kyb)*DSSNX + kxa; for ( k = kjs; k<=kje; k += DSSNX ) VT_IM[k-1] = (char) kkcol; } } /********************************************************************** DSXC_SCOLNUM -- Calc colour pixel number from colour number (XWindows) alan penny ral 1990 May pat morris leeds 1992 jan */ dsxc_scolnum ( kc, kkcol ) int kc; /* i: Colour number */ int *kkcol; /* o: Display colour pixel number */ /* C-- */ { /* Cbegin */ switch (kc) { case 9 : *kkcol = BY_PC_ID[10]; break; case 10 : *kkcol = BY_PC_ID[14]; break; default : *kkcol = BY_PC_ID[1+imin(8,imax(0,kc))]; } } /********************************************************************** DSXC_LINE -- Put a line at a position (XWindows) alan penny ral 1990 May pat morris leeds 1992 jan */ dsxc_line ( xs, ys, xe, ye, kc ) float xs; /* i: Line start X position(image pixels) */ float ys; /* i: Line start Y position (image pixels) */ float xe; /* i: Line end X position(image pixels) */ float ye; /* i: Line end Y position (image pixels) */ int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink) 9=black;10=white) */ /* C-- */ { float ds, axc, ayc, dx, dy, ax, ay; int k, kxa, kxb, kya, kyb, kkcol, kx, ky, kn, kp, kjs, kje, kt, kxs, kys, kpxs, kpys, kxe, kye, kpxe, kpye, jxs, jxe, jys, jye; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; (void) dsxc_setthecol ( kc ); kxs = xs; kys = ys; (void) vtc_tis ( kxs, kys, &kpxs, &kpys ); /*Get screen position*/ kxe = xe; kye = ye; (void) vtc_tis ( kxe, kye, &kpxe, &kpye ); /*Get screen position*/ kpxs = kpxs + (DSZM/2); kpys = kpys + (DSZM/2); kpxe = kpxe + (DSZM/2); kpye = kpye + (DSZM/2); jxs = kpxs - 1; jxe = kpxe - 1; jys = DSSNY - kpys; jye = DSSNY - kpye; XDrawLine ( VD_ID, WD_ID, GC_ID, jxs, jys, jxe, jye ); /* Paint line */ XDrawLine ( VD_ID, PIXMAP, GC_ID, jxs, jys, jxe, jye ); XFlush ( VD_ID ); (void) vtc_tsv ( kpxs, kpys, &kxa, &kya ); /* Put in virtual image */ (void) vtc_tsv ( kpxe, kpye, &kxb, &kyb ); (void) dsxc_scolnum ( kc, &kkcol ); if ( kxa==kxb ) { if ( (kxa>=1) && (kxa<=DSSNX) ) { kxa = imin(DSSNX,imax(1,kxa)); kjs = kxa + (DSSNY-kya)*DSSNX; kje = kxa + (DSSNY-kyb)*DSSNX; if ( kjs>kje ) { kt = kjs; kjs = kje; kje = kt; } if ( (kjs<=MAXVIRT) && (kje>=1) ) { kjs = imax(1,imin(MAXVIRT,kjs)); kje = imax(1,imin(MAXVIRT,kje)); for ( k = kjs; k<=kje; k+=DSSNX ) VT_IM[k-1] = (char) kkcol; } } } else if ( kya==kyb ) { if ( (kya>=1) && (kya<=DSSNY) ) { kya = imin(DSSNY,imax(1,kya)); if ( kxa>kxb ) { kt = kxa; kxa = kxb; kxb = kxa; } if ( (kxa<=DSSNX) && (kya>=1) ) { kxa = imin(DSSNX,imax(1,kxa)); kxb = imin(DSSNX,imax(1,kxb)); kjs = kxa + (DSSNY-kya)*DSSNX; kje = kxb + (DSSNY-kya)*DSSNX; for ( k = kjs; k<=kje; k++ ) VT_IM[k-1] = (char) kkcol; } } } else { dx = kxb - kxa; dy = kyb - kya; ds = sqrt(dx*dx+dy*dy); axc = dx/ds; ayc = dy/ds; ax = (float) (kxa) - 0.25; ay = (float) (kya) - 0.25; kn = ds*4.0; for ( k = 1; k<=kn; k++ ) { ax = ax + 0.25*axc; ay = ay + 0.25*ayc; kx = ax; ky = ay; if ( (kx>=1) && (kx<=DSSNX) && (ky>=1) && (ky<=DSSNY) ) { kp = kx + (DSSNY-ky)*DSSNX; VT_IM[kp-1] = (char) kkcol; } } } } /************************************************************************ DSXC_SETTHECOL -- Set writing colour (Xwindows) alan penny ral 1990-06-09 pat morris leeds 1992 jan */ dsxc_setthecol ( kc ) int kc; /* i: Colour (1=red;2=green;3=blue;4=yellow; 5=cyan;6=mauve;7=tan;8=pink; 9=black;10=white) */ /* C-- */ { int kkcol; /* Cbegin */ (void) dsxc_scolnum ( kc, &kkcol ); XSetForeground ( VD_ID, GC_ID, kkcol ); XFlush ( VD_ID ); } /**************************************************************************** DSXC_UPDOWN -- Raise' or 'lower' a window (Xwindows) alan penny ral 1990-06-09 pat morris leeds 1992 jan */ dsxc_updown ( kf ) int kf; /* i: raise=1; lower=2 */ /* C-- */ { /* Cbegin */ DSOPEN = F77_NAMED_COMMON(ds_genb).dsopen; if (!DSOPEN) return; if ( kf==1 ) { XRaiseWindow ( VD_ID, WD_ID ); XFlush ( VD_ID ); } else { XLowerWindow ( VD_ID, WD_ID ); XFlush ( VD_ID ); } } /******************************************************************************** DSXC_ACIMR -- Display part of an actual real image (loads virtual image) (X window) alan penny ral 1990 jan */ dsxc_acimr ( im, mx, my, ixs, ixe, iys, iye, ix, iy, wrap ) int mx; /* i: Actual image X size */ int my; /* i: Actual image Y size */ float im[]; /* i: Actual image */ int ixs; /* i: Actual image area X start */ int ixe; /* i: Actual image area X end */ int iys; /* i: Actual image area Y start */ int iye; /* i: Actual image area Y end */ int ix; /* i: Position in virtual image of X start */ int iy; /* i: Position in virtual image of Y start */ Bool wrap; /* i: Flag to wrap values round display limits */ /* C--*/ { int iv, j, jj, ja, jx, jy, k, ka, kxoff, kyoff, kvxs, kvxe, kvys, kvye, knv, kas, kbs, kcs, nxs, nxe, nys, nye; float zero, delta, rv, rva; char byteim[2048]; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; DSVMIN = F77_NAMED_COMMON(ds_gen).dsvmin; DSVMAX = F77_NAMED_COMMON(ds_gen).dsvmax; RINVAL = F77_NAMED_COMMON(imagecoma).rinval; if ( ixs>mx || ixe<1 || iys>my || iye<1 ) return; /* Check in image */ nxs = imax(1,ixs); /* Check all in image */ nxe = imin(mx,ixe); nys = imax(1,iys); nye = imin(my,iye); jx = 1 + (((nxe-nxs+1)-1)/DSCOMFX); jy = 1 + (((nye-nys+1)-1)/DSCOMFY); kvxs = ix; kvxe = ix + jx - 1; kvys = iy; kvye = iy + jy - 1; if ( kvxs>DSSNX || kvys>DSSNY || kvxe<1 || kvye<1 ) return; /* Check any in virtual screen */ kxoff = 0; kyoff = 0; if ( kvxs<1 ) kxoff = 1 - kvxs; if ( kvys<1 ) kyoff = 1 - kvys; kvxs = imax(1,kvxs); kvxe = imin(DSSNX,kvxe); kvys = imax(1,kvys); kvye = imin(DSSNY,kvye); rv = DSVMAX - DSVMIN; if ( rv==0.0 ) rv = 1.0; delta = (float) (NUMDCOL-1)/rv; /* Set up display factors */ zero = -1.0*DSVMIN*delta; knv = kvxe - kvxs + 1; ka = nys + kyoff; /* Load in virtual image */ for ( k=kvys; k<=kvye; k++ ) { ja = nxs + kxoff; for ( j=kvxs; j<=kvxe; j++ ) { rv = im[ja-1+(ka-1)*mx]; ja = ja + DSCOMFX; if ( rv==RINVAL ) { byteim[j-1] = BY_PC_ID[15+NUMDCOL]; }else{ rva = rv*delta + zero; rva = fmin(1.0e6,fmax(-1.0e6,rva)); jj = (int)rva; if ( wrap ) { jj = jj % (NUMDCOL-1); if ( jj<0 ) jj = jj + NUMDCOL; iv = 16 + jj; }else{ iv = 16 + imax(0,imin(jj,(NUMDCOL-1))); } byteim[j-1] = BY_PC_ID[iv]; } } ka = ka + DSCOMFY; for ( kas=0; kas<knv; kas++ ) { kbs = kvxs + (DSSNY-k)*DSSNX - 1; kcs = kvxs - 1; VT_IM[kbs+kas] = byteim[kcs+kas]; } } dsxc_vtim ( kvxs, kvxe, kvys, kvye, 0 ); /* Display section of virtual image */ } /******************************************************************************** DSXC_ACIMS -- Display part of an actual short image (loads virtual image) (X window) alan penny ral 1990 jan */ dsxc_acims ( im, mx, my, ixs, ixe, iys, iye, ix, iy, wrap ) int mx; /* i: Actual image X size */ int my; /* i: Actual image Y size */ short int im[]; /* i: Actual image */ int ixs; /* i: Actual image area X start */ int ixe; /* i: Actual image area X end */ int iys; /* i: Actual image area Y start */ int iye; /* i: Actual image area Y end */ int ix; /* i: Position in virtual image of X start */ int iy; /* i: Position in virtual image of Y start */ Bool wrap; /* i: Flag to wrap values round display limits */ /* C--*/ { int iv, j, ja, jj, jx, jy, kk, k, ka, kv, kxoff, kyoff, kvxs, kvxe, kvys, kvye, knv, kas, kbs, kcs, nxs, nxe, nys, nye; float zero, delta, rv, rva; char byteim[2048]; /* Cbegin */ DSSNX = F77_NAMED_COMMON(ds_gen).dssnx; DSSNY = F77_NAMED_COMMON(ds_gen).dssny; DSZM = F77_NAMED_COMMON(ds_gen).dszm; DSCOMFX = F77_NAMED_COMMON(ds_gen).dscomfx; DSCOMFY = F77_NAMED_COMMON(ds_gen).dscomfy; DSVMIN = F77_NAMED_COMMON(ds_gen).dsvmin; DSVMAX = F77_NAMED_COMMON(ds_gen).dsvmax; INVAL = F77_NAMED_COMMON(imagecoma).inval; if ( ixs>mx || ixe<1 || iys>my || iye<1 ) return; /* Check in image */ nxs = imax(1,ixs); /* Check all in image */ nxe = imin(mx,ixe); nys = imax(1,iys); nye = imin(my,iye); jx = 1 + (((nxe-nxs+1)-1)/DSCOMFX); jy = 1 + (((nye-nys+1)-1)/DSCOMFY); kvxs = ix; kvxe = ix + jx - 1; kvys = iy; kvye = iy + jy - 1; if ( kvxs>DSSNX || kvys>DSSNY || kvxe<1 || kvye<1 ) return; /* Check any in virtual screen */ kxoff = 0; kyoff = 0; if ( kvxs<1 ) kxoff = 1 - kvxs; if ( kvys<1 ) kyoff = 1 - kvys; kvxs = imax(1,kvxs); kvxe = imin(DSSNX,kvxe); kvys = imax(1,kvys); kvye = imin(DSSNY,kvye); rv = DSVMAX - DSVMIN; if ( rv==0.0 ) rv = 1.0; delta = (float) (NUMDCOL-1)/rv; /* Set up display factors */ zero = -1.0*DSVMIN*delta; knv = kvxe - kvxs + 1; ka = nys + kyoff; /* Load in virtual image */ for ( k=kvys; k<=kvye; k++ ) { ja = nxs + kxoff; for ( j=kvxs; j<=kvxe; j++ ) { kv = (int) im[ja-1+(ka-1)*mx]; ja = ja + DSCOMFX; if ( kv==INVAL ) { byteim[j-1] = BY_PC_ID[15+NUMDCOL]; }else{ rva = (float) kv*delta + zero; rva = fmin(1.0e6,fmax(-1.0e6,rva)); jj = (int) rva; if ( wrap ) { jj = jj % (NUMDCOL-1); if ( jj<0 ) jj = jj + NUMDCOL; iv = 16 + jj; }else{ iv = 16 + imax(0,imin(jj,(NUMDCOL-1))); } byteim[j-1] = BY_PC_ID[iv]; } } ka = ka + DSCOMFY; for ( kas=0; kas<knv; kas++ ) { kbs = kvxs + (DSSNY-k)*DSSNX - 1; kcs = kvxs - 1; VT_IM[kbs+kas] = byteim[kcs+kas]; } } dsxc_vtim ( kvxs, kvxe, kvys, kvye, 0 ); /* Display section of virtual image */ } /******************************************************************************** IMIN */ int imin ( int f1, int f2 ) { int smaller; if ( f1 < f2 ) smaller = f1; else smaller = f2; return smaller ; } /******************************************************************************** IMAX */ int imax ( int f1, int f2 ) { int bigger; if ( f1 > f2 ) bigger = f1; else bigger = f2; return bigger ; } /******************************************************************************** FMIN */ float fmin ( float f1, float f2 ) { float smaller; if ( f1 < f2 ) smaller = f1; else smaller = f2; return smaller ; } /******************************************************************************** FMAX */ float fmax ( float f1, float f2 ) { float bigger; if ( f1 > f2 ) bigger = f1; else bigger = f2; return bigger ; } /**************************************************************************** DSXC_MSWAIT -- Wait X millisecs (Xwindows) Authors: Alan Penny (RAL) 2 Mar 1993 Convert to Starman */ dsxc_mswait ( msecs ) int msecs; /* i: no of milliseconds to wait */ /* C-- */ { /* Cbegin */ (void) dsxc_unix_mswait ( msecs ); } /**************************************************************************** DSXC_UNIX_MSWAIT -- Wait X millisecs (Xwindows) This function causes the program to go to sleep for a given number of milliseconds. This function in needed to provides sub-second sleep intervals as the standard C function, sleep, has a resolution of 1 second. Notes: - If a negative time interval is given, the routine returns immediately. - The resolution of the timer on the Sun is 10ms. - The resolution of the timer on the DECstation is 3.906ms. - All actual sleep times will be in units of the timer resolution and will be rounded up. E.g. a request to sleep for 15ms on a Sun will result in an actual sleep time of 20ms. Copyright: Copyright (C) 1992 Science & Engineering Research Council Authors: PMA: Peter Allan (Starlink, RAL) 18 Jun 1992 Original Alan Penny (RAL) 2 Mar 1993 Convert to Starman */ dsxc_unix_mswait ( msecs ) int msecs; /* i: no of milliseconds to wait */ /* C-- */ { struct timeval time_struct; /* The time structure to give to select. */ int ret; /* The return code from select. */ fd_set ia, ib, ic; /* Cbegin */ if ( msecs <= 0 ) return; /* Check for a positive time interval. */ if ( msecs < 1000 ) { /* Set up the time structure, allowing */ time_struct.tv_sec = 0; /* for times longer than 1 second. */ time_struct.tv_usec = msecs * 1000; } else { time_struct.tv_sec = msecs / 1000; time_struct.tv_usec = ( msecs % 1000 ) * 1000; } FD_ZERO (&ia); FD_ZERO (&ib); FD_ZERO (&ic); ret = select ( 0, &ia, &ib, &ic, &time_struct ); /* Call select with null file descriptor sets */ /* to give the effect of going */ /* to sleep for a given time. */ }
9028fc972b279d2924eb36f9e6427cab84681570
8838eb997879add5759b6dfb23f9a646464e53ca
/src/drivers/serial/i8250/i8250_diag.c
d8d8e9350c137b35e2e47a23c992539fef4caa8d
[ "BSD-2-Clause" ]
permissive
embox/embox
d6aacec876978522f01cdc4b8de37a668c6f4c80
98e3c06e33f3fdac10a29c069c20775568e0a6d1
refs/heads/master
2023-09-04T03:02:20.165042
2023-09-02T14:55:31
2023-09-02T14:55:31
33,078,138
1,087
325
BSD-2-Clause
2023-09-14T16:58:34
2015-03-29T15:27:48
C
UTF-8
C
false
false
937
c
i8250_diag.c
/** * @file * @brief Serial driver for x86 (compatible with 16550) * * @date 12.04.10 * @author Nikolay Korotky */ #include <drivers/serial/uart_dev.h> #include <drivers/serial/diag_serial.h> #include <drivers/diag.h> //#include <drivers/common/memory.h> #include <framework/mod/options.h> /** Default I/O addresses * NOTE: The actual I/O addresses used are stored * in a table in the BIOS data area 0000:0400. */ #define UART_BASE OPTION_GET(NUMBER, base_addr) #define IRQ_NUM OPTION_GET(NUMBER, irq_num) #define BAUD_RATE OPTION_GET(NUMBER,baud_rate) extern const struct uart_ops i8250_uart_ops; static struct uart uart_diag = { .uart_ops = &i8250_uart_ops, .irq_num = IRQ_NUM, .base_addr = UART_BASE, }; static const struct uart_params uart_diag_params = { .baud_rate = BAUD_RATE, .uart_param_flags = UART_PARAM_FLAGS_8BIT_WORD, }; DIAG_SERIAL_DEF(&uart_diag, &uart_diag_params);
84eaee68b5c13e0e9c91391558d19c7e45a24d7d
ee87c715e5d937b0380ddb87d56e9ebc4877a02b
/sklearn/svm/src/libsvm/svm.h
518872c67bc5ca70db197af18dae3a284746b25e
[ "BSD-3-Clause" ]
permissive
scikit-learn/scikit-learn
27a2196f3173e0f32f7a5c5d652b70a6c57c7644
061f8777b48e5491b0c57bb8e0bc7067c103079d
refs/heads/main
2023-08-18T15:32:59.764468
2023-08-18T14:39:08
2023-08-18T14:39:08
843,222
58,456
29,777
BSD-3-Clause
2023-09-14T19:08:34
2010-08-17T09:43:38
Python
UTF-8
C
false
false
6,262
h
svm.h
#ifndef _LIBSVM_H #define _LIBSVM_H #define LIBSVM_VERSION 310 #ifdef __cplusplus extern "C" { #endif #include "_svm_cython_blas_helpers.h" struct svm_node { int dim; int ind; /* index. A bit redundant, but needed if using a precomputed kernel */ double *values; }; struct svm_problem { int l; double *y; struct svm_node *x; double *W; /* instance weights */ }; struct svm_csr_node { int index; double value; }; struct svm_csr_problem { int l; double *y; struct svm_csr_node **x; double *W; /* instance weights */ }; enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */ enum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */ struct svm_parameter { int svm_type; int kernel_type; int degree; /* for poly */ double gamma; /* for poly/rbf/sigmoid */ double coef0; /* for poly/sigmoid */ /* these are for training only */ double cache_size; /* in MB */ double eps; /* stopping criteria */ double C; /* for C_SVC, EPSILON_SVR and NU_SVR */ int nr_weight; /* for C_SVC */ int *weight_label; /* for C_SVC */ double* weight; /* for C_SVC */ double nu; /* for NU_SVC, ONE_CLASS, and NU_SVR */ double p; /* for EPSILON_SVR */ int shrinking; /* use the shrinking heuristics */ int probability; /* do probability estimates */ int max_iter; /* ceiling on Solver runtime */ int random_seed; /* seed for random number generator */ }; // // svm_model // struct svm_model { struct svm_parameter param; /* parameter */ int nr_class; /* number of classes, = 2 in regression/one class svm */ int l; /* total #SV */ struct svm_node *SV; /* SVs (SV[l]) */ double **sv_coef; /* coefficients for SVs in decision functions (sv_coef[k-1][l]) */ int *n_iter; /* number of iterations run by the optimization routine to fit the model */ int *sv_ind; /* index of support vectors */ double *rho; /* constants in decision functions (rho[k*(k-1)/2]) */ double *probA; /* pairwise probability information */ double *probB; /* for classification only */ int *label; /* label of each class (label[k]) */ int *nSV; /* number of SVs for each class (nSV[k]) */ /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */ /* XXX */ int free_sv; /* 1 if svm_model is created by svm_load_model*/ /* 0 if svm_model is created by svm_train */ }; struct svm_csr_model { struct svm_parameter param; /* parameter */ int nr_class; /* number of classes, = 2 in regression/one class svm */ int l; /* total #SV */ struct svm_csr_node **SV; /* SVs (SV[l]) */ double **sv_coef; /* coefficients for SVs in decision functions (sv_coef[k-1][l]) */ int *n_iter; /* number of iterations run by the optimization routine to fit the model */ int *sv_ind; /* index of support vectors */ double *rho; /* constants in decision functions (rho[k*(k-1)/2]) */ double *probA; /* pairwise probability information */ double *probB; /* for classification only */ int *label; /* label of each class (label[k]) */ int *nSV; /* number of SVs for each class (nSV[k]) */ /* nSV[0] + nSV[1] + ... + nSV[k-1] = l */ /* XXX */ int free_sv; /* 1 if svm_model is created by svm_load_model*/ /* 0 if svm_model is created by svm_train */ }; /* svm_ functions are defined by libsvm_template.cpp from generic versions in svm.cpp */ struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param, int *status, BlasFunctions *blas_functions); void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target, BlasFunctions *blas_functions); int svm_save_model(const char *model_file_name, const struct svm_model *model); struct svm_model *svm_load_model(const char *model_file_name); int svm_get_svm_type(const struct svm_model *model); int svm_get_nr_class(const struct svm_model *model); void svm_get_labels(const struct svm_model *model, int *label); double svm_get_svr_probability(const struct svm_model *model); double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values, BlasFunctions *blas_functions); double svm_predict(const struct svm_model *model, const struct svm_node *x, BlasFunctions *blas_functions); double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates, BlasFunctions *blas_functions); void svm_free_model_content(struct svm_model *model_ptr); void svm_free_and_destroy_model(struct svm_model **model_ptr_ptr); void svm_destroy_param(struct svm_parameter *param); const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param); void svm_set_print_string_function(void (*print_func)(const char *)); /* sparse version */ /* svm_csr_ functions are defined by libsvm_template.cpp from generic versions in svm.cpp */ struct svm_csr_model *svm_csr_train(const struct svm_csr_problem *prob, const struct svm_parameter *param, int *status, BlasFunctions *blas_functions); void svm_csr_cross_validation(const struct svm_csr_problem *prob, const struct svm_parameter *param, int nr_fold, double *target, BlasFunctions *blas_functions); int svm_csr_get_svm_type(const struct svm_csr_model *model); int svm_csr_get_nr_class(const struct svm_csr_model *model); void svm_csr_get_labels(const struct svm_csr_model *model, int *label); double svm_csr_get_svr_probability(const struct svm_csr_model *model); double svm_csr_predict_values(const struct svm_csr_model *model, const struct svm_csr_node *x, double* dec_values, BlasFunctions *blas_functions); double svm_csr_predict(const struct svm_csr_model *model, const struct svm_csr_node *x, BlasFunctions *blas_functions); double svm_csr_predict_probability(const struct svm_csr_model *model, const struct svm_csr_node *x, double* prob_estimates, BlasFunctions *blas_functions); void svm_csr_free_model_content(struct svm_csr_model *model_ptr); void svm_csr_free_and_destroy_model(struct svm_csr_model **model_ptr_ptr); void svm_csr_destroy_param(struct svm_parameter *param); const char *svm_csr_check_parameter(const struct svm_csr_problem *prob, const struct svm_parameter *param); /* end sparse version */ #ifdef __cplusplus } #endif #endif /* _LIBSVM_H */
f7bdd678243074674d1e32b05350b84b4e3c067a
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/virtio/virtio.c
beaa7cc4e857e8f9b54a8d1d3b862566ac11d312
[ "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,637
c
virtio.c
#include <linux/virtio.h> #include <linux/spinlock.h> #include <linux/virtio_config.h> #include <linux/module.h> #include <linux/idr.h> /* Unique numbering for virtio devices. */ static DEFINE_IDA(virtio_index_ida); static ssize_t device_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); return sprintf(buf, "0x%04x\n", dev->id.device); } static ssize_t vendor_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); return sprintf(buf, "0x%04x\n", dev->id.vendor); } static ssize_t status_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); return sprintf(buf, "0x%08x\n", dev->config->get_status(dev)); } static ssize_t modalias_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); return sprintf(buf, "virtio:d%08Xv%08X\n", dev->id.device, dev->id.vendor); } static ssize_t features_show(struct device *_d, struct device_attribute *attr, char *buf) { struct virtio_device *dev = dev_to_virtio(_d); unsigned int i; ssize_t len = 0; /* We actually represent this as a bitstring, as it could be * arbitrary length in future. */ for (i = 0; i < ARRAY_SIZE(dev->features)*BITS_PER_LONG; i++) len += sprintf(buf+len, "%c", test_bit(i, dev->features) ? '1' : '0'); len += sprintf(buf+len, "\n"); return len; } static struct device_attribute virtio_dev_attrs[] = { __ATTR_RO(device), __ATTR_RO(vendor), __ATTR_RO(status), __ATTR_RO(modalias), __ATTR_RO(features), __ATTR_NULL }; static inline int virtio_id_match(const struct virtio_device *dev, const struct virtio_device_id *id) { if (id->device != dev->id.device && id->device != VIRTIO_DEV_ANY_ID) return 0; return id->vendor == VIRTIO_DEV_ANY_ID || id->vendor == dev->id.vendor; } /* This looks through all the IDs a driver claims to support. If any of them * match, we return 1 and the kernel will call virtio_dev_probe(). */ static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) { unsigned int i; struct virtio_device *dev = dev_to_virtio(_dv); const struct virtio_device_id *ids; ids = drv_to_virtio(_dr)->id_table; for (i = 0; ids[i].device; i++) if (virtio_id_match(dev, &ids[i])) return 1; return 0; } static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env) { struct virtio_device *dev = dev_to_virtio(_dv); return add_uevent_var(env, "MODALIAS=virtio:d%08Xv%08X", dev->id.device, dev->id.vendor); } static void add_status(struct virtio_device *dev, unsigned status) { dev->config->set_status(dev, dev->config->get_status(dev) | status); } void virtio_check_driver_offered_feature(const struct virtio_device *vdev, unsigned int fbit) { unsigned int i; struct virtio_driver *drv = drv_to_virtio(vdev->dev.driver); for (i = 0; i < drv->feature_table_size; i++) if (drv->feature_table[i] == fbit) return; BUG(); } EXPORT_SYMBOL_GPL(virtio_check_driver_offered_feature); static int virtio_dev_probe(struct device *_d) { int err, i; struct virtio_device *dev = dev_to_virtio(_d); struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); u32 device_features; /* We have a driver! */ add_status(dev, VIRTIO_CONFIG_S_DRIVER); /* Figure out what features the device supports. */ device_features = dev->config->get_features(dev); /* Features supported by both device and driver into dev->features. */ memset(dev->features, 0, sizeof(dev->features)); for (i = 0; i < drv->feature_table_size; i++) { unsigned int f = drv->feature_table[i]; BUG_ON(f >= 32); if (device_features & (1 << f)) set_bit(f, dev->features); } /* Transport features always preserved to pass to finalize_features. */ for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) if (device_features & (1 << i)) set_bit(i, dev->features); dev->config->finalize_features(dev); err = drv->probe(dev); if (err) add_status(dev, VIRTIO_CONFIG_S_FAILED); else { add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); if (drv->scan) drv->scan(dev); } return err; } static int virtio_dev_remove(struct device *_d) { struct virtio_device *dev = dev_to_virtio(_d); struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); drv->remove(dev); /* Driver should have reset device. */ WARN_ON_ONCE(dev->config->get_status(dev)); /* Acknowledge the device's existence again. */ add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE); return 0; } static struct bus_type virtio_bus = { .name = "virtio", .match = virtio_dev_match, .dev_attrs = virtio_dev_attrs, .uevent = virtio_uevent, .probe = virtio_dev_probe, .remove = virtio_dev_remove, }; int register_virtio_driver(struct virtio_driver *driver) { /* Catch this early. */ BUG_ON(driver->feature_table_size && !driver->feature_table); driver->driver.bus = &virtio_bus; return driver_register(&driver->driver); } EXPORT_SYMBOL_GPL(register_virtio_driver); void unregister_virtio_driver(struct virtio_driver *driver) { driver_unregister(&driver->driver); } EXPORT_SYMBOL_GPL(unregister_virtio_driver); int register_virtio_device(struct virtio_device *dev) { int err; dev->dev.bus = &virtio_bus; /* Assign a unique device index and hence name. */ err = ida_simple_get(&virtio_index_ida, 0, 0, GFP_KERNEL); if (err < 0) goto out; dev->index = err; dev_set_name(&dev->dev, "virtio%u", dev->index); /* We always start by resetting the device, in case a previous * driver messed it up. This also tests that code path a little. */ dev->config->reset(dev); /* Acknowledge that we've seen the device. */ add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE); INIT_LIST_HEAD(&dev->vqs); /* device_register() causes the bus infrastructure to look for a * matching driver. */ err = device_register(&dev->dev); out: if (err) add_status(dev, VIRTIO_CONFIG_S_FAILED); return err; } EXPORT_SYMBOL_GPL(register_virtio_device); void unregister_virtio_device(struct virtio_device *dev) { int index = dev->index; /* save for after device release */ device_unregister(&dev->dev); ida_simple_remove(&virtio_index_ida, index); } EXPORT_SYMBOL_GPL(unregister_virtio_device); static int virtio_init(void) { if (bus_register(&virtio_bus) != 0) panic("virtio bus registration failed"); return 0; } static void __exit virtio_exit(void) { bus_unregister(&virtio_bus); ida_destroy(&virtio_index_ida); } core_initcall(virtio_init); module_exit(virtio_exit); MODULE_LICENSE("GPL");
2f7cb558faa2d1844dbce51e69156f0554bf71c1
c6759b857e55991fea3ef0b465dbcee53fa38714
/rtos/pmsis/bsp/ble/nina_b312/nina_b312.c
ac543659d3ec195703afc855bc0034ecfc9f5ad1
[ "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
28,259
c
nina_b312.c
/* * Copyright (C) 2019 GreenWaves Technologies * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "bsp/bsp.h" #include "bsp/ble/nina_b312.h" #include "nina_b312_defines.h" #include <string.h> /******************************************************************************* * Definitions ******************************************************************************/ #ifdef DEBUG #define DEBUG_PRINTF printf #else #define DEBUG_PRINTF(...) ((void) 0) #endif /* DEBUG */ /* Factory default S3(CR) & S4(LF) response format character. */ #define S3char '\r' /*!< CR char, ASCII 0x0D. */ #define S4char '\n' /*!< LF char, ASCII 0x0A. */ /* Same, but to use in string functions (strcat, strcmp, etc...). */ #define S3str "\r" /*!< CR string. */ #define S4str "\n" /*!< LF string. */ #define PI_NINA_B312_UART_BAUDRATE ( 115200 ) /*!< Baudrate used by NINA_B312 module(default value). */ #define PI_NINA_B312_DATA_BITS ( 8 ) /*!< Data bits used by NINA_B312 module(default value). */ typedef struct { struct pi_device uart_device; /*!< UART interface used to communicate with BLE module. */ char *byte; /*!< Byte used to receive response. */ char *buffer; /*!< Buffer used to receive response. */ } nina_b312_t; typedef enum { PI_AT_RESP_NOT_STARTED, /*!< Response not received yet from BLE module. */ PI_AT_RESP_IN_PROGRESS, /*!< Response transmission has started. */ PI_AT_RESP_DONE /*!< Response transmission received, with end of resp. */ } at_resp_state_e; typedef enum { CMD_RES_OK = 0, /*!< OK reponse. */ CMD_RES_ERR = -1, /*!< ERROR response. */ CMD_RES_UNSOL = -2, /*!< UNSOLICITED_RESPONSE response. */ CMD_RES_NA = -3 /*!< Non authorized response. */ } cmd_res_e; /** * \struct cb_args */ typedef struct { uint8_t has_error_code; nina_b312_t *nina; struct pi_task *task; } cb_args_t; /******************************************************************************* * Driver data ******************************************************************************/ static cb_args_t g_param = {0}; static volatile at_resp_state_e g_at_resp_state; static pi_device_api_t g_nina_b312_api = {0}; static pi_ble_api_t g_nina_b312_ble_api = {0}; /******************************************************************************* * Function declaration ******************************************************************************/ static int __pi_nina_b312_open(struct pi_device *device); static int __pi_nina_b312_close(struct pi_device *device); static int __pi_nina_hd_reset(); static ssize_t __pi_nina_b312_data_get(struct pi_device *device, uint32_t ext_addr, void *buffer, uint32_t size, pi_task_t *task); static ssize_t __pi_nina_b312_data_send(struct pi_device *device, uint32_t ext_addr, const void *buffer, uint32_t size, pi_task_t *task); static int __pi_nina_b312_ioctl(struct pi_device *device, uint32_t cmd, void *arg); static int32_t __pi_nina_b312_at_cmd(struct pi_device *device, const char *cmd, char *resp, uint32_t size); static int32_t __pi_nina_b312_peer_connect(struct pi_device *device, const char *addr); static int32_t __pi_nina_b312_peer_disconnect(struct pi_device *device, const char *addr); /******************************************************************************* * Board specific functions ******************************************************************************/ // These functions can be overloaded by the board-specific bsp part // in order to overload default behavior void __attribute__((weak)) bsp_nina_b312_conf_init(struct pi_nina_b312_conf *conf) { conf->uart_itf = (uint8_t) CONFIG_NINA_B312_UART_ID; } int __attribute__((weak)) bsp_nina_b312_open() { return 0; } /******************************************************************************* * Internal functions ******************************************************************************/ static void __pi_nina_b312_at_cmd_send(nina_b312_t *nina, const char *cmd) { uint32_t cmd_length = strlen(cmd); uint32_t length = cmd_length + 2 + 1; /* cmd length + "AT" + '\r'. */ char *cmd_string = (char *) pi_l2_malloc(sizeof(char) * length); if (cmd_string == NULL) { return; } strcpy((char*) cmd_string, (char*) "AT"); if (cmd_length != 0) { strcat((char*) cmd_string, (char*) cmd); } strcat((char*) cmd_string, (char*) S3str); DEBUG_PRINTF("Sending: %s\n", cmd_string); int success = pi_uart_write(&(nina->uart_device), cmd_string, strlen(cmd_string)); pi_l2_free(cmd_string, sizeof(char) * length); } static void __pi_nina_b312_startup_received(void *arg) { /* Beware with printf. If no control flow you should not put some, uart is too fast for printf. With control flow, you can. */ cb_args_t *param = (cb_args_t *) arg; static uint32_t index = 0; static unsigned char prev_byte = 0; uint8_t end = 0; if ((g_at_resp_state == PI_AT_RESP_IN_PROGRESS) && (prev_byte == S3char) && (*(g_param.nina->byte) == S4char)) { /* Check if +STARTUP (default factory message after wake up) */ if ((0 == g_param.has_error_code) || ((g_param.nina->buffer[index - 9] == '+') && (g_param.nina->buffer[index - 8] == 'S') && (g_param.nina->buffer[index - 7] == 'T') && (g_param.nina->buffer[index - 6] == 'A') && (g_param.nina->buffer[index - 5] == 'R') && (g_param.nina->buffer[index - 4] == 'T') && (g_param.nina->buffer[index - 3] == 'U') && (g_param.nina->buffer[index - 2] == 'P') ) ) { g_param.nina->buffer[--index] = '\0'; g_at_resp_state = PI_AT_RESP_DONE; end = 1; } else { printf("Got unsollicited response : %s\n", g_param.nina->buffer); } } if (0 == end) { if ((g_at_resp_state == PI_AT_RESP_NOT_STARTED) && (prev_byte == S3char) && (*(g_param.nina->byte) == S4char)) { index = 0; g_at_resp_state = PI_AT_RESP_IN_PROGRESS; } else if (g_at_resp_state == PI_AT_RESP_IN_PROGRESS) { g_param.nina->buffer[index++] = *(g_param.nina->byte); } } prev_byte = *(g_param.nina->byte); if (0 == end) { pi_task_callback(g_param.task, __pi_nina_b312_startup_received, &g_param); pi_uart_read_async(&(g_param.nina->uart_device), (void *) g_param.nina->byte, sizeof(uint8_t), g_param.task); } } static void __pi_nina_b312_data_received(void *arg) { /* Beware with printf. If no flow control you should not put some, uart is too fast for printf. With flow control, you can. */ cb_args_t *param = (cb_args_t *) arg; static uint32_t index = 0; static unsigned char prev_byte = 0; uint8_t end = 0; // if (*(g_param.nina->byte) == '\r') printf("current = '\\r'\n"); // else if (*(g_param.nina->byte) == '\n') printf("current = '\\n'\n"); // else if (*(g_param.nina->byte) == '\0') printf("current = '\\0'\n"); // else printf("current: %c\n", *(g_param.nina->byte)); if ((g_at_resp_state == PI_AT_RESP_IN_PROGRESS) && (prev_byte == S3char) && (*(g_param.nina->byte) == S4char)) { /* Check if ERROR or OK */ if ((0 == g_param.has_error_code) || (((g_param.nina->buffer[index - 3] == 'O') && (g_param.nina->buffer[index - 2] == 'K') ) || ((g_param.nina->buffer[index - 6] == 'E') && (g_param.nina->buffer[index - 5] == 'R') && (g_param.nina->buffer[index - 4] == 'R') && (g_param.nina->buffer[index - 3] == 'O') && (g_param.nina->buffer[index - 2] == 'R')) ) ) { g_param.nina->buffer[--index] = '\0'; g_at_resp_state = PI_AT_RESP_DONE; end = 1; } else { /* Got this case when the response has some text Schema is then as following: <S3><S4><text><S3><S4><S3><S4><code><S3><S4> We need therefore to parse again to get the code (OK|ERROR) */ DEBUG_PRINTF("Got something else than OK or ERROR -> Continue\n"); --index; } } if (0 == end) { if ((g_at_resp_state == PI_AT_RESP_NOT_STARTED) && (prev_byte == S3char) && (*(g_param.nina->byte) == S4char)) { index = 0; g_at_resp_state = PI_AT_RESP_IN_PROGRESS; } else if (g_at_resp_state == PI_AT_RESP_IN_PROGRESS) { g_param.nina->buffer[index++] = *(g_param.nina->byte); } } prev_byte = *(g_param.nina->byte); if (0 == end) { pi_task_callback(g_param.task, __pi_nina_b312_data_received, &g_param); pi_uart_read_async(&(g_param.nina->uart_device), (void *) g_param.nina->byte, sizeof(uint8_t), g_param.task); } } static int32_t __pi_nina_b312_read_startup(struct pi_device *device) { nina_b312_t *nina = (nina_b312_t *) device->data; g_at_resp_state = PI_AT_RESP_NOT_STARTED; pi_task_t rx_cb = {0}; g_param.has_error_code = 1; g_param.nina = nina; g_param.task = &rx_cb; pi_task_callback(&rx_cb, __pi_nina_b312_startup_received, &g_param); pi_uart_read_async(&(nina->uart_device), (void *) nina->byte, sizeof(uint8_t), &rx_cb); while (g_at_resp_state != PI_AT_RESP_DONE) { pi_yield(); } DEBUG_PRINTF("Got response: %s\n", nina->buffer); return CMD_RES_OK; } static int32_t __pi_nina_b312_wait_for_event(nina_b312_t *nina, char *resp) { g_at_resp_state = PI_AT_RESP_NOT_STARTED; pi_task_t rx_cb = {0}; g_param.has_error_code = 0; g_param.nina = nina; g_param.task = &rx_cb; pi_task_callback(&rx_cb, __pi_nina_b312_data_received, &g_param); pi_uart_read_async(&(nina->uart_device), (void *) nina->byte, sizeof(uint8_t), &rx_cb); while (g_at_resp_state != PI_AT_RESP_DONE) { pi_yield(); } DEBUG_PRINTF("Got unsolicited response: %s\n", nina->buffer); uint32_t resp_len = strlen((const char *) nina->buffer); strcpy((void *) resp, (void *) nina->buffer); return resp_len; } static int32_t __pi_nina_b312_data_mode_exit(nina_b312_t *nina) { #ifndef __PLATFORM_RTL__ pi_time_wait_us(1000 * 1000); #endif pi_uart_write(&(nina->uart_device), (void *) '+', 1); pi_uart_write(&(nina->uart_device), (void *) '+', 1); pi_uart_write(&(nina->uart_device), (void *) '+', 1); #ifndef __PLATFORM_RTL__ pi_time_wait_us(1000 * 1000); #endif return 0; } static int32_t __pi_nina_b312_data_mode_enter(struct pi_device *device) { char str[20]; strcpy(str, __XSTRING(PI_AT_NINA_B312_O_DATA_MODE)); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_device_unbond(struct pi_device *device, const char *addr) { char str[60]; strcpy(str, __XSTRING(PI_AT_NINA_B312_DEVICE_UNBOND_SET)); strcat(str, addr); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_device_role(struct pi_device *device, const char *role) { char str[20]; strcpy(str, __XSTRING(PI_AT_NINA_B312_DEVICE_ROLE_SET)); strcat(str, role); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_device_name(struct pi_device *device, const char *name) { char str[128]; strcpy(str, __XSTRING(PI_AT_NINA_B312_DEVICE_NAME_SET)); strcat(str, name); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_configuration_save(struct pi_device *device) { char str[10]; strcpy(str, __XSTRING(PI_AT_NINA_B312_CFG_SAVE)); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_device_reboot(struct pi_device *device) { char str[10]; strcpy(str, __XSTRING(PI_AT_NINA_B312_DEVICE_REBOOT)); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_uart_settings_set(struct pi_device *device, struct pi_nina_b312_conf *conf) { char num[30], str[40]; uint8_t ctrl_flow_ena = (conf->use_ctrl_flow != 1) ? 2 : 1; /* 2=disable : 1=enable */ sprintf(num, "%ld,%d,%d,%d,%d,%d", conf->baudrate, /* Default baudrate is 115200. */ ctrl_flow_ena, /* Control flow */ (uint8_t) PI_NINA_B312_DATA_BITS, /* Programmed to 8 data bits. */ conf->stop_bits, /* Stop bits. */ conf->parity_bits, /* Parity bits: 1=no parity, 2=Odd, 3=Even. */ 1 /* 0=Change after reboot, 1=Immediate change(after OK, wait 40 ms). */ ); strcpy(str, __XSTRING(PI_AT_NINA_B312_UART_SETTINGS_SET)); strcat(str, num); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static void __pi_nina_b312_server_configure(struct pi_device *device) { struct pi_nina_b312_conf *conf = (struct pi_nina_b312_conf *) device->config; nina_b312_t *nina = (nina_b312_t *) device->data; char str[10]; /* Turn off echo. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_ECHO_OFF)); __pi_nina_b312_at_cmd(device, str, NULL, 0); /* Factory reset. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_FACTORY_RESET)); __pi_nina_b312_at_cmd(device, str, NULL, 0); /* Unbound devices. */ __pi_nina_b312_device_unbond(device, "FFFFFFFFFFFF"); /* Config device role. */ __pi_nina_b312_device_role(device, __XSTRING(PI_AT_NINA_B312_SERVER_ROLE)); /* Config device name. */ __pi_nina_b312_device_name(device, conf->local_name); /* UART settings. */ __pi_nina_b312_uart_settings_set(device, conf); } static void __pi_nina_b312_client_configure(struct pi_device *device) { struct pi_nina_b312_conf *conf = (struct pi_nina_b312_conf *) device->config; nina_b312_t *nina = (nina_b312_t *) device->data; char str[10]; /* Turn off echo. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_ECHO_OFF)); __pi_nina_b312_at_cmd(device, str, NULL, 0); /* Factory reset. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_FACTORY_RESET)); __pi_nina_b312_at_cmd(device, str, NULL, 0); /* Unbound devices. */ __pi_nina_b312_device_unbond(device, "FFFFFFFFFFFF"); /* Config device role. */ __pi_nina_b312_device_role(device, __XSTRING(PI_AT_NINA_B312_CLIENT_ROLE)); /* Config device name. */ __pi_nina_b312_device_name(device, conf->local_name); // /* Bluetooth mode */ // __pi_nina_b312_at_cmd(device, "+UBTMODE=2", NULL, 0); // 2=BLE /* UART settings. */ __pi_nina_b312_uart_settings_set(device, conf); } static void __pi_nina_b312_device_id_get(struct pi_device *device, struct pi_nina_b312_id *info) { struct pi_nina_b312_conf *conf = (struct pi_nina_b312_conf *) device->config; nina_b312_t *nina = (nina_b312_t *) device->data; char str[10]; /* Manufacturer ID. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_MANUFACTURER_ID)); __pi_nina_b312_at_cmd(device, str, info->manufacturer_id, sizeof(info->manufacturer_id)); /* Model ID. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_MODEL_ID)); __pi_nina_b312_at_cmd(device, str, info->model_id, sizeof(info->model_id)); /* Software version ID. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_SW_VERSION_ID)); __pi_nina_b312_at_cmd(device, str, info->sw_ver_id, sizeof(info->sw_ver_id)); /* Serial number ID. */ strcpy(str, __XSTRING(PI_AT_NINA_B312_SERIAL_NUMBER)); __pi_nina_b312_at_cmd(device, str, info->serial_num, sizeof(info->serial_num)); } static int enable_fc_pads(void) { pi_device_t gpio_rts; pi_device_t gpio_cts; struct pi_gpio_conf gpio_rts_conf; struct pi_gpio_conf gpio_cts_conf; pi_gpio_conf_init(&gpio_rts_conf); pi_gpio_conf_init(&gpio_cts_conf); gpio_rts_conf.port = GPIO_UART1_RTS / 32; gpio_cts_conf.port = GPIO_UART1_CTS / 32; pi_open_from_conf(&gpio_rts, &gpio_rts_conf); pi_open_from_conf(&gpio_cts, &gpio_cts_conf); if (pi_gpio_open(&gpio_rts)) return -1; if (pi_gpio_open(&gpio_cts)) return -1; pi_pad_set_function(GPIO_UART1_RTS, PI_PAD_FUNC0); pi_pad_set_function(GPIO_UART1_CTS, PI_PAD_FUNC0); pi_pad_set_mux_group(GPIO_UART1_RTS, PI_PAD_MUX_GROUP_UART1_RTS); pi_pad_set_mux_group(GPIO_UART1_CTS, PI_PAD_MUX_GROUP_UART1_CTS); /* configure gpio output */ pi_gpio_flags_e output_flags = PI_GPIO_OUTPUT; pi_gpio_flags_e input_flags = PI_GPIO_INPUT; pi_gpio_pin_configure(&gpio_rts, GPIO_UART1_RTS, output_flags); pi_gpio_pin_configure(&gpio_cts, GPIO_UART1_CTS, input_flags); return 0; } /******************************************************************************* * API implementation ******************************************************************************/ static int __pi_nina_b312_open(struct pi_device *device) { pi_device_t gpio_nina_pwron; struct pi_gpio_conf gpio_conf_nina_pwron; pi_gpio_conf_init(&gpio_conf_nina_pwron); gpio_conf_nina_pwron.port = GPIO_NINA_PWRON / 32; pi_open_from_conf(&gpio_nina_pwron, &gpio_conf_nina_pwron); if (pi_gpio_open(&gpio_nina_pwron)) { return -1; } DEBUG_PRINTF("Open bsp nina b312\n"); bsp_nina_b312_open(); /* Config device GPIO & pads. */ pi_gpio_pin_configure(&gpio_nina_pwron, GPIO_NINA_PWRON, PI_GPIO_OUTPUT); pi_gpio_pin_write(&gpio_nina_pwron, GPIO_NINA_PWRON, 0); pi_time_wait_us(20000); struct pi_nina_b312_conf *conf = (struct pi_nina_b312_conf *) device->config; /* Nina_b312 device. */ nina_b312_t *nina = (nina_b312_t *) pi_l2_malloc(sizeof(nina_b312_t)); if (nina == NULL) { return -1; } nina->byte = (char *) pi_l2_malloc(sizeof(char) * 1); if (nina->byte == NULL) { pi_l2_free(nina, sizeof(nina_b312_t)); return -2; } nina->buffer = (char *) pi_l2_malloc(sizeof(char) * (uint32_t) PI_AT_RESP_ARRAY_LENGTH); if (nina->byte == NULL) { pi_l2_free(nina->byte, sizeof(sizeof(char) * 1)); pi_l2_free(nina, sizeof(nina_b312_t)); return -3; } device->data = (void *) nina; /* Init and open UART device. */ struct pi_uart_conf uart_conf = {0}; pi_uart_conf_init(&uart_conf); uart_conf.uart_id = conf->uart_itf; uart_conf.baudrate_bps = PI_NINA_B312_UART_BAUDRATE; uart_conf.enable_rx = 1; uart_conf.enable_tx = 1; uart_conf.use_ctrl_flow = conf->use_ctrl_flow; pi_open_from_conf(&(nina->uart_device), &uart_conf); if (pi_uart_open(&(nina->uart_device))) { pi_l2_free(nina->buffer, sizeof(sizeof(char) * (uint32_t) PI_AT_RESP_ARRAY_LENGTH)); pi_l2_free(nina->byte, sizeof(sizeof(char) * 1)); pi_l2_free(nina, sizeof(nina_b312_t)); return -4; } DEBUG_PRINTF("Enable nina b312\n"); /* Enable Nina_B312. */ pi_gpio_pin_write(&gpio_nina_pwron, GPIO_NINA_PWRON, 1); pi_time_wait_us(20000); /* Set pads for flow control */ enable_fc_pads(); /* Hardware reset of the module Ensure that +STARTUP will be send */ __pi_nina_hd_reset(); DEBUG_PRINTF("Read startup\n"); __pi_nina_b312_read_startup(device); /* Do not need to wait for stability We wait for +STARTUP message */ // #ifndef __PLATFORM_RTL__ // pi_time_wait_us(1 * 1000 * 1000); // #endif /* Test if NINA_B312 is active. */ cmd_res_e nina_active = __pi_nina_b312_at_cmd(device, "", NULL, 0); if (nina_active == CMD_RES_ERR) { return -5; } return 0; } static int __pi_nina_b312_close(struct pi_device *device) { nina_b312_t *nina = (nina_b312_t *) device->data; pi_uart_close(&(nina->uart_device)); pi_l2_free(nina->buffer, sizeof(sizeof(char) * (uint32_t) PI_AT_RESP_ARRAY_LENGTH)); pi_l2_free(nina->byte, sizeof(sizeof(char) * 1)); pi_l2_free(nina, sizeof(nina_b312_t)); return 0; } static int __pi_nina_hd_reset() { pi_device_t gpio_rst; struct pi_gpio_conf gpio_rst_conf; pi_gpio_conf_init(&gpio_rst_conf); gpio_rst_conf.port = GPIO_NINA_RST / 32; pi_open_from_conf(&gpio_rst, &gpio_rst_conf); if (pi_gpio_open(&gpio_rst)) { return -1; } /* set pad to gpio mode */ pi_pad_set_function(GPIO_NINA_RST, PI_PAD_FUNC1); /* configure gpio output */ pi_gpio_flags_e flags = PI_GPIO_OUTPUT; pi_gpio_pin_configure(&gpio_rst, GPIO_NINA_RST, flags); pi_gpio_pin_write(&gpio_rst, GPIO_NINA_RST, 0); pi_time_wait_us(20000); pi_gpio_pin_write(&gpio_rst, GPIO_NINA_RST, 1); pi_time_wait_us(20000); return 0; } static ssize_t __pi_nina_b312_data_get(struct pi_device *device, uint32_t ext_addr, void *buffer, uint32_t size, pi_task_t *task) { nina_b312_t *nina = (nina_b312_t *) device->data; pi_uart_read_async(&(nina->uart_device), buffer, size, task); return 0; } static ssize_t __pi_nina_b312_data_send(struct pi_device *device, uint32_t ext_addr, const void *buffer, uint32_t size, pi_task_t *task) { nina_b312_t *nina = (nina_b312_t *) device->data; pi_uart_write_async(&(nina->uart_device), (void *) buffer, size, task); return 0; } static int __pi_nina_b312_ioctl(struct pi_device *device, uint32_t cmd, void *arg) { nina_b312_t *nina = (nina_b312_t *) device->data; pi_ble_ioctl_cmd_e func_id = (pi_ble_ioctl_cmd_e) cmd; switch (func_id) { case PI_NINA_B312_MODEL_INFO : { struct pi_nina_b312_id *info = (struct pi_nina_b312_id *) arg; __pi_nina_b312_device_id_get(device, info); } break; case PI_NINA_B312_SERVER_CONFIGURE : { __pi_nina_b312_server_configure(device); } break; case PI_NINA_B312_CLIENT_CONFIGURE : { __pi_nina_b312_client_configure(device); } break; case PI_NINA_B312_UART_CONFIGURE : { struct pi_nina_b312_conf *conf = (struct pi_nina_b312_conf *) arg; cmd_res_e res = __pi_nina_b312_uart_settings_set(device, conf); if (CMD_RES_OK == res) { struct pi_uart_conf uart_conf = {0}; pi_uart_conf_init(&uart_conf); uart_conf.uart_id = conf->uart_itf; uart_conf.baudrate_bps = PI_NINA_B312_UART_BAUDRATE; uart_conf.enable_rx = 1; uart_conf.enable_tx = 1; uart_conf.use_ctrl_flow = conf->use_ctrl_flow; /* modify baudrate, parity & stop */ uart_conf.baudrate_bps = conf->baudrate; uart_conf.parity_mode = (conf->parity_bits != 1) ? 1 : 0; uart_conf.stop_bit_count = conf->stop_bits; pi_uart_ioctl(&(nina->uart_device), PI_UART_IOCTL_ABORT_RX, NULL); pi_uart_ioctl(&(nina->uart_device), PI_UART_IOCTL_ABORT_TX, NULL); pi_uart_ioctl(&(nina->uart_device), PI_UART_IOCTL_CONF_SETUP, &uart_conf); } #ifndef __PLATFORM_RTL__ /* wait 40ms for module to update */ pi_time_wait_us(40000); #endif } break; case PI_NINA_B312_DATA_MODE_ENTER : { return __pi_nina_b312_data_mode_enter(device); } break; case PI_NINA_B312_DATA_MODE_EXIT : { __pi_nina_b312_data_mode_exit(nina); } break; case PI_NINA_B312_WAIT_FOR_EVENT : { char *buffer = (char *) arg; return __pi_nina_b312_wait_for_event(nina, buffer); } break; default : printf("Error: unknown ioctl command !\n"); return -1; } return 0; } static int32_t __pi_nina_b312_at_cmd(struct pi_device *device, const char *cmd, char *resp, uint32_t size) { nina_b312_t *nina = (nina_b312_t *) device->data; g_at_resp_state = PI_AT_RESP_NOT_STARTED; pi_task_t rx_cb = {0}; g_param.has_error_code = 1; g_param.nina = nina; g_param.task = &rx_cb; pi_task_callback(&rx_cb, __pi_nina_b312_data_received, &g_param); pi_uart_read_async(&(nina->uart_device), (void *) nina->byte, sizeof(uint8_t), &rx_cb); __pi_nina_b312_at_cmd_send(nina, cmd); while (g_at_resp_state != PI_AT_RESP_DONE) { pi_yield(); } DEBUG_PRINTF("Got response: %s\n", nina->buffer); cmd_res_e cmd_res = CMD_RES_NA; uint32_t last_char_pos = strlen((const char *) nina->buffer); if ((nina->buffer[last_char_pos - 2] == 'O') && (nina->buffer[last_char_pos - 1] == 'K')) { DEBUG_PRINTF("OK response received !\n"); cmd_res = CMD_RES_OK; } else if((nina->buffer[last_char_pos - 5] == 'E') && (nina->buffer[last_char_pos - 4] == 'R') && (nina->buffer[last_char_pos - 3] == 'R') && (nina->buffer[last_char_pos - 2] == 'O') && (nina->buffer[last_char_pos - 1] == 'R')) { DEBUG_PRINTF("ERROR response received !\n"); cmd_res = CMD_RES_ERR; } else { DEBUG_PRINTF("Unsolicited/unrecognised response received: \"%s\" (len: %ld) !\n", nina->buffer, last_char_pos); cmd_res = CMD_RES_UNSOL; } if (size) { strcpy((void *) resp, (void *) nina->buffer); } return cmd_res; } static int32_t __pi_nina_b312_peer_connect(struct pi_device *device, const char *addr) { nina_b312_t *nina = (nina_b312_t *) device->data; char str[60]; strcpy(str, __XSTRING(PI_AT_NINA_B312_PEER_CONNECT)); strcat(str, addr); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } static int32_t __pi_nina_b312_peer_disconnect(struct pi_device *device, const char *addr) { nina_b312_t *nina = (nina_b312_t *) device->data; char str[60]; strcpy(str, __XSTRING(PI_AT_NINA_B312_PEER_DISCONNECT)); strcat(str, addr); return __pi_nina_b312_at_cmd(device, str, NULL, 0); } void pi_ble_nina_b312_conf_init(struct pi_device *device, struct pi_nina_b312_conf *conf) { bsp_nina_b312_conf_init(conf); /* Bind NINA_B312 API to BLE API. */ g_nina_b312_api.open = &__pi_nina_b312_open; g_nina_b312_api.close = &__pi_nina_b312_close; g_nina_b312_api.read = &__pi_nina_b312_data_get; g_nina_b312_api.write = &__pi_nina_b312_data_send; g_nina_b312_api.ioctl = &__pi_nina_b312_ioctl; /* BLE specific API. */ g_nina_b312_ble_api.at_cmd = &__pi_nina_b312_at_cmd; g_nina_b312_ble_api.peer_connect = &__pi_nina_b312_peer_connect; g_nina_b312_ble_api.peer_disconnect = &__pi_nina_b312_peer_disconnect; g_nina_b312_api.specific_api = (void *) &g_nina_b312_ble_api; char *str = "GreenWaves-GAP9_EVK"; strcpy(conf->local_name, str); conf->baudrate = (uint32_t) PI_NINA_B312_UART_BAUDRATE; /* Default baudrate. */ conf->parity_bits = 1; /* No parity. */ conf->stop_bits = 1; /* 1 stop bit. */ conf->use_ctrl_flow = 0; /* No control flow */ device->api = &g_nina_b312_api; }
9649dd726099aa82082f5781998b9133eaa8556f
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/examples/6tisch/6p-packet/test-sf.c
aad11571a64e963b4e550cf5c9529b49b44d39f4
[ "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
33,434
c
test-sf.c
/* * Copyright (c) 2017, Yasuyuki Tanaka * 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. */ #include <contiki.h> #include <lib/assert.h> #include <net/mac/tsch/tsch.h> #include <net/mac/tsch/sixtop/sixtop.h> #include <net/mac/tsch/sixtop/sixp.h> #include <net/mac/tsch/sixtop/sixp-nbr.h> #include <net/mac/tsch/sixtop/sixp-trans.h> #define DEBUG DEBUG_PRINT #include <net/net-debug.h> #define SIXP_PKT_BUFLEN 128 static uint8_t sixp_pkt_buf[SIXP_PKT_BUFLEN]; #define TEST_SF_SFID 0x80 #define TEST_SF_TIMEOUT CLOCK_SECOND PROCESS(test_sf_process, "test-sf initiator process"); static linkaddr_t peer_addr; static process_event_t test_sf_trans_done; static enum { TEST_SF_MODE_INITIATOR, TEST_SF_MODE_RESPONDER } test_sf_mode; static int test_index = 0; static const sixp_pkt_metadata_t sample_metadata = 0xcafe; static const uint32_t sample_cell_list1[] = { 0xdeadbeef, 0xcafebabe, 0xbaadf00d }; static const uint32_t sample_cell_list2[] = { 0xbaadcafe, 0xfacefeed, 0xbadcab1e }; static void test_add_2_step(const linkaddr_t *peer_addr); static void test_add_3_step(const linkaddr_t *peer_addr); static void test_delete_2_step(const linkaddr_t *peer_addr); static void test_delete_3_step(const linkaddr_t *peer_addr); static void test_relocate_2_step(const linkaddr_t *peer_addr); static void test_count_2_step(const linkaddr_t *peer_addr); static void test_list_2_step(const linkaddr_t *peer_addr); static void test_list_2_step_eol(const linkaddr_t *peer_addr); static void test_signal_2_step(const linkaddr_t *peer_addr); static void test_clear_2_step_success(const linkaddr_t *peer_addr); static void test_clear_2_step_eol(const linkaddr_t *peer_addr); static void test_clear_2_step_err(const linkaddr_t *peer_addr); static void test_clear_2_step_reset(const linkaddr_t *peer_addr); static void test_clear_2_step_version(const linkaddr_t *peer_addr); static void test_clear_2_step_sfid(const linkaddr_t *peer_addr); static void test_clear_2_step_seqnum(const linkaddr_t *peer_addr); static void test_clear_2_step_celllist(const linkaddr_t *peer_addr); static void test_clear_2_step_busy(const linkaddr_t *peer_addr); static void test_clear_2_step_locked(const linkaddr_t *peer_addr); typedef void (*test_func)(const linkaddr_t *peer_addr); static const test_func test_case[] = { test_add_2_step, test_add_3_step, test_delete_2_step, test_delete_3_step, test_relocate_2_step, test_count_2_step, test_list_2_step, test_list_2_step_eol, test_signal_2_step, test_clear_2_step_success, test_clear_2_step_eol, test_clear_2_step_err, test_clear_2_step_reset, test_clear_2_step_version, test_clear_2_step_sfid, test_clear_2_step_seqnum, test_clear_2_step_celllist, test_clear_2_step_busy, test_clear_2_step_locked, }; static void set_peer_addr(const linkaddr_t *addr) { peer_addr = *addr; PRINTF("test-sf: set peer addr: "); PRINTLLADDR((const uip_lladdr_t *)&peer_addr); PRINTF("\n"); } int test_sf_start(const linkaddr_t *addr) { if(addr == NULL) { test_sf_mode = TEST_SF_MODE_RESPONDER; } else { test_sf_mode = TEST_SF_MODE_INITIATOR; set_peer_addr(addr); test_sf_trans_done = process_alloc_event(); process_start(&test_sf_process, NULL); } return 0; } static void init(void) { } static void input(sixp_pkt_type_t type, sixp_pkt_code_t code, const uint8_t *body, uint16_t body_len, const linkaddr_t *src_addr) { if(test_index < (sizeof(test_case) / sizeof(test_func))) { test_case[test_index](src_addr); } } static void timeout(sixp_pkt_cmd_t cmd, const linkaddr_t *peer_addr) { } static void test_add_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, 1, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_num_cells_t) + sizeof(sixp_pkt_metadata_t) + sizeof(sample_cell_list1), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(uint32_t), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_add_3_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, 1, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_ADD, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_num_cells_t) + sizeof(sixp_pkt_metadata_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1), peer_addr, NULL, NULL, 0); } else if (state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_CONFIRMATION, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(uint32_t), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_CONFIRMATION, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t), peer_addr, NULL, NULL, 0); process_post(&test_sf_process, test_sf_trans_done, NULL); } else if (state == SIXP_TRANS_STATE_CONFIRMATION_RECEIVED){ test_index++; } } } static void test_delete_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, 1, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_num_cells_t) + sizeof(sixp_pkt_metadata_t) + sizeof(sample_cell_list1), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(uint32_t), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_delete_3_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert(sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, 1, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_DELETE, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_num_cells_t) + sizeof(sixp_pkt_metadata_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1), peer_addr, NULL, NULL, 0); } else if (state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_CONFIRMATION, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(uint32_t), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_CONFIRMATION, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t), peer_addr, NULL, NULL, 0); process_post(&test_sf_process, test_sf_trans_done, NULL); } else if (state == SIXP_TRANS_STATE_CONFIRMATION_RECEIVED) { test_index++; } } } static void test_relocate_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, 3, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_rel_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cand_cell_list(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, (const uint8_t *)sample_cell_list2, sizeof(sample_cell_list2), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_RELOCATE, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_num_cells_t) + sizeof(sample_cell_list1) + sizeof(sample_cell_list2), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list2, sizeof(uint32_t), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(uint32_t), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_count_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_RX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_COUNT, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_total_num_cells(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, 0xf0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_total_num_cells_t), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_list_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_RX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, 0x0f, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, 0xf0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_reserved_t) + sizeof(sixp_pkt_offset_t) + sizeof(sixp_pkt_max_num_cells_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)sample_cell_list2, sizeof(sample_cell_list2), sizeof(sample_cell_list1), sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1) + sizeof(sample_cell_list2), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_list_2_step_eol(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_options(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, SIXP_PKT_CELL_OPTION_TX | SIXP_PKT_CELL_OPTION_RX | SIXP_PKT_CELL_OPTION_SHARED, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_offset(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, 0x0f, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_max_num_cells(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, 0xf0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t) + sizeof(sixp_pkt_cell_options_t) + sizeof(sixp_pkt_reserved_t) + sizeof(sixp_pkt_offset_t) + sizeof(sixp_pkt_max_num_cells_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL, (const uint8_t *)sample_cell_list1, sizeof(sample_cell_list1), 0, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert( sixp_pkt_set_cell_list(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL, (const uint8_t *)sample_cell_list2, sizeof(sample_cell_list2), sizeof(sample_cell_list1), sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_EOL, TEST_SF_SFID, sixp_pkt_buf, sizeof(sample_cell_list1) + sizeof(sample_cell_list2), peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_signal_2_step(const linkaddr_t *peer_addr) { sixp_trans_t *trans = sixp_trans_find(peer_addr); uint8_t payload[10]; size_t payload_len; if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_LIST, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); payload[0] = 0xbe; payload[1] = 0xef; payload[2] = 0xca; payload[3] = 0xfe; payload_len = 4; assert( sixp_pkt_set_payload(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_SIGNAL, (const uint8_t *)payload, payload_len, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_SIGNAL, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t) + payload_len, peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; printf("hoge\n"); state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { payload[0] = 0x01; payload[1] = 0x02; payload[2] = 0x03; payload[3] = 0x04; payload[4] = 0x05; payload_len = 5; assert( sixp_pkt_set_payload(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, (const uint8_t *)payload, payload_len, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SUCCESS, TEST_SF_SFID, sixp_pkt_buf, payload_len, peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_clear_2_step(const linkaddr_t *peer_addr, sixp_pkt_rc_t rc) { sixp_trans_t *trans = sixp_trans_find(peer_addr); if(trans == NULL) { memset(sixp_pkt_buf, 0, sizeof(sixp_pkt_buf)); assert( sixp_pkt_set_metadata(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, sample_metadata, sixp_pkt_buf, sizeof(sixp_pkt_buf)) == 0); assert(sixp_output(SIXP_PKT_TYPE_REQUEST, (sixp_pkt_code_t)(uint8_t)SIXP_PKT_CMD_CLEAR, TEST_SF_SFID, sixp_pkt_buf, sizeof(sixp_pkt_metadata_t), peer_addr, NULL, NULL, 0) == 0); } else { sixp_trans_state_t state; state = sixp_trans_get_state(trans); if(state == SIXP_TRANS_STATE_REQUEST_RECEIVED) { sixp_output(SIXP_PKT_TYPE_RESPONSE, (sixp_pkt_code_t)rc, TEST_SF_SFID, NULL, 0, peer_addr, NULL, NULL, 0); test_index++; } else if(state == SIXP_TRANS_STATE_RESPONSE_RECEIVED) { process_post(&test_sf_process, test_sf_trans_done, NULL); } } } static void test_clear_2_step_success(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_SUCCESS); } static void test_clear_2_step_err(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR); } static void test_clear_2_step_eol(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_EOL); } static void test_clear_2_step_reset(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_RESET); } static void test_clear_2_step_version(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_VERSION); } static void test_clear_2_step_sfid(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_SFID); } static void test_clear_2_step_seqnum(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_SEQNUM); } static void test_clear_2_step_busy(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_BUSY); } static void test_clear_2_step_locked(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_LOCKED); } static void test_clear_2_step_celllist(const linkaddr_t *peer_addr) { test_clear_2_step(peer_addr, SIXP_PKT_RC_ERR_CELLLIST); } PROCESS_THREAD(test_sf_process, ev, data) { static struct etimer et; PROCESS_BEGIN(); etimer_set(&et, CLOCK_SECOND); while(1) { if(test_index == (sizeof(test_case) / sizeof(test_func))) { break; } else { test_case[test_index]((const linkaddr_t *)&peer_addr); } PROCESS_WAIT_EVENT_UNTIL(ev == test_sf_trans_done); PROCESS_YIELD_UNTIL(etimer_expired(&et)); etimer_reset(&et); test_index++; } PRINTF("done\n"); PROCESS_END(); } const sixtop_sf_t test_sf = { TEST_SF_SFID, TEST_SF_TIMEOUT, init, input, timeout, NULL };
8bcde05ffd2bfab48a35de8b6c84948c4f67318a
f643c78cd1c86d75f80992fed1ee440e2eece061
/include/NovelRT.Interop/Ecs/NrtSystemScheduler.h
506e43f522492df7137b20a61e7673bc13c21ab7
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "BSD-3-Clause", "LGPL-2.1-only", "LicenseRef-scancode-other-permissive", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
novelrt/NovelRT
6652d04abcb5a7cdf2713d93902bf237a4e2cbf4
8cf53527019e467517aa8ef9b0cb74309c72f898
refs/heads/main
2023-07-24T05:00:08.110952
2023-07-02T03:16:40
2023-07-02T03:16:40
161,620,104
204
72
MIT
2023-07-02T03:16:42
2018-12-13T10:06:21
C++
UTF-8
C
false
false
1,567
h
NrtSystemScheduler.h
// Copyright © Matt Jones and Contributors. Licensed under the MIT Licence (MIT). See LICENCE.md in the repository root // for more information. #ifndef NOVELRT_INTEROP_ECS_SYSTEMSCHEDULER_H #define NOVELRT_INTEROP_ECS_SYSTEMSCHEDULER_H #include "../NrtTypedefs.h" #ifdef __cplusplus extern "C" { #endif NrtSystemSchedulerHandle Nrt_SystemScheduler_CreateWithDefaultThreadCount(); NrtSystemSchedulerHandle Nrt_SystemScheduler_Create(uint32_t maximumThreadCount); NrtBool Nrt_SystemScheduler_GetThreadsAreSpinning(NrtSystemSchedulerHandle systemScheduler); void Nrt_SystemScheduler_RegisterSystem(NrtSystemSchedulerHandle systemScheduler, NrtSystemUpdateFnPtr systemUpdatePtr, void* context); uint32_t Nrt_SystemScheduler_GetWorkerThreadCount(NrtSystemSchedulerHandle systemScheduler); NrtEntityCacheHandle Nrt_SystemScheduler_GetEntityCache(NrtSystemSchedulerHandle systemScheduler); NrtComponentCacheHandle Nrt_SystemScheduler_GetComponentCache(NrtSystemSchedulerHandle systemScheduler); void Nrt_SystemScheduler_SpinThreads(NrtSystemSchedulerHandle systemScheduler); NrtResult Nrt_SystemScheduler_ExecuteIteration(NrtSystemSchedulerHandle systemScheduler, NrtTimestamp delta); NrtResult Nrt_SystemScheduler_ShutDown(NrtSystemSchedulerHandle systemScheduler); NrtResult Nrt_SystemScheduler_Destroy(NrtSystemSchedulerHandle systemScheduler); #ifdef __cplusplus } #endif #endif // NOVELRT_INTEROP_ECS_SYSTEMSCHEDULER_H
1fb98cafd0a7f6abec71622508269f6f3be5b445
d79db96554e506a7be2b61bd9df178a98ac7ccf4
/src/libressl-2.4.1/crypto/rsa/rsa_locl.h
fe465308eaf17d57234416feb54a343ceec327cf
[ "FSFAP", "OpenSSL", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
lsds/TaLoS
42edcb4ed4d76257ec3c217ba26a92f543a9ef63
9c959980de0c6d2a80582e3546747823ea3eca69
refs/heads/master
2023-09-05T04:58:07.718709
2022-01-25T05:00:19
2022-01-25T05:00:19
85,239,830
113
23
Apache-2.0
2020-11-19T08:10:08
2017-03-16T20:42:42
C
UTF-8
C
false
false
247
h
rsa_locl.h
/* $OpenBSD: rsa_locl.h,v 1.2 2014/06/12 15:49:30 deraadt Exp $ */ extern int int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len, unsigned char *rm, size_t *prm_len, const unsigned char *sigbuf, size_t siglen, RSA *rsa);
77f340c4d57a62da7f3ad03bdb58e1c66d33a743
035660e8cc10571ebbd0d4393fef063bb7eb98f6
/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h
9498e8e25325437b3e3d0f6b0bb4cd397e2c1776
[]
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
1,631
h
z_en_clear_tag.h
#ifndef Z_EN_CLEAR_TAG_H #define Z_EN_CLEAR_TAG_H #include "global.h" struct EnClearTag; #define CLEAR_TAG_PARAMS(type) (type) typedef enum { /* 0x00 */ CLEAR_TAG_SMALL_EXPLOSION, /* 0x01 */ CLEAR_TAG_LARGE_EXPLOSION, /* 0x02 */ CLEAR_TAG_POP, /* 0x03 */ CLEAR_TAG_SMALL_LIGHT_RAYS, /* 0x04 */ CLEAR_TAG_LARGE_LIGHT_RAYS, /* 0x23 */ CLEAR_TAG_SPLASH = 35, /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; /* 0x1C */ Vec3f accel; /* 0x28 */ Color_RGBAf primColor; /* 0x38 */ Color_RGBAf envColor; /* 0x48 */ s16 bounces; /* 0x4A */ s16 effectsTimer; /* 0x4C */ s16 lightRayAlpha; /* 0x4E */ s16 lightRayAlphaDecrementSpeed; /* 0x50 */ f32 scale; /* 0x54 */ f32 maxScale; /* 0x58 */ f32 rotationY; /* 0x5C */ f32 rotationX; /* 0x60 */ f32 rotationZ; /* 0x64 */ f32 maxScaleTarget; /* 0x68 */ f32 smokeScaleY; /* 0x6C */ f32 smokeScaleX; } EnClearTagEffect; // size = 0x70 #define EN_CLEAR_TAG_EFFECT_COUNT 103 typedef struct EnClearTag { /* 0x0000 */ Actor actor; /* 0x0144 */ EnClearTagEffect effect[EN_CLEAR_TAG_EFFECT_COUNT]; /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; /* 0x2E64 */ s16 subCamId; /* 0x2E66 */ Color_RGBA8 flashEnvColor; /* 0x2E6C */ Vec3f subCamEye; /* 0x2E78 */ Vec3f subCamAt; } EnClearTag; // size = 0x2E84 #endif // Z_EN_CLEAR_TAG_H
c299430c0d84cfe91bd7920b8474349057c33b78
baa9fffc817a2a993d4ecc774d3f277783308c20
/src/uct/ib/base/ib_log.c
324d39329f5fd80470c51f41490c93e832aba76a
[ "BSD-3-Clause" ]
permissive
openucx/ucx
9a0f2205295afbdf3cff14b5d24af781b123f5ea
73a48700badb7cbace64d94b82f408e2a26fca32
refs/heads/master
2023-09-01T16:51:26.913950
2023-09-01T13:02:25
2023-09-01T13:02:25
25,379,390
966
420
NOASSERTION
2023-09-14T12:29:35
2014-10-17T22:17:24
C
UTF-8
C
false
false
9,624
c
ib_log.c
/** * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2015. ALL RIGHTS RESERVED. * * See file LICENSE for terms. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include "ib_log.h" #include <ucs/sys/sys.h> const char *uct_ib_qp_type_str(int qp_type) { switch (qp_type) { case IBV_QPT_RC: return "RC"; case IBV_QPT_UD: return "UD"; #if HAVE_TL_DC case UCT_IB_QPT_DCI: return "DCI"; #endif default: ucs_bug("invalid qp type: %d", qp_type); return "unknown"; } } void uct_ib_log_dump_opcode(uct_ib_opcode_t *op, int sig, int fence, int se, char *buf, size_t max) { snprintf(buf, max, "%s %c%c%c", op->name, sig ? 's' : '-', fence ? 'f' : '-', se ? 'e' : '-'); } void uct_ib_log_dump_sg_list(uct_ib_iface_t *iface, uct_am_trace_type_t type, struct ibv_sge *sg_list, int num_sge, uint64_t inline_bitmap, uct_log_data_dump_func_t data_dump, int data_dump_sge, char *buf, size_t max) { char data[256]; size_t total_len = 0; size_t total_valid_len = 0; char *s = buf; char *ends = buf + max; void *md = data; size_t len; int i; for (i = 0; i < num_sge; ++i) { if (inline_bitmap & UCS_BIT(i)) { snprintf(s, ends - s, " [inl len %d]", sg_list[i].length); } else { snprintf(s, ends - s, " [va 0x%"PRIx64" len %d lkey 0x%x]", sg_list[i].addr, sg_list[i].length, sg_list[i].lkey); } s += strlen(s); if ((i < data_dump_sge) && data_dump) { len = ucs_min(sg_list[i].length, UCS_PTR_BYTE_DIFF(md, data) + sizeof(data)); memcpy(md, (void*)sg_list[i].addr, len); md = UCS_PTR_BYTE_OFFSET(md, len); total_len += len; total_valid_len += sg_list[i].length; } } if (data_dump) { data_dump(&iface->super, type, data, total_len, total_valid_len, s, ends - s); } } void uct_ib_log_dump_remote_addr(uint64_t remote_addr, uint32_t rkey, char *buf, size_t max) { snprintf(buf, max, " [rva 0x%"PRIx64" rkey 0x%x]", remote_addr, rkey); } void uct_ib_log_dump_atomic_fadd(uint64_t add, char *buf, size_t max) { snprintf(buf, max, " [add %ld]", add); } void uct_ib_log_dump_atomic_cswap(uint64_t compare, uint64_t swap, char *buf, size_t max) { snprintf(buf, max, " [cmp %ld swap %ld]", compare, swap); } void uct_ib_log_dump_atomic_masked_fadd(int argsize, uint64_t add, uint64_t boundary, char *buf, size_t max) { snprintf(buf, max, " [%dbit add %"PRIi64"/0x%"PRIx64"]", argsize * 8, add, boundary); } void uct_ib_log_dump_atomic_masked_cswap(int argsize, uint64_t compare, uint64_t compare_mask, uint64_t swap, uint64_t swap_mask, char *buf, size_t max) { snprintf(buf, max, " [%d bit cmp %"PRIi64"/0x%"PRIx64" swap %"PRIi64"/0x%"PRIx64"]", argsize * 8, compare, compare_mask, swap, swap_mask); } void uct_ib_log_dump_qp_peer_info(uct_ib_iface_t *iface, const struct ibv_ah_attr *ah_attr, uint32_t dest_qpn, char *buf, size_t max) { char *s = buf; char *ends = buf + max; snprintf(s, ends - s, "[rqpn 0x%x ", dest_qpn); s += strlen(s); uct_ib_ah_attr_str(s, ends - s, ah_attr); s += strlen(s); snprintf(s, ends - s, "]"); } void uct_ib_log_dump_recv_completion(uct_ib_iface_t *iface, uint32_t local_qp, uint32_t sender_qp, uint16_t sender_lid, void *data, size_t length, uct_log_data_dump_func_t data_dump, char *buf, size_t max) { char *s = buf; char *ends = buf + max; snprintf(s, ends - s, "RECV qp 0x%x", local_qp); s += strlen(s); if (iface->config.qp_type == IBV_QPT_UD) { snprintf(s, ends - s, " [slid %d sqp 0x%x]", sender_lid, sender_qp); s += strlen(s); } snprintf(s, ends - s, " [va %p len %zu]", data, length); s += strlen(s); if (data_dump != NULL) { data_dump(&iface->super, UCT_AM_TRACE_TYPE_RECV, data, length, length, s, ends - s); } } static void uct_ib_dump_wr_opcode(struct ibv_qp *qp, uint64_t wr_id, uct_ib_opcode_t *op, int send_flags, char *buf, size_t max) { char *s = buf; char *ends = buf + max; snprintf(s, ends - s, "QP 0x%x wrid 0x%"PRIx64" ", qp->qp_num, wr_id); s += strlen(s); uct_ib_log_dump_opcode(op, send_flags & IBV_SEND_SIGNALED, send_flags & IBV_SEND_FENCE, send_flags & IBV_SEND_SOLICITED, s, ends - s); } static void uct_ib_dump_wr(struct ibv_qp *qp, uct_ib_opcode_t *op, struct ibv_send_wr *wr, char *buf, size_t max) { char *s = buf; char *ends = buf + max; if (qp->qp_type == IBV_QPT_UD) { snprintf(s, ends - s, " [rqpn 0x%x ah %p]", wr->wr.ud.remote_qpn, wr->wr.ud.ah); s += strlen(s); } if (op->flags & UCT_IB_OPCODE_FLAG_HAS_RADDR) { uct_ib_log_dump_remote_addr(wr->wr.rdma.remote_addr, wr->wr.rdma.rkey, s, ends - s); s += strlen(s); } if (op->flags & UCT_IB_OPCODE_FLAG_HAS_ATOMIC) { uct_ib_log_dump_remote_addr(wr->wr.atomic.remote_addr, wr->wr.atomic.rkey, s, ends - s); s += strlen(s); if (wr->opcode == IBV_WR_ATOMIC_FETCH_AND_ADD) { uct_ib_log_dump_atomic_fadd(wr->wr.atomic.compare_add, s, ends - s); } else if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) { uct_ib_log_dump_atomic_cswap(wr->wr.atomic.compare_add, wr->wr.atomic.swap, s, ends - s); } /* do not forget `s += strlen(s);` here if you are * processing more information for dumping below */ } } static void uct_ib_dump_send_wr(uct_ib_iface_t *iface, struct ibv_qp *qp, struct ibv_send_wr *wr, int max_sge, uct_log_data_dump_func_t data_dump, char *buf, size_t max) { static uct_ib_opcode_t opcodes[] = { [IBV_WR_RDMA_WRITE] = { "RDMA_WRITE", UCT_IB_OPCODE_FLAG_HAS_RADDR }, [IBV_WR_RDMA_READ] = { "RDMA_READ", UCT_IB_OPCODE_FLAG_HAS_RADDR }, [IBV_WR_SEND] = { "SEND", 0 }, [IBV_WR_SEND_WITH_IMM] = { "SEND_IMM", 0 }, [IBV_WR_ATOMIC_CMP_AND_SWP] = { "CSWAP", UCT_IB_OPCODE_FLAG_HAS_ATOMIC }, [IBV_WR_ATOMIC_FETCH_AND_ADD] = { "FETCH_ADD", UCT_IB_OPCODE_FLAG_HAS_ATOMIC }, }; char *s = buf; char *ends = buf + max; uct_ib_opcode_t *op = &opcodes[wr->opcode]; uct_ib_dump_wr_opcode(qp, wr->wr_id, op, wr->send_flags, s, ends - s); s += strlen(s); uct_ib_dump_wr(qp, op, wr, s, ends - s); s += strlen(s); uct_ib_log_dump_sg_list(iface, UCT_AM_TRACE_TYPE_SEND, wr->sg_list, wr->num_sge, (wr->send_flags & IBV_SEND_INLINE) ? -1 : 0, data_dump, max_sge, s, ends - s); } void uct_ib_memlock_limit_msg(ucs_string_buffer_t *message, int sys_errno) { size_t memlock_limit; ucs_status_t status; if (sys_errno == ENOMEM) { status = ucs_sys_get_effective_memlock_rlimit(&memlock_limit); if ((status == UCS_OK) && (memlock_limit != SIZE_MAX)) { ucs_string_buffer_appendf( message, " : Please set max locked memory (ulimit -l) to 'unlimited'" " (current: %llu kbytes)", memlock_limit / UCS_KBYTE); } } } void __uct_ib_log_post_send(const char *file, int line, const char *function, uct_ib_iface_t *iface, struct ibv_qp *qp, struct ibv_send_wr *wr, int max_sge, uct_log_data_dump_func_t data_dump_cb) { char buf[256] = {0}; while (wr != NULL) { uct_ib_dump_send_wr(iface, qp, wr, max_sge, data_dump_cb, buf, sizeof(buf) - 1); uct_log_data(file, line, function, buf); wr = wr->next; } } void __uct_ib_log_recv_completion(const char *file, int line, const char *function, uct_ib_iface_t *iface, uint32_t l_qp, uint32_t r_qp, uint16_t slid, void *data, size_t length, uct_log_data_dump_func_t packet_dump_cb) { char buf[256] = {0}; size_t len; len = length; if (iface->config.qp_type == IBV_QPT_UD) { len -= UCT_IB_GRH_LEN; data = UCS_PTR_BYTE_OFFSET(data, UCT_IB_GRH_LEN); } uct_ib_log_dump_recv_completion(iface, l_qp, r_qp, slid, data, len, packet_dump_cb, buf, sizeof(buf) - 1); uct_log_data(file, line, function, buf); }
0599fecd700edeebca3885db49338b212ebfd95f
8f3bf2d3f72e9c7022b3e2efde3d787c9ca354fc
/test/integration/fapi-key-create2-sign.int.c
85960e5a05a181b11fbe836dc0873349defee8d8
[ "BSD-2-Clause" ]
permissive
tpm2-software/tpm2-tss
27dc9cddb545a04958c29839a9cdafb0df54ff3c
b7bad346b4b55def7fd1cd78c8724df00dddd76c
refs/heads/master
2023-09-03T19:58:41.440023
2023-08-15T18:30:40
2023-08-16T07:09:48
38,320,020
563
311
BSD-2-Clause
2023-09-14T08:28:43
2015-06-30T16:21:57
C
UTF-8
C
false
false
13,963
c
fapi-key-create2-sign.int.c
/* SPDX-License-Identifier: BSD-2-Clause */ /******************************************************************************* * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG * All rights reserved. *******************************************************************************/ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <string.h> #include "tss2_fapi.h" #include "test-fapi.h" #include "fapi_util.h" #include "fapi_int.h" #include "esys_iutil.h" #define LOGMODULE test #include "util/log.h" #include "util/aux_util.h" #define PASSWORD "abc" #define SIGN_TEMPLATE "sign,noDa" #define DECRYPT_TEMPLATE "restricted,decrypt,noDa" #define EVENT_SIZE 10 static bool cb_called = false; static TSS2_RC branch_callback( char const *objectPath, char const *description, char const **branchNames, size_t numBranches, size_t *selectedBranch, void *userData) { UNUSED(description); UNUSED(userData); if (strcmp(objectPath, FAPI_PROFILE "/HS/SRK/myDecryptKey1/myDecryptKey2/") != 0) { return_error(TSS2_FAPI_RC_BAD_VALUE, "Unexpected path"); } if (numBranches != 2) { LOG_ERROR("Wrong number of branches"); return TSS2_FAPI_RC_GENERAL_FAILURE; } if (!strcmp(branchNames[0], "branch0")) *selectedBranch = 0; else if (!strcmp(branchNames[1], "branch0")) *selectedBranch = 1; else { LOG_ERROR("BranchName not found. Got \"%s\" and \"%s\"", branchNames[0], branchNames[1]); return TSS2_FAPI_RC_GENERAL_FAILURE; } cb_called = true; return TSS2_RC_SUCCESS; } static char * read_policy(FAPI_CONTEXT *context, char *policy_name) { FILE *stream = NULL; long policy_size; char *json_policy = NULL; char policy_file[1024]; if (snprintf(&policy_file[0], 1023, TOP_SOURCEDIR "/test/data/fapi/%s.json", policy_name) < 0) return NULL; stream = fopen(policy_file, "r"); if (!stream) { LOG_ERROR("File %s does not exist", policy_file); return NULL; } fseek(stream, 0L, SEEK_END); policy_size = ftell(stream); fclose(stream); json_policy = malloc(policy_size + 1); stream = fopen(policy_file, "r"); ssize_t ret = read(fileno(stream), json_policy, policy_size); if (ret != policy_size) { LOG_ERROR("IO error %s.", policy_file); return NULL; } json_policy[policy_size] = '\0'; return json_policy; } json_object * get_json_hex_string(const uint8_t *buffer, size_t size) { char hex_string[size * 2 + 1]; for (size_t i = 0, off = 0; i < size; i++, off += 2) { sprintf(&hex_string[off], "%02x", buffer[i]); } hex_string[(size) * 2] = '\0'; json_object *jso = json_object_new_string(hex_string); return jso; } static TSS2_RC auth_callback( char const *objectPath, char const *description, const char **auth, void *userData) { UNUSED(description); UNUSED(userData); if (!objectPath) { return_error(TSS2_FAPI_RC_BAD_VALUE, "No path."); } *auth = PASSWORD; return TSS2_RC_SUCCESS; } /** Test the FAPI Key loading and signing with error cases. * * A key chain with four keys is generated. The last key will be used to * create a signature and the signature will be verified. * Policies and passwords will be assigned to the keys. Also error cases * will be tested to verify proper cleanup. * * Tested FAPI commands: * - Fapi_Provision() * - Fapi_SetAuthCB() * - Fapi_CreateKey() * - Fapi_GetTpmBlobs() * - Fapi_Sign() * - Fapi_VerifySignature() * - Fapi_SetCertificate() * - Fapi_List() * - Fapi_Delete() * * @param[in,out] context The FAPI_CONTEXT. * @retval EXIT_FAILURE * @retval EXIT_SUCCESS */ int test_fapi_key_create_sign(FAPI_CONTEXT *context) { TSS2_RC r; char *sigscheme = NULL; const char *cert = "-----BEGIN CERTIFICATE-----\n" "MIIDBjCCAe4CCQDcvXBOEVM0UTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJE\n" "RTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0\n" "cyBQdHkgTHRkMB4XDTE5MDIyODEwNDkyM1oXDTM1MDgyNzEwNDkyM1owRTELMAkG\n" "A1UEBhMCREUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0\n" "IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" "AKBi+iKwkgM55iCMwXrLCJlu7TzlMu/LlkyGrm99ip2B5+/Cl6a62d8pKelg6zkH\n" "jI7+AAPteJiW4O+2qVWF8hJ5BXTjGtYbM0iZ6enCb8eyC54C7xVMc21ZIv3ob4Et\n" "50ZOuzY2pfpzE3vIaXt1CkHlfyI/hdK+mM/dVvuCz5p3AIlHrEWS3rSNgWbCsB2E\n" "TM55qSGKaLmtTbUvEKRF0TJrFLntfXkv10QD5pgn52+QV9k59OogqZOsDvkXzKPX\n" "rXF+XC0gLiGBEGAr1dv9F03xMOtO77bQTdGOeC61Tip6Nb0V3ebMckZXwdFi+Nhe\n" "FRuU33CaObtV6u5PZvSue/MCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAcamUPe8I\n" "nMOHcv9x5lVN1joihVRmKc0QqNLFc6XpJY8+U5rGkZvOcDe9Da8L97wDNXpKmU/q\n" "pprj3rT8l3v0Z5xs8Vdr8lxS6T5NhqQV0UCsn1x14gZJcE48y9/LazYi6Zcar+BX\n" "Am4vewAV3HmQ8X2EctsRhXe4wlAq4slIfEWaaofa8ai7BzO9KwpMLsGPWoNetkB9\n" "19+SFt0lFFOj/6vDw5pCpSd1nQlo1ug69mJYSX/wcGkV4t4LfGhV8jRPDsGs6I5n\n" "ETHSN5KV1XCPYJmRCjFY7sIt1x4zN7JJRO9DVw+YheIlduVfkBiF+GlQgLlFTjrJ\n" "VrpSGMIFSu301A==\n" "-----END CERTIFICATE-----\n"; uint8_t *signature = NULL; char *publicKey = NULL; char *certificate = NULL; uint8_t *publicblob = NULL; uint8_t *privateblob = NULL; char *policy = NULL; char *path_list = NULL; size_t publicsize; size_t privatesize; json_object *jso = NULL; char *description = NULL; char *policy_pcr = "/policy/pol_pcr16_0"; char *policy_authorize = "/policy/pol_authorize"; char *policy_or = "/policy/pol_pcr16_0_or"; uint8_t policyRef[] = { 1, 2, 3, 4, 5 }; uint8_t data[EVENT_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; char *json_policy = NULL; if (strncmp("P_ECC", fapi_profile, 5) != 0) sigscheme = "RSA_PSS"; /* We need to reset the passwords again, in order to not brick physical TPMs */ r = Fapi_Provision(context, NULL, PASSWORD, NULL); goto_if_error(r, "Error Fapi_Provision", error); r = Fapi_SetAuthCB(context, auth_callback, NULL); goto_if_error(r, "Error SetPolicyAuthCallback", error); r = Fapi_SetBranchCB(context, branch_callback, NULL); goto_if_error(r, "Error SetPolicybranchselectioncallback", error); r = pcr_reset(context, 16); goto_if_error(r, "Error pcr_reset", error); json_policy = read_policy(context, policy_pcr); if (!json_policy) goto error; r = Fapi_Import(context, policy_pcr, json_policy); goto_if_error(r, "Error Fapi_Import", error); SAFE_FREE(json_policy); json_policy = read_policy(context, policy_or); if (!json_policy) goto error; r = Fapi_Import(context, policy_or, json_policy); goto_if_error(r, "Error Fapi_Import", error); SAFE_FREE(json_policy); json_policy = read_policy(context, policy_authorize); if (!json_policy) goto error; r = Fapi_Import(context, policy_authorize, json_policy); SAFE_FREE(json_policy); goto_if_error(r, "Error Fapi_Import", error); r = Fapi_CreateKey(context, "/HS/SRK/myPolicySignKey", SIGN_TEMPLATE, "", PASSWORD); goto_if_error(r, "Error Fapi_CreateKey", error); r = Fapi_AuthorizePolicy(context, policy_pcr, "/HS/SRK/myPolicySignKey", policyRef, sizeof(policyRef)); goto_if_error(r, "Authorize policy", error); r = Fapi_CreateKey(context, "HS/SRK/myDecryptKey1", DECRYPT_TEMPLATE , policy_authorize, PASSWORD); goto_if_error(r, "Error Fapi_CreateKey_Async", error); r = Fapi_CreateKey(context, "HS/SRK/myDecryptKeyErr", "decrypt,noDa" "", "", PASSWORD); goto_if_error(r, "Error Fapi_CreateKey_Async", error); r = Fapi_CreateKey(context, "HS/SRK/myDecryptKey1/myDecryptKey2", DECRYPT_TEMPLATE , policy_or, PASSWORD); goto_if_error(r, "Error Fapi_CreateKey_Async", error); r = Fapi_CreateKey(context, "HS/SRK/myDecryptKeyErr/mySignKey", SIGN_TEMPLATE "", "", PASSWORD); /* The Key creation should fail due to missing attribute "restricted" for myDecryptKeyErr */ if (r == TSS2_RC_SUCCESS) { LOG_ERROR("Key creation did not fail."); goto error; } r = Fapi_CreateKey(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", SIGN_TEMPLATE "", "", PASSWORD); goto_if_error(r, "Error Fapi_CreateKey_Async", error); goto_if_error(r, "Error Fapi_CreateKey_Finish", error); size_t signatureSize = 0; TPM2B_DIGEST digest = { .size = 32, .buffer = { 0x67, 0x68, 0x03, 0x3e, 0x21, 0x64, 0x68, 0x24, 0x7b, 0xd0, 0x31, 0xa0, 0xa2, 0xd9, 0x87, 0x6d, 0x79, 0x81, 0x8f, 0x8f, 0x31, 0xa0, 0xa2, 0xd9, 0x87, 0x6d, 0x79, 0x81, 0x8f, 0x8f, 0x67, 0x68 } }; r = Fapi_GetTpmBlobs(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", &publicblob, &publicsize, &privateblob, &privatesize, &policy); goto_if_error(r, "Error Fapi_GetTpmBlobs", error); ASSERT(publicblob != NULL); ASSERT(privateblob != NULL); ASSERT(policy != NULL); ASSERT(strlen(policy) == 0); r = Fapi_SetCertificate(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", cert); goto_if_error(r, "Error Fapi_SetCertificate", error); r = Fapi_Sign(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", sigscheme, &digest.buffer[0], digest.size, &signature, &signatureSize, &publicKey, &certificate); goto_if_error(r, "Error Fapi_Sign", error); ASSERT(signature != NULL); ASSERT(publicKey != NULL); ASSERT(certificate != NULL); ASSERT(strlen(publicKey) > ASSERT_SIZE); ASSERT(strlen(certificate) > ASSERT_SIZE); r = Fapi_VerifySignature(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", &digest.buffer[0], digest.size, signature, signatureSize); goto_if_error(r, "Error Fapi_VerifySignature", error); /* Create json date to import binary public and private blobs under the same parent key. */ json_object * publicblobHex_jso = get_json_hex_string(publicblob, publicsize); goto_if_null2(publicblobHex_jso, "Out of memory", r, TSS2_FAPI_RC_MEMORY, error); json_object * privateblobHex_jso = get_json_hex_string(privateblob, privatesize); goto_if_null2(privateblobHex_jso, "Out of memory", r, TSS2_FAPI_RC_MEMORY, error); jso = json_object_new_object(); goto_if_null2(jso, "Out of memory", r, TSS2_FAPI_RC_MEMORY, error); json_object_object_add(jso, "public", publicblobHex_jso); json_object_object_add(jso, "private", privateblobHex_jso); const char * jso_string = json_object_to_json_string_ext(jso, JSON_C_TO_STRING_PRETTY); r = Fapi_Import(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey2", jso_string); goto_if_error(r, "Error Fapi_Import", error); r = Fapi_VerifySignature(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey2", &digest.buffer[0], digest.size, signature, signatureSize); goto_if_error(r, "Error Fapi_VerifySignature", error); r = Fapi_VerifySignature(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey2", &digest.buffer[0], digest.size, signature, signatureSize); goto_if_error(r, "Error Fapi_VerifySignature", error); r = Fapi_PcrExtend(context, 16, data, EVENT_SIZE, "{ \"test\": \"myfile\" }"); goto_if_error(r, "Error Fapi_PcrExtend", error); r = Fapi_Sign(context, "HS/SRK/myDecryptKey1/myDecryptKey2/mySignKey", sigscheme, &digest.buffer[0], digest.size, &signature, &signatureSize, &publicKey, &certificate); /* The signing should fail due to violation of Policy PCR */ if (r == TSS2_RC_SUCCESS) { LOG_ERROR("Sign did not fail."); goto error; } r = Fapi_GetDescription(context, "/HS/SRK", &description); goto_if_error(r, "Error GetDescription", error); if (description) { LOG_INFO("SRK description: %s", description); SAFE_FREE(description); } r = Fapi_GetDescription(context, "/HE/EK", &description); goto_if_error(r, "Error GetDescription", error); if (description) { LOG_INFO("EK description: %s", description); SAFE_FREE(description); } r = pcr_reset(context, 16); goto_if_error(r, "Error pcr_reset", error); /* We need to reset the passwords again, in order to not brick physical TPMs */ r = Fapi_ChangeAuth(context, "/HS", NULL); goto_if_error(r, "Error Fapi_ChangeAuth", error); r = Fapi_Delete(context, "/"); goto_if_error(r, "Error Fapi_Delete", error); SAFE_FREE(json_policy); SAFE_FREE(policy); json_object_put(jso); SAFE_FREE(path_list); SAFE_FREE(publicblob); SAFE_FREE(privateblob); SAFE_FREE(policy); SAFE_FREE(publicKey); SAFE_FREE(signature); SAFE_FREE(certificate); if (!cb_called) { LOG_ERROR("Branch selection callback was not called."); return EXIT_FAILURE; } return EXIT_SUCCESS; error: SAFE_FREE(json_policy); SAFE_FREE(policy); if (jso) json_object_put(jso); Fapi_Delete(context, "/"); SAFE_FREE(path_list); SAFE_FREE(publicblob); SAFE_FREE(privateblob); SAFE_FREE(policy); SAFE_FREE(publicKey); SAFE_FREE(signature); SAFE_FREE(certificate); return EXIT_FAILURE; } int test_invoke_fapi(FAPI_CONTEXT *fapi_context) { return test_fapi_key_create_sign(fapi_context); }
b84a24022dd27719dda4366c2c8e0df41e379afa
99783290ac494aa812f6ee313c768b932985e7ef
/pigpio/pigpiod_if2.c
f8dc9c76b1a42410fdf50a227fe12ba997f9c51c
[ "Apache-2.0", "Unlicense" ]
permissive
UniPiTechnology/evok
4820d2615550d81fead9d8437520b3f4c3fb580b
ecbf147da32bffa79d1cf492c83898cdc14595e7
refs/heads/main
2023-04-10T00:06:41.177445
2023-04-02T19:10:02
2023-04-03T06:18:18
26,583,169
104
51
Apache-2.0
2022-10-13T14:26:42
2014-11-13T10:40:53
C
UTF-8
C
false
false
43,459
c
pigpiod_if2.c
/* This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. For more information, please refer to <http://unlicense.org/> */ /* PIGPIOD_IF2_VERSION 17 */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <time.h> #include <netdb.h> #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/socket.h> #include <netinet/tcp.h> #include <sys/select.h> #include <arpa/inet.h> #include "pigpio.h" #include "command.h" #include "pigpiod_if2.h" #define PI_MAX_REPORTS_PER_READ 4096 #define STACK_SIZE (256*1024) #define MAX_PI 32 typedef void (*CBF_t) (); struct callback_s { int id; int pi; int gpio; int edge; CBF_t f; void * user; int ex; callback_t *prev; callback_t *next; }; struct evtCallback_s { int id; int pi; int event; CBF_t f; void * user; int ex; evtCallback_t *prev; evtCallback_t *next; }; /* GLOBALS ---------------------------------------------------------------- */ static int gPiInUse [MAX_PI]; static int gPigCommand [MAX_PI]; static int gPigHandle [MAX_PI]; static int gPigNotify [MAX_PI]; static uint32_t gEventBits [MAX_PI]; static uint32_t gNotifyBits [MAX_PI]; static uint32_t gLastLevel [MAX_PI]; static pthread_t *gPthNotify [MAX_PI]; static pthread_mutex_t gCmdMutex [MAX_PI]; static int gCancelState [MAX_PI]; static callback_t *gCallBackFirst = 0; static callback_t *gCallBackLast = 0; static evtCallback_t *geCallBackFirst = 0; static evtCallback_t *geCallBackLast = 0; /* PRIVATE ---------------------------------------------------------------- */ static void _pml(int pi) { int cancelState; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancelState); pthread_mutex_lock(&gCmdMutex[pi]); gCancelState[pi] = cancelState; } static void _pmu(int pi) { int cancelState; cancelState = gCancelState[pi]; pthread_mutex_unlock(&gCmdMutex[pi]); pthread_setcancelstate(cancelState, NULL); } static int pigpio_command(int pi, int command, int p1, int p2, int rl) { cmdCmd_t cmd; if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return pigif_unconnected_pi; cmd.cmd = command; cmd.p1 = p1; cmd.p2 = p2; cmd.res = 0; _pml(pi); if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) { _pmu(pi); return pigif_bad_send; } if (recv(gPigCommand[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) { _pmu(pi); return pigif_bad_recv; } if (rl) _pmu(pi); return cmd.res; } static int pigpio_notify(int pi) { cmdCmd_t cmd; if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return pigif_unconnected_pi; cmd.cmd = PI_CMD_NOIB; cmd.p1 = 0; cmd.p2 = 0; cmd.res = 0; _pml(pi); if (send(gPigNotify[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) { _pmu(pi); return pigif_bad_send; } if (recv(gPigNotify[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) { _pmu(pi); return pigif_bad_recv; } _pmu(pi); return cmd.res; } static int pigpio_command_ext (int pi, int command, int p1, int p2, int p3, int extents, gpioExtent_t *ext, int rl) { int i; cmdCmd_t cmd; if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return pigif_unconnected_pi; cmd.cmd = command; cmd.p1 = p1; cmd.p2 = p2; cmd.p3 = p3; _pml(pi); if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) { _pmu(pi); return pigif_bad_send; } for (i=0; i<extents; i++) { if (send(gPigCommand[pi], ext[i].ptr, ext[i].size, 0) != ext[i].size) { _pmu(pi); return pigif_bad_send; } } if (recv(gPigCommand[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) { _pmu(pi); return pigif_bad_recv; } if (rl) _pmu(pi); return cmd.res; } static int pigpioOpenSocket(const char *addrStr, const char *portStr) { int sock, err, opt; struct addrinfo hints, *res, *rp; memset (&hints, 0, sizeof (hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags |= AI_CANONNAME; err = getaddrinfo (addrStr, portStr, &hints, &res); if (err) return pigif_bad_getaddrinfo; for (rp=res; rp!=NULL; rp=rp->ai_next) { sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sock == -1) continue; /* Disable the Nagle algorithm. */ opt = 1; setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int)); if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break; } freeaddrinfo(res); if (rp == NULL) return pigif_bad_connect; return sock; } static void dispatch_notification(int pi, gpioReport_t *r) { callback_t *p; evtCallback_t *ep; uint32_t changed; int l, g; /* printf("s=%4x f=%4x t=%10u l=%8x\n", r->seqno, r->flags, r->tick, r->level); */ if (r->flags == 0) { changed = (r->level ^ gLastLevel[pi]) & gNotifyBits[pi]; gLastLevel[pi] = r->level; p = gCallBackFirst; while (p) { if (((p->pi) == pi) && (changed & (1<<(p->gpio)))) { if ((r->level) & (1<<(p->gpio))) l = 1; else l = 0; if ((p->edge) ^ l) { if (p->ex) (p->f)(pi, p->gpio, l, r->tick, p->user); else (p->f)(pi, p->gpio, l, r->tick); } } p = p->next; } } else { if ((r->flags) & PI_NTFY_FLAGS_WDOG) { g = (r->flags) & 31; p = gCallBackFirst; while (p) { if (((p->pi) == pi) && ((p->gpio) == g)) { if (p->ex) (p->f)(pi, g, PI_TIMEOUT, r->tick, p->user); else (p->f)(pi, g, PI_TIMEOUT, r->tick); } p = p->next; } } else if ((r->flags) & PI_NTFY_FLAGS_EVENT) { g = (r->flags) & 31; ep = geCallBackFirst; while (ep) { if (((ep->pi) == pi) && ((ep->event) == g)) { if (ep->ex) (ep->f)(pi, g, r->tick, ep->user); else (ep->f)(pi, g, r->tick); } ep = ep->next; } } } } static void *pthNotifyThread(void *x) { static int got = 0; int pi; int bytes, r; gpioReport_t report[PI_MAX_REPORTS_PER_READ]; pi = *((int*)x); free(x); /* memory allocated in pigpio_start */ while (1) { bytes = read(gPigNotify[pi], (char*)&report+got, sizeof(report)-got); if (bytes > 0) got += bytes; else break; r = 0; while (got >= sizeof(gpioReport_t)) { dispatch_notification(pi, &report[r]); r++; got -= sizeof(gpioReport_t); } /* copy any partial report to start of array */ if (got && r) report[0] = report[r]; } fprintf(stderr, "notify thread for pi %d broke with read error %d\n", pi, bytes); while (1) sleep(1); return NULL; } static void findNotifyBits(int pi) { callback_t *p; uint32_t bits = 0; p = gCallBackFirst; while (p) { if (p->pi == pi) bits |= (1<<(p->gpio)); p = p->next; } if (bits != gNotifyBits[pi]) { gNotifyBits[pi] = bits; pigpio_command(pi, PI_CMD_NB, gPigHandle[pi], gNotifyBits[pi], 1); } } static void _wfe( int pi, unsigned user_gpio, unsigned level, uint32_t tick, void *user) { *(int *)user = 1; } static int intCallback( int pi, unsigned user_gpio, unsigned edge, void *f, void *user, int ex) { static int id = 0; callback_t *p; if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f) { /* prevent duplicates */ p = gCallBackFirst; while (p) { if ((p->pi == pi) && (p->gpio == user_gpio) && (p->edge == edge) && (p->f == f)) { return pigif_duplicate_callback; } p = p->next; } p = malloc(sizeof(callback_t)); if (p) { if (!gCallBackFirst) gCallBackFirst = p; p->id = id++; p->pi = pi; p->gpio = user_gpio; p->edge = edge; p->f = f; p->user = user; p->ex = ex; p->next = 0; p->prev = gCallBackLast; if (p->prev) (p->prev)->next = p; gCallBackLast = p; findNotifyBits(pi); return p->id; } return pigif_bad_malloc; } return pigif_bad_callback; } static void findEventBits(int pi) { evtCallback_t *ep; uint32_t bits = 0; ep = geCallBackFirst; while (ep) { if (ep->pi == pi) bits |= (1<<(ep->event)); ep = ep->next; } if (bits != gEventBits[pi]) { gEventBits[pi] = bits; pigpio_command(pi, PI_CMD_EVM, gPigHandle[pi], gEventBits[pi], 1); } } static void _ewfe( int pi, unsigned event, uint32_t tick, void *user) { *(int *)user = 1; } static int intEventCallback( int pi, unsigned event, void *f, void *user, int ex) { static int id = 0; evtCallback_t *ep; if ((event >=0) && (event < 32) && f) { /* prevent duplicates */ ep = geCallBackFirst; while (ep) { if ((ep->pi == pi) && (ep->event == event) && (ep->f == f)) { return pigif_duplicate_callback; } ep = ep->next; } ep = malloc(sizeof(evtCallback_t)); if (ep) { if (!geCallBackFirst) geCallBackFirst = ep; ep->id = id++; ep->pi = pi; ep->event = event; ep->f = f; ep->user = user; ep->ex = ex; ep->next = 0; ep->prev = geCallBackLast; if (ep->prev) (ep->prev)->next = ep; geCallBackLast = ep; findEventBits(pi); return ep->id; } return pigif_bad_malloc; } return pigif_bad_callback; } static int recvMax(int pi, void *buf, int bufsize, int sent) { /* Copy at most bufSize bytes from the receieved message to buf. Discard the rest of the message. */ uint8_t scratch[4096]; int remaining, fetch, count; if (sent < bufsize) count = sent; else count = bufsize; if (count) recv(gPigCommand[pi], buf, count, MSG_WAITALL); remaining = sent - count; while (remaining) { fetch = remaining; if (fetch > sizeof(scratch)) fetch = sizeof(scratch); recv(gPigCommand[pi], scratch, fetch, MSG_WAITALL); remaining -= fetch; } return count; } /* PUBLIC ----------------------------------------------------------------- */ double time_time(void) { struct timeval tv; double t; gettimeofday(&tv, 0); t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6); return t; } void time_sleep(double seconds) { struct timespec ts, rem; if (seconds > 0.0) { ts.tv_sec = seconds; ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9; while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem)) { /* copy remaining time to ts */ ts.tv_sec = rem.tv_sec; ts.tv_nsec = rem.tv_nsec; } } } char *pigpio_error(int errnum) { if (errnum > -1000) return cmdErrStr(errnum); else { switch(errnum) { case pigif_bad_send: return "failed to send to pigpiod"; case pigif_bad_recv: return "failed to receive from pigpiod"; case pigif_bad_getaddrinfo: return "failed to find address of pigpiod"; case pigif_bad_connect: return "failed to connect to pigpiod"; case pigif_bad_socket: return "failed to create socket"; case pigif_bad_noib: return "failed to open notification in band"; case pigif_duplicate_callback: return "identical callback exists"; case pigif_bad_malloc: return "failed to malloc"; case pigif_bad_callback: return "bad callback parameter"; case pigif_notify_failed: return "failed to create notification thread"; case pigif_callback_not_found: return "callback not found"; case pigif_unconnected_pi: return "not connected to Pi"; case pigif_too_many_pis: return "too many connected Pis"; default: return "unknown error"; } } } unsigned pigpiod_if_version(void) { return PIGPIOD_IF2_VERSION; } pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata) { pthread_t *pth; pthread_attr_t pthAttr; pth = malloc(sizeof(pthread_t)); if (pth) { if (pthread_attr_init(&pthAttr)) { perror("pthread_attr_init failed"); free(pth); return NULL; } if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) { perror("pthread_attr_setstacksize failed"); free(pth); return NULL; } if (pthread_create(pth, &pthAttr, thread_func, userdata)) { perror("pthread_create socket failed"); free(pth); return NULL; } } return pth; } void stop_thread(pthread_t *pth) { if (pth) { pthread_cancel(*pth); pthread_join(*pth, NULL); free(pth); } } int pigpio_start(const char *addrStr, const char *portStr) { int pi; int *userdata; for (pi=0; pi<MAX_PI; pi++) { if (!gPiInUse[pi]) break; } if (pi >= MAX_PI) return pigif_too_many_pis; gPiInUse[pi] = 1; if ((!addrStr) || (!strlen(addrStr))) { addrStr = getenv(PI_ENVADDR); if ((!addrStr) || (!strlen(addrStr))) { addrStr = PI_DEFAULT_SOCKET_ADDR_STR; } } if ((!portStr) || (!strlen(portStr))) { portStr = getenv(PI_ENVPORT); if ((!portStr) || (!strlen(portStr))) { portStr = PI_DEFAULT_SOCKET_PORT_STR; } } pthread_mutex_init(&gCmdMutex[pi], NULL); gPigCommand[pi] = pigpioOpenSocket(addrStr, portStr); if (gPigCommand[pi] >= 0) { gPigNotify[pi] = pigpioOpenSocket(addrStr, portStr); if (gPigNotify[pi] >= 0) { gPigHandle[pi] = pigpio_notify(pi); if (gPigHandle[pi] < 0) return pigif_bad_noib; else { gLastLevel[pi] = read_bank_1(pi); /* must be freed by pthNotifyThread */ userdata = malloc(sizeof(*userdata)); *userdata = pi; gPthNotify[pi] = start_thread(pthNotifyThread, userdata); if (gPthNotify[pi]) return pi; else return pigif_notify_failed; } } else return gPigNotify[pi]; } else return gPigCommand[pi]; } void pigpio_stop(int pi) { if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return; if (gPthNotify[pi]) { stop_thread(gPthNotify[pi]); gPthNotify[pi] = 0; } if (gPigCommand[pi] >= 0) { if (gPigHandle[pi] >= 0) { pigpio_command(pi, PI_CMD_NC, gPigHandle[pi], 0, 1); gPigHandle[pi] = -1; } close(gPigCommand[pi]); gPigCommand[pi] = -1; } if (gPigNotify[pi] >= 0) { close(gPigNotify[pi]); gPigNotify[pi] = -1; } gPiInUse[pi] = 0; } int set_mode(int pi, unsigned gpio, unsigned mode) {return pigpio_command(pi, PI_CMD_MODES, gpio, mode, 1);} int get_mode(int pi, unsigned gpio) {return pigpio_command(pi, PI_CMD_MODEG, gpio, 0, 1);} int set_pull_up_down(int pi, unsigned gpio, unsigned pud) {return pigpio_command(pi, PI_CMD_PUD, gpio, pud, 1);} int gpio_read(int pi, unsigned gpio) {return pigpio_command(pi, PI_CMD_READ, gpio, 0, 1);} int gpio_write(int pi, unsigned gpio, unsigned level) {return pigpio_command(pi, PI_CMD_WRITE, gpio, level, 1);} int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle) {return pigpio_command(pi, PI_CMD_PWM, user_gpio, dutycycle, 1);} int get_PWM_dutycycle(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_GDC, user_gpio, 0, 1);} int set_PWM_range(int pi, unsigned user_gpio, unsigned range) {return pigpio_command(pi, PI_CMD_PRS, user_gpio, range, 1);} int get_PWM_range(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_PRG, user_gpio, 0, 1);} int get_PWM_real_range(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_PRRG, user_gpio, 0, 1);} int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency) {return pigpio_command(pi, PI_CMD_PFS, user_gpio, frequency, 1);} int get_PWM_frequency(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_PFG, user_gpio, 0, 1);} int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth) {return pigpio_command(pi, PI_CMD_SERVO, user_gpio, pulsewidth, 1);} int get_servo_pulsewidth(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_GPW, user_gpio, 0, 1);} int notify_open(int pi) {return pigpio_command(pi, PI_CMD_NO, 0, 0, 1);} int notify_begin(int pi, unsigned handle, uint32_t bits) {return pigpio_command(pi, PI_CMD_NB, handle, bits, 1);} int notify_pause(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_NB, handle, 0, 1);} int notify_close(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_NC, handle, 0, 1);} int set_watchdog(int pi, unsigned user_gpio, unsigned timeout) {return pigpio_command(pi, PI_CMD_WDOG, user_gpio, timeout, 1);} uint32_t read_bank_1(int pi) {return pigpio_command(pi, PI_CMD_BR1, 0, 0, 1);} uint32_t read_bank_2(int pi) {return pigpio_command(pi, PI_CMD_BR2, 0, 0, 1);} int clear_bank_1(int pi, uint32_t levels) {return pigpio_command(pi, PI_CMD_BC1, levels, 0, 1);} int clear_bank_2(int pi, uint32_t levels) {return pigpio_command(pi, PI_CMD_BC2, levels, 0, 1);} int set_bank_1(int pi, uint32_t levels) {return pigpio_command(pi, PI_CMD_BS1, levels, 0, 1);} int set_bank_2(int pi, uint32_t levels) {return pigpio_command(pi, PI_CMD_BS2, levels, 0, 1);} int hardware_clock(int pi, unsigned gpio, unsigned frequency) {return pigpio_command(pi, PI_CMD_HC, gpio, frequency, 1);} int hardware_PWM(int pi, unsigned gpio, unsigned frequency, uint32_t dutycycle) { gpioExtent_t ext[1]; /* p1=gpio p2=frequency p3=4 ## extension ## uint32_t dutycycle */ ext[0].size = sizeof(dutycycle); ext[0].ptr = &dutycycle; return pigpio_command_ext( pi, PI_CMD_HP, gpio, frequency, sizeof(dutycycle), 1, ext, 1); } uint32_t get_current_tick(int pi) {return pigpio_command(pi, PI_CMD_TICK, 0, 0, 1);} uint32_t get_hardware_revision(int pi) {return pigpio_command(pi, PI_CMD_HWVER, 0, 0, 1);} uint32_t get_pigpio_version(int pi) {return pigpio_command(pi, PI_CMD_PIGPV, 0, 0, 1);} int wave_clear(int pi) {return pigpio_command(pi, PI_CMD_WVCLR, 0, 0, 1);} int wave_add_new(int pi) {return pigpio_command(pi, PI_CMD_WVNEW, 0, 0, 1);} int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses) { gpioExtent_t ext[1]; /* p1=0 p2=0 p3=pulses*sizeof(gpioPulse_t) ## extension ## gpioPulse_t[] pulses */ if (!numPulses) return 0; ext[0].size = numPulses * sizeof(gpioPulse_t); ext[0].ptr = pulses; return pigpio_command_ext( pi, PI_CMD_WVAG, 0, 0, ext[0].size, 1, ext, 1); } int wave_add_serial( int pi, unsigned user_gpio, unsigned baud, uint32_t databits, uint32_t stophalfbits, uint32_t offset, unsigned numChar, char *str) { uint8_t buf[12]; gpioExtent_t ext[2]; /* p1=user_gpio p2=baud p3=len+12 ## extension ## uint32_t databits uint32_t stophalfbits uint32_t offset char[len] str */ if (!numChar) return 0; memcpy(buf, &databits, 4); memcpy(buf+4, &stophalfbits, 4); memcpy(buf+8, &offset, 4); ext[0].size = sizeof(buf); ext[0].ptr = buf; ext[1].size = numChar; ext[1].ptr = str; return pigpio_command_ext(pi, PI_CMD_WVAS, user_gpio, baud, numChar+sizeof(buf), 2, ext, 1); } int wave_create(int pi) {return pigpio_command(pi, PI_CMD_WVCRE, 0, 0, 1);} int wave_create_and_pad(int pi, int percent) {return pigpio_command(pi, PI_CMD_WVCAP, percent, 0, 1);} int wave_delete(int pi, unsigned wave_id) {return pigpio_command(pi, PI_CMD_WVDEL, wave_id, 0, 1);} int wave_tx_start(int pi) /* DEPRECATED */ {return pigpio_command(pi, PI_CMD_WVGO, 0, 0, 1);} int wave_tx_repeat(int pi) /* DEPRECATED */ {return pigpio_command(pi, PI_CMD_WVGOR, 0, 0, 1);} int wave_send_once(int pi, unsigned wave_id) {return pigpio_command(pi, PI_CMD_WVTX, wave_id, 0, 1);} int wave_send_repeat(int pi, unsigned wave_id) {return pigpio_command(pi, PI_CMD_WVTXR, wave_id, 0, 1);} int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode) {return pigpio_command(pi, PI_CMD_WVTXM, wave_id, mode, 1);} int wave_chain(int pi, char *buf, unsigned bufSize) { gpioExtent_t ext[1]; /* p1=0 p2=0 p3=bufSize ## extension ## char buf[bufSize] */ ext[0].size = bufSize; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1); } int wave_tx_at(int pi) {return pigpio_command(pi, PI_CMD_WVTAT, 0, 0, 1);} int wave_tx_busy(int pi) {return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);} int wave_tx_stop(int pi) {return pigpio_command(pi, PI_CMD_WVHLT, 0, 0, 1);} int wave_get_micros(int pi) {return pigpio_command(pi, PI_CMD_WVSM, 0, 0, 1);} int wave_get_high_micros(int pi) {return pigpio_command(pi, PI_CMD_WVSM, 1, 0, 1);} int wave_get_max_micros(int pi) {return pigpio_command(pi, PI_CMD_WVSM, 2, 0, 1);} int wave_get_pulses(int pi) {return pigpio_command(pi, PI_CMD_WVSP, 0, 0, 1);} int wave_get_high_pulses(int pi) {return pigpio_command(pi, PI_CMD_WVSP, 1, 0, 1);} int wave_get_max_pulses(int pi) {return pigpio_command(pi, PI_CMD_WVSP, 2, 0, 1);} int wave_get_cbs(int pi) {return pigpio_command(pi, PI_CMD_WVSC, 0, 0, 1);} int wave_get_high_cbs(int pi) {return pigpio_command(pi, PI_CMD_WVSC, 1, 0, 1);} int wave_get_max_cbs(int pi) {return pigpio_command(pi, PI_CMD_WVSC, 2, 0, 1);} int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, uint32_t level) { gpioExtent_t ext[1]; /* p1=user_gpio p2=pulseLen p3=4 ## extension ## unsigned level */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &level; return pigpio_command_ext( pi, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext, 1); } int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady) {return pigpio_command(pi, PI_CMD_FG, user_gpio, steady, 1);} int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active) { gpioExtent_t ext[1]; /* p1=user_gpio p2=steady p3=4 ## extension ## unsigned active */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &active; return pigpio_command_ext( pi, PI_CMD_FN, user_gpio, steady, 4, 1, ext, 1); } int store_script(int pi, char *script) { unsigned len; gpioExtent_t ext[1]; /* p1=0 p2=0 p3=len ## extension ## char[len] script */ len = strlen(script); if (!len) return 0; ext[0].size = len; ext[0].ptr = script; return pigpio_command_ext(pi, PI_CMD_PROC, 0, 0, len, 1, ext, 1); } int run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param) { gpioExtent_t ext[1]; /* p1=script id p2=0 p3=numPar * 4 ## extension ## uint32_t[numPar] pars */ ext[0].size = 4 * numPar; ext[0].ptr = param; return pigpio_command_ext (pi, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1); } int update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param) { gpioExtent_t ext[1]; /* p1=script id p2=0 p3=numPar * 4 ## extension ## uint32_t[numPar] pars */ ext[0].size = 4 * numPar; ext[0].ptr = param; return pigpio_command_ext (pi, PI_CMD_PROCU, script_id, 0, numPar*4, 1, ext, 1); } int script_status(int pi, unsigned script_id, uint32_t *param) { int status; uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */ status = pigpio_command(pi, PI_CMD_PROCP, script_id, 0, 0); if (status > 0) { recvMax(pi, p, sizeof(p), status); status = p[0]; if (param) memcpy(param, p+1, sizeof(p)-4); } _pmu(pi); return status; } int stop_script(int pi, unsigned script_id) {return pigpio_command(pi, PI_CMD_PROCS, script_id, 0, 1);} int delete_script(int pi, unsigned script_id) {return pigpio_command(pi, PI_CMD_PROCD, script_id, 0, 1);} int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, uint32_t bbBits) { gpioExtent_t ext[1]; /* p1=user_gpio p2=baud p3=4 ## extension ## unsigned bbBits */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &bbBits; return pigpio_command_ext( pi, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1); } int bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize) { int bytes; bytes = pigpio_command(pi, PI_CMD_SLR, user_gpio, bufSize, 0); if (bytes > 0) { bytes = recvMax(pi, buf, bufSize, bytes); } _pmu(pi); return bytes; } int bb_serial_read_close(int pi, unsigned user_gpio) {return pigpio_command(pi, PI_CMD_SLRC, user_gpio, 0, 1);} int bb_serial_invert(int pi, unsigned user_gpio, unsigned invert) {return pigpio_command(pi, PI_CMD_SLRI, user_gpio, invert, 1);} int i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, uint32_t i2c_flags) { gpioExtent_t ext[1]; /* p1=i2c_bus p2=i2c_addr p3=4 ## extension ## uint32_t i2c_flags */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &i2c_flags; return pigpio_command_ext (pi, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext, 1); } int i2c_close(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_I2CC, handle, 0, 1);} int i2c_write_quick(int pi, unsigned handle, unsigned bit) {return pigpio_command(pi, PI_CMD_I2CWQ, handle, bit, 1);} int i2c_write_byte(int pi, unsigned handle, unsigned val) {return pigpio_command(pi, PI_CMD_I2CWS, handle, val, 1);} int i2c_read_byte(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_I2CRS, handle, 0, 1);} int i2c_write_byte_data(int pi, unsigned handle, unsigned reg, uint32_t val) { gpioExtent_t ext[1]; /* p1=handle p2=reg p3=4 ## extension ## uint32_t val */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &val; return pigpio_command_ext (pi, PI_CMD_I2CWB, handle, reg, 4, 1, ext, 1); } int i2c_write_word_data(int pi, unsigned handle, unsigned reg, uint32_t val) { gpioExtent_t ext[1]; /* p1=handle p2=reg p3=4 ## extension ## uint32_t val */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &val; return pigpio_command_ext (pi, PI_CMD_I2CWW, handle, reg, 4, 1, ext, 1); } int i2c_read_byte_data(int pi, unsigned handle, unsigned reg) {return pigpio_command(pi, PI_CMD_I2CRB, handle, reg, 1);} int i2c_read_word_data(int pi, unsigned handle, unsigned reg) {return pigpio_command(pi, PI_CMD_I2CRW, handle, reg, 1);} int i2c_process_call(int pi, unsigned handle, unsigned reg, uint32_t val) { gpioExtent_t ext[1]; /* p1=handle p2=reg p3=4 ## extension ## uint32_t val */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &val; return pigpio_command_ext (pi, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1); } int i2c_write_block_data( int pi, unsigned handle, unsigned reg, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=reg p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_I2CWK, handle, reg, count, 1, ext, 1); } int i2c_read_block_data(int pi, unsigned handle, unsigned reg, char *buf) { int bytes; bytes = pigpio_command(pi, PI_CMD_I2CRK, handle, reg, 0); if (bytes > 0) { bytes = recvMax(pi, buf, 32, bytes); } _pmu(pi); return bytes; } int i2c_block_process_call( int pi, unsigned handle, unsigned reg, char *buf, unsigned count) { int bytes; gpioExtent_t ext[1]; /* p1=handle p2=reg p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; bytes = pigpio_command_ext (pi, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, buf, 32, bytes); } _pmu(pi); return bytes; } int i2c_read_i2c_block_data( int pi, unsigned handle, unsigned reg, char *buf, uint32_t count) { int bytes; gpioExtent_t ext[1]; /* p1=handle p2=reg p3=4 ## extension ## uint32_t count */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &count; bytes = pigpio_command_ext (pi, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int i2c_write_i2c_block_data( int pi, unsigned handle, unsigned reg, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=reg p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_I2CWI, handle, reg, count, 1, ext, 1); } int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count) { int bytes; bytes = pigpio_command(pi, PI_CMD_I2CRD, handle, count, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int i2c_write_device(int pi, unsigned handle, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=0 p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_I2CWD, handle, 0, count, 1, ext, 1); } int i2c_zip( int pi, unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen) { int bytes; gpioExtent_t ext[1]; /* p1=handle p2=0 p3=inLen ## extension ## char inBuf[inLen] */ ext[0].size = inLen; ext[0].ptr = inBuf; bytes = pigpio_command_ext (pi, PI_CMD_I2CZ, handle, 0, inLen, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, outBuf, outLen, bytes); } _pmu(pi); return bytes; } int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud) { gpioExtent_t ext[1]; /* p1=SDA p2=SCL p3=4 ## extension ## uint32_t baud */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &baud; return pigpio_command_ext (pi, PI_CMD_BI2CO, SDA, SCL, 4, 1, ext, 1); } int bb_i2c_close(int pi, unsigned SDA) {return pigpio_command(pi, PI_CMD_BI2CC, SDA, 0, 1);} int bb_i2c_zip( int pi, unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen) { int bytes; gpioExtent_t ext[1]; /* p1=SDA p2=0 p3=inLen ## extension ## char inBuf[inLen] */ ext[0].size = inLen; ext[0].ptr = inBuf; bytes = pigpio_command_ext (pi, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, outBuf, outLen, bytes); } _pmu(pi); return bytes; } int bb_spi_open( int pi, unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, unsigned baud, unsigned spiFlags) { uint8_t buf[20]; gpioExtent_t ext[1]; /* p1=CS p2=0 p3=20 ## extension ## uint32_t MISO uint32_t MOSI uint32_t SCLK uint32_t baud uint32_t spiFlags */ ext[0].size = 20; ext[0].ptr = &buf; memcpy(buf + 0, &MISO, 4); memcpy(buf + 4, &MOSI, 4); memcpy(buf + 8, &SCLK, 4); memcpy(buf + 12, &baud, 4); memcpy(buf + 16, &spiFlags, 4); return pigpio_command_ext (pi, PI_CMD_BSPIO, CS, 0, 20, 1, ext, 1); } int bb_spi_close(int pi, unsigned CS) {return pigpio_command(pi, PI_CMD_BSPIC, CS, 0, 1);} int bb_spi_xfer( int pi, unsigned CS, char *txBuf, char *rxBuf, unsigned count) { int bytes; gpioExtent_t ext[1]; /* p1=CS p2=0 p3=count ## extension ## char txBuf[count] */ ext[0].size = count; ext[0].ptr = txBuf; bytes = pigpio_command_ext (pi, PI_CMD_BSPIX, CS, 0, count, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, rxBuf, count, bytes); } _pmu(pi); return bytes; } int spi_open(int pi, unsigned channel, unsigned speed, uint32_t flags) { gpioExtent_t ext[1]; /* p1=channel p2=speed p3=4 ## extension ## uint32_t flags */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &flags; return pigpio_command_ext (pi, PI_CMD_SPIO, channel, speed, 4, 1, ext, 1); } int spi_close(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_SPIC, handle, 0, 1);} int spi_read(int pi, unsigned handle, char *buf, unsigned count) { int bytes; bytes = pigpio_command (pi, PI_CMD_SPIR, handle, count, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int spi_write(int pi, unsigned handle, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=0 p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_SPIW, handle, 0, count, 1, ext, 1); } int spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count) { int bytes; gpioExtent_t ext[1]; /* p1=handle p2=0 p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = txBuf; bytes = pigpio_command_ext (pi, PI_CMD_SPIX, handle, 0, count, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, rxBuf, count, bytes); } _pmu(pi); return bytes; } int serial_open(int pi, char *dev, unsigned baud, unsigned flags) { int len; gpioExtent_t ext[1]; len = strlen(dev); /* p1=baud p2=flags p3=len ## extension ## char dev[len] */ ext[0].size = len; ext[0].ptr = dev; return pigpio_command_ext (pi, PI_CMD_SERO, baud, flags, len, 1, ext, 1); } int serial_close(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_SERC, handle, 0, 1);} int serial_write_byte(int pi, unsigned handle, unsigned val) {return pigpio_command(pi, PI_CMD_SERWB, handle, val, 1);} int serial_read_byte(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_SERRB, handle, 0, 1);} int serial_write(int pi, unsigned handle, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=0 p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_SERW, handle, 0, count, 1, ext, 1); } int serial_read(int pi, unsigned handle, char *buf, unsigned count) { int bytes; bytes = pigpio_command (pi, PI_CMD_SERR, handle, count, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int serial_data_available(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_SERDA, handle, 0, 1);} int custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned count) { gpioExtent_t ext[1]; /* p1=arg1 p2=arg2 p3=count ## extension ## char argx[count] */ ext[0].size = count; ext[0].ptr = argx; return pigpio_command_ext( pi, PI_CMD_CF1, arg1, arg2, count, 1, ext, 1); } int custom_2(int pi, unsigned arg1, char *argx, unsigned count, char *retBuf, uint32_t retMax) { int bytes; gpioExtent_t ext[1]; /* p1=arg1 p2=retMax p3=count ## extension ## char argx[count] */ ext[0].size = count; ext[0].ptr = argx; bytes = pigpio_command_ext (pi, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, retBuf, retMax, bytes); } _pmu(pi); return bytes; } int get_pad_strength(int pi, unsigned pad) {return pigpio_command(pi, PI_CMD_PADG, pad, 0, 1);} int set_pad_strength(int pi, unsigned pad, unsigned padStrength) {return pigpio_command(pi, PI_CMD_PADS, pad, padStrength, 1);} int shell_(int pi, char *scriptName, char *scriptString) { int ln, ls; gpioExtent_t ext[2]; ln = strlen(scriptName); ls = strlen(scriptString); /* p1=len(scriptName) p2=0 p3=len(scriptName) + len(scriptString) + 1 ## extension ## char[] */ ext[0].size = ln + 1; /* include null byte */ ext[0].ptr = scriptName; ext[1].size = ls; ext[1].ptr = scriptString; return pigpio_command_ext (pi, PI_CMD_SHELL, ln, 0, ln+ls+1, 2, ext, 1); } int file_open(int pi, char *file, unsigned mode) { int len; gpioExtent_t ext[1]; len = strlen(file); /* p1=mode p2=0 p3=len ## extension ## char file[len] */ ext[0].size = len; ext[0].ptr = file; return pigpio_command_ext (pi, PI_CMD_FO, mode, 0, len, 1, ext, 1); } int file_close(int pi, unsigned handle) {return pigpio_command(pi, PI_CMD_FC, handle, 0, 1);} int file_write(int pi, unsigned handle, char *buf, unsigned count) { gpioExtent_t ext[1]; /* p1=handle p2=0 p3=count ## extension ## char buf[count] */ ext[0].size = count; ext[0].ptr = buf; return pigpio_command_ext (pi, PI_CMD_FW, handle, 0, count, 1, ext, 1); } int file_read(int pi, unsigned handle, char *buf, unsigned count) { int bytes; bytes = pigpio_command (pi, PI_CMD_FR, handle, count, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom) { gpioExtent_t ext[1]; /* p1=handle p2=seekOffset p3=4 ## extension ## uint32_t seekFrom */ ext[0].size = sizeof(uint32_t); ext[0].ptr = &seekFrom; return pigpio_command_ext (pi, PI_CMD_FS, handle, seekOffset, 4, 1, ext, 1); } int file_list(int pi, char *fpat, char *buf, unsigned count) { int len; int bytes; gpioExtent_t ext[1]; len = strlen(fpat); /* p1=60000 p2=0 p3=len ## extension ## char fpat[len] */ ext[0].size = len; ext[0].ptr = fpat; bytes = pigpio_command_ext(pi, PI_CMD_FL, 60000, 0, len, 1, ext, 0); if (bytes > 0) { bytes = recvMax(pi, buf, count, bytes); } _pmu(pi); return bytes; } int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f) {return intCallback(pi, user_gpio, edge, f, 0, 0);} int callback_ex( int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user) {return intCallback(pi, user_gpio, edge, f, user, 1);} int callback_cancel(unsigned id) { callback_t *p; int pi; p = gCallBackFirst; while (p) { if (p->id == id) { pi = p->pi; if (p->prev) {p->prev->next = p->next;} else {gCallBackFirst = p->next;} if (p->next) {p->next->prev = p->prev;} else {gCallBackLast = p->prev;} free(p); findNotifyBits(pi); return 0; } p = p->next; } return pigif_callback_not_found; } int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout) { int triggered = 0; int id; double due; if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return pigif_unconnected_pi; if (timeout <= 0.0) return 0; due = time_time() + timeout; id = callback_ex(pi, user_gpio, edge, _wfe, &triggered); while (!triggered && (time_time() < due)) time_sleep(0.05); callback_cancel(id); return triggered; } int bsc_xfer(int pi, bsc_xfer_t *bscxfer) { int bytes; int status; gpioExtent_t ext[1]; /* p1=control p2=0 p3=len ## extension ## char buf[len] */ ext[0].size = bscxfer->txCnt; ext[0].ptr = bscxfer->txBuf; bytes = pigpio_command_ext (pi, PI_CMD_BSCX, bscxfer->control, 0, bscxfer->txCnt, 1, ext, 0); if (bytes > 0) { recvMax(pi, &status, 4, 4); status = ntohl(status); bytes -= 4; bytes = recvMax(pi, bscxfer->rxBuf, sizeof(bscxfer->rxBuf), bytes); bscxfer->rxCnt = bytes; } else { status = bytes; } _pmu(pi); return status; } int bsc_i2c(int pi, int i2c_addr, bsc_xfer_t *bscxfer) { int control = 0; if (i2c_addr) control = (i2c_addr<<16) | 0x305; bscxfer->control = control; return bsc_xfer(pi, bscxfer); } int event_callback(int pi, unsigned event, evtCBFunc_t f) {return intEventCallback(pi, event, f, 0, 0);} int event_callback_ex( int pi, unsigned event, evtCBFuncEx_t f, void *user) {return intEventCallback(pi, event, f, user, 1);} int event_callback_cancel(unsigned id) { evtCallback_t *ep; int pi; ep = geCallBackFirst; while (ep) { if (ep->id == id) { pi = ep->pi; if (ep->prev) {ep->prev->next = ep->next;} else {geCallBackFirst = ep->next;} if (ep->next) {ep->next->prev = ep->prev;} else {geCallBackLast = ep->prev;} free(ep); findEventBits(pi); return 0; } ep = ep->next; } return pigif_callback_not_found; } int wait_for_event(int pi, unsigned event, double timeout) { int triggered = 0; int id; double due; if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return pigif_unconnected_pi; if (timeout <= 0.0) return 0; due = time_time() + timeout; id = event_callback_ex(pi, event, _ewfe, &triggered); while (!triggered && (time_time() < due)) time_sleep(0.05); event_callback_cancel(id); return triggered; } int event_trigger(int pi, unsigned event) {return pigpio_command(pi, PI_CMD_EVT, event, 0, 1);}
a84256091c810b7e22ac55a352291ae868b38772
f42190636add23ead6a5022d706a124032d66f92
/src/Microsoft.DotNet.Wpf/src/WpfGfx/include/spec_string.h
33e66178b54e0298a5ec8232e06b5179029e34d6
[ "MIT" ]
permissive
dotnet/wpf
b8f73a99e03f87b4dee5db643e38e2c0704f707a
2ff355a607d79eef5fea7796de1f29cf9ea4fbed
refs/heads/main
2023-09-04T09:35:19.355384
2023-09-03T02:30:37
2023-09-03T02:30:37
153,711,945
6,927
1,397
MIT
2023-09-14T17:22:06
2018-10-19T01:55:23
C#
UTF-8
C
false
false
26,718
h
spec_string.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. //+--------------------------------------------------------------------------- // // // Abstract: Additional SAL macros not provided by SpecStrings.h // #pragma once #if !defined(__midl) && defined(_PREFAST_) && _MSC_VER >= 1000 // --------------------------------------------------------------------------- // In Out Parameter Annotations with Different Opt Specifications #define __deref_inout_ecount_inopt(size) __deref_inout_ecount(size) __pre __deref __exceptthat __maybenull #define __deref_inout_ecount_outopt(size) __deref_inout_ecount(size) __post __deref __exceptthat __maybenull // --------------------------------------------------------------------------- // Readonly Result Buffer Annotations // // ***NOTE***: Pre-fix/fast does not currently support the notion of returning // a read-only buffer. When it does, we can change the definition of __returnro // appropriately. // // _returnro/_outro annoations are similar to _out annotations except the // caller may not modify the buffer post call. // // These annotations are often useful when the callee is providing special // access via return to a buffer. Such buffers are often still owned by the // callee and attention should be paid to their use in the caller. // // --------------------------------------------------------------------------- // Readonly Result Buffer Annotation Examples // // __returnro RECT const *GetRectRef(); bool // GetRectRef(__deref_outro_ecount(1) RECT const **ppOut); // // The caller would have readonly access to a RECT provided by // GetRectRef, and quite likey GetRectRef still controls the lifetime // of the buffer although the annotation doesn't specify either way. // // ---------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Helper Macro Definitions // // These express behavior common to many of the high-level annotations. // DO NOT USE THESE IN YOUR CODE. // --------------------------------------------------------------------------- // // __pre commented out to work around prefast assert bug. #define __inner_pre_only_writableTo(sizeType, size) /*__pre*/ __##sizeType##_writableTo(size) // --------------------------------------------------------------------------- // // Readonly result buffers of multiple elements/bytes // --------------------------------------------------------------------------- #define __returnro_ecount(esize) __notnull __post __valid __post __elem_readableTo(esize) #define __returnro_bcount(bsize) __notnull __post __valid __post __byte_readableTo(bsize) #define __returnro_xcount(xsize) __notnull __post __valid __post __inexpressible_readableTo(xsize) #define __returnro_ecount_opt(esize) __returnro_ecount(esize) __exceptthat __maybenull #define __returnro_bcount_opt(bsize) __returnro_bcount(bsize) __exceptthat __maybenull #define __returnro_xcount_opt(xsize) __returnro_xcount(xsize) __exceptthat __maybenull #define __outro_ecount(esize) __notnull __inner_pre_only_writableTo(elem, esize) __post __valid __post __elem_readableTo(esize) #define __outro_bcount(bsize) __notnull __inner_pre_only_writableTo(byte, bsize) __post __valid __post __byte_readableTo(bsize) #define __outro_xcount(xsize) __notnull __inner_pre_only_writableTo(inexpressible, xsize) __post __valid __post __inexpressible_readableTo(xsize) #define __outro_ecount_opt(esize) __outro_ecount(esize) __exceptthat __maybenull #define __outro_bcount_opt(bsize) __outro_bcount(bsize) __exceptthat __maybenull #define __outro_xcount_opt(xsize) __outro_xcount(xsize) __exceptthat __maybenull #define __deref_outro_ecount(esize) __ecount(1) __post __elem_readableTo(1) __post __deref __notnull __post __deref __valid __post __deref __inner_pre_only_writableTo(elem, esize) #define __deref_outro_bcount(bsize) __ecount(1) __post __elem_readableTo(1) __post __deref __notnull __post __deref __valid __post __deref __inner_pre_only_writableTo(byte, bsize) #define __deref_outro_xcount(xsize) __ecount(1) __post __elem_readableTo(1) __post __deref __notnull __post __deref __valid __post __deref __inner_pre_only_writableTo(inexpressible, xsize) #define __deref_outro_ecount_opt(esize) __deref_outro_ecount(esize) __post __deref __exceptthat __maybenull #define __deref_outro_bcount_opt(bsize) __deref_outro_bcount(bsize) __post __deref __exceptthat __maybenull #define __deref_outro_xcount_opt(xsize) __deref_outro_xcount(xsize) __post __deref __exceptthat __maybenull // --------------------------------------------------------------------------- // // Readonly result buffers of single elements - implicit _ecount(1) // #define __returnro __returnro_ecount(1) #define __returnro_opt __returnro __exceptthat __maybenull #define __outro __outro_ecount(1) #define __outro_opt __outro __exceptthat __maybenull // --------------------------------------------------------------------------- // Pointer Buffer Annotations // // _pcount annotations are similar to _deref except that that instead of // and implict single pointer (or reference) _pcount has an explicit count of // pointers (multiple references are not allowed by the C++ language). // // A common need for _pcount annotation is multidimensional arrays, where the // structure consists of an array of pointers each of which points to an // array of elements. In this case psize would represent the first order // dimension to the array and esize or bsize would represnt the second order // dimension to yield a psize x esize or psize x bsize array, respectively. // // The annotation breakdown table now has pcount added to the Level compoment. // // |-------------|------------|---------|--------|----------|---------------| // | Level | Usage | Size | Output | Optional | Parameters | // |-------------|------------|---------|--------|----------|---------------| // | <> | <> | <> | <> | <> | <> | // | _deref | _in | _ecount | _full | _opt | (size) | // | _deref_opt | _out | _bcount | _part | | (size,length) | // | _pcount | _inout | | | | | // | _pcount_opt | | | | | | // | | | | | | | // |-------------|------------|---------|--------|----------|---------------| // // Level: Describes the buffer pointer's level of indirection from the // parameter or return value 'p'. // // <> : p is the buffer pointer. // _deref : *p is the buffer pointer. p must not be NULL. // _deref_opt : *p may be the buffer pointer. p may be NULL, in which case // the rest of the annotation is ignored. // _pcount : *p is the first point in the buffer of psize pointers. // p must not be NULL. // _pcount_opt : *p may be the first point in the buffer of psize pointers. // p may be NULL, in which case the rest of the annotation // is ignored. // // One difference from _deref is that _pcount will have an explicit usage // prefix of _in, _out, or _inout; whereas _deref has an implicit usage // derived from the remainder of the annotation. // // The remaining portion of the annotations apply to each pointer in the // buffer of pointers. // // Note because validity of pointer types are understood fully what would be // annotated as valid for a non-pointer type is explicitly annotated as // notnull for the pointers in a buffer of pointers. // // Simplified _pcount annotations in the absence of an _ecount or _bcount // there is an implied _ecount(1). These simplified _pcount annotations // should be used when there is a buffer of pointers, but the pointers // themselves do reference anything more complex than a single element. // // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Helper Macro Definitions // // These express behavior common to many of the high-level annotations. // DO NOT USE THESE IN YOUR CODE. // --------------------------------------------------------------------------- #define __inner_in_pcount(psize) __in_ecount(psize) __pre __deref __notnull #define __inner_in_pcount_opt(psize) __in_ecount_opt(psize) __pre __deref __notnull #define __inner_inout_pcount(psize) __inout_ecount(psize) __pre __deref __notnull __post __deref __valid // --------------------------------------------------------------------------- // // In buffer of pointers to buffers of elements // // Nothing optional #define __in_pcount_in_ecount(psize,esize) __inner_in_pcount(psize) __pre __deref __elem_readableTo(esize) __pre __deref __valid __pre __deref __deref __readonly #define __in_pcount_ecount(psize,esize) __inner_in_pcount(psize) __pre __deref __elem_writableTo(esize) #define __in_pcount_out_ecount(psize,esize) __in_pcount_ecount(psize,esize) __post __deref __valid #define __in_pcount_out_ecount_part(psize,esize,elength) __in_pcount_out_ecount(psize,esize) __post __deref __elem_readableTo(elength) #define __in_pcount_out_ecount_full(psize,esize) __in_pcount_out_ecount_part(psize,esize,esize) #define __in_pcount_inout_ecount(psize,esize) __in_pcount_out_ecount(psize,esize) __pre __deref __valid #define __in_pcount_inout_ecount_part(psize,esize,elength) __in_pcount_out_ecount_part(psize,esize,elength) __pre __deref __valid __pre __deref __elem_readableTo(elength) #define __in_pcount_inout_ecount_full(psize,esize) __in_pcount_inout_ecount_part(psize,esize,esize) // Dereferenced buffer(s) are optional #define __in_pcount_in_ecount_opt(psize,esize) __in_pcount_in_ecount(psize,esize) __deref __exceptthat __maybenull #define __in_pcount_ecount_opt(psize,esize) __in_pcount_ecount(psize,esize) __deref __exceptthat __maybenull #define __in_pcount_out_ecount_opt(psize,esize) __in_pcount_out_ecount(psize,esize) __deref __exceptthat __maybenull #define __in_pcount_out_ecount_part_opt(psize,esize,elength) __in_pcount_out_ecount_part(psize,esize,elength) __deref __exceptthat __maybenull #define __in_pcount_out_ecount_full_opt(psize,esize) __in_pcount_out_ecount_full(psize,esize) __deref __exceptthat __maybenull #define __in_pcount_inout_ecount_opt(psize,esize) __in_pcount_inout_ecount(psize,esize) __deref __exceptthat __maybenull #define __in_pcount_inout_ecount_part_opt(psize,esize,elength) __in_pcount_inout_ecount_part(psize,esize,elength) __deref __exceptthat __maybenull #define __in_pcount_inout_ecount_full_opt(psize,esize) __in_pcount_inout_ecount_full(psize,esize) __deref __exceptthat __maybenull // Buffer of pointers is optional // ... #define __in_pcount_opt_ecount(psize,esize) __in_pcount_opt(psize) __pre __deref __elem_writableTo(esize) // ... // Everything is optional // ... #define __in_pcount_opt_ecount_opt(psize,esize) __in_pcount_opt_ecount(psize,esize) __deref __exceptthat __maybenull // ... // --------------------------------------------------------------------------- // // In buffer of pointers to single elements // #define __in_pcount_in(psize) __in_pcount_in_ecount(psize,1) #define __in_pcount(psize) __in_pcount_ecount(psize,1) #define __in_pcount_out(psize) __in_pcount_out_ecount_full(psize,1) #define __in_pcount_inout(psize) __in_pcount_inout_ecount_full(psize,1) #define __in_pcount_in_opt(psize) __in_pcount_in_ecount_opt(psize,1) #define __in_pcount_out_opt(psize) __in_pcount_out_ecount_full_opt(psize,1) #define __in_pcount_inout_opt(psize) __in_pcount_inout_ecount_full_opt(psize,1) #define __in_pcount_opt_in(psize) __in_pcount_in_ecount(psize,1) __exceptthat __maybenull #define __in_pcount_opt(psize) __in_pcount_ecount(psize,1) __exceptthat __maybenull #define __in_pcount_opt_out(psize) __in_pcount_out_ecount_full(psize,1) __exceptthat __maybenull #define __in_pcount_opt_inout(psize) __in_pcount_inout_ecount_full(psize,1) __exceptthat __maybenull #define __in_pcount_opt_in_opt(psize) __in_pcount_in_ecount_opt(psize,1) __exceptthat __maybenull #define __in_pcount_opt_out_opt(psize) __in_pcount_out_ecount_full_opt(psize,1) __exceptthat __maybenull #define __in_pcount_opt_inout_opt(psize) __in_pcount_inout_ecount_full_opt(psize,1) __exceptthat __maybenull // --------------------------------------------------------------------------- // // In buffer of pointers to buffers of bytes // // Nothing optional #define __in_pcount_in_bcount(psize,bsize) __inner_in_pcount(psize) __pre __deref __byte_readableTo(bsize) __pre __deref __valid __pre __deref __deref __readonly #define __in_pcount_bcount(psize,bsize) __inner_in_pcount(psize) __pre __deref __byte_writableTo(bsize) #define __in_pcount_out_bcount(psize,bsize) __in_pcount_bcount(psize,bsize) __post __deref __valid #define __in_pcount_out_bcount_part(psize,bsize,blength) __in_pcount_out_bcount(psize,bsize) __post __deref __byte_readableTo(blength) #define __in_pcount_out_bcount_full(psize,bsize) __in_pcount_out_bcount_part(psize,bsize,bsize) #define __in_pcount_inout_bcount(psize,bsize) __in_pcount_out_bcount(psize,bsize) __pre __deref __valid #define __in_pcount_inout_bcount_part(psize,bsize,blength) __in_pcount_out_bcount_part(psize,bsize,blength) __pre __deref __valid __pre __deref __byte_readableTo(blength) #define __in_pcount_inout_bcount_full(psize,bsize) __in_pcount_inout_bcount_part(psize,bsize,bsize) // ... #define __in_pcount_bcount_opt(psize,bsize) __in_pcount_bcount(psize,bsize) __deref __exceptthat __maybenull #define __in_pcount_opt_bcount(psize,bsize) __in_pcount_opt(psize) __pre __deref __byte_writableTo(bsize) #define __in_pcount_opt_bcount_opt(psize,bsize) __in_pcount_opt_bcount(psize,bsize) __deref __exceptthat __maybenull // ... // --------------------------------------------------------------------------- // // Out buffer of pointers to buffers of elements // // Dereferenced buffers are not initialized (just allocated) #define __out_pcount_ecount(psize,esize) __ecount(psize) __post __deref __notnull __post __deref __elem_writableTo(esize) #define __out_pcount_part_ecount(psize,plength,esize) __out_pcount_ecount(psize,esize) __post __elem_readableTo(plength) #define __out_pcount_full_ecount(psize,esize) __out_pcount_part_ecount(psize,psize,esize) // Dereferenced buffers are initialized #define __out_pcount_out_ecount(psize,esize) __out_pcount_ecount(psize,esize) __post __deref __valid #define __out_pcount_out_ecount_part(psize,esize,elength) __out_pcount_out_ecount(psize,esize) __post __deref __elem_readableTo(elength) #define __out_pcount_out_ecount_full(psize,esize) __out_pcount_out_ecount_part(psize,esize,esize) #define __out_pcount_part_out_ecount(psize,plength,esize) __out_pcount_part_ecount(psize,plength,esize) __post __deref __valid #define __out_pcount_part_out_ecount_part(psize,plength,esize,elength) __out_pcount_part_out_ecount(psize,plength,esize) __post __deref __elem_readableTo(elength) #define __out_pcount_part_out_ecount_full(psize,plength,esize) __out_pcount_part_out_ecount_part(psize,plength,esize,esize) #define __out_pcount_full_out_ecount(psize,esize) __out_pcount_part_out_ecount(psize,psize,esize) #define __out_pcount_full_out_ecount_part(psize,esize,elength) __out_pcount_part_out_ecount_part(psize,psize,esize,elength) #define __out_pcount_full_out_ecount_full(psize,esize) __out_pcount_part_out_ecount_full(psize,psize,esize) // --------------------------------------------------------------------------- // // Out buffer of pointers to single elements // // Dereferenced elements are not initialized (just allocated) #define __out_pcount(psize) __out_pcount_ecount(psize,1) #define __out_pcount_part(psize,plength) __out_pcount_part_ecount(psize,plength,1) #define __out_pcount_full(psize) __out_pcount_part(psize,psize) // Dereferenced elements are initialized #define __out_pcount_out(psize) __out_pcount_out_ecount_full(psize,1) #define __out_pcount_part_out(psize,plength) __out_pcount_part_out_ecount_full(psize,plength,1) #define __out_pcount_full_out(psize) __out_pcount_part_out(psize,psize) // --------------------------------------------------------------------------- // // Out buffer of pointers to buffers of bytes // // Dereferenced buffers are not initialized (just allocated) #define __out_pcount_bcount(psize,bsize) __ecount(psize) __post __deref __notnull __post __deref __byte_writableTo(bsize) #define __out_pcount_part_bcount(psize,plength,bsize) __out_pcount_bcount(psize,bsize) __post __byte_readableTo(plength) #define __out_pcount_full_bcount(psize,bsize) __out_pcount_part_bcount(psize,psize,bsize) // Dereferenced buffers are initialized #define __out_pcount_out_bcount(psize,bsize) __out_pcount_bcount(psize,bsize) __post __deref __valid #define __out_pcount_out_bcount_part(psize,bsize,blength) __out_pcount_out_bcount(psize,bsize) __post __deref __byte_readableTo(blength) #define __out_pcount_out_bcount_full(psize,bsize) __out_pcount_out_bcount_part(psize,bsize,bsize) #define __out_pcount_part_out_bcount(psize,plength,bsize) __out_pcount_part_bcount(psize,plength,bsize) __post __deref __valid #define __out_pcount_part_out_bcount_part(psize,plength,bsize,blength) __out_pcount_part_out_bcount(psize,plength,bsize) __post __deref __byte_readableTo(blength) #define __out_pcount_part_out_bcount_full(psize,plength,bsize) __out_pcount_part_out_bcount_part(psize,plength,bsize,bsize) #define __out_pcount_full_out_bcount(psize,bsize) __out_pcount_part_out_bcount(psize,psize,bsize) #define __out_pcount_full_out_bcount_part(psize,bsize,blength) __out_pcount_part_out_bcount_part(psize,psize,bsize,blength) #define __out_pcount_full_out_bcount_full(psize,bsize) __out_pcount_part_out_bcount_full(psize,psize,bsize) #define __out_pcount_out_out_ecount(psize,esize) __out_pcount_out(psize) __post __deref __deref __notnull __post __deref __byte_writableTo(esize) __post __deref __deref __valid #define __out_pcount_out_out_ecount_part(psize,esize,elength) __out_pcount_out_out_ecount(psize,esize) __post __deref __deref __byte_readableTo(elength) #define __out_pcount_out_out_ecount_full(psize,esize) __out_pcount_out_out_ecount_part(psize,esize,esize) // --------------------------------------------------------------------------- // // InOut buffer of pointers to buffers ... // #define __inout_pcount_in_ecount(psize,esize) #define __inout_pcount_in(psize) #define __inout_pcount_in_bcount(psize,bsize) __inner_inout_pcount(psize) __pre __deref __byte_readableTo(bsize) __post __deref __byte_readableTo(bsize) #else #define __deref_inout_ecount_inopt(size) #define __deref_inout_ecount_outopt(size) #define __returnro_ecount(esize) #define __returnro_bcount(bsize) #define __returnro_xcount(xsize) #define __returnro_ecount_opt(esize) #define __returnro_bcount_opt(bsize) #define __returnro_xcount_opt(xsize) #define __outro_ecount(esize) #define __outro_bcount(bsize) #define __outro_xcount(xsize) #define __outro_ecount_opt(esize) #define __outro_bcount_opt(bsize) #define __outro_xcount_opt(xsize) #define __deref_outro_ecount(esize) #define __deref_outro_bcount(bsize) #define __deref_outro_xcount(xsize) #define __deref_outro_ecount_opt(esize) #define __deref_outro_bcount_opt(bsize) #define __deref_outro_xcount_opt(xsize) #define __returnro #define __returnro_opt #define __outro #define __outro_opt #define __in_pcount_in_ecount(psize,esize) #define __in_pcount_ecount(psize,esize) #define __in_pcount_out_ecount(psize,esize) #define __in_pcount_out_ecount_part(psize,esize,elength) #define __in_pcount_out_ecount_full(psize,esize) #define __in_pcount_inout_ecount(psize,esize) #define __in_pcount_inout_ecount_part(psize,esize,elength) #define __in_pcount_inout_ecount_full(psize,esize) #define __in_pcount_in_ecount_opt(psize,esize) #define __in_pcount_ecount_opt(psize,esize) #define __in_pcount_out_ecount_opt(psize,esize) #define __in_pcount_out_ecount_part_opt(psize,esize,elength) #define __in_pcount_out_ecount_full_opt(psize,esize) #define __in_pcount_inout_ecount_opt(psize,esize) #define __in_pcount_inout_ecount_part_opt(psize,esize,elength) #define __in_pcount_inout_ecount_full_opt(psize,esize) #define __in_pcount_opt_ecount(psize,esize) #define __in_pcount_opt_ecount_opt(psize,esize) #define __in_pcount_in(psize) #define __in_pcount(psize) #define __in_pcount_out(psize) #define __in_pcount_inout(psize) #define __in_pcount_in_opt(psize) #define __in_pcount_out_opt(psize) #define __in_pcount_inout_opt(psize) #define __in_pcount_opt_in(psize) #define __in_pcount_opt(psize) #define __in_pcount_opt_out(psize) #define __in_pcount_opt_inout(psize) #define __in_pcount_opt_in_opt(psize) #define __in_pcount_opt_out_opt(psize) #define __in_pcount_opt_inout_opt(psize) #define __in_pcount_in_bcount(psize,bsize) #define __in_pcount_bcount(psize,bsize) #define __in_pcount_out_bcount(psize,bsize) #define __in_pcount_out_bcount_part(psize,bsize,blength) #define __in_pcount_out_bcount_full(psize,bsize) #define __in_pcount_inout_bcount(psize,bsize) #define __in_pcount_inout_bcount_part(psize,bsize,blength) #define __in_pcount_inout_bcount_full(psize,bsize) #define __in_pcount_bcount_opt(psize,bsize) #define __in_pcount_opt_bcount(psize,bsize) #define __in_pcount_opt_bcount_opt(psize,bsize) #define __out_pcount_ecount(psize,esize) #define __out_pcount_part_ecount(psize,plength,esize) #define __out_pcount_full_ecount(psize,esize) #define __out_pcount_out_ecount(psize,esize) #define __out_pcount_out_ecount_part(psize,esize,elength) #define __out_pcount_out_ecount_full(psize,esize) #define __out_pcount_part_out_ecount(psize,plength,esize) #define __out_pcount_part_out_ecount_part(psize,plength,esize,elength) #define __out_pcount_part_out_ecount_full(psize,plength,esize) #define __out_pcount_full_out_ecount(psize,esize) #define __out_pcount_full_out_ecount_part(psize,esize,elength) #define __out_pcount_full_out_ecount_full(psize,esize) #define __out_pcount(psize) #define __out_pcount_part(psize,plength) #define __out_pcount_full(psize) #define __out_pcount_out(psize) #define __out_pcount_part_out(psize,plength) #define __out_pcount_full_out(psize) #define __out_pcount_bcount(psize,bsize) #define __out_pcount_part_bcount(psize,plength,bsize) #define __out_pcount_full_bcount(psize,bsize) #define __out_pcount_out_bcount(psize,bsize) #define __out_pcount_out_bcount_part(psize,bsize,blength) #define __out_pcount_out_bcount_full(psize,bsize) #define __out_pcount_part_out_bcount(psize,plength,bsize) #define __out_pcount_part_out_bcount_part(psize,plength,bsize,blength) #define __out_pcount_part_out_bcount_full(psize,plength,bsize) #define __out_pcount_full_out_bcount(psize,bsize) #define __out_pcount_full_out_bcount_part(psize,bsize,blength) #define __out_pcount_full_out_bcount_full(psize,bsize) #define __out_pcount_out_out_ecount(psize,esize) #define __out_pcount_out_out_ecount_part(psize,esize,elength) #define __out_pcount_out_out_ecount_full(psize,esize) #define __inout_pcount_in_ecount(psize,esize) #define __inout_pcount_in(psize) #define __inout_pcount_in_bcount(psize,bsize) #endif
79795bc5594e79c5e32304f60048d9f8b21f0a62
1efd2de8bf77ec00eb2fcaf5749278495946d920
/src/tests/ftest/cart/test_ep_cred_server.c
9f747aef6c2aa2b3ce426efb369848c6dd630644
[ "BSD-2-Clause", "BSD-2-Clause-Patent" ]
permissive
daos-stack/daos
6f55bf3061fd830d5b8d28506e1295e2d3a27c38
ed5eed5df43a68571afe123132a743824c02637a
refs/heads/master
2023-08-31T21:43:37.606145
2023-08-31T16:38:00
2023-08-31T16:38:00
69,390,670
631
300
NOASSERTION
2023-09-14T18:55:15
2016-09-27T19:21:29
C
UTF-8
C
false
false
1,956
c
test_ep_cred_server.c
/* * (C) Copyright 2018-2022 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ #include <semaphore.h> #include "crt_utils.h" #include "test_ep_cred_common.h" static void test_run(d_rank_t my_rank) { crt_init_options_t opt = {0}; crt_group_t *grp = NULL; uint32_t grp_size; int rc; DBG_PRINT("local group: %s remote group: %s\n", test.tg_local_group_name, test.tg_remote_group_name); opt.cio_use_credits = 1; opt.cio_ep_credits = test.tg_credits; rc = crtu_srv_start_basic(test.tg_local_group_name, &test.tg_crt_ctx, &test.tg_tid, &grp, &grp_size, &opt); D_ASSERT(rc == 0); DBG_PRINT("Server started, grp_size = %d\n", grp_size); rc = sem_init(&test.tg_token_to_proceed, 0, 0); D_ASSERTF(rc == 0, "sem_init() failed.\n"); rc = crt_proto_register(&my_proto_fmt_0); D_ASSERT(rc == 0); if (my_rank == 0) { rc = crt_group_config_save(NULL, true); D_ASSERTF(rc == 0, "crt_group_config_save() failed. rc: %d\n", rc); DBG_PRINT("Group config saved\n"); } rc = pthread_join(test.tg_tid, NULL); D_ASSERTF(rc == 0, "pthread_join failed. rc: %d\n", rc); DBG_PRINT("joined progress thread.\n"); rc = sem_destroy(&test.tg_token_to_proceed); D_ASSERTF(rc == 0, "sem_destroy() failed.\n"); if (my_rank == 0) { rc = crt_group_config_remove(NULL); D_ASSERTF(rc == 0, "crt_group_config_remove() failed. rc: %d\n", rc); } rc = crt_finalize(); D_ASSERTF(rc == 0, "crt_finalize() failed. rc: %d\n", rc); d_log_fini(); DBG_PRINT("exiting.\n"); } int main(int argc, char **argv) { char *env_self_rank; d_rank_t my_rank; int rc; rc = test_parse_args(argc, argv); if (rc != 0) { fprintf(stderr, "test_parse_args() failed, rc: %d.\n", rc); return rc; } env_self_rank = getenv("CRT_L_RANK"); my_rank = atoi(env_self_rank); /* rank, num_attach_retries, is_server, assert_on_error */ crtu_test_init(my_rank, 40, true, true); test_run(my_rank); return rc; }
9d7b39d86ade21085d2898ae21ff2a72cff1d95f
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/hpc/stand/include/machine/ansi.h
edefb656a7fb16c7bd11f25ea4c3675178b67188
[]
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
469
h
ansi.h
/* $NetBSD: ansi.h,v 1.2 2011/07/17 20:54:40 joerg Exp $ */ /* Windows CE architecture */ #include <machine/int_types.h> #define _BSD_CLOCK_T_ unsigned int /* clock() */ #define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ #define _BSD_SSIZE_T_ int /* byte count or error */ #define _BSD_CLOCKID_T_ int /* clockid_t */ #define _BSD_TIMER_T_ int /* timer_t */ #define _BSD_SUSECONDS_T_ int /* suseconds_t */ #define _BSD_USECONDS_T_ unsigned int /* useconds_t */
bfeb1906132d288bbb601ea7beba9dde9009ee3e
55540f3e86f1d5d86ef6b5d295a63518e274efe3
/toolchain/riscv/Linux/lib/gcc/riscv64-unknown-elf/10.2.0/plugin/include/gengtype.h
6e50d7a4919fac034ac0a3f12124c43631b6cc29
[ "Apache-2.0" ]
permissive
bouffalolab/bl_iot_sdk
bc5eaf036b70f8c65dd389439062b169f8d09daa
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
refs/heads/master
2023-08-31T03:38:03.369853
2023-08-16T08:50:33
2023-08-18T09:13:27
307,347,250
244
101
Apache-2.0
2023-08-28T06:29:02
2020-10-26T11:16:30
C
UTF-8
C
false
false
17,013
h
gengtype.h
/* Process source files and output type information. Copyright (C) 2002-2020 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC 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 GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #ifndef GCC_GENGTYPE_H #define GCC_GENGTYPE_H #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free #define OBSTACK_CHUNK_SIZE 0 /* Sets of accepted source languages like C, C++, Ada... are represented by a bitmap. */ typedef unsigned lang_bitmap; /* Variable length structure representing an input file. A hash table ensure uniqueness for a given input file name. The only function allocating input_file-s is input_file_by_name. */ struct input_file_st { struct outf* inpoutf; /* Cached corresponding output file, computed in get_output_file_with_visibility. */ lang_bitmap inpbitmap; /* The set of languages using this file. */ bool inpisplugin; /* Flag set for plugin input files. */ char inpname[1]; /* A variable-length array, ended by a null char. */ }; typedef struct input_file_st input_file; /* A file position, mostly for error messages. The FILE element may be compared using pointer equality. */ struct fileloc { const input_file *file; int line; }; /* Table of all input files and its size. */ extern const input_file** gt_files; extern size_t num_gt_files; /* A number of places use the name of this "gengtype.c" file for a location for things that we can't rely on the source to define. We also need to refer to the "system.h" file specifically. These two pointers are initialized early in main. */ extern input_file* this_file; extern input_file* system_h_file; /* Retrieve or create the input_file for a given name, which is a file path. This is the only function allocating input_file-s and it is hash-consing them. */ input_file* input_file_by_name (const char* name); /* For F an input_file, return the relative path to F from $(srcdir) if the latter is a prefix in F, NULL otherwise. */ const char *get_file_srcdir_relative_path (const input_file *inpf); /* Get the name of an input file. */ static inline const char* get_input_file_name (const input_file *inpf) { if (inpf) return inpf->inpname; return NULL; } /* Return a bitmap which has bit `1 << BASE_FILE_<lang>' set iff INPUT_FILE is used by <lang>. This function should be written to assume that a file _is_ used if the situation is unclear. If it wrongly assumes a file _is_ used, a linker error will result. If it wrongly assumes a file _is not_ used, some GC roots may be missed, which is a much harder-to-debug problem. */ static inline lang_bitmap get_lang_bitmap (const input_file* inpf) { if (inpf == NULL) return 0; return inpf->inpbitmap; } /* Set the bitmap returned by get_lang_bitmap. The only legitimate callers of this function are read_input_list & read_state_*. */ static inline void set_lang_bitmap (input_file* inpf, lang_bitmap n) { gcc_assert (inpf); inpf->inpbitmap = n; } /* Vector of per-language directories. */ extern const char **lang_dir_names; extern size_t num_lang_dirs; /* Data types handed around within, but opaque to, the lexer and parser. */ typedef struct pair *pair_p; typedef struct type *type_p; typedef const struct type *const_type_p; typedef struct options *options_p; /* Variables used to communicate between the lexer and the parser. */ extern int lexer_toplevel_done; extern struct fileloc lexer_line; /* Various things, organized as linked lists, needed both in gengtype.c & in gengtype-state.c files. */ extern pair_p typedefs; extern type_p structures; extern pair_p variables; /* An enum for distinguishing GGC vs PCH. */ enum write_types_kinds { WTK_GGC, WTK_PCH, NUM_WTK }; /* Discrimating kind of types we can understand. */ enum typekind { TYPE_NONE=0, /* Never used, so zeroed memory is invalid. */ TYPE_UNDEFINED, /* We have not yet seen a definition for this type. If a type is still undefined when generating code, an error will be generated. */ TYPE_SCALAR, /* Scalar types like char. */ TYPE_STRING, /* The string type. */ TYPE_STRUCT, /* Type for GTY-ed structs. */ TYPE_UNION, /* Type for GTY-ed discriminated unions. */ TYPE_POINTER, /* Pointer type to GTY-ed type. */ TYPE_ARRAY, /* Array of GTY-ed types. */ TYPE_LANG_STRUCT, /* GCC front-end language specific structs. Various languages may have homonymous but different structs. */ TYPE_USER_STRUCT /* User defined type. Walkers and markers for this type are assumed to be provided by the user. */ }; /* Discriminating kind for options. */ enum option_kind { OPTION_NONE=0, /* Never used, so zeroed memory is invalid. */ OPTION_STRING, /* A string-valued option. Most options are strings. */ OPTION_TYPE, /* A type-valued option. */ OPTION_NESTED /* Option data for 'nested_ptr'. */ }; /* A way to pass data through to the output end. */ struct options { struct options *next; /* next option of the same pair. */ const char *name; /* GTY option name. */ enum option_kind kind; /* discriminating option kind. */ union { const char* string; /* When OPTION_STRING. */ type_p type; /* When OPTION_TYPE. */ struct nested_ptr_data* nested; /* when OPTION_NESTED. */ } info; }; /* Option data for the 'nested_ptr' option. */ struct nested_ptr_data { type_p type; const char *convert_to; const char *convert_from; }; /* Some functions to create various options structures with name NAME and info INFO. NEXT is the next option in the chain. */ /* Create a string option. */ options_p create_string_option (options_p next, const char* name, const char* info); /* Create a type option. */ options_p create_type_option (options_p next, const char* name, type_p info); /* Create a nested option. */ options_p create_nested_option (options_p next, const char* name, struct nested_ptr_data* info); /* Create a nested pointer option. */ options_p create_nested_ptr_option (options_p next, type_p t, const char *to, const char *from); /* A name and a type. */ struct pair { pair_p next; /* The next pair in the linked list. */ const char *name; /* The defined name. */ type_p type; /* Its GTY-ed type. */ struct fileloc line; /* The file location. */ options_p opt; /* GTY options, as a linked list. */ }; /* Usage information for GTY-ed types. Gengtype has to care only of used GTY-ed types. Types are initially unused, and their usage is computed by set_gc_used_type and set_gc_used functions. */ enum gc_used_enum { /* We need that zeroed types are initially unused. */ GC_UNUSED=0, /* The GTY-ed type is used, e.g by a GTY-ed variable or a field inside a GTY-ed used type. */ GC_USED, /* For GTY-ed structures whose definitions we haven't seen so far when we encounter a pointer to it that is annotated with ``maybe_undef''. If after reading in everything we don't have source file information for it, we assume that it never has been defined. */ GC_MAYBE_POINTED_TO, /* For known GTY-ed structures which are pointed to by GTY-ed variables or fields. */ GC_POINTED_TO }; /* Our type structure describes all types handled by gengtype. */ struct type { /* Discriminating kind, cannot be TYPE_NONE. */ enum typekind kind; /* For top-level structs or unions, the 'next' field links the global list 'structures'; for lang_structs, their homonymous structs are linked using this 'next' field. The homonymous list starts at the s.lang_struct field of the lang_struct. See the new_structure function for details. This is tricky! */ type_p next; /* State number used when writing & reading the persistent state. A type with a positive number has already been written. For ease of debugging, newly allocated types have a unique negative number. */ int state_number; /* Each GTY-ed type which is pointed to by some GTY-ed type knows the GTY pointer type pointing to it. See create_pointer function. */ type_p pointer_to; /* Type usage information, computed by set_gc_used_type and set_gc_used functions. */ enum gc_used_enum gc_used; /* The following union is discriminated by the 'kind' field above. */ union { /* TYPE__NONE is impossible. */ /* when TYPE_POINTER: */ type_p p; /* when TYPE_STRUCT or TYPE_UNION or TYPE_LANG_STRUCT, we have an aggregate type containing fields: */ struct { const char *tag; /* the aggregate tag, if any. */ struct fileloc line; /* the source location. */ pair_p fields; /* the linked list of fields. */ options_p opt; /* the GTY options if any. */ lang_bitmap bitmap; /* the set of front-end languages using that GTY-ed aggregate. */ /* For TYPE_LANG_STRUCT, the lang_struct field gives the first element of a linked list of homonymous struct or union types. Within this list, each homonymous type has as its lang_struct field the original TYPE_LANG_STRUCT type. This is a dirty trick, see the new_structure function for details. */ type_p lang_struct; type_p base_class; /* the parent class, if any. */ /* The following two fields are not serialized in state files, and are instead reconstructed on load. */ /* The head of a singly-linked list of immediate descendents in the inheritance hierarchy. */ type_p first_subclass; /* The next in that list. */ type_p next_sibling_class; /* Have we already written ggc/pch user func for ptr to this? (in write_user_func_for_structure_ptr). */ bool wrote_user_func_for_ptr[NUM_WTK]; } s; /* when TYPE_SCALAR: */ bool scalar_is_char; /* when TYPE_ARRAY: */ struct { type_p p; /* The array component type. */ const char *len; /* The string if any giving its length. */ } a; } u; }; /* The one and only TYPE_STRING. */ extern struct type string_type; /* The two and only TYPE_SCALARs. Their u.scalar_is_char flags are set early in main. */ extern struct type scalar_nonchar; extern struct type scalar_char; /* Test if a type is a union, either a plain one or a language specific one. */ #define UNION_P(x) \ ((x)->kind == TYPE_UNION \ || ((x)->kind == TYPE_LANG_STRUCT \ && (x)->u.s.lang_struct->kind == TYPE_UNION)) /* Test if a type is a union or a structure, perhaps a language specific one. */ static inline bool union_or_struct_p (enum typekind kind) { return (kind == TYPE_UNION || kind == TYPE_STRUCT || kind == TYPE_LANG_STRUCT || kind == TYPE_USER_STRUCT); } static inline bool union_or_struct_p (const_type_p x) { return union_or_struct_p (x->kind); } /* Give the file location of a type, if any. */ static inline struct fileloc* type_fileloc (type_p t) { if (!t) return NULL; if (union_or_struct_p (t)) return &t->u.s.line; return NULL; } /* Structure representing an output file. */ struct outf { struct outf *next; const char *name; size_t buflength; size_t bufused; char *buf; }; typedef struct outf *outf_p; /* The list of output files. */ extern outf_p output_files; /* The output header file that is included into pretty much every source file. */ extern outf_p header_file; /* Print, like fprintf, to O. No-op if O is NULL. */ void oprintf (outf_p o, const char *S, ...) ATTRIBUTE_PRINTF_2; /* An output file, suitable for definitions, that can see declarations made in INPF and is linked into every language that uses INPF. May return NULL in plugin mode. The INPF argument is almost const, but since the result is cached in its inpoutf field it cannot be declared const. */ outf_p get_output_file_with_visibility (input_file* inpf); /* The name of an output file, suitable for definitions, that can see declarations made in INPF and is linked into every language that uses INPF. May return NULL. */ const char *get_output_file_name (input_file *inpf); /* Source directory. */ extern const char *srcdir; /* (-S) program argument. */ /* Length of srcdir name. */ extern size_t srcdir_len; /* Variable used for reading and writing the state. */ extern const char *read_state_filename; /* (-r) program argument. */ extern const char *write_state_filename; /* (-w) program argument. */ /* Functions reading and writing the entire gengtype state, called from main, and implemented in file gengtype-state.c. */ void read_state (const char* path); /* Write the state, and update the state_number field in types. */ void write_state (const char* path); /* Print an error message. */ extern void error_at_line (const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2; /* Constructor routines for types. */ extern void do_typedef (const char *s, type_p t, struct fileloc *pos); extern void do_scalar_typedef (const char *s, struct fileloc *pos); extern type_p resolve_typedef (const char *s, struct fileloc *pos); extern void add_subclass (type_p base, type_p subclass); extern type_p new_structure (const char *name, enum typekind kind, struct fileloc *pos, pair_p fields, options_p o, type_p base); type_p create_user_defined_type (const char *, struct fileloc *); extern type_p find_structure (const char *s, enum typekind kind); extern type_p create_scalar_type (const char *name); extern type_p create_pointer (type_p t); extern type_p create_array (type_p t, const char *len); extern pair_p create_field_at (pair_p next, type_p type, const char *name, options_p opt, struct fileloc *pos); extern pair_p nreverse_pairs (pair_p list); extern type_p adjust_field_type (type_p, options_p); extern void note_variable (const char *s, type_p t, options_p o, struct fileloc *pos); /* Lexer and parser routines. */ extern int yylex (const char **yylval); extern void yybegin (const char *fname); extern void yyend (void); extern void parse_file (const char *name); extern bool hit_error; /* Token codes. */ enum gty_token { EOF_TOKEN = 0, /* Per standard convention, codes in the range (0, UCHAR_MAX] represent single characters with those character codes. */ CHAR_TOKEN_OFFSET = UCHAR_MAX + 1, GTY_TOKEN = CHAR_TOKEN_OFFSET, TYPEDEF, EXTERN, STATIC, UNION, STRUCT, ENUM, ELLIPSIS, PTR_ALIAS, NESTED_PTR, USER_GTY, NUM, SCALAR, ID, STRING, CHAR, ARRAY, IGNORABLE_CXX_KEYWORD, /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have a meaningful value to be printed. */ FIRST_TOKEN_WITH_VALUE = USER_GTY }; /* Level for verbose messages, e.g. output file generation... */ extern int verbosity_level; /* (-v) program argument. */ /* For debugging purposes we provide two flags. */ /* Dump everything to understand gengtype's state. Might be useful to gengtype users. */ extern int do_dump; /* (-d) program argument. */ /* Trace the execution by many DBGPRINTF (with the position inside gengtype source code). Only useful to debug gengtype itself. */ extern int do_debug; /* (-D) program argument. */ #define DBGPRINTF(Fmt,...) do {if (do_debug) \ fprintf (stderr, "%s:%d: " Fmt "\n", \ lbasename (__FILE__),__LINE__, ##__VA_ARGS__);} while (0) void dbgprint_count_type_at (const char *, int, const char *, type_p); #define DBGPRINT_COUNT_TYPE(Msg,Ty) do {if (do_debug) \ dbgprint_count_type_at (__FILE__, __LINE__, Msg, Ty);}while (0) #define FOR_ALL_INHERITED_FIELDS(TYPE, FIELD_VAR) \ for (type_p sub = (TYPE); sub; sub = sub->u.s.base_class) \ for (FIELD_VAR = sub->u.s.fields; FIELD_VAR; FIELD_VAR = FIELD_VAR->next) extern bool opts_have (options_p opts, const char *str); #endif
40dfbb5208f68b52b00f58d4388e81e4785ee859
5816ae8b5fdfe9ab93b3653742b5d4c2a1567111
/hitcon-2021/mercy/src/mercy.c
17a117b112287c3d3310c1cd6442ebcd4204f844
[]
no_license
david942j/ctf-writeups
6c2ff633d80809e422f0263b8ac9a69607d31e84
a4d086684a939000286d0876dd29463ccdceea2e
refs/heads/master
2022-09-07T00:27:23.594820
2021-12-14T10:50:47
2021-12-14T10:50:47
77,058,219
316
49
null
null
null
null
UTF-8
C
false
false
1,352
c
mercy.c
#include <stdio.h> #include <string.h> #define FLAG_AT 0x04010000 #define false 0 #define true 1 typedef unsigned char uint8_t; static bool check(uint8_t *flag) { #define N 27 static uint8_t S[512]; int i; for (i = 0; i < 512; i++) S[i] = i; uint8_t j = 0; #define KLEN 9 static uint8_t key[KLEN] = { 299, 98, 188, 156, 59, 52, 273, 137, 324 }; for (i = 0; i < 512; i++) { j = (j + S[i] + key[i % KLEN]) % 512; S[i] ^= S[j] ^= S[i] ^= S[j]; } j = 0; uint8_t out[N], prev = 0; for (i = 0; i < N; i++) { j += S[i]; S[i] ^= S[j] ^= S[i] ^= S[j]; uint8_t t = S[i] + S[j]; out[i] = (flag[i] ^ S[t]) + prev; prev = out[i]; } /* for (i = 0; i < N; i += 3) printf("0x%x\n", *(int *)(out + i)); */ if (*(int *)(out + 24) != 0x0c7a45e) return false; if (*(int *)(out + 3) != 0x441d6a8) return false; if (*(int *)(out + 18) != 0x624e22d) return false; if (*(int *)(out + 15) != 0x6f30d11) return false; if (*(int *)(out + 12) != 0x40ff43f) return false; if (*(int *)(out + 0) != 0x4062ee8) return false; if (*(int *)(out + 21) != 0x183716f) return false; if (*(int *)(out + 6) != 0x69edf0e) return false; if (*(int *)(out + 9) != 0x7885b66) return false; return true; } int main() { if (check(FLAG_AT)) printf("Nice job: %s", FLAG_AT); else printf("NO\n"); return 0; }
d151020914a475bd43f29316ab8f3d40082ede5f
35c04ea32351dc95bc18d46e5c70dda9c1e08668
/Examples/MCUXpresso/K22FX512/K22FX512xxx12_FreeRTOS/source/Application.c
1a54ec04717639add7582aa57e397a43bda2f55e
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
ErichStyger/mcuoneclipse
0f8e7a2056a26ed79d9d4a0afd64777ff0b2b2fe
04ad311b11860ae5f8285316010961a87fa06d0c
refs/heads/master
2023-08-28T22:54:08.501719
2023-08-25T15:11:44
2023-08-25T15:11:44
7,446,094
620
1,191
NOASSERTION
2020-10-16T03:13:28
2013-01-04T19:38:12
Batchfile
UTF-8
C
false
false
518
c
Application.c
/* * Copyright (c) 2019, Erich Styger * * SPDX-License-Identifier: BSD-3-Clause */ #include "Application.h" #include "FreeRTOS.h" #include "task.h" #include <stdio.h> static void myTask(void *pvParameters) { for (;;) { vTaskDelay(pdMS_TO_TICKS(1000)); } } void APP_Run(void) { if (xTaskCreate(myTask, "myTask", 500/sizeof(StackType_t), NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { printf("ERROR: Creating task failed, not enough memory?\n"); for(;;){} } vTaskStartScheduler(); for(;;){} }
20e54d54a930da3f1e66c6b49c79f40e56cb5807
7df190df28da7e4ff166e55dc8ce780f11236a9f
/src/router/lighttpd/src/server.c
44385db11f74044c69a3cd2e6bd36695f93bb7c5
[ "BSD-3-Clause" ]
permissive
mirror/dd-wrt
25416946e6132aa54b35809de61834a1825a9a36
8f2934a5a2adfbb59b471375aa3a38de5d036531
refs/heads/master
2023-08-31T14:54:47.496685
2023-08-30T17:40:54
2023-08-30T17:40:54
7,470,282
520
281
null
2023-05-29T20:56:24
2013-01-06T17:21:29
null
UTF-8
C
false
false
69,855
c
server.c
#include "first.h" #include "base.h" #include "buffer.h" #include "network.h" #include "log.h" #include "rand.h" #include "chunk.h" #include "http_range.h" /* http_range_config_allow_http10() */ #include "fdevent.h" #include "fdlog.h" #include "connections.h" #include "sock_addr.h" #include "stat_cache.h" #include "plugin.h" #include "plugins.h" #include "plugin_config.h" /* config_plugin_value_tobool() */ #include "network_write.h" /* network_write_show_handlers() */ #include "reqpool.h" /* request_pool_init() request_pool_free() */ #include "response.h" /* http_dispatch[] strftime_cache_reset() */ #ifdef HAVE_VERSIONSTAMP_H # include "versionstamp.h" #else # define REPO_VERSION "" #endif #define PACKAGE_DESC PACKAGE_NAME "/" PACKAGE_VERSION REPO_VERSION static const buffer default_server_tag = { PACKAGE_DESC "\0server", sizeof(PACKAGE_DESC), 0 }; #include <sys/types.h> #include "sys-setjmp.h" #include "sys-stat.h" #include "sys-time.h" #include "sys-unistd.h" /* <unistd.h> */ #include <string.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <signal.h> #include <locale.h> #ifdef _WIN32 #include <mbctype.h> /* _setmbcp() */ #endif #include <stdio.h> #ifdef HAVE_GETOPT_H # include <getopt.h> #else /* basic (very limited) getopt() implementation */ extern char *optarg; extern int optind, opterr, optopt; char *optarg = NULL; int optind = 1, opterr = 1, optopt = 0; int getopt (int argc, char * const argv[], const char *optstring); int getopt (int argc, char * const argv[], const char *optstring) { static char *nextchar; optarg = NULL; if (optind >= argc || argc < 1) return -1; if (optind <= 1) nextchar = argv[(optind = 1)]; else if (nextchar == NULL) nextchar = argv[optind]; if (nextchar == argv[optind]) { if (*nextchar++ != '-' || nextchar[0] == '\0' /* "-" */ || (nextchar[0] == '-' && nextchar[1] == '\0')) { /* "--" */ return -1; } ++optind; } const char *o = optstring; if (*o == '+' || *o == '-') ++o; /*(ignore; behave as if '+' is set)*/ if (*o == ':') ++o; /*(ignore; behave as if ':' is set)*/ for (; *o; ++o) { if (*o == *nextchar) break; if (o[1] == ':') ++o; if (o[1] == ':') ++o; } if (!*o) { /* if (opterr) fprintf(stderr, "..."); */ optopt = *nextchar; return '?'; } if (!*++nextchar) nextchar = NULL; if (o[1] == ':') { if (nextchar) { optarg = nextchar; nextchar = NULL; } else if (optind < argc) optarg = argv[optind++]; else if (o[2] != ':') { /* if (opterr) fprintf(stderr, "..."); */ /*(fprintf if ':' not at beginning of optstring)*/ optopt = *o; return ':'; } } return *o; } #endif #ifdef HAVE_VALGRIND_VALGRIND_H # include <valgrind/valgrind.h> #endif #ifdef HAVE_PWD_H # include <grp.h> # include <pwd.h> #endif #ifdef HAVE_SYS_LOADAVG_H # include <sys/loadavg.h> #endif #ifdef HAVE_SYS_RESOURCE_H # include <sys/resource.h> #endif #ifdef HAVE_SYS_PRCTL_H # include <sys/prctl.h> #endif #ifdef HAVE_SYS_PROCCTL_H # include <sys/procctl.h> #endif #ifdef HAVE_PRIV_H # include <priv.h> #endif #ifdef HAVE_MALLOC_H #ifndef LIGHTTPD_STATIC #ifdef HAVE_DLFCN_H #include <dlfcn.h> #endif #endif #include <malloc.h> #if defined(HAVE_MALLOC_TRIM) static int(*malloc_trim_fn)(size_t); static size_t malloc_top_pad; #endif #endif #include "sys-crypto.h" #if defined(USE_OPENSSL_CRYPTO) \ || defined(USE_MBEDTLS_CRYPTO) \ || defined(USE_NSS_CRYPTO) \ || defined(USE_GNUTLS_CRYPTO) \ || defined(USE_WOLFTLS_CRYPTO) #define TEXT_SSL " (ssl)" #else #define TEXT_SSL #endif #ifndef __sgi /* IRIX doesn't like the alarm based time() optimization */ /* #define USE_ALARM */ #endif #ifdef _WIN32 /* (Note: assume overwrite == 1 in this setenv() replacement) */ /*#define setenv(name,value,overwrite) SetEnvironmentVariable((name),(value))*/ /*#define unsetenv(name) SetEnvironmentVariable((name),NULL)*/ #define setenv(name,value,overwrite) _putenv_s((name), strdup(value)) #define unsetenv(name) _putenv_s((name), "") #endif #include "h1.h" static const struct http_dispatch h1_1_dispatch_table = { .send_1xx = h1_send_1xx }; static int oneshot_fd = 0; static int oneshot_fdout = -1; static fdnode *oneshot_fdn = NULL; static int (*oneshot_read_cq)(connection *con, chunkqueue *cq, off_t max_bytes); static volatile int pid_fd = -2; static server_socket_array graceful_sockets; static server_socket_array inherited_sockets; static volatile sig_atomic_t graceful_restart = 0; static volatile sig_atomic_t graceful_shutdown = 0; static volatile sig_atomic_t srv_shutdown = 0; static volatile sig_atomic_t handle_sig_child = 0; static volatile sig_atomic_t handle_sig_alarm = 1; static volatile sig_atomic_t handle_sig_hup = 0; static int idle_limit = 0; __attribute_cold__ int server_main (int argc, char ** argv); #ifdef _WIN32 #ifndef SIGBREAK #define SIGBREAK 21 #endif /* Ctrl-BREAK (repurposed and treated as SIGUSR1)*/ #ifndef SIGUSR1 #define SIGUSR1 SIGBREAK #endif #include "server_win32.c" #endif #if defined(HAVE_SIGACTION) && defined(SA_SIGINFO) static volatile siginfo_t last_sigterm_info; static volatile siginfo_t last_sighup_info; static void sigaction_handler(int sig, siginfo_t *si, void *context) { static const siginfo_t empty_siginfo; UNUSED(context); if (!si) *(const siginfo_t **)&si = &empty_siginfo; switch (sig) { case SIGTERM: srv_shutdown = 1; last_sigterm_info = *si; break; case SIGUSR1: if (!graceful_shutdown) { graceful_restart = 1; graceful_shutdown = 1; last_sigterm_info = *si; } break; case SIGINT: if (graceful_shutdown) { if (2 == graceful_restart) graceful_restart = 1; else srv_shutdown = 1; } else { graceful_shutdown = 1; } last_sigterm_info = *si; break; case SIGALRM: handle_sig_alarm = 1; break; case SIGHUP: handle_sig_hup = 1; last_sighup_info = *si; break; case SIGCHLD: handle_sig_child = 1; break; } } #elif defined(HAVE_SIGNAL) || defined(HAVE_SIGACTION) static void signal_handler(int sig) { switch (sig) { case SIGTERM: srv_shutdown = 1; break; case SIGUSR1: if (!graceful_shutdown) { graceful_restart = 1; graceful_shutdown = 1; } break; case SIGINT: if (graceful_shutdown) { if (2 == graceful_restart) graceful_restart = 1; else srv_shutdown = 1; } else { graceful_shutdown = 1; } break; #ifndef _WIN32 case SIGALRM: handle_sig_alarm = 1; break; case SIGHUP: handle_sig_hup = 1; break; case SIGCHLD: handle_sig_child = 1; break; #endif } } #endif #if defined(HAVE_SIGNAL) #ifdef _WIN32 static BOOL WINAPI ConsoleCtrlHandler(DWORD dwType) { /* Note: Windows handles "signals" inconsistently, varying depending on * whether or not the program is attached to a non-hidden window. * CTRL_CLOSE_EVENT sent by taskkill can be received if attached to a * non-hidden window, but taskkill /f must be used (and CTRL_CLOSE_EVENT * is not received here) if process is not attached to a window, or if * the window is hidden. (WTH MS?!) This *does not* catch CTRL_CLOSE_EVENT: * start -FilePath .\lighttpd.exe -ArgumentList "-D -f lighttpd.conf" * -WindowStyle Hidden # (or None) * but any other -WindowStyle can catch CTRL_CLOSE_EVENT. * CTRL_C_EVENT can only be sent to 0 (self process group) or self pid * and is ignored by default (sending signal does not indicate failure) * in numerous other cases. Some people have resorted to standalone helper * programs to attempt AttachConsole() to a target pid before sending * CTRL_C_EVENT via GenerateConsoleCtrlEvent(). Another alternative is * running lighttpd as a Windows service, which uses a different mechanism, * also more limited than unix signals. Other alternatives include * NSSM (Non-Sucking Service Manager) or cygwin's cygrunsrv program */ switch(dwType) { case CTRL_C_EVENT: signal_handler(SIGINT); break; case CTRL_BREAK_EVENT: /* Ctrl-BREAK (repurposed and treated as SIGUSR1)*/ signal_handler(SIGUSR1); break; case CTRL_CLOSE_EVENT:/* sent by taskkill */ case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: /* non-cancellable event; program terminates soon after return */ signal_handler(SIGTERM);/* trigger server shutdown in main thread */ Sleep(2000); /* sleep 2 secs to give threads chance to exit*/ return FALSE; } return TRUE; } #endif #endif static void server_main_setup_signals (void) { #ifdef HAVE_SIGACTION struct sigaction act; memset(&act, 0, sizeof(act)); sigemptyset(&act.sa_mask); act.sa_handler = SIG_IGN; sigaction(SIGPIPE, &act, NULL); #ifndef _MSC_VER act.sa_flags = SA_NODEFER; act.sa_handler = sys_setjmp_sigbus; sigaction(SIGBUS, &act, NULL); act.sa_flags = 0; #endif #if defined(SA_SIGINFO) last_sighup_info.si_uid = 0, last_sighup_info.si_pid = 0; last_sigterm_info.si_uid = 0, last_sigterm_info.si_pid = 0; act.sa_sigaction = sigaction_handler; act.sa_flags = SA_SIGINFO; #else act.sa_handler = signal_handler; act.sa_flags = 0; #endif sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGALRM, &act, NULL); sigaction(SIGUSR1, &act, NULL); /* it should be safe to restart syscalls after SIGCHLD */ act.sa_flags |= SA_RESTART | SA_NOCLDSTOP; sigaction(SIGCHLD, &act, NULL); #elif defined(HAVE_SIGNAL) #ifndef _WIN32 /* ignore the SIGPIPE from sendfile() */ signal(SIGPIPE, SIG_IGN); #endif signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); #ifndef _WIN32 signal(SIGHUP, signal_handler); signal(SIGALRM, signal_handler); signal(SIGUSR1, signal_handler); signal(SIGCHLD, signal_handler); #else /* Ctrl-BREAK (repurposed and treated as SIGUSR1)*/ signal(SIGUSR1, signal_handler); SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleCtrlHandler,TRUE); #endif #ifndef _MSC_VER signal(SIGBUS, sys_setjmp_sigbus); #endif #endif } #ifdef HAVE_FORK static int daemonize(void) { int pipefd[2]; pid_t pid; #ifdef SIGTTOU signal(SIGTTOU, SIG_IGN); #endif #ifdef SIGTTIN signal(SIGTTIN, SIG_IGN); #endif #ifdef SIGTSTP signal(SIGTSTP, SIG_IGN); #endif if (fdevent_pipe_cloexec(pipefd, 64) < 0) exit(-1); if (0 > (pid = fork())) exit(-1); if (0 < pid) { char buf; ssize_t bytes; close(pipefd[1]); /* parent waits for grandchild to be ready */ do { bytes = read(pipefd[0], &buf, sizeof(buf)); } while (bytes < 0 && EINTR == errno); close(pipefd[0]); if (bytes <= 0) { /* closed fd (without writing) == failure in grandchild */ fputs("daemonized server failed to start; check error log for details\n", stderr); exit(-1); } exit(0); } close(pipefd[0]); if (-1 == setsid()) exit(0); signal(SIGHUP, SIG_IGN); if (0 != fork()) exit(0); if (0 != chdir("/")) exit(0); return pipefd[1]; } #endif static int clockid_mono_coarse = 0; static unix_time64_t server_monotonic_secs (void) { #ifdef _MSC_VER return (unix_time64_t)(GetTickCount64() / 1000); #else unix_timespec64_t ts; return (0 == log_clock_gettime(clockid_mono_coarse, &ts)) ? ts.tv_sec : log_monotonic_secs; #endif } static unix_time64_t server_epoch_secs (server * const srv, unix_time64_t mono_ts_delta) { const unix_time64_t cur_ts = log_epoch_secs; const unix_time64_t new_ts = TIME64_CAST(time(NULL)); const unix_time64_t new_ts_adj = new_ts - mono_ts_delta; /* attempt to detect large clock jump */ if (new_ts_adj < cur_ts || new_ts_adj - cur_ts > 300) { /*(5 mins)*/ log_error(srv->errh, __FILE__, __LINE__, "warning: clock jumped %lld secs", (long long)((int64_t)new_ts_adj - (int64_t)cur_ts)); int delta = /*(30 mins default)*/ config_feature_int(srv, "server.clock-jump-restart", 1800); if (delta && (new_ts_adj > cur_ts ? new_ts_adj-cur_ts : cur_ts-new_ts_adj) > delta) { log_error(srv->errh, __FILE__, __LINE__, "attempting graceful restart in < ~5 seconds, else hard restart"); srv->graceful_expire_ts = log_monotonic_secs + 5; raise(SIGUSR1); } } return new_ts; } __attribute_cold__ __attribute_noinline__ __attribute_returns_nonnull__ static server *server_init(void) { server *srv = ck_calloc(1, sizeof(*srv)); srv->tmp_buf = buffer_init(); strftime_cache_reset(); li_rand_reseed(); srv->startup_ts = log_epoch_secs = TIME64_CAST(time(NULL)); #ifdef HAVE_CLOCK_GETTIME unix_timespec64_t ts; UNUSED(&ts); #ifdef CLOCK_MONOTONIC_COARSE if (0 == log_clock_gettime(CLOCK_MONOTONIC_COARSE, &ts)) clockid_mono_coarse = CLOCK_MONOTONIC_COARSE; else #endif #ifdef CLOCK_MONOTONIC_RAW_APPROX if (0 == log_clock_gettime(CLOCK_MONOTONIC_RAW_APPROX, &ts)) clockid_mono_coarse = CLOCK_MONOTONIC_RAW_APPROX; else #endif #ifdef CLOCK_MONOTONIC_RAW if (0 == log_clock_gettime(CLOCK_MONOTONIC_RAW, &ts)) clockid_mono_coarse = CLOCK_MONOTONIC_RAW; else #endif clockid_mono_coarse = CLOCK_MONOTONIC; #endif log_monotonic_secs = server_monotonic_secs(); srv->errh = log_set_global_errh(NULL, 0); config_init(srv); srv->request_env = plugins_call_handle_request_env; srv->plugins_request_reset = plugins_call_handle_request_reset; srv->loadavg[0] = 0.0; srv->loadavg[1] = 0.0; srv->loadavg[2] = 0.0; srv->stdin_fd = -1; srv->default_server_tag = &default_server_tag; log_con_jqueue = (connection *)(uintptr_t)&log_con_jqueue;/*(sentinel)*/ memset(http_dispatch, 0, sizeof(http_dispatch)); return srv; } __attribute_cold__ __attribute_noinline__ static void server_free(server *srv) { if (oneshot_fd > 0) { if (oneshot_fdn) { fdevent_fdnode_event_del(srv->ev, oneshot_fdn); fdevent_unregister(srv->ev, oneshot_fdn); oneshot_fdn = NULL; } if (oneshot_fdout >= 0) fdio_close_pipe(oneshot_fd); else fdio_close_socket(oneshot_fd); } if (oneshot_fdout >= 0) { fdio_close_pipe(oneshot_fdout); } if (srv->stdin_fd >= 0) { fdio_close_socket(srv->stdin_fd); } buffer_free(srv->tmp_buf); fdevent_free(srv->ev); config_free(srv); stat_cache_free(); li_rand_cleanup(); chunkqueue_chunk_pool_free(); if (srv->errh != log_set_global_errh(NULL, 0)) fdlog_free(srv->errh); free(srv); } __attribute_cold__ __attribute_noinline__ static void remove_pid_file(server *srv) { if (pid_fd <= -2) return; if (srv->srvconf.pid_file && 0 <= pid_fd) { if (0 != ftruncate(pid_fd, 0)) { log_perror(srv->errh, __FILE__, __LINE__, "ftruncate failed for: %s", srv->srvconf.pid_file->ptr); } } if (0 <= pid_fd) { close(pid_fd); pid_fd = -1; } if (srv->srvconf.pid_file && !srv->srvconf.changeroot) { if (0 != unlink(srv->srvconf.pid_file->ptr)) { if (errno != EACCES && errno != EPERM) { log_perror(srv->errh, __FILE__, __LINE__, "unlink failed for: %s", srv->srvconf.pid_file->ptr); } } } } __attribute_cold__ static server_socket * server_oneshot_getsock(server *srv, sock_addr *cnt_addr) { server_socket *srv_socket, *srv_socket_wild = NULL; for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) { srv_socket = srv->srv_sockets.ptr[i]; if (!sock_addr_is_port_eq(&srv_socket->addr,cnt_addr)) continue; if (sock_addr_is_addr_eq(&srv_socket->addr,cnt_addr)) return srv_socket; if (NULL != srv_socket_wild) continue; if (sock_addr_is_addr_wildcard(&srv_socket->addr)) { srv_socket_wild = srv_socket; } } if (NULL != srv_socket_wild) { return srv_socket_wild; } else if (srv->srv_sockets.used) { return srv->srv_sockets.ptr[0]; } else { log_error(srv->errh, __FILE__, __LINE__, "no sockets configured"); return NULL; } } static int server_oneshot_read_cq(connection *con, chunkqueue *cq, off_t max_bytes) { /* temporary set con->fd to oneshot_fd (fd input) rather than outshot_fdout * (lighttpd generally assumes operation on sockets, so this is a kludge) */ int fd = con->fd; con->fd = oneshot_fdn->fd; int rc = oneshot_read_cq(con, cq, max_bytes); con->fd = fd; /* note: optimistic reads (elsewhere) may or may not be enough to re-enable * read interest after FDEVENT_IN interest was paused for other reasons */ const int events = fdevent_fdnode_interest(oneshot_fdn); int n = con->is_readable > 0 ? 0 : FDEVENT_IN; if (events & FDEVENT_RDHUP) n |= FDEVENT_RDHUP; fdevent_fdnode_event_set(con->srv->ev, oneshot_fdn, n); return rc; } static handler_t server_oneshot_handle_fdevent(void *context, int revents) { connection *con = context; /* note: not sync'd with con->fdn or connection_set_fdevent_interest() */ int rdhup = 0; int n = fdevent_fdnode_interest(oneshot_fdn); if (revents & FDEVENT_IN) n &= ~FDEVENT_IN; request_st * const r = &con->request; if (r->state != CON_STATE_ERROR && (revents & (FDEVENT_HUP|FDEVENT_RDHUP))){ revents &= ~(FDEVENT_HUP|FDEVENT_RDHUP); /* copied and modified from connection_handle_fdevent() * fdevent_is_tcp_half_closed() will fail on pipe * and, besides, read end of pipes should treat POLLHUP as POLLRDHUP */ n &= ~(FDEVENT_IN|FDEVENT_RDHUP); rdhup = 1; } fdevent_fdnode_event_set(con->srv->ev, oneshot_fdn, n); fdnode * const fdn = con->fdn; /* fdn->ctx == con */ handler_t rc = (fdn && (fdevent_handler)NULL != fdn->handler) ? (*fdn->handler)(con, revents) : HANDLER_FINISHED; if (rdhup) { r->conf.stream_request_body &= ~(FDEVENT_STREAM_REQUEST_BUFMIN|FDEVENT_STREAM_REQUEST_POLLIN); r->conf.stream_request_body |= FDEVENT_STREAM_REQUEST_POLLRDHUP; r->conf.stream_request_body |= FDEVENT_STREAM_REQUEST_TCP_FIN; con->is_readable = 1; /*(can read 0 for end-of-stream)*/ if (chunkqueue_is_empty(con->read_queue)) r->keep_alive = 0; if (r->reqbody_length < -1) /*(transparent proxy mode; no more data)*/ r->reqbody_length = r->reqbody_queue.bytes_in; } return rc; } __attribute_cold__ static int server_oneshot_init_pipe(server *srv, int fdin, int fdout) { /* Note: attempt to work with netcat pipes though other code expects socket. * netcat has different fds (pipes) for stdin and stdout. To support * netcat, need to avoid S_ISSOCK(), getsockname(), and getpeername(), * reconstructing addresses from environment variables: * NCAT_LOCAL_ADDR NCAT_LOCAL_PORT * NCAT_REMOTE_ADDR NCAT_REMOTE_PORT * NCAT_PROTO (TCP, UDP, SCTP) */ connection *con; const server_socket *srv_socket; sock_addr cnt_addr; /* detect if called from netcat or else fabricate localhost addrs */ const char * const ncat = getenv("NCAT_LOCAL_ADDR"); const char * const ncat_local_addr = ncat ? ncat : "127.0.0.1"; /*(fabricated)*/ const char * const ncat_local_port = ncat ? getenv("NCAT_LOCAL_PORT") : "80"; /*(fabricated)*/ const char * const ncat_remote_addr = ncat ? getenv("NCAT_REMOTE_ADDR") : "127.0.0.1"; /*(fabricated)*/ const char * const ncat_remote_port = ncat ? getenv("NCAT_REMOTE_PORT") : "48080"; /*(fabricated)*/ if (NULL == ncat_local_addr || NULL == ncat_local_port) return 0; if (NULL == ncat_remote_addr || NULL == ncat_remote_port) return 0; const int family = ncat && strchr(ncat_local_addr,':') ? AF_INET6 : AF_INET; unsigned short port; port = (unsigned short)strtol(ncat_local_port, NULL, 10); if (1 != sock_addr_inet_pton(&cnt_addr, ncat_local_addr, family, port)) { log_error(srv->errh, __FILE__, __LINE__, "invalid local addr"); return 0; } srv_socket = server_oneshot_getsock(srv, &cnt_addr); if (NULL == srv_socket) return 0; port = (unsigned short)strtol(ncat_remote_port, NULL, 10); if (1 != sock_addr_inet_pton(&cnt_addr, ncat_remote_addr, family, port)) { log_error(srv->errh, __FILE__, __LINE__, "invalid remote addr"); return 0; } /*(must set flags; fd did not pass through fdevent accept() logic)*/ if (-1 == fdevent_fcntl_set_nb_cloexec(fdin)) { log_perror(srv->errh, __FILE__, __LINE__, "fcntl()"); return 0; } if (-1 == fdevent_fcntl_set_nb_cloexec(fdout)) { log_perror(srv->errh, __FILE__, __LINE__, "fcntl()"); return 0; } con = connection_accepted(srv, srv_socket, &cnt_addr, fdout); if (NULL == con) return 0; /* note: existing routines assume socket, not pipe * connections.c:connection_read_cq() * uses recv() ifdef _WIN32 * passes S_IFSOCK to fdevent_ioctl_fionread() * (The routine could be copied and modified, if required) * This is unlikely to work if TLS is used over pipe since the SSL_CTX * is associated with the other end of the pipe. However, if using * pipes, using TLS is unexpected behavior. */ /*assert(oneshot_fd == fdin);*/ oneshot_read_cq = con->network_read; con->network_read = server_oneshot_read_cq; oneshot_fdn = fdevent_register(srv->ev, fdin, server_oneshot_handle_fdevent, con); fdevent_fdnode_event_set(srv->ev, oneshot_fdn, FDEVENT_RDHUP); connection_state_machine(con); return 1; } __attribute_cold__ static int server_oneshot_init(server *srv, int fd) { connection *con; const server_socket *srv_socket; sock_addr cnt_addr; socklen_t cnt_len; cnt_len = sizeof(cnt_addr); if (0 != getsockname(fd, (struct sockaddr *)&cnt_addr, &cnt_len)) { log_perror(srv->errh, __FILE__, __LINE__, "getsockname()"); return 0; } srv_socket = server_oneshot_getsock(srv, &cnt_addr); if (NULL == srv_socket) return 0; #ifdef __clang_analyzer__ memset(&cnt_addr, 0, sizeof(cnt_addr)); #endif cnt_len = sizeof(cnt_addr); if (0 != getpeername(fd, (struct sockaddr *)&cnt_addr, &cnt_len)) { log_perror(srv->errh, __FILE__, __LINE__, "getpeername()"); return 0; } /*(must set flags; fd did not pass through fdevent accept() logic)*/ if (-1 == fdevent_socket_set_nb_cloexec(fd)) { log_perror(srv->errh, __FILE__, __LINE__, "fcntl()"); return 0; } if (sock_addr_get_family(&cnt_addr) != AF_UNIX) { network_accept_tcp_nagle_disable(fd); } con = connection_accepted(srv, srv_socket, &cnt_addr, fd); if (NULL == con) return 0; connection_state_machine(con); return 1; } __attribute_cold__ static void show_version (void) { char *b = PACKAGE_DESC TEXT_SSL \ " - a light and fast webserver\n" #ifdef NONREPRODUCIBLE_BUILD "Build-Date: " __DATE__ " " __TIME__ "\n"; #endif ; write_all(STDOUT_FILENO, b, strlen(b)); } __attribute_cold__ static void show_features (void) { static const char features[] = "\nFeatures:\n\n" #ifdef HAVE_IPV6 "\t+ IPv6 support\n" #else "\t- IPv6 support\n" #endif #if defined HAVE_ZLIB_H && defined HAVE_LIBZ "\t+ zlib support\n" #else "\t- zlib support\n" #endif #if defined HAVE_ZSTD_H && defined HAVE_ZSTD "\t+ zstd support\n" #else "\t- zstd support\n" #endif #if defined HAVE_BZLIB_H && defined HAVE_LIBBZ2 "\t+ bzip2 support\n" #else "\t- bzip2 support\n" #endif #if defined HAVE_BROTLI_ENCODE_H && defined HAVE_BROTLI "\t+ brotli support\n" #else "\t- brotli support\n" #endif #if defined(HAVE_CRYPT) || defined(HAVE_CRYPT_R) "\t+ crypt support\n" #else "\t- crypt support\n" #endif #ifdef USE_OPENSSL_CRYPTO "\t+ OpenSSL support\n" #else "\t- OpenSSL support\n" #endif #ifdef USE_MBEDTLS_CRYPTO "\t+ mbedTLS support\n" #else "\t- mbedTLS support\n" #endif #ifdef USE_NSS_CRYPTO "\t+ NSS crypto support\n" #else "\t- NSS crypto support\n" #endif #ifdef USE_GNUTLS_CRYPTO "\t+ GnuTLS support\n" #else "\t- GnuTLS support\n" #endif #ifdef USE_WOLFSSL_CRYPTO "\t+ WolfSSL support\n" #else "\t- WolfSSL support\n" #endif #ifdef USE_NETTLE_CRYPTO "\t+ Nettle support\n" #else "\t- Nettle support\n" #endif #ifdef HAVE_PCRE "\t+ PCRE support\n" #else "\t- PCRE support\n" #endif #ifdef HAVE_MYSQL "\t+ MySQL support\n" #else "\t- MySQL support\n" #endif #ifdef HAVE_PGSQL "\t+ PgSQL support\n" #else "\t- PgSQL support\n" #endif #ifdef HAVE_DBI "\t+ DBI support\n" #else "\t- DBI support\n" #endif #ifdef HAVE_KRB5 "\t+ Kerberos support\n" #else "\t- Kerberos support\n" #endif #if defined(HAVE_LDAP_H) && defined(HAVE_LBER_H) && defined(HAVE_LIBLDAP) && defined(HAVE_LIBLBER) "\t+ LDAP support\n" #else "\t- LDAP support\n" #endif #ifdef HAVE_PAM "\t+ PAM support\n" #else "\t- PAM support\n" #endif #ifdef HAVE_FAM_H "\t+ FAM support\n" #else "\t- FAM support\n" #endif #ifdef HAVE_LUA_H "\t+ LUA support\n" #else "\t- LUA support\n" #endif #ifdef HAVE_LIBXML_H "\t+ xml support\n" #else "\t- xml support\n" #endif #ifdef HAVE_SQLITE3_H "\t+ SQLite support\n" #else "\t- SQLite support\n" #endif ; show_version(); printf("%s%s%s%s\n", fdevent_show_event_handlers(), network_write_show_handlers(), features, sizeof(time_t) > 4 || (sizeof(time_t) == 4 && (time_t)-1 > (time_t)1) ? "\t+ Y2038 support\n" : "\t- Y2038 support (unsafe 32-bit signed time_t)\n"); } __attribute_cold__ static void show_help (void) { char *b = PACKAGE_DESC TEXT_SSL #ifdef NONREPRODUCIBLE_BUILD " ("__DATE__ " " __TIME__ ")" #endif " - a light and fast webserver\n" \ "usage:\n" \ " -f <name> filename of the config-file\n" \ " -m <name> module directory (default: "LIBRARY_DIR")\n" \ " -i <secs> graceful shutdown after <secs> of inactivity\n" \ " -1 process single (one) request on stdin socket, then exit\n" \ " -p print the parsed config-file in internal form, and exit\n" \ " -t test config-file syntax, then exit\n" \ " -tt test config-file syntax, load and init modules, then exit\n" \ " -D don't go to background (default: go to background)\n" \ " -v show version\n" \ " -V show compile-time features\n" \ " -h show this help\n" \ "\n" ; write_all(STDOUT_FILENO, b, strlen(b)); } __attribute_cold__ __attribute_noinline__ static void server_sockets_save (server *srv) { /* graceful_restart */ for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) srv->srv_sockets.ptr[i]->srv = NULL; /* srv will shortly be invalid */ for (uint32_t i = 0; i < srv->srv_sockets_inherited.used; ++i) srv->srv_sockets_inherited.ptr[i]->srv = NULL; /* srv to be invalid */ memcpy(&graceful_sockets, &srv->srv_sockets, sizeof(server_socket_array)); memset(&srv->srv_sockets, 0, sizeof(server_socket_array)); memcpy(&inherited_sockets, &srv->srv_sockets_inherited, sizeof(server_socket_array)); memset(&srv->srv_sockets_inherited, 0, sizeof(server_socket_array)); } __attribute_cold__ __attribute_noinline__ static void server_sockets_restore (server *srv) { /* graceful_restart */ memcpy(&srv->srv_sockets, &graceful_sockets, sizeof(server_socket_array)); memset(&graceful_sockets, 0, sizeof(server_socket_array)); memcpy(&srv->srv_sockets_inherited, &inherited_sockets, sizeof(server_socket_array)); memset(&inherited_sockets, 0, sizeof(server_socket_array)); for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) { srv->srv_sockets.ptr[i]->srv = srv; /* update ptr */ srv->srv_sockets.ptr[i]->sidx= (unsigned short)~0u; } for (uint32_t i = 0; i < srv->srv_sockets_inherited.used; ++i) srv->srv_sockets_inherited.ptr[i]->srv = srv; /* update ptr */ } __attribute_cold__ static int server_sockets_set_nb_cloexec (server *srv) { if (srv->sockets_disabled) return 0; /* lighttpd -1 (one-shot mode) */ for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) { server_socket *srv_socket = srv->srv_sockets.ptr[i]; if (-1 == fdevent_fcntl_set_nb_cloexec_sock(srv_socket->fd)) { log_perror(srv->errh, __FILE__, __LINE__, "fcntl()"); return -1; } } return 0; } __attribute_cold__ static void server_sockets_set_event (server *srv, int event) { for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) { server_socket *srv_socket = srv->srv_sockets.ptr[i]; fdevent_fdnode_event_set(srv->ev, srv_socket->fdn, event); } } __attribute_cold__ static void server_sockets_unregister (server *srv) { if (2 == srv->sockets_disabled) return; srv->sockets_disabled = 2; for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) network_unregister_sock(srv, srv->srv_sockets.ptr[i]); } __attribute_cold__ static void server_sockets_close (server *srv) { /* closing socket right away will make it possible for the next lighttpd * to take over (old-style graceful restart), but only if backends * (e.g. fastcgi, scgi, etc) are independent from lighttpd, rather * than started by lighttpd via "bin-path") */ if (3 == srv->sockets_disabled) return; for (uint32_t i = 0; i < srv->srv_sockets.used; ++i) { server_socket *srv_socket = srv->srv_sockets.ptr[i]; if (-1 == srv_socket->fd) continue; if (2 != srv->sockets_disabled) network_unregister_sock(srv,srv_socket); fdio_close_socket(srv_socket->fd); srv_socket->fd = -1; /* network_close() will cleanup after us */ } srv->sockets_disabled = 3; } __attribute_cold__ static void server_graceful_signal_prev_generation (void) { #ifdef HAVE_FORK const char * const prev_gen = getenv("LIGHTTPD_PREV_GEN"); if (NULL == prev_gen) return; pid_t pid = (pid_t)strtol(prev_gen, NULL, 10); unsetenv("LIGHTTPD_PREV_GEN"); if (pid <= 0) return; /*(should not happen)*/ if (pid == fdevent_waitpid(pid,NULL,1)) return; /*(pid exited; unexpected)*/ kill(pid, SIGINT); /* signal previous generation for graceful shutdown */ #endif } __attribute_cold__ static int server_graceful_state_bg (server *srv) { /*assert(graceful_restart);*/ /*(SIGUSR1 set to SIG_IGN in workers, so should not reach here if worker)*/ if (srv_shutdown) return 0; /* check if server should fork and background (bg) itself * to continue processing requests already in progress */ if (!config_feature_bool(srv, "server.graceful-restart-bg", 0)) return 0; /*(set flag to false to avoid repeating)*/ data_unset * const du = array_get_data_unset(srv->srvconf.feature_flags, CONST_STR_LEN("server.graceful-restart-bg")); if (du->type == TYPE_STRING) buffer_copy_string_len(&((data_string *)du)->value, CONST_STR_LEN("false")); else /* (du->type == TYPE_INTEGER) */ ((data_integer *)du)->value = 0; /* require exec'd via absolute path or daemon in foreground * and exec'd with path containing '/' (e.g. "./xxxxx") */ char ** const argv = srv->argv; if (0 == srv->srvconf.dont_daemonize ? argv[0][0] != '/' : NULL == strchr(argv[0], '/')) return 0; /* flush log buffers to avoid potential duplication of entries * server_handle_sighup(srv) does the following, but skip logging */ plugins_call_handle_sighup(srv); fdlog_files_cycle(srv->errh); /* reopen log files, not pipes */ /* backgrounding to continue processing requests in progress */ /* re-exec lighttpd in original process * Note: using path in re-exec is portable and allows lighttpd upgrade. * OTOH, getauxval() AT_EXECFD and fexecve() could be used on Linux to * re-exec without access to original executable on disk, which might be * desirable in some situations, but is not implemented here. * Alternatively, if argv[] was not available, could use readlink() on * /proc/self/exe (Linux-specific), though there are ways on many other * platforms to achieve the same: * https://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe */ #if defined(HAVE_KQUEUE) #if defined(__FreeBSD__) || defined(__DragonFly__) /*(must *exclude* rfork RFFDG flag for kqueue to work across rfork)*/ pid_t pid = rfork(RFPROC); #else pid_t pid = -1; if (pid < 0) { /* kqueue is not inherited across fork * future: fdevent kqueue and stat_cache kqueue would need to be closed, * re-opened, and active fds re-registered. Not current done. * Need to create some routines like fdevent_reinit_after_fork*/ log_error(srv->errh, __FILE__, __LINE__, "server.graceful-restart-bg ignored on OpenBSD and NetBSD " "due to limitation in kqueue inheritance and lacking rfork"); return 0; } #endif #elif defined(HAVE_FORK) pid_t pid = fork(); #else pid_t pid = -1; #endif if (pid) { /* original process */ if (pid < 0) return 0; network_socket_activation_to_env(srv); /* save pid of original server in environment so that it can be * signalled by restarted server once restarted server is ready * to accept new connections */ server_graceful_signal_prev_generation();/*(expect no prev gen active)*/ if (0 == srv->srvconf.max_worker) { buffer * const tb = srv->tmp_buf; buffer_clear(tb); buffer_append_int(tb, pid); setenv("LIGHTTPD_PREV_GEN", tb->ptr, 1); } /*fdevent_waitpid(pid, NULL, 0);*//* detach? */ execv(argv[0], argv); _exit(1); } /* else child/grandchild */ /*if (-1 == setsid()) _exit(1);*//* should we detach? */ /* Note: restarted server will fail with socket-in-use error if * server.systemd-socket-activation not enabled in restarted server */ if (0 != srv->srvconf.max_worker) server_sockets_close(srv);/*(close before parent reaps pid in waitpid)*/ /*if (0 != fork()) _exit(0);*//* should we detach? */ /*(grandchild is now backgrounded and detached from original process)*/ /* XXX: might extend code to have new server.feature-flags param specify * max lifetime before aborting remaining connections */ /* (reached if lighttpd workers or if sole process w/o workers) * use same code as comment elsewhere in server.c: * make sure workers do not muck with pid-file */ if (0 <= pid_fd) { close(pid_fd); pid_fd = -1; } srv->srvconf.pid_file = NULL; /* (original process is backgrounded -- even if no active connections -- * to allow graceful shutdown tasks to be run by server and by modules) */ log_error(srv->errh, __FILE__, __LINE__, "[note] pid %lld continuing to handle %u connection(s) in progress", (long long)getpid(), srv->srvconf.max_conns - srv->lim_conns); if (0 == srv->srvconf.max_worker) { /* reset graceful_shutdown; wait for signal from restarted server */ srv->graceful_expire_ts = 0; graceful_shutdown = 0; } graceful_restart = 0; return 1; } __attribute_cold__ __attribute_noinline__ static void server_graceful_shutdown_maint (server *srv) { if (oneshot_fd) { /* permit keep-alive on one-shot connections until graceful_expire_ts */ if (!srv->graceful_expire_ts) return; if (srv->graceful_expire_ts >= log_monotonic_secs) return; } connection_graceful_shutdown_maint(srv); } #ifndef server_status_stopping #define server_status_stopping(srv) do { } while (0) #endif __attribute_cold__ __attribute_noinline__ static void server_graceful_state (server *srv) { if (!srv_shutdown) { if (0 == srv->graceful_expire_ts) { srv->graceful_expire_ts = config_feature_int(srv, "server.graceful-shutdown-timeout", 8); if (srv->graceful_expire_ts) srv->graceful_expire_ts += log_monotonic_secs; } server_graceful_shutdown_maint(srv); } server_status_stopping(srv);/*might be called multiple times; intentional*/ if (2 == srv->sockets_disabled || 3 == srv->sockets_disabled) { if (oneshot_fd) graceful_restart = 0; return; } log_error(srv->errh,__FILE__,__LINE__,"[note] graceful shutdown started"); /* no graceful restart if chroot()ed, if oneshot mode, or if idle timeout */ if (srv->srvconf.changeroot || oneshot_fd || 2 == graceful_shutdown) graceful_restart = 0; if (graceful_restart) { if (!server_graceful_state_bg(srv)) server_sockets_unregister(srv); if (pid_fd > 0) pid_fd = -pid_fd; /*(flag to skip removing pid file)*/ } else { server_sockets_close(srv); remove_pid_file(srv); /*(prevent more removal attempts)*/ srv->srvconf.pid_file = NULL; } } __attribute_cold__ __attribute_noinline__ static void server_sockets_enable (server *srv) { server_sockets_set_event(srv, FDEVENT_IN); srv->sockets_disabled = 0; log_error(srv->errh, __FILE__, __LINE__, "[note] sockets enabled again"); } __attribute_cold__ __attribute_noinline__ static void server_sockets_disable (server *srv) { server_sockets_set_event(srv, 0); srv->sockets_disabled = 1; log_error(srv->errh, __FILE__, __LINE__, (0 == srv->lim_conns) ? "[note] sockets disabled, connection limit reached" : "[note] sockets disabled, out-of-fds"); } __attribute_cold__ static void server_overload_check (server *srv) { if (srv->cur_fds < srv->max_fds_lowat && 0 != srv->lim_conns) server_sockets_enable(srv); } static void server_load_check (server *srv) { /* check if hit limits for num fds used or num connections */ if (srv->cur_fds > srv->max_fds_hiwat || 0 == srv->lim_conns) server_sockets_disable(srv); } #ifdef HAVE_FORK __attribute_noinline__ static int server_main_setup_workers (server * const srv, const int npids) { pid_t pid; int num_childs = npids; int child = 0; unsigned int timer = 0; pid_t pids[npids]; for (int n = 0; n < npids; ++n) pids[n] = -1; server_graceful_signal_prev_generation(); while (!child && !srv_shutdown && !graceful_shutdown) { if (num_childs > 0) { switch ((pid = fork())) { case -1: return -1; case 0: child = 1; alarm(0); break; default: num_childs--; for (int n = 0; n < npids; ++n) { if (-1 == pids[n]) { pids[n] = pid; break; } } break; } } else { int status; unix_time64_t mono_ts; if (-1 != (pid = fdevent_waitpid_intr(-1, &status))) { mono_ts = log_monotonic_secs; log_monotonic_secs = server_monotonic_secs(); log_epoch_secs = server_epoch_secs(srv, log_monotonic_secs - mono_ts); if (plugins_call_handle_waitpid(srv, pid, status) != HANDLER_GO_ON) { if (!timer) alarm((timer = 5)); continue; } switch (fdlog_pipes_waitpid_cb(pid)) { default: break; case -1: if (!timer) alarm((timer = 5)); __attribute_fallthrough__ case 1: continue; } /** * check if one of our workers went away */ for (int n = 0; n < npids; ++n) { if (pid == pids[n]) { pids[n] = -1; num_childs++; break; } } } else if (errno == EINTR) { mono_ts = log_monotonic_secs; log_monotonic_secs = server_monotonic_secs(); log_epoch_secs = server_epoch_secs(srv, log_monotonic_secs - mono_ts); /* On SIGHUP, cycle logs (periodic maint runs in children) */ if (handle_sig_hup) { handle_sig_hup = 0; fdlog_files_cycle(srv->errh);/*reopen log files, not pipes*/ /* forward SIGHUP to workers */ for (int n = 0; n < npids; ++n) { if (pids[n] > 0) kill(pids[n], SIGHUP); } } if (handle_sig_alarm) { handle_sig_alarm = 0; timer = 0; plugins_call_handle_trigger(srv); fdlog_pipes_restart(log_monotonic_secs); } } } } if (!child) { /* exit point for parent monitoring workers; * signal children, too */ if (graceful_shutdown || graceful_restart) { /* flag to ignore one SIGINT if graceful_restart */ if (graceful_restart) graceful_restart = 2; kill(0, SIGINT); server_graceful_state(srv); } else if (srv_shutdown) kill(0, SIGTERM); return 0; } /* ignore SIGUSR1 in workers; only parent directs graceful restart */ #ifdef HAVE_SIGACTION struct sigaction actignore; memset(&actignore, 0, sizeof(actignore)); actignore.sa_handler = SIG_IGN; sigaction(SIGUSR1, &actignore, NULL); #elif defined(HAVE_SIGNAL) signal(SIGUSR1, SIG_IGN); #endif /** * make sure workers do not muck with pid-file */ if (0 <= pid_fd) { close(pid_fd); pid_fd = -1; } srv->srvconf.pid_file = NULL; fdlog_pipes_abandon_pids(); srv->pid = getpid(); li_rand_reseed(); return 1; /* child worker */ } #endif __attribute_cold__ __attribute_noinline__ static int server_main_setup (server * const srv, int argc, char **argv) { int print_config = 0; int test_config = 0; int i_am_root = 0; #ifdef HAVE_FORK int parent_pipe_fd = -1; #endif #ifdef HAVE_GETUID i_am_root = (0 == getuid()); #endif /* initialize globals (including file-scoped static globals) */ oneshot_fd = 0; oneshot_fdout = -1; srv_shutdown = 0; graceful_shutdown = 0; handle_sig_alarm = 1; handle_sig_hup = 0; idle_limit = 0; chunkqueue_set_tempdirs_default_reset(); /*graceful_restart = 0;*//*(reset below to avoid further daemonizing)*/ /*(intentionally preserved)*/ /*memset(graceful_sockets, 0, sizeof(graceful_sockets));*/ /*memset(inherited_sockets, 0, sizeof(inherited_sockets));*/ /*pid_fd = -1;*/ srv->argv = argv; for (int o; -1 != (o = getopt(argc, argv, "f:m:i:hvVD1pt")); ) { switch(o) { case 'f': if (srv->config_data_base) { log_error(srv->errh, __FILE__, __LINE__, "Can only read one config file. Use the include command to use multiple config files."); return -1; } if (config_read(srv, optarg)) { return -1; } break; case 'm': srv->srvconf.modules_dir = optarg; break; case 'i': { char *endptr; long timeout = strtol(optarg, &endptr, 0); if (!*optarg || *endptr || timeout < 0) { log_error(srv->errh, __FILE__, __LINE__, "Invalid idle timeout value: %s", optarg); return -1; } idle_limit = (int)timeout; break; } case 'p': print_config = 1; break; case 't': ++test_config; break; case '1': if (0 == oneshot_fd) oneshot_fd = dup(STDIN_FILENO); break; case 'D': srv->srvconf.dont_daemonize = 1; break; case 'v': show_version(); return 0; case 'V': show_features(); return 0; case 'h': show_help(); return 0; default: show_help(); return -1; } } #if defined(__CYGWIN__) || defined(_WIN32) if (!srv->config_data_base && NULL != getenv("NSSM_SERVICE_NAME")) { char *dir = getenv("NSSM_SERVICE_DIR"); if (NULL != dir && 0 != chdir(dir)) { log_perror(srv->errh, __FILE__, __LINE__, "chdir %s failed", dir); return -1; } srv->srvconf.dont_daemonize = 1; srv->srvconf.modules_dir = "modules"; if (config_read(srv, "conf/lighttpd.conf")) return -1; } #ifndef HAVE_FORK srv->srvconf.dont_daemonize = 1; #endif #endif if (!srv->config_data_base) { log_error(srv->errh, __FILE__, __LINE__, "No configuration available. Try using -f option."); return -1; } if (1 == srv->srvconf.max_worker) srv->srvconf.max_worker = 0; if (print_config) { config_print(srv); puts(srv->tmp_buf->ptr); } if (test_config) { srv->srvconf.pid_file = NULL; if (1 == test_config) { printf("Syntax OK\n"); } else { /*(test_config > 1)*/ test_config = 0; srv->srvconf.preflight_check = 1; srv->srvconf.dont_daemonize = 1; } } if (test_config || print_config) { return 0; } #if defined(HAVE_MALLOC_TRIM) if (srv->srvconf.max_conns <= 16 && malloc_top_pad == 524288) malloc_top_pad = 131072; /*(reduce memory use on small systems)*/ #endif if (oneshot_fd) { if (oneshot_fd <= STDERR_FILENO) { log_error(srv->errh, __FILE__, __LINE__, "Invalid fds at startup with lighttpd -1"); return -1; } graceful_shutdown = 1; srv->sockets_disabled = 2; srv->srvconf.dont_daemonize = 1; srv->srvconf.pid_file = NULL; if (srv->srvconf.max_worker) { srv->srvconf.max_worker = 0; log_error(srv->errh, __FILE__, __LINE__, "server one-shot command line option disables server.max-worker config file option."); } struct stat st; if (0 != fstat(oneshot_fd, &st)) { log_perror(srv->errh, __FILE__, __LINE__, "fstat()"); return -1; } #ifndef _WIN32 /*(skip S_ISFIFO() and hope for the best if _WIN32)*/ if (S_ISFIFO(st.st_mode)) { oneshot_fdout = dup(STDOUT_FILENO); if (oneshot_fdout <= STDERR_FILENO) { log_perror(srv->errh, __FILE__, __LINE__, "dup()"); return -1; } } #endif #ifndef _WIN32 /*(skip S_ISSOCK() and hope for the best if _WIN32)*/ else if (!S_ISSOCK(st.st_mode)) { /* require that fd is a socket * (modules might expect STDIN_FILENO and STDOUT_FILENO opened to /dev/null) */ log_error(srv->errh, __FILE__, __LINE__, "lighttpd -1 stdin is not a socket"); return -1; } #endif } if (srv->srvconf.bindhost && buffer_is_equal_string(srv->srvconf.bindhost, CONST_STR_LEN("/dev/stdin"))) { /* XXX: to potentially support on _WIN32, * (SOCKET)GetStdHandle(STD_INPUT_HANDLE) and * WSADuplicateSocket() instead of dup() */ if (-1 == srv->stdin_fd) srv->stdin_fd = dup(STDIN_FILENO); if (srv->stdin_fd <= STDERR_FILENO) { log_error(srv->errh, __FILE__, __LINE__, "Invalid fds at startup"); return -1; } } /* close stdin and stdout, as they are not needed */ #ifdef _WIN32 /* _WIN32 file descriptors are not allocated lowest first. * Open NUL in binary mode and as (default) inheritable handle * https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/dup-dup2?view=msvc-170 * * A stream is associated with a file descriptor (_fileno(stream)). * An open file descriptor has an underlying operating system HANDLE. * However, standard handles are cached at program startup, * so we try to match them all back up after redirection. */ if ( NULL == freopen("nul:", "rb", stdin) || NULL == freopen("nul:", "wb", stdout) || (_fileno(stderr) == -2 && NULL == freopen("nul:", "wb", stderr))) { log_perror(srv->errh, __FILE__, __LINE__, "freopen() NUL"); return -1; } SetStdHandle(STD_INPUT_HANDLE, (HANDLE)_get_osfhandle(_fileno(stdin))); SetStdHandle(STD_OUTPUT_HANDLE,(HANDLE)_get_osfhandle(_fileno(stdout))); SetStdHandle(STD_ERROR_HANDLE, (HANDLE)_get_osfhandle(_fileno(stderr))); fdevent_setfd_cloexec(STDERR_FILENO); #else { struct stat st; int devnull; int errfd; do { /* coverity[overwrite_var : FALSE] */ devnull = fdevent_open_devnull(); #ifdef __COVERITY__ __coverity_escape__(devnull); #endif } while (-1 != devnull && devnull <= STDERR_FILENO); if (-1 == devnull) { log_perror(srv->errh, __FILE__, __LINE__, "opening /dev/null failed"); return -1; } errfd = (0 == fstat(STDERR_FILENO, &st)) ? -1 : devnull; if (0 != fdevent_set_stdin_stdout_stderr(devnull, devnull, errfd)) { log_perror(srv->errh, __FILE__, __LINE__, "setting default fds failed"); #ifdef FD_CLOEXEC if (-1 != errfd) close(errfd); if (devnull != errfd) close(devnull); #endif return -1; } #ifdef FD_CLOEXEC if (-1 != errfd) close(errfd); if (devnull != errfd) close(devnull); #endif } #endif http_range_config_allow_http10(config_feature_bool(srv, "http10.range", 0)); if (0 != config_set_defaults(srv)) { log_error(srv->errh, __FILE__, __LINE__, "setting default values failed"); return -1; } if (plugins_load(srv)) { log_error(srv->errh, __FILE__, __LINE__, "loading plugins finally failed"); return -1; } if (HANDLER_GO_ON != plugins_call_init(srv)) { log_error(srv->errh, __FILE__, __LINE__, "Initialization of plugins failed. Going down."); return -1; } http_dispatch[HTTP_VERSION_1_1] = h1_1_dispatch_table; /* copy struct */ if (config_feature_bool(srv, "server.h2-discard-backend-1xx", 0)) http_dispatch[HTTP_VERSION_2].send_1xx = 0; if (config_feature_bool(srv, "server.h1-discard-backend-1xx", 0)) http_dispatch[HTTP_VERSION_1_1].send_1xx = 0; if (config_feature_bool(srv, "server.discard-backend-1xx", 0)) { http_dispatch[HTTP_VERSION_3].send_1xx = 0; http_dispatch[HTTP_VERSION_2].send_1xx = 0; http_dispatch[HTTP_VERSION_1_1].send_1xx = 0; } /* mod_indexfile should be listed in server.modules prior to dynamic handlers */ uint32_t i = 0; for (const char *pname = NULL; i < srv->plugins.used; ++i) { plugin *p = ((plugin **)srv->plugins.ptr)[i]; if (0 == strcmp(p->name, "indexfile")) { if (pname) log_error(srv->errh, __FILE__, __LINE__, "Warning: mod_indexfile should be listed in server.modules prior to mod_%s", pname); break; } if (p->handle_subrequest_start && p->handle_subrequest) { if (!pname) pname = p->name; } } /* open pid file BEFORE chroot */ if (-2 == pid_fd) pid_fd = -1; /*(initial startup state)*/ if (-1 == pid_fd && srv->srvconf.pid_file) { const char *pidfile = srv->srvconf.pid_file->ptr; if (-1 == (pid_fd = fdevent_open_cloexec(pidfile, 0, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) { struct stat st; if (errno != EEXIST) { log_perror(srv->errh, __FILE__, __LINE__, "opening pid-file failed: %s", pidfile); return -1; } if (0 != stat(pidfile, &st)) { log_perror(srv->errh, __FILE__, __LINE__, "stating existing pid-file failed: %s", pidfile); } if (!S_ISREG(st.st_mode)) { log_error(srv->errh, __FILE__, __LINE__, "pid-file exists and isn't regular file: %s", pidfile); return -1; } if (-1 == (pid_fd = fdevent_open_cloexec(pidfile, 0, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) { log_perror(srv->errh, __FILE__, __LINE__, "opening pid-file failed: %s", pidfile); return -1; } } } { #ifdef HAVE_GETRLIMIT struct rlimit rlim = { 4096, 4096 }; int use_rlimit = 1; #ifdef HAVE_VALGRIND_VALGRIND_H if (RUNNING_ON_VALGRIND) use_rlimit = 0; #endif if (0 != getrlimit(RLIMIT_NOFILE, &rlim)) { log_perror(srv->errh, __FILE__, __LINE__, "getrlimit()"); use_rlimit = 0; } /** * if we are not root can can't increase the fd-limit above rlim_max, but we can reduce it */ if (use_rlimit && srv->srvconf.max_fds && (i_am_root || srv->srvconf.max_fds <= rlim.rlim_max)) { /* set rlimits */ rlim_t rlim_cur = rlim.rlim_cur; rlim.rlim_cur = srv->srvconf.max_fds; if (i_am_root) rlim.rlim_max = srv->srvconf.max_fds; if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) { log_perror(srv->errh, __FILE__, __LINE__, "setrlimit()"); log_error(srv->errh, __FILE__, __LINE__, "setrlimit() may need root to run once: setsebool -P httpd_setrlimit on"); use_rlimit = 0; if (srv->srvconf.max_fds > rlim_cur) srv->srvconf.max_fds = rlim_cur; } } /*(default upper limit of 4k if server.max-fds not specified)*/ if (0 == srv->srvconf.max_fds) srv->srvconf.max_fds = (rlim.rlim_cur <= 4096) ? (unsigned short)rlim.rlim_cur : 4096; /* set core file rlimit, if enable_cores is set */ if (use_rlimit && srv->srvconf.enable_cores && getrlimit(RLIMIT_CORE, &rlim) == 0) { rlim.rlim_cur = rlim.rlim_max; setrlimit(RLIMIT_CORE, &rlim); } #else #ifdef _WIN32 /*(default upper limit of 4k if server.max-fds not specified)*/ if (0 == srv->srvconf.max_fds) srv->srvconf.max_fds = 4096; #endif #endif } /* we need root-perms for port < 1024 */ if (0 != network_init(srv, srv->stdin_fd)) { return -1; } srv->stdin_fd = -1; if (i_am_root) { #ifdef HAVE_PWD_H /* set user and group */ struct group *grp = NULL; struct passwd *pwd = NULL; if (srv->srvconf.groupname) { if (NULL == (grp = getgrnam(srv->srvconf.groupname->ptr))) { log_error(srv->errh, __FILE__, __LINE__, "can't find groupname %s", srv->srvconf.groupname->ptr); return -1; } } if (srv->srvconf.username) { if (NULL == (pwd = getpwnam(srv->srvconf.username->ptr))) { log_error(srv->errh, __FILE__, __LINE__, "can't find username %s", srv->srvconf.username->ptr); return -1; } if (pwd->pw_uid == 0) { log_error(srv->errh, __FILE__, __LINE__, "I will not set uid to 0. Perhaps you should comment out server.username in lighttpd.conf\n"); return -1; } if (NULL == grp && NULL == (grp = getgrgid(pwd->pw_gid))) { log_error(srv->errh, __FILE__, __LINE__, "can't find group id %d", (int)pwd->pw_gid); return -1; } } if (NULL != grp) { if (grp->gr_gid == 0) { log_error(srv->errh, __FILE__, __LINE__, "I will not set gid to 0. Perhaps you should comment out server.groupname in lighttpd.conf\n"); return -1; } } /* * Change group before chroot, when we have access * to /etc/group * */ if (NULL != grp) { if (-1 == setgid(grp->gr_gid)) { log_perror(srv->errh, __FILE__, __LINE__, "setgid()"); return -1; } if (-1 == setgroups(0, NULL)) { log_perror(srv->errh, __FILE__, __LINE__, "setgroups()"); return -1; } if (srv->srvconf.username) { initgroups(srv->srvconf.username->ptr, grp->gr_gid); } } #endif #ifdef HAVE_CHROOT if (srv->srvconf.changeroot) { tzset(); if (-1 == chroot(srv->srvconf.changeroot->ptr)) { log_perror(srv->errh, __FILE__, __LINE__, "chroot()"); return -1; } if (-1 == chdir("/")) { log_perror(srv->errh, __FILE__, __LINE__, "chdir()"); return -1; } } #endif #ifdef HAVE_PWD_H /* drop root privs */ if (NULL != pwd) { if (-1 == setuid(pwd->pw_uid)) { log_perror(srv->errh, __FILE__, __LINE__, "setuid()"); return -1; } } #endif #if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_DUMPABLE) /** * on IRIX 6.5.30 they have prctl() but no DUMPABLE */ if (srv->srvconf.enable_cores) { prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); } #elif defined(HAVE_SYS_PROCCTL_H) && defined(PROC_TRACE_CTL_ENABLE) /* (DragonFlyBSD has procctl(), but not PROC_TRACE_CTL_ENABLE) */ if (srv->srvconf.enable_cores) { int dumpable = PROC_TRACE_CTL_ENABLE; procctl(P_PID, 0, PROC_TRACE_CTL, &dumpable); } #elif defined(HAVE_SETPFLAGS) && defined(__PROC_PROTECT) /** * setpflags seems uniquely a solaris/illumos feature * but just taking extra precautions clearing __PROC_PROTECT option */ if (srv->srvconf.enable_cores) { setpflags(__PROC_PROTECT, 0); } #endif } #ifdef HAVE_FORK /* network is up, let's daemonize ourself */ if (0 == srv->srvconf.dont_daemonize && 0 == graceful_restart) { parent_pipe_fd = daemonize(); } #endif graceful_restart = 0;/*(reset here after avoiding further daemonizing)*/ if (0 == oneshot_fd) graceful_shutdown = 0; server_main_setup_signals(); #ifdef HAVE_GETUID srv->gid = getgid(); srv->uid = getuid(); #endif srv->pid = getpid(); /* write pid file */ if (pid_fd > 2) { buffer * const tb = srv->tmp_buf; buffer_clear(tb); buffer_append_int(tb, srv->pid); buffer_append_char(tb, '\n'); if (-1 == write_all(pid_fd, BUF_PTR_LEN(tb))) { log_perror(srv->errh, __FILE__, __LINE__, "Couldn't write pid file"); close(pid_fd); pid_fd = -1; return -1; } } else if (pid_fd < -2) { pid_fd = -pid_fd; } /* Close stderr ASAP in the child process to make sure that nothing * is being written to that fd which may not be valid anymore. */ if (!srv->srvconf.preflight_check) { if (-1 == config_log_error_open(srv)) { log_error(srv->errh, __FILE__, __LINE__, "Opening errorlog failed. Going down."); return -1; } if (!oneshot_fd) log_error(srv->errh, __FILE__, __LINE__, "server started (" PACKAGE_DESC ")"); } if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) { log_error(srv->errh, __FILE__, __LINE__, "Configuration of plugins failed. Going down."); return -1; } if (!config_finalize(srv, &default_server_tag)) { return -1; } if (srv->srvconf.preflight_check) { /*printf("Preflight OK");*//*(stdout reopened to /dev/null)*/ return 0; } #ifdef HAVE_FORK /** * notify daemonize-grandparent of successful startup * do this before any further forking is done (workers) */ if (0 == srv->srvconf.dont_daemonize && -1 != parent_pipe_fd) { if (0 > write(parent_pipe_fd, "", 1)) return -1; close(parent_pipe_fd); } if (idle_limit && srv->srvconf.max_worker) { srv->srvconf.max_worker = 0; log_error(srv->errh, __FILE__, __LINE__, "server idle time limit command line option disables server.max-worker config file option."); } /* start watcher and workers */ if (srv->srvconf.max_worker > 0) { int rc = server_main_setup_workers(srv, srv->srvconf.max_worker); if (rc != 1) /* 1 for worker; 0 for worker parent done; -1 for error */ return rc; } #endif srv->max_fds = (int)srv->srvconf.max_fds; if (srv->max_fds < 32) /*(sanity check; not expected)*/ srv->max_fds = 32; /*(server load checks will fail if too low)*/ srv->ev = fdevent_init(srv->srvconf.event_handler, &srv->max_fds, &srv->cur_fds, srv->errh); if (NULL == srv->ev) { log_error(srv->errh, __FILE__, __LINE__, "fdevent_init failed"); return -1; } srv->max_fds_lowat = srv->max_fds * 8 / 10; srv->max_fds_hiwat = srv->max_fds * 9 / 10; /* set max-conns */ if (srv->srvconf.max_conns > srv->max_fds/2) { /* we can't have more connections than max-fds/2 */ log_error(srv->errh, __FILE__, __LINE__, "can't have more connections than fds/2: %hu %d", srv->srvconf.max_conns, srv->max_fds); srv->lim_conns = srv->srvconf.max_conns = srv->max_fds/2; } else if (srv->srvconf.max_conns) { /* otherwise respect the wishes of the user */ srv->lim_conns = srv->srvconf.max_conns; } else { /* or use the default: we really don't want to hit max-fds */ srv->lim_conns = srv->srvconf.max_conns = srv->max_fds/3; } /* * kqueue() is called here, select resets its internals, * all server sockets get their handlers * * */ if (0 != network_register_fdevents(srv)) { return -1; } chunkqueue_internal_pipes(config_feature_bool(srv, "chunkqueue.splice", 1)); /* might fail if user is using fam (not gamin) and famd isn't running */ if (!stat_cache_init(srv->ev, srv->errh)) { log_error(srv->errh, __FILE__, __LINE__, "stat-cache could not be setup, dying."); return -1; } #ifdef USE_ALARM { /* setup periodic timer (1 second) */ struct itimerval interval; interval.it_interval.tv_sec = 1; interval.it_interval.tv_usec = 0; interval.it_value.tv_sec = 1; interval.it_value.tv_usec = 0; if (setitimer(ITIMER_REAL, &interval, NULL)) { log_perror(srv->errh, __FILE__, __LINE__, "setitimer()"); return -1; } } #endif /* get the current number of FDs */ #ifdef _WIN32 srv->cur_fds = 3; /*(estimate on _WIN32)*/ #else { int fd = fdevent_open_devnull(); if (fd >= 0) { srv->cur_fds = fd; close(fd); } } #endif if (0 != server_sockets_set_nb_cloexec(srv)) { return -1; } /* plugin hook for worker_init */ if (HANDLER_GO_ON != plugins_call_worker_init(srv)) return -1; if (oneshot_fdout > 0) { if (server_oneshot_init_pipe(srv, oneshot_fd, oneshot_fdout)) { oneshot_fd = -1; oneshot_fdout = -1; } } else if (oneshot_fd && server_oneshot_init(srv, oneshot_fd)) { oneshot_fd = -1; } if (0 == srv->srvconf.max_worker) server_graceful_signal_prev_generation(); return 1; } __attribute_cold__ __attribute_noinline__ static void server_handle_sighup (server * const srv) { /* cycle logfiles */ plugins_call_handle_sighup(srv); fdlog_files_cycle(srv->errh); /* reopen log files, not pipes */ #ifdef HAVE_SIGACTION log_error(srv->errh, __FILE__, __LINE__, "logfiles cycled UID = %d PID = %d", (int)last_sighup_info.si_uid, (int)last_sighup_info.si_pid); #else log_error(srv->errh, __FILE__, __LINE__, "logfiles cycled"); #endif } __attribute_noinline__ static void server_handle_sigalrm (server * const srv, unix_time64_t mono_ts, unix_time64_t last_active_ts) { plugins_call_handle_trigger(srv); log_monotonic_secs = mono_ts; log_epoch_secs = server_epoch_secs(srv, 0); /* check idle time limit, if enabled */ if (idle_limit && idle_limit < mono_ts - last_active_ts && !graceful_shutdown) { log_error(srv->errh, __FILE__, __LINE__, "[note] idle timeout %ds exceeded, " "initiating graceful shutdown", (int)idle_limit); graceful_shutdown = 2; /* value 2 indicates idle timeout */ if (graceful_restart) { graceful_restart = 0; if (pid_fd < -2) pid_fd = -pid_fd; server_sockets_close(srv); } } #ifdef HAVE_GETLOADAVG /* refresh loadavg data every 30 seconds */ if (srv->loadts + 30 < mono_ts) { if (-1 != getloadavg(srv->loadavg, 3)) { srv->loadts = mono_ts; } } #endif if (0 == (mono_ts & 0x3f)) { /*(once every 64 secs)*/ /* free logger buffers every 64 secs */ fdlog_flushall(srv->errh); /* free excess chunkqueue buffers every 64 secs */ chunkqueue_chunk_pool_clear(); /* clear request and connection pools every 64 secs */ request_pool_free(); connections_pool_clear(srv); #if defined(HAVE_MALLOC_TRIM) if (malloc_trim_fn) malloc_trim_fn(malloc_top_pad); #endif /* attempt to restart dead piped loggers every 64 secs */ if (0 == srv->srvconf.max_worker) fdlog_pipes_restart(mono_ts); } /* cleanup stat-cache */ stat_cache_trigger_cleanup(); /* reset global/aggregate rate limit counters */ config_reset_config_bytes_sec(srv->config_data_base); /* if graceful_shutdown, accelerate cleanup of recently completed request/responses */ if (graceful_shutdown && !srv_shutdown) server_graceful_shutdown_maint(srv); connection_periodic_maint(srv, mono_ts); } __attribute_noinline__ static void server_handle_sigchld (server * const srv) { pid_t pid; do { int status; pid = fdevent_waitpid(-1, &status, 1); if (pid > 0) { if (plugins_call_handle_waitpid(srv, pid, status) != HANDLER_GO_ON) { continue; } if (0 == srv->srvconf.max_worker) { /* check piped-loggers and restart, even if shutting down */ if (fdlog_pipes_waitpid_cb(pid)) { continue; } } } } while (pid > 0 || (-1 == pid && errno == EINTR)); } __attribute_hot__ __attribute_nonnull__() static void server_run_con_queue (connection * const restrict joblist, const connection * const sentinel) { for (connection *con = joblist, *jqnext; con != sentinel; con = jqnext) { jqnext = con->jqnext; con->jqnext = NULL; connection_state_machine(con); } } __attribute_hot__ __attribute_noinline__ static void server_main_loop (server * const srv) { unix_time64_t last_active_ts = server_monotonic_secs(); log_epoch_secs = server_epoch_secs(srv, 0); while (!srv_shutdown) { if (handle_sig_hup) { handle_sig_hup = 0; server_handle_sighup(srv); } /*(USE_ALARM not used; fdevent_poll() is effective periodic timer)*/ #ifdef USE_ALARM if (handle_sig_alarm) { handle_sig_alarm = 0; #endif unix_time64_t mono_ts = server_monotonic_secs(); if (mono_ts != log_monotonic_secs) { server_handle_sigalrm(srv, mono_ts, last_active_ts); } #ifdef USE_ALARM } #endif if (handle_sig_child) { handle_sig_child = 0; server_handle_sigchld(srv); } if (graceful_shutdown) { server_graceful_state(srv); if (NULL == srv->conns && graceful_shutdown) { /* we are in graceful shutdown phase and all connections are closed * we are ready to terminate without harming anyone */ srv_shutdown = 1; break; } } else if (srv->sockets_disabled) { server_overload_check(srv); } else { server_load_check(srv); } #ifndef _MSC_VER static #endif connection * const sentinel = (connection *)(uintptr_t)&log_con_jqueue; connection * const joblist = log_con_jqueue; log_con_jqueue = sentinel; server_run_con_queue(joblist, sentinel); if (fdevent_poll(srv->ev, log_con_jqueue != sentinel ? 0 : 1000) > 0) last_active_ts = log_monotonic_secs; } } __attribute_cold__ __attribute_noinline__ static int main_init_once (void) { #ifdef HAVE_GETUID #ifndef HAVE_ISSETUGID #define issetugid() (geteuid() != getuid() || getegid() != getgid()) #endif if (0 != getuid() && issetugid()) { /*check as early as possible in main()*/ fprintf(stderr, "Are you nuts ? Don't apply a SUID bit to this binary\n"); return 0; } #endif #if defined(HAVE_MALLOPT) && defined(M_ARENA_MAX) #ifdef LIGHTTPD_STATIC mallopt(M_ARENA_MAX, 2); /*(ignore error, if any)*/ #else { int (*mallopt_fn)(int, int); mallopt_fn = (int (*)(int, int))(intptr_t)dlsym(RTLD_DEFAULT,"mallopt"); if (mallopt_fn) mallopt_fn(M_ARENA_MAX, 2); /*(ignore error, if any)*/ } #endif #endif #if defined(HAVE_MALLOC_TRIM) malloc_top_pad = 524288; { const char * const top_pad_str = getenv("MALLOC_TOP_PAD_"); if (top_pad_str) { unsigned long top_pad = strtoul(top_pad_str, NULL, 10); if (top_pad != ULONG_MAX) malloc_top_pad = (size_t)top_pad; } } #ifdef LIGHTTPD_STATIC malloc_trim_fn = malloc_trim; #else malloc_trim_fn = (int (*)(size_t))(intptr_t)dlsym(RTLD_DEFAULT,"malloc_trim"); #endif #endif /* for nice %b handling in strftime() */ #ifdef _WIN32 setlocale(LC_ALL, "C.UTF-8"); #ifdef __MINGW32__ _setmbcp(_MB_CP_LOCALE); #else _setmbcp(_MB_CP_UTF8); #endif #else setlocale(LC_TIME, "C"); #endif tzset(); return 1; } #ifndef server_status_running #define server_status_running(srv) do { } while (0) #endif #ifndef main #define server_main main #endif __attribute_cold__ int server_main (int argc, char ** argv) { if (!main_init_once()) return -1; int rc; do { server * const srv = server_init(); if (graceful_restart) { server_sockets_restore(srv); optind = 1; } rc = server_main_setup(srv, argc, argv); if (rc > 0) { server_status_running(srv); server_main_loop(srv); if (graceful_shutdown || graceful_restart) { server_graceful_state(srv); } if (NULL == srv->conns) rc = 0; if (2 == graceful_shutdown) { /* value 2 indicates idle timeout */ log_error(srv->errh, __FILE__, __LINE__, "server stopped after idle timeout"); } else if (!oneshot_fd) { #ifdef HAVE_SIGACTION log_error(srv->errh, __FILE__, __LINE__, "server stopped by UID = %d PID = %d", (int)last_sigterm_info.si_uid, (int)last_sigterm_info.si_pid); #else log_error(srv->errh, __FILE__, __LINE__, "server stopped"); #endif } } /* clean-up */ chunkqueue_internal_pipes(0); remove_pid_file(srv); config_log_error_close(srv); #ifdef _WIN32 fdevent_win32_cleanup(); #endif if (graceful_restart) server_sockets_save(srv); else network_close(srv); request_pool_free(); connections_free(srv); plugins_free(srv); server_free(srv); if (rc < 0 || !graceful_restart) break; /* wait for all children to exit before graceful restart */ while (fdevent_waitpid(-1, NULL, 0) > 0) ; } while (graceful_restart); return rc; }
dc09fecc51989ae0d53de41ba55e2aba21e0d02c
9923d63fc48c0fcc786c7d09789cbdebbd700f0a
/demo/os/rt-thread/stm32f10x/RT-Thread-1.2.2/src/irq.c
70b18e018c0c98d9a809ec7dea562216d364fd47
[ "GPL-2.0-only", "MIT" ]
permissive
armink/EasyLogger
87e92bcf83c405c8d4c6885eb0de0f017a68ac3d
8585ed801d8ae57af6f2bc41ada8107a0eca44de
refs/heads/master
2023-07-09T17:47:58.713944
2023-07-04T02:38:52
2023-07-04T02:38:52
35,313,328
3,279
1,136
MIT
2023-07-04T02:38:53
2015-05-09T03:25:54
C
UTF-8
C
false
false
2,511
c
irq.c
/* * File : irq.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team * * 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 02110-1301 USA. * * Change Logs: * Date Author Notes * 2006-02-24 Bernard first version * 2006-05-03 Bernard add IRQ_DEBUG */ #include <rthw.h> #include <rtthread.h> /* #define IRQ_DEBUG */ /** * @addtogroup Kernel */ /*@{*/ volatile rt_uint8_t rt_interrupt_nest; /** * This function will be invoked by BSP, when enter interrupt service routine * * @note please don't invoke this routine in application * * @see rt_interrupt_leave */ void rt_interrupt_enter(void) { rt_base_t level; RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq coming..., irq nest:%d\n", rt_interrupt_nest)); level = rt_hw_interrupt_disable(); rt_interrupt_nest ++; rt_hw_interrupt_enable(level); } RTM_EXPORT(rt_interrupt_enter); /** * This function will be invoked by BSP, when leave interrupt service routine * * @note please don't invoke this routine in application * * @see rt_interrupt_enter */ void rt_interrupt_leave(void) { rt_base_t level; RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq leave, irq nest:%d\n", rt_interrupt_nest)); level = rt_hw_interrupt_disable(); rt_interrupt_nest --; rt_hw_interrupt_enable(level); } RTM_EXPORT(rt_interrupt_leave); /** * This function will return the nest of interrupt. * * User application can invoke this function to get whether current * context is interrupt context. * * @return the number of nested interrupts. */ rt_uint8_t rt_interrupt_get_nest(void) { return rt_interrupt_nest; } RTM_EXPORT(rt_interrupt_get_nest); RTM_EXPORT(rt_hw_interrupt_disable); RTM_EXPORT(rt_hw_interrupt_enable); /*@}*/
8547c8861742d28cf40825dd6911360fed2ba7c6
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/net-mgmt/collectd5/files/patch-src_daemon_collectd.h
f7ee044bae137bfa187e2a1f0295222cc7c49505
[ "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
298
h
patch-src_daemon_collectd.h
--- src/daemon/collectd.h.orig 2019-06-13 09:13:42 UTC +++ src/daemon/collectd.h @@ -213,7 +213,7 @@ typedef int uid_t; #endif #ifndef PKGLOCALSTATEDIR -#define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME +#define PKGLOCALSTATEDIR PREFIX "/var/db/" PACKAGE_NAME #endif #ifndef PIDFILE
e8751bdfb5151c8616c43b18bb1508bfd95923ba
fb0f9abad373cd635c2635bbdf491ea0f32da5ff
/src/mono/mono/utils/json.h
7b7d8e82b46895ca4c7776ce277e0fc6ad23ad97
[ "MIT" ]
permissive
dotnet/runtime
f6fd23936752e202f8e4d6d94f3a4f3b0e77f58f
47bb554d298e1e34c4e3895d7731e18ad1c47d02
refs/heads/main
2023-09-03T15:35:46.493337
2023-09-03T08:13:23
2023-09-03T08:13:23
210,716,005
13,765
5,179
MIT
2023-09-14T21:58:52
2019-09-24T23:36:39
C#
UTF-8
C
false
false
1,394
h
json.h
/** * \file * JSON writer * * Author: * Joao Matos (joao.matos@xamarin.com) * * Copyright 2015 Xamarin Inc (http://www.xamarin.com) * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef __MONO_UTILS_JSON_H__ #define __MONO_UTILS_JSON_H__ #include <glib.h> #include "mono-compiler.h" #define JSON_INDENT_VALUE 2 typedef struct JsonWriter { GString* text; int indent; } JsonWriter; MONO_COMPONENT_API void mono_json_writer_init (JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_destroy (JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_indent(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_indent_push(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_indent_pop(JsonWriter* writer); void mono_json_writer_vprintf(JsonWriter* writer, const gchar *format, va_list args); MONO_COMPONENT_API void mono_json_writer_printf(JsonWriter* writer, const gchar *format, ...); MONO_COMPONENT_API void mono_json_writer_array_begin(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_array_end(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_object_begin(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_object_end(JsonWriter* writer); MONO_COMPONENT_API void mono_json_writer_object_key(JsonWriter* writer, const gchar* format, ...); #endif
6632207c58bb871fbdb9d5ca21a06163706c00b6
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/mojo/public/cpp/bindings/tracing_helpers.h
c64982522b80325dd14f2c8bf89dc0327b74dd71
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
1,177
h
tracing_helpers.h
// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MOJO_PUBLIC_CPP_BINDINGS_TRACING_HELPERS_H_ #define MOJO_PUBLIC_CPP_BINDINGS_TRACING_HELPERS_H_ #include "base/trace_event/trace_event.h" #include "build/buildflag.h" #include "mojo/public/cpp/bindings/message.h" #include "mojo/public/cpp/bindings/mojo_buildflags.h" // Helper for determine trace category for high-level coarse mojo events: // - If detailed mojo tracing is enabled, these events are not useful in most // circumstances (e.g. they capture only interface name, while detailed mojo // event tracing emits events which contain both interface and method names) // apart from debugging mojo or trace events, so "disabled-by-default-mojom" // category is used. // - If detailed mojo tracing is disabled, then the passed category is used. #if BUILDFLAG(MOJO_TRACE_ENABLED) #define TRACE_CATEGORY_OR_DISABLED_BY_DEFAULT_MOJOM(category) \ TRACE_DISABLED_BY_DEFAULT("mojom") #else #define TRACE_CATEGORY_OR_DISABLED_BY_DEFAULT_MOJOM(category) category #endif #endif // MOJO_PUBLIC_CPP_BINDINGS_TRACING_HELPERS_H_
f01f2e9bae06cc5c3a9adcd572c8bbebca75a304
21c92afbd7fd022a206fb31294c523aebb770104
/SuiteSparse/UMFPACK/Source/umf_utsolve.c
21eead8c75bb706ea50eb51700b0ad8b4fd9af8f
[ "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
9,229
c
umf_utsolve.c
/* ========================================================================== */ /* === UMF_utsolve ========================================================== */ /* ========================================================================== */ /* -------------------------------------------------------------------------- */ /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com. */ /* All Rights Reserved. See ../Doc/License.txt for License. */ /* -------------------------------------------------------------------------- */ /* solves U'x = b or U.'x=b, where U is the upper triangular factor of a */ /* matrix. B is overwritten with the solution X. */ /* Returns the floating point operation count */ #include "umf_internal.h" #include "umf_utsolve.h" GLOBAL double #ifdef CONJUGATE_SOLVE UMF_uhsolve /* solve U'x=b (complex conjugate transpose) */ #else UMF_utsolve /* solve U.'x=b (array transpose) */ #endif ( NumericType *Numeric, Entry X [ ], /* b on input, solution x on output */ Int Pattern [ ] /* a work array of size n */ ) { /* ---------------------------------------------------------------------- */ /* local variables */ /* ---------------------------------------------------------------------- */ Entry xk ; Entry *xp, *D, *Uval ; Int k, deg, j, *ip, col, *Upos, *Uilen, kstart, kend, up, *Uip, n, uhead, ulen, pos, npiv, n1, *Ui ; /* ---------------------------------------------------------------------- */ /* get parameters */ /* ---------------------------------------------------------------------- */ if (Numeric->n_row != Numeric->n_col) return (0.) ; n = Numeric->n_row ; npiv = Numeric->npiv ; Upos = Numeric->Upos ; Uilen = Numeric->Uilen ; Uip = Numeric->Uip ; D = Numeric->D ; kend = 0 ; n1 = Numeric->n1 ; #ifndef NDEBUG DEBUG4 (("Utsolve start: npiv "ID" n "ID"\n", npiv, n)) ; for (j = 0 ; j < n ; j++) { DEBUG4 (("Utsolve start "ID": ", j)) ; EDEBUG4 (X [j]) ; DEBUG4 (("\n")) ; } #endif /* ---------------------------------------------------------------------- */ /* singletons */ /* ---------------------------------------------------------------------- */ for (k = 0 ; k < n1 ; k++) { DEBUG4 (("Singleton k "ID"\n", k)) ; #ifndef NO_DIVIDE_BY_ZERO /* Go ahead and divide by zero if D [k] is zero. */ #ifdef CONJUGATE_SOLVE /* xk = X [k] / conjugate (D [k]) ; */ DIV_CONJ (xk, X [k], D [k]) ; #else /* xk = X [k] / D [k] ; */ DIV (xk, X [k], D [k]) ; #endif #else /* Do not divide by zero */ if (IS_NONZERO (D [k])) { #ifdef CONJUGATE_SOLVE /* xk = X [k] / conjugate (D [k]) ; */ DIV_CONJ (xk, X [k], D [k]) ; #else /* xk = X [k] / D [k] ; */ DIV (xk, X [k], D [k]) ; #endif } #endif X [k] = xk ; deg = Uilen [k] ; if (deg > 0 && IS_NONZERO (xk)) { up = Uip [k] ; Ui = (Int *) (Numeric->Memory + up) ; up += UNITS (Int, deg) ; Uval = (Entry *) (Numeric->Memory + up) ; for (j = 0 ; j < deg ; j++) { DEBUG4 ((" k "ID" col "ID" value", k, Ui [j])) ; EDEBUG4 (Uval [j]) ; DEBUG4 (("\n")) ; #ifdef CONJUGATE_SOLVE /* X [Ui [j]] -= xk * conjugate (Uval [j]) ; */ MULT_SUB_CONJ (X [Ui [j]], xk, Uval [j]) ; #else /* X [Ui [j]] -= xk * Uval [j] ; */ MULT_SUB (X [Ui [j]], xk, Uval [j]) ; #endif } } } /* ---------------------------------------------------------------------- */ /* nonsingletons */ /* ---------------------------------------------------------------------- */ for (kstart = n1 ; kstart < npiv ; kstart = kend + 1) { /* ------------------------------------------------------------------ */ /* find the end of this Uchain */ /* ------------------------------------------------------------------ */ DEBUG4 (("kstart "ID" kend "ID"\n", kstart, kend)) ; /* for (kend = kstart ; kend < npiv && Uip [kend+1] > 0 ; kend++) ; */ kend = kstart ; while (kend < npiv && Uip [kend+1] > 0) { kend++ ; } /* ------------------------------------------------------------------ */ /* scan the whole Uchain to find the pattern of the first row of U */ /* ------------------------------------------------------------------ */ k = kend+1 ; DEBUG4 (("\nKend "ID" K "ID"\n", kend, k)) ; /* ------------------------------------------------------------------ */ /* start with last row in Uchain of U in Pattern [0..deg-1] */ /* ------------------------------------------------------------------ */ if (k == npiv) { deg = Numeric->ulen ; if (deg > 0) { /* :: make last pivot row of U (singular matrices only) :: */ for (j = 0 ; j < deg ; j++) { Pattern [j] = Numeric->Upattern [j] ; } } } else { ASSERT (k >= 0 && k < npiv) ; up = -Uip [k] ; ASSERT (up > 0) ; deg = Uilen [k] ; DEBUG4 (("end of chain for row of U "ID" deg "ID"\n", k-1, deg)) ; ip = (Int *) (Numeric->Memory + up) ; for (j = 0 ; j < deg ; j++) { col = *ip++ ; DEBUG4 ((" k "ID" col "ID"\n", k-1, col)) ; ASSERT (k <= col) ; Pattern [j] = col ; } } /* empty the stack at the bottom of Pattern */ uhead = n ; for (k = kend ; k > kstart ; k--) { /* Pattern [0..deg-1] is the pattern of row k of U */ /* -------------------------------------------------------------- */ /* make row k-1 of U in Pattern [0..deg-1] */ /* -------------------------------------------------------------- */ ASSERT (k >= 0 && k < npiv) ; ulen = Uilen [k] ; /* delete, and push on the stack */ for (j = 0 ; j < ulen ; j++) { ASSERT (uhead >= deg) ; Pattern [--uhead] = Pattern [--deg] ; } DEBUG4 (("middle of chain for row of U "ID" deg "ID"\n", k, deg)) ; ASSERT (deg >= 0) ; pos = Upos [k] ; if (pos != EMPTY) { /* add the pivot column */ DEBUG4 (("k "ID" add pivot entry at position "ID"\n", k, pos)) ; ASSERT (pos >= 0 && pos <= deg) ; Pattern [deg++] = Pattern [pos] ; Pattern [pos] = k ; } } /* Pattern [0..deg-1] is now the pattern of the first row in Uchain */ /* ------------------------------------------------------------------ */ /* solve using this Uchain, in reverse order */ /* ------------------------------------------------------------------ */ DEBUG4 (("Unwinding Uchain\n")) ; for (k = kstart ; k <= kend ; k++) { /* -------------------------------------------------------------- */ /* construct row k */ /* -------------------------------------------------------------- */ ASSERT (k >= 0 && k < npiv) ; pos = Upos [k] ; if (pos != EMPTY) { /* remove the pivot column */ DEBUG4 (("k "ID" add pivot entry at position "ID"\n", k, pos)) ; ASSERT (k > kstart) ; ASSERT (pos >= 0 && pos < deg) ; ASSERT (Pattern [pos] == k) ; Pattern [pos] = Pattern [--deg] ; } up = Uip [k] ; ulen = Uilen [k] ; if (k > kstart) { /* concatenate the deleted pattern; pop from the stack */ for (j = 0 ; j < ulen ; j++) { ASSERT (deg <= uhead && uhead < n) ; Pattern [deg++] = Pattern [uhead++] ; } DEBUG4 (("middle of chain, row of U "ID" deg "ID"\n", k, deg)) ; ASSERT (deg >= 0) ; } /* -------------------------------------------------------------- */ /* use row k of U */ /* -------------------------------------------------------------- */ #ifndef NO_DIVIDE_BY_ZERO /* Go ahead and divide by zero if D [k] is zero. */ #ifdef CONJUGATE_SOLVE /* xk = X [k] / conjugate (D [k]) ; */ DIV_CONJ (xk, X [k], D [k]) ; #else /* xk = X [k] / D [k] ; */ DIV (xk, X [k], D [k]) ; #endif #else /* Do not divide by zero */ if (IS_NONZERO (D [k])) { #ifdef CONJUGATE_SOLVE /* xk = X [k] / conjugate (D [k]) ; */ DIV_CONJ (xk, X [k], D [k]) ; #else /* xk = X [k] / D [k] ; */ DIV (xk, X [k], D [k]) ; #endif } #endif X [k] = xk ; if (IS_NONZERO (xk)) { if (k == kstart) { up = -up ; xp = (Entry *) (Numeric->Memory + up + UNITS (Int, ulen)) ; } else { xp = (Entry *) (Numeric->Memory + up) ; } for (j = 0 ; j < deg ; j++) { DEBUG4 ((" k "ID" col "ID" value", k, Pattern [j])) ; EDEBUG4 (*xp) ; DEBUG4 (("\n")) ; #ifdef CONJUGATE_SOLVE /* X [Pattern [j]] -= xk * conjugate (*xp) ; */ MULT_SUB_CONJ (X [Pattern [j]], xk, *xp) ; #else /* X [Pattern [j]] -= xk * (*xp) ; */ MULT_SUB (X [Pattern [j]], xk, *xp) ; #endif xp++ ; } } } ASSERT (uhead == n) ; } #ifndef NO_DIVIDE_BY_ZERO for (k = npiv ; k < n ; k++) { /* This is an *** intentional *** divide-by-zero, to get Inf or Nan, * as appropriate. It is not a bug. */ ASSERT (IS_ZERO (D [k])) ; /* For conjugate solve, D [k] == conjugate (D [k]), in this case */ /* xk = X [k] / D [k] ; */ DIV (xk, X [k], D [k]) ; X [k] = xk ; } #endif #ifndef NDEBUG for (j = 0 ; j < n ; j++) { DEBUG4 (("Utsolve done "ID": ", j)) ; EDEBUG4 (X [j]) ; DEBUG4 (("\n")) ; } DEBUG4 (("Utsolve done.\n")) ; #endif return (DIV_FLOPS * ((double) n) + MULTSUB_FLOPS * ((double) Numeric->unz)); }
b5ee6d174fb3d676a309c2fa6b8d095d31054034
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/fuchsia_web/common/test/test_devtools_list_fetcher.h
b8da70f5dd5edb230b128bcc642df382dd340ae5
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
582
h
test_devtools_list_fetcher.h
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef FUCHSIA_WEB_COMMON_TEST_TEST_DEVTOOLS_LIST_FETCHER_H_ #define FUCHSIA_WEB_COMMON_TEST_TEST_DEVTOOLS_LIST_FETCHER_H_ #include <stdint.h> #include "base/values.h" // Returns the JSON value of the list URL for the DevTools service listening // on port |port| on localhost. Returns an empty value on error. base::Value::List GetDevToolsListFromPort(uint16_t port); #endif // FUCHSIA_WEB_COMMON_TEST_TEST_DEVTOOLS_LIST_FETCHER_H_
3671b81f23be44abd25392fdc21405303d352c9c
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/qemu-vexpress-a9/drivers/board.c
6c6d1df07fae64e23722052bb38faa98e74d478d
[ "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
2,278
c
board.c
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2012-11-20 Bernard the first version * 2018-11-22 Jesven add rt_hw_spin_lock * add rt_hw_spin_unlock * add smp ipi init */ #include <rthw.h> #include <rtthread.h> #include "board.h" #include "drv_timer.h" #include "mm_aspace.h" #include <mmu.h> #ifdef RT_USING_SMART #include <page.h> #include <lwp_arch.h> #endif #ifdef RT_USING_SMART struct mem_desc platform_mem_desc[] = { {KERNEL_VADDR_START, KERNEL_VADDR_START + 0x10000000, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM} }; #else struct mem_desc platform_mem_desc[] = { {0x10000000, 0x50000000, 0x10000000, DEVICE_MEM}, {0x60000000, 0x70000000, 0x60000000, NORMAL_MEM} }; #endif const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]); #define SYS_CTRL __REG32(REALVIEW_SCTL_BASE) extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler); void idle_wfi(void) { asm volatile ("wfi"); } /** * This function will initialize board */ extern size_t MMUTable[]; #ifdef RT_USING_SMART rt_region_t init_page_region = { (uint32_t)PAGE_START, (uint32_t)PAGE_END, }; #endif void rt_hw_board_init(void) { #ifdef RT_USING_SMART rt_hw_mmu_map_init(&rt_kernel_space, (void*)0xf0000000, 0x10000000, MMUTable, PV_OFFSET); rt_page_init(init_page_region); rt_hw_mmu_ioremap_init(&rt_kernel_space, (void*)0xf0000000, 0x10000000); arch_kuser_init(&rt_kernel_space, (void*)0xffff0000); #else rt_hw_mmu_map_init(&rt_kernel_space, (void*)0x80000000, 0x10000000, MMUTable, 0); rt_hw_mmu_ioremap_init(&rt_kernel_space, (void*)0x80000000, 0x10000000); #endif /* initialize system heap */ rt_system_heap_init(HEAP_BEGIN, HEAP_END); /* initialize hardware interrupt */ rt_hw_interrupt_init(); rt_components_board_init(); rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_thread_idle_sethook(idle_wfi); #ifdef RT_USING_SMP /* install IPI handle */ rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler); #endif }
2e859641d4e2f3745c69dabebc32a7b7160688c4
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/zlib/adler32_simd.h
0b2361a5174f7af327d52889771f94c0634184fa
[ "BSD-3-Clause", "Zlib", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
363
h
adler32_simd.h
/* adler32_simd.h * * Copyright 2017 The Chromium Authors * Use of this source code is governed by a BSD-style license that can be * found in the Chromium source repository LICENSE file. */ #include <stdint.h> #include "zconf.h" #include "zutil.h" uint32_t ZLIB_INTERNAL adler32_simd_( uint32_t adler, const unsigned char *buf, z_size_t len);