hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
2bd20cd0ad15fd428caf9e462f7095cfa419e50a
3,599
h
C
main/sal/rtl/source/alloc_arena.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
679
2015-01-06T06:34:58.000Z
2022-03-30T01:06:03.000Z
main/sal/rtl/source/alloc_arena.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
102
2017-11-07T08:51:31.000Z
2022-03-17T12:13:49.000Z
main/sal/rtl/source/alloc_arena.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
331
2015-01-06T11:40:55.000Z
2022-03-14T04:07:51.000Z
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #ifndef INCLUDED_RTL_ALLOC_ARENA_H #define INCLUDED_RTL_ALLOC_ARENA_H #include "sal/types.h" #include "rtl/alloc.h" #include "alloc_impl.h" #ifdef __cplusplus extern "C" { #endif /** rtl_arena_stat_type * @internal */ typedef struct rtl_arena_stat_st rtl_arena_stat_type; struct rtl_arena_stat_st { sal_uInt64 m_alloc; sal_uInt64 m_free; sal_Size m_mem_total; sal_Size m_mem_alloc; }; /** rtl_arena_segment_type * @internal */ #define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01)) #define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02)) #define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04)) #define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08)) typedef struct rtl_arena_segment_st rtl_arena_segment_type; struct rtl_arena_segment_st { /* segment list linkage */ rtl_arena_segment_type * m_snext; rtl_arena_segment_type * m_sprev; /* free/used list linkage */ rtl_arena_segment_type * m_fnext; rtl_arena_segment_type * m_fprev; /* segment description */ sal_uIntPtr m_addr; sal_Size m_size; sal_Size m_type; }; /** rtl_arena_type * @internal */ #define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8) #define RTL_ARENA_HASH_SIZE 64 #define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */ struct rtl_arena_st { /* linkage */ rtl_arena_type * m_arena_next; rtl_arena_type * m_arena_prev; /* properties */ char m_name[RTL_ARENA_NAME_LENGTH + 1]; long m_flags; rtl_memory_lock_type m_lock; rtl_arena_stat_type m_stats; rtl_arena_type * m_source_arena; void * (SAL_CALL * m_source_alloc)(rtl_arena_type *, sal_Size *); void (SAL_CALL * m_source_free) (rtl_arena_type *, void *, sal_Size); sal_Size m_quantum; sal_Size m_quantum_shift; /* log2(m_quantum) */ rtl_arena_segment_type m_segment_reserve_span_head; rtl_arena_segment_type m_segment_reserve_head; rtl_arena_segment_type m_segment_head; rtl_arena_segment_type m_freelist_head[RTL_ARENA_FREELIST_SIZE]; sal_Size m_freelist_bitmap; rtl_arena_segment_type ** m_hash_table; rtl_arena_segment_type * m_hash_table_0[RTL_ARENA_HASH_SIZE]; sal_Size m_hash_size; /* m_hash_mask + 1 */ sal_Size m_hash_shift; /* log2(m_hash_size) */ sal_Size m_qcache_max; rtl_cache_type ** m_qcache_ptr; }; /** gp_default_arena * default arena with pagesize quantum * * @internal */ extern rtl_arena_type * gp_default_arena; #ifdef __cplusplus } #endif #endif /* INCLUDED_RTL_ALLOC_ARENA_H */
26.858209
72
0.691859
281227901dc05a73904245cbaa7c782742b220f5
1,369
h
C
src/frontend/qt/qt_window.h
destoer/destoer-emu
2a7941b175126e998eed2df8df87ee382c43d0b1
[ "BSD-3-Clause" ]
20
2020-01-19T21:54:23.000Z
2021-11-28T17:27:15.000Z
src/frontend/qt/qt_window.h
destoer/destoer-emu
2a7941b175126e998eed2df8df87ee382c43d0b1
[ "BSD-3-Clause" ]
3
2020-05-01T07:46:10.000Z
2021-09-18T13:50:18.000Z
src/frontend/qt/qt_window.h
destoer/destoer-emu
2a7941b175126e998eed2df8df87ee382c43d0b1
[ "BSD-3-Clause" ]
null
null
null
#ifdef FRONTEND_QT #include <QMainWindow> #include <QApplication> #include <QTextStream> #include <QAction> #include <QLabel> #include <QMenu> #include <QVBoxLayout> #include <destoer-emu/emulator.h> #include "framebuffer.h" #include "gameboy_instance.h" #include "gba_instance.h" class QtMainWindow : public QMainWindow { Q_OBJECT public: QtMainWindow(); ~QtMainWindow(); FrameBuffer framebuffer; private slots: void open(); void load_state(); void save_state(); //void disassembler(); <-- disassembler implemented in imgui first for now! protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; private: void create_actions(); void create_menus(); QMenu *file_menu; QAction *open_act; QAction *load_state_act; QAction *save_state_act; QMenu *emu_menu; QAction *pause_emulator_act; QAction *continue_emulator_act; QAction *disable_audio_act; QAction *enable_audio_act; QLabel *info_label; QThread *emu_thread; void stop_emu(); void start_emu(); void disable_audio(); void enable_audio(); bool emu_running = false; GameboyInstance gb_instance; GbaInstance gba_instance; emu_type running_type = emu_type::none; }; #endif
21.390625
80
0.677137
2b64e53294317645b39a0e1e2a2be002009a565c
521
c
C
bench/graphdiameter/src/msgTest.c
jiverson002/bdmpi
11fc719f82a6851644fa21c6b12b0adec84feaf9
[ "Apache-2.0" ]
null
null
null
bench/graphdiameter/src/msgTest.c
jiverson002/bdmpi
11fc719f82a6851644fa21c6b12b0adec84feaf9
[ "Apache-2.0" ]
null
null
null
bench/graphdiameter/src/msgTest.c
jiverson002/bdmpi
11fc719f82a6851644fa21c6b12b0adec84feaf9
[ "Apache-2.0" ]
null
null
null
#include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char *inMsg, *outMsg = "ping_pong_ball"; /* SegFault: inMsg not initialized */ // int msgLen = strlen(outMsg); /* CORRECT! */ // char *inMsg = "ping_pong_ball"; // char *outMsg = inMsg; int inMsgLen = strlen(inMsg); int outMsgLen = strlen(outMsg); printf("inMsg: %s\n", inMsg); printf("outMsg: %s\n", outMsg); printf("inMsg has %d chars.\n", inMsgLen); printf("outMsg has %d chars.\n", outMsgLen); return 0; }
22.652174
81
0.618042
7f3c08e974ae28330032450d03f850be4efca74f
5,463
c
C
LibWebP/src/enc/picture_psnr.c
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
2
2015-03-23T01:08:49.000Z
2015-03-23T02:28:17.000Z
LibWebP/src/enc/picture_psnr.c
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
null
null
null
LibWebP/src/enc/picture_psnr.c
sim9108/SDKS
2823124fa0a22f8a77d131e7a2fb7f4aba59129c
[ "MIT" ]
null
null
null
// Copyright 2014 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // WebPPicture tools for measuring distortion // // Author: Skal (pascal.massimino@gmail.com) #include <math.h> #include "enc/vp8enci.h" //------------------------------------------------------------------------------ // local-min distortion // // For every pixel in the *reference* picture, we search for the local best // match in the compressed image. This is not a symmetrical measure. #define RADIUS 2 // search radius. Shouldn't be too large. static float AccumulateLSIM(const uint8_t* src, int src_stride, const uint8_t* ref, int ref_stride, int w, int h) { int x, y; double total_sse = 0.; for (y = 0; y < h; ++y) { const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS; const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1; for (x = 0; x < w; ++x) { const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS; const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1; double best_sse = 255. * 255.; const double value = (double)ref[y * ref_stride + x]; int i, j; for (j = y_0; j < y_1; ++j) { const uint8_t* s = src + j * src_stride; for (i = x_0; i < x_1; ++i) { const double sse = (double)(s[i] - value) * (s[i] - value); if (sse < best_sse) best_sse = sse; } } total_sse += best_sse; } } return (float)total_sse; } #undef RADIUS //------------------------------------------------------------------------------ // Distortion // Max value returned in case of exact similarity. static const double kMinDistortion_dB = 99.; static float GetPSNR(const double v) { return (float)((v > 0.) ? -4.3429448 * log(v / (255 * 255.)) : kMinDistortion_dB); } int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref, int type, float result[5]) { DistoStats stats[5]; int has_alpha; int uv_w, uv_h; if (src == NULL || ref == NULL || src->width != ref->width || src->height != ref->height || src->y == NULL || ref->y == NULL || src->u == NULL || ref->u == NULL || src->v == NULL || ref->v == NULL || result == NULL) { return 0; } // TODO(skal): provide distortion for ARGB too. if (src->use_argb == 1 || src->use_argb != ref->use_argb) { return 0; } has_alpha = !!(src->colorspace & WEBP_CSP_ALPHA_BIT); if (has_alpha != !!(ref->colorspace & WEBP_CSP_ALPHA_BIT) || (has_alpha && (src->a == NULL || ref->a == NULL))) { return 0; } memset(stats, 0, sizeof(stats)); uv_w = (src->width + 1) >> 1; uv_h = (src->height + 1) >> 1; if (type >= 2) { float sse[4]; sse[0] = AccumulateLSIM(src->y, src->y_stride, ref->y, ref->y_stride, src->width, src->height); sse[1] = AccumulateLSIM(src->u, src->uv_stride, ref->u, ref->uv_stride, uv_w, uv_h); sse[2] = AccumulateLSIM(src->v, src->uv_stride, ref->v, ref->uv_stride, uv_w, uv_h); sse[3] = has_alpha ? AccumulateLSIM(src->a, src->a_stride, ref->a, ref->a_stride, src->width, src->height) : 0.f; result[0] = GetPSNR(sse[0] / (src->width * src->height)); result[1] = GetPSNR(sse[1] / (uv_w * uv_h)); result[2] = GetPSNR(sse[2] / (uv_w * uv_h)); result[3] = GetPSNR(sse[3] / (src->width * src->height)); { double total_sse = sse[0] + sse[1] + sse[2]; int total_pixels = src->width * src->height + 2 * uv_w * uv_h; if (has_alpha) { total_pixels += src->width * src->height; total_sse += sse[3]; } result[4] = GetPSNR(total_sse / total_pixels); } } else { int c; VP8SSIMAccumulatePlane(src->y, src->y_stride, ref->y, ref->y_stride, src->width, src->height, &stats[0]); VP8SSIMAccumulatePlane(src->u, src->uv_stride, ref->u, ref->uv_stride, uv_w, uv_h, &stats[1]); VP8SSIMAccumulatePlane(src->v, src->uv_stride, ref->v, ref->uv_stride, uv_w, uv_h, &stats[2]); if (has_alpha) { VP8SSIMAccumulatePlane(src->a, src->a_stride, ref->a, ref->a_stride, src->width, src->height, &stats[3]); } for (c = 0; c <= 4; ++c) { if (type == 1) { const double v = VP8SSIMGet(&stats[c]); result[c] = (float)((v < 1.) ? -10.0 * log10(1. - v) : kMinDistortion_dB); } else { const double v = VP8SSIMGetSquaredError(&stats[c]); result[c] = GetPSNR(v); } // Accumulate forward if (c < 4) VP8SSIMAddStats(&stats[c], &stats[4]); } } return 1; } //------------------------------------------------------------------------------
36.178808
80
0.496614
2c98398d2299ad551d78b76dba4285c1788bbad3
1,455
h
C
src/dfm/protocol/UintTypes.h
dfm-official/dfm
97f133aa87b17c760b90f2358d6ba10bc7ad9d1f
[ "ISC" ]
null
null
null
src/dfm/protocol/UintTypes.h
dfm-official/dfm
97f133aa87b17c760b90f2358d6ba10bc7ad9d1f
[ "ISC" ]
null
null
null
src/dfm/protocol/UintTypes.h
dfm-official/dfm
97f133aa87b17c760b90f2358d6ba10bc7ad9d1f
[ "ISC" ]
null
null
null
#ifndef RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED #define RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED #include <ripple/basics/UnorderedContainers.h> #include <ripple/basics/base_uint.h> #include <ripple/protocol/AccountID.h> #include <ripple/beast/utility/Zero.h> namespace ripple { namespace detail { class CurrencyTag { public: explicit CurrencyTag() = default; }; class DirectoryTag { public: explicit DirectoryTag() = default; }; class NodeIDTag { public: explicit NodeIDTag() = default; }; } using Directory = base_uint<256, detail::DirectoryTag>; using Currency = base_uint<160, detail::CurrencyTag>; using NodeID = base_uint<160, detail::NodeIDTag>; Currency const& xrpCurrency(); Currency const& noCurrency(); Currency const& badCurrency(); inline bool isXRP(Currency const& c) { return c == beast::zero; } std::string to_string(Currency const& c); bool to_currency(Currency&, std::string const&); Currency to_currency(std::string const&); inline std::ostream& operator<< (std::ostream& os, Currency const& x) { os << to_string (x); return os; } } namespace std { template <> struct hash <ripple::Currency> : ripple::Currency::hasher { explicit hash() = default; }; template <> struct hash <ripple::NodeID> : ripple::NodeID::hasher { explicit hash() = default; }; template <> struct hash <ripple::Directory> : ripple::Directory::hasher { explicit hash() = default; }; } #endif
13.857143
69
0.704467
82f0fb485d858f46a52464ca18a5498bd6909de5
1,920
h
C
MUSEN/Modules/SystemStructure/Bond.h
msolids/musen
67d9a70d03d771ccda649c21b78d165684e31171
[ "BSD-3-Clause" ]
19
2020-09-28T07:22:50.000Z
2022-03-07T09:52:20.000Z
MUSEN/Modules/SystemStructure/Bond.h
LasCondes/musen
18961807928285ff802e050050f4c627dd7bec1e
[ "BSD-3-Clause" ]
5
2020-12-26T18:18:27.000Z
2022-02-23T22:56:43.000Z
MUSEN/Modules/SystemStructure/Bond.h
LasCondes/musen
18961807928285ff802e050050f4c627dd7bec1e
[ "BSD-3-Clause" ]
11
2020-11-02T11:32:03.000Z
2022-01-27T08:22:04.000Z
/* Copyright (c) 2013-2020, MUSEN Development Team. All rights reserved. This file is part of MUSEN framework http://msolids.net/musen. See LICENSE file for license and warranty information. */ #pragma once #include "PhysicalObject.h" class CBond : public CPhysicalObject { public: unsigned int m_nLeftObjectID; // The id of the first connected body. unsigned int m_nRightObjectID; // The id of the second connected body. CBond(unsigned _id, CDemStorage* _storage); std::string GetObjectGeometryText() const override; void SetObjectGeometryText(std::stringstream& _inputStream) override; std::vector<uint8_t> GetObjectGeometryBin() const override; void SetObjectGeometryBin(const std::vector<uint8_t>& _data) override; inline double GetDiameter() const { return m_dDiameter; } inline double GetInitLength() const { return m_dInitialLength; } inline double GetViscosity() const { return m_dViscosity; } inline void SetDiameter(const double _diameter) { m_dDiameter = _diameter; UpdatePrecalculatedValues(); } inline void SetInitialLength(const double _dLength) { m_dInitialLength = _dLength; } protected: double m_dDiameter; // the diameter of the bond [m] double m_dViscosity; double m_dInitialLength; // Initial length of the bond [m]. private: // Is needed to convert data for saving/loading. union USaveHelper { #pragma pack(push, 1) // Is important for cross-compiler compatibility. struct SSaveData // A structure with data for saving/loading. The order matters! { uint32_t idLeft; uint32_t idRight; double diameter; double initialLength; } data; #pragma pack(pop) uint8_t binary[sizeof(SSaveData)]; // A binary form of the data. USaveHelper(const SSaveData& _data) : data{ _data } {} // Initialize data. explicit USaveHelper(const std::vector<uint8_t>& _data) { std::copy(_data.begin(), _data.end(), binary); } // Initialize binary. }; };
38.4
130
0.746875
d20441acc87db428a118ab7787f4ec9887b3632b
7,575
h
C
SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h
malbouis/cmssw
16173a30d3f0c9ecc5419c474bb4d272c58b65c8
[ "Apache-2.0" ]
852
2015-01-11T21:03:51.000Z
2022-03-25T21:14:00.000Z
SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h
malbouis/cmssw
16173a30d3f0c9ecc5419c474bb4d272c58b65c8
[ "Apache-2.0" ]
30,371
2015-01-02T00:14:40.000Z
2022-03-31T23:26:05.000Z
SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h
malbouis/cmssw
16173a30d3f0c9ecc5419c474bb4d272c58b65c8
[ "Apache-2.0" ]
3,240
2015-01-02T05:53:18.000Z
2022-03-31T17:24:21.000Z
#ifndef SimCalorimetry_EcalSimProducers_EcalDigiProducer_h #define SimCalorimetry_EcalSimProducers_EcalDigiProducer_h #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h" #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h" #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h" #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h" #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h" #include "CondFormats/DataRecord/interface/ESGainRcd.h" #include "CondFormats/DataRecord/interface/ESIntercalibConstantsRcd.h" #include "CondFormats/DataRecord/interface/ESMIPToGeVConstantRcd.h" #include "CondFormats/DataRecord/interface/ESPedestalsRcd.h" #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h" #include "CondFormats/EcalObjects/interface/EcalGainRatios.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h" #include "CondFormats/EcalObjects/interface/EcalPedestals.h" #include "CondFormats/ESObjects/interface/ESGain.h" #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h" #include "CondFormats/ESObjects/interface/ESMIPToGeVConstant.h" #include "CondFormats/ESObjects/interface/ESPedestals.h" #include "DataFormats/Math/interface/Error.h" #include "CalibFormats/CaloObjects/interface/CaloTSamples.h" #include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/Framework/interface/ProducesCollector.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "SimCalorimetry/EcalSimAlgos/interface/APDShape.h" #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h" #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim.h" #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSim.h" #include "SimCalorimetry/EcalSimAlgos/interface/ESShape.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix.h" #include "SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.h" #include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer.h" #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" #include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h" #include <vector> typedef EcalTDigitizer<EBDigitizerTraits> EBDigitizer; typedef EcalTDigitizer<EEDigitizerTraits> EEDigitizer; typedef CaloTDigitizer<ESOldDigitizerTraits> ESOldDigitizer; class ESDigitizer; class APDSimParameters; class EEHitResponse; class ESHitResponse; class CaloHitResponse; class EcalSimParameterMap; class EcalCoder; class ESElectronicsSim; class ESElectronicsSimFast; class EcalBaseSignalGenerator; class CaloGeometry; class EBDigiCollection; class EEDigiCollection; class ESDigiCollection; class PileUpEventPrincipal; namespace edm { class ConsumesCollector; class Event; class EventSetup; template <typename T> class Handle; class ParameterSet; class StreamID; } // namespace edm namespace CLHEP { class HepRandomEngine; } class EcalDigiProducer : public DigiAccumulatorMixMod { public: EcalDigiProducer(const edm::ParameterSet &params, edm::ProducesCollector, edm::ConsumesCollector &iC); EcalDigiProducer(const edm::ParameterSet &params, edm::ConsumesCollector &iC); ~EcalDigiProducer() override; void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override; void accumulate(edm::Event const &e, edm::EventSetup const &c) override; void accumulate(PileUpEventPrincipal const &e, edm::EventSetup const &c, edm::StreamID const &) override; void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override; void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override; void setEBNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator); void setEENoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator); void setESNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator); private: virtual void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const {} virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const {} typedef edm::Handle<std::vector<PCaloHit>> HitsHandle; void accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, HitsHandle const &esHandle, int bunchCrossing); void checkGeometry(const edm::EventSetup &eventSetup); void updateGeometry(); void checkCalibrations(const edm::Event &event, const edm::EventSetup &eventSetup); APDShape m_APDShape; EBShape m_EBShape; EEShape m_EEShape; ESShape m_ESShape; // no const because gain must be set const std::string m_EBdigiCollection; const std::string m_EEdigiCollection; const std::string m_ESdigiCollection; const std::string m_hitsProducerTag; const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> m_pedestalsToken; const edm::ESGetToken<EcalIntercalibConstantsMC, EcalIntercalibConstantsMCRcd> m_icalToken; const edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> m_laserToken; const edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> m_agcToken; const edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> m_grToken; const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> m_geometryToken; edm::ESGetToken<ESGain, ESGainRcd> m_esGainToken; edm::ESGetToken<ESMIPToGeVConstant, ESMIPToGeVConstantRcd> m_esMIPToGeVToken; edm::ESGetToken<ESPedestals, ESPedestalsRcd> m_esPedestalsToken; edm::ESGetToken<ESIntercalibConstants, ESIntercalibConstantsRcd> m_esMIPsToken; edm::ESWatcher<CaloGeometryRecord> m_geometryWatcher; bool m_useLCcorrection; const bool m_apdSeparateDigi; const double m_EBs25notCont; const double m_EEs25notCont; const unsigned int m_readoutFrameSize; protected: std::unique_ptr<const EcalSimParameterMap> m_ParameterMap; private: const std::string m_apdDigiTag; std::unique_ptr<const APDSimParameters> m_apdParameters; std::unique_ptr<EBHitResponse> m_APDResponse; protected: std::unique_ptr<EBHitResponse> m_EBResponse; std::unique_ptr<EEHitResponse> m_EEResponse; private: std::unique_ptr<ESHitResponse> m_ESResponse; std::unique_ptr<CaloHitResponse> m_ESOldResponse; const bool m_addESNoise; const bool m_PreMix1; const bool m_PreMix2; const bool m_doFastES; const bool m_doEB, m_doEE, m_doES; std::unique_ptr<ESElectronicsSim> m_ESElectronicsSim; std::unique_ptr<ESOldDigitizer> m_ESOldDigitizer; std::unique_ptr<ESElectronicsSimFast> m_ESElectronicsSimFast; std::unique_ptr<ESDigitizer> m_ESDigitizer; std::unique_ptr<EBDigitizer> m_APDDigitizer; std::unique_ptr<EBDigitizer> m_BarrelDigitizer; std::unique_ptr<EEDigitizer> m_EndcapDigitizer; typedef CaloTSamples<float, 10> EcalSamples; typedef EcalElectronicsSim<EcalCoder, EcalSamples, EcalDataFrame> EcalElectronicsSim_Ph1; std::unique_ptr<EcalElectronicsSim_Ph1> m_ElectronicsSim; std::unique_ptr<EcalCoder> m_Coder; std::unique_ptr<EcalElectronicsSim_Ph1> m_APDElectronicsSim; std::unique_ptr<EcalCoder> m_APDCoder; const CaloGeometry *m_Geometry; std::array<std::unique_ptr<CorrelatedNoisifier<EcalCorrMatrix>>, 3> m_EBCorrNoise; std::array<std::unique_ptr<CorrelatedNoisifier<EcalCorrMatrix>>, 3> m_EECorrNoise; CLHEP::HepRandomEngine *randomEngine_ = nullptr; }; #endif
39.046392
107
0.817954
c59183fdbf16497d557d96b6acc74c899eba882f
1,135
h
C
src/internal.h
nexos-dev/libnex
66980485a20cfedbcfdf0667324b9dbbc70aae14
[ "Apache-2.0" ]
null
null
null
src/internal.h
nexos-dev/libnex
66980485a20cfedbcfdf0667324b9dbbc70aae14
[ "Apache-2.0" ]
null
null
null
src/internal.h
nexos-dev/libnex
66980485a20cfedbcfdf0667324b9dbbc70aae14
[ "Apache-2.0" ]
null
null
null
/* internal.h - contains internal libnex things that shouldn't be visible to the outside Copyright 2022 The NexNix Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. There should be a copy of the License distributed in a file named LICENSE, if not, you may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _LIBNEX_INTERNAL_H #define _LIBNEX_INTERNAL_H #include <libintl.h> #include <libnex_config.h> #include <locale.h> // Initializes internationalization for libnex void __Libnex_i18n_init(); #ifdef LIBNEX_ENABLE_NLS #define _(str) dgettext ("libnex", str) #define N_(str) (str) #else #define _(str) (str) #define N_(str) (str) #endif #endif
29.868421
89
0.743612
5cd8e606209e18d44e669d2ad0c7352ea5ac1dfd
77,984
c
C
sources/cg_json_schema.c
isabella232/CG-SQL
6f60abc7272260a501da6a667beac75a96e03c8f
[ "MIT" ]
null
null
null
sources/cg_json_schema.c
isabella232/CG-SQL
6f60abc7272260a501da6a667beac75a96e03c8f
[ "MIT" ]
1
2022-03-08T18:32:22.000Z
2022-03-08T18:32:22.000Z
sources/cg_json_schema.c
isabella232/CG-SQL
6f60abc7272260a501da6a667beac75a96e03c8f
[ "MIT" ]
null
null
null
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #if defined(CQL_AMALGAM_LEAN) && !defined(CQL_AMALGAM_JSON) // stubs to avoid link errors cql_noexport void cg_json_schema_main(ast_node *head) {} #else // Perform codegen of the various nodes to json schema format #include "cg_json_schema.h" #include <stdio.h> #include "ast.h" #include "cg_common.h" #include "charbuf.h" #include "cql.h" #include "gen_sql.h" #include "list.h" #include "sem.h" #include "symtab.h" #include "encoders.h" #include "eval.h" #include "cg_common.h" static void cg_fragment_with_params(charbuf *output, CSTR frag, ast_node *ast, gen_func fn); static void cg_fragment_with_params_raw(charbuf *output, CSTR frag, ast_node *ast, gen_func fn); static void cg_json_fk_target_options(charbuf *output, ast_node *ast); static void cg_json_emit_region_info(charbuf *output, ast_node *ast); static void cg_json_dependencies(charbuf *output, ast_node *ast); static void cg_json_data_type(charbuf *output, sem_t sem_type, CSTR kind); // These little helpers are for handling comma seperated lists where you may or may // not need a comma in various places. The local tracks if there is an item already // present and you either get ",\n" or just "\n" as needed. #define BEGIN_LIST bool_t list_start = 1 #define CONTINUE_LIST bool_t list_start = 0 #define COMMA if (!list_start) bprintf(output, ",\n"); else list_start = 0 #define END_LIST if (!list_start) bprintf(output, "\n") // These are the main output buffers for the various forms of statements we support // we build these up as we encounter them, redirecting the local 'output' to one of these static charbuf *queries; static charbuf *deletes; static charbuf *inserts; static charbuf *updates; static charbuf *general; static charbuf *general_inserts; // We use this to track every table we've ever seen and we remember what stored procedures use it static symtab *tables_to_procs; // The callback function for dependency analysis gets this structure as the anonymous context typedef struct json_context { CSTR cookie; ast_node *proc_ast; charbuf *used_tables; charbuf *used_views; charbuf *insert_tables; charbuf *update_tables; charbuf *delete_tables; charbuf *from_tables; charbuf *used_procs; } json_context; // magic string to sanity check the context cuz we're paranoid static char cookie_str[] = "cookie"; // compute the CRC for an arbitrary statement static llint_t crc_stmt(ast_node *stmt) { CHARBUF_OPEN(temp); // Format the text with full annotations, this text isn't going to SQLite but it should capture // all aspects of the table/view/index/trigger including annotations. gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); gen_set_output_buffer(&temp); gen_statement_with_callbacks(stmt, &callbacks); llint_t result = (llint_t)crc_charbuf(&temp); CHARBUF_CLOSE(temp); return result; } static void add_name_to_output(charbuf* output, CSTR table_name) { Contract(output); if (output->used > 1) { bprintf(output, ", "); } bprintf(output, "\"%s\"", table_name); } // This is the callback function that tells us a view name was found in the body // of the stored proc we are currently examining. The void context information // is how we remember which proc we were processing. For each table we have // a character buffer. We look it up, create it if not present, and write into it. // We also write into the buffer for the current proc which came in with the context. static void cg_found_view(CSTR view_name, ast_node* table_ast, void* pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check Contract(context->used_views); add_name_to_output(context->used_views, view_name); } // This is the callback function that tells us a table name was found in the body // of the stored proc we are currently examining. The void context information // is how we remember which proc we were processing. For each table we have // a character buffer. We look it up, create it if not present, and write into it. // We also write into the buffer for the current proc which came in with the context. static void cg_found_table(CSTR table_name, ast_node* table_ast, void* pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check Contract(context->used_tables); ast_node *proc_ast = context->proc_ast; if (is_ast_create_proc_stmt(proc_ast)) { Contract(tables_to_procs); charbuf* output = symtab_ensure_charbuf(tables_to_procs, table_name); // Get the proc name and add it to the list for this table EXTRACT_STRING(proc_name, proc_ast->left); add_name_to_output(output, proc_name); } add_name_to_output(context->used_tables, table_name); } static void cg_found_insert(CSTR table_name, ast_node *table_ast, void *pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check add_name_to_output(context->insert_tables, table_name); } static void cg_found_update(CSTR table_name, ast_node *table_ast, void *pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check add_name_to_output(context->update_tables, table_name); } static void cg_found_delete(CSTR table_name, ast_node *table_ast, void *pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check add_name_to_output(context->delete_tables, table_name); } static void cg_found_from(CSTR table_name, ast_node *table_ast, void *pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check add_name_to_output(context->from_tables, table_name); } static void cg_found_proc(CSTR proc_name, ast_node *name_ast, void *pvContext) { json_context *context = (json_context *)pvContext; Contract(context->cookie == cookie_str); // sanity check add_name_to_output(context->used_procs, proc_name); } // When processing generated SQL we get a callback every time a variable appears // in the output stream. This method records the variable name for use later // in the _parameters array. static bool_t cg_json_record_var(struct ast_node *_Nonnull ast, void *_Nullable context, charbuf *_Nonnull output) { // If this invariant fails that means the code is using cg_fragment when // cg_fragment_with_params is required (because variables were used). Invariant(context); charbuf *var = (charbuf *)context; bprintf(output, "?"); if (var->used > 1) { bprintf(var, ", "); } bprintf(var, "\"%s\"", ast->sem->name); return true; } static void cg_json_test_details(charbuf *output, ast_node *ast, ast_node *misc_attrs) { if (options.test) { bprintf(output, "\nThe statement ending at line %d\n", ast->lineno); bprintf(output, "\n"); gen_set_output_buffer(output); if (misc_attrs) { gen_with_callbacks(misc_attrs, gen_misc_attrs, NULL); } gen_with_callbacks(ast, gen_one_stmt, NULL); bprintf(output, "\n\n"); } } // Just extract a name from the AST and emit it static void cg_json_name(charbuf *output, ast_node *ast) { EXTRACT_STRING(name, ast); bprintf(output, "%s", name); } // Emit a quoted string into the JSON static void cg_json_emit_string(charbuf *output, ast_node *ast) { Invariant(is_strlit(ast)); EXTRACT_STRING(str, ast); // note str is the lexeme, so it is still quoted and escaped CHARBUF_OPEN(str1); CHARBUF_OPEN(str2); // requote it as a c style literal cg_decode_string_literal(str, &str1); cg_encode_json_string_literal(str1.ptr, &str2); bprintf(output, "%s", str2.ptr); CHARBUF_CLOSE(str2); CHARBUF_CLOSE(str1); } // Emit out a single miscellaneous attribute value into the current output stream // We could be processing any kind of entity, we don't care. We're just // emitting a single value here. The legal values are: // * a list of nested values // * an integer literal // * a double literal // * a string literal // * a name // * null // String literals have to be unescaped from SQL format and reescaped into C format static void cg_json_attr_value(charbuf *output, ast_node *ast) { if (is_ast_misc_attr_value_list(ast)) { bprintf(output, "["); for (ast_node *item = ast; item; item = item->right) { cg_json_attr_value(output, item->left); if (item->right) { bprintf(output, ", "); } } bprintf(output, "]"); } else if (is_ast_str(ast)) { EXTRACT_STRING(str, ast); if (is_strlit(ast)) { cg_json_emit_string(output, ast); } else { bprintf(output, "\"%s\"", str); // an identifier } } else if (is_ast_null(ast)) { // Null must be all in lowercase to be valid json, so we need a special case bprintf(output, "null"); } else { gen_set_output_buffer(output); gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); callbacks.mode = gen_mode_sql; callbacks.convert_hex = true; // json doesn't support hex numbers gen_with_callbacks(ast, gen_root_expr, &callbacks); } } // Emit a single miscellaneous attribute name/value pair // The name could be of the form foo:bar in which case we emit foo_bar // The value is any of the legal values handled above in cg_json_attr_value. static void cg_json_misc_attr(charbuf *output, ast_node *ast) { Contract(is_ast_misc_attr(ast)); bprintf(output, "{\n"); BEGIN_INDENT(attr, 2); bprintf(output, "\"name\" : \""); if (is_ast_dot(ast->left)) { cg_json_name(output, ast->left->left); bprintf(output, ":"); cg_json_name(output, ast->left->right); } else { cg_json_name(output, ast->left); } bprintf(output, "\",\n\"value\" : "); if (ast->right) { cg_json_attr_value(output, ast->right); } else { bprintf(output, "1"); } END_INDENT(attr); bprintf(output, "\n}"); } // Emit a list of attributes for the current entity, it could be any kind of entity. // Whatever it is we spit out the attributes here in array format. static void cg_json_misc_attrs(charbuf *output, ast_node *_Nonnull list) { Contract(is_ast_misc_attrs(list)); bprintf(output, "\"attributes\" : [\n"); BEGIN_INDENT(attr, 2); BEGIN_LIST; for (ast_node *item = list; item; item = item->right) { COMMA; cg_json_misc_attr(output, item->left); } END_LIST; END_INDENT(attr); bprintf(output, "]"); } // The column has its definition and attributes, output for the column goes // into the direct output and maybe to the deferred outputs. For instance if // a column in an FK then is FKness is emitted into the fk buffer for later use // in the fk section. typedef struct col_info { // Inputs ast_node *def; ast_node *attrs; // We write to these charbuf *col_pk; charbuf *col_uk; charbuf *col_fk; } col_info; static void cg_json_default_value(charbuf *output, ast_node *def) { if (is_ast_uminus(def)) { def = def->left; bprintf(output, "-"); } cg_json_attr_value(output, def); } // Emits the JSON for all ad-hoc migration procs as a list static void cg_json_ad_hoc_migration_procs(charbuf* output) { bprintf(output, "\"adHocMigrationProcs\" : [\n"); BEGIN_INDENT(list, 2); BEGIN_LIST; for (list_item *item = all_ad_hoc_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_schema_ad_hoc_migration_stmt(ast)); EXTRACT(version_annotation, ast->left); EXTRACT_OPTION(version, version_annotation->left); EXTRACT_STRING(name, version_annotation->right); ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); COMMA; bprintf(output, "{\n"); BEGIN_INDENT(t, 2); bprintf(output, "\"name\" : \"%s\",\n", name); bprintf(output, "\"CRC\" : \"%lld\",\n", crc_stmt(ast)); if (misc_attrs) { cg_json_misc_attrs(output, misc_attrs); bprintf(output, ",\n"); } bprintf(output, "\"version\" : %d", version); END_INDENT(t); bprintf(output, "\n}"); } uint32_t count = ad_hoc_recreate_actions->count; symtab_entry *actions = symtab_copy_sorted_payload(ad_hoc_recreate_actions, default_symtab_comparator); for (int32_t i = 0; i < count; i++) { ast_node *ast = (ast_node *)actions[i].val; EXTRACT_STRING(group, ast->left); EXTRACT_STRING(proc, ast->right); ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); COMMA; bprintf(output, "{\n"); BEGIN_INDENT(t, 2); bprintf(output, "\"name\" : \"%s\",\n", proc); bprintf(output, "\"CRC\" : \"%lld\",\n", crc_stmt(ast)); if (misc_attrs) { cg_json_misc_attrs(output, misc_attrs); bprintf(output, ",\n"); } bprintf(output, "\"onRecreateOf\" : \"%s\"", group); END_INDENT(t); bprintf(output, "\n}"); } free(actions); END_LIST; END_INDENT(list); bprintf(output, "]"); } // Emits the name and value for each value in the enumeration static void cg_json_enum_values(ast_node *enum_values, charbuf *output) { Contract(is_ast_enum_values(enum_values)); bprintf(output, "\"values\" : [\n"); BEGIN_INDENT(list, 2); BEGIN_LIST; while (enum_values) { EXTRACT_NOTNULL(enum_value, enum_values->left); EXTRACT_ANY_NOTNULL(enum_name_ast, enum_value->left); EXTRACT_STRING(enum_name, enum_name_ast); COMMA; bprintf(output, "{\n"); bprintf(output, " \"name\" : \"%s\",\n", enum_name); bprintf(output, " \"value\" : "); eval_format_number(enum_name_ast->sem->value, output); bprintf(output, "\n}"); enum_values = enum_values->right; } END_LIST; END_INDENT(list); bprintf(output, "]\n"); } // Emits the JSON for all enumerations static void cg_json_enums(charbuf* output) { bprintf(output, "\"enums\" : [\n"); BEGIN_INDENT(list, 2); BEGIN_LIST; for (list_item *item = all_enums_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_declare_enum_stmt(ast)); EXTRACT_NOTNULL(typed_name, ast->left); EXTRACT_NOTNULL(enum_values, ast->right); EXTRACT_ANY(name_ast, typed_name->left); EXTRACT_STRING(name, name_ast); EXTRACT_ANY_NOTNULL(type, typed_name->right); cg_json_test_details(output, ast, NULL); COMMA; bprintf(output, "{\n"); BEGIN_INDENT(t, 2); bprintf(output, "\"name\" : \"%s\",\n", name); cg_json_data_type(output, type->sem->sem_type | SEM_TYPE_NOTNULL, NULL); bprintf(output, ",\n"); cg_json_enum_values(enum_values, output); END_INDENT(t); bprintf(output, "}"); } END_LIST; END_INDENT(list); bprintf(output, "]"); } // emits the type and value for each constant in the constant group static void cg_json_const_values(ast_node *const_values, charbuf *output) { Contract(is_ast_const_values(const_values)); bprintf(output, "\"values\" : [\n"); BEGIN_INDENT(list, 2); BEGIN_LIST; while (const_values) { EXTRACT_NOTNULL(const_value, const_values->left); EXTRACT_ANY_NOTNULL(const_name_ast, const_value->left); EXTRACT_STRING(const_name, const_name_ast); EXTRACT_ANY_NOTNULL(const_expr, const_value->right); COMMA; bprintf(output, "{\n"); bprintf(output, " \"name\" : \"%s\",\n", const_name); BEGIN_INDENT(type, 2); cg_json_data_type(output, const_expr->sem->sem_type, const_expr->sem->kind); END_INDENT(type); bprintf(output, ",\n"); bprintf(output, " \"value\" : "); if (is_strlit(const_expr)) { cg_json_emit_string(output, const_expr); } else { eval_format_number(const_expr->sem->value, output); } bprintf(output, "\n}"); const_values = const_values->right; } END_LIST; END_INDENT(list); bprintf(output, "]\n"); } // Emits the JSON for all the global constants // note that these are in groups for convenience but they are all global // scope, not like enums. static void cg_json_constant_groups(charbuf* output) { bprintf(output, "\"constantGroups\" : [\n"); BEGIN_INDENT(list, 2); BEGIN_LIST; for (list_item *item = all_constant_groups_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_declare_const_stmt(ast)); EXTRACT_ANY_NOTNULL(name_ast, ast->left); EXTRACT_NOTNULL(const_values, ast->right); EXTRACT_STRING(name, name_ast); cg_json_test_details(output, ast, NULL); COMMA; bprintf(output, "{\n"); BEGIN_INDENT(t, 2); bprintf(output, "\"name\" : \"%s\",\n", name); cg_json_const_values(const_values, output); END_INDENT(t); bprintf(output, "}"); } END_LIST; END_INDENT(list); bprintf(output, "]"); } static void cg_migration_proc(ast_node *ast, charbuf *output) { if (is_ast_dot(ast)) { EXTRACT_NOTNULL(dot, ast); EXTRACT_STRING(lhs, dot->left); EXTRACT_STRING(rhs, dot->right); bprintf(output,"\"%s:%s\"", lhs, rhs); } else { EXTRACT_STRING(migration_proc_name, ast); bprintf(output,"\"%s\"", migration_proc_name); } } // Searches for an "ast_create" node from a list and emits the name of the migration // proc associated with it, if any static void cg_json_added_migration_proc(charbuf *output, ast_node *list) { for (ast_node *attr = list; attr; attr = attr->right) { if (is_ast_create_attr(attr)){ EXTRACT(version_annotation, attr->left); if (version_annotation && version_annotation->right) { bprintf(output,",\n\"addedMigrationProc\" : "); cg_migration_proc(version_annotation->right, output); } } } } // Searches for an "ast_delete" node from a list and emits the name of the migration // proc associated with it, if any static void cg_json_deleted_migration_proc(charbuf *output, ast_node *list) { for (ast_node *attr = list; attr; attr = attr->right) { if (is_ast_delete_attr(attr)){ EXTRACT(version_annotation, attr->left); if (version_annotation && version_annotation->right) { bprintf(output,",\n\"deletedMigrationProc\" : "); cg_migration_proc(version_annotation->right, output); } } } } // Crack the semantic info for the column and emit that into the main output // examine the attributes and emit those as needed. static void cg_json_col_attrs(charbuf *output, col_info *info) { // most of the attributes are in the semantic type, we don't have to walk the tree for them // we do need to check for a default value. // Note that there are implications associated with this flags and semantic analysis // makes those conclusions (e.g. pk implies not null) // We don't want that logic again so we use the semantic type not the raw declaration ast_node *col = info->def; sem_t sem_type = col->sem->sem_type; CSTR name = col->sem->name; bool_t is_added = col->sem->create_version > 0; bool_t is_deleted = col->sem->delete_version > 0; bprintf(output, ",\n\"isAdded\" : %d", is_added); if (is_added) { bprintf(output, ",\n\"addedVersion\" : %d", col->sem->create_version); cg_json_added_migration_proc(output, info->attrs); } bprintf(output, ",\n\"isDeleted\" : %d", is_deleted); if (is_deleted) { bprintf(output, ",\n\"deletedVersion\" : %d", col->sem->delete_version); cg_json_deleted_migration_proc(output, info->attrs); } if (sem_type & SEM_TYPE_PK) { bprintf(info->col_pk, "\"%s\"", name); } if (sem_type & SEM_TYPE_UK) { if (info->col_uk->used > 1) { bprintf(info->col_uk, ",\n"); } bprintf(info->col_uk, "{\n"); bprintf(info->col_uk, " \"name\" : \"%s_uk\",\n", name); bprintf(info->col_uk, " \"columns\" : [ \"%s\" ],\n", name); bprintf(info->col_uk, " \"sortOrders\" : [ \"\" ]\n"); bprintf(info->col_uk, "}"); } // There could be several foreign keys, we have to walk the list of attributes and gather them all for (ast_node *attr = info->attrs; attr; attr = attr->right) { charbuf *saved = output; output = info->col_fk; if (is_ast_col_attrs_fk(attr)) { if (output->used > 1) { bprintf(output, ",\n"); } bprintf(output, "{\n"); BEGIN_INDENT(fk, 2) bprintf(output, "\"columns\" : [ \"%s\" ]", name); cg_json_fk_target_options(output, attr->left); END_INDENT(fk); bprintf(output,"\n}"); } output = saved; } if (sem_type & SEM_TYPE_HAS_DEFAULT) { bprintf(output, ",\n\"defaultValue\" : "); cg_json_default_value(output, sem_get_col_default_value(info->attrs)); } if (sem_type & SEM_TYPE_HAS_COLLATE) { // find the collate attribute and emit it (there can only be one) for (ast_node *attr = info->attrs; attr; attr = attr->right) { if (is_ast_col_attrs_collate(attr)) { bprintf(output, ",\n\"collate\" : "); cg_json_attr_value(output, attr->left); } } } if (sem_type & SEM_TYPE_HAS_CHECK) { // find the check attribute and emit it (there can only be one) for (ast_node *attr = info->attrs; attr; attr = attr->right) { if (is_ast_col_attrs_check(attr)) { EXTRACT_ANY_NOTNULL(when_expr, attr->left); cg_fragment_with_params(output, "checkExpr", when_expr, gen_root_expr); } } } // end with mandatory columns, this makes the json validation with yacc a little easier bprintf(output, ",\n\"isPrimaryKey\" : %d", !!(sem_type & SEM_TYPE_PK)); bprintf(output, ",\n\"isUniqueKey\" : %d", !!(sem_type & SEM_TYPE_UK)); bprintf(output, ",\n\"isAutoIncrement\" : %d", !!(sem_type & SEM_TYPE_AUTOINCREMENT)); } // Starting from a semantic type, emit the appropriate JSON type static void cg_json_data_type(charbuf *output, sem_t sem_type, CSTR kind) { sem_t core_type = core_type_of(sem_type); BEGIN_LIST; COMMA; bprintf(output, "\"type\" : \""); switch (core_type) { case SEM_TYPE_INTEGER: bprintf(output, "integer"); break; case SEM_TYPE_TEXT: bprintf(output, "text"); break; case SEM_TYPE_BLOB: bprintf(output, "blob"); break; case SEM_TYPE_BOOL: bprintf(output, "bool"); break; case SEM_TYPE_REAL: bprintf(output, "real"); break; case SEM_TYPE_LONG_INTEGER: bprintf(output, "long"); break; case SEM_TYPE_OBJECT: bprintf(output, "object"); break; } bprintf(output, "\""); if (kind) { COMMA; bprintf(output, "\"kind\" : \"%s\"", kind); } bool_t sensitive = !!sensitive_flag(sem_type); if (sensitive) { COMMA; bprintf(output, "\"isSensitive\" : %d", sensitive); } COMMA; bprintf(output, "\"isNotNull\" : %d", !is_nullable(sem_type)); } // Starting with a column definition, emit the name and type information // for the column. If there are any miscellaneous attributes emit them as well. // Finally gather the column attributes like not null etc. and emit those using // the helper methods above. static void cg_json_col_def(charbuf *output, col_info *info) { ast_node *def = info->def; Contract(is_ast_col_def(def)); EXTRACT_NOTNULL(col_def_type_attrs, def->left); EXTRACT(misc_attrs, def->right); EXTRACT_ANY(attrs, col_def_type_attrs->right); EXTRACT_NOTNULL(col_def_name_type, col_def_type_attrs->left); EXTRACT_STRING(name, col_def_name_type->left); bprintf(output, "{\n"); BEGIN_INDENT(col, 2); bprintf(output, "\"name\" : \"%s\",\n", name); if (misc_attrs) { cg_json_misc_attrs(output, misc_attrs); bprintf(output, ",\n"); } cg_json_data_type(output, def->sem->sem_type, def->sem->kind); info->attrs = attrs; cg_json_col_attrs(output, info); END_INDENT(col); bprintf(output, "\n}"); } // Emits a list of names into a one-line array of quoted names static void cg_json_name_list(charbuf *output, ast_node *list) { Contract(is_ast_name_list(list)); for (ast_node *item = list; item; item = item->right) { bprintf(output, "\""); cg_json_name(output, item->left); bprintf(output, "\""); if (item->right) { bprintf(output, ", "); } } } // This is useful for expressions known to have no parameters (e.g. constraint expressions) // variables are illegal in such things so there can be no binding needed static void cg_json_vanilla_expr(charbuf *output, ast_node *expr) { gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); callbacks.mode = gen_mode_echo; // we want all the text, unexpanded, so NOT for sqlite output (this is raw echo) gen_set_output_buffer(output); gen_with_callbacks(expr, gen_root_expr, &callbacks); } // Similar to the above, this is also a list of names but we emit two arrays // one array for the names and another array for the sort orders specified if any. // Note unspecified sort orders are emitted as "". static void cg_json_indexed_columns(charbuf *cols, charbuf *orders, ast_node *list) { for (ast_node *item = list; item; item = item->right) { Contract(is_ast_indexed_columns(list)); EXTRACT_NOTNULL(indexed_column, item->left); bprintf(cols, "\""); cg_json_vanilla_expr(cols, indexed_column->left); bprintf(cols, "\""); if (is_ast_asc(indexed_column->right)) { bprintf(orders, "\"asc\""); } else if (is_ast_desc(indexed_column->right)) { bprintf(orders, "\"desc\""); } else { bprintf(orders, "\"\""); } if (item->right) { bprintf(cols, ", "); bprintf(orders, ", "); } } } // The primary key def is emitted just as an ordinary name list static void cg_json_pk_def(charbuf *output, ast_node *def) { Contract(is_ast_pk_def(def)); EXTRACT_NOTNULL(indexed_columns_conflict_clause, def->right); EXTRACT_NOTNULL(indexed_columns, indexed_columns_conflict_clause->left); CHARBUF_OPEN(cols); CHARBUF_OPEN(orders); cg_json_indexed_columns(&cols, &orders, indexed_columns); bprintf(output, "\"primaryKey\" : [ %s ]", cols.ptr); bprintf(output, ",\n\"primaryKeySortOrders\" : [ %s ],\n", orders.ptr); CHARBUF_CLOSE(orders); CHARBUF_CLOSE(cols); } // This is just a little wrapper to set up the buffer to get the FK // resolution action emitted without cloning that code. gen_fk_action // has a different contract than the usual generators (it doesn't take an AST) // so I can't use the usual fragment helpers. static void cg_json_action(charbuf *output, int32_t action) { CHARBUF_OPEN(sql); gen_set_output_buffer(&sql); if (!action) { action = FK_NO_ACTION; } gen_fk_action(action); bprintf(output, "\"%s\"", sql.ptr); CHARBUF_CLOSE(sql); } // Here we generate the update and delete actions plus the isDeferred state // Everything is sitting pretty in the AST. static void cg_json_fk_flags(charbuf *output, int32_t flags) { int32_t action = (flags & FK_ON_UPDATE) >> 4; bprintf(output, ",\n\"onUpdate\" : "); cg_json_action(output, action); action = (flags & FK_ON_DELETE); bprintf(output, ",\n\"onDelete\" : "); cg_json_action(output, action); // in sqlite anything that is not: // DEFERRABLE INITIALLY DEFERRED is immediate // See 4.2. Deferred Foreign Key Constraints bool_t deferred = (flags & FK_DEFERRABLE) && (flags & FK_INITIALLY_DEFERRED); bprintf(output, ",\n\"isDeferred\" : %d", deferred); } // Generates the properties for a foreign key's target and the options // that means the referencedTable, the columns as well as the flags // using the helper above. static void cg_json_fk_target_options(charbuf *output, ast_node *ast) { Contract(is_ast_fk_target_options(ast)); EXTRACT_NOTNULL(fk_target, ast->left); EXTRACT_OPTION(flags, ast->right); EXTRACT_STRING(table_name, fk_target->left); EXTRACT_NAMED_NOTNULL(ref_list, name_list, fk_target->right); bprintf(output, ",\n\"referenceTable\" : \"%s\"", table_name); bprintf(output, ",\n\"referenceColumns\" : [ "); cg_json_name_list(output, ref_list); bprintf(output, " ]"); cg_json_fk_flags(output, flags); } // A full FK definition consists of the constrained columns // and the FK target. This takes care of the columns and defers // to the above for the target (the target is used in other cases too) static void cg_json_fk_def(charbuf *output, ast_node *def) { Contract(is_ast_fk_def(def)); EXTRACT_NOTNULL(fk_info, def->right); EXTRACT_NAMED_NOTNULL(src_list, name_list, fk_info->left); EXTRACT_NOTNULL(fk_target_options, fk_info->right); if (def->left) { EXTRACT_STRING(name, def->left); bprintf(output, "\"name\" : \"%s\",\n", name); } bprintf(output, "\"columns\" : [ "); cg_json_name_list(output, src_list); bprintf(output, " ]"); cg_json_fk_target_options(output, fk_target_options); } // A unique key definition is just the name of the key and then // the participating columns. static void cg_json_unq_def(charbuf *output, ast_node *def) { Contract(is_ast_unq_def(def)); EXTRACT_NOTNULL(indexed_columns_conflict_clause, def->right); EXTRACT_NOTNULL(indexed_columns, indexed_columns_conflict_clause->left); bprintf(output, "{\n"); BEGIN_INDENT(uk, 2); if (def->left) { EXTRACT_STRING(name, def->left); bprintf(output, "\"name\" : \"%s\",\n", name); } CHARBUF_OPEN(cols); CHARBUF_OPEN(orders); cg_json_indexed_columns(&cols, &orders, indexed_columns); bprintf(output, "\"columns\" : [ %s ]", cols.ptr); bprintf(output, ",\n\"sortOrders\" : [ %s ]", orders.ptr); CHARBUF_CLOSE(orders); CHARBUF_CLOSE(cols); END_INDENT(uk); bprintf(output, "\n}"); } // A check constraint is just an expression, possibly named static void cg_json_check_def(charbuf *output, ast_node *def) { Contract(is_ast_check_def(def)); EXTRACT_ANY_NOTNULL(expr, def->right); bprintf(output, "{\n"); BEGIN_INDENT(chk, 2); if (def->left) { EXTRACT_STRING(name, def->left); bprintf(output, "\"name\" : \"%s\",\n", name); } cg_fragment_with_params_raw(output, "checkExpr", expr, gen_root_expr); END_INDENT(chk); bprintf(output, "\n}"); } // This is the list of "columns and keys" that form a table. In order to // organize these we make several passes on the column list. We loop once // for the columns then again for the PKs, then the FK, and finally UK. // Note that in each case there is a chance that columns will contribute to // the contents with keys that are defined directly on the column. // That's ok, those are just buffered up and emitted with each section. // All this several passes business just results in for sure all the column direct // stuff comes before non column related stuff in each section. static void cg_json_col_key_list(charbuf *output, ast_node *list) { Contract(is_ast_col_key_list(list)); CHARBUF_OPEN(col_pk); CHARBUF_OPEN(col_uk); CHARBUF_OPEN(col_fk); col_info info; info.col_pk = &col_pk; info.col_uk = &col_uk; info.col_fk = &col_fk; { bprintf(output, "\"columns\" : [\n"); BEGIN_INDENT(cols, 2); BEGIN_LIST; for (ast_node *item = list; item; item = item->right) { EXTRACT_ANY_NOTNULL(def, item->left); if (is_ast_col_def(def)) { COMMA; info.def = def; info.attrs = NULL; cg_json_col_def(output, &info); } } END_LIST; END_INDENT(cols); bprintf(output, "],\n"); } ast_node *pk_def = NULL; { if (col_pk.used > 1) { bprintf(output, "\"primaryKey\" : [ %s ],\n", col_pk.ptr); bprintf(output, "\"primaryKeySortOrders\" : [ \"\" ],\n"); } else { for (ast_node *item = list; item; item = item->right) { EXTRACT_ANY_NOTNULL(def, item->left); if (is_ast_pk_def(def)) { cg_json_pk_def(output, def); pk_def = def; } } if (!pk_def) { bprintf(output, "\"primaryKey\" : [ ],\n"); bprintf(output, "\"primaryKeySortOrders\" : [ ],\n"); } } } if (pk_def && pk_def->left) { EXTRACT_STRING(pk_name, pk_def->left); bprintf(output, "\"primaryKeyName\" : \"%s\",\n", pk_name); } { bprintf(output, "\"foreignKeys\" : [\n"); BEGIN_INDENT(fks, 2); BEGIN_LIST; if (col_fk.used > 1) { COMMA; bprintf(output, "%s", col_fk.ptr); } for (ast_node *item = list; item; item = item->right) { EXTRACT_ANY_NOTNULL(def, item->left); if (is_ast_fk_def(def)) { COMMA; bprintf(output, "{\n"); BEGIN_INDENT(fk, 2); cg_json_fk_def(output, def); END_INDENT(fk); bprintf(output, "\n}"); } } END_LIST; END_INDENT(fks); bprintf(output, "],\n"); } { bprintf(output, "\"uniqueKeys\" : [\n"); BEGIN_INDENT(uk, 2); BEGIN_LIST; if (col_uk.used > 1) { COMMA; bprintf(output, "%s", col_uk.ptr); } for (ast_node *item = list; item; item = item->right) { EXTRACT_ANY_NOTNULL(def, item->left); if (is_ast_unq_def(def)) { COMMA; cg_json_unq_def(output, def); } } END_LIST; END_INDENT(uk); bprintf(output, "],\n"); } { bprintf(output, "\"checkExpressions\" : [\n"); BEGIN_INDENT(chk, 2); BEGIN_LIST; for (ast_node *item = list; item; item = item->right) { EXTRACT_ANY_NOTNULL(def, item->left); if (is_ast_check_def(def)) { COMMA; cg_json_check_def(output, def); } } END_LIST; END_INDENT(chk); bprintf(output, "]"); } CHARBUF_CLOSE(col_fk); CHARBUF_CLOSE(col_uk); CHARBUF_CLOSE(col_pk); } // Here we walk all the indices, extract out the key info for each index and // emit it. The indices have a few flags plus columns and a sort order for // each column. static void cg_json_indices(charbuf *output) { bprintf(output, "\"indices\" : [\n"); BEGIN_INDENT(indices, 2); BEGIN_LIST; for (list_item *item = all_indices_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_create_index_stmt(ast)); EXTRACT_NOTNULL(create_index_on_list, ast->left); EXTRACT_NOTNULL(flags_names_attrs, ast->right); EXTRACT_NOTNULL(connector, flags_names_attrs->right); EXTRACT_NOTNULL(index_names_and_attrs, connector->left); EXTRACT_OPTION(flags, flags_names_attrs->left); EXTRACT_NOTNULL(indexed_columns, index_names_and_attrs->left); EXTRACT(opt_where, index_names_and_attrs->right); EXTRACT_ANY_NOTNULL(index_name_ast, create_index_on_list->left); EXTRACT_STRING(index_name, index_name_ast); EXTRACT_ANY_NOTNULL(table_name_ast, create_index_on_list->right); EXTRACT_STRING(table_name, table_name_ast); ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); COMMA; bprintf(output, "{\n"); BEGIN_INDENT(index, 2); bool_t is_deleted = ast->sem->delete_version > 0; bprintf(output, "\"name\" : \"%s\"", index_name); bprintf(output, ",\n\"CRC\" : \"%lld\"", crc_stmt(ast)); bprintf(output, ",\n\"table\" : \"%s\"", table_name); bprintf(output, ",\n\"isUnique\" : %d", !!(flags & INDEX_UNIQUE)); bprintf(output, ",\n\"ifNotExists\" : %d", !!(flags & INDEX_IFNE)); bprintf(output, ",\n\"isDeleted\" : %d", is_deleted); if (is_deleted) { bprintf(output, ",\n\"deletedVersion\" : %d", ast->sem->delete_version); } if (ast->sem->region) { cg_json_emit_region_info(output, ast); } if (opt_where) { bprintf(output, ",\n\"where\" : \""); cg_json_vanilla_expr(output, opt_where->left); bprintf(output, "\""); } if (misc_attrs) { bprintf(output, ",\n"); cg_json_misc_attrs(output, misc_attrs); } CHARBUF_OPEN(cols); CHARBUF_OPEN(orders); cg_json_indexed_columns(&cols, &orders, indexed_columns); bprintf(output, ",\n\"columns\" : [ %s ]", cols.ptr); bprintf(output, ",\n\"sortOrders\" : [ %s ]", orders.ptr); CHARBUF_CLOSE(orders); CHARBUF_CLOSE(cols); END_INDENT(index); bprintf(output, "\n}"); } END_INDENT(indices); END_LIST; bprintf(output, "]"); } static void cg_json_opt_bool(charbuf *output, int32_t flag, CSTR desc) { if (flag) { bprintf(output, ",\n\"%s\" : 1", desc); } } // Here we walk all the triggers, we extract the essential flags from // the trigger statement and emit those into the metadata as well. The main // body is emitted verbatim. static void cg_json_triggers(charbuf *output) { bprintf(output, "\"triggers\" : [\n"); BEGIN_INDENT(indices, 2); BEGIN_LIST; for (list_item *item = all_triggers_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_create_trigger_stmt(ast)); EXTRACT_OPTION(flags, ast->left); EXTRACT_NOTNULL(trigger_body_vers, ast->right); EXTRACT_NOTNULL(trigger_def, trigger_body_vers->left); EXTRACT_STRING(trigger_name, trigger_def->left); EXTRACT_NOTNULL(trigger_condition, trigger_def->right); EXTRACT_OPTION(cond_flags, trigger_condition->left); flags |= cond_flags; EXTRACT_NOTNULL(trigger_op_target, trigger_condition->right); EXTRACT_NOTNULL(trigger_operation, trigger_op_target->left); EXTRACT_OPTION(op_flags, trigger_operation->left); EXTRACT(name_list, trigger_operation->right); flags |= op_flags; EXTRACT_NOTNULL(trigger_target_action, trigger_op_target->right); EXTRACT_ANY_NOTNULL(table_name_ast, trigger_target_action->left); EXTRACT_NOTNULL(trigger_action, trigger_target_action->right); EXTRACT_OPTION(action_flags, trigger_action->left); flags |= action_flags; EXTRACT_NOTNULL(trigger_when_stmts, trigger_action->right); EXTRACT_ANY(when_expr, trigger_when_stmts->left); EXTRACT_NOTNULL(stmt_list, trigger_when_stmts->right); ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); // use the canonical name (which may be case-sensitively different) CSTR table_name = table_name_ast->sem->sptr->struct_name; COMMA; bprintf(output, "{\n"); BEGIN_INDENT(trigger, 2); bool_t is_deleted = ast->sem->delete_version > 0; bprintf(output, "\"name\" : \"%s\"", trigger_name); bprintf(output, ",\n\"CRC\" : \"%lld\"", crc_stmt(ast)); bprintf(output, ",\n\"target\" : \"%s\"", table_name); bprintf(output, ",\n\"isTemp\" : %d", !!(flags & TRIGGER_IS_TEMP)); bprintf(output, ",\n\"ifNotExists\" : %d", !!(flags & TRIGGER_IF_NOT_EXISTS)); bprintf(output, ",\n\"isDeleted\" : %d", is_deleted); if (is_deleted) { bprintf(output, ",\n\"deletedVersion\" : %d", ast->sem->delete_version); } // only one of these cg_json_opt_bool(output, (flags & TRIGGER_BEFORE), "isBeforeTrigger"); cg_json_opt_bool(output, (flags & TRIGGER_AFTER), "isAfterTrigger"); cg_json_opt_bool(output, (flags & TRIGGER_INSTEAD_OF), "isInsteadOfTrigger"); // only one of these cg_json_opt_bool(output, (flags & TRIGGER_DELETE), "isDeleteTrigger"); cg_json_opt_bool(output, (flags & TRIGGER_INSERT), "isInsertTrigger"); cg_json_opt_bool(output, (flags & TRIGGER_UPDATE), "isUpdateTrigger"); cg_json_opt_bool(output, (flags & TRIGGER_FOR_EACH_ROW), "forEachRow"); if (when_expr) { cg_fragment_with_params(output, "whenExpr", when_expr, gen_root_expr); } cg_fragment_with_params(output, "statement", ast, gen_one_stmt); if (ast->sem->region) { cg_json_emit_region_info(output, ast); } if (misc_attrs) { bprintf(output, ",\n"); cg_json_misc_attrs(output, misc_attrs); } cg_json_dependencies(output, ast); END_INDENT(trigger); bprintf(output, "\n}"); } END_INDENT(indices); END_LIST; bprintf(output, "]"); } static void cg_json_region_deps(charbuf *output, CSTR sym) { // Every name we encounter has already been validated! ast_node *region = find_region(sym); Invariant(region); bprintf(output, "\"using\" : [ ", sym); EXTRACT(region_list, region->right); for (ast_node *item = region_list; item; item = item->right) { Contract(is_ast_region_list(item)); EXTRACT_NOTNULL(region_spec, item->left); EXTRACT_STRING(item_name, region_spec->left); bprintf(output, "\"%s\"", item_name); if (item->right) { bprintf(output, ", "); } } bprintf(output, " ]", sym); bprintf(output, ",\n\"usingPrivately\" : [ ", sym); for (ast_node *item = region_list; item; item = item->right) { Contract(is_ast_region_list(item)); EXTRACT_NOTNULL(region_spec, item->left); EXTRACT_OPTION(type, region_spec->right); bprintf(output, "%d", type == PRIVATE_REGION); if (item->right) { bprintf(output, ", "); } } bprintf(output, " ]", sym); } // To compute the deployed_in_region we only need to know its definiton // * a normal object (not a region) indicates the region it is in by filling // in the region of its semantic node // * a region indicates the deployment region it is in by filling in // the region of its semantic node // * therefore to go from an object to its deployed region you first // get the region the object is in and then get the region that region is in // * note that deployable regions do not necessarily cover everything so // if the object is in a region that is not yet in an deployable region // it's marked as an orphan. static CSTR get_deployed_in_region(ast_node *ast) { CSTR deployedInRegion = "(orphan)"; // if we are in no region at all, we're an orphan if (ast->sem->region) { // this is the region we are in, look it up ast_node *reg = find_region(ast->sem->region); // the region of that region is our deployment region if (reg->sem->region) { deployedInRegion = reg->sem->region; } } return deployedInRegion; } // Emit the region info and the deployment region info as needed static void cg_json_emit_region_info(charbuf *output, ast_node *ast) { bprintf(output, ",\n\"region\" : \"%s\"", ast->sem->region); bprintf(output, ",\n\"deployedInRegion\" : \"%s\"", get_deployed_in_region(ast)); } // Here we walk all the regions, we get the dependency information for // that region and emit it. // static void cg_json_regions(charbuf *output) { bprintf(output, "\"regions\" : [\n"); BEGIN_INDENT(regout, 2); BEGIN_LIST; symtab_entry *regs = symtab_copy_sorted_payload(schema_regions, default_symtab_comparator); for (list_item *item = all_regions_list; item; item = item->next) { ast_node *ast = item->ast; EXTRACT_STRING(name, ast->left); cg_json_test_details(output, ast, NULL); COMMA; bprintf(output, "{\n\"name\" : \"%s\",\n", name); CSTR deployedInRegion = get_deployed_in_region(ast); bprintf(output, "\"isDeployableRoot\" : %d,\n", !!(ast->sem->sem_type & SEM_TYPE_DEPLOYABLE)); bprintf(output, "\"deployedInRegion\" : \"%s\",\n", deployedInRegion); cg_json_region_deps(output, name); bprintf(output, "\n}"); } END_LIST; END_INDENT(regout); bprintf(output, "]"); free(regs); } // Emit the result columns in the select list -- their names and types. // This is the projection of the select. static void cg_json_projection(charbuf *output, ast_node *ast) { Contract(ast); Contract(ast->sem); sem_struct *sptr = ast->sem->sptr; bprintf(output, ",\n\"projection\" : [\n"); BEGIN_INDENT(proj, 2); BEGIN_LIST; for (int32_t i = 0; i < sptr->count; i++) { COMMA; bprintf(output, "{\n"); BEGIN_INDENT(type, 2); bprintf(output, "\"name\" : \"%s\",\n", sptr->names[i]); cg_json_data_type(output, sptr->semtypes[i], sptr->kinds[i]); END_INDENT(type); bprintf(output, "\n}"); } END_LIST; END_INDENT(proj); bprintf(output, "]"); } // The set of views look rather like the query section in as much as // they are in fact nothing more than named select statements. However // the output here is somewhat simplified. We only emit the whole select // statement and any binding args, we don't also emit all the pieces of the select. static void cg_json_views(charbuf *output) { bprintf(output, "\"views\" : [\n"); BEGIN_INDENT(views, 2); int32_t i = 0; for (list_item *item = all_views_list; item; item = item->next) { ast_node *ast = item->ast; Invariant(is_ast_create_view_stmt(ast)); ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); EXTRACT_OPTION(flags, ast->left); EXTRACT(view_and_attrs, ast->right); EXTRACT(name_and_select, view_and_attrs->left); EXTRACT_ANY_NOTNULL(select_stmt, name_and_select->right); EXTRACT_ANY_NOTNULL(name_ast, name_and_select->left); EXTRACT_STRING(name, name_ast); if (i > 0) { bprintf(output, ",\n"); } bprintf(output, "{\n"); bool_t is_deleted = ast->sem->delete_version > 0; BEGIN_INDENT(view, 2); bprintf(output, "\"name\" : \"%s\"", name); bprintf(output, ",\n\"CRC\" : \"%lld\"", crc_stmt(ast)); bprintf(output, ",\n\"isTemp\" : %d", !!(flags & VIEW_IS_TEMP)); bprintf(output, ",\n\"isDeleted\" : %d", is_deleted); if (is_deleted) { bprintf(output, ",\n\"deletedVersion\" : %d", ast->sem->delete_version); cg_json_deleted_migration_proc(output, view_and_attrs); } if (ast->sem->region) { cg_json_emit_region_info(output, ast); } if (misc_attrs) { bprintf(output, ",\n"); cg_json_misc_attrs(output, misc_attrs); } cg_json_projection(output, select_stmt); cg_fragment_with_params(output, "select", select_stmt, gen_one_stmt); cg_json_dependencies(output, ast); END_INDENT(view); bprintf(output, "\n}\n"); i++; } END_INDENT(views); bprintf(output, "]"); } static void cg_json_table_indices(list_item *head, charbuf *output) { bprintf(output, "\"indices\" : [ "); bool_t needs_comma = 0; for (list_item *item = head; item; item = item->next) { ast_node *ast = item->ast; // don't include deleted indices if (ast->sem->delete_version > 0) { continue; } Invariant(is_ast_create_index_stmt(ast)); EXTRACT_NOTNULL(create_index_on_list, ast->left); EXTRACT_ANY_NOTNULL(index_name_ast, create_index_on_list->left); EXTRACT_STRING(index_name, index_name_ast); if (needs_comma) { bprintf(output, ", "); } bprintf(output, "\"%s\"", index_name); needs_comma = 1; } bprintf(output, " ]"); } // The table output is the tables name, the assorted flags, and misc attributes // the rest of the table output is produced by walking the column and key list // using the helper above. static void cg_json_table(charbuf *output, ast_node *ast) { Invariant(is_ast_create_table_stmt(ast)); EXTRACT_NOTNULL(create_table_name_flags, ast->left); EXTRACT_NOTNULL(table_flags_attrs, create_table_name_flags->left); EXTRACT_OPTION(flags, table_flags_attrs->left); EXTRACT_STRING(name, create_table_name_flags->right); EXTRACT_ANY_NOTNULL(col_key_list, ast->right); int32_t temp = flags & TABLE_IS_TEMP; int32_t if_not_exist = flags & TABLE_IF_NOT_EXISTS; int32_t no_rowid = flags & TABLE_IS_NO_ROWID; ast_node *misc_attrs = NULL; ast_node *attr_target = ast->parent; if (is_virtual_ast(ast)) { // for virtual tables, we have to go up past the virtual table node to get the attributes attr_target = attr_target->parent; } if (is_ast_stmt_and_attr(attr_target)) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc, attr_target->parent); misc_attrs = misc; } cg_json_test_details(output, ast, misc_attrs); bprintf(output, "{\n"); BEGIN_INDENT(table, 2); bool_t is_added = ast->sem->create_version > 0; bool_t is_deleted = ast->sem->delete_version > 0; bprintf(output, "\"name\" : \"%s\"", name); bprintf(output, ",\n\"CRC\" : \"%lld\"", crc_stmt(ast)); bprintf(output, ",\n\"isTemp\" : %d", !!temp); bprintf(output, ",\n\"ifNotExists\" : %d", !!if_not_exist); bprintf(output, ",\n\"withoutRowid\" : %d", !!no_rowid); bprintf(output, ",\n\"isAdded\" : %d", is_added); if (is_added) { bprintf(output, ",\n\"addedVersion\" : %d", ast->sem->create_version); cg_json_added_migration_proc(output, table_flags_attrs); } bprintf(output, ",\n\"isDeleted\" : %d", is_deleted); if (is_deleted) { bprintf(output, ",\n\"deletedVersion\" : %d", ast->sem->delete_version); cg_json_deleted_migration_proc(output, table_flags_attrs); } bprintf(output, ",\n\"isRecreated\": %d", ast->sem->recreate); if (ast->sem->recreate_group_name) { bprintf(output, ",\n\"recreateGroupName\" : \"%s\"", ast->sem->recreate_group_name); } if (ast->sem->region) { cg_json_emit_region_info(output, ast); } if (is_virtual_ast(ast)) { bprintf(output, ",\n\"isVirtual\" : 1"); EXTRACT_NOTNULL(create_virtual_table_stmt, ast->parent); EXTRACT_NOTNULL(module_info, create_virtual_table_stmt->left); EXTRACT_STRING(module_name, module_info->left); EXTRACT_ANY(module_args, module_info->right); bprintf(output, ",\n\"module\" : \"%s\"", module_name); if (module_args) { bprintf(output, ",\n\"moduleArgs\" : "); if (is_ast_following(module_args)) { CHARBUF_OPEN(sql); gen_set_output_buffer(&sql); gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); gen_with_callbacks(col_key_list, gen_col_key_list, &callbacks); cg_encode_json_string_literal(sql.ptr, output); CHARBUF_CLOSE(sql); } else { CHARBUF_OPEN(sql); gen_set_output_buffer(&sql); gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); gen_with_callbacks(module_args, gen_misc_attr_value_list, &callbacks); cg_encode_json_string_literal(sql.ptr, output); CHARBUF_CLOSE(sql); } } } CONTINUE_LIST; if (ast->sem->index_list) { COMMA; cg_json_table_indices(ast->sem->index_list, output); } if (misc_attrs) { COMMA; cg_json_misc_attrs(output, misc_attrs); } COMMA; cg_json_col_key_list(output, col_key_list); END_INDENT(table); END_LIST; bprintf(output, "}"); } // The tables section is simply an array of table entries under the tables key static void cg_json_tables(charbuf *output) { bprintf(output, "\"tables\" : [\n"); BEGIN_INDENT(tables, 2); BEGIN_LIST; for (list_item *item = all_tables_list; item; item = item->next) { ast_node *ast = item->ast; if (is_virtual_ast(ast)) { continue; } COMMA; cg_json_table(output, ast); } END_INDENT(tables); END_LIST; bprintf(output, "]"); } // The tables section is simply an array of table entries under the tables key static void cg_json_virtual_tables(charbuf *output) { bprintf(output, "\"virtualTables\" : [\n"); BEGIN_INDENT(tables, 2); BEGIN_LIST; for (list_item *item = all_tables_list; item; item = item->next) { ast_node *ast = item->ast; if (!is_virtual_ast(ast)) { continue; } COMMA; cg_json_table(output, ast); } END_INDENT(tables); END_LIST; bprintf(output, "]"); } // This helper emits one parameter for a single stored proc. Each will be // used as the legal arguments to the statement we are binding. If any of // the parameters are of the 'out' flavor then this proc is "complex" // so we simply return false and let it fall into the general bucket. static bool_t cg_json_param(charbuf *output, ast_node *ast, CSTR *infos) { Contract(is_ast_param(ast)); EXTRACT_ANY(opt_inout, ast->left); EXTRACT_NOTNULL(param_detail, ast->right); EXTRACT_STRING(name, param_detail->left); bool_t simple = 1; bprintf(output, "{\n"); BEGIN_INDENT(type, 2); if (is_ast_inout(opt_inout)) { bprintf(output, "\"binding\" : \"inout\",\n", name); simple = 0; } else if (is_ast_out(opt_inout)) { bprintf(output, "\"binding\" : \"out\",\n", name); simple = 0; } bprintf(output, "\"name\" : \"%s\",\n", name); CSTR base_name = infos[0]; CSTR shape_name = infos[1]; CSTR shape_type = infos[2]; if (shape_name[0]) { // this is an expansion of the form shape_name LIKE shape_type // the formal arg will have a name like "shape_name_base_name" (underscore between the parts) bprintf(output, "\"argOrigin\" : \"%s %s %s\",\n", shape_name, shape_type, base_name); } else if (shape_type[0]) { // this is an expansion of the form LIKE shape_type // the formal arg will have a name like "base_name_" (trailing underscore) bprintf(output, "\"argOrigin\" : \"%s %s\",\n", shape_type, base_name); } else { // this is a normal arg, it was not auto-expanded from anything // the formal arg will have the name "base_name" bprintf(output, "\"argOrigin\" : \"%s\",\n", base_name); } cg_json_data_type(output, ast->sem->sem_type, ast->sem->kind); END_INDENT(type); bprintf(output, "\n}"); return simple; } // Here we walk all the parameters of a stored proc and process each in turn. // If any parameter is not valid, the entire proc becomes not valid. static bool_t cg_json_params(charbuf *output, ast_node *ast, CSTR *infos) { bool_t simple = 1; BEGIN_LIST; while (ast) { Contract(is_ast_params(ast)); EXTRACT_NOTNULL(param, ast->left); COMMA; simple &= cg_json_param(output, param, infos); ast = ast->right; // There are 3 strings per arg, one each for the shape name, shape type, and base name // these desribe how automatically generated arguments were created. infos += 3; } END_LIST; return simple; } static bool_t found_shared_fragment; // simply record the factthat we found a shared fragment static bool_t cg_json_call_in_cte(ast_node *cte_body, void *context, charbuf *buffer) { found_shared_fragment = true; return false; } // Use the indicated generation function to create a SQL fragment. The fragment // may have parameters. They are captured and emitted as an array. static void cg_fragment_with_params_raw(charbuf *output, CSTR frag, ast_node *ast, gen_func fn) { CHARBUF_OPEN(sql); CHARBUF_OPEN(vars); gen_set_output_buffer(&sql); gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); callbacks.variables_callback = cg_json_record_var; callbacks.variables_context = &vars; callbacks.star_callback = cg_expand_star; callbacks.cte_proc_callback = cg_json_call_in_cte; found_shared_fragment = false; bprintf(output, "\"%s\" : ", frag); gen_with_callbacks(ast, fn, &callbacks); cg_pretty_quote_plaintext(sql.ptr, output, PRETTY_QUOTE_JSON | PRETTY_QUOTE_SINGLE_LINE); bprintf(output, ",\n\"%sArgs\" : [ %s ]", frag, vars.ptr); CHARBUF_CLOSE(vars); CHARBUF_CLOSE(sql); } // Same as the above, but the most common case requires continuing a list // so this helper does that. static void cg_fragment_with_params(charbuf *output, CSTR frag, ast_node *ast, gen_func fn) { bprintf(output, ",\n"); cg_fragment_with_params_raw(output, frag, ast, fn); } // Use the indicated generation function to create a SQL fragment. The fragment // may not have parameters. This is not suitable for use where expressions // will be present. static void cg_fragment(charbuf *output, CSTR frag, ast_node *ast, gen_func fn) { CHARBUF_OPEN(sql); gen_set_output_buffer(&sql); gen_sql_callbacks callbacks; init_gen_sql_callbacks(&callbacks); callbacks.variables_callback = cg_json_record_var; callbacks.variables_context = NULL; // forces invariant violation if any variables callbacks.star_callback = cg_expand_star; bprintf(output, ",\n\"%s\" : ", frag); gen_with_callbacks(ast, fn, &callbacks); cg_pretty_quote_plaintext(sql.ptr, output, PRETTY_QUOTE_JSON | PRETTY_QUOTE_SINGLE_LINE); CHARBUF_CLOSE(sql); } // The select statement is emitted in two ways. First we emit a fragment for the // whole statement and its arguments. This is really the easiest way to use the data here. // Also we emit sub-fragments for each top level piece. The helpers above do most of that // work. Here we just trigger: // * the big fragment for everything // * the select list // * the expression list and the optional (and highly important) other clauses static void cg_json_select_stmt(charbuf *output, ast_node *ast) { Contract(is_select_stmt(ast)); cg_fragment_with_params(output, "statement", ast, gen_one_stmt); } // Here we emit the following bits of information // * the table we are inserting into // * the insert type (INSERT, INSERT OR REPLACE etc) // * the insert columns (the ones we are specifying) // * a fragment for the entire statement with all the args // * [optional] a fragment for each inserted value with its args static void cg_json_insert_stmt(charbuf *output, ast_node *ast, bool_t emit_values) { // Both insert types have been unified in the AST Contract(is_insert_stmt(ast)); ast_node *insert_stmt = ast; // extract the insert part it may be behind the WITH clause and it may be the insert part of an upsert if (is_ast_with_insert_stmt(ast)) { insert_stmt = ast->right; } else if (is_ast_upsert_stmt(ast)) { insert_stmt = ast->left; } else if (is_ast_with_upsert_stmt(ast)) { insert_stmt = ast->right->left; } Contract(is_ast_insert_stmt(insert_stmt)); EXTRACT_ANY_NOTNULL(insert_type, insert_stmt->left); EXTRACT_NOTNULL(name_columns_values, insert_stmt->right); EXTRACT_ANY_NOTNULL(name_ast, name_columns_values->left) EXTRACT_NOTNULL(columns_values, name_columns_values->right); EXTRACT_NOTNULL(column_spec, columns_values->left); EXTRACT_ANY(columns_values_right, columns_values->right); EXTRACT(insert_dummy_spec, insert_type->left); EXTRACT(name_list, column_spec->left); // use the canonical name (which may be case-sensitively different) CSTR name = name_ast->sem->sptr->struct_name; bprintf(output, ",\n\"table\" : \"%s\"", name); cg_fragment_with_params(output, "statement", ast, gen_one_stmt); cg_fragment(output, "statementType", insert_type, gen_insert_type); bprintf(output, ",\n\"columns\" : [ "); if (name_list) { cg_json_name_list(output, name_list); } bprintf(output, " ]"); if (emit_values) { // We only try to emit values if we know there is one row of them // So the select statement can only be a values clause with only one list of values. // This is guaranteed because of is_simple_insert(...) already checked this. // The general insert form might have arguments in all sorts of places and // so it can't be readily analyzed by downstream tools. This very simple // insert form can be manipulated in interesting ways. A downstream tool might // want to convert it into an upsert or some such. In any case, we pull // out the very simple inserts to allow them to be more deeply analyzed. bprintf(output, ",\n\"values\" : [\n"); BEGIN_LIST; BEGIN_INDENT(v1, 2); if (is_ast_select_stmt(columns_values_right)) { EXTRACT(select_stmt, columns_values_right); EXTRACT_NOTNULL(select_core_list, select_stmt->left); EXTRACT(select_core_compound, select_core_list->right); EXTRACT_NOTNULL(select_core, select_core_list->left); EXTRACT_NOTNULL(values, select_core->right); columns_values_right = values->left; } Invariant(columns_values_right == NULL || is_ast_insert_list(columns_values_right)); EXTRACT(insert_list, columns_values_right); for (ast_node *item = insert_list; item; item = item->right) { COMMA; bprintf(output, "{\n"); BEGIN_INDENT(v2, 2); cg_fragment_with_params_raw(output, "value", item->left, gen_root_expr); END_INDENT(v2); bprintf(output, "\n}"); } END_INDENT(v1); END_LIST; bprintf(output, "]"); } } // Delete statement gets the table name and the full statement and args // as one fragment. static void cg_json_delete_stmt(charbuf *output, ast_node * ast) { Contract(is_delete_stmt(ast)); ast_node *delete_stmt = is_ast_with_delete_stmt(ast) ? ast->right : ast; EXTRACT_ANY_NOTNULL(name_ast, delete_stmt->left); // use the canonical name (which may be case-sensitively different) CSTR name = name_ast->sem->sptr->struct_name; bprintf(output, ",\n\"table\" : \"%s\"", name); cg_fragment_with_params(output, "statement", ast, gen_one_stmt); } // Update statement gets the table name and the full statement and args // as one fragment. static void cg_json_update_stmt(charbuf *output, ast_node *ast) { Contract(is_update_stmt(ast)); ast_node *update_stmt = is_ast_with_update_stmt(ast) ? ast->right : ast; EXTRACT_ANY_NOTNULL(name_ast, update_stmt->left); // use the canonical name (which may be case-sensitively different) CSTR name = name_ast->sem->sptr->struct_name; bprintf(output, ",\n\"table\" : \"%s\"", name); cg_fragment_with_params(output, "statement", ast, gen_one_stmt); } // Start a new section for a proc, if testing we spew the test info here // This lets us attribute the output to a particular line number in the test file. static void cg_begin_proc(charbuf *output, ast_node *ast, ast_node *misc_attrs) { Contract(is_ast_create_proc_stmt(ast)); EXTRACT_STRING(name, ast->left); if (output->used > 1) bprintf(output, ",\n"); cg_json_test_details(output, ast, misc_attrs); bprintf(output, "{\n"); } // For symetry we have this lame end function static void cg_end_proc(charbuf *output, ast_node *ast) { bprintf(output, "\n}"); } // Emit the arguments to the proc, track if they are valid (i.e. no OUT args) // If not valid, the proc will be "general" static bool_t cg_parameters(charbuf *output, ast_node *ast) { Contract(is_ast_create_proc_stmt(ast)); EXTRACT_STRING(name, ast->left); EXTRACT_NOTNULL(proc_params_stmts, ast->right); EXTRACT(params, proc_params_stmts->left); bool_t simple = 1; bytebuf *arg_info = find_proc_arg_info(name); CSTR *infos = arg_info ? (CSTR *)arg_info->ptr : NULL; bprintf(output, "\"args\" : [\n"); BEGIN_INDENT(parms, 2); simple = cg_json_params(output, params, infos); END_INDENT(parms); bprintf(output, "]"); return simple; } // The purpose of the "simple" versions is to enable code-rewriters to replace // the proc with the DML directly and bind it. The code gen can some idea of what's // going on in the simple cases -- it's a single row insert. In those cases it's // possible to skip the C codegen entirely. You can just bind and run the DML. bool_t static is_simple_insert(ast_node *ast) { if (!is_ast_insert_stmt(ast)) { return false; } EXTRACT_NOTNULL(name_columns_values, ast->right); EXTRACT_NOTNULL(columns_values, name_columns_values->right); if (!is_select_stmt(columns_values->right)) { // the insert statement does not have a select statement return true; } EXTRACT(select_stmt, columns_values->right); EXTRACT_NOTNULL(select_core_list, select_stmt->left); EXTRACT(select_core_compound, select_core_list->right); if (select_core_compound != NULL) { // The select statement is a compound select therefore it's not simple insert return false; } EXTRACT_NOTNULL(select_core, select_core_list->left); if (!is_ast_values(select_core->right)) { // The select statement does not have VALUES clause then it's not simple insert return false; } EXTRACT_NOTNULL(values, select_core->right); if (values->right) { // The values clause has multiple list of value therefore it's not a simple insert return false; } // The insert statement contains a select statement that only has a VALUES clause // and the VALUES clause has only one list of values. return true; } static void cg_json_general_proc(ast_node *ast, ast_node *misc_attrs, CSTR params) { charbuf *output = general; cg_begin_proc(output, ast, misc_attrs); sem_t sem_type = ast->sem->sem_type; BEGIN_INDENT(proc, 2) bprintf(output, "%s", params); bool_t has_any_result_set = !!ast->sem->sptr; bool_t uses_out_union = !!(sem_type & SEM_TYPE_USES_OUT_UNION); bool_t uses_out = !!(sem_type & SEM_TYPE_USES_OUT); bool_t select_result = !uses_out && !uses_out_union && has_any_result_set; if (has_any_result_set) { cg_json_projection(output, ast); } // clearer coding of the result types including out union called out seperately if (uses_out) { Invariant(has_any_result_set); bprintf(output, ",\n\"hasOutResult\" : 1"); } else if (uses_out_union) { Invariant(has_any_result_set); bprintf(output, ",\n\"hasOutUnionResult\" : 1"); } else if (select_result) { Invariant(has_any_result_set); bprintf(output, ",\n\"hasSelectResult\" : 1"); } else { Invariant(!has_any_result_set); } bprintf(output, ",\n\"usesDatabase\" : %d", !!(sem_type & SEM_TYPE_DML_PROC)); END_INDENT(proc); } // For procedures and triggers we want to walk the statement list and emit a set // of dependency entries that show what the code in question is using and how. // We track tables that are used and if they appear in say the FROM clause // (or some other read-context) or if they are the subject of an insert, update, // or delete. We also track the use of nested procedures and produce a list of // procs the subject might call. Of course no proc calls ever appear in triggers. static void cg_json_dependencies(charbuf *output, ast_node *ast) { json_context context; CHARBUF_OPEN(used_tables); CHARBUF_OPEN(used_views); CHARBUF_OPEN(insert_tables); CHARBUF_OPEN(update_tables); CHARBUF_OPEN(delete_tables); CHARBUF_OPEN(from_tables); CHARBUF_OPEN(used_procs); context.cookie = cookie_str; context.proc_ast = ast; context.used_tables = &used_tables; context.used_views = &used_views; context.insert_tables = &insert_tables; context.delete_tables = &delete_tables; context.update_tables = &update_tables; context.from_tables = &from_tables; context.used_procs = &used_procs; table_callbacks callbacks = { .notify_table_or_view_drops = false, .notify_fk = false, .notify_triggers = false, .callback_any_table = cg_found_table, .callback_any_view = cg_found_view, .callback_inserts = cg_found_insert, .callback_updates = cg_found_update, .callback_deletes = cg_found_delete, .callback_from = cg_found_from, .callback_proc = cg_found_proc, .callback_context = &context, }; find_table_refs(&callbacks, ast); if (insert_tables.used > 1) { bprintf(output, ",\n\"insertTables\" : [ %s ]", insert_tables.ptr); } if (update_tables.used > 1) { bprintf(output, ",\n\"updateTables\" : [ %s ]", update_tables.ptr); } if (delete_tables.used > 1) { bprintf(output, ",\n\"deleteTables\" : [ %s ]", delete_tables.ptr); } if (from_tables.used > 1) { bprintf(output, ",\n\"fromTables\" : [ %s ]", from_tables.ptr); } if (used_procs.used > 1) { bprintf(output, ",\n\"usesProcedures\" : [ %s ]", used_procs.ptr); } if (used_views.used > 1) { bprintf(output, ",\n\"usesViews\" : [ %s ]", used_views.ptr); } bprintf(output, ",\n\"usesTables\" : [ %s ]", used_tables.ptr); CHARBUF_CLOSE(used_procs); CHARBUF_CLOSE(from_tables); CHARBUF_CLOSE(delete_tables); CHARBUF_CLOSE(update_tables); CHARBUF_CLOSE(insert_tables); CHARBUF_CLOSE(used_views); CHARBUF_CLOSE(used_tables); } // If we find a procedure definition we crack its arguments and first statement // If it matches one of the known types we generate the details for it. Otherwise // it goes into the general bucket. The output is redirected to the appropriate // output stream for the type of statement and then a suitable helper is dispatched. // Additionally, each procedure includes an array of tables that it uses regardless // of the type of procedure. static void cg_json_create_proc(ast_node *ast, ast_node *misc_attrs) { Contract(is_ast_create_proc_stmt(ast)); EXTRACT_ANY_NOTNULL(name_ast, ast->left); EXTRACT_STRING(name, name_ast); EXTRACT_NOTNULL(proc_params_stmts, ast->right); EXTRACT(params, proc_params_stmts->left); EXTRACT(stmt_list, proc_params_stmts->right); // shared fragments are invisible to the JSON or anything else, they have // no external interface. uint32_t frag_type = find_proc_frag_type(ast); if (frag_type == FRAG_TYPE_SHARED) { return; } CHARBUF_OPEN(param_buffer); charbuf *output = &param_buffer; bprintf(output, "\"name\" : \"%s\",\n", name); CHARBUF_OPEN(tmp); // quote the file as a json style literaj CSTR filename = name_ast->filename; #ifdef _WIN32 CSTR slash = strrchr(filename, '\\'); #else CSTR slash = strrchr(filename, '/'); #endif if (slash) { filename = slash + 1; } cg_encode_json_string_literal(filename, &tmp); bprintf(output, "\"definedInFile\" : %s,\n", tmp.ptr); CHARBUF_CLOSE(tmp); bool_t simple = cg_parameters(output, ast); cg_json_dependencies(output, ast); if (ast->sem->region) { cg_json_emit_region_info(output, ast); } if (misc_attrs) { bprintf(output, ",\n"); cg_json_misc_attrs(output, misc_attrs); } if (!stmt_list) { output = general; cg_json_general_proc(ast, misc_attrs, param_buffer.ptr); goto cleanup; } EXTRACT_STMT_AND_MISC_ATTRS(stmt, nested_misc_attrs, stmt_list); // if more than one statement it isn't simple if (stmt_list->right) { simple = 0; } // we have to see if it uses shared fragments, this can't be "simple" // because the parameters can be synthetic and require assignments and such if (simple && is_select_stmt(stmt)) { found_shared_fragment = false; CHARBUF_OPEN(scratch); cg_json_select_stmt(&scratch, stmt); // easy way to walk the tree CHARBUF_CLOSE(scratch); simple = !found_shared_fragment; } if (simple && is_select_stmt(stmt)) { output = queries; cg_begin_proc(output, ast, misc_attrs); BEGIN_INDENT(proc, 2); bprintf(output, "%s", param_buffer.ptr); cg_json_projection(output, stmt); cg_json_select_stmt(output, stmt); END_INDENT(proc); } else if (simple && is_insert_stmt(stmt)) { bool_t simple_insert = is_simple_insert(stmt); output = simple_insert ? inserts : general_inserts; cg_begin_proc(output, ast, misc_attrs); BEGIN_INDENT(proc, 2); bprintf(output, "%s", param_buffer.ptr); cg_json_insert_stmt(output, stmt, simple_insert); END_INDENT(proc); } else if (simple && is_delete_stmt(stmt)) { output = deletes; cg_begin_proc(output, ast, misc_attrs); BEGIN_INDENT(proc, 2); bprintf(output, "%s", param_buffer.ptr); cg_json_delete_stmt(output, stmt); END_INDENT(proc); } else if (simple && is_update_stmt(stmt)) { output = updates; cg_begin_proc(output, ast, misc_attrs); BEGIN_INDENT(proc, 2); bprintf(output, "%s", param_buffer.ptr); cg_json_update_stmt(output, stmt); END_INDENT(proc); } else { output = general; cg_json_general_proc(ast, misc_attrs, param_buffer.ptr); } cleanup: CHARBUF_CLOSE(param_buffer); cg_end_proc(output, ast); } // This lets us have top level attributes that go into the main output stream // this is stuff like the name of the database and so forth. By convention these // are placed as an attribution on the statements "declare database object". // Attributes for any object variables named *database are unified so that // different schema fragments can contribute easily. static void cg_json_declare_vars_type(charbuf *output, ast_node *ast, ast_node *misc_attrs) { Contract(is_ast_declare_vars_type(ast)); EXTRACT_NOTNULL(name_list, ast->left); EXTRACT_ANY_NOTNULL(data_type, ast->right); bool_t first_attr = output->used == 1; // we're looking for "declare database object" and nothing else if (misc_attrs && !name_list->right && is_object(data_type->sem->sem_type)) { EXTRACT_STRING(name, name_list->left); if (Strendswith(name, "database")) { if (first_attr) { bprintf(output, "\n"); } cg_json_test_details(output, ast, misc_attrs); BEGIN_INDENT(attr, 2); // The attributes from all the various sources are unified, they will // go into one attributes block. Note there can be duplicates but that's // not a problem for the schema and may even be desired. Note also // that even if we had only one such object there could still be duplicates // because again, attributes on a single object are not unique. They mean // whatever you want them to mean. So we just spit them out and let // the consumer sort it out. In practice this isn't really a problem. // Whatever tool is downstream will complain if the attributes are badly formed. for (ast_node *item = misc_attrs; item; item = item->right) { if (!first_attr) { bprintf(output, ",\n"); } first_attr = false; cg_json_misc_attr(output, item->left); } END_INDENT(attr); } } } // Here we create several buffers for the various statement types and then redirect // output into the appropriate buffer as we walk the statements. Finally each buffer // is emitted in order. static void cg_json_stmt_list(charbuf *output, ast_node *head) { CHARBUF_OPEN(query_buf); CHARBUF_OPEN(insert_buf); CHARBUF_OPEN(update_buf); CHARBUF_OPEN(delete_buf); CHARBUF_OPEN(general_buf); CHARBUF_OPEN(general_inserts_buf); CHARBUF_OPEN(attributes_buf); queries = &query_buf; inserts = &insert_buf; updates = &update_buf; deletes = &delete_buf; general = &general_buf; general_inserts = &general_inserts_buf; for (ast_node *ast = head; ast; ast = ast->right) { EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc_attrs, ast); if (is_ast_create_proc_stmt(stmt)) { cg_json_create_proc(stmt, misc_attrs); } else if (is_ast_declare_vars_type(stmt)) { cg_json_declare_vars_type(&attributes_buf, stmt, misc_attrs); } } bprintf(output, "\"attributes\" : ["); bprintf(output, "%s", attributes_buf.ptr); bprintf(output, "\n],\n"); bprintf(output, "\"queries\" : [\n"); bindent(output, queries, 2); bprintf(output, "\n],\n"); bprintf(output, "\"inserts\" : [\n"); bindent(output, inserts, 2); bprintf(output, "\n],\n"); bprintf(output, "\"generalInserts\" : [\n"); bindent(output, general_inserts, 2); bprintf(output, "\n],\n"); bprintf(output, "\"updates\" : [\n"); bindent(output, updates, 2); bprintf(output, "\n],\n"); bprintf(output, "\"deletes\" : [\n"); bindent(output, deletes, 2); bprintf(output, "\n],\n"); bprintf(output, "\"general\" : [\n"); bindent(output, general, 2); bprintf(output, "\n]"); CHARBUF_CLOSE(attributes_buf); CHARBUF_CLOSE(general_inserts_buf); CHARBUF_CLOSE(general_buf); CHARBUF_CLOSE(delete_buf); CHARBUF_CLOSE(update_buf); CHARBUF_CLOSE(insert_buf); CHARBUF_CLOSE(query_buf); // Ensure the globals do not hold any pointers so that leaksan will find any leaks // All of these have already been freed (above) queries = NULL; deletes = NULL; inserts = NULL; updates = NULL; general = NULL; general_inserts = NULL; } // Here we emit a top level fragment that has all the tables and // all the procedures that use that table. This is the reverse mapping // from the proc section where each proc defines which tables it uses. // i.e. we can use this map to go from a dirty table name to a list of // affected queries/updates etc. static void cg_json_table_users(charbuf *output) { uint32_t count = tables_to_procs->count; symtab_entry *deps = symtab_copy_sorted_payload(tables_to_procs, default_symtab_comparator); bprintf(output, "\"tableUsers\" : {\n"); BEGIN_INDENT(users, 2); BEGIN_LIST; for (int32_t i = 0; i < count; i++) { CSTR sym = deps[i].sym; charbuf *buf = (charbuf*)deps[i].val; COMMA; bprintf(output, "\"%s\" : [ %s ]", sym, buf->ptr); } END_LIST; END_INDENT(users); bprintf(output, "}"); free(deps); } // Main entry point for json schema format cql_noexport void cg_json_schema_main(ast_node *head) { Contract(options.file_names_count == 1); cql_exit_on_semantic_errors(head); tables_to_procs = symtab_new(); CHARBUF_OPEN(main); charbuf *output = &main; bprintf(output, "%s", rt->source_prefix); // master dictionary begins bprintf(output, "\n{\n"); BEGIN_INDENT(defs, 2); cg_json_tables(output); bprintf(output, ",\n"); cg_json_virtual_tables(output); bprintf(output, ",\n"); cg_json_views(output); bprintf(output, ",\n"); cg_json_indices(output); bprintf(output, ",\n"); cg_json_triggers(output); bprintf(output, ",\n"); cg_json_stmt_list(output, head); bprintf(output, ",\n"); cg_json_regions(output); bprintf(output, ",\n"); cg_json_ad_hoc_migration_procs(output); bprintf(output, ",\n"); cg_json_enums(output); bprintf(output, ",\n"); cg_json_constant_groups( output); if (options.test) { bprintf(output, ",\n"); cg_json_table_users(output); } END_INDENT(defs); bprintf(output, "\n}\n"); cql_write_file(options.file_names[0], output->ptr); CHARBUF_CLOSE(main); SYMTAB_CLEANUP(tables_to_procs); } #endif
32.385382
116
0.68659
d08a0803bb11d625ec8c88c18f274d90608ee5f7
588
h
C
code-sample/commons/samples.h
profnandaa/c-pointers-demystified
77c5f65e1db5aff63438edb4a98c316e8a9dee30
[ "MIT" ]
2
2020-02-04T20:59:29.000Z
2021-01-02T12:52:01.000Z
code-sample/commons/samples.h
profnandaa/c-pointers-demystified
77c5f65e1db5aff63438edb4a98c316e8a9dee30
[ "MIT" ]
null
null
null
code-sample/commons/samples.h
profnandaa/c-pointers-demystified
77c5f65e1db5aff63438edb4a98c316e8a9dee30
[ "MIT" ]
2
2020-02-04T21:15:03.000Z
2021-01-02T12:52:06.000Z
struct Person { char* name; int age; }; // this truly modifies the struct // pointed at void modifyStruct(struct Person *p) { p->name = "Modified Name"; } // this modifies the copy of the struct // passed to it, but then that is it // the original remains unchanged void modifyStruct2(struct Person p) { p.name = "Modified Name"; } // this will crash the caller // if they don't check for null pointer // x is deallocated once myFunc returns // supposedly "pointer-to-x" is null. int *myFunc() { int x = 30; // return &x; // gcc won't compile return 0; }
17.818182
39
0.658163
a978660825de8b4a51ac59acefac6fa67ec0b91b
10,553
c
C
res/unzip-5.52/windll/uzexampl.c
tsee/p5-Archive-Unzip-Burst
b13db7b97b216cc91bff49636d4c764c10414625
[ "Info-ZIP" ]
1
2015-01-14T20:11:52.000Z
2015-01-14T20:11:52.000Z
res/unzip-5.52/windll/uzexampl.c
tsee/p5-Archive-Unzip-Burst
b13db7b97b216cc91bff49636d4c764c10414625
[ "Info-ZIP" ]
null
null
null
res/unzip-5.52/windll/uzexampl.c
tsee/p5-Archive-Unzip-Burst
b13db7b97b216cc91bff49636d4c764c10414625
[ "Info-ZIP" ]
null
null
null
/* Copyright (c) 1990-2005 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in unzip.h) for terms of use. If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* This is a very simplistic example of how to load and make a call into the dll. This has been compiled and tested for a 32-bit console version, but not under 16-bit windows. However, the #ifdef's have been left in for the 16-bit code, simply as an example. */ #ifndef WIN32 /* this code is currently only tested for 32-bit console */ # define WIN32 #endif #if defined(__WIN32__) && !defined(WIN32) # define WIN32 #endif #include <sys/types.h> #include <sys/stat.h> #include <time.h> #include <string.h> #include "uzexampl.h" #include "../unzvers.h" #ifdef WIN32 # include <winver.h> #else # include <ver.h> #endif #ifndef _MAX_PATH # define _MAX_PATH 260 /* max total file or directory name path */ #endif #ifdef WIN32 #define UNZ_DLL_NAME "UNZIP32.DLL\0" #else #define UNZ_DLL_NAME "UNZIP16.DLL\0" #endif #define DLL_WARNING "Cannot find %s."\ " The Dll must be in the application directory, the path, "\ "the Windows directory or the Windows System directory." #define DLL_VERSION_WARNING "%s has the wrong version number."\ " Insure that you have the correct dll's installed, and that "\ "an older dll is not in your path or Windows System directory." int hFile; /* file handle */ LPUSERFUNCTIONS lpUserFunctions; HANDLE hUF = (HANDLE)NULL; LPDCL lpDCL = NULL; HANDLE hDCL = (HANDLE)NULL; HINSTANCE hUnzipDll; HANDLE hZCL = (HANDLE)NULL; #ifdef WIN32 DWORD dwPlatformId = 0xFFFFFFFF; #endif /* Forward References */ int WINAPI DisplayBuf(LPSTR, unsigned long); int WINAPI GetReplaceDlgRetVal(LPSTR); int WINAPI password(LPSTR, int, LPCSTR, LPCSTR); void WINAPI ReceiveDllMessage(unsigned long, unsigned long, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, char, LPSTR, LPSTR, unsigned long, char); _DLL_UNZIP pWiz_SingleEntryUnzip; static void FreeUpMemory(void); int main(int argc, char **argv) { int exfc, infc; char **exfv, **infv; char *x_opt; DWORD dwVerInfoSize; DWORD dwVerHnd; char szFullPath[_MAX_PATH]; int retcode; #ifdef WIN32 char *ptr; #else HFILE hfile; OFSTRUCT ofs; #endif HANDLE hMem; /* handle to mem alloc'ed */ if (argc < 2) /* We must have an archive to unzip */ { printf("usage: %s <zipfile> [entry1 [entry2 [...]]] [-x xentry1 [...]]", "example"); return 0; } hDCL = GlobalAlloc( GPTR, (DWORD)sizeof(DCL)); if (!hDCL) { return 0; } lpDCL = (LPDCL)GlobalLock(hDCL); if (!lpDCL) { GlobalFree(hDCL); return 0; } hUF = GlobalAlloc( GPTR, (DWORD)sizeof(USERFUNCTIONS)); if (!hUF) { GlobalUnlock(hDCL); GlobalFree(hDCL); return 0; } lpUserFunctions = (LPUSERFUNCTIONS)GlobalLock(hUF); if (!lpUserFunctions) { GlobalUnlock(hDCL); GlobalFree(hDCL); GlobalFree(hUF); return 0; } lpUserFunctions->password = password; lpUserFunctions->print = DisplayBuf; lpUserFunctions->sound = NULL; lpUserFunctions->replace = GetReplaceDlgRetVal; lpUserFunctions->SendApplicationMessage = ReceiveDllMessage; /* First we go look for the unzip dll */ #ifdef WIN32 if (SearchPath( NULL, /* address of search path */ UNZ_DLL_NAME, /* address of filename */ NULL, /* address of extension */ _MAX_PATH, /* size, in characters, of buffer */ szFullPath, /* address of buffer for found filename */ &ptr /* address of pointer to file component */ ) == 0) #else hfile = OpenFile(UNZ_DLL_NAME, &ofs, OF_SEARCH); if (hfile == HFILE_ERROR) #endif { char str[256]; wsprintf (str, DLL_WARNING, UNZ_DLL_NAME); printf("%s\n", str); FreeUpMemory(); return 0; } #ifndef WIN32 else lstrcpy(szFullPath, ofs.szPathName); _lclose(hfile); #endif /* Now we'll check the unzip dll version information. Note that this is not the same information as is returned from a call to UzpVersion() */ dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd); if (dwVerInfoSize) { BOOL fRet, fRetName; char str[256]; LPSTR lpstrVffInfo; /* Pointer to block to hold info */ LPSTR lszVer = NULL; LPSTR lszVerName = NULL; UINT cchVer = 0; /* Get a block big enough to hold the version information */ hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize); lpstrVffInfo = GlobalLock(hMem); /* Get the version information */ if (GetFileVersionInfo(szFullPath, 0L, dwVerInfoSize, lpstrVffInfo)) { fRet = VerQueryValue(lpstrVffInfo, TEXT("\\StringFileInfo\\040904E4\\FileVersion"), (LPVOID)&lszVer, &cchVer); fRetName = VerQueryValue(lpstrVffInfo, TEXT("\\StringFileInfo\\040904E4\\CompanyName"), (LPVOID)&lszVerName, &cchVer); if (!fRet || !fRetName || (lstrcmpi(lszVer, UNZ_DLL_VERSION) != 0) || (lstrcmpi(lszVerName, IZ_COMPANY_NAME) != 0)) { wsprintf (str, DLL_VERSION_WARNING, UNZ_DLL_NAME); printf("%s\n", str); FreeUpMemory(); GlobalUnlock(hMem); GlobalFree(hMem); return 0; } } /* free memory */ GlobalUnlock(hMem); GlobalFree(hMem); } else { char str[256]; wsprintf (str, DLL_VERSION_WARNING, UNZ_DLL_NAME); printf("%s\n", str); FreeUpMemory(); return 0; } /* Okay, now we know that the dll exists, and has the proper version * information in it. We can go ahead and load it. */ hUnzipDll = LoadLibrary(UNZ_DLL_NAME); #ifndef WIN32 if (hUnzipDll > HINSTANCE_ERROR) #else if (hUnzipDll != NULL) #endif { pWiz_SingleEntryUnzip = (_DLL_UNZIP)GetProcAddress(hUnzipDll, "Wiz_SingleEntryUnzip"); } else { char str[256]; wsprintf (str, "Could not load %s", UNZ_DLL_NAME); printf("%s\n", str); FreeUpMemory(); return 0; } /* Here is where the actual extraction process begins. First we set up the flags to be passed into the dll. */ lpDCL->ncflag = 0; /* Write to stdout if true */ lpDCL->fQuiet = 0; /* We want all messages. 1 = fewer messages, 2 = no messages */ lpDCL->ntflag = 0; /* test zip file if true */ lpDCL->nvflag = 0; /* give a verbose listing if true */ lpDCL->nzflag = 0; /* display a zip file comment if true */ lpDCL->ndflag = 1; /* Recreate directories != 0, skip "../" if < 2 */ lpDCL->naflag = 0; /* Do not convert CR to CRLF */ lpDCL->nfflag = 0; /* Do not freshen existing files only */ lpDCL->noflag = 1; /* Over-write all files if true */ lpDCL->ExtractOnlyNewer = 0; /* Do not extract only newer */ lpDCL->PromptToOverwrite = 0; /* "Overwrite all" selected -> no query mode */ lpDCL->lpszZipFN = argv[1]; /* The archive name */ lpDCL->lpszExtractDir = NULL; /* The directory to extract to. This is set to NULL if you are extracting to the current directory. */ /* As this is a quite short example, intended primarily to show how to load and call in to the dll, the command-line parameters are only parsed in a very simplistic way: We assume that the command-line parameters after the zip archive make up a list of file patterns: " [file_i1] [file_i2] ... [file_iN] [-x file_x1 [file_x2] ...]". We scan for an argument "-x"; all arguments in front are "include file patterns", all arguments after are "exclude file patterns". If no more arguments are given, we extract ALL files. In summary, the example program should be run like: example <archive.name> [files to include] [-x files to exclude] ("<...> denotes mandatory arguments, "[...]" optional arguments) */ x_opt = NULL; if (argc > 2) { infv = &argv[2]; for (infc = 0; infc < argc-2; infc++) if (!strcmp("-x", infv[infc])) { x_opt = infv[infc]; infv[infc] = NULL; break; } exfc = argc - infc - 3; if (exfc > 0) exfv = &argv[infc+3]; else { exfc = 0; exfv = NULL; } } else { infc = exfc = 0; infv = exfv = NULL; } retcode = (*pWiz_SingleEntryUnzip)(infc, infv, exfc, exfv, lpDCL, lpUserFunctions); if (x_opt) { infv[infc] = x_opt; x_opt = NULL; } if (retcode != 0) printf("Error unzipping...\n"); FreeUpMemory(); FreeLibrary(hUnzipDll); return 1; } int WINAPI GetReplaceDlgRetVal(LPSTR filename) { /* This is where you will decide if you want to replace, rename etc existing files. */ return 1; } static void FreeUpMemory(void) { if (hDCL) { GlobalUnlock(hDCL); GlobalFree(hDCL); } if (hUF) { GlobalUnlock(hUF); GlobalFree(hUF); } } /* This is a very stripped down version of what is done in Wiz. Essentially what this function is for is to do a listing of an archive contents. It is actually never called in this example, but a dummy procedure had to be put in, so this was used. */ void WINAPI ReceiveDllMessage(unsigned long ucsize, unsigned long csiz, unsigned cfactor, unsigned mo, unsigned dy, unsigned yr, unsigned hh, unsigned mm, char c, LPSTR filename, LPSTR methbuf, unsigned long crc, char fCrypt) { char psLBEntry[_MAX_PATH]; char LongHdrStats[] = "%7lu %7lu %4s %02u-%02u-%02u %02u:%02u %c%s"; char CompFactorStr[] = "%c%d%%"; char CompFactor100[] = "100%%"; char szCompFactor[10]; char sgn; if (csiz > ucsize) sgn = '-'; else sgn = ' '; if (cfactor == 100) lstrcpy(szCompFactor, CompFactor100); else sprintf(szCompFactor, CompFactorStr, sgn, cfactor); wsprintf(psLBEntry, LongHdrStats, ucsize, csiz, szCompFactor, mo, dy, yr, hh, mm, c, filename); printf("%s\n", psLBEntry); } /* Password entry routine - see password.c in the wiz directory for how this is actually implemented in WiZ. If you have an encrypted file, this will probably give you great pain. */ int WINAPI password(LPSTR p, int n, LPCSTR m, LPCSTR name) { return 1; } /* Dummy "print" routine that simply outputs what is sent from the dll */ int WINAPI DisplayBuf(LPSTR buf, unsigned long size) { printf("%s", (char *)buf); return (int)(unsigned int) size; }
27.698163
77
0.645883
45e856a2a334eb737e2ea6089e986738bbf2eaf9
113,809
c
C
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/usb/Beceem_driver/src/Common/CmHost.c
ghsecuritylab/tomato-sabai-arm
c24634f2dc8950c5e1d10bc9d7ef11dc6f1c45a4
[ "FSFAP" ]
3
2019-01-13T09:15:57.000Z
2019-02-08T10:59:25.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/usb/Beceem_driver/src/Common/CmHost.c
ghsecuritylab/tomato-sabai-arm
c24634f2dc8950c5e1d10bc9d7ef11dc6f1c45a4
[ "FSFAP" ]
1
2018-08-21T03:43:09.000Z
2018-08-21T03:43:09.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/usb/Beceem_driver/src/Common/CmHost.c
ghsecuritylab/tomato-sabai-arm
c24634f2dc8950c5e1d10bc9d7ef11dc6f1c45a4
[ "FSFAP" ]
2
2017-03-24T18:55:32.000Z
2020-03-08T02:32:43.000Z
/* * CmHost.c * *Copyright (C) 2010 Beceem Communications, Inc. * *This program is free software: you can redistribute it and/or modify *it under the terms of the GNU General Public License version 2 as *published by the Free Software Foundation. * *This program is distributed in the hope that it will be useful,but *WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *See the GNU General Public License for more details. * *You should have received a copy of the GNU General Public License *along with this program. If not, write to the Free Software Foundation, Inc., *51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ /************************************************************ * This file contains the routines for handling Connnection * Management. ************************************************************/ //#define CONN_MSG #include<headers.h> typedef enum _E_CLASSIFIER_ACTION { eInvalidClassifierAction, eAddClassifier, eReplaceClassifier, eDeleteClassifier }E_CLASSIFIER_ACTION; /************************************************************ * Function - SearchSfid * * Description - This routinue would search QOS queues having * specified SFID as input parameter. * * Parameters - Adapter: Pointer to the Adapter structure * uiSfid : Given SFID for matching * * Returns - Queue index for this SFID(If matched) Else Invalid Queue Index(If Not matched) ************************************************************/ __inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid) { INT iIndex=0; for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--) if(Adapter->PackInfo[iIndex].ulSFID==uiSfid) return iIndex; return NO_OF_QUEUES+1; } /*************************************************************** * Function - SearchFreeSfid * * Description - This routinue would search Free available SFID. * * Parameter - Adapter: Pointer to the Adapter structure * * Returns - Queue index for the free SFID * Else returns Invalid Index. ****************************************************************/ __inline INT SearchFreeSfid(PMINI_ADAPTER Adapter) { UINT uiIndex=0; for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++) if(Adapter->PackInfo[uiIndex].ulSFID==0) return uiIndex; return NO_OF_QUEUES+1; } __inline int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid) { int iIndex=0; for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--) if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid) return iIndex; return NO_OF_QUEUES+1; } /* Function: SearchClsid Description: This routinue would search Classifier having specified ClassifierID as input parameter Input parameters: PMINI_ADAPTER Adapter - Adapter Context unsigned int uiSfid - The SF in which the classifier is to searched B_UINT16 uiClassifierID - The classifier ID to be searched Return: int :Classifier table index of matching entry */ __inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifierID) { unsigned int uiClassifierIndex = 0; for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) { if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && (Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex == uiClassifierID)&& (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == ulSFID)) return uiClassifierIndex; } return MAX_CLASSIFIERS+1; } /** @ingroup ctrl_pkt_functions This routinue would search Free available Classifier entry in classifier table. @return free Classifier Entry index in classifier table for specified SF */ static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/ ) { unsigned int uiClassifierIndex = 0; for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) { if(!Adapter->astClassifierTable[uiClassifierIndex].bUsed) return uiClassifierIndex; } return MAX_CLASSIFIERS+1; } VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex) { //deleting all the packet held in the SF flush_queue(Adapter,uiSearchRuleIndex); //Deleting the all classifiers for this SF DeleteAllClassifiersForSF(Adapter,uiSearchRuleIndex); //Resetting only MIBS related entries in the SF memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, sizeof(S_MIBS_SERVICEFLOW_TABLE)); } static inline VOID CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry , B_UINT8 u8IpAddressLen , B_UINT8 *pu8IpAddressMaskSrc , BOOLEAN bIpVersion6 , E_IPADDR_CONTEXT eIpAddrContext) { UINT ucLoopIndex=0; UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS; UCHAR *ptrClassifierIpAddress = NULL; UCHAR *ptrClassifierIpMask = NULL; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); if(bIpVersion6) { nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES; } //Destination Ip Address BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Address Range Length:0x%X ", u8IpAddressLen); if((bIpVersion6?(IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2): (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) { /* //checking both the mask and address togethor in Classification. //So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2 //(nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask) */ if(eIpAddrContext == eDestIpAddress) { pstClassifierEntry->ucIPDestinationAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if(bIpVersion6) { ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv6Address; ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv6Mask; } else { ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv4Address; ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv4Mask; } } else if(eIpAddrContext == eSrcIpAddress) { pstClassifierEntry->ucIPSourceAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if(bIpVersion6) { ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv6Address; ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv6Mask; } else { ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv4Address; ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv4Mask; } } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Address Length:0x%X \n", pstClassifierEntry->ucIPDestinationAddressLength); while((u8IpAddressLen>= nSizeOfIPAddressInBytes) && (ucLoopIndex < MAX_IP_RANGE_LENGTH)) { memcpy(ptrClassifierIpAddress + (ucLoopIndex * nSizeOfIPAddressInBytes), (pu8IpAddressMaskSrc+(ucLoopIndex*nSizeOfIPAddressInBytes*2)), nSizeOfIPAddressInBytes); if(!bIpVersion6) { if(eIpAddrContext == eSrcIpAddress) { pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress. ulIpv4Addr[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]); } else if(eIpAddrContext == eDestIpAddress) { pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. ulIpv4Addr[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); } } u8IpAddressLen-=nSizeOfIPAddressInBytes; if(u8IpAddressLen >= nSizeOfIPAddressInBytes) { memcpy(ptrClassifierIpMask + (ucLoopIndex * nSizeOfIPAddressInBytes), (pu8IpAddressMaskSrc+nSizeOfIPAddressInBytes + (ucLoopIndex*nSizeOfIPAddressInBytes*2)), nSizeOfIPAddressInBytes); if(!bIpVersion6) { if(eIpAddrContext == eSrcIpAddress) { pstClassifierEntry->stSrcIpAddress. ulIpv4Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress. ulIpv4Mask[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Mask Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[ucLoopIndex]); } else if(eIpAddrContext == eDestIpAddress) { pstClassifierEntry->stDestIpAddress. ulIpv4Mask[ucLoopIndex] = ntohl(pstClassifierEntry->stDestIpAddress. ulIpv4Mask[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Mask Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[ucLoopIndex]); } } u8IpAddressLen-=nSizeOfIPAddressInBytes; } if(0==u8IpAddressLen) { pstClassifierEntry->bDestIpValid=TRUE; } ucLoopIndex++; } if(bIpVersion6) { //Restore EndianNess of Struct for(ucLoopIndex =0 ; ucLoopIndex < MAX_IP_RANGE_LENGTH * 4 ; ucLoopIndex++) { if(eIpAddrContext == eSrcIpAddress) { pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress. ulIpv6Addr[ucLoopIndex]); pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress. ulIpv6Mask[ucLoopIndex]); } else if(eIpAddrContext == eDestIpAddress) { pstClassifierEntry->stDestIpAddress.ulIpv6Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. ulIpv6Addr[ucLoopIndex]); pstClassifierEntry->stDestIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress. ulIpv6Mask[ucLoopIndex]); } } } } } void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll) { ULONG ulIndex; for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable; ulIndex++) { if(Adapter->astTargetDsxBuffer[ulIndex].valid) continue; if ((bFreeAll) || (Adapter->astTargetDsxBuffer[ulIndex].tid == TID)){ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", TID, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer); Adapter->astTargetDsxBuffer[ulIndex].valid=1; Adapter->astTargetDsxBuffer[ulIndex].tid=0; Adapter->ulFreeTargetBufferCnt++; } } } /** @ingroup ctrl_pkt_functions copy classifier rule into the specified SF index */ static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter,stConvergenceSLTypes *psfCSType,UINT uiSearchRuleIndex,UINT nClassifierIndex) { S_CLASSIFIER_RULE *pstClassifierEntry = NULL; //VOID *pvPhsContext = NULL; UINT ucLoopIndex=0; //UCHAR ucProtocolLength=0; //ULONG ulPhsStatus; if(Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 || nClassifierIndex > (MAX_CLASSIFIERS-1)) return; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Storing Classifier Rule Index : %X",ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex)); if(nClassifierIndex > MAX_CLASSIFIERS-1) return; pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if(pstClassifierEntry) { //Store if Ipv6 pstClassifierEntry->bIpv6Protocol = (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE; //Destinaiton Port pstClassifierEntry->ucDestPortRangeLength=psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength/4; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Length:0x%X ",pstClassifierEntry->ucDestPortRangeLength); if( MAX_PORT_RANGE >= psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength) { for(ucLoopIndex=0;ucLoopIndex<(pstClassifierEntry->ucDestPortRangeLength);ucLoopIndex++) { pstClassifierEntry->usDestPortRangeLo[ucLoopIndex] = *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+ucLoopIndex)); pstClassifierEntry->usDestPortRangeHi[ucLoopIndex] = *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+2+ucLoopIndex)); pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Lo:0x%X ",pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]); pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]); } } else { pstClassifierEntry->ucDestPortRangeLength=0; } //Source Port BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Length:0x%X ",psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); if(MAX_PORT_RANGE >= psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength) { pstClassifierEntry->ucSrcPortRangeLength = psfCSType->cCPacketClassificationRule. u8ProtocolSourcePortRangeLength/4; for(ucLoopIndex = 0; ucLoopIndex < (pstClassifierEntry->ucSrcPortRangeLength); ucLoopIndex++) { pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] = *((PUSHORT)(psfCSType->cCPacketClassificationRule. u8ProtocolSourcePortRange+ucLoopIndex)); pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex] = *((PUSHORT)(psfCSType->cCPacketClassificationRule. u8ProtocolSourcePortRange+2+ucLoopIndex)); pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] = ntohs(pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Lo:0x%X ",pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]); pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]); } } //Destination Ip Address and Mask BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Destination Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength, psfCSType->cCPacketClassificationRule.u8IPDestinationAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)? TRUE:FALSE, eDestIpAddress); //Source Ip Address and Mask BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Source Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength, psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE, eSrcIpAddress); //TOS BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"TOS Length:0x%X ",psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); if(3 == psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength) { pstClassifierEntry->ucIPTypeOfServiceLength = psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength; pstClassifierEntry->ucTosLow = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0]; pstClassifierEntry->ucTosHigh = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1]; pstClassifierEntry->ucTosMask = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]; pstClassifierEntry->bTOSValid = TRUE; } if(psfCSType->cCPacketClassificationRule.u8Protocol == 0) { //we didnt get protocol field filled in by the BS pstClassifierEntry->ucProtocolLength=0; } else { pstClassifierEntry->ucProtocolLength=1;// 1 valid protocol } pstClassifierEntry->ucProtocol[0] = psfCSType->cCPacketClassificationRule.u8Protocol; pstClassifierEntry->u8ClassifierRulePriority = psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority; //store the classifier rule ID and set this classifier entry as valid pstClassifierEntry->ucDirection = Adapter->PackInfo[uiSearchRuleIndex].ucDirection; pstClassifierEntry->uiClassifierRuleIndex = ntohs(psfCSType-> cCPacketClassificationRule.u16PacketClassificationRuleIndex); pstClassifierEntry->usVCID_Value = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; pstClassifierEntry->ulSFID = Adapter->PackInfo[uiSearchRuleIndex].ulSFID; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", uiSearchRuleIndex, pstClassifierEntry->ucDirection, pstClassifierEntry->uiClassifierRuleIndex, pstClassifierEntry->usVCID_Value); if(psfCSType->cCPacketClassificationRule.u8AssociatedPHSI) { pstClassifierEntry->u8AssociatedPHSI = psfCSType->cCPacketClassificationRule.u8AssociatedPHSI; } //Copy ETH CS Parameters pstClassifierEntry->ucEthCSSrcMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddressLength); memcpy(pstClassifierEntry->au8EThCSSrcMAC,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress,MAC_ADDRESS_SIZE); memcpy(pstClassifierEntry->au8EThCSSrcMACMask,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE); pstClassifierEntry->ucEthCSDestMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); memcpy(pstClassifierEntry->au8EThCSDestMAC,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress,MAC_ADDRESS_SIZE); memcpy(pstClassifierEntry->au8EThCSDestMACMask,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE); pstClassifierEntry->ucEtherTypeLen = (psfCSType->cCPacketClassificationRule.u8EthertypeLength); memcpy(pstClassifierEntry->au8EthCSEtherType,psfCSType->cCPacketClassificationRule.u8Ethertype,NUM_ETHERTYPE_BYTES); memcpy(pstClassifierEntry->usUserPriority, &psfCSType->cCPacketClassificationRule.u16UserPriority, 2); pstClassifierEntry->usVLANID = ntohs(psfCSType->cCPacketClassificationRule.u16VLANID); pstClassifierEntry->usValidityBitMap = ntohs(psfCSType->cCPacketClassificationRule.u16ValidityBitMap); pstClassifierEntry->bUsed = TRUE; } } /** @ingroup ctrl_pkt_functions */ static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex,UINT nClassifierIndex) { S_CLASSIFIER_RULE *pstClassifierEntry = NULL; B_UINT16 u16PacketClassificationRuleIndex; USHORT usVCID; //VOID *pvPhsContext = NULL; //ULONG ulPhsStatus; usVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; if(nClassifierIndex > MAX_CLASSIFIERS-1) return; if(usVCID == 0) return; u16PacketClassificationRuleIndex = Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if(pstClassifierEntry) { pstClassifierEntry->bUsed = FALSE; pstClassifierEntry->uiClassifierRuleIndex = 0; memset(pstClassifierEntry,0,sizeof(S_CLASSIFIER_RULE)); //Delete the PHS Rule for this classifier PhsDeleteClassifierRule( &Adapter->stBCMPhsContext, usVCID, u16PacketClassificationRuleIndex); } } /** @ingroup ctrl_pkt_functions */ VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex) { S_CLASSIFIER_RULE *pstClassifierEntry = NULL; UINT nClassifierIndex; //B_UINT16 u16PacketClassificationRuleIndex; USHORT ulVCID; //VOID *pvPhsContext = NULL; //ULONG ulPhsStatus; ulVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; if(ulVCID == 0) return; for(nClassifierIndex =0 ; nClassifierIndex < MAX_CLASSIFIERS ; nClassifierIndex++) { if(Adapter->astClassifierTable[nClassifierIndex].usVCID_Value == ulVCID) { pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if(pstClassifierEntry->bUsed) { DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex); } } } //Delete All Phs Rules Associated with this SF PhsDeleteSFRules( &Adapter->stBCMPhsContext, ulVCID); } /** This routinue copies the Connection Management related data into the Adapter structure. @ingroup ctrl_pkt_functions */ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ register pstServiceFlowParamSI psfLocalSet, /**<Pointer to the ServiceFlowParamSI structure*/ register UINT uiSearchRuleIndex, /**<Index of Queue, to which this data belongs*/ register UCHAR ucDsxType, stLocalSFAddIndicationAlt *pstAddIndication) { //UCHAR ucProtocolLength=0; ULONG ulSFID; UINT nClassifierIndex = 0; E_CLASSIFIER_ACTION eClassifierAction = eInvalidClassifierAction; B_UINT16 u16PacketClassificationRuleIndex=0; UINT nIndex=0; stConvergenceSLTypes *psfCSType = NULL; S_PHS_RULE sPhsRule; USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; UINT UGIValue = 0; Adapter->PackInfo[uiSearchRuleIndex].bValid=TRUE; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s: SFID= %x ",__FUNCTION__, ntohl(psfLocalSet->u32SFID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Updating Queue %d",uiSearchRuleIndex); ulSFID = ntohl(psfLocalSet->u32SFID); //Store IP Version used //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = 0; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; /*Enable IP/ETh CS Support As Required*/ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : u8CSSpecification : %X\n",psfLocalSet->u8CSSpecification); switch(psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; } case eCSPacketIPV6: { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; break; } case eCS802_3PacketEthernet: case eCS802_1QPacketVLAN: { Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; } case eCSPacketIPV4Over802_1QVLAN: case eCSPacketIPV4Over802_3Ethernet: { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; } case eCSPacketIPV6Over802_1QVLAN: case eCSPacketIPV6Over802_3Ethernet: { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; } default: { BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error in value of CS Classification.. setting default to IP CS\n"); Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; } } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X \n", uiSearchRuleIndex, Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport, Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport); //Store IP Version used //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF if(Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS) { Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6; } else { Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4; } /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */ if(!Adapter->bETHCSEnabled) Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; if(psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) { memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName, psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); } Adapter->PackInfo[uiSearchRuleIndex].u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; if(Adapter->PackInfo[uiSearchRuleIndex].u8QueueType==BE && Adapter->PackInfo[uiSearchRuleIndex].ucDirection) { Adapter->usBestEffortQueueIndex=uiSearchRuleIndex; } Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID); Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority; //copy all the classifier in the Service Flow param structure for(nIndex=0; nIndex<psfLocalSet->u8TotalClassifiers; nIndex++) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex); psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex); if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) { Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE; } if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) { Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE; } if(ucDsxType== DSA_ACK) { eClassifierAction = eAddClassifier; } else if(ucDsxType == DSC_ACK) { switch(psfCSType->u8ClassfierDSCAction) { case 0://DSC Add Classifier { eClassifierAction = eAddClassifier; } break; case 1://DSC Replace Classifier { eClassifierAction = eReplaceClassifier; } break; case 2://DSC Delete Classifier { eClassifierAction = eDeleteClassifier; } break; default: { eClassifierAction = eInvalidClassifierAction; } } } u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); switch(eClassifierAction) { case eAddClassifier: { //Get a Free Classifier Index From Classifier table for this SF to add the Classifier //Contained in this message nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); if(nClassifierIndex > MAX_CLASSIFIERS) { nClassifierIndex = SearchFreeClsid(Adapter); if(nClassifierIndex > MAX_CLASSIFIERS) { //Failed To get a free Entry BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Failed To get a free Classifier Entry"); break; } //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex); } else { //This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Error The Specified Classifier Already Exists \ and attempted To Add Classifier with Same PCRI : 0x%x\n", u16PacketClassificationRuleIndex); } } break; case eReplaceClassifier: { //Get the Classifier Index From Classifier table for this SF and replace existing Classifier //with the new classifier Contained in this message nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); if(nClassifierIndex > MAX_CLASSIFIERS) { //Failed To search the classifier BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be replaced failed"); break; } //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex); } break; case eDeleteClassifier: { //Get the Classifier Index From Classifier table for this SF and replace existing Classifier //with the new classifier Contained in this message nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex); if(nClassifierIndex > MAX_CLASSIFIERS) { //Failed To search the classifier BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be deleted failed"); break; } //Delete This classifier DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex); } break; default: { //Invalid Action for classifier break; } } } //Repeat parsing Classification Entries to process PHS Rules for(nIndex=0; nIndex < psfLocalSet->u8TotalClassifiers; nIndex++) { psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n", psfCSType->u8PhsDSCAction ); switch (psfCSType->u8PhsDSCAction) { case eDeleteAllPHSRules: { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Deleting All PHS Rules For VCID: 0x%X\n",uVCID); //Delete All the PHS rules for this Service flow PhsDeleteSFRules( &Adapter->stBCMPhsContext, uVCID); break; } case eDeletePHSRule: { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"PHS DSC Action = Delete PHS Rule \n"); if(psfCSType->cPhsRule.u8PHSI) { PhsDeletePHSRule( &Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); } else { //BCM_DEBUG_PRINT(CONN_MSG,("Error CPHSRule.PHSI is ZERO \n")); } break; } default : { if(ucDsxType == DSC_ACK) { //BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC \n",psfCSType->cPhsRule.u8PHSI)); break; //FOr DSC ACK Case PHS DSC Action must be in valid set } } //Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified //No Break Here . Intentionally! case eAddPHSRule: case eSetPHSRule: { if(psfCSType->cPhsRule.u8PHSI) { //Apply This PHS Rule to all classifiers whose Associated PHSI Match unsigned int uiClassifierIndex = 0; if(pstAddIndication->u8Direction == UPLINK_DIR ) { for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++) { if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && (Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adding PHS Rule For Classifier : 0x%x cPhsRule.u8PHSI : 0x%x\n", Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, psfCSType->cPhsRule.u8PHSI); //Update The PHS Rule for this classifier as Associated PHSI id defined //Copy the PHS Rule sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS); memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS); sPhsRule.u8RefCnt = 0; sPhsRule.bUnclassifiedPHSRule = FALSE; sPhsRule.PHSModifiedBytes = 0; sPhsRule.PHSModifiedNumPackets = 0; sPhsRule.PHSErrorNumPackets = 0; //bPHSRuleAssociated = TRUE; //Store The PHS Rule for this classifier PhsUpdateClassifierRule( &Adapter->stBCMPhsContext, uVCID, Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, &sPhsRule, Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI); //Update PHS Rule For the Classifier if(sPhsRule.u8PHSI) { Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule,&sPhsRule,sizeof(S_PHS_RULE)); } } } } else { //Error PHS Rule specified in signaling could not be applied to any classifier //Copy the PHS Rule sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS); memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS); sPhsRule.u8RefCnt = 0; sPhsRule.bUnclassifiedPHSRule = TRUE; sPhsRule.PHSModifiedBytes = 0; sPhsRule.PHSModifiedNumPackets = 0; sPhsRule.PHSErrorNumPackets = 0; //Store The PHS Rule for this classifier /* Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, clsid will be zero hence we cant have multiple PHS rules for the same SF. To support multiple PHS rule, passing u8PHSI. */ PhsUpdateClassifierRule( &Adapter->stBCMPhsContext, uVCID, sPhsRule.u8PHSI, &sPhsRule, sPhsRule.u8PHSI); } } } break; } } if(psfLocalSet->u32MaxSustainedTrafficRate == 0 ) { //No Rate Limit . Set Max Sustained Traffic Rate to Maximum Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) { //Too large Allowed Rate specified. Limiting to Wi Max Allowed rate Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else { Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = ntohl(psfLocalSet->u32MaxSustainedTrafficRate); } Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */ Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED; if(( Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS || Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS ) ) UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval); if(UGIValue == 0) UGIValue = DEFAULT_UG_INTERVAL; /* For UGI based connections... DEFAULT_UGI_FACTOR*UGIInterval worth of data is the max token count at host... The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput... In case of non-UGI based connection, 200 frames worth of data is the max token count at host... */ Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = (DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8) { UINT UGIFactor = 0; /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows: 1. Any packet from Host to FW can go out in different packet size. 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped. 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer */ UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1); if(UGIFactor > DEFAULT_UGI_FACTOR) Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = (UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8) Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8; } BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"LAT: %d, UGI: %d \n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate, ntohl(psfLocalSet->u32MaxSustainedTrafficRate), Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize); //copy the extended SF Parameters to Support MIBS CopyMIBSExtendedSFParameters(Adapter,psfLocalSet,uiSearchRuleIndex); //store header suppression enabled flag per SF Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled = !(psfLocalSet->u8RequesttransmissionPolicy & MASK_DISABLE_HEADER_SUPPRESSION); if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication) { bcm_kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL; } Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; if(UPLINK_DIR == pstAddIndication->u8Direction && Adapter->PackInfo[uiSearchRuleIndex].bActive) { BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Up link direction added...\n"); atomic_set(&Adapter->PackInfo[uiSearchRuleIndex].uiPerSFTxResourceCount, DEFAULT_PERSFCOUNT); Adapter->ucDsxConnBitMap |= CONNECT_ON_ULSF; } else if(DOWNLINK_DIR == pstAddIndication->u8Direction && Adapter->PackInfo[uiSearchRuleIndex].bActive) { BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Down link direction added...\n"); Adapter->ucDsxConnBitMap |= CONNECT_ON_DLSF; } //Re Sort the SF list in PackInfo according to Traffic Priority SortPackInfo(Adapter); /* Re Sort the Classifier Rules table and re - arrange according to Classifier Rule Priority */ SortClassifiers(Adapter); DumpPhsRules(&Adapter->stBCMPhsContext); // // Check and See if we can say Linkup to the Operating System. // CheckAndIndicateConnect(Adapter,pstAddIndication); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s <=====", __FUNCTION__); } /*********************************************************************** * Function - DumpCmControlPacket * * Description - This routinue Dumps the Contents of the AddIndication * Structure in the Connection Management Control Packet * * Parameter - pvBuffer: Pointer to the buffer containing the * AddIndication data. * * Returns - None *************************************************************************/ VOID DumpCmControlPacket(PVOID pvBuffer) { UINT uiLoopIndex; UINT nIndex; stLocalSFAddIndicationAlt *pstAddIndication; UINT nCurClassifierCnt; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type : 0x%X",pstAddIndication->u8Type); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction : 0x%X",pstAddIndication->u8Direction); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TID: 0x%X", ntohs(pstAddIndication->u16TID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",ntohs(pstAddIndication->u16CID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " AuthorizedSet--->"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",htonl(pstAddIndication->sfAuthorizedSet.u32SFID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",htons(pstAddIndication->sfAuthorizedSet.u16CID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", pstAddIndication->sfAuthorizedSet.u8ServiceClassNameLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x%X ,0x%X , 0x%X, 0x%X, 0x%X, 0x%X", pstAddIndication->sfAuthorizedSet.u8ServiceClassName[0], pstAddIndication->sfAuthorizedSet.u8ServiceClassName[1], pstAddIndication->sfAuthorizedSet.u8ServiceClassName[2], pstAddIndication->sfAuthorizedSet.u8ServiceClassName[3], pstAddIndication->sfAuthorizedSet.u8ServiceClassName[4], pstAddIndication->sfAuthorizedSet.u8ServiceClassName[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%X", pstAddIndication->sfAuthorizedSet.u8MBSService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%X", pstAddIndication->sfAuthorizedSet.u8QosParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%X, %p", pstAddIndication->sfAuthorizedSet.u8TrafficPriority, &pstAddIndication->sfAuthorizedSet.u8TrafficPriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%X 0x%p", pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate, &pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", pstAddIndication->sfAuthorizedSet.u32MinimumTolerableTrafficRate); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", pstAddIndication->sfAuthorizedSet.u32RequesttransmissionPolicy); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%X", pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X", pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParam[0]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%X", pstAddIndication->sfAuthorizedSet.u8ServiceFlowSchedulingType); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", pstAddIndication->sfAuthorizedSet.u32ToleratedJitter); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", pstAddIndication->sfAuthorizedSet.u32MaximumLatency); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%X", pstAddIndication->sfAuthorizedSet.u8FixedLengthVSVariableLengthSDUIndicator); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X", pstAddIndication->sfAuthorizedSet.u8SDUSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%X", pstAddIndication->sfAuthorizedSet.u16TargetSAID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQEnable); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQWindowSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryTxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRetryRxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockLifeTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQSyncLossTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%X", pstAddIndication->sfAuthorizedSet.u8ARQDeliverInOrder); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQRxPurgeTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X", pstAddIndication->sfAuthorizedSet.u16ARQBlockSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%X", pstAddIndication->sfAuthorizedSet.u8CSSpecification); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%X", pstAddIndication->sfAuthorizedSet.u8TypeOfDataDeliveryService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X", pstAddIndication->sfAuthorizedSet.u16SDUInterArrivalTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X", pstAddIndication->sfAuthorizedSet.u16TimeBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", pstAddIndication->sfAuthorizedSet.u8PagingPreference); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X", pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignmentLength); for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignment[uiLoopIndex]); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ", *(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping, *(unsigned int*)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[4], *(USHORT*) &pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[8]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%X", pstAddIndication->sfAuthorizedSet.u8TrafficIndicationPreference); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAuthorizedSet.u8TotalClassifiers); nCurClassifierCnt = pstAddIndication->sfAuthorizedSet.u8TotalClassifiers; if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) { nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.bValid %d", pstAddIndication->sfAuthorizedSet.bValid); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.u16MacOverhead %x", pstAddIndication->sfAuthorizedSet.u16MacOverhead); if(!pstAddIndication->sfAuthorizedSet.bValid) pstAddIndication->sfAuthorizedSet.bValid=1; for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) { stConvergenceSLTypes *psfCSType = NULL; psfCSType = &pstAddIndication->sfAuthorizedSet.cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "psfCSType = %p", psfCSType); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "CCPacketClassificationRuleSI====>"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%X ", psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u8ProtocolLength :0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolLength); #endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ", psfCSType->cCPacketClassificationRule.u8Protocol); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength:0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X", psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X ,0x%02X ,0x%02X ", psfCSType->cCPacketClassificationRule.u8Ethertype[0], psfCSType->cCPacketClassificationRule.u8Ethertype[1], psfCSType->cCPacketClassificationRule.u8Ethertype[2]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ", psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%X ", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%X ", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); #endif } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%02X",pstAddIndication->sfAuthorizedSet.bValid); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "AdmittedSet--->"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfAdmittedSet.u32SFID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfAdmittedSet.u16CID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", pstAddIndication->sfAdmittedSet.u8ServiceClassNameLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X", pstAddIndication->sfAdmittedSet.u8ServiceClassName[0], pstAddIndication->sfAdmittedSet.u8ServiceClassName[1], pstAddIndication->sfAdmittedSet.u8ServiceClassName[2], pstAddIndication->sfAdmittedSet.u8ServiceClassName[3], pstAddIndication->sfAdmittedSet.u8ServiceClassName[4], pstAddIndication->sfAdmittedSet.u8ServiceClassName[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X", pstAddIndication->sfAdmittedSet.u8MBSService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X", pstAddIndication->sfAdmittedSet.u8QosParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", pstAddIndication->sfAdmittedSet.u8TrafficPriority); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", ntohl(pstAddIndication->sfAdmittedSet.u32MaxSustainedTrafficRate)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", pstAddIndication->sfAdmittedSet.u32MinimumTolerableTrafficRate); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", pstAddIndication->sfAdmittedSet.u32RequesttransmissionPolicy); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", pstAddIndication->sfAdmittedSet.u32MinReservedTrafficRate); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X", pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParam[0]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X", pstAddIndication->sfAdmittedSet.u8ServiceFlowSchedulingType); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", pstAddIndication->sfAdmittedSet.u32ToleratedJitter); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", pstAddIndication->sfAdmittedSet.u32MaximumLatency); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", pstAddIndication->sfAdmittedSet.u8FixedLengthVSVariableLengthSDUIndicator); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%02X", pstAddIndication->sfAdmittedSet.u8SDUSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%02X", pstAddIndication->sfAdmittedSet.u16TargetSAID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQEnable); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQWindowSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryTxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRetryRxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockLifeTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQSyncLossTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%02X", pstAddIndication->sfAdmittedSet.u8ARQDeliverInOrder); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQRxPurgeTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X", pstAddIndication->sfAdmittedSet.u16ARQBlockSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%02X", pstAddIndication->sfAdmittedSet.u8CSSpecification); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%02X", pstAddIndication->sfAdmittedSet.u8TypeOfDataDeliveryService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X", pstAddIndication->sfAdmittedSet.u16SDUInterArrivalTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X", pstAddIndication->sfAdmittedSet.u16TimeBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X", pstAddIndication->sfAdmittedSet.u8PagingPreference); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X", pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignmentLength); for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X", pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignment[uiLoopIndex]); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%02X", pstAddIndication->sfAdmittedSet.u8TrafficIndicationPreference); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAdmittedSet.u8TotalClassifiers); nCurClassifierCnt = pstAddIndication->sfAdmittedSet.u8TotalClassifiers; if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) { nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; } for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) { stConvergenceSLTypes *psfCSType = NULL; psfCSType = &pstAddIndication->sfAdmittedSet.cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%02X ", psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%02X", psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%02X %02X %02X", psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolLength :0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolLength); #endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ", psfCSType->cCPacketClassificationRule.u8Protocol); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%02X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4] : 0x %02X %02X %02X %02X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4] : 0x %02X %02X %02X %02X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X", psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X %02X %02X", psfCSType->cCPacketClassificationRule.u8Ethertype[0], psfCSType->cCPacketClassificationRule.u8Ethertype[1], psfCSType->cCPacketClassificationRule.u8Ethertype[2]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ", psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%02X", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%02X ", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength : 0x%X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); #endif } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%X",pstAddIndication->sfAdmittedSet.bValid); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " ActiveSet--->"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfActiveSet.u32SFID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfActiveSet.u16CID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X", pstAddIndication->sfActiveSet.u8ServiceClassNameLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X", pstAddIndication->sfActiveSet.u8ServiceClassName[0], pstAddIndication->sfActiveSet.u8ServiceClassName[1], pstAddIndication->sfActiveSet.u8ServiceClassName[2], pstAddIndication->sfActiveSet.u8ServiceClassName[3], pstAddIndication->sfActiveSet.u8ServiceClassName[4], pstAddIndication->sfActiveSet.u8ServiceClassName[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X", pstAddIndication->sfActiveSet.u8MBSService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X", pstAddIndication->sfActiveSet.u8QosParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X", pstAddIndication->sfActiveSet.u8TrafficPriority); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X", ntohl(pstAddIndication->sfActiveSet.u32MaxSustainedTrafficRate)); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X", pstAddIndication->sfActiveSet.u32MaxTrafficBurst); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X", pstAddIndication->sfActiveSet.u32MinReservedTrafficRate); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X", pstAddIndication->sfActiveSet.u32MinimumTolerableTrafficRate); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X", pstAddIndication->sfActiveSet.u32RequesttransmissionPolicy); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X", pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X", pstAddIndication->sfActiveSet.u8VendorSpecificQoSParam[0]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X", pstAddIndication->sfActiveSet.u8ServiceFlowSchedulingType); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X", pstAddIndication->sfActiveSet.u32ToleratedJitter); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X", pstAddIndication->sfActiveSet.u32MaximumLatency); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X", pstAddIndication->sfActiveSet.u8FixedLengthVSVariableLengthSDUIndicator); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X", pstAddIndication->sfActiveSet.u8SDUSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TargetSAID : 0x%X", pstAddIndication->sfActiveSet.u16TargetSAID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQEnable : 0x%X", pstAddIndication->sfActiveSet.u8ARQEnable); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQWindowSize : 0x%X", pstAddIndication->sfActiveSet.u16ARQWindowSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryTxTimeOut : 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryTxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryRxTimeOut : 0x%X", pstAddIndication->sfActiveSet.u16ARQRetryRxTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockLifeTime : 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockLifeTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQSyncLossTimeOut : 0x%X", pstAddIndication->sfActiveSet.u16ARQSyncLossTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQDeliverInOrder : 0x%X", pstAddIndication->sfActiveSet.u8ARQDeliverInOrder); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRxPurgeTimeOut : 0x%X", pstAddIndication->sfActiveSet.u16ARQRxPurgeTimeOut); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockSize : 0x%X", pstAddIndication->sfActiveSet.u16ARQBlockSize); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8CSSpecification : 0x%X", pstAddIndication->sfActiveSet.u8CSSpecification); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TypeOfDataDeliveryService : 0x%X", pstAddIndication->sfActiveSet.u8TypeOfDataDeliveryService); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16SDUInterArrivalTime : 0x%X", pstAddIndication->sfActiveSet.u16SDUInterArrivalTime); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TimeBase : 0x%X", pstAddIndication->sfActiveSet.u16TimeBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X", pstAddIndication->sfActiveSet.u8PagingPreference); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignmentLength : 0x%X", pstAddIndication->sfActiveSet.MBSZoneIdentifierassignmentLength); for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignment : 0x%X", pstAddIndication->sfActiveSet.MBSZoneIdentifierassignment[uiLoopIndex]); #endif BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference : 0x%X", pstAddIndication->sfActiveSet.u8TrafficIndicationPreference); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfActiveSet.u8TotalClassifiers); nCurClassifierCnt = pstAddIndication->sfActiveSet.u8TotalClassifiers; if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF) { nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF; } for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++) { stConvergenceSLTypes *psfCSType = NULL; psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority :0x%X ", psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); #if 0 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " u8ProtocolLength :0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolLength); #endif for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ", psfCSType->cCPacketClassificationRule.u8Protocol); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]:0x%X ", psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); for(uiLoopIndex=0;uiLoopIndex<32;uiLoopIndex++) BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ", psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength:0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength:0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength:0x%X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength:0x%X ", psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength :0x%X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3] :0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8Ethertype[0], psfCSType->cCPacketClassificationRule.u8Ethertype[1], psfCSType->cCPacketClassificationRule.u8Ethertype[2]); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority :0x%X ", psfCSType->cCPacketClassificationRule.u16UserPriority); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID :0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI :0x%X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ", psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ", psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength :0x%X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6] :0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); #endif } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid : 0x%X",pstAddIndication->sfActiveSet.bValid); } static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet,PUCHAR pucDestBuffer) { UINT nBytesToRead = sizeof(stServiceFlowParamSI); if(ulAddrSFParamSet == 0 || NULL == pucDestBuffer) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Got Param address as 0!!"); return 0; } ulAddrSFParamSet = ntohl(ulAddrSFParamSet); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " RestoreSFParam: Total Words of DSX Message To Read: 0x%x From Target At : 0x%lx ", nBytesToRead/sizeof(ULONG),ulAddrSFParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "sizeof(stServiceFlowParamSI) = %x", sizeof(stServiceFlowParamSI)); //Read out the SF Param Set At the indicated Location BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "nBytesToRead = %x", nBytesToRead); if(rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) return STATUS_FAILURE; return 1; } static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULONG ulAddrSFParamSet) { UINT nBytesToWrite = sizeof(stServiceFlowParamSI); UINT uiRetVal =0; if(ulAddrSFParamSet == 0 || NULL == pucSrcBuffer) { return 0; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " StoreSFParam: Total Words of DSX Message To Write: 0x%X To Target At : 0x%lX ",(nBytesToWrite/sizeof(ULONG)),ulAddrSFParamSet); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "WRM with %x bytes",nBytesToWrite); uiRetVal = wrm(Adapter,ulAddrSFParamSet,(PUCHAR)pucSrcBuffer, nBytesToWrite); if(uiRetVal < 0) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed",__FUNCTION__, __LINE__); return uiRetVal; } return 1; } ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength) { stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL; stLocalSFAddIndication * pstAddIndication = NULL; stLocalSFDeleteRequest *pstDeletionRequest; UINT uiSearchRuleIndex; ULONG ulSFID; pstAddIndicationAlt = (stLocalSFAddIndicationAlt *)(pvBuffer); /* * In case of DSD Req By MS, we should immediately delete this SF so that * we can stop the further classifying the pkt for this SF. */ if(pstAddIndicationAlt->u8Type == DSD_REQ) { pstDeletionRequest = (stLocalSFDeleteRequest *)pvBuffer; ulSFID = ntohl(pstDeletionRequest->u32SFID); uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); if(uiSearchRuleIndex < NO_OF_QUEUES) { deleteSFBySfid(Adapter,uiSearchRuleIndex); Adapter->u32TotalDSD++; } return 1; } if( (pstAddIndicationAlt->u8Type == DSD_RSP) || (pstAddIndicationAlt->u8Type == DSD_ACK)) { //No Special handling send the message as it is return 1; } // For DSA_REQ, only upto "psfAuthorizedSet" parameter should be accessed by driver! pstAddIndication=(stLocalSFAddIndication *)kmalloc(sizeof(*pstAddIndication), GFP_KERNEL); if(NULL==pstAddIndication) return 0; /* AUTHORIZED SET */ pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *) GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); if(!pstAddIndication->psfAuthorizedSet) return 0; if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet, (ULONG)pstAddIndication->psfAuthorizedSet)!= 1) return 0; pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *) ntohl((ULONG)pstAddIndication->psfAuthorizedSet); if(pstAddIndicationAlt->u8Type == DSA_REQ) { stLocalSFAddRequest AddRequest; AddRequest.u8Type = pstAddIndicationAlt->u8Type; AddRequest.eConnectionDir = pstAddIndicationAlt->u8Direction; AddRequest.u16TID = pstAddIndicationAlt->u16TID; AddRequest.u16CID = pstAddIndicationAlt->u16CID; AddRequest.u16VCID = pstAddIndicationAlt->u16VCID; AddRequest.psfParameterSet =pstAddIndication->psfAuthorizedSet ; (*puBufferLength) = sizeof(stLocalSFAddRequest); memcpy(pvBuffer,&AddRequest,sizeof(stLocalSFAddRequest)); return 1; } // Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt //We need to extract the structure from the buffer and pack it differently pstAddIndication->u8Type = pstAddIndicationAlt->u8Type; pstAddIndication->eConnectionDir= pstAddIndicationAlt->u8Direction ; pstAddIndication->u16TID = pstAddIndicationAlt->u16TID; pstAddIndication->u16CID = pstAddIndicationAlt->u16CID; pstAddIndication->u16VCID = pstAddIndicationAlt->u16VCID; pstAddIndication->u8CC = pstAddIndicationAlt->u8CC; /* ADMITTED SET */ pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *) GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); if(!pstAddIndication->psfAdmittedSet) return 0; if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,(ULONG)pstAddIndication->psfAdmittedSet) != 1) return 0; pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAdmittedSet); /* ACTIVE SET */ pstAddIndication->psfActiveSet = (stServiceFlowParamSI *) GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); if(!pstAddIndication->psfActiveSet) return 0; if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfActiveSet,(ULONG)pstAddIndication->psfActiveSet) != 1) return 0; pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfActiveSet); (*puBufferLength) = sizeof(stLocalSFAddIndication); *(stLocalSFAddIndication *)pvBuffer = *pstAddIndication; bcm_kfree(pstAddIndication); return 1; } static inline stLocalSFAddIndicationAlt *RestoreCmControlResponseMessage(register PMINI_ADAPTER Adapter,register PVOID pvBuffer) { ULONG ulStatus=0; stLocalSFAddIndication *pstAddIndication = NULL; stLocalSFAddIndicationAlt *pstAddIndicationDest = NULL; pstAddIndication = (stLocalSFAddIndication *)(pvBuffer); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>" ); if ((pstAddIndication->u8Type == DSD_REQ) || (pstAddIndication->u8Type == DSD_RSP) || (pstAddIndication->u8Type == DSD_ACK)) { return (stLocalSFAddIndicationAlt *)pvBuffer; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Inside RestoreCmControlResponseMessage "); /* //Need to Allocate memory to contain the SUPER Large structures //Our driver cant create these structures on Stack :( */ pstAddIndicationDest=kmalloc(sizeof(stLocalSFAddIndicationAlt), GFP_KERNEL); if(pstAddIndicationDest) { memset(pstAddIndicationDest,0,sizeof(stLocalSFAddIndicationAlt)); } else { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure "); return NULL; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X",pstAddIndication->u8Type); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X",pstAddIndication->eConnectionDir); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X",ntohs(pstAddIndication->u16TID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X",ntohs(pstAddIndication->u16CID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : 0x%x",ntohl(pstAddIndication->psfAuthorizedSet)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : 0x%x",ntohl(pstAddIndication->psfAdmittedSet)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : 0x%x",ntohl(pstAddIndication->psfActiveSet)); pstAddIndicationDest->u8Type = pstAddIndication->u8Type; pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; pstAddIndicationDest->u16TID = pstAddIndication->u16TID; pstAddIndicationDest->u16CID = pstAddIndication->u16CID; pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID; pstAddIndicationDest->u8CC = pstAddIndication->u8CC; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Active Set "); ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet); if(ulStatus != 1) { goto failed_restore_sf_param; } if(pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Admitted Set "); ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAdmittedSet,(PUCHAR)&pstAddIndicationDest->sfAdmittedSet); if(ulStatus != 1) { goto failed_restore_sf_param; } if(pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Authorized Set "); ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAuthorizedSet,(PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); if(ulStatus != 1) { goto failed_restore_sf_param; } if(pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size %x %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest); //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); return pstAddIndicationDest; failed_restore_sf_param: bcm_kfree(pstAddIndicationDest); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" ); return NULL; } ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter) { ULONG ulTargetDsxBuffersBase = 0; ULONG ulCntTargetBuffers; ULONG ulIndex=0; int Status; if(Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer) return 1; if(NULL == Adapter) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!"); return 0; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of ServiceFlowParamSI): %x ",sizeof(stServiceFlowParamSI)); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ",DSX_MESSAGE_EXCHANGE_BUFFER); Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); if(Status < 0) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!"); return 0; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX Target Buffer : 0x%lx",ulTargetDsxBuffersBase); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Tgt Buffer is Now %lx :",ulTargetDsxBuffersBase); ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE/sizeof(stServiceFlowParamSI); Adapter->ulTotalTargetBuffersAvailable = ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ? MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ",Adapter->ulTotalTargetBuffersAvailable); for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable ; ulIndex++) { Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer = ulTargetDsxBuffersBase; Adapter->astTargetDsxBuffer[ulIndex].valid=1; Adapter->astTargetDsxBuffer[ulIndex].tid=0; ulTargetDsxBuffersBase+=sizeof(stServiceFlowParamSI); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Target DSX Buffer %lx setup at 0x%lx", ulIndex, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer); } Adapter->ulCurrentTargetBuffer = 0; Adapter->ulFreeTargetBufferCnt = Adapter->ulTotalTargetBuffersAvailable; return 1; } ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid) { ULONG ulTargetDSXBufferAddress; ULONG ulTargetDsxBufferIndexToUse,ulMaxTry; if((Adapter->ulTotalTargetBuffersAvailable == 0)|| (Adapter->ulFreeTargetBufferCnt == 0)) { ClearTargetDSXBuffer(Adapter,tid,FALSE); return 0; } ulTargetDsxBufferIndexToUse = Adapter->ulCurrentTargetBuffer; ulMaxTry = Adapter->ulTotalTargetBuffersAvailable; while((ulMaxTry)&&(Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid != 1)) { ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1)% Adapter->ulTotalTargetBuffersAvailable; ulMaxTry--; } if(ulMaxTry==0) { BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ",Adapter->ulFreeTargetBufferCnt); ClearTargetDSXBuffer(Adapter,tid,FALSE); return 0; } ulTargetDSXBufferAddress = Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].ulTargetDsxBuffer; Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid=0; Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].tid=tid; Adapter->ulFreeTargetBufferCnt--; ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1)%Adapter->ulTotalTargetBuffersAvailable; Adapter->ulCurrentTargetBuffer = ulTargetDsxBufferIndexToUse; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", ulTargetDSXBufferAddress,tid); return ulTargetDSXBufferAddress; } INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter) { /* //Need to Allocate memory to contain the SUPER Large structures //Our driver cant create these structures on Stack */ Adapter->caDsxReqResp=kmalloc(sizeof(stLocalSFAddIndicationAlt)+LEADER_SIZE, GFP_KERNEL); if(!Adapter->caDsxReqResp) return -ENOMEM; return 0; } INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter) { if(Adapter->caDsxReqResp) { bcm_kfree(Adapter->caDsxReqResp); } return 0; } VOID CheckAndIndicateConnect(PMINI_ADAPTER Adapter, stLocalSFAddIndicationAlt *pstAddIndication) { struct timeval tv = {0} ; if((Adapter->ucDsxConnBitMap & Adapter->ucDsxLinkUpCfg) == Adapter->ucDsxLinkUpCfg) { if(0==Adapter->LinkUpStatus) { BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the queue...\n"); Adapter->LinkUpStatus = TRUE; Adapter->TimerActive = TRUE; do_gettimeofday(&tv); Adapter->liTimeSinceLastNetEntry = tv.tv_sec; atomic_set(&Adapter->TxPktAvail, 1); netif_carrier_on (Adapter->dev); netif_start_queue (Adapter->dev); wake_up(&Adapter->tx_packet_wait_queue); } } } /** @ingroup ctrl_pkt_functions This routinue would process the Control responses for the Connection Management. @return - Queue index for the free SFID else returns Invalid Index. */ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/ PVOID pvBuffer /**Starting Address of the Buffer, that contains the AddIndication Data*/ ) { stServiceFlowParamSI *psfLocalSet=NULL; stLocalSFAddIndicationAlt *pstAddIndication = NULL; stLocalSFChangeIndicationAlt *pstChangeIndication = NULL; PLEADER pLeader=NULL; /* //Otherwise the message contains a target address from where we need to //read out the rest of the service flow param structure */ if((pstAddIndication = RestoreCmControlResponseMessage(Adapter,pvBuffer)) == NULL) { ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndication *)pvBuffer)->u16TID, FALSE); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message"); return FALSE; } DumpCmControlPacket(pstAddIndication); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>"); pLeader = (PLEADER)Adapter->caDsxReqResp; pLeader->Status =CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ; pLeader->Vcid = 0; ClearTargetDSXBuffer(Adapter,pstAddIndication->u16TID,FALSE); BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n",pstAddIndication->u16TID); switch(pstAddIndication->u8Type) { case DSA_REQ: { pLeader->PLength = sizeof(stLocalSFAddIndicationAlt); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n"); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength ); *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstAddIndication; ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID)); CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); bcm_kfree(pstAddIndication); } break; case DSA_RSP: { pLeader->PLength = sizeof(stLocalSFAddIndicationAlt); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d", pLeader->PLength); *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstAddIndication; ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK; }//no break here..we should go down. case DSA_ACK: { UINT uiSearchRuleIndex=0; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X", ntohs(pstAddIndication->u16VCID)); uiSearchRuleIndex=SearchFreeSfid(Adapter); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiSearchRuleIndex:0x%X ", uiSearchRuleIndex); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Direction:0x%X ", pstAddIndication->u8Direction); if((uiSearchRuleIndex< NO_OF_QUEUES) ) { Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstAddIndication->u8Direction; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ", pstAddIndication->sfActiveSet.bValid); if(pstAddIndication->sfActiveSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE; } if(pstAddIndication->sfAuthorizedSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE; } if(pstAddIndication->sfAdmittedSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE; } if(FALSE == pstAddIndication->sfActiveSet.bValid) { Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; if(pstAddIndication->sfAdmittedSet.bValid) { psfLocalSet = &pstAddIndication->sfAdmittedSet; } else if(pstAddIndication->sfAuthorizedSet.bValid) { psfLocalSet = &pstAddIndication->sfAuthorizedSet; } } else { psfLocalSet = &pstAddIndication->sfActiveSet; Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; } if(!psfLocalSet) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No set is valid\n"); Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; bcm_kfree(pstAddIndication); } else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0)) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSA ACK"); Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstAddIndication->u16VCID); Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstAddIndication->u16CID); CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex, DSA_ACK, pstAddIndication); // don't free pstAddIndication /* Inside CopyToAdapter, Sorting of all the SFs take place. Hence any access to the newly added SF through uiSearchRuleIndex is invalid. SHOULD BE STRICTLY AVOIDED. */ // *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; memcpy((((PUCHAR)pvBuffer)+1), &psfLocalSet->u32SFID, 4); } else { Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE; Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0; bcm_kfree(pstAddIndication); } } else { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID"); bcm_kfree(pstAddIndication); return FALSE; } } break; case DSC_REQ: { pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength); *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP; CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); bcm_kfree(pstAddIndication); } break; case DSC_RSP: { pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt); pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength); *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication; ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK; } case DSC_ACK: { UINT uiSearchRuleIndex=0; pstChangeIndication = (stLocalSFChangeIndicationAlt *)pstAddIndication; uiSearchRuleIndex=SearchSfid(Adapter,ntohl(pstChangeIndication->sfActiveSet.u32SFID)); if(uiSearchRuleIndex > NO_OF_QUEUES-1) { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received"); } if((uiSearchRuleIndex < NO_OF_QUEUES)) { Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction; if(pstChangeIndication->sfActiveSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE; } if(pstChangeIndication->sfAuthorizedSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE; } if(pstChangeIndication->sfAdmittedSet.bValid==TRUE) { Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE; } if(FALSE==pstChangeIndication->sfActiveSet.bValid) { Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE; Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE; if(pstChangeIndication->sfAdmittedSet.bValid) { psfLocalSet = &pstChangeIndication->sfAdmittedSet; } else if(pstChangeIndication->sfAuthorizedSet.bValid) { psfLocalSet = &pstChangeIndication->sfAuthorizedSet; } } else { psfLocalSet = &pstChangeIndication->sfActiveSet; Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; } if(psfLocalSet->bValid && (pstChangeIndication->u8CC == 0)) { Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pstChangeIndication->u16VCID); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n", pstChangeIndication->u8CC, psfLocalSet->bValid); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "VCID= %d\n", ntohs(pstChangeIndication->u16VCID)); Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pstChangeIndication->u16CID); CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex, DSC_ACK, pstAddIndication); *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID; } else if(pstChangeIndication->u8CC == 6) { deleteSFBySfid(Adapter,uiSearchRuleIndex); bcm_kfree(pstAddIndication); } } else { BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID"); bcm_kfree(pstAddIndication); return FALSE; } } break; case DSD_REQ: { UINT uiSearchRuleIndex; ULONG ulSFID; pLeader->PLength = sizeof(stLocalSFDeleteIndication); *((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((stLocalSFDeleteIndication*)pstAddIndication); ulSFID = ntohl(((stLocalSFDeleteIndication*)pstAddIndication)->u32SFID); uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD - Removing connection %x",uiSearchRuleIndex); if(uiSearchRuleIndex < NO_OF_QUEUES) { //Delete All Classifiers Associated with this SFID deleteSFBySfid(Adapter,uiSearchRuleIndex); Adapter->u32TotalDSD++; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC"); ((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP; CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp); } case DSD_RSP: { //Do nothing as SF has already got Deleted } break; case DSD_ACK: BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n"); break; default: bcm_kfree(pstAddIndication); return FALSE ; } return TRUE; } int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, PUCHAR user_buffer) { int status = 0; struct _packet_info *psSfInfo=NULL; BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status); status = SearchSfid(Adapter, uiSFId); if(status>NO_OF_QUEUES) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID %d not present in queue !!!", uiSFId ); return -EINVAL; } BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status); psSfInfo=&Adapter->PackInfo[status]; if(psSfInfo->pstSFIndication && copy_to_user((PCHAR)user_buffer, (PCHAR)psSfInfo->pstSFIndication, sizeof(stLocalSFAddIndicationAlt))) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId ); status = -EFAULT; return status; } return STATUS_SUCCESS; } VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer) { B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1)); stIM_SFHostNotify *pHostInfo = NULL; UINT uiSearchRuleIndex = 0; ULONG ulSFID = 0; puiBuffer+=2; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n",u32NumofSFsinMsg); while(u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) { u32NumofSFsinMsg--; pHostInfo = (stIM_SFHostNotify *)puiBuffer; puiBuffer = (PUINT)(pHostInfo + 1); ulSFID = ntohl(pHostInfo->SFID); uiSearchRuleIndex=SearchSfid(Adapter,ulSFID); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"SFID: 0x%lx\n",ulSFID); if(uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID); continue; } if(pHostInfo->RetainSF == FALSE) { BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Going to Delete SF"); deleteSFBySfid(Adapter,uiSearchRuleIndex); } else { // // Propagte the VCID update to the PHS table. // UpdateServiceFlowParams(Adapter->stBCMPhsContext.pstServiceFlowPhsRulesTable, Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value, ntohs(pHostInfo->VCID)); Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pHostInfo->VCID); Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pHostInfo->newCID); Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE; BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"pHostInfo->QoSParamSet: 0x%x\n",pHostInfo->QoSParamSet); if(pHostInfo->QoSParamSet & 0x1) Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet =TRUE; if(pHostInfo->QoSParamSet & 0x2) Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet =TRUE; if(pHostInfo->QoSParamSet & 0x4) { Adapter->PackInfo[uiSearchRuleIndex].bActiveSet =TRUE; Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE; } } } }
45.450879
198
0.759887
ca16f792f67b8b3e702034560854b276bf51120f
1,017
h
C
DependentExtensions/SQLite3Plugin/Logger/ClientOnly/Optional/SQLiteClientLogger_RNSLogger.h
Iam1337/CrabNet
4e88fb11941dee557c1f96c6a6c8f04fd6360de5
[ "BSD-2-Clause" ]
19
2016-09-26T16:37:06.000Z
2018-03-31T10:20:49.000Z
DependentExtensions/SQLite3Plugin/Logger/ClientOnly/Optional/SQLiteClientLogger_RNSLogger.h
Iam1337/CrabNet
4e88fb11941dee557c1f96c6a6c8f04fd6360de5
[ "BSD-2-Clause" ]
10
2017-07-06T10:10:18.000Z
2018-06-13T20:02:46.000Z
DependentExtensions/SQLite3Plugin/Logger/ClientOnly/Optional/SQLiteClientLogger_RNSLogger.h
Iam1337/CrabNet
4e88fb11941dee557c1f96c6a6c8f04fd6360de5
[ "BSD-2-Clause" ]
4
2017-01-17T06:14:07.000Z
2018-02-23T18:51:02.000Z
/* * Copyright (c) 2014, Oculus VR, Inc. * Copyright (c) 2016-2018, TES3MP Team * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ /// \file /// \brief Writes RakNetStatistics for all connected systems once per second to SQLiteClientLogger /// #ifndef __SQL_LITE_CLIENT_LOGGER_RAKNET_STATISTICS_H_ #define __SQL_LITE_CLIENT_LOGGER_RAKNET_STATISTICS_H_ #include "PluginInterface2.h" namespace RakNet { /// \ingroup PACKETLOGGER_GROUP /// \brief Packetlogger that outputs to a file class RAK_DLL_EXPORT SQLiteClientLogger_RakNetStatistics : public PluginInterface2 { public: SQLiteClientLogger_RakNetStatistics(); virtual ~SQLiteClientLogger_RakNetStatistics(); virtual void Update(void); protected: RakNet::TimeUS lastUpdate; }; } #endif
26.076923
99
0.737463
10e26850166577f4d1af6646e0be6020129aad95
2,043
h
C
interfaces/kits/js/medialibrary/include/video_asset_napi.h
openharmony-gitee-mirror/multimedia_medialibrary_standard
84968c9e4b6292182bfeb4f6aa88b227ffeebab6
[ "Apache-2.0" ]
null
null
null
interfaces/kits/js/medialibrary/include/video_asset_napi.h
openharmony-gitee-mirror/multimedia_medialibrary_standard
84968c9e4b6292182bfeb4f6aa88b227ffeebab6
[ "Apache-2.0" ]
null
null
null
interfaces/kits/js/medialibrary/include/video_asset_napi.h
openharmony-gitee-mirror/multimedia_medialibrary_standard
84968c9e4b6292182bfeb4f6aa88b227ffeebab6
[ "Apache-2.0" ]
1
2021-09-13T11:20:49.000Z
2021-09-13T11:20:49.000Z
/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef VIDEO_ASSET_NAPI_H #define VIDEO_ASSET_NAPI_H #include "media_asset_napi.h" #include "napi/native_api.h" #include "napi/native_node_api.h" #include "video_asset.h" namespace OHOS { static const std::string VIDEO_ASSET_NAPI_CLASS_NAME = "VideoAsset"; class VideoAssetNapi : public MediaAssetNapi { public: static napi_value Init(napi_env env, napi_value exports); static napi_value CreateVideoAsset(napi_env env, Media::VideoAsset &vAsset, Media::IMediaLibraryClient &mediaLibClient); VideoAssetNapi(); ~VideoAssetNapi(); private: static void VideoAssetNapiDestructor(napi_env env, void* nativeObject, void* finalize_hint); static napi_value VideoAssetNapiConstructor(napi_env env, napi_callback_info info); static napi_value GetMimeType(napi_env env, napi_callback_info info); static napi_value GetWidth(napi_env env, napi_callback_info info); static napi_value GetHeight(napi_env env, napi_callback_info info); static napi_value GetDuration(napi_env env, napi_callback_info info); void UpdateVideoAssetInfo(); std::string mimeType_; int32_t width_; int32_t height_; int32_t duration_; napi_env env_; napi_ref wrapper_; static napi_ref sConstructor_; static Media::VideoAsset *sVideoAsset_; static Media::IMediaLibraryClient *sMediaLibrary_; }; } // namespace OHOS #endif /* VIDEO_ASSET_NAPI_H */
33.491803
96
0.74743
2ef69ce77f67d5214a86bff49e9b7906e912fb62
944
h
C
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/BussinessJDExtendItem.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
30
2020-03-22T12:30:21.000Z
2022-02-09T08:49:13.000Z
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/BussinessJDExtendItem.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
null
null
null
CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/BussinessJDExtendItem.h
ceekay1991/CallTraceForWeChat
5767cb6f781821b6bf9facc8c87e58e15fa88541
[ "MIT" ]
8
2020-03-22T12:30:23.000Z
2020-09-22T04:01:47.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import "MMObject.h" @class NSString; @interface BussinessJDExtendItem : MMObject { NSString *nsIconUrl; NSString *nsName; NSString *nsJumpUrl; NSString *nsJumpWeapp; NSString *nsJumpWeappPath; long long nsJumpWeappVersion; } @property(nonatomic) long long nsJumpWeappVersion; // @synthesize nsJumpWeappVersion; @property(retain, nonatomic) NSString *nsJumpWeappPath; // @synthesize nsJumpWeappPath; @property(retain, nonatomic) NSString *nsJumpWeapp; // @synthesize nsJumpWeapp; @property(retain, nonatomic) NSString *nsJumpUrl; // @synthesize nsJumpUrl; @property(retain, nonatomic) NSString *nsName; // @synthesize nsName; @property(retain, nonatomic) NSString *nsIconUrl; // @synthesize nsIconUrl; - (void).cxx_destruct; @end
30.451613
90
0.738347
2c022728acb95a3e02b98a969560545e1914201d
1,803
h
C
spot/cma_optimizer.h
adamkewley/spot
36782240cb3382f705a688688e7f8b49c09a5fa5
[ "Apache-2.0" ]
null
null
null
spot/cma_optimizer.h
adamkewley/spot
36782240cb3382f705a688688e7f8b49c09a5fa5
[ "Apache-2.0" ]
null
null
null
spot/cma_optimizer.h
adamkewley/spot
36782240cb3382f705a688688e7f8b49c09a5fa5
[ "Apache-2.0" ]
null
null
null
#pragma once #include "spot_types.h" #include "optimizer.h" namespace spot { enum class cma_weights { equal = 0, linear = 1, log = 2 }; struct cma_options { int lambda = 0; long random_seed = 123; cma_weights weights = cma_weights::log; // #todo: this setting is currently ignored :S }; class SPOT_API cma_optimizer : public optimizer { public: cma_optimizer( const objective& o, evaluator& e, const cma_options& options = cma_options() ); virtual ~cma_optimizer(); // optimization const search_point_vec& sample_population(); void update_distribution( const fitness_vec& results ); // fitness info virtual const fitness_vec& current_step_fitnesses() const override { return current_step_fitnesses_; } virtual fitness_t current_step_best_fitness() const override { return current_step_best_fitness_; } virtual const search_point& current_step_best_point() const override { return current_step_best_point_; } virtual fitness_t best_fitness() const override { return best_fitness_; } virtual const search_point& best_point() const override { return best_point_; } // analysis par_vec current_mean() const; par_vec current_std() const; vector< par_vec > current_covariance() const; // state virtual void save_state( const path& filename ) const override; virtual objective_info make_updated_objective_info() const override; // actual parameters int dim() const; int lambda() const; int mu() const; int random_seed() const; double sigma() const; protected: fitness_t best_fitness_; search_point best_point_; fitness_t current_step_best_fitness_; fitness_vec current_step_fitnesses_; search_point current_step_best_point_; size_t max_resample_count; virtual void internal_step() override; struct pimpl_t* pimpl; }; }
28.619048
107
0.757626
d80e7ee9861be58d58b448142a9cf2f69826dd7e
1,514
c
C
exercises/7_8_file_pages.c
xanpen/exercises
bac2b69392659fb5727b6e4a8ac37722e7b1a696
[ "Apache-2.0" ]
null
null
null
exercises/7_8_file_pages.c
xanpen/exercises
bac2b69392659fb5727b6e4a8ac37722e7b1a696
[ "Apache-2.0" ]
null
null
null
exercises/7_8_file_pages.c
xanpen/exercises
bac2b69392659fb5727b6e4a8ac37722e7b1a696
[ "Apache-2.0" ]
null
null
null
// // 7_8_file_pages.c // c_exercises // // Created by 王显朋 on 2019/4/24. // Copyright © 2019年 wongxp. All rights reserved. // #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXLINE 100 #define MAXHDR 5 #define MAXBTM 3 #define MAXPAGE 66 void fileprint(FILE *, char *); int main_7_8(int argc, char *argv[]) { FILE *fp; if (argc == 1) { fileprint(stdin, " "); } else { while (--argc > 0) { if ((fp = fopen(*++argv, "r")) == NULL) { fprintf(stderr, "can not open %s\n", *argv); } else { fileprint(fp, *argv); fclose(fp); } } } return 0; } // 打印文件内容: 页头(2个空行+标题页码行+2个空行); 内容n行; 页脚(3个空行); 换页 void fileprint(FILE *fp, char *fname) { int heading(char *, int); char line[MAXLINE]; int lineno = 1; int pageno = 1; // 页头 lineno = heading(fname, pageno++); // 内容 while (fgets(line, MAXLINE, fp) != NULL) { if (lineno == 1) { fprintf(stdout, "\t"); heading(fname, pageno++); } fputs(line, stdout); if (++lineno > MAXPAGE - MAXBTM) { lineno = 1; } } fprintf(stdout, "\t"); } // 填充页头 int heading(char *fname, int pageno) { int ln = 3; fprintf(stdout, "\n\n"); fprintf(stdout, "%s page %d\n", fname, pageno); // 最后指向第6行 while (ln++ < MAXHDR) { fprintf(stdout, "\n"); } return ln; }
18.02381
60
0.490753
d9b67d79dd3c04c691396675ae0cc039a18fe9a0
2,162
c
C
sdk/bare/user/usr/beta_labs/cmd/cmd_inv.c
Severson-Group/AMDC-Firmware
3747bf33eb9f6ade5aa72d5a7d99ef1a37035d26
[ "BSD-3-Clause" ]
15
2020-01-16T14:19:10.000Z
2022-03-09T18:38:49.000Z
sdk/bare/user/usr/beta_labs/cmd/cmd_inv.c
Severson-Group/AMDC-Firmware
3747bf33eb9f6ade5aa72d5a7d99ef1a37035d26
[ "BSD-3-Clause" ]
187
2019-04-17T23:46:37.000Z
2022-03-28T22:47:44.000Z
sdk/bare/user/usr/beta_labs/cmd/cmd_inv.c
Severson-Group/AMDC-Firmware
3747bf33eb9f6ade5aa72d5a7d99ef1a37035d26
[ "BSD-3-Clause" ]
5
2019-06-27T21:43:08.000Z
2020-10-10T06:30:20.000Z
#ifdef APP_BETA_LABS #include "usr/beta_labs/cmd/cmd_inv.h" #include "sys/commands.h" #include "sys/defines.h" #include "usr/beta_labs/inverter.h" #include <stdint.h> #include <stdlib.h> #include <string.h> static command_entry_t cmd_entry; #define NUM_HELP_ENTRIES (2) static command_help_t cmd_help[NUM_HELP_ENTRIES] = { { "dtc <uDcomp> <mCurrLimit>", "Set deadtime compensation" }, { "Vdc <mVdc>", "Set Vdc" }, }; void cmd_inv_register(void) { // Populate the command entry block commands_cmd_init(&cmd_entry, "inv", "Inverter commands", cmd_help, NUM_HELP_ENTRIES, cmd_inv); // Register the command commands_cmd_register(&cmd_entry); } // // Handles the 'inv' command // and all sub-commands // int cmd_inv(int argc, char **argv) { // Handle 'dtc' sub-command if (strcmp("dtc", argv[1]) == 0) { // Check correct number of arguments if (argc != 4) return CMD_INVALID_ARGUMENTS; // Pull out uDcomp argument // and saturate to 0 .. 0.2 double uDcomp = (double) atoi(argv[2]); if (uDcomp > 200000.0) return CMD_INVALID_ARGUMENTS; if (uDcomp < 0.0) return CMD_INVALID_ARGUMENTS; // Pull out mCurrLimit argument // and saturate to 0 ... 4A double mCurrLimit = (double) atoi(argv[3]); if (mCurrLimit > 4000.0) return CMD_INVALID_ARGUMENTS; if (mCurrLimit < 0.0) return CMD_INVALID_ARGUMENTS; inverter_set_dtc(uDcomp / 1000000.0, mCurrLimit / 1000.0); return CMD_SUCCESS; } // Handle 'Vdc' sub-command if (strcmp("Vdc", argv[1]) == 0) { // Check correct number of arguments if (argc != 3) return CMD_INVALID_ARGUMENTS; // Pull out mVdc argument // and saturate to 0 .. 100V double mVdc = (double) atoi(argv[2]); if (mVdc > 100000.0) return CMD_INVALID_ARGUMENTS; if (mVdc < 0.0) return CMD_INVALID_ARGUMENTS; inverter_set_Vdc(mVdc / 1000.0); return CMD_SUCCESS; } return CMD_INVALID_ARGUMENTS; } #endif // APP_BETA_LABS
26.365854
99
0.614709
b302ae17f6949a383f102efd558cc4ff1cc57f36
2,455
h
C
Pelican/src/Pelican/Renderer/VulkanDebug.h
SeppahBaws/PelicanEngine
7bc5f5e55993220d731ad6a5dbff1470ad4c6ee5
[ "MIT" ]
1
2022-03-01T10:36:57.000Z
2022-03-01T10:36:57.000Z
Pelican/src/Pelican/Renderer/VulkanDebug.h
SeppahBaws/PelicanEngine
7bc5f5e55993220d731ad6a5dbff1470ad4c6ee5
[ "MIT" ]
1
2021-09-27T16:47:43.000Z
2021-09-27T16:47:43.000Z
Pelican/src/Pelican/Renderer/VulkanDebug.h
SeppahBaws/PelicanEngine
7bc5f5e55993220d731ad6a5dbff1470ad4c6ee5
[ "MIT" ]
null
null
null
#pragma once #include <vulkan/vulkan.hpp> #pragma warning(push, 0) #include <glm/vec4.hpp> #pragma warning(pop) namespace Pelican { namespace VkDebug { VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void*); // Load debug functions and setup debug callback void Setup(VkInstance instance); void FreeDebugCallback(VkInstance instance); } namespace VkDebugMarker { // Load the required function pointers void Setup(VkDevice device); void SetObjectName(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, const char* name); void SetObjectTag(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag); void BeginRegion(VkCommandBuffer commandBuffer, const char* markerName, const glm::vec4& color); void Insert(VkCommandBuffer commandBuffer, const char* markerName, const glm::vec4& color); void EndRegion(VkCommandBuffer commandBuffer); void SetCommandBufferName(VkDevice device, VkCommandBuffer commandBuffer, const char* name); void SetQueueName(VkDevice device, VkQueue queue, const char* name); void SetImageName(VkDevice device, VkImage image, const char* name); void SetSamplerName(VkDevice device, VkSampler sampler, const char* name); void SetBufferName(VkDevice device, VkBuffer buffer, const char* name); void SetDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char* name); void SetShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char* name); void SetPipelineName(VkDevice device, VkPipeline pipeline, const char* name); void SetPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char* name); void SetRenderPassName(VkDevice device, VkRenderPass renderPass, const char* name); void SetFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char* name); void SetDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char* name); void SetDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char* name); void SetSemaphoreName(VkDevice device, VkSemaphore semaphore, const char* name); void SetFenceName(VkDevice device, VkFence fence, const char* name); void SetEventName(VkDevice device, VkEvent _event, const char* name); } }
46.320755
141
0.804073
8c17fb5bf87891ced861c16a4c443eafacdc9278
21,986
c
C
interface/swd_host.c
huming2207/swd-esp
6de0b36d127f2f577b93400917db6784a62bde69
[ "MIT" ]
4
2021-09-18T04:28:40.000Z
2022-03-11T03:42:42.000Z
interface/swd_host.c
huming2207/swd-esp
6de0b36d127f2f577b93400917db6784a62bde69
[ "MIT" ]
null
null
null
interface/swd_host.c
huming2207/swd-esp
6de0b36d127f2f577b93400917db6784a62bde69
[ "MIT" ]
null
null
null
/** * @file swd_host.c * @brief Implementation of swd_host.h * * DAPLink Interface Firmware * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved * Copyright 2019, Cypress Semiconductor Corporation * or a subsidiary of Cypress Semiconductor Corporation. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <freertos/FreeRTOS.h> #include <freertos/task.h> #include "swd_host.h" #include "debug_cm.h" #include "DAP_config.h" #include "DAP.h" #include <esp_log.h> #define DAP_TAG "swd" // Probably not 1024 #ifndef TARGET_AUTO_INCREMENT_PAGE_SIZE #define TARGET_AUTO_INCREMENT_PAGE_SIZE (1024) #endif // Default NVIC and Core debug base addresses // TODO: Read these addresses from ROM. #define NVIC_Addr (0xe000e000) #define DBG_Addr (0xe000edf0) // AP CSW register, base value #define CSW_VALUE (CSW_RESERVED | CSW_MSTRDBG | CSW_HPROT | CSW_DBGSTAT | CSW_SADDRINC) #define DCRDR 0xE000EDF8 #define DCRSR 0xE000EDF4 #define DHCSR 0xE000EDF0 #define REGWnR (1 << 16) #define MAX_SWD_RETRY 100//10 #define MAX_TIMEOUT 10000 // Timeout for syscalls on target // Use the CMSIS-Core definition if available. #if !defined(SCB_AIRCR_PRIGROUP_Pos) #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ #endif typedef struct { uint32_t select; uint32_t csw; } DAP_STATE; typedef struct { uint32_t r[16]; uint32_t xpsr; } DEBUG_STATE; static SWD_CONNECT_TYPE reset_connect = CONNECT_NORMAL; static DAP_STATE dap_state; static uint32_t soft_reset = SYSRESETREQ; static uint32_t swd_get_apsel(uint32_t adr) { uint32_t apsel = 0; // target_get_apsel(); if (!apsel) return adr & 0xff000000; else return apsel; } void swd_set_reset_connect(SWD_CONNECT_TYPE type) { reset_connect = type; } void IRAM_ATTR int2array(uint8_t *res, uint32_t data, uint8_t len) { uint8_t i = 0; for (i = 0; i < len; i++) { res[i] = (data >> 8 * i) & 0xff; } } uint8_t IRAM_ATTR swd_transfer_retry(uint32_t req, uint32_t *data) { uint8_t i, ack; for (i = 0; i < MAX_SWD_RETRY; i++) { ack = SWD_Transfer(req, data); // if ack != WAIT if (ack != DAP_TRANSFER_WAIT) { return ack; } } return ack; } void swd_set_soft_reset(uint32_t soft_reset_type) { soft_reset = soft_reset_type; } uint8_t swd_init(void) { //TODO - DAP_Setup puts GPIO pins in a hi-z state which can // cause problems on re-init. This needs to be investigated // and fixed. DAP_Setup(); PORT_SWD_SETUP(); return 1; } uint8_t swd_off(void) { PORT_OFF(); return 1; } uint8_t IRAM_ATTR swd_clear_errors(void) { if (!swd_write_dp(DP_ABORT, STKCMPCLR | STKERRCLR | WDERRCLR | ORUNERRCLR)) { return 0; } return 1; } // Read debug port register. uint8_t IRAM_ATTR swd_read_dp(uint8_t adr, uint32_t *val) { uint32_t tmp_in; uint8_t tmp_out[4]; uint8_t ack; uint32_t tmp; tmp_in = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(adr); ack = swd_transfer_retry(tmp_in, (uint32_t *)tmp_out); *val = 0; tmp = tmp_out[3]; *val |= (tmp << 24); tmp = tmp_out[2]; *val |= (tmp << 16); tmp = tmp_out[1]; *val |= (tmp << 8); tmp = tmp_out[0]; *val |= (tmp << 0); return (ack == 0x01); } // Write debug port register uint8_t IRAM_ATTR swd_write_dp(uint8_t adr, uint32_t val) { uint32_t req; uint8_t data[4]; uint8_t ack; //check if the right bank is already selected if ((adr == DP_SELECT) && (dap_state.select == val)) { return 1; } req = SWD_REG_DP | SWD_REG_W | SWD_REG_ADR(adr); int2array(data, val, 4); ack = swd_transfer_retry(req, (uint32_t *)data); if ((ack == DAP_TRANSFER_OK) && (adr == DP_SELECT)) { dap_state.select = val; } return (ack == 0x01); } // Read access port register. uint8_t IRAM_ATTR swd_read_ap(uint32_t adr, uint32_t *val) { uint8_t tmp_in, ack; uint8_t tmp_out[4]; uint32_t tmp; uint32_t apsel = swd_get_apsel(adr); uint32_t bank_sel = adr & APBANKSEL; if (!swd_write_dp(DP_SELECT, apsel | bank_sel)) { return 0; } tmp_in = SWD_REG_AP | SWD_REG_R | SWD_REG_ADR(adr); // first dummy read swd_transfer_retry(tmp_in, (uint32_t *)tmp_out); ack = swd_transfer_retry(tmp_in, (uint32_t *)tmp_out); *val = 0; tmp = tmp_out[3]; *val |= (tmp << 24); tmp = tmp_out[2]; *val |= (tmp << 16); tmp = tmp_out[1]; *val |= (tmp << 8); tmp = tmp_out[0]; *val |= (tmp << 0); return (ack == 0x01); } // Write access port register uint8_t IRAM_ATTR swd_write_ap(uint32_t adr, uint32_t val) { uint8_t data[4]; uint8_t req, ack; uint32_t apsel = swd_get_apsel(adr); uint32_t bank_sel = adr & APBANKSEL; if (!swd_write_dp(DP_SELECT, apsel | bank_sel)) { return 0; } switch (adr) { case AP_CSW: if (dap_state.csw == val) { return 1; } dap_state.csw = val; break; default: break; } req = SWD_REG_AP | SWD_REG_W | SWD_REG_ADR(adr); int2array(data, val, 4); if (swd_transfer_retry(req, (uint32_t *)data) != 0x01) { return 0; } req = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(DP_RDBUFF); ack = swd_transfer_retry(req, NULL); return (ack == 0x01); } // Write 32-bit word aligned values to target memory using address auto-increment. // size is in bytes. static IRAM_ATTR uint8_t swd_write_block(uint32_t address, uint8_t *data, uint32_t size) { uint8_t tmp_in[4], req; uint32_t size_in_words; uint32_t i, ack; if (size == 0) { return 0; } size_in_words = size / 4; // CSW register if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE32)) { return 0; } // TAR write req = SWD_REG_AP | SWD_REG_W | (1 << 2); int2array(tmp_in, address, 4); if (swd_transfer_retry(req, (uint32_t *)tmp_in) != 0x01) { return 0; } // DRW write req = SWD_REG_AP | SWD_REG_W | (3 << 2); for (i = 0; i < size_in_words; i++) { if (swd_transfer_retry(req, (uint32_t *)data) != 0x01) { return 0; } data += 4; } // dummy read req = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(DP_RDBUFF); ack = swd_transfer_retry(req, NULL); return (ack == 0x01); } // Read 32-bit word aligned values from target memory using address auto-increment. // size is in bytes. static uint8_t IRAM_ATTR swd_read_block(uint32_t address, uint8_t *data, uint32_t size) { uint8_t tmp_in[4], req, ack; uint32_t size_in_words; uint32_t i; if (size == 0) { return 0; } size_in_words = size / 4; if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE32)) { return 0; } // TAR write req = SWD_REG_AP | SWD_REG_W | AP_TAR; int2array(tmp_in, address, 4); if (swd_transfer_retry(req, (uint32_t *)tmp_in) != DAP_TRANSFER_OK) { return 0; } // read data req = SWD_REG_AP | SWD_REG_R | AP_DRW; // initiate first read, data comes back in next read if (swd_transfer_retry(req, NULL) != 0x01) { return 0; } for (i = 0; i < (size_in_words - 1); i++) { if (swd_transfer_retry(req, (uint32_t *)data) != DAP_TRANSFER_OK) { return 0; } data += 4; } // read last word req = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(DP_RDBUFF); ack = swd_transfer_retry(req, (uint32_t *)data); return (ack == 0x01); } // Read target memory. static uint8_t IRAM_ATTR swd_read_data(uint32_t addr, uint32_t *val) { uint8_t tmp_in[4]; uint8_t tmp_out[4]; uint8_t req, ack; uint32_t tmp; // put addr in TAR register int2array(tmp_in, addr, 4); req = SWD_REG_AP | SWD_REG_W | (1 << 2); if (swd_transfer_retry(req, (uint32_t *)tmp_in) != 0x01) { return 0; } // read data req = SWD_REG_AP | SWD_REG_R | (3 << 2); if (swd_transfer_retry(req, (uint32_t *)tmp_out) != 0x01) { return 0; } // dummy read req = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(DP_RDBUFF); ack = swd_transfer_retry(req, (uint32_t *)tmp_out); *val = 0; tmp = tmp_out[3]; *val |= (tmp << 24); tmp = tmp_out[2]; *val |= (tmp << 16); tmp = tmp_out[1]; *val |= (tmp << 8); tmp = tmp_out[0]; *val |= (tmp << 0); return (ack == 0x01); } // Write target memory. static uint8_t IRAM_ATTR swd_write_data(uint32_t address, uint32_t data) { uint8_t tmp_in[4]; uint8_t req, ack; // put addr in TAR register int2array(tmp_in, address, 4); req = SWD_REG_AP | SWD_REG_W | (1 << 2); if (swd_transfer_retry(req, (uint32_t *)tmp_in) != 0x01) { return 0; } // write data int2array(tmp_in, data, 4); req = SWD_REG_AP | SWD_REG_W | (3 << 2); if (swd_transfer_retry(req, (uint32_t *)tmp_in) != 0x01) { return 0; } // dummy read req = SWD_REG_DP | SWD_REG_R | SWD_REG_ADR(DP_RDBUFF); ack = swd_transfer_retry(req, NULL); return (ack == 0x01) ? 1 : 0; } // Read 32-bit word from target memory. uint8_t IRAM_ATTR swd_read_word(uint32_t addr, uint32_t *val) { if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE32)) { return 0; } if (!swd_read_data(addr, val)) { return 0; } return 1; } // Write 32-bit word to target memory. uint8_t IRAM_ATTR swd_write_word(uint32_t addr, uint32_t val) { if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE32)) { return 0; } if (!swd_write_data(addr, val)) { return 0; } return 1; } // Read 8-bit byte from target memory. uint8_t IRAM_ATTR swd_read_byte(uint32_t addr, uint8_t *val) { uint32_t tmp; if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE8)) { return 0; } if (!swd_read_data(addr, &tmp)) { return 0; } *val = (uint8_t)(tmp >> ((addr & 0x03) << 3)); return 1; } // Write 8-bit byte to target memory. uint8_t IRAM_ATTR swd_write_byte(uint32_t addr, uint8_t val) { uint32_t tmp; if (!swd_write_ap(AP_CSW, CSW_VALUE | CSW_SIZE8)) { return 0; } tmp = val << ((addr & 0x03) << 3); if (!swd_write_data(addr, tmp)) { return 0; } return 1; } // Read unaligned data from target memory. // size is in bytes. uint8_t IRAM_ATTR swd_read_memory(uint32_t address, uint8_t *data, uint32_t size) { uint32_t n; // Read bytes until word aligned while ((size > 0) && (address & 0x3)) { if (!swd_read_byte(address, data)) { return 0; } address++; data++; size--; } // Read word aligned blocks while (size > 3) { // Limit to auto increment page size n = TARGET_AUTO_INCREMENT_PAGE_SIZE - (address & (TARGET_AUTO_INCREMENT_PAGE_SIZE - 1)); if (size < n) { n = size & 0xFFFFFFFC; // Only count complete words remaining } if (!swd_read_block(address, data, n)) { return 0; } address += n; data += n; size -= n; } // Read remaining bytes while (size > 0) { if (!swd_read_byte(address, data)) { return 0; } address++; data++; size--; } return 1; } // Write unaligned data to target memory. // size is in bytes. uint8_t IRAM_ATTR swd_write_memory(uint32_t address, uint8_t *data, uint32_t size) { uint32_t n = 0; // Write bytes until word aligned while ((size > 0) && (address & 0x3)) { if (!swd_write_byte(address, *data)) { return 0; } address++; data++; size--; } // Write word aligned blocks while (size > 3) { // Limit to auto increment page size n = TARGET_AUTO_INCREMENT_PAGE_SIZE - (address & (TARGET_AUTO_INCREMENT_PAGE_SIZE - 1)); if (size < n) { n = size & 0xFFFFFFFC; // Only count complete words remaining } if (!swd_write_block(address, data, n)) { return 0; } address += n; data += n; size -= n; } // Write remaining bytes while (size > 0) { if (!swd_write_byte(address, *data)) { return 0; } address++; data++; size--; } return 1; } // Execute system call. static uint8_t IRAM_ATTR swd_write_debug_state(DEBUG_STATE *state) { uint32_t i, status; if (!swd_write_dp(DP_SELECT, 0)) { return 0; } // R0, R1, R2, R3 for (i = 0; i < 4; i++) { if (!swd_write_core_register(i, state->r[i])) { ESP_LOGE(DAP_TAG, "Failed to set R0-3"); return 0; } } // R9 if (!swd_write_core_register(9, state->r[9])) { ESP_LOGE(DAP_TAG, "Failed to set R9"); return 0; } // R13, R14, R15 for (i = 13; i < 16; i++) { if (!swd_write_core_register(i, state->r[i])) { ESP_LOGE(DAP_TAG, "Failed to set R13-15"); return 0; } } // xPSR if (!swd_write_core_register(16, state->xpsr)) { ESP_LOGE(DAP_TAG, "Failed to set xPSR"); return 0; } if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS | C_HALT)) { ESP_LOGE(DAP_TAG, "Failed to set halt"); return 0; } if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_MASKINTS)) { ESP_LOGE(DAP_TAG, "Failed to set unhalt"); return 0; } // check status if (!swd_read_dp(DP_CTRL_STAT, &status)) { ESP_LOGE(DAP_TAG, "Failed to check status"); return 0; } if (status & (STICKYERR | WDATAERR)) { ESP_LOGE(DAP_TAG, "Status has error"); return 0; } return 1; } uint8_t IRAM_ATTR swd_read_core_register(uint32_t n, uint32_t *val) { int i = 0, timeout = 100; if (!swd_write_word(DCRSR, n)) { return 0; } // wait for S_REGRDY for (i = 0; i < timeout; i++) { if (!swd_read_word(DHCSR, val)) { return 0; } if (*val & S_REGRDY) { break; } } if (i == timeout) { ESP_LOGE(DAP_TAG, "Timeout"); return 0; } if (!swd_read_word(DCRDR, val)) { return 0; } return 1; } uint8_t IRAM_ATTR swd_write_core_register(uint32_t n, uint32_t val) { int i = 0, timeout = 100; if (!swd_write_word(DCRDR, val)) { return 0; } if (!swd_write_word(DCRSR, n | REGWnR)) { return 0; } // wait for S_REGRDY for (i = 0; i < timeout; i++) { if (!swd_read_word(DHCSR, &val)) { return 0; } if (val & S_REGRDY) { return 1; } } ESP_LOGE(DAP_TAG, "Core timeout"); return 0; } uint8_t IRAM_ATTR swd_wait_until_halted(void) { // Wait for target to stop uint32_t val, i, timeout = MAX_TIMEOUT; for (i = 0; i < timeout; i++) { if (!swd_read_word(DBG_HCSR, &val)) { return 0; } if (val & S_HALT) { return 1; } } return 0; } uint8_t IRAM_ATTR swd_flash_syscall_exec(const program_syscall_t *sysCallParam, uint32_t entry, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, flash_algo_return_t return_type) { DEBUG_STATE state = {{0}, 0}; // Call flash algorithm function on target and wait for result. state.r[0] = arg1; // R0: Argument 1 state.r[1] = arg2; // R1: Argument 2 state.r[2] = arg3; // R2: Argument 3 state.r[3] = arg4; // R3: Argument 4 state.r[9] = sysCallParam->static_base; // SB: Static Base state.r[13] = sysCallParam->stack_pointer; // SP: Stack Pointer state.r[14] = sysCallParam->breakpoint; // LR: Exit Point state.r[15] = entry; // PC: Entry Point state.xpsr = 0x01000000; // xPSR: T = 1, ISR = 0 if (!swd_write_debug_state(&state)) { ESP_LOGE(DAP_TAG, "Failed to set state"); return 0; } if (!swd_wait_until_halted()) { ESP_LOGE(DAP_TAG, "Failed to halt"); return 0; } if (!swd_read_core_register(0, &state.r[0])) { ESP_LOGE(DAP_TAG, "Failed to read register"); return 0; } //remove the C_MASKINTS if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_HALT)) { ESP_LOGE(DAP_TAG, "Failed to halt again"); return 0; } if ( return_type == FLASHALGO_RETURN_POINTER ) { // Flash verify functions return pointer to byte following the buffer if successful. if (state.r[0] != (arg1 + arg2)) { return 0; } } else { // ESP_LOGW(DAP_TAG, "R0 = %d", state.r[0]); // // uint32_t r1 = 0; // swd_read_core_register(1, &r1); // // uint32_t r2 = 0; // swd_read_core_register(2, &r2); // // uint32_t r15 = 0; // swd_read_core_register(15, &r15); // ESP_LOGW(DAP_TAG, "R1 = 0x%x, R2 = 0x%x, R15 (PC) = 0x%x", r1, r2, r15); if (state.r[0] != 0) { uint32_t r1 = 0; swd_read_core_register(1, &r1); uint32_t r2 = 0; swd_read_core_register(2, &r2); uint32_t r15 = 0; swd_read_core_register(15, &r15); ESP_LOGW(DAP_TAG, "R1 = 0x%x, R2 = 0x%x, R15 (PC) = 0x%x", r1, r2, r15); return 0; } } return 1; } // SWD Reset static uint8_t IRAM_ATTR swd_reset(void) { uint8_t tmp_in[8]; uint8_t i = 0; for (i = 0; i < 8; i++) { tmp_in[i] = 0xff; } SWJ_Sequence(51, tmp_in); return 1; } // SWD Switch static uint8_t IRAM_ATTR swd_switch(uint16_t val) { uint8_t tmp_in[2]; tmp_in[0] = val & 0xff; tmp_in[1] = (val >> 8) & 0xff; SWJ_Sequence(16, tmp_in); return 1; } // SWD Read ID uint8_t IRAM_ATTR swd_read_idcode(uint32_t *id) { uint8_t tmp_in[1]; uint8_t tmp_out[4]; tmp_in[0] = 0x00; SWJ_Sequence(8, tmp_in); if (swd_read_dp(0, (uint32_t *)tmp_out) != 0x01) { return 0; } *id = (tmp_out[3] << 24) | (tmp_out[2] << 16) | (tmp_out[1] << 8) | tmp_out[0]; return 1; } uint8_t IRAM_ATTR JTAG2SWD() { uint32_t tmp = 0; if (!swd_reset()) { return 0; } if (!swd_switch(0xE79E)) { return 0; } if (!swd_reset()) { return 0; } if (!swd_read_idcode(&tmp)) { ESP_LOGE(DAP_TAG, "Set transit fail"); return 0; } return 1; } uint8_t swd_init_debug(void) { uint32_t tmp = 0; int i = 0; int timeout = 100; // init dap state with fake values dap_state.select = 0xffffffff; dap_state.csw = 0xffffffff; PIN_nRESET_OUT(0); vTaskDelay(pdMS_TO_TICKS(10)); PIN_nRESET_OUT(1); vTaskDelay(pdMS_TO_TICKS(10)); int8_t retries = 4; int8_t do_abort = 0; do { if (do_abort) { //do an abort on stale target, then reset the device swd_write_dp(DP_ABORT, DAPABORT); PIN_nRESET_OUT(0); vTaskDelay(pdMS_TO_TICKS(10)); PIN_nRESET_OUT(1); vTaskDelay(pdMS_TO_TICKS(10)); do_abort = 0; } swd_init(); if (!JTAG2SWD()) { ESP_LOGE(DAP_TAG, "JTAG2SWD fail"); do_abort = 1; continue; } if (!swd_clear_errors()) { ESP_LOGE(DAP_TAG, "Clear error fail"); do_abort = 1; continue; } if (!swd_write_dp(DP_SELECT, 0)) { ESP_LOGE(DAP_TAG, "SELECT DP fail"); do_abort = 1; continue; } // Power up if (!swd_write_dp(DP_CTRL_STAT, CSYSPWRUPREQ | CDBGPWRUPREQ)) { ESP_LOGE(DAP_TAG, "Power up fail"); do_abort = 1; continue; } for (i = 0; i < timeout; i++) { if (!swd_read_dp(DP_CTRL_STAT, &tmp)) { ESP_LOGE(DAP_TAG, "DP_CTRL_STAT fail"); do_abort = 1; break; } if ((tmp & (CDBGPWRUPACK | CSYSPWRUPACK)) == (CDBGPWRUPACK | CSYSPWRUPACK)) { // Break from loop if powerup is complete break; } } if ((i == timeout) || (do_abort == 1)) { // Unable to powerup DP ESP_LOGE(DAP_TAG, "Unable to powerup DP"); do_abort = 1; continue; } if (!swd_write_dp(DP_CTRL_STAT, CSYSPWRUPREQ | CDBGPWRUPREQ | TRNNORMAL | MASKLANE)) { ESP_LOGE(DAP_TAG, "Set transit fail"); do_abort = 1; continue; } if (!swd_write_dp(DP_SELECT, 0)) { ESP_LOGE(DAP_TAG, "Unselect DP fail"); do_abort = 1; continue; } return 1; } while (--retries > 0); return 0; } uint8_t IRAM_ATTR swd_halt_target() { if (!swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_HALT)) { return 0; } return 1; }
23.143158
188
0.568817
8c7000f969e5a1ca9286f22a63a4d859b08805c7
10,589
c
C
release/src-ra-4300/linux/linux-2.6.36.x/drivers/net/cryptoDriver/source/utils/mtk_ringHelper.c
zhoutao0712/rtn11pb1
09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05
[ "Apache-2.0" ]
1
2022-03-19T06:38:01.000Z
2022-03-19T06:38:01.000Z
release/src-ra-4300/linux/linux-2.6.36.x/drivers/net/cryptoDriver/source/utils/mtk_ringHelper.c
zhoutao0712/rtn11pb1
09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05
[ "Apache-2.0" ]
null
null
null
release/src-ra-4300/linux/linux-2.6.36.x/drivers/net/cryptoDriver/source/utils/mtk_ringHelper.c
zhoutao0712/rtn11pb1
09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05
[ "Apache-2.0" ]
1
2022-03-19T06:38:03.000Z
2022-03-19T06:38:03.000Z
#include "mtk_baseDefs.h" // bool, MIN #include "mtk_ring.h" #include "mtk_cLib.h" // memset /*---------------------------------------------------------------------------- * RingHelper_Init * * This routine must be called once to initialize the administration block * related to a ring. * * See header file for function specification. */ int RingHelper_Init( RingHelper_t * const Ring_p, const RingHelper_CallbackInterface_t * const CallbackIF_p, const bool fSeparateRings, const unsigned int CommandRing_MaxDescriptors, const unsigned int ResultRing_MaxDescriptors) { if (Ring_p == NULL || CallbackIF_p == NULL || CommandRing_MaxDescriptors < 1) { // invalid argument return -1; } if (fSeparateRings) { if (ResultRing_MaxDescriptors < 1) { // invalid arguments return -1; } } if (CallbackIF_p->ReadFunc_p == NULL || CallbackIF_p->WriteFunc_p == NULL || CallbackIF_p->StatusFunc_p == NULL) { return -1; } // initialize the ring admin data structure memset(Ring_p, 0, sizeof(RingHelper_t)); Ring_p->CB = *CallbackIF_p; Ring_p->fSupportsDeviceReadPos = true; // initial assumption Ring_p->IN_Size = CommandRing_MaxDescriptors; if (fSeparateRings) { // separate rings Ring_p->fSeparate = true; Ring_p->OUT_Size = ResultRing_MaxDescriptors; } else { // combined rings Ring_p->fSeparate = false; Ring_p->OUT_Size = CommandRing_MaxDescriptors; } return 0; // success } /*---------------------------------------------------------------------------- * RingHelper_Put * * This function tries to add a number of descriptors to the command ring * specified. * * See header file for function specification. */ int RingHelper_Put( RingHelper_t * const Ring_p, const void * Descriptors_p, const int DescriptorCount) { int A, N, W1, W2; if (Ring_p == NULL || Descriptors_p == NULL || DescriptorCount < 0) { return -1; } if (DescriptorCount == 0) return 0; W1 = W2 = 0; // out of the descriptors provided, calculate the maximum number of // descriptors that can be written sequentially before the ring is full. if (Ring_p->fSeparate) { // separate rings // ask how far the device has processed the ring // we do this on every call and do not cache the result int DeviceReadHead = -1; // not supported if (Ring_p->fSupportsDeviceReadPos) { int res; //read PE_RING_PNTR for CmdRing and store it in DeviceReadHead --Trey res = Ring_p->CB.StatusFunc_p( //EIP93_StatusCB() Ring_p->CB.CallbackParam1_p, //IOArea_p Ring_p->CB.CallbackParam2, //0 &DeviceReadHead); if (res < 0) return res; // ## RETURN ## // suppress these calls if the device does not support it if (DeviceReadHead < 0) Ring_p->fSupportsDeviceReadPos = false; } if (DeviceReadHead < 0) { // device does not expose its read position // this means we cannot calculate how much space is available // the WriteFunc will have to check, descriptor by descriptor A = Ring_p->IN_Size; // note: under this condition we rely on the implementation of // the callback interface to handle ring-full condition and not // overwrite existing descriptors. Because of this, we can // fill the ring to the limit and do not have to keep 1 free // position as done below. } else { unsigned int Device_IN_Head = (unsigned int)DeviceReadHead; // based on the device read position we can calculate // how many positions in the ring are free if (Ring_p->IN_Tail < Device_IN_Head) { // we have wrapped around // available space is between the two A = Device_IN_Head - Ring_p->IN_Tail; } else { // used positions are between the two pointers // rest is free A = Ring_p->IN_Size - (Ring_p->IN_Tail - Device_IN_Head); } // avoid filling the entire ring // so we can differentiate full from empty if (A != 0) A--; } } else { // combined rings // Critical: we have to be careful not to read the OUT_Head more // than one, since it might change in between! unsigned int OUT_Head_copy = Ring_p->OUT_Head; // we can write descriptors up to the point where we expect the // result descriptors if (Ring_p->IN_Tail < OUT_Head_copy) { // used positions are around the wrap point // free positions are between the pointers A = OUT_Head_copy - Ring_p->IN_Tail; } else { // used positions are between the two pointers // rest is free A = Ring_p->IN_Size - (Ring_p->IN_Tail - OUT_Head_copy); } // avoid filling the entire ring // so we can differentiate full from empty // (when it contains all commands or all results) if (A != 0) A--; } // limit based on provided descriptors A = MIN(A, DescriptorCount); // limit for sequential writing N = MIN(A, (int)(Ring_p->IN_Size - Ring_p->IN_Tail)); // bail out early if there is no space if (N == 0) { return 0; // ## RETURN ## } W1 = Ring_p->CB.WriteFunc_p( //EIP93_WriteCB in eip93_arm.c Ring_p->CB.CallbackParam1_p, Ring_p->CB.CallbackParam2, /*WriteIndex:*/Ring_p->IN_Tail, /*WriteCount:*/N, /*AvailableSpace*/A, Descriptors_p, DescriptorCount, /*SkipCount:*/0); if (W1 <= 0) { // 0: no descriptors could be added // <0: failure return W1; // ## RETURN ## } if (W1 == N && W1 < DescriptorCount && A > N) { // we have written all possible positions up to the end of the ring // now write the rest N = A - N; W2 = Ring_p->CB.WriteFunc_p( Ring_p->CB.CallbackParam1_p, Ring_p->CB.CallbackParam2, /*WriteIndex:*/0, /*WriteCount:*/N, /*AvailableSpace*/N, Descriptors_p, DescriptorCount, /*SkipCount:*/W1); if (W2 < 0) { // failure return W2; // ## RETURN ## } } // now update the position for the next write { unsigned int i = Ring_p->IN_Tail + W1 + W2; // do not use % operator to avoid costly divisions if (i >= Ring_p->IN_Size) i -= Ring_p->IN_Size; Ring_p->IN_Tail = i; } // return how many descriptors were added return W1 + W2; } /*---------------------------------------------------------------------------- * RingHelper_Get * * This routine retrieves a number of descriptors from the result ring * specified. * * See header file for function specification. */ int RingHelper_Get( RingHelper_t * const Ring_p, const int ReadyCount, void * Descriptors_p, const int DescriptorsLimit) { int A, N; int R1, R2; R1 = R2 = 0; if (Ring_p == NULL || Descriptors_p == NULL || DescriptorsLimit < 0) { return -1; } if (DescriptorsLimit == 0 || ReadyCount == 0) { // no space in output buffer // or no descriptors ready return 0; } // calculate the maximum number of descriptors that can be retrieved // sequentially from this read position, taking into account the // DescriptorsLimit and the ReadyCount (if available) // A = entries in result ring from read position till end A = Ring_p->OUT_Size - Ring_p->OUT_Head; N = MIN(A, DescriptorsLimit); if (ReadyCount > 0) N = MIN(N, ReadyCount); // now retrieve this number of descriptors R1 = Ring_p->CB.ReadFunc_p( //EIP93_ReadCB Ring_p->CB.CallbackParam1_p, Ring_p->CB.CallbackParam2, /*ReadIndex:*/Ring_p->OUT_Head, /*ReadLimit:*/N, Descriptors_p, /*SkipCount:*/0); if (R1 <= 0) { // 0: if we got nothing on the first call, we can stop here // <0: error while reading // this means we cannot maintain read synchronization return R1; // ## RETURN ## } // if we got the maximum, we can try to read more // after wrapping to the start of the buffer if (R1 == N && R1 < DescriptorsLimit && R1 != ReadyCount) { // A = number of entries in ring up to previous read-start position A = Ring_p->OUT_Head; N = MIN(A, DescriptorsLimit - R1); if (ReadyCount > 0) N = MIN(N, ReadyCount - R1); R2 = Ring_p->CB.ReadFunc_p( Ring_p->CB.CallbackParam1_p, Ring_p->CB.CallbackParam2, /*ReadIndex:*/0, // start of buffer /*ReadLimit:*/N, Descriptors_p, /*SkipCount:*/R1); if (R2 < 0) { // failure return R2; // ## RETURN ## } } // now update the position for the next read { unsigned int i = Ring_p->OUT_Head + R1 + R2; // do not use % operator to avoid costly divisions if (i >= Ring_p->OUT_Size) i -= Ring_p->OUT_Size; Ring_p->OUT_Head = i; } // return the number of descriptors read return R1 + R2; }
28.38874
78
0.51393
1e72480ae6877fe5577ed48fe28f2cf12e9a131f
4,813
h
C
firmware/prototype - final/firmware/src/system_config/default/framework/peripheral/can/templates/can_FilterToChannelLink_pic32.h
mzeitler/openstrom
ba52e85ef11778a61a38577803dd9ffa8619434f
[ "MIT" ]
19
2016-02-22T00:43:05.000Z
2020-12-14T06:14:10.000Z
firmware/prototype - final/firmware/src/system_config/default/framework/peripheral/can/templates/can_FilterToChannelLink_pic32.h
mzeitler/openstrom
ba52e85ef11778a61a38577803dd9ffa8619434f
[ "MIT" ]
null
null
null
firmware/prototype - final/firmware/src/system_config/default/framework/peripheral/can/templates/can_FilterToChannelLink_pic32.h
mzeitler/openstrom
ba52e85ef11778a61a38577803dd9ffa8619434f
[ "MIT" ]
3
2016-06-30T12:37:47.000Z
2020-10-14T06:28:56.000Z
/******************************************************************************* CAN Peripheral Library Template Implementation File Name: can_FilterToChannelLink_pic32.h Summary: CAN PLIB Template Implementation Description: This header file contains template implementations For Feature : FilterToChannelLink and its Variant : pic32 For following APIs : PLIB_CAN_FilterToChannelLink PLIB_CAN_ExistsFilterToChannelLink *******************************************************************************/ //DOM-IGNORE-BEGIN /******************************************************************************* Copyright (c) 2012 released Microchip Technology Inc. All rights reserved. Microchip licenses to you the right to use, modify, copy and distribute Software only when embedded on a Microchip microcontroller or digital signal controller that is integrated into your product or third party product (pursuant to the sublicense terms in the accompanying license agreement). You should refer to the license agreement accompanying this Software for additional information regarding your rights and obligations. SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. *******************************************************************************/ //DOM-IGNORE-END #ifndef _CAN_FILTERTOCHANNELLINK_PIC32_H #define _CAN_FILTERTOCHANNELLINK_PIC32_H #include "../templates/can_registers.h" //****************************************************************************** /* Function : CAN_FilterToChannelLink_pic32 Summary: Implements pic32 variant of PLIB_CAN_FilterToChannelLink Description: This template implements the pic32 variant of the PLIB_CAN_FilterToChannelLink function. */ PLIB_TEMPLATE void CAN_FilterToChannelLink_pic32( CAN_MODULE_ID index , CAN_FILTER filter , CAN_FILTER_MASK mask , CAN_CHANNEL channel ) { volatile can_registers_t * can = ((can_registers_t *)(index)); /* There are 32 filters in total and 8 H/W registers having 4 filters each */ /* This function will link a filter to a channel. FLTCONx is the filter control register that is associated with the filter and sub offset provides the shift amount with in the filter control register. The filter control register has four bytes each controlling a filter. The contents of the other filter fields should not be changed. */ uint32_t filterRegIndex = filter >> 2; uint32_t filterOffSet = filter % 4; uint32_t filterRegValue = 0; uint32_t filterRegMask = 0; uint32_t maskSelPosition = 0, filterSelPosition = 0; filterRegMask = ( (_C1FLTCON0_MSEL0_MASK | _C1FLTCON0_FSEL0_MASK) << (filterOffSet * 8) ); maskSelPosition = ( _C1FLTCON0_MSEL0_POSITION + (filterOffSet * 8) ); filterSelPosition = ( _C1FLTCON0_FSEL0_POSITION + (filterOffSet * 8) ); /* Get the value of the filter register containing the selected filter */ filterRegValue = can->CFLTCON[filterRegIndex].CFLTCON0.w; /* Clear the selected filter FSEL and MSEL fields initially */ filterRegValue &= (~filterRegMask); /* Write selected FSEL and MSEL values for the filter */ filterRegValue |= ( ((mask << maskSelPosition) | (channel << filterSelPosition)) & filterRegMask ); /* Finally write the 32-bit filter register value that updates only * FSEL and MSEL of the selected filter */ can->CFLTCON[filterRegIndex].CFLTCON0.w = filterRegValue; } //****************************************************************************** /* Function : CAN_ExistsFilterToChannelLink_pic32 Summary: Implements pic32 variant of PLIB_CAN_ExistsFilterToChannelLink Description: This template implements the pic32 variant of the PLIB_CAN_ExistsFilterToChannelLink function. */ #define PLIB_CAN_ExistsFilterToChannelLink PLIB_CAN_ExistsFilterToChannelLink PLIB_TEMPLATE bool CAN_ExistsFilterToChannelLink_pic32( CAN_MODULE_ID index ) { return true; } #endif /*_CAN_FILTERTOCHANNELLINK_PIC32_H*/ /****************************************************************************** End of File */
40.445378
136
0.682942
f005a2a4c0d4d02f0f429c5b866aca949de0b9c3
33,579
c
C
gnu/gcc/gcc/config/vax/vax.c
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
105
2015-03-02T16:58:34.000Z
2022-03-28T07:17:49.000Z
gnu/gcc/gcc/config/vax/vax.c
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
145
2015-03-18T10:08:17.000Z
2022-03-31T01:27:08.000Z
gnu/gcc/gcc/config/vax/vax.c
ArrogantWombatics/openbsd-src
75721e1d44322953075b7c4b89337b163a395291
[ "BSD-3-Clause" ]
26
2015-10-10T09:37:44.000Z
2022-02-23T02:02:05.000Z
/* Subroutines for insn-output.c for VAX. Copyright (C) 1987, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 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 2, 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 COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "rtl.h" #include "tree.h" #include "regs.h" #include "hard-reg-set.h" #include "real.h" #include "insn-config.h" #include "conditions.h" #include "function.h" #include "output.h" #include "insn-attr.h" #include "recog.h" #include "expr.h" #include "optabs.h" #include "flags.h" #include "debug.h" #include "toplev.h" #include "tm_p.h" #include "target.h" #include "target-def.h" static void vax_output_function_prologue (FILE *, HOST_WIDE_INT); static void vax_file_start (void); static void vax_init_libfuncs (void); static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static int vax_address_cost_1 (rtx); static int vax_address_cost (rtx); static bool vax_rtx_costs (rtx, int, int, int *); static rtx vax_struct_value_rtx (tree, int); /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t" #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue #undef TARGET_ASM_FILE_START #define TARGET_ASM_FILE_START vax_file_start #undef TARGET_ASM_FILE_START_APP_OFF #define TARGET_ASM_FILE_START_APP_OFF true #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS vax_init_libfuncs #undef TARGET_ASM_OUTPUT_MI_THUNK #define TARGET_ASM_OUTPUT_MI_THUNK vax_output_mi_thunk #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS vax_rtx_costs #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST vax_address_cost #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true #undef TARGET_STRUCT_VALUE_RTX #define TARGET_STRUCT_VALUE_RTX vax_struct_value_rtx struct gcc_target targetm = TARGET_INITIALIZER; /* Set global variables as needed for the options enabled. */ void override_options (void) { /* We're VAX floating point, not IEEE floating point. */ if (TARGET_G_FLOAT) REAL_MODE_FORMAT (DFmode) = &vax_g_format; } /* Generate the assembly code for function entry. FILE is a stdio stream to output the code to. SIZE is an int: how many units of temporary storage to allocate. Refer to the array `regs_ever_live' to determine which registers to save; `regs_ever_live[I]' is nonzero if register number I is ever used in the function. This function is responsible for knowing which registers should not be saved even if used. */ static void vax_output_function_prologue (FILE * file, HOST_WIDE_INT size) { int regno; int mask = 0; for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (regs_ever_live[regno] && !call_used_regs[regno]) mask |= 1 << regno; fprintf (file, "\t.word 0x%x\n", mask); if (dwarf2out_do_frame ()) { const char *label = dwarf2out_cfi_label (); int offset = 0; for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno) if (regs_ever_live[regno] && !call_used_regs[regno]) dwarf2out_reg_save (label, regno, offset -= 4); dwarf2out_reg_save (label, PC_REGNUM, offset -= 4); dwarf2out_reg_save (label, FRAME_POINTER_REGNUM, offset -= 4); dwarf2out_reg_save (label, ARG_POINTER_REGNUM, offset -= 4); dwarf2out_def_cfa (label, FRAME_POINTER_REGNUM, -(offset - 4)); } size -= STARTING_FRAME_OFFSET; if (size >= 64) asm_fprintf (file, "\tmovab %wd(%Rsp),%Rsp\n", -size); else if (size) asm_fprintf (file, "\tsubl2 $%wd,%Rsp\n", size); } /* When debugging with stabs, we want to output an extra dummy label so that gas can distinguish between D_float and G_float prior to processing the .stabs directive identifying type double. */ static void vax_file_start (void) { default_file_start (); if (write_symbols == DBX_DEBUG) fprintf (asm_out_file, "___vax_%c_doubles:\n", ASM_DOUBLE_CHAR); } /* We can use the BSD C library routines for the libgcc calls that are still generated, since that's what they boil down to anyways. When ELF, avoid the user's namespace. */ static void vax_init_libfuncs (void) { set_optab_libfunc (udiv_optab, SImode, TARGET_ELF ? "*__udiv" : "*udiv"); set_optab_libfunc (umod_optab, SImode, TARGET_ELF ? "*__urem" : "*urem"); } /* This is like nonimmediate_operand with a restriction on the type of MEM. */ void split_quadword_operands (rtx * operands, rtx * low, int n ATTRIBUTE_UNUSED) { int i; /* Split operands. */ low[0] = low[1] = low[2] = 0; for (i = 0; i < 3; i++) { if (low[i]) /* it's already been figured out */; else if (MEM_P (operands[i]) && (GET_CODE (XEXP (operands[i], 0)) == POST_INC)) { rtx addr = XEXP (operands[i], 0); operands[i] = low[i] = gen_rtx_MEM (SImode, addr); if (which_alternative == 0 && i == 0) { addr = XEXP (operands[i], 0); operands[i+1] = low[i+1] = gen_rtx_MEM (SImode, addr); } } else { low[i] = operand_subword (operands[i], 0, 0, DImode); operands[i] = operand_subword (operands[i], 1, 0, DImode); } } } void print_operand_address (FILE * file, rtx addr) { rtx reg1, breg, ireg; rtx offset; retry: switch (GET_CODE (addr)) { case MEM: fprintf (file, "*"); addr = XEXP (addr, 0); goto retry; case REG: fprintf (file, "(%s)", reg_names[REGNO (addr)]); break; case PRE_DEC: fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]); break; case POST_INC: fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]); break; case PLUS: /* There can be either two or three things added here. One must be a REG. One can be either a REG or a MULT of a REG and an appropriate constant, and the third can only be a constant or a MEM. We get these two or three things and put the constant or MEM in OFFSET, the MULT or REG in IREG, and the REG in BREG. If we have a register and can't tell yet if it is a base or index register, put it into REG1. */ reg1 = 0; ireg = 0; breg = 0; offset = 0; if (CONSTANT_ADDRESS_P (XEXP (addr, 0)) || MEM_P (XEXP (addr, 0))) { offset = XEXP (addr, 0); addr = XEXP (addr, 1); } else if (CONSTANT_ADDRESS_P (XEXP (addr, 1)) || MEM_P (XEXP (addr, 1))) { offset = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 1)) == MULT) { ireg = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (GET_CODE (XEXP (addr, 0)) == MULT) { ireg = XEXP (addr, 0); addr = XEXP (addr, 1); } else if (REG_P (XEXP (addr, 1))) { reg1 = XEXP (addr, 1); addr = XEXP (addr, 0); } else if (REG_P (XEXP (addr, 0))) { reg1 = XEXP (addr, 0); addr = XEXP (addr, 1); } else gcc_unreachable (); if (REG_P (addr)) { if (reg1) ireg = addr; else reg1 = addr; } else if (GET_CODE (addr) == MULT) ireg = addr; else { gcc_assert (GET_CODE (addr) == PLUS); if (CONSTANT_ADDRESS_P (XEXP (addr, 0)) || MEM_P (XEXP (addr, 0))) { if (offset) { if (CONST_INT_P (offset)) offset = plus_constant (XEXP (addr, 0), INTVAL (offset)); else { gcc_assert (CONST_INT_P (XEXP (addr, 0))); offset = plus_constant (offset, INTVAL (XEXP (addr, 0))); } } offset = XEXP (addr, 0); } else if (REG_P (XEXP (addr, 0))) { if (reg1) ireg = reg1, breg = XEXP (addr, 0), reg1 = 0; else reg1 = XEXP (addr, 0); } else { gcc_assert (GET_CODE (XEXP (addr, 0)) == MULT); gcc_assert (!ireg); ireg = XEXP (addr, 0); } if (CONSTANT_ADDRESS_P (XEXP (addr, 1)) || MEM_P (XEXP (addr, 1))) { if (offset) { if (CONST_INT_P (offset)) offset = plus_constant (XEXP (addr, 1), INTVAL (offset)); else { gcc_assert (CONST_INT_P (XEXP (addr, 1))); offset = plus_constant (offset, INTVAL (XEXP (addr, 1))); } } offset = XEXP (addr, 1); } else if (REG_P (XEXP (addr, 1))) { if (reg1) ireg = reg1, breg = XEXP (addr, 1), reg1 = 0; else reg1 = XEXP (addr, 1); } else { gcc_assert (GET_CODE (XEXP (addr, 1)) == MULT); gcc_assert (!ireg); ireg = XEXP (addr, 1); } } /* If REG1 is nonzero, figure out if it is a base or index register. */ if (reg1) { if (breg != 0 || (offset && MEM_P (offset))) { gcc_assert (!ireg); ireg = reg1; } else breg = reg1; } if (offset != 0) output_address (offset); if (breg != 0) fprintf (file, "(%s)", reg_names[REGNO (breg)]); if (ireg != 0) { if (GET_CODE (ireg) == MULT) ireg = XEXP (ireg, 0); gcc_assert (REG_P (ireg)); fprintf (file, "[%s]", reg_names[REGNO (ireg)]); } break; default: output_addr_const (file, addr); } } const char * rev_cond_name (rtx op) { switch (GET_CODE (op)) { case EQ: return "neq"; case NE: return "eql"; case LT: return "geq"; case LE: return "gtr"; case GT: return "leq"; case GE: return "lss"; case LTU: return "gequ"; case LEU: return "gtru"; case GTU: return "lequ"; case GEU: return "lssu"; default: gcc_unreachable (); } } int vax_float_literal(rtx c) { enum machine_mode mode; REAL_VALUE_TYPE r, s; int i; if (GET_CODE (c) != CONST_DOUBLE) return 0; mode = GET_MODE (c); if (c == const_tiny_rtx[(int) mode][0] || c == const_tiny_rtx[(int) mode][1] || c == const_tiny_rtx[(int) mode][2]) return 1; REAL_VALUE_FROM_CONST_DOUBLE (r, c); for (i = 0; i < 7; i++) { int x = 1 << i; bool ok; REAL_VALUE_FROM_INT (s, x, 0, mode); if (REAL_VALUES_EQUAL (r, s)) return 1; ok = exact_real_inverse (mode, &s); gcc_assert (ok); if (REAL_VALUES_EQUAL (r, s)) return 1; } return 0; } /* Return the cost in cycles of a memory address, relative to register indirect. Each of the following adds the indicated number of cycles: 1 - symbolic address 1 - pre-decrement 1 - indexing and/or offset(register) 2 - indirect */ static int vax_address_cost_1 (rtx addr) { int reg = 0, indexed = 0, indir = 0, offset = 0, predec = 0; rtx plus_op0 = 0, plus_op1 = 0; restart: switch (GET_CODE (addr)) { case PRE_DEC: predec = 1; case REG: case SUBREG: case POST_INC: reg = 1; break; case MULT: indexed = 1; /* 2 on VAX 2 */ break; case CONST_INT: /* byte offsets cost nothing (on a VAX 2, they cost 1 cycle) */ if (offset == 0) offset = (unsigned HOST_WIDE_INT)(INTVAL(addr)+128) > 256; break; case CONST: case SYMBOL_REF: offset = 1; /* 2 on VAX 2 */ break; case LABEL_REF: /* this is probably a byte offset from the pc */ if (offset == 0) offset = 1; break; case PLUS: if (plus_op0) plus_op1 = XEXP (addr, 0); else plus_op0 = XEXP (addr, 0); addr = XEXP (addr, 1); goto restart; case MEM: indir = 2; /* 3 on VAX 2 */ addr = XEXP (addr, 0); goto restart; default: break; } /* Up to 3 things can be added in an address. They are stored in plus_op0, plus_op1, and addr. */ if (plus_op0) { addr = plus_op0; plus_op0 = 0; goto restart; } if (plus_op1) { addr = plus_op1; plus_op1 = 0; goto restart; } /* Indexing and register+offset can both be used (except on a VAX 2) without increasing execution time over either one alone. */ if (reg && indexed && offset) return reg + indir + offset + predec; return reg + indexed + indir + offset + predec; } static int vax_address_cost (rtx x) { return (1 + (REG_P (x) ? 0 : vax_address_cost_1 (x))); } /* Cost of an expression on a VAX. This version has costs tuned for the CVAX chip (found in the VAX 3 series) with comments for variations on other models. FIXME: The costs need review, particularly for TRUNCATE, FLOAT_EXTEND and FLOAT_TRUNCATE. We need a -mcpu option to allow provision of costs on a per cpu basis. */ static bool vax_rtx_costs (rtx x, int code, int outer_code, int *total) { enum machine_mode mode = GET_MODE (x); int i = 0; /* may be modified in switch */ const char *fmt = GET_RTX_FORMAT (code); /* may be modified in switch */ switch (code) { /* On a VAX, constants from 0..63 are cheap because they can use the 1 byte literal constant format. Compare to -1 should be made cheap so that decrement-and-branch insns can be formed more easily (if the value -1 is copied to a register some decrement-and-branch patterns will not match). */ case CONST_INT: if (INTVAL (x) == 0) return true; if (outer_code == AND) { *total = ((unsigned HOST_WIDE_INT) ~INTVAL (x) <= 077) ? 1 : 2; return true; } if ((unsigned HOST_WIDE_INT) INTVAL (x) <= 077 || (outer_code == COMPARE && INTVAL (x) == -1) || ((outer_code == PLUS || outer_code == MINUS) && (unsigned HOST_WIDE_INT) -INTVAL (x) <= 077)) { *total = 1; return true; } /* FALLTHRU */ case CONST: case LABEL_REF: case SYMBOL_REF: *total = 3; return true; case CONST_DOUBLE: if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) *total = vax_float_literal (x) ? 5 : 8; else *total = ((CONST_DOUBLE_HIGH (x) == 0 && (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x) < 64) || (outer_code == PLUS && CONST_DOUBLE_HIGH (x) == -1 && (unsigned HOST_WIDE_INT)-CONST_DOUBLE_LOW (x) < 64)) ? 2 : 5; return true; case POST_INC: *total = 2; return true; /* Implies register operand. */ case PRE_DEC: *total = 3; return true; /* Implies register operand. */ case MULT: switch (mode) { case DFmode: *total = 16; /* 4 on VAX 9000 */ break; case SFmode: *total = 9; /* 4 on VAX 9000, 12 on VAX 2 */ break; case DImode: *total = 16; /* 6 on VAX 9000, 28 on VAX 2 */ break; case SImode: case HImode: case QImode: *total = 10; /* 3-4 on VAX 9000, 20-28 on VAX 2 */ break; default: *total = MAX_COST; /* Mode is not supported. */ return true; } break; case UDIV: if (mode != SImode) { *total = MAX_COST; /* Mode is not supported. */ return true; } *total = 17; break; case DIV: if (mode == DImode) *total = 30; /* Highly variable. */ else if (mode == DFmode) /* divide takes 28 cycles if the result is not zero, 13 otherwise */ *total = 24; else *total = 11; /* 25 on VAX 2 */ break; case MOD: *total = 23; break; case UMOD: if (mode != SImode) { *total = MAX_COST; /* Mode is not supported. */ return true; } *total = 29; break; case FLOAT: *total = (6 /* 4 on VAX 9000 */ + (mode == DFmode) + (GET_MODE (XEXP (x, 0)) != SImode)); break; case FIX: *total = 7; /* 17 on VAX 2 */ break; case ASHIFT: case LSHIFTRT: case ASHIFTRT: if (mode == DImode) *total = 12; else *total = 10; /* 6 on VAX 9000 */ break; case ROTATE: case ROTATERT: *total = 6; /* 5 on VAX 2, 4 on VAX 9000 */ if (CONST_INT_P (XEXP (x, 1))) fmt = "e"; /* all constant rotate counts are short */ break; case PLUS: case MINUS: *total = (mode == DFmode) ? 13 : 8; /* 6/8 on VAX 9000, 16/15 on VAX 2 */ /* Small integer operands can use subl2 and addl2. */ if ((CONST_INT_P (XEXP (x, 1))) && (unsigned HOST_WIDE_INT)(INTVAL (XEXP (x, 1)) + 63) < 127) fmt = "e"; break; case IOR: case XOR: *total = 3; break; case AND: /* AND is special because the first operand is complemented. */ *total = 3; if (CONST_INT_P (XEXP (x, 0))) { if ((unsigned HOST_WIDE_INT)~INTVAL (XEXP (x, 0)) > 63) *total = 4; fmt = "e"; i = 1; } break; case NEG: if (mode == DFmode) *total = 9; else if (mode == SFmode) *total = 6; else if (mode == DImode) *total = 4; else *total = 2; break; case NOT: *total = 2; break; case ZERO_EXTRACT: case SIGN_EXTRACT: *total = 15; break; case MEM: if (mode == DImode || mode == DFmode) *total = 5; /* 7 on VAX 2 */ else *total = 3; /* 4 on VAX 2 */ x = XEXP (x, 0); if (!REG_P (x) && GET_CODE (x) != POST_INC) *total += vax_address_cost_1 (x); return true; case FLOAT_EXTEND: case FLOAT_TRUNCATE: case TRUNCATE: *total = 3; /* FIXME: Costs need to be checked */ break; default: return false; } /* Now look inside the expression. Operands which are not registers or short constants add to the cost. FMT and I may have been adjusted in the switch above for instructions which require special handling. */ while (*fmt++ == 'e') { rtx op = XEXP (x, i); i += 1; code = GET_CODE (op); /* A NOT is likely to be found as the first operand of an AND (in which case the relevant cost is of the operand inside the not) and not likely to be found anywhere else. */ if (code == NOT) op = XEXP (op, 0), code = GET_CODE (op); switch (code) { case CONST_INT: if ((unsigned HOST_WIDE_INT)INTVAL (op) > 63 && GET_MODE (x) != QImode) *total += 1; /* 2 on VAX 2 */ break; case CONST: case LABEL_REF: case SYMBOL_REF: *total += 1; /* 2 on VAX 2 */ break; case CONST_DOUBLE: if (GET_MODE_CLASS (GET_MODE (op)) == MODE_FLOAT) { /* Registers are faster than floating point constants -- even those constants which can be encoded in a single byte. */ if (vax_float_literal (op)) *total += 1; else *total += (GET_MODE (x) == DFmode) ? 3 : 2; } else { if (CONST_DOUBLE_HIGH (op) != 0 || (unsigned)CONST_DOUBLE_LOW (op) > 63) *total += 2; } break; case MEM: *total += 1; /* 2 on VAX 2 */ if (!REG_P (XEXP (op, 0))) *total += vax_address_cost_1 (XEXP (op, 0)); break; case REG: case SUBREG: break; default: *total += 1; break; } } return true; } /* Output code to add DELTA to the first argument, and then jump to FUNCTION. Used for C++ multiple inheritance. .mask ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11> #conservative entry mask addl2 $DELTA, 4(ap) #adjust first argument jmp FUNCTION+2 #jump beyond FUNCTION's entry mask */ static void vax_output_mi_thunk (FILE * file, tree thunk ATTRIBUTE_UNUSED, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED, tree function) { fprintf (file, "\t.word 0x0ffc\n\taddl2 $" HOST_WIDE_INT_PRINT_DEC, delta); asm_fprintf (file, ",4(%Rap)\n"); fprintf (file, "\tjmp "); assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0)); fprintf (file, "+2\n"); } static rtx vax_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED, int incoming ATTRIBUTE_UNUSED) { return gen_rtx_REG (Pmode, VAX_STRUCT_VALUE_REGNUM); } /* Worker function for NOTICE_UPDATE_CC. */ void vax_notice_update_cc (rtx exp, rtx insn ATTRIBUTE_UNUSED) { if (GET_CODE (exp) == SET) { if (GET_CODE (SET_SRC (exp)) == CALL) CC_STATUS_INIT; else if (GET_CODE (SET_DEST (exp)) != ZERO_EXTRACT && GET_CODE (SET_DEST (exp)) != PC) { cc_status.flags = 0; /* The integer operations below don't set carry or set it in an incompatible way. That's ok though as the Z bit is all we need when doing unsigned comparisons on the result of these insns (since they're always with 0). Set CC_NO_OVERFLOW to generate the correct unsigned branches. */ switch (GET_CODE (SET_SRC (exp))) { case NEG: if (GET_MODE_CLASS (GET_MODE (exp)) == MODE_FLOAT) break; case AND: case IOR: case XOR: case NOT: case MEM: case REG: cc_status.flags = CC_NO_OVERFLOW; break; default: break; } cc_status.value1 = SET_DEST (exp); cc_status.value2 = SET_SRC (exp); } } else if (GET_CODE (exp) == PARALLEL && GET_CODE (XVECEXP (exp, 0, 0)) == SET) { if (GET_CODE (SET_SRC (XVECEXP (exp, 0, 0))) == CALL) CC_STATUS_INIT; else if (GET_CODE (SET_DEST (XVECEXP (exp, 0, 0))) != PC) { cc_status.flags = 0; cc_status.value1 = SET_DEST (XVECEXP (exp, 0, 0)); cc_status.value2 = SET_SRC (XVECEXP (exp, 0, 0)); } else /* PARALLELs whose first element sets the PC are aob, sob insns. They do change the cc's. */ CC_STATUS_INIT; } else CC_STATUS_INIT; if (cc_status.value1 && REG_P (cc_status.value1) && cc_status.value2 && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2)) cc_status.value2 = 0; if (cc_status.value1 && MEM_P (cc_status.value1) && cc_status.value2 && MEM_P (cc_status.value2)) cc_status.value2 = 0; /* Actual condition, one line up, should be that value2's address depends on value1, but that is too much of a pain. */ } /* Output integer move instructions. */ const char * vax_output_int_move (rtx insn ATTRIBUTE_UNUSED, rtx *operands, enum machine_mode mode) { switch (mode) { case SImode: if (GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST) { if (push_operand (operands[0], SImode)) return "pushab %a1"; return "movab %a1,%0"; } if (operands[1] == const0_rtx) return "clrl %0"; if (CONST_INT_P (operands[1]) && (unsigned) INTVAL (operands[1]) >= 64) { int i = INTVAL (operands[1]); if ((unsigned)(~i) < 64) return "mcoml %N1,%0"; if ((unsigned)i < 0x100) return "movzbl %1,%0"; if (i >= -0x80 && i < 0) return "cvtbl %1,%0"; if ((unsigned)i < 0x10000) return "movzwl %1,%0"; if (i >= -0x8000 && i < 0) return "cvtwl %1,%0"; } if (push_operand (operands[0], SImode)) return "pushl %1"; return "movl %1,%0"; case HImode: if (CONST_INT_P (operands[1])) { int i = INTVAL (operands[1]); if (i == 0) return "clrw %0"; else if ((unsigned int)i < 64) return "movw %1,%0"; else if ((unsigned int)~i < 64) return "mcomw %H1,%0"; else if ((unsigned int)i < 256) return "movzbw %1,%0"; } return "movw %1,%0"; case QImode: if (CONST_INT_P (operands[1])) { int i = INTVAL (operands[1]); if (i == 0) return "clrb %0"; else if ((unsigned int)~i < 64) return "mcomb %B1,%0"; } return "movb %1,%0"; default: gcc_unreachable (); } } /* Output integer add instructions. The space-time-opcode tradeoffs for addition vary by model of VAX. On a VAX 3 "movab (r1)[r2],r3" is faster than "addl3 r1,r2,r3", but it not faster on other models. "movab #(r1),r2" is usually shorter than "addl3 #,r1,r2", and is faster on a VAX 3, but some VAXen (e.g. VAX 9000) will stall if a register is used in an address too soon after it is set. Compromise by using movab only when it is shorter than the add or the base register in the address is one of sp, ap, and fp, which are not modified very often. */ const char * vax_output_int_add (rtx insn ATTRIBUTE_UNUSED, rtx *operands, enum machine_mode mode) { switch (mode) { case SImode: if (rtx_equal_p (operands[0], operands[1])) { if (operands[2] == const1_rtx) return "incl %0"; if (operands[2] == constm1_rtx) return "decl %0"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subl2 $%n2,%0"; if (CONST_INT_P (operands[2]) && (unsigned) INTVAL (operands[2]) >= 64 && REG_P (operands[1]) && ((INTVAL (operands[2]) < 32767 && INTVAL (operands[2]) > -32768) || REGNO (operands[1]) > 11)) return "movab %c2(%1),%0"; return "addl2 %2,%0"; } if (rtx_equal_p (operands[0], operands[2])) return "addl2 %1,%0"; if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 32767 && INTVAL (operands[2]) > -32768 && REG_P (operands[1]) && push_operand (operands[0], SImode)) return "pushab %c2(%1)"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subl3 $%n2,%1,%0"; if (CONST_INT_P (operands[2]) && (unsigned) INTVAL (operands[2]) >= 64 && REG_P (operands[1]) && ((INTVAL (operands[2]) < 32767 && INTVAL (operands[2]) > -32768) || REGNO (operands[1]) > 11)) return "movab %c2(%1),%0"; /* Add this if using gcc on a VAX 3xxx: if (REG_P (operands[1]) && REG_P (operands[2])) return "movab (%1)[%2],%0"; */ return "addl3 %1,%2,%0"; case HImode: if (rtx_equal_p (operands[0], operands[1])) { if (operands[2] == const1_rtx) return "incw %0"; if (operands[2] == constm1_rtx) return "decw %0"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subw2 $%n2,%0"; return "addw2 %2,%0"; } if (rtx_equal_p (operands[0], operands[2])) return "addw2 %1,%0"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subw3 $%n2,%1,%0"; return "addw3 %1,%2,%0"; case QImode: if (rtx_equal_p (operands[0], operands[1])) { if (operands[2] == const1_rtx) return "incb %0"; if (operands[2] == constm1_rtx) return "decb %0"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subb2 $%n2,%0"; return "addb2 %2,%0"; } if (rtx_equal_p (operands[0], operands[2])) return "addb2 %1,%0"; if (CONST_INT_P (operands[2]) && (unsigned) (- INTVAL (operands[2])) < 64) return "subb3 $%n2,%1,%0"; return "addb3 %1,%2,%0"; default: gcc_unreachable (); } } /* Output a conditional branch. */ const char * vax_output_conditional_branch (enum rtx_code code) { switch (code) { case EQ: return "jeql %l0"; case NE: return "jneq %l0"; case GT: return "jgtr %l0"; case LT: return "jlss %l0"; case GTU: return "jgtru %l0"; case LTU: return "jlssu %l0"; case GE: return "jgeq %l0"; case LE: return "jleq %l0"; case GEU: return "jgequ %l0"; case LEU: return "jlequ %l0"; default: gcc_unreachable (); } } /* 1 if X is an rtx for a constant that is a valid address. */ int legitimate_constant_address_p (rtx x) { return (GET_CODE (x) == LABEL_REF || GET_CODE (x) == SYMBOL_REF || CONST_INT_P (x) || GET_CODE (x) == CONST || GET_CODE (x) == HIGH); } /* Nonzero if the constant value X is a legitimate general operand. It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ int legitimate_constant_p (rtx x ATTRIBUTE_UNUSED) { return 1; } /* The other macros defined here are used only in legitimate_address_p (). */ /* Nonzero if X is a hard reg that can be used as an index or, if not strict, if it is a pseudo reg. */ #define INDEX_REGISTER_P(X, STRICT) \ (REG_P (X) && (!(STRICT) || REGNO_OK_FOR_INDEX_P (REGNO (X)))) /* Nonzero if X is a hard reg that can be used as a base reg or, if not strict, if it is a pseudo reg. */ #define BASE_REGISTER_P(X, STRICT) \ (REG_P (X) && (!(STRICT) || REGNO_OK_FOR_BASE_P (REGNO (X)))) #ifdef NO_EXTERNAL_INDIRECT_ADDRESS /* Re-definition of CONSTANT_ADDRESS_P, which is true only when there are no SYMBOL_REFs for external symbols present. */ static int indirectable_constant_address_p (rtx x) { if (!CONSTANT_ADDRESS_P (x)) return 0; if (GET_CODE (x) == CONST && GET_CODE (XEXP ((x), 0)) == PLUS) x = XEXP (XEXP (x, 0), 0); if (GET_CODE (x) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (x)) return 0; return 1; } #else /* not NO_EXTERNAL_INDIRECT_ADDRESS */ static int indirectable_constant_address_p (rtx x) { return CONSTANT_ADDRESS_P (x); } #endif /* not NO_EXTERNAL_INDIRECT_ADDRESS */ /* Nonzero if X is an address which can be indirected. External symbols could be in a sharable image library, so we disallow those. */ static int indirectable_address_p(rtx x, int strict) { if (indirectable_constant_address_p (x)) return 1; if (BASE_REGISTER_P (x, strict)) return 1; if (GET_CODE (x) == PLUS && BASE_REGISTER_P (XEXP (x, 0), strict) && indirectable_constant_address_p (XEXP (x, 1))) return 1; return 0; } /* Return 1 if x is a valid address not using indexing. (This much is the easy part.) */ static int nonindexed_address_p (rtx x, int strict) { rtx xfoo0; if (REG_P (x)) { extern rtx *reg_equiv_mem; if (!reload_in_progress || reg_equiv_mem[REGNO (x)] == 0 || indirectable_address_p (reg_equiv_mem[REGNO (x)], strict)) return 1; } if (indirectable_constant_address_p (x)) return 1; if (indirectable_address_p (x, strict)) return 1; xfoo0 = XEXP (x, 0); if (MEM_P (x) && indirectable_address_p (xfoo0, strict)) return 1; if ((GET_CODE (x) == PRE_DEC || GET_CODE (x) == POST_INC) && BASE_REGISTER_P (xfoo0, strict)) return 1; return 0; } /* 1 if PROD is either a reg times size of mode MODE and MODE is less than or equal 8 bytes, or just a reg if MODE is one byte. */ static int index_term_p (rtx prod, enum machine_mode mode, int strict) { rtx xfoo0, xfoo1; if (GET_MODE_SIZE (mode) == 1) return BASE_REGISTER_P (prod, strict); if (GET_CODE (prod) != MULT || GET_MODE_SIZE (mode) > 8) return 0; xfoo0 = XEXP (prod, 0); xfoo1 = XEXP (prod, 1); if (CONST_INT_P (xfoo0) && INTVAL (xfoo0) == (int)GET_MODE_SIZE (mode) && INDEX_REGISTER_P (xfoo1, strict)) return 1; if (CONST_INT_P (xfoo1) && INTVAL (xfoo1) == (int)GET_MODE_SIZE (mode) && INDEX_REGISTER_P (xfoo0, strict)) return 1; return 0; } /* Return 1 if X is the sum of a register and a valid index term for mode MODE. */ static int reg_plus_index_p (rtx x, enum machine_mode mode, int strict) { rtx xfoo0, xfoo1; if (GET_CODE (x) != PLUS) return 0; xfoo0 = XEXP (x, 0); xfoo1 = XEXP (x, 1); if (BASE_REGISTER_P (xfoo0, strict) && index_term_p (xfoo1, mode, strict)) return 1; if (BASE_REGISTER_P (xfoo1, strict) && index_term_p (xfoo0, mode, strict)) return 1; return 0; } /* legitimate_address_p returns 1 if it recognizes an RTL expression "x" that is a valid memory address for an instruction. The MODE argument is the machine mode for the MEM expression that wants to use this address. */ int legitimate_address_p (enum machine_mode mode, rtx x, int strict) { rtx xfoo0, xfoo1; if (nonindexed_address_p (x, strict)) return 1; if (GET_CODE (x) != PLUS) return 0; /* Handle <address>[index] represented with index-sum outermost */ xfoo0 = XEXP (x, 0); xfoo1 = XEXP (x, 1); if (index_term_p (xfoo0, mode, strict) && nonindexed_address_p (xfoo1, strict)) return 1; if (index_term_p (xfoo1, mode, strict) && nonindexed_address_p (xfoo0, strict)) return 1; /* Handle offset(reg)[index] with offset added outermost */ if (indirectable_constant_address_p (xfoo0) && (BASE_REGISTER_P (xfoo1, strict) || reg_plus_index_p (xfoo1, mode, strict))) return 1; if (indirectable_constant_address_p (xfoo1) && (BASE_REGISTER_P (xfoo0, strict) || reg_plus_index_p (xfoo0, mode, strict))) return 1; return 0; } /* Return 1 if x (a legitimate address expression) has an effect that depends on the machine mode it is used for. On the VAX, the predecrement and postincrement address depend thus (the amount of decrement or increment being the length of the operand) and all indexed address depend thus (because the index scale factor is the length of the operand). */ int vax_mode_dependent_address_p (rtx x) { rtx xfoo0, xfoo1; if (GET_CODE (x) == POST_INC || GET_CODE (x) == PRE_DEC) return 1; if (GET_CODE (x) != PLUS) return 0; xfoo0 = XEXP (x, 0); xfoo1 = XEXP (x, 1); if (CONSTANT_ADDRESS_P (xfoo0) && REG_P (xfoo1)) return 0; if (CONSTANT_ADDRESS_P (xfoo1) && REG_P (xfoo0)) return 0; return 1; }
25.361782
82
0.612883
1b71e5c9ad13a09dee2811bb0919888bffb6a283
496
c
C
src/Data/Semiring.c
purescript-c/purescript-prelude
fd343c3aeb751b6f56fa086adf61f2c27dacf049
[ "BSD-3-Clause" ]
null
null
null
src/Data/Semiring.c
purescript-c/purescript-prelude
fd343c3aeb751b6f56fa086adf61f2c27dacf049
[ "BSD-3-Clause" ]
null
null
null
src/Data/Semiring.c
purescript-c/purescript-prelude
fd343c3aeb751b6f56fa086adf61f2c27dacf049
[ "BSD-3-Clause" ]
1
2018-10-09T03:15:39.000Z
2018-10-09T03:15:39.000Z
#include <purescript.h> PURS_FFI_FUNC_2(Data_Semiring_intAdd, x, y) { return purs_any_int(purs_any_force_int(x) + purs_any_force_int(y)); } PURS_FFI_FUNC_2(Data_Semiring_intMul, x, y) { return purs_any_int(purs_any_force_int(x) * purs_any_force_int(y)); } PURS_FFI_FUNC_2(Data_Semiring_numAdd, x, y) { return purs_any_num(purs_any_force_num(x) + purs_any_force_num(y)); } PURS_FFI_FUNC_2(Data_Semiring_numMul, x, y) { return purs_any_num(purs_any_force_num(x) * purs_any_force_num(y)); }
27.555556
68
0.78629
bb2f6d2c028aac84643133cd960f54291e2505d0
3,151
h
C
src/conv2d/winograd/queue_output_transform_impl.h
GeorgeWeb/SYCL-DNN
50fe1357f5302d188d85512c58de1ae7ed8a0912
[ "Apache-2.0" ]
85
2018-06-04T08:07:20.000Z
2022-03-30T15:53:46.000Z
src/conv2d/winograd/queue_output_transform_impl.h
GeorgeWeb/SYCL-DNN
50fe1357f5302d188d85512c58de1ae7ed8a0912
[ "Apache-2.0" ]
8
2019-07-19T11:10:43.000Z
2021-02-05T10:18:49.000Z
src/conv2d/winograd/queue_output_transform_impl.h
GeorgeWeb/SYCL-DNN
50fe1357f5302d188d85512c58de1ae7ed8a0912
[ "Apache-2.0" ]
19
2018-12-28T12:09:22.000Z
2022-01-08T02:55:14.000Z
/* * Copyright 2018 Codeplay Software Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SYCLDNN_SRC_CONV2D_WINOGRAD_QUEUE_OUTPUT_TRANSFORM_IMPL_H_ #define SYCLDNN_SRC_CONV2D_WINOGRAD_QUEUE_OUTPUT_TRANSFORM_IMPL_H_ #include "sycldnn/mem_object.h" #include "src/conv2d/winograd/queue_output_transform.h" #include "src/conv2d/winograd/kernels/extract_output_transform.h" namespace sycldnn { namespace conv2d { namespace internal { namespace winograd { namespace { /** Round up a value to the nearest multiple of 4. */ auto round_up = [](int val) { constexpr int pow_two_multiple = 4; return helpers::round_up_to_nearest_multiple(val, pow_two_multiple); }; /** Get the number of threads for a given convolution. */ template <typename ConvType> inline cl::sycl::range<1> get_thread_range(Conv2DParams const& params, TileInfo const& tile_info) { size_t n_threads = round_up(params.batch * tile_info.rows * tile_info.cols * params.features); return cl::sycl::range<1>{n_threads}; } /** Get the number of threads for a given filter backprop convolution. */ template <> inline cl::sycl::range<1> get_thread_range<conv_type::FilterBackprop>( Conv2DParams const& params, TileInfo const& /*unused*/) { auto round_up = [](int val) { constexpr int pow_two_multiple = 4; return helpers::round_up_to_nearest_multiple(val, pow_two_multiple); }; size_t n_threads = round_up(params.features * params.channels); return cl::sycl::range<1>{n_threads}; } } // namespace template <typename T, typename Index, typename ConvType, int M, int N, int R, int S, bool Accumulate> SNNStatus queue_output_transform(BaseMemObject<T const>& intermediate_mem, BaseMemObject<T>& output_mem, Conv2DParams const& params, TileInfo const& tile_info, cl::sycl::queue& queue) { using Functor = ExtractOutputTiles<T, Index, M, N, R, S, ConvType, Accumulate>; auto event = queue.submit([&](cl::sycl::handler& cgh) { auto intermediate = intermediate_mem.read_accessor(cgh); auto output = output_mem.write_accessor(cgh); auto range = get_thread_range<ConvType>(params, tile_info); Functor conv{params, tile_info, intermediate, output}; cgh.parallel_for(range, conv); }); return SNNStatus{event, StatusCode::OK}; } } // namespace winograd } // namespace internal } // namespace conv2d } // namespace sycldnn #endif // SYCLDNN_SRC_CONV2D_WINOGRAD_QUEUE_OUTPUT_TRANSFORM_IMPL_H_
35.806818
78
0.69946
18345ec6309bdd88555c73b3fc495b7545f27c26
572
h
C
System/Library/PrivateFrameworks/SyncedDefaults.framework/Support/syncdefaultsd/SYDDaemonToClientConnectionDelegate.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
11
2019-11-06T04:48:48.000Z
2022-02-09T17:48:15.000Z
System/Library/PrivateFrameworks/SyncedDefaults.framework/Support/syncdefaultsd/SYDDaemonToClientConnectionDelegate.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
1
2020-04-16T01:41:56.000Z
2020-04-16T04:32:00.000Z
System/Library/PrivateFrameworks/SyncedDefaults.framework/Support/syncdefaultsd/SYDDaemonToClientConnectionDelegate.h
lechium/tvOS130Headers
6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd
[ "MIT" ]
3
2019-12-22T20:17:53.000Z
2021-01-25T09:47:49.000Z
/* * This header is generated by classdump-dyld 1.0 * on Tuesday, November 5, 2019 at 2:45:15 AM Mountain Standard Time * Operating System: Version 13.0 (Build 17J586) * Image Source: /System/Library/PrivateFrameworks/SyncedDefaults.framework/Support/syncdefaultsd * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @protocol SYDDaemonToClientConnectionDelegate @required -(void)connectionDidInvalidate:(id)arg1; -(id)connection:(id)arg1 syncManagerForStoreIdentifier:(id)arg2 type:(long long)arg3; -(void)processAccountChanges; @end
31.777778
96
0.793706
767533af9d66575757cfe4b7fe266b4d7d99340e
3,265
h
C
Src/Foundation/Utility/Memory/Memory.h
prophecy/Pillar
a60b07857e66312ee94d69678b1ca8c97b1a19eb
[ "MIT" ]
2
2017-07-19T03:23:27.000Z
2018-01-16T04:26:53.000Z
Src/Foundation/Utility/Memory/Memory.h
prophecy/Pillar
a60b07857e66312ee94d69678b1ca8c97b1a19eb
[ "MIT" ]
null
null
null
Src/Foundation/Utility/Memory/Memory.h
prophecy/Pillar
a60b07857e66312ee94d69678b1ca8c97b1a19eb
[ "MIT" ]
null
null
null
/* * This source file is part of Wonderland, the C++ Cross-platform middleware for game * * For the latest information, see https://github.com/prophecy/Wonderland * * The MIT License (MIT) * Copyright (c) 2015 Adawat Chanchua * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #ifndef __MEMORY_H__ #define __MEMORY_H__ #define DEBUG_MEMORY #include "Utility/Types.h" #include "Utility/Singleton.h" #include "MemoryHandle.h" class Memory : public Singleton<Memory> { private: u32 _handleId; // This map is between code and handle std::map< u32, MemoryHandle<u32> > _codeHandleMap; // This is an additional map between pointer and handle std::map< u32*, MemoryHandle<u32> > _addressHandleMap; public: template <typename T> MemoryHandle<T>* Alloc() { // Naive alloc mode1 MemoryHandle<T>* handle = new MemoryHandle<T>(); // <<< keep this in organized place T* ptr = new T(); handle->code = _handleId; handle->ptr = ptr; // Increment ++_handleId; // Add to map // u32 is an address which is converted from T MemoryHandle<u32> hMap; hMap.code = handle->code; hMap.ptr = (u32*)handle->ptr; _codeHandleMap.insert(std::pair< u32, MemoryHandle<u32> >(hMap.code, hMap)); // Create additional map for searching _addressHandleMap.insert(std::pair< u32*, MemoryHandle<u32> >(hMap.ptr, hMap)); // Return handle return handle; } template <typename T> void Free(MemoryHandle<T>* handle) { // Erase address handle _addressHandleMap.erase((u32*)handle->ptr); // Naive alloc mode delete handle->ptr; handle->ptr = NULL; // Erase from map _codeHandleMap.erase(handle->code); } void FreeAll() { std::map< u32, MemoryHandle<u32> >::iterator it = _codeHandleMap.begin(); while (it != _codeHandleMap.end()) { MemoryHandle<u32> handle = (*it).second; // Naive alloc mode delete handle.ptr; handle.ptr = NULL; // Erase from map _codeHandleMap.erase(it++); } // Clear all address handle _addressHandleMap.clear(); } u64 GetMemoryCounter() { return _codeHandleMap.size(); } template <typename T> MemoryHandle<T>* GetHandle(u64 address) { return (MemoryHandle<T>*)&_addressHandleMap[(u32*)address]; } }; #endif // __MEMORY_H__
27.208333
86
0.712404
0afe215d1d81a22df1f752022fcb7612c30321c4
217
h
C
Plugins/Actions/MailMe/MailMe/GrowlMailMePreferencePane.h
nochkin/growl
c2ab08ccfde2cc0e9c25506fa3e1fa8a63a29632
[ "BSD-3-Clause" ]
121
2020-11-28T22:44:54.000Z
2022-03-30T13:21:33.000Z
Plugins/Actions/MailMe/MailMe/GrowlMailMePreferencePane.h
nochkin/growl
c2ab08ccfde2cc0e9c25506fa3e1fa8a63a29632
[ "BSD-3-Clause" ]
3
2015-05-01T13:55:30.000Z
2015-09-05T13:45:58.000Z
Plugins/Actions/MailMe/MailMe/GrowlMailMePreferencePane.h
nochkin/growl
c2ab08ccfde2cc0e9c25506fa3e1fa8a63a29632
[ "BSD-3-Clause" ]
28
2020-11-29T02:19:02.000Z
2022-03-20T20:23:59.000Z
// // GrowlMailMePreferencePane.h // MailMe // // Created by Daniel Siemer on 4/12/12. // #import <GrowlPlugins/GrowlPluginPreferencePane.h> @interface GrowlMailMePreferencePane : GrowlPluginPreferencePane @end
16.692308
64
0.764977
9d95f37f3cabe98862aae2ae9ce3c89d0cae901d
5,931
c
C
test/test_config.c
CamStan/shuffile
0eaa6e2c5a273539326b3cb32f3739ee487b549b
[ "MIT" ]
null
null
null
test/test_config.c
CamStan/shuffile
0eaa6e2c5a273539326b3cb32f3739ee487b549b
[ "MIT" ]
null
null
null
test/test_config.c
CamStan/shuffile
0eaa6e2c5a273539326b3cb32f3739ee487b549b
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "shuffile.h" #include "shuffile_util.h" #include "kvtree.h" #include "kvtree_util.h" /* helper function to check for known options */ void check_known_options(const kvtree* configured_values, const char* known_options[]) { /* report all unknown options (typos?) */ const kvtree_elem* elem; for (elem = kvtree_elem_first(configured_values); elem != NULL; elem = kvtree_elem_next(elem)) { const char* key = kvtree_elem_key(elem); /* must be only one level deep, ie plain kev = value */ const kvtree* elem_hash = kvtree_elem_hash(elem); if (kvtree_size(elem_hash) != 1) { printf("Element %s has unexpected number of values: %d", key, kvtree_size(elem_hash)); exit(EXIT_FAILURE); } const kvtree* kvtree_first_elem_hash = kvtree_elem_hash(kvtree_elem_first(elem_hash)); if (kvtree_size(kvtree_first_elem_hash) != 0) { printf("Element %s is not a pure value", key); exit(EXIT_FAILURE); } /* check against known options */ const char** opt; int found = 0; for (opt = known_options; *opt != NULL; opt++) { if (strcmp(*opt, key) == 0) { found = 1; break; } } if (! found) { printf("Unknown configuration parameter '%s' with value '%s'\n", kvtree_elem_key(elem), kvtree_elem_key(kvtree_elem_first(kvtree_elem_hash(elem))) ); exit(EXIT_FAILURE); } } } /* helper function to check option values in kvtree against expected values */ void check_options(const int exp_debug, const int exp_mpi_buf_size) { kvtree* config = shuffile_config(NULL); if (config == NULL) { printf("shuffile_config failed\n"); exit(EXIT_FAILURE); } int cfg_debug; if (kvtree_util_get_int(config, SHUFFILE_KEY_CONFIG_DEBUG, &cfg_debug) != KVTREE_SUCCESS) { printf("Could not get %s from shuffile_config\n", SHUFFILE_KEY_CONFIG_DEBUG); exit(EXIT_FAILURE); } if (cfg_debug != exp_debug) { printf("shuffile_config returned unexpected value %d for %s. Expected %d.\n", cfg_debug, SHUFFILE_KEY_CONFIG_DEBUG, exp_debug); exit(EXIT_FAILURE); } int cfg_mpi_buf_size; if (kvtree_util_get_int(config, SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE, &cfg_mpi_buf_size) != KVTREE_SUCCESS) { printf("Could not get %s from shuffile_config\n", SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE); exit(EXIT_FAILURE); } if (cfg_mpi_buf_size != exp_mpi_buf_size) { printf("shuffile_config returned unexpected value %d for %s. Expected %d.\n", cfg_mpi_buf_size, SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE, exp_mpi_buf_size); exit(EXIT_FAILURE); } static const char* known_options[] = { SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE, SHUFFILE_KEY_CONFIG_DEBUG, NULL }; check_known_options(config, known_options); kvtree_delete(&config); } int main(int argc, char *argv[]) { int rc; kvtree* shuffile_config_values = kvtree_new(); MPI_Init(&argc, &argv); rc = shuffile_init(); if (rc != SHUFFILE_SUCCESS) { printf("shuffile_init() failed (error %d)\n", rc); return EXIT_FAILURE; } /* needs to be afater shuffile_init to catch initialization of globals */ int old_shuffile_debug = shuffile_debug; int old_shuffile_mpi_buf_size = shuffile_mpi_buf_size; int new_shuffile_debug = !old_shuffile_debug; int new_shuffile_mpi_buf_size = old_shuffile_mpi_buf_size + 1; check_options(old_shuffile_debug, old_shuffile_mpi_buf_size); /* check shuffile configuration settings */ rc = kvtree_util_set_int(shuffile_config_values, SHUFFILE_KEY_CONFIG_DEBUG, new_shuffile_debug); if (rc != KVTREE_SUCCESS) { printf("kvtree_util_set_int failed (error %d)\n", rc); return EXIT_FAILURE; } printf("Configuring shuffile (first set of options)...\n"); if (shuffile_config(shuffile_config_values) == NULL) { printf("shuffile_config() failed\n"); return EXIT_FAILURE; } /* check options just set */ if (shuffile_debug != new_shuffile_debug) { printf("shuffile_config() failed to set %s: %d != %d\n", SHUFFILE_KEY_CONFIG_DEBUG, shuffile_debug, new_shuffile_debug); return EXIT_FAILURE; } check_options(new_shuffile_debug, old_shuffile_mpi_buf_size); /* configure remainder of options */ kvtree_delete(&shuffile_config_values); shuffile_config_values = kvtree_new(); rc = kvtree_util_set_int(shuffile_config_values, SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE, new_shuffile_mpi_buf_size); if (rc != KVTREE_SUCCESS) { printf("kvtree_util_set_int failed (error %d)\n", rc); return EXIT_FAILURE; } printf("Configuring shuffile (second set of options)...\n"); if (shuffile_config(shuffile_config_values) == NULL) { printf("shuffile_config() failed\n"); return EXIT_FAILURE; } /* check all options once more */ if (shuffile_debug != new_shuffile_debug) { printf("shuffile_config() failed to set %s: %d != %d\n", SHUFFILE_KEY_CONFIG_DEBUG, shuffile_debug, new_shuffile_debug); return EXIT_FAILURE; } if (shuffile_mpi_buf_size != new_shuffile_mpi_buf_size) { printf("shuffile_config() failed to set %s: %d != %d\n", SHUFFILE_KEY_CONFIG_MPI_BUF_SIZE, shuffile_mpi_buf_size, old_shuffile_mpi_buf_size); return EXIT_FAILURE; } check_options(new_shuffile_debug, new_shuffile_mpi_buf_size); rc = shuffile_finalize(); if (rc != SHUFFILE_SUCCESS) { printf("shuffile_finalize() failed (error %d)\n", rc); return EXIT_FAILURE; } MPI_Finalize(); return EXIT_SUCCESS; }
30.260204
86
0.66026
130b427ecec4ef2dd4a15e96061d8e167208c56f
2,682
h
C
CHGetAuthStatus-Demo/CHGetAuthStatus-Demo/CHGetAuthStatusTools/CHPermission.h
MeteoriteMan/CHGetPermissionStatus
bc5b58182ebd04863b225e6d3a35d94a9659000e
[ "MIT" ]
null
null
null
CHGetAuthStatus-Demo/CHGetAuthStatus-Demo/CHGetAuthStatusTools/CHPermission.h
MeteoriteMan/CHGetPermissionStatus
bc5b58182ebd04863b225e6d3a35d94a9659000e
[ "MIT" ]
null
null
null
CHGetAuthStatus-Demo/CHGetAuthStatus-Demo/CHGetAuthStatusTools/CHPermission.h
MeteoriteMan/CHGetPermissionStatus
bc5b58182ebd04863b225e6d3a35d94a9659000e
[ "MIT" ]
null
null
null
// // CHPermission.h // CHGetAuthStatus-Demo // // Created by 张晨晖 on 2018/7/23. // Copyright © 2018年 张晨晖. All rights reserved. // #import <Foundation/Foundation.h> typedef NS_ENUM(NSUInteger, CHPermissionRequestType){/// 请求类型 CHPermission_None = 0, CHPermission_BluetoothPeripheralUsage = 1, // 蓝牙 CHPermission_CalendarsUsage = 2, // 日历 CHPermission_CameraUsage = 3, // 相机 CHPermission_ContactsUsage = 4, // 通讯录 CHPermission_FaceIDUsage = 5, // FaceID CHPermission_HealthShareUsage = 6, // 健康数据分享 CHPermission_HealthUpdateUsage = 7, // 健康数据更新 CHPermission_HomeKitUsage = 8, // 家庭 >= iOS8.0 CHPermission_LocationLocationAlwaysUsage = 9, // 定位服务始终开启 CHPermission_LocationLocationUsage = 10, // 定位服务 CHPermission_LocationLocationWhenInUseUsage = 11, // 需要时开启定位 CHPermission_MediaLibraryUsage = 12, // 播放音乐或者视频 CHPermission_MicrophoneUsage = 13, // 麦克风 CHPermission_MotionUsage = 14, // 运动与健身 CHPermission_MusicUsage = 15, // 音乐 CHPermission_NFCScanUsage = 16, // NFC CHPermission_PhotoLibraryUsage = 17, // 照片 CHPermission_RemindersUsage = 18, // 提醒事项 CHPermission_SiriUsage = 19, // Siri CHPermission_SpeechRecognitionUsage = 20, // 语音识别 >= iOS10 CHPermission_TVProviderUsage = 21, // 电视提供商 CHPermission_VideoSubscriberAccountUsage = 22, // 媒体与Apple Music >= iOS9.3 }; typedef NS_ENUM(NSUInteger, CHPermissionRequestResultType) {/// 返回结果类型 CHPermissionRequestResultType_NotExplicit,//结果不明 CHPermissionRequestResultType_Granted,//允许 CHPermissionRequestResultType_Reject,//拒绝 CHPermissionRequestResultType_ParentallyRestricted,//家长权限拒绝 }; typedef NS_ENUM(NSUInteger, CHPermissionRequestSupportType) {/// 返回结果类型 CHPermissionRequestSupportType_Support,//支持 CHPermissionRequestSupportType_NotSupport,//不支持 }; typedef void(^CHPermissionRequestResultBlock)(CHPermissionRequestResultType resultType); @interface CHPermission : NSObject /// 全局单例访问点 + (instancetype)sharedClass; - (void)requestAuthWithPermissionRequestType:(CHPermissionRequestType)requestType andCompleteHandle:(void(^)(CHPermissionRequestSupportType supportType))completeHandle; @property (nonatomic ,strong) CHPermissionRequestResultBlock permissionRequestResultBlock; @end
43.967213
168
0.648397
59642280e2e6906789ac428ac920c54a6f7fbcbb
9,890
c
C
sw/lib/source/neorv32_cpu.c
miscellaneousbits/neorv32
fd35c7fdd331813c7c1a5b6a7333989aaf53ee67
[ "BSD-3-Clause" ]
null
null
null
sw/lib/source/neorv32_cpu.c
miscellaneousbits/neorv32
fd35c7fdd331813c7c1a5b6a7333989aaf53ee67
[ "BSD-3-Clause" ]
null
null
null
sw/lib/source/neorv32_cpu.c
miscellaneousbits/neorv32
fd35c7fdd331813c7c1a5b6a7333989aaf53ee67
[ "BSD-3-Clause" ]
null
null
null
// ################################################################################################# // # << NEORV32: neorv32_cpu.c - CPU Core Functions HW Driver >> # // # ********************************************************************************************* # // # BSD 3-Clause License # // # # // # Copyright (c) 2020, 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 neorv32_cpu.c * @author Stephan Nolting * @brief CPU Core Functions HW driver source file. **************************************************************************/ #include "neorv32.h" #include "neorv32_cpu.h" /**********************************************************************//** * Enable specific CPU interrupt. * * @note Interrupts have to be globally enabled via neorv32_cpu_eint(void), too. * * @param[in] irq_sel CPU interrupt select. See #NEORV32_CPU_MIE_enum. * @return 0 if success, 1 if error (invalid irq_sel). **************************************************************************/ int neorv32_cpu_irq_enable(uint8_t irq_sel) { if ((irq_sel != CPU_MIE_MSIE) && (irq_sel != CPU_MIE_MTIE) && (irq_sel != CPU_MIE_MEIE) && (irq_sel != CPU_MIE_FIRQ0E) && (irq_sel != CPU_MIE_FIRQ1E) && (irq_sel != CPU_MIE_FIRQ2E) && (irq_sel != CPU_MIE_FIRQ3E)) { return 1; } register uint32_t mask = (uint32_t)(1 << irq_sel); asm volatile ("csrrs zero, mie, %0" : : "r" (mask)); return 0; } /**********************************************************************//** * Disable specific CPU interrupt. * * @param[in] irq_sel CPU interrupt select. See #NEORV32_CPU_MIE_enum. * @return 0 if success, 1 if error (invalid irq_sel). **************************************************************************/ int neorv32_cpu_irq_disable(uint8_t irq_sel) { if ((irq_sel != CPU_MIE_MSIE) && (irq_sel != CPU_MIE_MTIE) && (irq_sel != CPU_MIE_MEIE) && (irq_sel != CPU_MIE_FIRQ0E) && (irq_sel != CPU_MIE_FIRQ1E) && (irq_sel != CPU_MIE_FIRQ2E) && (irq_sel != CPU_MIE_FIRQ3E)) { return 1; } register uint32_t mask = (uint32_t)(1 << irq_sel); asm volatile ("csrrc zero, mie, %0" : : "r" (mask)); return 0; } /**********************************************************************//** * Get cycle count from cycle[h]. * * @note The cycle[h] CSR is shadowed copy of the mcycle[h] CSR. * * @return Current cycle counter (64 bit). **************************************************************************/ uint64_t neorv32_cpu_get_cycle(void) { union { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/2]; } cycles; uint32_t tmp1, tmp2, tmp3; while(1) { tmp1 = neorv32_cpu_csr_read(CSR_CYCLEH); tmp2 = neorv32_cpu_csr_read(CSR_CYCLE); tmp3 = neorv32_cpu_csr_read(CSR_CYCLEH); if (tmp1 == tmp3) { break; } } cycles.uint32[0] = tmp2; cycles.uint32[1] = tmp3; return cycles.uint64; } /**********************************************************************//** * Set mcycle[h] counter. * * @param[in] value New value for mcycle[h] CSR (64-bit). **************************************************************************/ void neorv32_cpu_set_mcycle(uint64_t value) { union { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/2]; } cycles; cycles.uint64 = value; neorv32_cpu_csr_write(CSR_MCYCLE, 0); neorv32_cpu_csr_write(CSR_MCYCLEH, cycles.uint32[1]); neorv32_cpu_csr_write(CSR_MCYCLE, cycles.uint32[0]); } /**********************************************************************//** * Get retired instructions counter from instret[h]. * * @note The instret[h] CSR is shadowed copy of the instret[h] CSR. * * @return Current instructions counter (64 bit). **************************************************************************/ uint64_t neorv32_cpu_get_instret(void) { union { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/2]; } cycles; uint32_t tmp1, tmp2, tmp3; while(1) { tmp1 = neorv32_cpu_csr_read(CSR_INSTRETH); tmp2 = neorv32_cpu_csr_read(CSR_INSTRET); tmp3 = neorv32_cpu_csr_read(CSR_INSTRETH); if (tmp1 == tmp3) { break; } } cycles.uint32[0] = tmp2; cycles.uint32[1] = tmp3; return cycles.uint64; } /**********************************************************************//** * Set retired instructions counter minstret[h]. * * @param[in] value New value for mcycle[h] CSR (64-bit). **************************************************************************/ void neorv32_cpu_set_minstret(uint64_t value) { union { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/2]; } cycles; cycles.uint64 = value; neorv32_cpu_csr_write(CSR_MINSTRET, 0); neorv32_cpu_csr_write(CSR_MINSTRETH, cycles.uint32[1]); neorv32_cpu_csr_write(CSR_MINSTRET, cycles.uint32[0]); } /**********************************************************************//** * Get current system time from time[h] CSR. * * @note This function requires the MTIME system timer to be implemented. * * @return Current system time (64 bit). **************************************************************************/ uint64_t neorv32_cpu_get_systime(void) { union { uint64_t uint64; uint32_t uint32[sizeof(uint64_t)/2]; } cycles; uint32_t tmp1, tmp2, tmp3; while(1) { tmp1 = neorv32_cpu_csr_read(CSR_TIMEH); tmp2 = neorv32_cpu_csr_read(CSR_TIME); tmp3 = neorv32_cpu_csr_read(CSR_TIMEH); if (tmp1 == tmp3) { break; } } cycles.uint32[0] = tmp2; cycles.uint32[1] = tmp3; return cycles.uint64; } /**********************************************************************//** * Simple delay function (not very precise) using busy wait. * * @param[in] time_ms Time in ms to wait. **************************************************************************/ void neorv32_cpu_delay_ms(uint32_t time_ms) { uint32_t clock_speed = SYSINFO_CLK >> 10; // fake divide by 1000 clock_speed = clock_speed >> 5; // divide by loop execution time (~30 cycles) uint32_t cnt = clock_speed * time_ms; // one iteration = ~30 cycles while (cnt) { asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); cnt--; } } /**********************************************************************//** * Switch from privilege mode MACHINE to privilege mode USER. * * @note This function requires the U extension to be implemented. * @note Maybe you should do a fence.i after this. **************************************************************************/ void __attribute__((naked)) neorv32_cpu_goto_user_mode(void) { register uint32_t mask = (1<<CPU_MSTATUS_MPP_H) | (1<<CPU_MSTATUS_MPP_L); asm volatile ("csrrc zero, mstatus, %[input_j]" : : [input_j] "r" (mask)); // return switching to user mode asm volatile ("csrw mepc, ra"); asm volatile ("mret"); }
38.48249
129
0.480384
74b7f9155d7cc9394f8fdf4a143805e4db1f6536
3,037
h
C
oneEngine/oneGame/source/m04-editor/standalone/seqeditor/NodeBoardState.h
skarik/1Engine
84e846544b4a89af8fd7e9236131363096538ef4
[ "BSD-3-Clause" ]
8
2017-12-08T02:59:31.000Z
2022-02-02T04:30:03.000Z
oneEngine/oneGame/source/m04-editor/standalone/seqeditor/NodeBoardState.h
skarik/1Engine
84e846544b4a89af8fd7e9236131363096538ef4
[ "BSD-3-Clause" ]
2
2021-04-16T03:44:42.000Z
2021-08-30T06:48:44.000Z
oneEngine/oneGame/source/m04-editor/standalone/seqeditor/NodeBoardState.h
skarik/1Engine
84e846544b4a89af8fd7e9236131363096538ef4
[ "BSD-3-Clause" ]
1
2021-04-16T02:09:54.000Z
2021-04-16T02:09:54.000Z
#ifndef M04_EDITORS_SEQUENCE_EDITOR_NODE_BOARD_STATE_H_ #define M04_EDITORS_SEQUENCE_EDITOR_NODE_BOARD_STATE_H_ #include "SequenceNode.h" #include "core/math/Vector3.h" #include "core-ext/containers/arguid.h" #include "m04/eventide/UserInterface.h" namespace m04 { namespace editor { class SequenceEditor; }} namespace m04 { namespace editor { namespace sequence { class INodeDisplay; class ISequenceSerializer; class ISequenceDeserializer; struct BoardNode { public: // Actual data contained in the node SequenceNode* sequenceInfo; // Position the node is at Vector3f position; // GUID of the node arguid32 guid; // Associated Eventide element used to render the object. // Not owned by this object. INodeDisplay* display; public: EDITOR_API void SetPosition ( const Vector3f& new_position ) { position = new_position; } // PushEditorData() : Pushes the editor data to the sequence node's keyvalues. EDITOR_API void PushEditorData ( void ); // FreeData() : Frees associated SequenceNode and other information. EDITOR_API void FreeData ( void ); public: // DebugDumpOSF() : Calls PushEditorData, then dumps out current keyvalues into stdout. EDITOR_API void DebugDumpOSF ( void ); }; class INodeDisplay { public: INodeDisplay(BoardNode* in_node) : node(in_node) {} BoardNode* GetBoardNode ( void ) { return node; } protected: BoardNode* node; }; // Board state contains all the nodes for the current sequence, as well as the visuals and ids class NodeBoardState { public: explicit NodeBoardState ( m04::editor::SequenceEditor* editor ); // AddDisplayNode( board_node ) : Adds node to display. Allocates and sets up a proper display object. void AddDisplayNode ( BoardNode* board_node ); // UnhookNode( board_node ) : Removes links to this node. // Searches through all the flow, sync, and output of everything in the board. void UnhookNode ( BoardNode* board_node ); // RemoveNode( board_node ) : Removes node from the board. void RemoveDisplayNode ( BoardNode* board_node ); // Save( serializer ) : Saves board state with the given serializer. void Save ( ISequenceSerializer* serializer ); // Load( deserializer ) : Clears board state, then loads board state with given serializer. // Any invalid nodes are still loaded, but with a severely-limited view. Since the views are mostly untouched, their data is preserved. void Load ( ISequenceDeserializer* deserializer ); // ClearAllNodes() : Clears all nodes from the board state. void ClearAllNodes ( void ); public: m04::editor::SequenceEditor* GetEditor ( void ) { return parent_editor; } public: std::vector<BoardNode*> nodes; std::vector<INodeDisplay*> display; std::vector<arguid32*> node_guids; protected: ui::eventide::UserInterface* ui; m04::editor::SequenceEditor* parent_editor; }; }}} #endif//M04_EDITORS_SEQUENCE_EDITOR_NODE_BOARD_STATE_H_
25.957265
137
0.718143
1c3065271e2afe9b3271e4cd7bcb79b289103a33
1,098
h
C
Example/Pods/Headers/Public/CDASyncService/CDACoreDataStackProtocol.h
Codedazur/sync-process-ios
8fd12da4a56456c3b97dc91c5b7c09838e9bc44b
[ "MIT" ]
null
null
null
Example/Pods/Headers/Public/CDASyncService/CDACoreDataStackProtocol.h
Codedazur/sync-process-ios
8fd12da4a56456c3b97dc91c5b7c09838e9bc44b
[ "MIT" ]
null
null
null
Example/Pods/Headers/Public/CDASyncService/CDACoreDataStackProtocol.h
Codedazur/sync-process-ios
8fd12da4a56456c3b97dc91c5b7c09838e9bc44b
[ "MIT" ]
null
null
null
// // CDACoreDataStackProtocol.h // Pods // // Created by Tamara Bernad on 08/04/16. // // #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @protocol CDACoreDataStackProtocol <NSObject> @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; - (instancetype)initWithModelName:(NSString *)modelName; - (void)saveMainContext; - (NSManagedObject *_Nullable) createNewEntity:(NSString *)entity inContext:(NSManagedObjectContext *)context; - (NSManagedObjectContext *)independentManagedObjectContext; - (NSManagedObject *_Nullable)fetchEntity:(NSString *)entity WithPredicate:(NSPredicate *)predicate InContext:(NSManagedObjectContext *)context; - (NSArray * _Nullable)fetchEntities:(NSString *)entity WithSortKey:(NSString * _Nullable)sortKey Ascending:(BOOL)ascending WithPredicate:( NSPredicate * _Nullable )predicate InContext:(NSManagedObjectContext *)context; @end
43.92
219
0.807832
ea45947f0d4cd4fe93c9cbef7ec1908333a2c93d
24,847
h
C
aws-cpp-sdk-nimble/include/aws/nimble/model/CreateStudioComponentRequest.h
fboranek/aws-sdk-cpp
2aa01e7d5c5431d9702caf9bf21f4e07b6ef15ae
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-nimble/include/aws/nimble/model/CreateStudioComponentRequest.h
fboranek/aws-sdk-cpp
2aa01e7d5c5431d9702caf9bf21f4e07b6ef15ae
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-nimble/include/aws/nimble/model/CreateStudioComponentRequest.h
fboranek/aws-sdk-cpp
2aa01e7d5c5431d9702caf9bf21f4e07b6ef15ae
[ "Apache-2.0" ]
null
null
null
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/nimble/NimbleStudio_EXPORTS.h> #include <aws/nimble/NimbleStudioRequest.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/nimble/model/StudioComponentConfiguration.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/nimble/model/StudioComponentSubtype.h> #include <aws/core/utils/memory/stl/AWSMap.h> #include <aws/nimble/model/StudioComponentType.h> #include <aws/nimble/model/StudioComponentInitializationScript.h> #include <aws/nimble/model/ScriptParameterKeyValue.h> #include <utility> #include <aws/core/utils/UUID.h> namespace Aws { namespace NimbleStudio { namespace Model { /** * <p>The studio components.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/nimble-2020-08-01/CreateStudioComponentRequest">AWS * API Reference</a></p> */ class AWS_NIMBLESTUDIO_API CreateStudioComponentRequest : public NimbleStudioRequest { public: CreateStudioComponentRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "CreateStudioComponent"; } Aws::String SerializePayload() const override; Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override; /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline const Aws::String& GetClientToken() const{ return m_clientToken; } /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline bool ClientTokenHasBeenSet() const { return m_clientTokenHasBeenSet; } /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline void SetClientToken(const Aws::String& value) { m_clientTokenHasBeenSet = true; m_clientToken = value; } /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline void SetClientToken(Aws::String&& value) { m_clientTokenHasBeenSet = true; m_clientToken = std::move(value); } /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline void SetClientToken(const char* value) { m_clientTokenHasBeenSet = true; m_clientToken.assign(value); } /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline CreateStudioComponentRequest& WithClientToken(const Aws::String& value) { SetClientToken(value); return *this;} /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline CreateStudioComponentRequest& WithClientToken(Aws::String&& value) { SetClientToken(std::move(value)); return *this;} /** * <p>To make an idempotent API request using one of these actions, specify a * client token in the request. You should not reuse the same client token for * other API requests. If you retry a request that completed successfully using the * same client token and the same parameters, the retry succeeds without performing * any further actions. If you retry a successful request using the same client * token, but one or more of the parameters are different, the retry fails with a * ValidationException error.</p> */ inline CreateStudioComponentRequest& WithClientToken(const char* value) { SetClientToken(value); return *this;} /** * <p>The configuration of the studio component, based on component type.</p> */ inline const StudioComponentConfiguration& GetConfiguration() const{ return m_configuration; } /** * <p>The configuration of the studio component, based on component type.</p> */ inline bool ConfigurationHasBeenSet() const { return m_configurationHasBeenSet; } /** * <p>The configuration of the studio component, based on component type.</p> */ inline void SetConfiguration(const StudioComponentConfiguration& value) { m_configurationHasBeenSet = true; m_configuration = value; } /** * <p>The configuration of the studio component, based on component type.</p> */ inline void SetConfiguration(StudioComponentConfiguration&& value) { m_configurationHasBeenSet = true; m_configuration = std::move(value); } /** * <p>The configuration of the studio component, based on component type.</p> */ inline CreateStudioComponentRequest& WithConfiguration(const StudioComponentConfiguration& value) { SetConfiguration(value); return *this;} /** * <p>The configuration of the studio component, based on component type.</p> */ inline CreateStudioComponentRequest& WithConfiguration(StudioComponentConfiguration&& value) { SetConfiguration(std::move(value)); return *this;} /** * <p>The description.</p> */ inline const Aws::String& GetDescription() const{ return m_description; } /** * <p>The description.</p> */ inline bool DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; } /** * <p>The description.</p> */ inline void SetDescription(const Aws::String& value) { m_descriptionHasBeenSet = true; m_description = value; } /** * <p>The description.</p> */ inline void SetDescription(Aws::String&& value) { m_descriptionHasBeenSet = true; m_description = std::move(value); } /** * <p>The description.</p> */ inline void SetDescription(const char* value) { m_descriptionHasBeenSet = true; m_description.assign(value); } /** * <p>The description.</p> */ inline CreateStudioComponentRequest& WithDescription(const Aws::String& value) { SetDescription(value); return *this;} /** * <p>The description.</p> */ inline CreateStudioComponentRequest& WithDescription(Aws::String&& value) { SetDescription(std::move(value)); return *this;} /** * <p>The description.</p> */ inline CreateStudioComponentRequest& WithDescription(const char* value) { SetDescription(value); return *this;} /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline const Aws::Vector<Aws::String>& GetEc2SecurityGroupIds() const{ return m_ec2SecurityGroupIds; } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline bool Ec2SecurityGroupIdsHasBeenSet() const { return m_ec2SecurityGroupIdsHasBeenSet; } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline void SetEc2SecurityGroupIds(const Aws::Vector<Aws::String>& value) { m_ec2SecurityGroupIdsHasBeenSet = true; m_ec2SecurityGroupIds = value; } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline void SetEc2SecurityGroupIds(Aws::Vector<Aws::String>&& value) { m_ec2SecurityGroupIdsHasBeenSet = true; m_ec2SecurityGroupIds = std::move(value); } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline CreateStudioComponentRequest& WithEc2SecurityGroupIds(const Aws::Vector<Aws::String>& value) { SetEc2SecurityGroupIds(value); return *this;} /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline CreateStudioComponentRequest& WithEc2SecurityGroupIds(Aws::Vector<Aws::String>&& value) { SetEc2SecurityGroupIds(std::move(value)); return *this;} /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline CreateStudioComponentRequest& AddEc2SecurityGroupIds(const Aws::String& value) { m_ec2SecurityGroupIdsHasBeenSet = true; m_ec2SecurityGroupIds.push_back(value); return *this; } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline CreateStudioComponentRequest& AddEc2SecurityGroupIds(Aws::String&& value) { m_ec2SecurityGroupIdsHasBeenSet = true; m_ec2SecurityGroupIds.push_back(std::move(value)); return *this; } /** * <p>The EC2 security groups that control access to the studio component.</p> */ inline CreateStudioComponentRequest& AddEc2SecurityGroupIds(const char* value) { m_ec2SecurityGroupIdsHasBeenSet = true; m_ec2SecurityGroupIds.push_back(value); return *this; } /** * <p>Initialization scripts for studio components.</p> */ inline const Aws::Vector<StudioComponentInitializationScript>& GetInitializationScripts() const{ return m_initializationScripts; } /** * <p>Initialization scripts for studio components.</p> */ inline bool InitializationScriptsHasBeenSet() const { return m_initializationScriptsHasBeenSet; } /** * <p>Initialization scripts for studio components.</p> */ inline void SetInitializationScripts(const Aws::Vector<StudioComponentInitializationScript>& value) { m_initializationScriptsHasBeenSet = true; m_initializationScripts = value; } /** * <p>Initialization scripts for studio components.</p> */ inline void SetInitializationScripts(Aws::Vector<StudioComponentInitializationScript>&& value) { m_initializationScriptsHasBeenSet = true; m_initializationScripts = std::move(value); } /** * <p>Initialization scripts for studio components.</p> */ inline CreateStudioComponentRequest& WithInitializationScripts(const Aws::Vector<StudioComponentInitializationScript>& value) { SetInitializationScripts(value); return *this;} /** * <p>Initialization scripts for studio components.</p> */ inline CreateStudioComponentRequest& WithInitializationScripts(Aws::Vector<StudioComponentInitializationScript>&& value) { SetInitializationScripts(std::move(value)); return *this;} /** * <p>Initialization scripts for studio components.</p> */ inline CreateStudioComponentRequest& AddInitializationScripts(const StudioComponentInitializationScript& value) { m_initializationScriptsHasBeenSet = true; m_initializationScripts.push_back(value); return *this; } /** * <p>Initialization scripts for studio components.</p> */ inline CreateStudioComponentRequest& AddInitializationScripts(StudioComponentInitializationScript&& value) { m_initializationScriptsHasBeenSet = true; m_initializationScripts.push_back(std::move(value)); return *this; } /** * <p>The name for the studio component.</p> */ inline const Aws::String& GetName() const{ return m_name; } /** * <p>The name for the studio component.</p> */ inline bool NameHasBeenSet() const { return m_nameHasBeenSet; } /** * <p>The name for the studio component.</p> */ inline void SetName(const Aws::String& value) { m_nameHasBeenSet = true; m_name = value; } /** * <p>The name for the studio component.</p> */ inline void SetName(Aws::String&& value) { m_nameHasBeenSet = true; m_name = std::move(value); } /** * <p>The name for the studio component.</p> */ inline void SetName(const char* value) { m_nameHasBeenSet = true; m_name.assign(value); } /** * <p>The name for the studio component.</p> */ inline CreateStudioComponentRequest& WithName(const Aws::String& value) { SetName(value); return *this;} /** * <p>The name for the studio component.</p> */ inline CreateStudioComponentRequest& WithName(Aws::String&& value) { SetName(std::move(value)); return *this;} /** * <p>The name for the studio component.</p> */ inline CreateStudioComponentRequest& WithName(const char* value) { SetName(value); return *this;} /** * <p>Parameters for the studio component scripts.</p> */ inline const Aws::Vector<ScriptParameterKeyValue>& GetScriptParameters() const{ return m_scriptParameters; } /** * <p>Parameters for the studio component scripts.</p> */ inline bool ScriptParametersHasBeenSet() const { return m_scriptParametersHasBeenSet; } /** * <p>Parameters for the studio component scripts.</p> */ inline void SetScriptParameters(const Aws::Vector<ScriptParameterKeyValue>& value) { m_scriptParametersHasBeenSet = true; m_scriptParameters = value; } /** * <p>Parameters for the studio component scripts.</p> */ inline void SetScriptParameters(Aws::Vector<ScriptParameterKeyValue>&& value) { m_scriptParametersHasBeenSet = true; m_scriptParameters = std::move(value); } /** * <p>Parameters for the studio component scripts.</p> */ inline CreateStudioComponentRequest& WithScriptParameters(const Aws::Vector<ScriptParameterKeyValue>& value) { SetScriptParameters(value); return *this;} /** * <p>Parameters for the studio component scripts.</p> */ inline CreateStudioComponentRequest& WithScriptParameters(Aws::Vector<ScriptParameterKeyValue>&& value) { SetScriptParameters(std::move(value)); return *this;} /** * <p>Parameters for the studio component scripts.</p> */ inline CreateStudioComponentRequest& AddScriptParameters(const ScriptParameterKeyValue& value) { m_scriptParametersHasBeenSet = true; m_scriptParameters.push_back(value); return *this; } /** * <p>Parameters for the studio component scripts.</p> */ inline CreateStudioComponentRequest& AddScriptParameters(ScriptParameterKeyValue&& value) { m_scriptParametersHasBeenSet = true; m_scriptParameters.push_back(std::move(value)); return *this; } /** * <p>The studio ID.</p> */ inline const Aws::String& GetStudioId() const{ return m_studioId; } /** * <p>The studio ID.</p> */ inline bool StudioIdHasBeenSet() const { return m_studioIdHasBeenSet; } /** * <p>The studio ID.</p> */ inline void SetStudioId(const Aws::String& value) { m_studioIdHasBeenSet = true; m_studioId = value; } /** * <p>The studio ID.</p> */ inline void SetStudioId(Aws::String&& value) { m_studioIdHasBeenSet = true; m_studioId = std::move(value); } /** * <p>The studio ID.</p> */ inline void SetStudioId(const char* value) { m_studioIdHasBeenSet = true; m_studioId.assign(value); } /** * <p>The studio ID.</p> */ inline CreateStudioComponentRequest& WithStudioId(const Aws::String& value) { SetStudioId(value); return *this;} /** * <p>The studio ID.</p> */ inline CreateStudioComponentRequest& WithStudioId(Aws::String&& value) { SetStudioId(std::move(value)); return *this;} /** * <p>The studio ID.</p> */ inline CreateStudioComponentRequest& WithStudioId(const char* value) { SetStudioId(value); return *this;} /** * <p>The specific subtype of a studio component.</p> */ inline const StudioComponentSubtype& GetSubtype() const{ return m_subtype; } /** * <p>The specific subtype of a studio component.</p> */ inline bool SubtypeHasBeenSet() const { return m_subtypeHasBeenSet; } /** * <p>The specific subtype of a studio component.</p> */ inline void SetSubtype(const StudioComponentSubtype& value) { m_subtypeHasBeenSet = true; m_subtype = value; } /** * <p>The specific subtype of a studio component.</p> */ inline void SetSubtype(StudioComponentSubtype&& value) { m_subtypeHasBeenSet = true; m_subtype = std::move(value); } /** * <p>The specific subtype of a studio component.</p> */ inline CreateStudioComponentRequest& WithSubtype(const StudioComponentSubtype& value) { SetSubtype(value); return *this;} /** * <p>The specific subtype of a studio component.</p> */ inline CreateStudioComponentRequest& WithSubtype(StudioComponentSubtype&& value) { SetSubtype(std::move(value)); return *this;} /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline const Aws::Map<Aws::String, Aws::String>& GetTags() const{ return m_tags; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline bool TagsHasBeenSet() const { return m_tagsHasBeenSet; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline void SetTags(const Aws::Map<Aws::String, Aws::String>& value) { m_tagsHasBeenSet = true; m_tags = value; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline void SetTags(Aws::Map<Aws::String, Aws::String>&& value) { m_tagsHasBeenSet = true; m_tags = std::move(value); } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& WithTags(const Aws::Map<Aws::String, Aws::String>& value) { SetTags(value); return *this;} /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& WithTags(Aws::Map<Aws::String, Aws::String>&& value) { SetTags(std::move(value)); return *this;} /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(const Aws::String& key, const Aws::String& value) { m_tagsHasBeenSet = true; m_tags.emplace(key, value); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(Aws::String&& key, const Aws::String& value) { m_tagsHasBeenSet = true; m_tags.emplace(std::move(key), value); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(const Aws::String& key, Aws::String&& value) { m_tagsHasBeenSet = true; m_tags.emplace(key, std::move(value)); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(Aws::String&& key, Aws::String&& value) { m_tagsHasBeenSet = true; m_tags.emplace(std::move(key), std::move(value)); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(const char* key, Aws::String&& value) { m_tagsHasBeenSet = true; m_tags.emplace(key, std::move(value)); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(Aws::String&& key, const char* value) { m_tagsHasBeenSet = true; m_tags.emplace(std::move(key), value); return *this; } /** * <p>A collection of labels, in the form of key:value pairs, that apply to this * resource.</p> */ inline CreateStudioComponentRequest& AddTags(const char* key, const char* value) { m_tagsHasBeenSet = true; m_tags.emplace(key, value); return *this; } /** * <p>The type of the studio component.</p> */ inline const StudioComponentType& GetType() const{ return m_type; } /** * <p>The type of the studio component.</p> */ inline bool TypeHasBeenSet() const { return m_typeHasBeenSet; } /** * <p>The type of the studio component.</p> */ inline void SetType(const StudioComponentType& value) { m_typeHasBeenSet = true; m_type = value; } /** * <p>The type of the studio component.</p> */ inline void SetType(StudioComponentType&& value) { m_typeHasBeenSet = true; m_type = std::move(value); } /** * <p>The type of the studio component.</p> */ inline CreateStudioComponentRequest& WithType(const StudioComponentType& value) { SetType(value); return *this;} /** * <p>The type of the studio component.</p> */ inline CreateStudioComponentRequest& WithType(StudioComponentType&& value) { SetType(std::move(value)); return *this;} private: Aws::String m_clientToken; bool m_clientTokenHasBeenSet; StudioComponentConfiguration m_configuration; bool m_configurationHasBeenSet; Aws::String m_description; bool m_descriptionHasBeenSet; Aws::Vector<Aws::String> m_ec2SecurityGroupIds; bool m_ec2SecurityGroupIdsHasBeenSet; Aws::Vector<StudioComponentInitializationScript> m_initializationScripts; bool m_initializationScriptsHasBeenSet; Aws::String m_name; bool m_nameHasBeenSet; Aws::Vector<ScriptParameterKeyValue> m_scriptParameters; bool m_scriptParametersHasBeenSet; Aws::String m_studioId; bool m_studioIdHasBeenSet; StudioComponentSubtype m_subtype; bool m_subtypeHasBeenSet; Aws::Map<Aws::String, Aws::String> m_tags; bool m_tagsHasBeenSet; StudioComponentType m_type; bool m_typeHasBeenSet; }; } // namespace Model } // namespace NimbleStudio } // namespace Aws
41.550167
223
0.695899
e36aae1befc6b152f7d9116c7c05b1aceeaeab3d
4,630
c
C
transmitter/transmitter.c
congngale/MSP430_E19868M30S
ea5c616c39c44a1ae51e11d5d8dbc38f941f5890
[ "MIT" ]
null
null
null
transmitter/transmitter.c
congngale/MSP430_E19868M30S
ea5c616c39c44a1ae51e11d5d8dbc38f941f5890
[ "MIT" ]
null
null
null
transmitter/transmitter.c
congngale/MSP430_E19868M30S
ea5c616c39c44a1ae51e11d5d8dbc38f941f5890
[ "MIT" ]
null
null
null
/* * transmitter.c * * Created on: 07.08.2018 * Author: baeumker */ #include "transmitter.h" #include "sx1276regs-lora.h" #include "sx1276.h" #include "custom.h" static radio_events_t radio_events; //---------- Functions for reaction of different events -------------- // Should be later be put in other places void OnTxDone() { } void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { } void OnRxError() { } //---------------------------------------------------------------------- // ---- Own fields --------- char paConfig = 0; //----- Own functions ----------- void rf_waitTillIdle(){ while(sx1276.Settings.State != RF_IDLE); } void rf_setPAPower(int pa_power){ #ifdef RFM95 if( pa_power > 17 ) pa_power = 2; paConfig = sx1276_read(REG_LR_PACONFIG); paConfig = (paConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK) | (uint8_t) ((uint16_t) (pa_power - 2) & 0x0F); sx1276_write(REG_LR_PACONFIG, paConfig); #else if( pa_power > 14 ) pa_power = -1; paConfig = sx1276_read(REG_LR_PACONFIG); paConfig = (paConfig & RFLR_PACONFIG_OUTPUTPOWER_MASK) | (uint8_t) ((uint16_t) (pa_power + 1) & 0x0F); sx1276_write(REG_LR_PACONFIG, paConfig); #endif } void rf_setSpreadingF(int sf){ if(sf > 12) sf = 7; char LowDatarateOptimize = 0; if((sf == 11) || (sf == 12)) { LowDatarateOptimize = 0x01; } else { LowDatarateOptimize = 0x00; } sx1276_write(REG_LR_MODEMCONFIG2, (sx1276_read(REG_LR_MODEMCONFIG2) & RFLR_MODEMCONFIG2_SF_MASK) | (sf << 4)); sx1276_write(REG_LR_MODEMCONFIG3, (sx1276_read(REG_LR_MODEMCONFIG3) & RFLR_MODEMCONFIG3_LOWDATARATEOPTIMIZE_MASK ) | (LowDatarateOptimize << 3)); } //--------------- /* * Initialises all necessary stuff for the transmitter */ void rf_init_lora() { radio_events.TxDone = OnTxDone; radio_events.RxDone = OnRxDone; //radio_events.TxTimeout = OnTxTimeout; //radio_events.RxTimeout = OnRxTimeout; radio_events.RxError = OnRxError; sx1276_init(radio_events); sx1276_set_channel(RF_FREQUENCY); sx1276_set_txconfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, LORA_CODINGRATE, LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, true, 0, 0, LORA_IQ_INVERSION_ON, 3000); #ifndef REDUCED sx1276_set_rxconfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH, LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON, 0, true, 0, 0, LORA_IQ_INVERSION_ON, true); #endif // Full buffer used for Tx sx1276_write(REG_LR_FIFOTXBASEADDR, 0); sx1276_write(REG_LR_FIFOADDRPTR, 0); // Channel for LoRaWAN network sx1276_write(REG_LR_SYNCWORD, 0x34); sx1276_write(REG_LR_FRFMSB, 0xD8); sx1276_write(REG_LR_FRFMID, 0xEC); sx1276_write(REG_LR_FRFLSB, 0xCC); #ifdef REDUCED // One-time Pre-Configurations for Sending ------------------------------------------------------ // Write: 5 Bytes --> 10 Bytes total as every time address + Byte // Read: 1 Byte -> 2 Bytes for reading //....... .> 12 Bytes, everytime CS sx1276_write(REG_LR_INVERTIQ2, RFLR_INVERTIQ2_ON ); sx1276_write(REG_LR_INVERTIQ, 0x67); // InvertIQ Enabled (bit 6) | default_value (0x27) = 0x67 #ifdef TTN sx1276.Settings.LoRaPacketHandler.Size = PHY_PAYLOAD_SIZE; sx1276_write(REG_LR_PAYLOADLENGTH, PHY_PAYLOAD_SIZE); // Initializes the payload size #else sx1276.Settings.LoRaPacketHandler.Size = PAYLOAD_SIZE; sx1276_write(REG_LR_PAYLOADLENGTH, PAYLOAD_SIZE); // Initializes the payload size #endif sx1276_write(REG_LR_IRQFLAGSMASK, RFLR_IRQFLAGS_RXTIMEOUT | RFLR_IRQFLAGS_RXDONE | RFLR_IRQFLAGS_PAYLOADCRCERROR | RFLR_IRQFLAGS_VALIDHEADER | //RFLR_IRQFLAGS_TXDONE | RFLR_IRQFLAGS_CADDONE | RFLR_IRQFLAGS_FHSSCHANGEDCHANNEL | RFLR_IRQFLAGS_CADDETECTED ); // DIO0=TxDone sx1276_write(REG_LR_DIOMAPPING1, (sx1276_read(REG_LR_DIOMAPPING1) & RFLR_DIOMAPPING1_DIO0_MASK) | RFLR_DIOMAPPING1_DIO0_01); //------------------------------------------------------------------------------------------- #endif sx1276_set_opmode(RFLR_OPMODE_SLEEP); }
34.81203
158
0.609935
2d411f57a24ad9981024398a9fc74d90b19586bb
214
h
C
ButtonCategory/ButtonCategory/ViewController.h
SunXu231/UIButton-SXImagePositon
40bd2532e3f99276b791698c4e9af6b926e20d3b
[ "MIT" ]
5
2017-06-30T05:42:39.000Z
2017-07-04T07:14:59.000Z
ButtonCategory/ButtonCategory/ViewController.h
jokerxsun/UIButton-SXImagePositon
40bd2532e3f99276b791698c4e9af6b926e20d3b
[ "MIT" ]
1
2017-10-26T03:51:03.000Z
2017-10-26T06:44:14.000Z
ButtonCategory/ButtonCategory/ViewController.h
SunXu231/UIButton-SXImagePositon
40bd2532e3f99276b791698c4e9af6b926e20d3b
[ "MIT" ]
2
2019-09-04T09:02:24.000Z
2021-02-25T07:48:49.000Z
// // ViewController.h // ButtonCategory // // Created by sunxu on 2017/6/30. // Copyright © 2017年 isunxu. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController @end
13.375
50
0.691589
2d4e8b297966abe6b0a6b38fd8e8528e24ee2eb4
6,636
c
C
lsp_shiloh/common/scan/lsp/apps/mkdevscan.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/common/scan/lsp/apps/mkdevscan.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
lsp_shiloh/common/scan/lsp/apps/mkdevscan.c
internaru/Pinetree_P
1f1525454c8b20c6c589529ff4bc159404611297
[ "FSFAP" ]
null
null
null
/* * ============================================================================ * Copyright (c) 2012 Marvell International, Ltd. All Rights Reserved * * Marvell Confidential * ============================================================================ */ /** * \file mkdevscan.c * * \brief Create /dev/scanman with a lot of sanity checks. * * Reads /proc/devices looking for scanman. Creates /dev/scanman with the major * id if it doesn't already exist. * * davep 06-Sep-2012 */ #include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <limits.h> #define DEBUG 1 #include "utils.h" #include "scantypes.h" #include "scandbg.h" /* version string displayed in the usage */ #define PROGRAM_VERSION "0.0.1" #define MODULE_NAME "scanman" #define DEV_NAME "/dev/"MODULE_NAME static int g_debug_level=0; scan_err_t find_device_number( const char *name, int *devnum ) { scan_err_t final_scerr; int retcode; FILE *f; char line[80]; int linelen, module_name_len; char *ptr_list[20]; uint32_t longnum; dbg2( "%s\n", __FUNCTION__); f = fopen( "/proc/devices", "r" ); if( f==NULL ) { dbg1( "%s unable to open /proc/devices : %s\n", __FUNCTION__, strerror(errno) ); return SCANERR_NO_ENTRY; } dbg2( "%s opened /proc/devices\n", __FUNCTION__ ); module_name_len = strlen(MODULE_NAME); final_scerr = SCANERR_NO_ENTRY; memset( line, 0, sizeof(line) ); while( !feof(f) ) { fgets( line, 79, f ); linelen = strnlen( line, 79 ); str_chomp( line, &linelen ); retcode = str_split( line, linelen, ptr_list, 20, " " ); if( retcode != 2 ) { continue; } if( !str_match( ptr_list[1], MODULE_NAME, module_name_len ) ) { continue; } dbg1( "%s found \%s\"\n", __FUNCTION__, MODULE_NAME ); retcode = str_mkint( ptr_list[0], &longnum ); if( retcode == 0 ) { if( longnum > INT_MAX ) { dbg1( "%s invalid integer \"%s\"\n", __FUNCTION__, ptr_list[0] ); } else { *devnum = (int)longnum; final_scerr = SCANERR_NONE; } } break; } if( final_scerr != SCANERR_NONE ) { dbg1( "%s error: unable to find \"scanman\" in /proc/devices\n", __FUNCTION__ ); } fclose( f ); return final_scerr; } scan_err_t verify_device_path( const char *path, dev_t dev_num ) { int retcode; struct stat statbuf; dbg2( "%s \"%s\"\n", __FUNCTION__, path ); memset( &statbuf, 0, sizeof(struct stat) ); /* verify file exists */ retcode = stat( path, &statbuf ); if( retcode != 0 ) { dbg1( "%s \"%s\" : %s\n", __FUNCTION__, path, strerror(errno) ); return SCANERR_NO_ENTRY; } dbg2( "%s \"%s\" exists\n", __FUNCTION__, path ); /* verify it's a dev node & has the proper dev number */ if( ! S_ISCHR( statbuf.st_mode ) ) { dbg2( "%s \"%s\" is not a character device file\n", __FUNCTION__, path ); return SCANERR_INVALID_PARAM; } dbg2( "%s \"%s\" is a character device\n", __FUNCTION__, path ); if( statbuf.st_rdev != dev_num ) { dbg2( "%s \"%s\" wrong device; want=(%d,%d) have=(%d,%d)\n", __FUNCTION__, path, major(dev_num), minor(dev_num), major(statbuf.st_rdev), minor(statbuf.st_rdev) ); return SCANERR_INVALID_PARAM; } dbg2( "%s \"%s\" has the proper device numbers (%d,%d)\n", __FUNCTION__, path, major(statbuf.st_rdev), minor(statbuf.st_rdev) ); return SCANERR_NONE; } scan_err_t make_device( const char *path, dev_t dev_num ) { int retcode; dbg1( "%s \"%s\"\n", __FUNCTION__, path ); /* create it */ retcode = mknod( path, S_IFCHR|S_IRUSR|S_IWUSR, dev_num ); if( retcode != 0 ) { dbg1( "%s mknod() failed : %s\n", __FUNCTION__, strerror(errno) ); return SCANERR_NO_ENTRY; } dbg1( "%s device node \"%s\" successfully created\n", __FUNCTION__, path ); return SCANERR_NONE; } scan_err_t create_dev_scanman( void ) { scan_err_t scerr; int major_num; dev_t dev_num; dbg2( "%s\n", __FUNCTION__); /* find the number for scanman */ scerr = find_device_number( MODULE_NAME, &major_num ); if( scerr != SCANERR_NONE ) { return scerr; } dbg2( "%s found major_num=%d\n", __FUNCTION__, major_num ); dev_num = makedev( major_num, 0 ); /* does it already exist? */ scerr = verify_device_path( DEV_NAME, dev_num ); if( scerr==SCANERR_NONE ) { /* file exists and is the proper type so we're done here */ dbg2( "%s \"%s\" is ok so we are done\n", __FUNCTION__, DEV_NAME ); return SCANERR_NONE; } if( scerr != SCANERR_NO_ENTRY ) { return scerr; } /* create it */ scerr = make_device( DEV_NAME, dev_num ); if( scerr!=SCANERR_NONE ) { return scerr; } return SCANERR_NONE; } static void usage( const char *progname ) { fprintf( stderr, "%s %s - %s\n", progname, PROGRAM_VERSION, __DATE__ ); fprintf( stderr, "%s - create /dev/scanman for Marvell linux-kernel scanner\n", progname ) ; fprintf( stderr, "usage:\n" ); fprintf( stderr, " -h ; this help text\n" ); fprintf( stderr, " -d ; increase debug log level (can be used multiple times)\n" ); } static scan_err_t parse_args( int argc, char *argv[] ) { int retcode; int opt; while( 1 ) { opt = getopt( argc, argv, "hd" ); if( opt==-1 ) { break; } switch( opt ) { case 'h' : usage(argv[0]); exit( EXIT_SUCCESS ); break; case 'd' : g_debug_level += 1; scanlog_set_level( g_debug_level ); break; default: break; } } return SCANERR_NONE; } int main( int argc, char *argv[] ) { scan_err_t scerr; scanlog_set_level( g_debug_level ); scerr = parse_args( argc, argv ); if( scerr != SCANERR_NONE ) { dbg2( "%s parse_args() failed scerr=%d\n", __FUNCTION__, scerr ); return EXIT_FAILURE; } scerr = create_dev_scanman(); if( scerr != SCANERR_NONE ) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
24.761194
96
0.553647
8750e14235b81d571061de2d5ba37613040eae75
1,416
h
C
modules/standard.net.tlse/src/library.h
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
11
2016-01-24T18:53:36.000Z
2021-01-21T08:59:01.000Z
modules/standard.net.tlse/src/library.h
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
1
2016-01-22T21:38:38.000Z
2016-01-30T17:25:01.000Z
modules/standard.net.tlse/src/library.h
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
null
null
null
#ifndef __LIBRARY_H #define __LIBRARY_H // user definition ... extern "C" { CONCEPT_DLL_API ON_CREATE_CONTEXT MANAGEMENT_PARAMETERS; CONCEPT_DLL_API ON_DESTROY_CONTEXT MANAGEMENT_PARAMETERS; CONCEPT_FUNCTION(TLSEServer) CONCEPT_FUNCTION(TLSEClient) CONCEPT_FUNCTION(TLSEDone) CONCEPT_FUNCTION(TLSEAccept) CONCEPT_FUNCTION(TLSEConnect) CONCEPT_FUNCTION(TLSERequestClientCertificate) CONCEPT_FUNCTION(TLSERead) CONCEPT_FUNCTION(TLSEWrite) CONCEPT_FUNCTION(TLSEConsume) CONCEPT_FUNCTION(TLSEstablished) CONCEPT_FUNCTION(TLSEPending) CONCEPT_FUNCTION(TLSEReadBufferSize) CONCEPT_FUNCTION(TLSESent) CONCEPT_FUNCTION(TLSELoadKeys) CONCEPT_FUNCTION(TLSELoadRootCA) CONCEPT_FUNCTION(TLSEChipher) CONCEPT_FUNCTION(TLSEChipherName) CONCEPT_FUNCTION(TLSEBroken) CONCEPT_FUNCTION(TLSESetExportable) CONCEPT_FUNCTION(TLSEExport) CONCEPT_FUNCTION(TLSEImport) CONCEPT_FUNCTION(TLSEGetSNI) CONCEPT_FUNCTION(TLSESetSNI) CONCEPT_FUNCTION(TLSESetVerify) CONCEPT_FUNCTION(TLSECertificateInfo) CONCEPT_FUNCTION(TLSEShutdown) CONCEPT_FUNCTION(TLSEError) CONCEPT_FUNCTION(TLSEAddALPN) CONCEPT_FUNCTION(TLSEALPN) CONCEPT_FUNCTION(TLSEClearCertificates) CONCEPT_FUNCTION(SRTPInit) CONCEPT_FUNCTION(SRTPEncrypt) CONCEPT_FUNCTION(SRTPDecrypt) CONCEPT_FUNCTION(SRTPDone) } #endif // __LIBRARY_H
30.12766
61
0.79661
0c6a09fd44d3e5a52cce26af6b69aab1fd1f4e46
710
h
C
Example/XWDownloader/XWDownloader/XWDownloaderManager.h
qxuewei/XWDownloader
0a2c8f36db2d2f2fa5a168a06ac5b80106e885bf
[ "MIT" ]
1
2017-02-20T07:10:52.000Z
2017-02-20T07:10:52.000Z
Example/XWDownloader/XWDownloader/XWDownloaderManager.h
qxuewei/XWDownloader
0a2c8f36db2d2f2fa5a168a06ac5b80106e885bf
[ "MIT" ]
null
null
null
Example/XWDownloader/XWDownloader/XWDownloaderManager.h
qxuewei/XWDownloader
0a2c8f36db2d2f2fa5a168a06ac5b80106e885bf
[ "MIT" ]
1
2019-01-10T03:10:34.000Z
2019-01-10T03:10:34.000Z
// // XWDownloaderManager.h // XWDownloader // // Created by 邱学伟 on 2017/2/3. // Copyright © 2017年 Xuewei. All rights reserved. // #import <Foundation/Foundation.h> #import "XWDownloader.h" @interface XWDownloaderManager : NSObject +(instancetype)shareInstance; -(void)downloader:(NSURL *)url downloadInfo:(DownloadInfoBlock)downloadInfo stateChange:(StateChangeBlock)stateChange progressChange:(ProgressChangeBlock)progressChange downloadSuccess:(DownloadSuccessBlock)downloadSuccess downloadFailed:(DownloadFailedBlock)downloadFailed; - (void)pauseWithURL:(NSURL *)url; - (void)resumeWithURL:(NSURL *)url; - (void)cancelWithURL:(NSURL *)url; - (void)pauseAll; - (void)resumeAll; - (void)cancelAll; @end
33.809524
274
0.783099
0c82478f58bb9950f6d798f84116389ad85bad10
308
c
C
recipes/minizip-ng/all/test_package/test_package.c
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
562
2019-09-04T12:23:43.000Z
2022-03-29T16:41:43.000Z
recipes/minizip-ng/all/test_package/test_package.c
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
9,799
2019-09-04T12:02:11.000Z
2022-03-31T23:55:45.000Z
recipes/minizip-ng/all/test_package/test_package.c
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
1,126
2019-09-04T11:57:46.000Z
2022-03-31T16:43:38.000Z
#include <stdlib.h> #include <mz.h> #include <mz_os.h> int main(int argc, char** argv) { char output[256]; memset(output, 'z', sizeof(output)); int32_t err = mz_path_resolve("c:\\test\\.", output, sizeof(output)); int32_t ok = (strcmp(output, "c:\\test\\") == 0); return EXIT_SUCCESS; }
23.692308
73
0.616883
0c82bdb73a139a427526a1c54afc03e754005479
517
h
C
PQType.h
MISabic/Uber
1232d18bf2ffcd8d8de82c744a2736adee0497bf
[ "MIT" ]
null
null
null
PQType.h
MISabic/Uber
1232d18bf2ffcd8d8de82c744a2736adee0497bf
[ "MIT" ]
null
null
null
PQType.h
MISabic/Uber
1232d18bf2ffcd8d8de82c744a2736adee0497bf
[ "MIT" ]
null
null
null
#ifndef PQTYPE_H_INCLUDED #define PQTYPE_H_INCLUDED #include "HeapType.h" using namespace std; class FullPQ{}; class EmptyPQ{}; template<class ItemType> class PQType { public: PQType( ); PQType( int ); ~PQType( ); void MakeEmpty( ); bool IsEmpty( ); bool IsFull( ); int GetSize( ); void Enqueue( ItemType newItem ); void Dequeue( ItemType& item ); private: int length; HeapType<ItemType> items; int maxItems; }; #endif // PQTYPE_H_INCLUDED #include "PQType.cpp"
15.666667
37
0.65764
104735e05c9590220453427c85916eeee432ce62
1,708
c
C
Week 2/Problem Set 2/Lab 2/scrabble/scrabble.c
diegoamato/CS50x-Harvard
68088df4b8e28660c3db2217053fb9bc0ec1b0e6
[ "MIT" ]
1
2022-03-02T21:08:05.000Z
2022-03-02T21:08:05.000Z
Week 2/Problem Set 2/Lab 2/scrabble/scrabble.c
diegoamato/CS50x-Harvard
68088df4b8e28660c3db2217053fb9bc0ec1b0e6
[ "MIT" ]
null
null
null
Week 2/Problem Set 2/Lab 2/scrabble/scrabble.c
diegoamato/CS50x-Harvard
68088df4b8e28660c3db2217053fb9bc0ec1b0e6
[ "MIT" ]
null
null
null
#include <ctype.h> #include <cs50.h> #include <stdio.h> #include <string.h> // Points assigned to each letter of the alphabet int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10}; int LETTERS[] = {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}; int compute_score(string word); int main(void) { // Get input words from both players string word1 = get_string("Player 1: "); string word2 = get_string("Player 2: "); // Score both words int score1 = compute_score(word1); int score2 = compute_score(word2); // Print the winner if (score1 > score2) { printf("Player 1 wins!"); } else if (score1 < score2) { printf("Player 2 wins!"); } else { //For the same scores printf("Tie!"); } printf("\n"); } int compute_score(string word) { //Sum of word scores int sum = 0; // Compute and return score for string for (int i = 0, n = strlen(word); i < n; i++) { if (islower(word[i])) { for (int j = 0; j < 26; j++) { if (word[i] == LETTERS[j]) { sum = sum + POINTS[j]; } } } else if (isupper(word[i])) { word[i] = tolower(word[i]); for (int j = 0; j < 26; j++) { if (word[i] == LETTERS[j]) { sum = sum + POINTS[j]; } } } else { sum = sum + 0; } } return sum; }
22.773333
144
0.449063
dc7067b4b6b5abb812d6808ab2d4740871af3fc1
1,402
c
C
common.c
jonatanlinden/PR
63004cd9679d675b88309c70f9a0021769e63ee7
[ "BSD-3-Clause" ]
13
2015-09-30T01:25:28.000Z
2022-03-28T12:07:29.000Z
common.c
jonatanlinden/PR
63004cd9679d675b88309c70f9a0021769e63ee7
[ "BSD-3-Clause" ]
null
null
null
common.c
jonatanlinden/PR
63004cd9679d675b88309c70f9a0021769e63ee7
[ "BSD-3-Clause" ]
6
2017-04-13T02:49:16.000Z
2021-08-30T10:58:31.000Z
#define _GNU_SOURCE #include "common.h" #if defined(__linux__) pid_t gettid(void) { return (pid_t) syscall(SYS_gettid); } void pin(pid_t t, int cpu) { cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); E_en(sched_setaffinity(t, sizeof(cpu_set_t), &cpuset)); } void gettime(struct timespec *ts) { E(clock_gettime(CLOCK_MONOTONIC, ts)); } #endif #if defined(__APPLE__) void gettime(struct timespec *ts) { uint64_t time = mach_absolute_time(); static mach_timebase_info_data_t info = {0,0}; if (info.denom == 0) { mach_timebase_info(&info); } uint64_t elapsed = time * (info.numer / info.denom); ts->tv_sec = elapsed * 1e-9; ts->tv_nsec = elapsed - (ts->tv_sec * 1e9); } #endif struct timespec timediff (struct timespec begin, struct timespec end) { struct timespec tmp; if ((end.tv_nsec - begin.tv_nsec) < 0) { tmp.tv_sec = end.tv_sec - begin.tv_sec - 1; tmp.tv_nsec = 1000000000 + end.tv_nsec - begin.tv_nsec; } else { tmp.tv_sec = end.tv_sec - begin.tv_sec; tmp.tv_nsec = end.tv_nsec - begin.tv_nsec; } return tmp; } void rng_init (unsigned short rng[3]) { struct timespec time; // finally available in macos 10.12 as well! clock_gettime(CLOCK_REALTIME, &time); /* initialize seed */ rng[0] = time.tv_nsec; rng[1] = time.tv_nsec >> 16; rng[2] = time.tv_nsec >> 32; }
17.974359
59
0.652639
91366379dc377141a5d2f2419210fbb27a4ecee6
566
h
C
h/siglist.h
natalijamitic/OSKernel
e50d9ab28f1b872a2802a6dda907949a77953af9
[ "MIT" ]
null
null
null
h/siglist.h
natalijamitic/OSKernel
e50d9ab28f1b872a2802a6dda907949a77953af9
[ "MIT" ]
null
null
null
h/siglist.h
natalijamitic/OSKernel
e50d9ab28f1b872a2802a6dda907949a77953af9
[ "MIT" ]
null
null
null
/* * siglist.h * * Created on: May 28, 2019 * Author: OS1 */ #ifndef _siglist_h_ #define _siglist_h_ typedef unsigned SignalId; typedef void (*SignalHandler)(); class SignalList { private: struct Element { SignalId data; Element* next; Element(SignalId d); ~Element() { } }; Element* first, * last; friend class PCB; friend class SignalHandlerList; friend class PCB; public: SignalList(); ~SignalList(); void add(SignalId d); void processSignals(PCB* pcb); }; #endif /* SIGLIST_H_ */
13.47619
33
0.618375
916fc1849a4307fa3a7600af17a35e9f81e81916
1,447
h
C
leapAndCamDepthProblem/src/LeapVisualizer.h
jing-interactive/digital_art_2014
736ce10ea3fa92b415c57fa5a1a41a64e6d98622
[ "MIT" ]
1
2019-10-10T12:23:21.000Z
2019-10-10T12:23:21.000Z
leapAndCamRecorder2/src/LeapVisualizer.h
jing-interactive/digital_art_2014
736ce10ea3fa92b415c57fa5a1a41a64e6d98622
[ "MIT" ]
null
null
null
leapAndCamRecorder2/src/LeapVisualizer.h
jing-interactive/digital_art_2014
736ce10ea3fa92b415c57fa5a1a41a64e6d98622
[ "MIT" ]
3
2019-05-02T11:20:41.000Z
2021-07-26T16:38:38.000Z
// // LeapVisualizer.h // leapAndCamRecorder2 // // Created by chris on 28/07/14. // // #pragma once #include "ofMain.h" #include "ofxLeapMotion.h" #include "ofxXmlSettings.h" class LeapVisualizer{ public: void setup(); void loadXmlFile(string fileName); ofPoint getIndexFingertip(ofxLeapMotion & leap); ofPoint getIndexFingertipFromXML(int whichFrame); void drawOrientedCylinder (ofPoint pt0, ofPoint pt1, float radius); void setColorByFinger (Finger::Type fingerType, Bone::Type boneType); void drawGrid(); // xml drawing void drawFrameFromXML(int whichFrame); void drawFrameFromXML(int whichFrame, ofxXmlSettings & myXML); void drawHandFromXML(int whichHand, ofxXmlSettings & XML); void drawFingersFromXML(ofxXmlSettings & XML); void drawFingerFromXML(ofxXmlSettings & XML); void drawPalmFromXML(ofxXmlSettings & XML); void drawArmFromXML(ofxXmlSettings & XML); // live drawing void drawFrame(ofxLeapMotion & leap); void drawHand(Hand & hand,ofxLeapMotion & leap); void drawFingers(Hand & hand,ofxLeapMotion & leap); void drawFinger(const Finger & finger,ofxLeapMotion & leap); void drawBone(const Finger & finger, Bone & bone,ofxLeapMotion & leap); void drawPalm(Hand & hand,ofxLeapMotion & leap); void drawArm(Hand & hand,ofxLeapMotion & leap); ofxXmlSettings XML; bool bDrawSimple; bool bDrawGrid; };
27.301887
75
0.70698
8ca238f576d88d6b6240b7580cd0cf1893dd69e7
2,973
h
C
include/votca/moo/jcalc.h
jimbach/ctp
e5b33f074f81c6e6859dfaacada1b6c992c67c2b
[ "Apache-2.0" ]
null
null
null
include/votca/moo/jcalc.h
jimbach/ctp
e5b33f074f81c6e6859dfaacada1b6c992c67c2b
[ "Apache-2.0" ]
null
null
null
include/votca/moo/jcalc.h
jimbach/ctp
e5b33f074f81c6e6859dfaacada1b6c992c67c2b
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _JCALC_H #define _JCALC_H #include <boost/lexical_cast.hpp> #include <map> #include <stdexcept> #include "crgunittype.h" #include "votca/tools/tokenizer.h" #include "crgunit.h" #include "fock.h" #include <votca/tools/property.h> namespace votca { namespace moo { using namespace boost; class JCalc{ public: JCalc() {}; ~JCalc(); JCalc(string name); CrgUnitType * GetCrgUnitTypeByName(string); void Initialize(const string &file); vector <double> CalcJ (CrgUnit & one, CrgUnit & two); int WriteProJ(CrgUnit & one, CrgUnit & two, string namedir=(string("./")) ); CrgUnit *CreateCrgUnit(int id, const string &type_name, int molid=-1); private: struct JCalcData{ /// the CrgUnitType of the first (will contain coordinates of the still molecules CrgUnitType *_type1; CrgUnitType *_type2; ///variables copied from _type1 and _type2 pair <vector <unsigned int>, vector <unsigned int> > _orblabels; /// the moved coordinates mol_and_orb _mol1; mol_and_orb _mol2; /// the moved orbitals orb _orb1; orb _orb2; /// the fock matrix herself fock _fock; }; /// To parse the xml file Property _options; /// a list of charge transport units vector <CrgUnitType *> _listCrgUnitType; /// a map of charge unit type names to their index in the list map <string, CrgUnitType *> _mapCrgUnitByName; /// map the fock calculators to the pair of integers representing the corresponding charge unit types map <pair<CrgUnitType *, CrgUnitType *> , JCalcData *> _maplistfock; /// Enter data for Crg Unit Types void ParseCrgUnitTypes(Property &options); /// initialise a JCAlcDAta type JCalcData * InitJCalcData(CrgUnitType *, CrgUnitType * ); /// get a J calc data from the map JCalcData * getJCalcData(CrgUnit &, CrgUnit &); }; inline JCalc::JCalc(string name) { Initialize (name); } inline CrgUnit *JCalc::CreateCrgUnit(int id, const string &type_name, int molid) { CrgUnitType *type = GetCrgUnitTypeByName(type_name); if(!type) throw runtime_error("Charge unit type not found: " + type_name); return new CrgUnit(id, type, molid); } }} #endif /* _JCALC_H */
27.275229
105
0.672048
8cc29a03137509776f171d7b83d141cf9faf06e9
708
h
C
src/libcipcm/cwrap.h
wrathematics/pbdPAPI
cb3fad3bccd54b7aeeef9e687b52d938613a356e
[ "Intel", "BSD-3-Clause" ]
8
2015-02-14T17:00:51.000Z
2016-02-01T20:13:43.000Z
src/libcipcm/cwrap.h
QuantScientist3/pbdPAPI
708bee501de20eb82829e03b92b24b6352044f49
[ "Intel", "BSD-3-Clause" ]
null
null
null
src/libcipcm/cwrap.h
QuantScientist3/pbdPAPI
708bee501de20eb82829e03b92b24b6352044f49
[ "Intel", "BSD-3-Clause" ]
3
2015-03-26T13:41:27.000Z
2015-04-01T11:36:34.000Z
#ifndef IPCM_CWRAP_H #define IPCM_CWRAP_H #ifdef __cplusplus extern "C" { #endif enum event_codes{ IPCM_START_EVENT=0, IPCM_L2_TCM=0, IPCM_L2_TCH, IPCM_INS_RET, IPCM_CYC, IPCM_L3_TCH_NS, IPCM_L3_TCH_S, IPCM_L3_TCH, IPCM_L3_TCM, IPCM_NULL_EVENT, }; typedef struct ipcm_event_val_s{ int code; long long val; }ipcm_event_val_t; int ipcm_init(); void ipcm_get_events(); void ipcm_end_events(ipcm_event_val_t *values, const int num); int ipcm_event_avail(const int code); long long ipcm_get_frequency(); int ipcm_get_cpus(); void ipcm_cpu_strings(char *vendor, char *model, char *codename); void ipcm_get_cpuid(int *family, int *model); #ifdef __cplusplus } #endif #endif
18.153846
66
0.754237
bce7913dc860bf80dc90f0605a1dcdb0513962c9
597
h
C
yahoo/YahooMsgAuth.h
fioresoft/NO5
0acb1fdf191e3aa1e6f082ae996c1bf2a545e6c4
[ "MIT" ]
6
2017-06-01T01:28:11.000Z
2022-01-06T13:24:42.000Z
yahoo/YahooMsgAuth.h
fioresoft/NO5
0acb1fdf191e3aa1e6f082ae996c1bf2a545e6c4
[ "MIT" ]
null
null
null
yahoo/YahooMsgAuth.h
fioresoft/NO5
0acb1fdf191e3aa1e6f082ae996c1bf2a545e6c4
[ "MIT" ]
2
2021-07-05T01:17:23.000Z
2022-01-06T13:24:44.000Z
// YahooMsgAuth.h: interface for the CYahooMsgAuth class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_YAHOOMSGAUTH_H__6D59CF63_4AA2_11D9_A17B_C9614B571C31__INCLUDED_) #define AFX_YAHOOMSGAUTH_H__6D59CF63_4AA2_11D9_A17B_C9614B571C31__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CYahooMsgAuth { CString m_user; CString m_pw; CString m_challenge; public: CYahooMsgAuth(); virtual ~CYahooMsgAuth(); }; #endif // !defined(AFX_YAHOOMSGAUTH_H__6D59CF63_4AA2_11D9_A17B_C9614B571C31__INCLUDED_)
25.956522
88
0.693467
878f1111b507b7398fadb129f84fc029beb206d3
3,920
h
C
ArchivoDeC++/letras/include/Diccionario.h
RicardoRamirezGarcia/C-
f07a5e9d29faeba355712449d324c13a4a454dd7
[ "Apache-2.0" ]
null
null
null
ArchivoDeC++/letras/include/Diccionario.h
RicardoRamirezGarcia/C-
f07a5e9d29faeba355712449d324c13a4a454dd7
[ "Apache-2.0" ]
null
null
null
ArchivoDeC++/letras/include/Diccionario.h
RicardoRamirezGarcia/C-
f07a5e9d29faeba355712449d324c13a4a454dd7
[ "Apache-2.0" ]
null
null
null
#ifndef __Diccionario_h__ #define __Diccionario_h__ #include <string> #include <vector> #include "ArbolGeneral.h" using namespace std; /** * @brief Estructura que almacenaremos en el arbol * */ struct info { /** * Guardaremos el caracter de la palabra en un char * y una bandera final que estará a true si desde el primer nivel * hasta el nodo que contiene la bandera se forma una palabra * */ char c; bool final; /** * @brief Constructor sin parametros */ info() : c('\0'), final(false) {} /** * @brief Constructor con parametros * * @param car char con el caracter a almacenar * @param f booleano que indica si es la letra final de la palabra */ info(char car, bool f) : c(car), final(f) {} /** * @brief Constructor de copia */ info(const info & i) : c(i.c), final(i.final) {} /** * @brief Operador de salida */ friend ostream & operator<<(ostream & os, const info &i) { os << i.c; return os; } }; /** * @brief TDA Diccionario * @details Almacena las palabras de un fichero de texto e itera sobre ellas * */ class Diccionario { private: /** * La representación de los datos del diccionario es un ArbolGeneral de elementos * de tipo info (que a su vez son un char y un booleano que indica si es final de palabra) * */ ArbolGeneral<info> datos; public: /** @brief Construye un diccionario vacio. **/ Diccionario(); /** @brief Devuelve el numero de palabras en el diccionario **/ int size() const ; /** @brief Obtiene todas las palabras en el diccionario de un longitud dada @param longitud: la longitud de las palabras de salida @return un vector con las palabras de longitud especifica en el parametro de entrada **/ vector<string> PalabrasLongitud(int longitud); /** @brief Indica si una palabra esta en el diccionario o no @param palabra: la palabra que se quiere buscar @return true si la palabra esta en el diccionario. False en caso contrario **/ bool Esta(string palabra); /** * @brief Indica el numero de apariciones de una letra en el arbol * * @param c letra a buscar * @return Un entero indicando el numero de apariciones */ int getApariciones(const char c); /** * @brief Agrega una palabra al arbol * @details esta funcion se llama recursivamente * * @param palabra la palabra a agregar * @param i posicion de la letra a insertar * @param l ultimo nodo insertado */ void insertar_cadena( string palabra, int i, ArbolGeneral<info>::Nodo n); /** * @brief Agrega una palabra al arbol * * @param palabra Palabra a agregar al arbol */ void Agrega(string palabra); /** @brief Lee de un flujo de entrada un diccionario @param is:flujo de entrada @param D: el objeto donde se realiza la lectura. @return el flujo de entrada **/ friend istream & operator>>(istream & is,Diccionario &D); /** @brief Escribe en un flujo de salida un diccionario @param os:flujo de salida @param D: el objeto diccionario que se escribe @return el flujo de salida **/ friend ostream & operator<<(ostream & os, const Diccionario &D); /** * @brief Clase iteradora del diccioanrio * */ class iterator { private: /** * representacion de los datos del iterador del diccionario * nos guardamos una copia del arbol y un iterador del mismo * asi como la cadena que iremos construyendo y el nivel */ ArbolGeneral<info> arbol; ArbolGeneral<info>::iter_preorden it; string cad; //mantiene los caracteres desde el nivel 1 hasta donde se encuentra it. int level; public: /** * @brief Constructor sin parametros */ iterator(); iterator(Diccionario diccionario); string operator *(); iterator & operator ++(); bool operator ==(const iterator &i); bool operator !=(const iterator &i); ostream & operator<<(ostream & os); friend class Diccionario; }; iterator begin(); iterator end(); }; #include "Diccionario.cpp" #endif
21.777778
91
0.686735
563436d56e0b59405b359a2748cc62bf2f3576b8
461
h
C
src/kriti/bullet/Util.h
etherealvisage/kriti
6397c4d20331d9f5ce07460df08bbac9653ffa8b
[ "BSD-3-Clause" ]
2
2015-10-05T19:33:19.000Z
2015-12-08T08:39:17.000Z
src/kriti/bullet/Util.h
etherealvisage/kriti
6397c4d20331d9f5ce07460df08bbac9653ffa8b
[ "BSD-3-Clause" ]
1
2017-04-30T16:26:08.000Z
2017-05-01T03:00:42.000Z
src/kriti/bullet/Util.h
etherealvisage/kriti
6397c4d20331d9f5ce07460df08bbac9653ffa8b
[ "BSD-3-Clause" ]
null
null
null
#ifndef KRITI_BULLET__UTIL_H #define KRITI_BULLET__UTIL_H #include "../math/Vector.h" #include "../math/Quaternion.h" class btVector3; class btQuaternion; namespace Kriti { namespace Bullet { btVector3 toBullet(const Math::Vector &vector); Math::Vector toMath(const btVector3 &vector); btQuaternion toBullet(const Math::Quaternion &quaternion); Math::Quaternion toMath(const btQuaternion &quaternion); } // namespace Bullet } // namespace Kriti #endif
20.043478
58
0.772234
f460d1058335d0fbcf3faad08babe6c53a7cc314
1,068
h
C
Fmod Sample/FMOD Programmers API/api/studio/examples/common.h
seandenigris/FMODExample
e044249c5709cdeb6cd28f8dff5bafbeed7fdf91
[ "MIT" ]
null
null
null
Fmod Sample/FMOD Programmers API/api/studio/examples/common.h
seandenigris/FMODExample
e044249c5709cdeb6cd28f8dff5bafbeed7fdf91
[ "MIT" ]
null
null
null
Fmod Sample/FMOD Programmers API/api/studio/examples/common.h
seandenigris/FMODExample
e044249c5709cdeb6cd28f8dff5bafbeed7fdf91
[ "MIT" ]
6
2018-10-27T08:14:40.000Z
2022-01-11T12:15:56.000Z
#include "common_platform.h" #include "fmod.h" #include <stddef.h> #include <string.h> #include <stdlib.h> #include <math.h> #define NUM_COLUMNS 50 #define NUM_ROWS 25 enum Common_Button { BTN_ACTION1, BTN_ACTION2, BTN_ACTION3, BTN_ACTION4, BTN_LEFT, BTN_RIGHT, BTN_UP, BTN_DOWN, BTN_MORE, BTN_QUIT }; /* Cross platform functions (common) */ void Common_Fatal(const char *format, ...); void Common_Draw(const char *format, ...); void ERRCHECK(FMOD_RESULT result); /* Functions with platform specific implementation (common_platform) */ void Common_Init(void **extraDriverData); void Common_Close(); void Common_Update(); void Common_Sleep(unsigned int ms); void Common_Exit(int returnCode); void Common_DrawText(const char *text); void Common_LoadFileMemory(const char *name, void **buff, int *length); void Common_UnloadFileMemory(void *buff); bool Common_BtnPress(Common_Button btn); bool Common_BtnDown(Common_Button btn); const char *Common_BtnStr(Common_Button btn); const char *Common_MediaPath(const char *fileName);
24.837209
71
0.751873
3c9630b8bda9c0bc84c5e8e60dd8f0416f9b0ea1
3,354
h
C
src/Matrix2D.h
YuseqYaseq/ML-framework
d7830132ced6f874a774f86ce85345ef4dc630d9
[ "MIT" ]
null
null
null
src/Matrix2D.h
YuseqYaseq/ML-framework
d7830132ced6f874a774f86ce85345ef4dc630d9
[ "MIT" ]
null
null
null
src/Matrix2D.h
YuseqYaseq/ML-framework
d7830132ced6f874a774f86ce85345ef4dc630d9
[ "MIT" ]
null
null
null
#ifndef __MATRIX2D_H #define __MATRIX2D_H #include <iostream> #include <cmath> namespace AGH_NN { #define OVER_COLUMNS 0 #define OVER_ROWS 1 template <typename D> class Matrix2D; template <typename D> std::ostream& operator<<(const std::ostream &ostream, Matrix2D<D> &matrix); template<typename D> class Matrix2D { public: explicit Matrix2D(unsigned long _rows, unsigned long _cols, D** mat); explicit Matrix2D(); Matrix2D(unsigned long _rows, unsigned long _cols, const D &_initial); Matrix2D(const Matrix2D<D> &rhs); virtual ~Matrix2D(); // Operator overloading, for "standard" mathematical matrix operations Matrix2D<D>& operator=(const Matrix2D<D> &rhs); Matrix2D<D>& operator+=(const Matrix2D<D> &rhs); Matrix2D<D>& operator-=(const Matrix2D<D> &rhs); Matrix2D<D>& operator*=(const Matrix2D<D> &rhs); // Matrix mathematical operations Matrix2D<D> operator+(const Matrix2D<D> &rhs); Matrix2D<D> operator-(const Matrix2D<D> &rhs); Matrix2D<D> operator*(const Matrix2D<D> &rhs); //Add a scalar to every element of a matrix Matrix2D<D> operator+(const D scalar); //Multiply matrix by a scalar Matrix2D<D> operator*(const D scalar); //Divide matrix by a scalar Matrix2D<D> operator/(const D scalar); // Access the individual elements D* operator[](const unsigned long id); //slice Matrix2D<D> slice(unsigned long x_from, unsigned long x_to, unsigned long y_from, unsigned long y_to); //Element-wise negation Matrix2D<D> operator-(); //element-wise multiplication Matrix2D<D> dot(const Matrix2D<D> &rhs); //TODO: add usage of 1xn/nx1 matrices //element-wise division Matrix2D<D> div(const Matrix2D<D> &rhs); bool isSymmetrical(); D determinant(); void initialize_gaussian(); void initialize_gaussian(double median, double variance, unsigned long seed); //transpose Matrix2D<D> T(); // Printing matrix friend std::ostream& operator<< <>(const std::ostream &ostream, Matrix2D<D> &matrix); // Access the row and column sizes unsigned long get_rows() const; unsigned long get_cols() const; private: D** matrix = 0; unsigned long rows; unsigned long cols; D operator()(const unsigned long row, const unsigned long column) const; void showDotFailedMsg(const Matrix2D<D> &rhs) const; }; template <typename D> Matrix2D<D> operator+(const D scalar, Matrix2D<D>& matrix); template <typename D> Matrix2D<D> operator-(const D scalar, Matrix2D<D>& matrix); template <typename D> Matrix2D<D> operator*(const D scalar, Matrix2D<D>& matrix); template <typename D> Matrix2D<D> operator/(const D scalar, Matrix2D<D>& matrix); template <typename D> Matrix2D<D> exp(Matrix2D<D> a); template <typename D> Matrix2D<D> log(Matrix2D<D> a); template <typename D> Matrix2D<D> sigmoid2D(Matrix2D<D> a); template <typename D> D sum(Matrix2D<D> a); template <typename D> D avg(Matrix2D<D> a); //sum over chosen dimension //0 - over columns, returns 1xn //1 - over rows, returns nx1 template <typename D> Matrix2D<D> sum(Matrix2D<D> matrix, unsigned long dimension); template <typename D> Matrix2D<D> avg(Matrix2D<D> matrix, unsigned long dimension); }; #include "Matrix2D.cpp" #endif
25.603053
106
0.683065
a744cf9cd7f9feea55a5b9a9addc16437196bb12
7,316
h
C
MakiseGUI/gui/makise_gui_elements.h
SL-RU/MakiseGUI
574d020ab9bd9a8ae583b0cf71b0ed34faf7a235
[ "MIT" ]
133
2017-01-06T11:02:10.000Z
2022-01-25T09:17:43.000Z
MakiseGUI/gui/makise_gui_elements.h
SL-RU/MakiseGUI
574d020ab9bd9a8ae583b0cf71b0ed34faf7a235
[ "MIT" ]
10
2017-04-18T18:28:10.000Z
2022-02-13T14:20:20.000Z
MakiseGUI/gui/makise_gui_elements.h
SL-RU/MakiseGUI
574d020ab9bd9a8ae583b0cf71b0ed34faf7a235
[ "MIT" ]
25
2017-04-16T00:42:25.000Z
2020-05-05T11:31:53.000Z
#ifndef _MAKISE_H_G_EL #define _MAKISE_H_G_EL 1 #ifdef __cplusplus extern "C" { #endif #include "makise_config.h" typedef struct _MElement MElement; #define MState_Disable 0b0000 #define MState_Idle 0b0001 #define MState_Focused 0b0010 #define MState_Pressed 0b0100 typedef enum { MPositionAnchor_LeftUp, MPositionAnchor_RightUp, MPositionAnchor_LeftDown, MPositionAnchor_RighDown } MPositionAnchor; typedef enum { MPositionStretch_LeftRight, // Stretch in horizontal direction. MPositionStretch_Left, // No stretch. anchor is left. MPositionStretch_Right, // No stretch. anchor is rigth. } MPositionStretchHor; typedef enum { MPositionStretch_UpDown, // Stretch in vertical direction. MPositionStretch_Up, // No stretch. anchor is up. MPositionStretch_Down, // No stretch. anchor is down. } MPositionStretchVert; typedef enum { MFocusPrior_NotFocusble, // Focus doesn't required MFocusPrior_Focusble, // Focus is required MFocusPrior_FocusbleIsolated, // Focus is required but only directly by M_G_FOCUS_GET, not _NEXT or _PREV. } MFocusPriorEnum; typedef struct _MPosition { MPositionStretchHor horisontal; MPositionStretchVert vertical; int32_t left; int32_t right; int32_t up; int32_t down; uint32_t width; uint32_t height; // It will be calculated automatically int32_t real_x; // Position on the screen. It will be calculated automatically int32_t real_y; // Position on the screen.It will be calculated automatically } MPosition; #include "makise_gui.h" typedef struct _MElement { MPosition position; // Relative position of the element. void* data; MResult (*draw ) (MElement* el, MakiseGUI *gui); MResult (*predraw ) (MElement* el, MakiseGUI *gui); // Count real position for every element MResult (*update ) (MElement* el ); MInputResultEnum (*input ) (MElement* el, MInputData data); MFocusEnum (*focus ) (MElement* el, MFocusEnum act); uint8_t is_parent; // Is element parent(contains other elements. MContainer* children; // Only if element is parent. MElement* prev; // Previous if exists. MElement* next; // Next element if exists. MContainer* parent; // Parent element, if exists. MHost* host; // MHost, if exists. uint8_t enabled; // If enabled - methods will be executed. MFocusPriorEnum focus_prior; // Defines focus behavior uint32_t id; // Unique id. char* name; } MElement; /** * Initialize MElement structure * * @param e Pointer to element themself * @param name Human name of the element * @param data pointer to structure with your data * @param enabled is element enabled * @param focus_prior focus prior * @param position MPosition * @param draw draw function * @param predraw predraw function * @param update update function * @param input input function * @param focus focus function * @param is_parent 1 if element is container or parent, else 0 * @param children if is_parent==1 then MContainer, else 0 * @return */ void m_element_create(MElement *e, char *name, void* data, uint8_t enabled, MFocusPriorEnum focus_prior, MPosition position, MResult (*draw )(MElement* el, MakiseGUI *gui), MResult (*predraw )(MElement* el, MakiseGUI *gui), MResult (*update )(MElement* el), MInputResultEnum (*input)(MElement* el, MInputData data), MFocusEnum (*focus )(MElement* el, MFocusEnum act), uint8_t is_parent, MContainer *children); /** * Lock element's mutex * * @param el element * @return result */ MResult m_element_mutex_request(MElement* el); /** * Unlock element's mutex * * @param el element * @return result */ MResult m_element_mutex_release(MElement* el); uint8_t m_element_call(MElement* el, MakiseGUI *host, MElementCall type); MInputResultEnum m_element_input(MElement* el, MInputData data); MFocusEnum m_element_focus(MElement* el, MFocusEnum act ); /** * Create MPosition from relative coordinates & size. Anchor - left up corner * * @param h * @return */ MPosition mp_rel(int32_t x, int32_t y, uint32_t w, uint32_t h); /** * Create MPosition from relative coordinates and custom anchor * * @param x horizontal coordinate * @param y vertical coordinate * @param w width * @param h height * @param anchor * @return */ MPosition mp_anc(int32_t x, int32_t y, uint32_t w, uint32_t h, MPositionAnchor anchor); /** * Create MPosition fully customizable. Unnecessary options you can equal to zero. * * @param left dist from left side. Required when hor is MPositionStretch_Left or MPositionStretch_LeftRight * @param right dist form the right side. Required when hor is MPositionStretch_Right or MPositionStretch_LeftRight * @param w width. Required when when hor is MPositionStretch_Left or MPositionStretch_Right * @param hor Type of horizontal stretch * @param up dist from top. Required when vert is MPositionStretch_Up or MPositionStretch_UpDown * @param down dist from bottom. Required when vert is MPositionStretch_Down or MPositionStretch_UpDown * @param h height. Required when vert is MPositionStretch_Up or MPositionStretch_Down * @param vert Type of vertical stretch * @return */ MPosition mp_cust(int32_t left, int32_t right, uint32_t w, MPositionStretchHor hor, int32_t up, int32_t down, uint32_t h, MPositionStretchVert vert); /** * Create MPosition with horizontal stretch and vertical relative coordinates * * @param left dist from the left side of parent container to the left border * @param right dist from the right side of parent container to right border * @param up dist from the top of the parent to the top border * @param h height * @return */ MPosition mp_shor(int32_t left, int32_t right, int32_t up, uint32_t h); /** * Create MPosition with horizontal relative coordinates and vertical stretch * * @param left left dist from the left side of parent container to the left border * @param width width * @param up dist from the top of the parent to the top border * @param down dist from the bottom of the parent to the bottom border * @return */ MPosition mp_sver(int32_t left, int32_t width, int32_t up, uint32_t down); /** * Create MPosition with horizontal and vertical stretch * * @param left left dist from the left side of parent container to the left border * @param right dist from the right side of parent container to right border * @param up dist from the top of the parent to the top border * @param down dist from the bottom of the parent to the bottom border * @return */ MPosition mp_sall(int32_t left, int32_t right, int32_t up, uint32_t down); /** * Zero position * * @return */ MPosition mp_nil(); #ifdef __cplusplus } #endif #endif
34.347418
116
0.6807
34dd29e79ac32eac3d908c2d9150795c6894baca
231
h
C
MMFlexboxDemo/MMFlexboxDemo/AppDelegate.h
hzx157/has_h5
5b73e465e373e214629df2381eebd3b773439125
[ "MIT" ]
1
2020-09-21T14:04:20.000Z
2020-09-21T14:04:20.000Z
MMFlexboxDemo/MMFlexboxDemo/AppDelegate.h
hzx157/MMFlexbox-iOS
5b73e465e373e214629df2381eebd3b773439125
[ "MIT" ]
null
null
null
MMFlexboxDemo/MMFlexboxDemo/AppDelegate.h
hzx157/MMFlexbox-iOS
5b73e465e373e214629df2381eebd3b773439125
[ "MIT" ]
null
null
null
// // AppDelegate.h // MMFlexboxDemo // // Created by mac on 2020/8/17. // Copyright © 2020 Huangzhenxiang. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @end
14.4375
60
0.701299
711b3133b259394b08b6c7801afea4982312be87
1,065
c
C
libft/ft_memcpy.c
ricardoreves/42-push-swap
97c7d465dabd703fd13157799cbf4bc5eb29d5ce
[ "MIT" ]
null
null
null
libft/ft_memcpy.c
ricardoreves/42-push-swap
97c7d465dabd703fd13157799cbf4bc5eb29d5ce
[ "MIT" ]
null
null
null
libft/ft_memcpy.c
ricardoreves/42-push-swap
97c7d465dabd703fd13157799cbf4bc5eb29d5ce
[ "MIT" ]
1
2022-03-12T20:24:48.000Z
2022-03-12T20:24:48.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcpy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rpinto-r <rpinto-r@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/14 05:05:56 by rpinto-r #+# #+# */ /* Updated: 2021/10/18 14:07:14 by rpinto-r ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void *ft_memcpy(void *dest, const void *src, size_t n) { size_t i; i = -1; while (++i < n) ((char *)dest)[i] = ((char *)src)[i]; return (dest); }
44.375
80
0.183099
61c3cd8ce98a05dd90eef3bd549c024d9036bc8f
6,978
c
C
core/db_bdb.c
auzkok/libagar
8dffa4afe73df47cf7e461c3073b744373d3af0b
[ "BSD-2-Clause" ]
286
2017-07-31T20:05:16.000Z
2022-03-26T20:26:24.000Z
core/db_bdb.c
auzkok/libagar
8dffa4afe73df47cf7e461c3073b744373d3af0b
[ "BSD-2-Clause" ]
67
2017-08-30T18:56:21.000Z
2021-09-08T03:38:20.000Z
core/db_bdb.c
auzkok/libagar
8dffa4afe73df47cf7e461c3073b744373d3af0b
[ "BSD-2-Clause" ]
31
2017-08-14T13:34:12.000Z
2022-03-14T15:33:49.000Z
/* * Copyright (c) 2012-2018 Julien Nadeau Carriere <vedge@csoft.net> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Berkeley DB database access. */ #include <db5/db.h> #include <agar/core/core.h> typedef struct ag_db_hash_bt { struct ag_db _inherit; DB *pDB; } AG_DbHashBT; static const struct { const char *_Nonnull name; Uint32 mask; } bdbOptions[] = { { "db-create", DB_CREATE }, { "db-create-excl", DB_EXCL }, { "db-auto-commit", DB_AUTO_COMMIT }, { "db-threaded", DB_THREAD }, { "db-truncate", DB_TRUNCATE }, #ifdef DB_MULTIVERSION { "db-multiversion", DB_MULTIVERSION }, #endif #ifdef DB_NOMMAP { "db-no-mmap", DB_NOMMAP }, #endif #ifdef DB_READ_UNCOMMITTED { "db-read-uncommitted", DB_READ_UNCOMMITTED }, #endif }; static const int bdbOptionCount = sizeof(bdbOptions)/sizeof(bdbOptions[0]); static void Init(void *obj) { AG_DbHashBT *db = obj; int i; for (i = 0; i < bdbOptionCount; i++) AG_SetInt(db, bdbOptions[i].name, 0); AG_SetInt(db, "db-create", 1); } static int Open(void *obj, const char *path, Uint flags) { AG_DbHashBT *db = obj; Uint32 dbFlags = 0; int i, rv; DBTYPE dbtype; if (strcmp(AGDB_CLASS(db)->name, "hash") == 0) { dbtype = DB_HASH; } else { dbtype = DB_BTREE; } if ((rv = db_create(&db->pDB, NULL, 0)) != 0) { AG_SetError("db_create: %s", db_strerror(rv)); return (-1); } for (i = 0; i < bdbOptionCount; i++) { if (AG_GetInt(db, bdbOptions[i].name)) dbFlags |= bdbOptions[i].mask; } if (flags & AG_DB_READONLY) { dbFlags |= DB_RDONLY; } rv = db->pDB->open(db->pDB, NULL, path, NULL, dbtype, dbFlags, 0); if (rv != 0) { AG_SetError("db_open %s: %s", path, db_strerror(rv)); return (-1); } return (0); } static void Close(void *obj) { AG_DbHashBT *db = obj; int rv; if ((rv = db->pDB->close(db->pDB, 0)) != 0) AG_Verbose("db_close: %s; ignoring\n", db_strerror(rv)); } static int Sync(void *obj) { AG_DbHashBT *db = obj; int rv; if ((rv = db->pDB->sync(db->pDB, 0)) != 0) { AG_SetError("db_sync: %s", db_strerror(rv)); return (-1); } return (0); } static int Exists(void *obj, const AG_Dbt *key) { AG_DbHashBT *db = obj; DBT dbKey; int rv; memset(&dbKey, 0, sizeof(DBT)); dbKey.data = Malloc(key->size); memcpy(dbKey.data, key->data, key->size); dbKey.size = key->size; #if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 6) rv = db->pDB->exists(db->pDB, NULL, &dbKey, 0); #else { DBT dbVal; memset(&dbVal, 0, sizeof(DBT)); rv = db->pDB->get(db->pDB, NULL, &dbKey, &dbVal, 0); Free(dbVal.data); } #endif Free(dbKey.data); return (rv != DB_NOTFOUND); } static int Get(void *obj, const AG_Dbt *key, AG_Dbt *val) { AG_DbHashBT *db = obj; DBT dbKey, dbVal; int rv; memset(&dbKey, 0, sizeof(DBT)); if ((dbKey.data = TryMalloc(key->size)) == NULL) { return (-1); } memcpy(dbKey.data, key->data, key->size); dbKey.size = key->size; memset(&dbVal, 0, sizeof(DBT)); if ((rv = db->pDB->get(db->pDB, NULL, &dbKey, &dbVal, 0)) != 0) { AG_SetError("db_get: %s", db_strerror(rv)); } Free(dbKey.data); val->data = dbVal.data; val->size = dbVal.size; return (rv != 0) ? -1 : 0; } static int Put(void *_Nonnull obj, const AG_Dbt *_Nonnull key, const AG_Dbt *_Nonnull val) { AG_DbHashBT *db = obj; DBT dbKey, dbVal; int rv; memset(&dbKey, 0, sizeof(DBT)); if ((dbKey.data = TryMalloc(key->size)) == NULL) { return (-1); } memcpy(dbKey.data, key->data, key->size); dbKey.size = key->size; memset(&dbVal, 0, sizeof(DBT)); if ((dbVal.data = TryMalloc(val->size)) == NULL) { Free(dbKey.data); return (-1); } memcpy(dbVal.data, val->data, val->size); dbVal.size = val->size; if ((rv = db->pDB->put(db->pDB, NULL, &dbKey, &dbVal, 0)) != 0) AG_SetError("db_put: %s", db_strerror(rv)); Free(dbKey.data); Free(dbVal.data); return (rv != 0) ? -1 : 0; } static int Del(void *_Nonnull obj, const AG_Dbt *_Nonnull key) { AG_DbHashBT *db = obj; DBT dbKey; int rv; memset(&dbKey, 0, sizeof(DBT)); if ((dbKey.data = TryMalloc(key->size)) == NULL) { return (-1); } memcpy(dbKey.data, key->data, key->size); dbKey.size = key->size; if ((rv = db->pDB->del(db->pDB, NULL, &dbKey, 0)) != 0) { AG_SetError("DB Delete: %s", db_strerror(rv)); } Free(dbKey.data); return (rv != 0) ? -1 : 0; } static int Iterate(void *_Nonnull obj, AG_DbIterateFn fn, void *_Nullable arg) { AG_DbHashBT *db = obj; DBC *c; DBT dbk, dbv; int rv; db->pDB->cursor(db->pDB, NULL, &c, 0); memset(&dbk, 0, sizeof(DBT)); memset(&dbv, 0, sizeof(DBT)); while ((rv = c->c_get(c, &dbk, &dbv, DB_NEXT)) == 0) { AG_Dbt key, val; key.data = dbk.data; key.size = dbk.size; val.data = dbv.data; val.size = dbv.size; if (fn(&key, &val, arg) == -1) { c->c_close(c); return (-1); } } c->c_close(c); if (rv != DB_NOTFOUND) { AG_SetError("c_get: %s", db_strerror(rv)); return (-1); } else { return (0); } } AG_DbClass agDbHashClass = { { "AG_Db:AG_DbHash", sizeof(AG_DbHashBT), { 0,0 }, Init, NULL, /* free */ NULL, /* destroy */ NULL, /* load */ NULL, /* save */ NULL /* edit */ }, "hash", N_("Extended Linear Hashing"), AG_DB_KEY_DATA, /* Key is variable data */ AG_DB_REC_VARIABLE, /* Variable-sized records */ Open, Close, Sync, Exists, Get, Put, Del, Iterate }; AG_DbClass agDbBtreeClass = { { "AG_Db:AG_DbBtree", sizeof(AG_DbHashBT), { 0,0 }, Init, NULL, /* free */ NULL, /* destroy */ NULL, /* load */ NULL, /* save */ NULL /* edit */ }, "btree", N_("Sorted, Balanced Tree Structure"), AG_DB_KEY_DATA, /* Key is variable data */ AG_DB_REC_VARIABLE, /* Variable-sized records */ Open, Close, Sync, Exists, Get, Put, Del, Iterate };
22.365385
80
0.642591
9f938d89b8685ba923ac6831eb04b15c0bb55bd1
114
h
C
src/ducer/ducer_pass.h
kirkshoop/transducer
a14e50a202a8e6e51280ef8580531d21193402be
[ "BSD-3-Clause" ]
43
2015-02-04T13:30:48.000Z
2021-12-13T16:41:17.000Z
src/ducer/ducer_pass.h
kirkshoop/transducer
a14e50a202a8e6e51280ef8580531d21193402be
[ "BSD-3-Clause" ]
null
null
null
src/ducer/ducer_pass.h
kirkshoop/transducer
a14e50a202a8e6e51280ef8580531d21193402be
[ "BSD-3-Clause" ]
4
2015-01-22T09:49:36.000Z
2019-05-14T21:03:51.000Z
#pragma once namespace nsducer { auto pass = [](){ return [=](auto step) { return step; }; }; }
10.363636
27
0.508772
0f32bb3b2d0523c342b43f3712bd3b6008344b8e
1,263
h
C
src/bulletsource.h
tedajax/asteroids
0c1c41d21ca6a95f48795e943ce4dc1b7b8612ee
[ "MIT" ]
null
null
null
src/bulletsource.h
tedajax/asteroids
0c1c41d21ca6a95f48795e943ce4dc1b7b8612ee
[ "MIT" ]
null
null
null
src/bulletsource.h
tedajax/asteroids
0c1c41d21ca6a95f48795e943ce4dc1b7b8612ee
[ "MIT" ]
null
null
null
#ifndef ASTEROIDS_BULLET_SOURCE_H #define ASTEROIDS_BULLET_SOURCE_H #include "core.h" #include "collider.h" #include "prefab.h" typedef struct bullet_source_t { BulletSourceConfig* configSource; Prefab* prefab; BulletSourceConfig config; f32 fireTimer; f32 burstTimer; i32 burstsRemaining; i32 burstShotsRemaining; u32 level; bool active; } BulletSource; typedef struct entity_manager_t EntityManager; void bullet_source_init(BulletSource* self, BulletSourceConfig* config); void bullet_source_release(BulletSource* self); static inline void bullet_source_on(BulletSource* self) { self->active = true; self->fireTimer = 0.f; self->burstTimer = 0.f; self->burstsRemaining = self->config.burstCount; } static inline void bullet_source_off(BulletSource* self) { self->active = false; self->burstTimer = 0.f; self->burstShotsRemaining = 0; } void bullet_source_update(BulletSource* self, f32 dt, EntityManager* entityManager, TransformComponent* anchor); void bullet_source_fire(BulletSource* self, EntityManager* entityManager, TransformComponent* anchor); void bullet_source_fire_direction(BulletSource* self, EntityManager* entityManager, TransformComponent* anchor, Vec2* direction); #endif
30.071429
129
0.770388
95ce503c59e3e8dff12c306fff8b22210fad656b
28,254
h
C
include/openssl/x509_vfy.h
vigortls/vigortls
96d5ef366291a7a5976bda43025b054021dbf1bf
[ "OpenSSL", "0BSD" ]
3
2017-02-21T06:57:01.000Z
2018-11-21T09:57:43.000Z
include/openssl/x509_vfy.h
vigortls/vigortls
96d5ef366291a7a5976bda43025b054021dbf1bf
[ "OpenSSL", "0BSD" ]
null
null
null
include/openssl/x509_vfy.h
vigortls/vigortls
96d5ef366291a7a5976bda43025b054021dbf1bf
[ "OpenSSL", "0BSD" ]
1
2018-05-22T02:28:43.000Z
2018-05-22T02:28:43.000Z
/* * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef HEADER_X509_H #include <openssl/x509.h> /* openssl/x509.h ends up #include-ing this file at about the only * appropriate moment. */ #endif #ifndef HEADER_X509_VFY_H #define HEADER_X509_VFY_H #include <openssl/base.h> #include <openssl/bio.h> #include <openssl/crypto.h> #include <openssl/lhash.h> #include <openssl/threads.h> #ifdef __cplusplus extern "C" { #endif typedef struct x509_file_st { int num_paths; /* number of paths to files or directories */ int num_alloced; char **paths; /* the list of paths or directories */ int *path_type; } X509_CERT_FILE_CTX; /*******************************/ /* * SSL_CTX -> X509_STORE * -> X509_LOOKUP * -> X509_LOOKUP_METHOD * -> X509_LOOKUP * -> X509_LOOKUP_METHOD * * SSL -> X509_STORE_CTX * -> X509_STORE * * The X509_STORE holds the tables etc for verification stuff. * A X509_STORE_CTX is used while validating a single certificate. * The X509_STORE has X509_LOOKUPs for looking up certs. * The X509_STORE then calls a function to actually verify the * certificate chain. */ #define X509_LU_RETRY -1 #define X509_LU_FAIL 0 #define X509_LU_X509 1 #define X509_LU_CRL 2 #define X509_LU_PKEY 3 typedef struct x509_object_st { /* one of the above types */ int type; union { char *ptr; X509 *x509; X509_CRL *crl; EVP_PKEY *pkey; } data; } X509_OBJECT; typedef struct x509_lookup_st X509_LOOKUP; DECLARE_STACK_OF(X509_LOOKUP) DECLARE_STACK_OF(X509_OBJECT) /* This is a static that defines the function interface */ typedef struct x509_lookup_method_st { const char *name; int (*new_item)(X509_LOOKUP *ctx); void (*free)(X509_LOOKUP *ctx); int (*init)(X509_LOOKUP *ctx); int (*shutdown)(X509_LOOKUP *ctx); int (*ctrl)(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); int (*get_by_subject)(X509_LOOKUP *ctx, int type, X509_NAME *name, X509_OBJECT *ret); int (*get_by_issuer_serial)(X509_LOOKUP *ctx, int type, X509_NAME *name, ASN1_INTEGER *serial, X509_OBJECT *ret); int (*get_by_fingerprint)(X509_LOOKUP *ctx, int type, uint8_t *bytes, int len, X509_OBJECT *ret); int (*get_by_alias)(X509_LOOKUP *ctx, int type, char *str, int len, X509_OBJECT *ret); } X509_LOOKUP_METHOD; typedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID; /* * This structure hold all parameters associated with a verify operation * by including an X509_VERIFY_PARAM structure in related structures the * parameters used can be customized */ typedef struct X509_VERIFY_PARAM_st { char *name; time_t check_time; /* Time to use */ unsigned long inh_flags; /* Inheritance flags */ unsigned long flags; /* Various verify flags */ int purpose; /* purpose to check untrusted certificates */ int trust; /* trust setting to check */ int depth; /* Verify depth */ STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ X509_VERIFY_PARAM_ID *id; /* opaque ID data */ } X509_VERIFY_PARAM; DECLARE_STACK_OF(X509_VERIFY_PARAM) /* This is used to hold everything. It is used for all certificate * validation. Once we have a certificate chain, the 'verify' * function is then called to actually check the cert chain. */ struct x509_store_st { /* The following is a cache of trusted certs */ int cache; /* if true, stash any hits */ STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ /* These are external lookup methods */ STACK_OF(X509_LOOKUP) *get_cert_methods; X509_VERIFY_PARAM *param; /* Callbacks for various operations */ int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ int (*verify_cb)(int ok, X509_STORE_CTX *ctx); /* error callback */ int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ int (*check_revocation)( X509_STORE_CTX *ctx); /* Check revocation status of chain */ int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ STACK_OF(X509) *(*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm); STACK_OF(X509_CRL) *(*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm); int (*cleanup)(X509_STORE_CTX *ctx); CRYPTO_EX_DATA ex_data; int references; CRYPTO_MUTEX *lock; } /* X509_STORE */; VIGORTLS_EXPORT int X509_STORE_set_depth(X509_STORE *store, int depth); #define X509_STORE_set_verify_cb_func(ctx, func) ((ctx)->verify_cb = (func)) #define X509_STORE_set_verify_func(ctx, func) ((ctx)->verify = (func)) /* This is the functions plus an instance of the local variables. */ struct x509_lookup_st { int init; /* have we been started */ int skip; /* don't use us. */ X509_LOOKUP_METHOD *method; /* the functions */ char *method_data; /* method data */ X509_STORE *store_ctx; /* who owns us */ } /* X509_LOOKUP */; /* * This is a used when verifying cert chains. Since the * gathering of the cert chain can take some time (and have to be * 'retried', this needs to be kept and passed around. */ struct x509_store_ctx_st /* X509_STORE_CTX */ { X509_STORE *ctx; int current_method; /* used when looking up certs */ /* The following are set by the caller */ X509 *cert; /* The cert to check */ STACK_OF(X509) *untrusted; /* chain of X509s - untrusted - passed in */ STACK_OF(X509_CRL) *crls; /* set of CRLs passed in */ X509_VERIFY_PARAM *param; void *other_ctx; /* Other info for use with get_issuer() */ /* Callbacks for various operations */ int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ int (*verify_cb)(int ok, X509_STORE_CTX *ctx); /* error callback */ int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ int (*check_revocation)( X509_STORE_CTX *ctx); /* Check revocation status of chain */ int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */ int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */ int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */ int (*check_policy)(X509_STORE_CTX *ctx); STACK_OF(X509) *(*lookup_certs)(X509_STORE_CTX *ctx, X509_NAME *nm); STACK_OF(X509_CRL) *(*lookup_crls)(X509_STORE_CTX *ctx, X509_NAME *nm); int (*cleanup)(X509_STORE_CTX *ctx); /* The following is built up */ int valid; /* if 0, rebuild chain */ int last_untrusted; /* index of last untrusted cert */ STACK_OF(X509) *chain; /* chain of X509s - built up and trusted */ X509_POLICY_TREE *tree; /* Valid policy tree */ int explicit_policy; /* Require explicit policy value */ /* When something goes wrong, this is why */ int error_depth; int error; X509 *current_cert; X509 *current_issuer; /* cert currently being tested as valid issuer */ X509_CRL *current_crl; /* current CRL */ int current_crl_score; /* score of current CRL */ unsigned int current_reasons; /* Reason mask */ X509_STORE_CTX *parent; /* For CRL path validation: parent context */ CRYPTO_EX_DATA ex_data; } /* X509_STORE_CTX */; VIGORTLS_EXPORT void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); #define X509_STORE_CTX_set_app_data(ctx, data) \ X509_STORE_CTX_set_ex_data(ctx, 0, data) #define X509_STORE_CTX_get_app_data(ctx) X509_STORE_CTX_get_ex_data(ctx, 0) #define X509_L_FILE_LOAD 1 #define X509_L_ADD_DIR 2 #define X509_LOOKUP_load_file(x, name, type) \ X509_LOOKUP_ctrl((x), X509_L_FILE_LOAD, (name), (long)(type), NULL) #define X509_LOOKUP_add_dir(x, name, type) \ X509_LOOKUP_ctrl((x), X509_L_ADD_DIR, (name), (long)(type), NULL) #define X509_V_OK 0 #define X509_V_ERR_UNSPECIFIED 1 #define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 #define X509_V_ERR_UNABLE_TO_GET_CRL 3 #define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 #define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 #define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 #define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 #define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 #define X509_V_ERR_CERT_NOT_YET_VALID 9 #define X509_V_ERR_CERT_HAS_EXPIRED 10 #define X509_V_ERR_CRL_NOT_YET_VALID 11 #define X509_V_ERR_CRL_HAS_EXPIRED 12 #define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 #define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 #define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 #define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 #define X509_V_ERR_OUT_OF_MEM 17 #define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 #define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 #define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 #define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 #define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 #define X509_V_ERR_CERT_REVOKED 23 #define X509_V_ERR_INVALID_CA 24 #define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 #define X509_V_ERR_INVALID_PURPOSE 26 #define X509_V_ERR_CERT_UNTRUSTED 27 #define X509_V_ERR_CERT_REJECTED 28 /* These are 'informational' when looking for issuer cert */ #define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 #define X509_V_ERR_AKID_SKID_MISMATCH 30 #define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 #define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 #define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 #define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 #define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 #define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 #define X509_V_ERR_INVALID_NON_CA 37 #define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 #define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 #define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 #define X509_V_ERR_INVALID_EXTENSION 41 #define X509_V_ERR_INVALID_POLICY_EXTENSION 42 #define X509_V_ERR_NO_EXPLICIT_POLICY 43 #define X509_V_ERR_DIFFERENT_CRL_SCOPE 44 #define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45 #define X509_V_ERR_UNNESTED_RESOURCE 46 #define X509_V_ERR_PERMITTED_VIOLATION 47 #define X509_V_ERR_EXCLUDED_VIOLATION 48 #define X509_V_ERR_SUBTREE_MINMAX 49 #define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51 #define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52 #define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53 #define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54 /* Suite B mode algorithm violation */ #define X509_V_ERR_SUITE_B_INVALID_VERSION 56 #define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57 #define X509_V_ERR_SUITE_B_INVALID_CURVE 58 #define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59 #define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60 #define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61 /* Host, email and IP check errors */ #define X509_V_ERR_HOSTNAME_MISMATCH 62 #define X509_V_ERR_EMAIL_MISMATCH 63 #define X509_V_ERR_IP_ADDRESS_MISMATCH 64 /* The application is not happy */ #define X509_V_ERR_APPLICATION_VERIFICATION 50 /* Certificate verify flags */ /* Send issuer+subject checks to verify_cb */ #define X509_V_FLAG_CB_ISSUER_CHECK 0x1 /* Use check time instead of current time */ #define X509_V_FLAG_USE_CHECK_TIME 0x2 /* Lookup CRLs */ #define X509_V_FLAG_CRL_CHECK 0x4 /* Lookup CRLs for whole chain */ #define X509_V_FLAG_CRL_CHECK_ALL 0x8 /* Ignore unhandled critical extensions */ #define X509_V_FLAG_IGNORE_CRITICAL 0x10 /* Disable workarounds for broken certificates */ #define X509_V_FLAG_X509_STRICT 0x20 /* Enable proxy certificate validation */ #define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 /* Enable policy checking */ #define X509_V_FLAG_POLICY_CHECK 0x80 /* Policy variable require-explicit-policy */ #define X509_V_FLAG_EXPLICIT_POLICY 0x100 /* Policy variable inhibit-any-policy */ #define X509_V_FLAG_INHIBIT_ANY 0x200 /* Policy variable inhibit-policy-mapping */ #define X509_V_FLAG_INHIBIT_MAP 0x400 /* Notify callback that policy is OK */ #define X509_V_FLAG_NOTIFY_POLICY 0x800 /* Extended CRL features such as indirect CRLs, alternate CRL signing keys */ #define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000 /* Delta CRL support */ #define X509_V_FLAG_USE_DELTAS 0x2000 /* Check selfsigned CA signature */ #define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 #define X509_V_FLAG_TRUSTED_FIRST 0x8000 /* Suite B 128 bit only mode: not normally used */ #define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000 /* Suite B 192 bit only mode */ #define X509_V_FLAG_SUITEB_192_LOS 0x20000 /* Suite B 128 bit mode allowing 192 bit algorithms */ #define X509_V_FLAG_SUITEB_128_LOS 0x30000 /* Allow partial chains if at least one certificate is in trusted store */ #define X509_V_FLAG_PARTIAL_CHAIN 0x80000 /* * If the initial chain is not trusted, do not attempt to build an alternative * chain. Alternate chain checking was introduced in 1.0.2b. Setting this flag * will force the behaviour to match that of previous versions. */ #define X509_V_FLAG_NO_ALT_CHAINS 0x100000 #define X509_VP_FLAG_DEFAULT 0x1 #define X509_VP_FLAG_OVERWRITE 0x2 #define X509_VP_FLAG_RESET_FLAGS 0x4 #define X509_VP_FLAG_LOCKED 0x8 #define X509_VP_FLAG_ONCE 0x10 /* Internal use: mask of policy related options */ #define X509_V_FLAG_POLICY_MASK \ (X509_V_FLAG_POLICY_CHECK | X509_V_FLAG_EXPLICIT_POLICY | \ X509_V_FLAG_INHIBIT_ANY | X509_V_FLAG_INHIBIT_MAP) VIGORTLS_EXPORT int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name); VIGORTLS_EXPORT X509_OBJECT * X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type, X509_NAME *name); VIGORTLS_EXPORT X509_OBJECT * X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x); VIGORTLS_EXPORT void X509_OBJECT_up_ref_count(X509_OBJECT *a); VIGORTLS_EXPORT void X509_OBJECT_free_contents(X509_OBJECT *a); VIGORTLS_EXPORT X509_STORE *X509_STORE_new(void); VIGORTLS_EXPORT int X509_STORE_up_ref(X509_STORE *v); VIGORTLS_EXPORT void X509_STORE_free(X509_STORE *v); VIGORTLS_EXPORT STACK_OF(X509) * X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm); VIGORTLS_EXPORT STACK_OF(X509_CRL) * X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm); VIGORTLS_EXPORT int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); VIGORTLS_EXPORT int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); VIGORTLS_EXPORT int X509_STORE_set_trust(X509_STORE *ctx, int trust); VIGORTLS_EXPORT int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); VIGORTLS_EXPORT void X509_STORE_set_verify_cb(X509_STORE *ctx, int (*verify_cb)(int, X509_STORE_CTX *)); VIGORTLS_EXPORT void X509_STORE_set_lookup_crls_cb( X509_STORE *ctx, STACK_OF(X509_CRL) *(*cb)(X509_STORE_CTX *ctx, X509_NAME *nm)); VIGORTLS_EXPORT X509_STORE_CTX *X509_STORE_CTX_new(void); VIGORTLS_EXPORT int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); VIGORTLS_EXPORT void X509_STORE_CTX_free(X509_STORE_CTX *ctx); VIGORTLS_EXPORT int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, STACK_OF(X509) *chain); VIGORTLS_EXPORT void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); VIGORTLS_EXPORT void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); VIGORTLS_EXPORT X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); VIGORTLS_EXPORT X509_LOOKUP_METHOD *X509_LOOKUP_file(void); VIGORTLS_EXPORT int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); VIGORTLS_EXPORT int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); VIGORTLS_EXPORT int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name, X509_OBJECT *ret); VIGORTLS_EXPORT int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); VIGORTLS_EXPORT int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); VIGORTLS_EXPORT int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); VIGORTLS_EXPORT int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); VIGORTLS_EXPORT X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); VIGORTLS_EXPORT void X509_LOOKUP_free(X509_LOOKUP *ctx); VIGORTLS_EXPORT int X509_LOOKUP_init(X509_LOOKUP *ctx); VIGORTLS_EXPORT int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, X509_OBJECT *ret); VIGORTLS_EXPORT int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name, ASN1_INTEGER *serial, X509_OBJECT *ret); VIGORTLS_EXPORT int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, uint8_t *bytes, int len, X509_OBJECT *ret); VIGORTLS_EXPORT int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len, X509_OBJECT *ret); VIGORTLS_EXPORT int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); VIGORTLS_EXPORT int X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *dir); VIGORTLS_EXPORT int X509_STORE_set_default_paths(X509_STORE *ctx); VIGORTLS_EXPORT int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); VIGORTLS_EXPORT int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); VIGORTLS_EXPORT void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx); VIGORTLS_EXPORT int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); VIGORTLS_EXPORT void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); VIGORTLS_EXPORT int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509_STORE_CTX * X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx); VIGORTLS_EXPORT STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx); VIGORTLS_EXPORT STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); VIGORTLS_EXPORT void X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x); VIGORTLS_EXPORT void X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); VIGORTLS_EXPORT void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk); VIGORTLS_EXPORT int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); VIGORTLS_EXPORT int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); VIGORTLS_EXPORT int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, int purpose, int trust); VIGORTLS_EXPORT void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); VIGORTLS_EXPORT void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, time_t t); VIGORTLS_EXPORT void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, int (*verify_cb)(int, X509_STORE_CTX *)); VIGORTLS_EXPORT X509_POLICY_TREE * X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); VIGORTLS_EXPORT int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); VIGORTLS_EXPORT X509_VERIFY_PARAM * X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); VIGORTLS_EXPORT void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); VIGORTLS_EXPORT int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); /* X509_VERIFY_PARAM functions */ VIGORTLS_EXPORT X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); VIGORTLS_EXPORT void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); VIGORTLS_EXPORT int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags); VIGORTLS_EXPORT int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, unsigned long flags); VIGORTLS_EXPORT unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); VIGORTLS_EXPORT void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); VIGORTLS_EXPORT void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); VIGORTLS_EXPORT int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, STACK_OF(ASN1_OBJECT) * policies); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen); VIGORTLS_EXPORT int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, const char *name, size_t namelen); VIGORTLS_EXPORT void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, unsigned int flags); VIGORTLS_EXPORT char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, size_t emaillen); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const uint8_t *ip, size_t iplen); VIGORTLS_EXPORT int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc); VIGORTLS_EXPORT int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); VIGORTLS_EXPORT const char * X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); VIGORTLS_EXPORT int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); VIGORTLS_EXPORT int X509_VERIFY_PARAM_get_count(void); VIGORTLS_EXPORT const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); VIGORTLS_EXPORT const X509_VERIFY_PARAM * X509_VERIFY_PARAM_lookup(const char *name); VIGORTLS_EXPORT void X509_VERIFY_PARAM_table_cleanup(void); VIGORTLS_EXPORT int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, STACK_OF(X509) *certs, STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags); VIGORTLS_EXPORT void X509_policy_tree_free(X509_POLICY_TREE *tree); VIGORTLS_EXPORT int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); VIGORTLS_EXPORT X509_POLICY_LEVEL * X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i); VIGORTLS_EXPORT STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree); VIGORTLS_EXPORT STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree); VIGORTLS_EXPORT int X509_policy_level_node_count(X509_POLICY_LEVEL *level); VIGORTLS_EXPORT X509_POLICY_NODE * X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i); VIGORTLS_EXPORT const ASN1_OBJECT * X509_policy_node_get0_policy(const X509_POLICY_NODE *node); VIGORTLS_EXPORT STACK_OF(POLICYQUALINFO) * X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node); VIGORTLS_EXPORT const X509_POLICY_NODE * X509_policy_node_get0_parent(const X509_POLICY_NODE *node); #ifdef __cplusplus } #endif #endif
46.318033
80
0.66026
d77a8b9eca329167be8943d3732ce27935141ad3
220
h
C
examples/gbs_sample_color/data/include/data/script_s13a0_interact.h
um3k/gbvm
dce728c5fd0d40c3f75b773660f475b4911d8121
[ "MIT" ]
33
2020-12-27T11:53:23.000Z
2022-02-19T23:05:12.000Z
examples/gbs_sample_color/data/include/data/script_s13a0_interact.h
um3k/gbvm
dce728c5fd0d40c3f75b773660f475b4911d8121
[ "MIT" ]
2
2020-12-10T16:53:53.000Z
2022-01-31T21:42:01.000Z
examples/gbs_sample_color/data/include/data/script_s13a0_interact.h
um3k/gbvm
dce728c5fd0d40c3f75b773660f475b4911d8121
[ "MIT" ]
6
2021-04-18T08:09:16.000Z
2022-01-31T21:52:24.000Z
#ifndef SCRIPT_S13A0_INTERACT_H #define SCRIPT_S13A0_INTERACT_H // Script script_s13a0_interact #include "gbs_types.h" BANKREF_EXTERN(script_s13a0_interact) extern const unsigned char script_s13a0_interact[]; #endif
18.333333
51
0.845455
443205ef2295517b738e306e03367f438518e0db
14,665
c
C
syslibs/ksxdr/source/KSDATAPACKET_xdrhandling_ov_specific.c
fransvanderlek/acplt-rte
8c664d247e4a0c9291b97aafc930c05341f3b048
[ "Apache-2.0" ]
18
2015-12-07T15:15:53.000Z
2021-10-07T04:09:36.000Z
syslibs/ksxdr/source/KSDATAPACKET_xdrhandling_ov_specific.c
fransvanderlek/acplt-rte
8c664d247e4a0c9291b97aafc930c05341f3b048
[ "Apache-2.0" ]
41
2015-12-08T13:31:41.000Z
2022-01-31T16:32:14.000Z
syslibs/ksxdr/source/KSDATAPACKET_xdrhandling_ov_specific.c
fransvanderlek/acplt-rte
8c664d247e4a0c9291b97aafc930c05341f3b048
[ "Apache-2.0" ]
12
2015-06-11T13:09:41.000Z
2019-02-07T13:33:37.000Z
/* * KSDATAPACKET_xdrhandling_ov_specific.c * * Created on: 18.02.2013 * Author: lars */ /* * The functions defined herein handle OV-specific datatypes. * there are more (specialized functions) for other datatypes (e.g. GETVAR_ITEM) they can be found in the respective ksxdr_xxx.c files. They were not put here in order * not to inflate this file too much */ #include "ksxdr.h" #include "ov_malloc.h" #include "ov_memstack.h" #include "ksbase_helper.h" #include <string.h> #include "KSDATAPACKET_xdrhandling.h" #include "ov_ksserver_backend.h" /* * XDR routines for OV_TIME */ OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_read_xdr_OV_TIME(KS_DATAPACKET* datapacket, OV_TIME *ptime) { OV_RESULT result; if(!ptime) return OV_ERR_BADPARAM; result = KS_DATAPACKET_read_xdr_uint(datapacket, &ptime->secs); if(Ov_Fail(result)) return result; return KS_DATAPACKET_read_xdr_uint(datapacket, &ptime->usecs); } OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_write_xdr_OV_TIME(KS_DATAPACKET* datapacket, const OV_TIME* ptime) { OV_RESULT result; if(!ptime) return OV_ERR_BADPARAM; result = KS_DATAPACKET_write_xdr_uint(datapacket, &ptime->secs); if(Ov_Fail(result)) return result; return KS_DATAPACKET_write_xdr_uint(datapacket, &ptime->usecs); } /* * XDR routines for OV_TIME_SPAN */ OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_read_xdr_OV_TIME_SPAN(KS_DATAPACKET* datapacket, OV_TIME_SPAN *ptimespan) { OV_RESULT result; if(!ptimespan) return OV_ERR_BADPARAM; result = KS_DATAPACKET_read_xdr_int(datapacket, &ptimespan->secs); if(Ov_Fail(result)) return result; return KS_DATAPACKET_read_xdr_int(datapacket, &ptimespan->usecs); } OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_write_xdr_OV_TIME_SPAN(KS_DATAPACKET* datapacket, const OV_TIME_SPAN* ptimespan) { OV_RESULT result; if(!ptimespan) return OV_ERR_BADPARAM; result = KS_DATAPACKET_write_xdr_int(datapacket, &ptimespan->secs); if(Ov_Fail(result)) return result; return KS_DATAPACKET_write_xdr_int(datapacket, &ptimespan->usecs); } /* * XDR routine for OV_NAMED_ELEMENT * These are used for example for structs * The read function allocates memory on the memstack */ OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_read_xdr_OV_NAMED_ELEMENT (KS_DATAPACKET* datapacket, OV_NAMED_ELEMENT* pNamedElement) { OV_RESULT result; if(!pNamedElement) return OV_ERR_BADPARAM; result = KS_DATAPACKET_read_xdr_string_tomemstack(datapacket, &pNamedElement->identifier, KS_NAME_MAXLEN); if(Ov_Fail(result)) return result; return KS_DATAPACKET_read_xdr_OV_VAR_VALUE(datapacket, &pNamedElement->value); } OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_write_xdr_OV_NAMED_ELEMENT (KS_DATAPACKET* datapacket, OV_NAMED_ELEMENT* pNamedElement) { OV_RESULT result; if(!pNamedElement) return OV_ERR_BADPARAM; if(pNamedElement && strlen(pNamedElement->identifier) > KS_NAME_MAXLEN) return OV_ERR_BADVALUE; result = KS_DATAPACKET_write_xdr_string(datapacket, &pNamedElement->identifier); if(Ov_Fail(result)) return result; return KS_DATAPACKET_write_xdr_OV_VAR_VALUE(datapacket, &pNamedElement->value); } /* * The following functions read or write OV_VAR_VALUEs. this is a synonym for ANY variables * The read-function allocates memory from the memstack */ OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_read_xdr_OV_VAR_VALUE(KS_DATAPACKET* datapacket, OV_VAR_VALUE* value) { OV_RESULT result; if(!value) return OV_ERR_BADPARAM; result = KS_DATAPACKET_read_xdr_OV_VAR_TYPE(datapacket, &value->vartype); if(Ov_Fail(result)) return result; switch(value->vartype & OV_VT_KSMASK) { case OV_VT_BOOL: return KS_DATAPACKET_read_xdr_OV_BOOL(datapacket, &value->valueunion.val_bool); case OV_VT_INT: return KS_DATAPACKET_read_xdr_int(datapacket, &value->valueunion.val_int); case OV_VT_STATE: return KS_DATAPACKET_read_xdr_OV_STATE(datapacket, &value->valueunion.val_state); case OV_VT_UINT: return KS_DATAPACKET_read_xdr_uint(datapacket, &value->valueunion.val_uint); case OV_VT_SINGLE: return KS_DATAPACKET_read_xdr_single(datapacket, &value->valueunion.val_single); case OV_VT_DOUBLE: return KS_DATAPACKET_read_xdr_double(datapacket, &value->valueunion.val_double); case OV_VT_STRING: return KS_DATAPACKET_read_xdr_string_tomemstack_wolength(datapacket, &value->valueunion.val_string); case OV_VT_TIME: return KS_DATAPACKET_read_xdr_OV_TIME(datapacket, &value->valueunion.val_time); case OV_VT_TIME_SPAN: return KS_DATAPACKET_read_xdr_OV_TIME_SPAN(datapacket, &value->valueunion.val_time_span); case OV_VT_STRUCT: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_struct.value, sizeof(OV_NAMED_ELEMENT), &value->valueunion.val_struct.elements, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_OV_NAMED_ELEMENT); case OV_VT_BOOL_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_bool_vec.value, sizeof(OV_BOOL), &value->valueunion.val_bool_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_int); case OV_VT_INT_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_int_vec.value, sizeof(OV_INT), &value->valueunion.val_int_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_int); case OV_VT_STATE_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_state_vec.value, sizeof(OV_STATE), &value->valueunion.val_state_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_uint); case OV_VT_UINT_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_uint_vec.value, sizeof(OV_UINT), &value->valueunion.val_uint_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_uint); case OV_VT_SINGLE_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_single_vec.value, sizeof(OV_SINGLE), &value->valueunion.val_single_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_single); case OV_VT_DOUBLE_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_double_vec.value, sizeof(OV_DOUBLE), &value->valueunion.val_double_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_double); case OV_VT_STRING_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_string_vec.value, sizeof(OV_STRING), &value->valueunion.val_string_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_string_tomemstack_wolength); case OV_VT_TIME_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_time_vec.value, sizeof(OV_TIME), &value->valueunion.val_time_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_OV_TIME); case OV_VT_TIME_SPAN_VEC: return KS_DATAPACKET_read_xdr_array_tomemstack(datapacket, (void**) &value->valueunion.val_time_span_vec.value, sizeof(OV_TIME_SPAN), &value->valueunion.val_time_span_vec.veclen, (xdr_readfncptr) &KS_DATAPACKET_read_xdr_OV_TIME_SPAN); case OV_VT_VOID: return OV_ERR_OK; case OV_VT_BYTE_VEC: return KS_DATAPACKET_read_xdr_opaque_tomemstack(datapacket, (char**) &value->valueunion.val_byte_vec.value, &value->valueunion.val_byte_vec.veclen, ~0); default: break; } return OV_ERR_BADTYPE; } OV_DLLFNCEXPORT OV_RESULT KS_DATAPACKET_write_xdr_OV_VAR_VALUE(KS_DATAPACKET* datapacket, OV_VAR_VALUE* value) { OV_RESULT result; OV_VAR_TYPE temptype = (value->vartype & OV_VT_KSMASK); if(!value) return OV_ERR_BADPARAM; result = KS_DATAPACKET_write_xdr_OV_VAR_TYPE(datapacket, &temptype); if(Ov_Fail(result)) return result; switch(value->vartype & temptype) { case OV_VT_BOOL: return KS_DATAPACKET_write_xdr_OV_BOOL(datapacket, &value->valueunion.val_bool); case OV_VT_INT: return KS_DATAPACKET_write_xdr_int(datapacket, &value->valueunion.val_int); case OV_VT_STATE: return KS_DATAPACKET_write_xdr_OV_STATE(datapacket, &value->valueunion.val_state); case OV_VT_UINT: return KS_DATAPACKET_write_xdr_uint(datapacket, &value->valueunion.val_uint); case OV_VT_SINGLE: return KS_DATAPACKET_write_xdr_single(datapacket, &value->valueunion.val_single); case OV_VT_DOUBLE: return KS_DATAPACKET_write_xdr_double(datapacket, &value->valueunion.val_double); case OV_VT_STRING: return KS_DATAPACKET_write_xdr_string(datapacket, &value->valueunion.val_string); case OV_VT_TIME: return KS_DATAPACKET_write_xdr_OV_TIME(datapacket, &value->valueunion.val_time); case OV_VT_TIME_SPAN: return KS_DATAPACKET_write_xdr_OV_TIME_SPAN(datapacket, &value->valueunion.val_time_span); case OV_VT_STRUCT: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_struct.value, sizeof(OV_NAMED_ELEMENT), &value->valueunion.val_struct.elements, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_OV_NAMED_ELEMENT); case OV_VT_BOOL_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_bool_vec.value, sizeof(OV_BOOL), &value->valueunion.val_bool_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_int); case OV_VT_INT_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_int_vec.value, sizeof(OV_INT), &value->valueunion.val_int_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_int); case OV_VT_STATE_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_state_vec.value, sizeof(OV_STATE), &value->valueunion.val_state_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_uint); case OV_VT_UINT_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_uint_vec.value, sizeof(OV_UINT), &value->valueunion.val_uint_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_uint); case OV_VT_SINGLE_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_single_vec.value, sizeof(OV_SINGLE), &value->valueunion.val_single_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_single); case OV_VT_DOUBLE_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_double_vec.value, sizeof(OV_DOUBLE), &value->valueunion.val_double_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_double); case OV_VT_STRING_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_string_vec.value, sizeof(OV_STRING), &value->valueunion.val_string_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_string); case OV_VT_TIME_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_time_vec.value, sizeof(OV_TIME), &value->valueunion.val_time_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_OV_TIME); case OV_VT_TIME_SPAN_VEC: return KS_DATAPACKET_write_xdr_array(datapacket, (void**) &value->valueunion.val_time_span_vec.value, sizeof(OV_TIME_SPAN), &value->valueunion.val_time_span_vec.veclen, (xdr_writefncptr) &KS_DATAPACKET_write_xdr_OV_TIME_SPAN); case OV_VT_VOID: return OV_ERR_OK; case OV_VT_BYTE_VEC: return KS_DATAPACKET_write_xdr_opaque(datapacket, (char*) value->valueunion.val_byte_vec.value, value->valueunion.val_byte_vec.veclen); default: break; } return OV_ERR_BADTYPE; } /* * XDR routine for OV_VAR_CURRENT_PROPS */ OV_RESULT xdr_read_OV_VAR_CURRENT_PROPS(KS_DATAPACKET* dataReceived, OV_VAR_CURRENT_PROPS* currprops) { OV_RESULT result; result = KS_DATAPACKET_read_xdr_OV_VAR_VALUE(dataReceived, &currprops->value); if(Ov_Fail(result)) return result; result = KS_DATAPACKET_read_xdr_OV_TIME(dataReceived, &currprops->time); if(Ov_Fail(result)) return result; return KS_DATAPACKET_read_xdr_OV_STATE(dataReceived, &currprops->state); } /* * XDR routine for OV_VAR_CURRENT_PROPS */ OV_RESULT xdr_write_OV_VAR_CURRENT_PROPS(KS_DATAPACKET* serviceAnswer, OV_VAR_CURRENT_PROPS* pProps) { OV_RESULT result; result = KS_DATAPACKET_write_xdr_OV_VAR_VALUE(serviceAnswer, &pProps->value); if(Ov_Fail(result)) return result; result = KS_DATAPACKET_write_xdr_OV_TIME(serviceAnswer, &pProps->time); if(Ov_Fail(result)) return result; return KS_DATAPACKET_write_xdr_OV_STATE(serviceAnswer, &pProps->state); } /* * XDR routine for OV_PLACEMENT */ OV_RESULT xdr_read_OV_PLACEMENT (KS_DATAPACKET* dataReceived, OV_PLACEMENT* pplacement) { OV_RESULT result; result = KS_DATAPACKET_read_xdr_OV_PLACEMENT_HINT(dataReceived, &pplacement->hint); if(Ov_Fail(result)) return result; switch(pplacement->hint) { case OV_PMH_BEFORE: case OV_PMH_AFTER: return KS_DATAPACKET_read_xdr_string_tomemstack_wolength(dataReceived, &pplacement->place_path); default: break; } return OV_ERR_OK; } OV_RESULT xdr_write_OV_PLACEMENT (KS_DATAPACKET* dataPacket, OV_PLACEMENT* pplacement) { OV_RESULT result; result = KS_DATAPACKET_write_xdr_OV_PLACEMENT_HINT(dataPacket, &pplacement->hint); if(Ov_Fail(result)) return result; switch(pplacement->hint) { case OV_PMH_BEFORE: case OV_PMH_AFTER: return KS_DATAPACKET_write_xdr_string(dataPacket, &pplacement->place_path); default: break; } return OV_ERR_OK; } /* ---------------------------------------------------------------------- */ /* * XDR routine for OV_LINK_ITEM */ OV_RESULT xdr_read_OV_LINK_ITEM (KS_DATAPACKET* dataReceived, OV_LINK_ITEM* pitem) { OV_RESULT result; result = KS_DATAPACKET_read_xdr_string_tomemstack_wolength(dataReceived, &pitem->link_path); if(Ov_Fail(result)) return result; result = KS_DATAPACKET_read_xdr_string_tomemstack_wolength(dataReceived, &pitem->element_path); if(Ov_Fail(result)) return result; result = xdr_read_OV_PLACEMENT(dataReceived, &pitem->place); if(Ov_Fail(result)) return result; return xdr_read_OV_PLACEMENT(dataReceived, &pitem->opposite_place); } OV_RESULT xdr_write_OV_LINK_ITEM (KS_DATAPACKET* dataPacket, OV_LINK_ITEM* pitem) { OV_RESULT result; result = KS_DATAPACKET_write_xdr_string(dataPacket, &pitem->link_path); if(Ov_Fail(result)) return result; result = KS_DATAPACKET_write_xdr_string(dataPacket, &pitem->element_path); if(Ov_Fail(result)) return result; result = xdr_write_OV_PLACEMENT(dataPacket, &pitem->place); if(Ov_Fail(result)) return result; return xdr_write_OV_PLACEMENT(dataPacket, &pitem->opposite_place); }
39.00266
168
0.78043
be5cfdab0cc940007569a828a44c24c91f7a5a96
226
h
C
xfile/XFile.h
ryutorion/DirectX11ShaderProgrammingBook
2407dafec283bac2f195bcdf48ffae024f819d80
[ "MIT" ]
2
2021-01-12T13:40:45.000Z
2021-01-12T23:55:22.000Z
xfile/XFile.h
ryutorion/DirectX11ShaderProgrammingBook
2407dafec283bac2f195bcdf48ffae024f819d80
[ "MIT" ]
null
null
null
xfile/XFile.h
ryutorion/DirectX11ShaderProgrammingBook
2407dafec283bac2f195bcdf48ffae024f819d80
[ "MIT" ]
null
null
null
#pragma once #ifndef XFILE_XFILE_H_INCLUDED #define XFILE_XFILE_H_INCLUDED #include <vector> #include "XFileMesh.h" namespace xfile { struct XFile { std::vector<XFileMesh> meshes; }; } #endif // XFILE_XFILE_H_INCLUDED
13.294118
32
0.761062
67e8ffc17f7db5d3772242d2a5345eb5ba83d187
2,148
h
C
variants/WIO_3G/variant.h
mnakai3/Arduino_Core_STM32
2e9b78374012217674c998ca26ae2b0cb901a148
[ "Apache-2.0" ]
null
null
null
variants/WIO_3G/variant.h
mnakai3/Arduino_Core_STM32
2e9b78374012217674c998ca26ae2b0cb901a148
[ "Apache-2.0" ]
null
null
null
variants/WIO_3G/variant.h
mnakai3/Arduino_Core_STM32
2e9b78374012217674c998ca26ae2b0cb901a148
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2011 Arduino. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _VARIANT_ARDUINO_STM32_ #define _VARIANT_ARDUINO_STM32_ #ifdef __cplusplus extern "C"{ #endif // __cplusplus /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ #define PINNAME_TO_PIN(port, pin) ((port - 'A') * 16 + pin) // This must be a literal #define NUM_DIGITAL_PINS (80+NUM_ANALOG_INPUTS) // This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS #define NUM_ANALOG_INPUTS (16) #define NUM_ANALOG_FIRST (80) // SPI Definitions #define PIN_SPI_SS PINNAME_TO_PIN('D', 0) #define PIN_SPI_MOSI PINNAME_TO_PIN('C', 12) #define PIN_SPI_MISO PINNAME_TO_PIN('C', 11) #define PIN_SPI_SCK PINNAME_TO_PIN('C', 10) // I2C Definitions #define PIN_WIRE_SDA PINNAME_TO_PIN('B', 9) #define PIN_WIRE_SCL PINNAME_TO_PIN('B', 8) // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM. #define TIMER_TONE TIM6 #define TIMER_SERVO TIM2 // UART Definitions #define SERIAL_UART_INSTANCE (1) #define PIN_SERIAL_RX PINNAME_TO_PIN('B', 7) #define PIN_SERIAL_TX PINNAME_TO_PIN('B', 6) #ifdef __cplusplus } // extern "C" #endif #endif /* _VARIANT_ARDUINO_STM32_ */
34.095238
81
0.657821
170cc7fd251cfdab6b6d1bbe7b35405401f10d5c
8,546
h
C
Standard/Rect.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
32
2016-05-22T23:09:19.000Z
2022-03-13T03:32:27.000Z
Standard/Rect.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
2
2016-05-30T19:45:58.000Z
2018-01-24T22:29:51.000Z
Standard/Rect.h
CarysT/medusa
8e79f7738534d8cf60577ec42ed86621533ac269
[ "MIT" ]
17
2016-05-27T11:01:42.000Z
2022-03-13T03:32:30.000Z
/* Rect.h Rect template class (c)2005 Palestar, Richard Lyle */ #ifndef RECT_H #define RECT_H #include "Point.h" #include "Size.h" //---------------------------------------------------------------------------- template<class T> class Rect { public: // construction Rect(); Rect(const Point<T> &point, const Size<T> &size); Rect(T X, T Y, Size<T> size); Rect(T left, T top, T right, T bottom); // accessors bool valid() const; // is this rectangle valid T width() const; // right - left + 1 T height() const; // bottom - top + 1 Size<T> size() const; // get the size of the rectangle bool inRect( int x, int y ) const; bool inRect( const Point<T> & point ) const; bool inRect( const Rect<T> & rect ) const; Point<T> center() const; Point<T> upperLeft() const; // corners of this rectangle Point<T> upperRight() const; Point<T> lowerLeft() const; Point<T> lowerRight() const; bool operator==(const Rect<T>& Rhs); bool operator!=(const Rect<T>& Rhs); Rect<T> scale(T scaleWidth,T scaleHeight) const; Rect<T> operator+(const Point<T> &Rhs) const; Rect<T> operator-(const Point<T> &Rhs) const; // mutators Rect<T>& setInvalid(); void setLeft(const T Left); void setTop(const T Top); void setRight(const T Right); void setBottom(const T Bottom); void setWidth(const T Width); // expands to the right void setHeight(const T Height); // expands to the bottom void set(T left,T top,T right,T bottom); void set(T X, T Y, const Size<T> & size); void set(const Point<T> &point,const Size<T> &size); Rect<T>& inset( T inset ); // >0 inset or <0 outset the rectangle Rect<T>& operator=(const Rect<T> &Rhs); Rect<T>& operator+=(const Point<T> & Rhs); Rect<T>& operator-=(const Point<T>& Rhs); Rect<T>& operator&=(const Rect<T>& Rhs); // Intersection Rect<T>& operator|=(const Rect<T>& Rhs); // Union Rect<T>& operator*=(const T Multiplier); Rect<T>& operator/=(const T Divisor); Rect<T> operator&(const Rect<T>& Rhs); Rect<T> operator|(const Rect<T>& Rhs); // Data union { T m_Left, left; }; union { T m_Top, top; }; union { T m_Right, right; }; union { T m_Bottom, bottom; }; }; //------------------------------------------------------------------------------- template<class T> inline Rect<T>::Rect() { set(0,0,0,0); } template<class T> inline Rect<T>::Rect(const Point<T> &point, const Size<T> &size) { set(point,size); } template<class T> inline Rect<T>::Rect(T X, T Y, Size<T> size) { set(X,Y,size); } template<class T> inline Rect<T>::Rect(T left, T top, T right, T bottom) { set(left,top,right,bottom); } //------------------------------------------------------------------------------- template<class T> inline bool Rect<T>::valid() const { return( (m_Left <= m_Right) && (m_Top <= m_Bottom) ); } template<class T> inline T Rect<T>::width() const { return( (m_Right - m_Left) + 1); } template<class T> inline T Rect<T>::height() const { return( (m_Bottom - m_Top) + 1); } template<class T> inline Size<T> Rect<T>::size() const { return( Size<T>( width(), height() ) ); } template<class T> inline bool Rect<T>::inRect( int x, int y ) const { return( x >= m_Left && x <= m_Right && y >= m_Top && y <= m_Bottom ); } template<class T> inline bool Rect<T>::inRect( const Point<T> & point ) const { return( point.x >= m_Left && point.x <= m_Right && point.y >= m_Top && point.y <= m_Bottom ); } template<class T> inline bool Rect<T>::inRect( const Rect<T> & rect ) const { return( m_Left <= rect.m_Left && m_Right >= rect.m_Right && m_Top <= rect.m_Top && m_Bottom >= rect.m_Bottom ); } template<class T> inline Point<T> Rect<T>::center() const { return(Point<T>( (m_Left + m_Right) / 2, (m_Top + m_Bottom) / 2 ) ); } template<class T> inline Point<T> Rect<T>::upperLeft() const { return(Point<T>( m_Left, m_Top) ); } template<class T> inline Point<T> Rect<T>::upperRight() const { return(Point<T>( m_Right, m_Top) ); } template<class T> inline Point<T> Rect<T>::lowerLeft() const { return(Point<T>( m_Left, m_Bottom ) ); } template<class T> inline Point<T> Rect<T>::lowerRight() const { return(Point<T>( m_Right, m_Bottom) ); } template<class T> inline Rect<T> Rect<T>::scale(T scaleWidth,T scaleHeight) const { Rect<T> result( *this ); result.m_Left *= scaleWidth; result.m_Right *= scaleWidth; result.m_Top *= scaleHeight; result.m_Bottom *= scaleHeight; return(result); } template<class T> inline bool Rect<T>::operator==(const Rect<T>& Rhs) { return(m_Left == Rhs.m_Left && m_Top == Rhs.m_Top && m_Right == Rhs.m_Right && m_Bottom == Rhs.m_Bottom); } template<class T> inline bool Rect<T>::operator!=(const Rect<T>& Rhs) { return(!(*this == Rhs)); } //------------------------------------------------------------------------------- template<class T> inline Rect<T>& Rect<T>::setInvalid() { set( 1,1,-1,-1 ); return( *this ); } template<class T> inline void Rect<T>::setLeft(const T Left) { m_Left = Left; } template<class T> inline void Rect<T>::setTop(const T Top) { m_Top = Top; } template<class T> inline void Rect<T>::setRight(const T Right) { m_Right = Right; } template<class T> inline void Rect<T>::setBottom(const T Bottom) { m_Bottom = Bottom; } template<class T> inline void Rect<T>::setWidth(const T Width) { m_Right = m_Left + (Width - 1); } template<class T> inline void Rect<T>::setHeight(const T Height) { m_Bottom = m_Top + (Height - 1); } template<class T> inline void Rect<T>::set(T left,T top,T right,T bottom) { m_Left = left; m_Top = top; m_Right = right; m_Bottom = bottom; } template<class T> inline void Rect<T>::set(T X, T Y, const Size<T> & size) { m_Left = X; m_Top = Y; m_Right = X + size.width - 1; m_Bottom = Y + size.height - 1; } template<class T> inline void Rect<T>::set(const Point<T> &point,const Size<T> &size) { m_Left = point.x; m_Top = point.y; m_Right = m_Left + size.width - 1; m_Bottom = m_Top + size.height - 1; } template<class T> inline Rect<T>& Rect<T>::inset( T inset ) { m_Left += inset; m_Top += inset; m_Right -= inset; m_Bottom -= inset; return *this; } template<class T> inline Rect<T>& Rect<T>::operator=(const Rect<T> &Rhs) { m_Left = Rhs.m_Left; m_Top = Rhs.m_Top; m_Right = Rhs.m_Right; m_Bottom = Rhs.m_Bottom; return(*this); } template<class T> inline Rect<T>& Rect<T>::operator+=(const Point<T> & Rhs) { m_Left += Rhs.x; m_Top += Rhs.y; m_Right += Rhs.x; m_Bottom += Rhs.y; return(*this); } template<class T> inline Rect<T>& Rect<T>::operator-=(const Point<T>& Rhs) { m_Left -= Rhs.x; m_Top -= Rhs.y; m_Right -= Rhs.x; m_Bottom -= Rhs.y; return(*this); } template<class T> inline Rect<T> Rect<T>::operator+(const Point<T> &Rhs) const { Rect result = *this; result += Rhs; return( result ); } template<class T> inline Rect<T> Rect<T>::operator-(const Point<T> &Rhs) const { Rect result = *this; result -= Rhs; return( result ); } template<class T> inline Rect<T>& Rect<T>::operator&=(const Rect<T>& Rhs) // intersect with Rhs { if(m_Left < Rhs.m_Left) m_Left = Rhs.m_Left; if(m_Top < Rhs.m_Top) m_Top = Rhs.m_Top; if(m_Right > Rhs.m_Right) m_Right = Rhs.m_Right; if(m_Bottom > Rhs.m_Bottom) m_Bottom = Rhs.m_Bottom; return(*this); } template<class T> inline Rect<T>& Rect<T>::operator|=(const Rect<T>& Rhs) // union with Rhs { if(m_Left > Rhs.m_Left) m_Left = Rhs.m_Left; if(m_Top > Rhs.m_Top) m_Top = Rhs.m_Top; if(m_Right < Rhs.m_Right) m_Right = Rhs.m_Right; if(m_Bottom < Rhs.m_Bottom) m_Bottom = Rhs.m_Bottom; return(*this); } template<class T> inline Rect<T>& Rect<T>::operator*=(const T Multiplier) { m_Left *= Multiplier; m_Top *= Multiplier; m_Right *= Multiplier; m_Bottom *= Multiplier; return(*this); } template<class T> inline Rect<T>& Rect<T>::operator/=(const T Divisor) { m_Left /= Divisor; m_Top /= Divisor; m_Right /= Divisor; m_Bottom /= Divisor; return(*this); } template<class T> inline Rect<T> Rect<T>::operator&(const Rect<T>& Rhs) { Rect<T> result(*this); result &= Rhs; return(result); } template<class T> inline Rect<T> Rect<T>::operator|(const Rect<T>& Rhs) { Rect<T> result(*this); result |= Rhs; return(result); } //------------------------------------------------------------------------------- typedef Rect<int> RectInt; typedef Rect<float> RectFloat; #endif //---------------------------------------------------------------------------- // EOF
19.600917
81
0.60227
44c6c9187b7a62c7e6b528ae705388f0c1af2de5
654
h
C
DdckMerchantIos/DotMerchant/Home/View/Cell/ PaperManager/DTPaperManagerTableViewCell.h
dander521/DDMerchant
cb2e09d14cd8b82313d77fa5b002eed6a01d86f3
[ "MIT" ]
null
null
null
DdckMerchantIos/DotMerchant/Home/View/Cell/ PaperManager/DTPaperManagerTableViewCell.h
dander521/DDMerchant
cb2e09d14cd8b82313d77fa5b002eed6a01d86f3
[ "MIT" ]
null
null
null
DdckMerchantIos/DotMerchant/Home/View/Cell/ PaperManager/DTPaperManagerTableViewCell.h
dander521/DDMerchant
cb2e09d14cd8b82313d77fa5b002eed6a01d86f3
[ "MIT" ]
null
null
null
// // DTPaperManagerTableViewCell.h // DotMerchant // // Created by 倩倩 on 2017/9/17. // Copyright © 2017年 RogerChen. All rights reserved. // #import <UIKit/UIKit.h> #import "DTPaperListModel.h" typedef NS_ENUM(NSInteger, DTPaperManagerTableViewCellType) { DTPaperManagerTableViewCellTypeTitle = 0, DTPaperManagerTableViewCellTypeContent }; @interface DTPaperManagerTableViewCell : TXSeperateLineCell @property (nonatomic, assign) DTPaperManagerTableViewCellType cellType; /** <#description#> */ @property (nonatomic, strong) DTPaperList *listModel; /** * cell 实例方法 */ + (instancetype)cellWithTableView:(UITableView *)tableView; @end
22.551724
71
0.761468
a3a150323bc94b459ae70fd6a3613e6712bfab08
1,013
h
C
UWP/RadialDevice/winrt/internal/Windows.Phone.System.2.h
megayuchi/RadialController
87bb1baa72a0b43b1b7b0d7787b0a93edc7e3175
[ "MIT" ]
23
2016-11-28T05:47:06.000Z
2020-11-13T20:13:47.000Z
UWP/RadialDevice/winrt/internal/Windows.Phone.System.2.h
megayuchi/RadialController
87bb1baa72a0b43b1b7b0d7787b0a93edc7e3175
[ "MIT" ]
null
null
null
UWP/RadialDevice/winrt/internal/Windows.Phone.System.2.h
megayuchi/RadialController
87bb1baa72a0b43b1b7b0d7787b0a93edc7e3175
[ "MIT" ]
5
2017-01-21T14:42:47.000Z
2022-02-24T03:42:24.000Z
// C++ for the Windows Runtime v1.0.161012.5 // Copyright (c) 2016 Microsoft Corporation. All rights reserved. #pragma once #include "Windows.Phone.System.1.h" WINRT_EXPORT namespace winrt { namespace Windows::Phone::System { template <typename D> struct WINRT_EBO impl_ISystemProtectionStatics { bool ScreenLocked() const; }; template <typename D> struct WINRT_EBO impl_ISystemProtectionUnlockStatics { void RequestScreenUnlock() const; }; struct ISystemProtectionStatics : Windows::IInspectable, impl::consume<ISystemProtectionStatics> { ISystemProtectionStatics(std::nullptr_t = nullptr) noexcept {} auto operator->() const noexcept { return ptr<ISystemProtectionStatics>(m_ptr); } }; struct ISystemProtectionUnlockStatics : Windows::IInspectable, impl::consume<ISystemProtectionUnlockStatics> { ISystemProtectionUnlockStatics(std::nullptr_t = nullptr) noexcept {} auto operator->() const noexcept { return ptr<ISystemProtectionUnlockStatics>(m_ptr); } }; } }
23.55814
91
0.759131
2875f092630597079b4744016c69d8cc1a14cfe1
723
c
C
Labosi/cetvrti/2.c
MrHighTech/UPRO
1824a9ef4fd136f68459c049619e8feb611d10a2
[ "MIT" ]
null
null
null
Labosi/cetvrti/2.c
MrHighTech/UPRO
1824a9ef4fd136f68459c049619e8feb611d10a2
[ "MIT" ]
null
null
null
Labosi/cetvrti/2.c
MrHighTech/UPRO
1824a9ef4fd136f68459c049619e8feb611d10a2
[ "MIT" ]
null
null
null
#include <stdio.h> int main(void) { int n, i, j; printf("Upisite dimenziju matrice > "); scanf("%d", &n); printf("Upisite elemente matrice > "); int mat[n + 1][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%d", &mat[i][j]); } } for (j = 0; j < n; j++) { mat[i][j] = 0; } int brojac = 0; for (j = 0; j < n; j++) { brojac = 0; for (i = 0; i < n; i++) { brojac += mat[i][j]; } if (brojac % 2 != 0) { mat[i][j] = 1; } } printf("Nova matrica:\n"); for (i = 0; i <= n; i++) { for (j = 0; j < n; j++) { printf("%d ", mat[i][j]); } printf("\n"); } return 0; }
18.538462
42
0.365145
d18963b010f37fcae1f7e23559747789539ae8dc
1,512
h
C
Applications/Podcasts/MTTVMediaItem.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
Applications/Podcasts/MTTVMediaItem.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
Applications/Podcasts/MTTVMediaItem.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
// // Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20). // // Copyright (C) 1997-2019 Steve Nygard. // #import <objc/NSObject.h> #import "TVPMediaItem-Protocol.h" @class MTPlayerItem, NSString; @interface MTTVMediaItem : NSObject <TVPMediaItem> { MTPlayerItem *_playerItem; // 8 = 0x8 } - (void).cxx_destruct; // IMP=0x000000010002bc60 @property(retain, nonatomic) MTPlayerItem *playerItem; // @synthesize playerItem=_playerItem; - (id)reportingDelegate; // IMP=0x000000010002bc44 - (void)updateBookmarkWithSuggestedTime:(double)arg1 forElapsedTime:(double)arg2 duration:(double)arg3 playbackOfMediaItemIsEnding:(_Bool)arg4; // IMP=0x000000010002bc40 - (void)performMediaItemMetadataTransactionWithBlock:(CDUnknownBlockType)arg1; // IMP=0x000000010002bc34 - (void)removeMediaItemMetadataForProperty:(id)arg1; // IMP=0x000000010002bc30 - (void)setMediaItemMetadata:(id)arg1 forProperty:(id)arg2; // IMP=0x000000010002bc2c - (id)mediaItemMetadataForProperty:(id)arg1; // IMP=0x000000010002b08c - (_Bool)hasTrait:(id)arg1; // IMP=0x000000010002b014 - (_Bool)isEqualToMediaItem:(id)arg1; // IMP=0x000000010002af38 - (id)mediaItemURL; // IMP=0x000000010002aee4 - (id)initWithMediaItem:(id)arg1; // IMP=0x000000010002ae70 // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
38.769231
169
0.778439
946a1e4bd00aed840c687beca1e18c08b5fbed0b
4,082
h
C
Library/Tools/include/nova/Tools/Log/Log.h
OrionQuest/Nova
473a4df24191097c6542c3ec935b3d1bdd2cf13a
[ "Apache-2.0" ]
23
2018-08-24T01:40:56.000Z
2021-01-14T06:58:44.000Z
Library/Tools/include/nova/Tools/Log/Log.h
SoldierDown/Nova
d2da3ee316687316d5a858cd2b95605c483859db
[ "Apache-2.0" ]
2
2017-07-04T11:25:17.000Z
2020-10-10T12:31:01.000Z
Library/Tools/include/nova/Tools/Log/Log.h
SoldierDown/Nova
d2da3ee316687316d5a858cd2b95605c483859db
[ "Apache-2.0" ]
7
2017-07-02T01:10:05.000Z
2020-01-29T17:59:31.000Z
//!##################################################################### //! \file Log.h //!##################################################################### // Class Log //###################################################################### #ifndef __Log__ #define __Log__ #include <nova/Tools/Utilities/Non_Copyable.h> #include <nova/Tools/Utilities/Timer.h> #include <cassert> #include <ostream> #include <sstream> namespace Nova{ #define Log_Real Log namespace Log_Null{ struct log_null_class{ template<class T> log_null_class& operator<<(const T&) {return *this;} log_null_class& operator<<(std::ostream& (*)(std::ostream&)) {return *this;} template<class T> void flags(const T&); template<class T> void width(const T&); template<class A,class B> void Copy_Log_To_File(const A&,const B&) {} }; extern log_null_class cout; extern log_null_class cerr; template<class T> inline void Time(const T&) {} template<class A,class B> inline void Stat(const A&,const B&) {} inline void Stop_Time() {} inline void Finish_Logging() {} template<class A,class B,class C,class D> inline void Initialize_Logging(const A&,const B&,const C&,const D&) {} inline log_null_class* Instance() {return &cout;} struct Scope { template<class A> Scope(const A&) {} template<class A,class B> Scope(const A&,const B&) {} template<class A,class B,class C> Scope(const A&,const B&,const C&) {} template<class A,class B,class C,class D> Scope(const A&,const B&,const C&,const D&) {} template<class A,class B,class C,class D,class E> Scope(const A&,const B&,const C&,const D&,const E&) {} void Pop() {} }; } namespace Log_Real{ class Log_Entry; class Log_Scope; class Log_Class { friend class Log_Entry; friend class Log_Scope; friend class Log_Cout_Buffer; friend class Log_Cerr_Buffer; friend void Reset(); friend void Dump_Log(); public: Timer* timer_singleton; int timer_id; bool suppress_cout,suppress_cerr; bool suppress_timing; FILE* log_file; int verbosity_level; bool log_file_temporary; bool xml; Log_Entry* root; Log_Entry* current_entry; Log_Class(const bool suppress_cout,const bool suppress_cerr,const bool suppress_timing,const int verbosity_level,const bool cache_initial_output); ~Log_Class(); static void Push_Scope(const std::string& scope_identifier,const std::string& scope_name); static void Pop_Scope(); static void Time_Helper(const std::string& label); void Copy_Log_To_File(const std::string& filename,const bool append); }; class Scope: public Non_Copyable { bool active; public: Scope() :active(false) {} Scope(const std::string& scope_identifier) :active(true) { Log_Class::Push_Scope(scope_identifier,scope_identifier); } Scope(const std::string& scope_identifier,const std::string& scope_name) :active(true) { Log_Class::Push_Scope(scope_identifier,scope_name); } ~Scope(); void Push(const std::string& scope_identifier,const std::string& scope_name) {assert(!active);active=true;Log_Class::Push_Scope(scope_identifier,scope_name);} void Pop() {assert(active);active=false;Log_Class::Pop_Scope();} }; Log_Class* Instance(); std::ostream& cout_Helper(); std::ostream& cerr_Helper(); namespace{ static std::ostream& cout = ::Nova::Log_Real::cout_Helper(); static std::ostream& cerr = ::Nova::Log_Real::cerr_Helper(); } void Initialize_Logging(const bool suppress_cout_input=false,const bool suppress_timing_input=false,const int verbosity_level_input=1<<30,const bool cache_initial_output=false); void Finish_Logging(); void Stop_Time(); void Stat_Helper(const std::string& label,const std::stringstream& s); template<class T_VALUE> void Stat(const std::string& label,const T_VALUE& value) {std::stringstream s;s<<value;Stat_Helper(label,s);} void Reset(); void Dump_log(); inline void Time(const std::string& format) { if(Instance()->suppress_timing) return; Log_Class::Time_Helper(format); } } } #endif
29.157143
177
0.673689
7f5cb98af63e97ca2561c69c5c447b823cd86494
238
c
C
d/shadow/room/deep_echos/14.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/shadow/room/deep_echos/14.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/shadow/room/deep_echos/14.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
//14.c inherits from 01 like many others #include <std.h> #include "deep_echo.h" inherit DEEP; void create(){ ::create(); set_exits(([ "west" : ROOMS"11", "east" : ROOMS"30", "south" : ROOMS"23", ])); }
14.875
41
0.542017
3d13787f81ec059fb0227a967514798e10626160
488
c
C
src/slibc/slibc_u64_to_string.c
kissen/slibc
3a92342150aad287858168bb0a991e9c13543f1b
[ "Apache-2.0" ]
null
null
null
src/slibc/slibc_u64_to_string.c
kissen/slibc
3a92342150aad287858168bb0a991e9c13543f1b
[ "Apache-2.0" ]
null
null
null
src/slibc/slibc_u64_to_string.c
kissen/slibc
3a92342150aad287858168bb0a991e9c13543f1b
[ "Apache-2.0" ]
null
null
null
#include "slibc.h" #include "string.h" #include "unistd.h" const char *slibc_u64_to_string(slibc_u64 k) { // special case zero if (k == 0) { return "0"; } // regular case non-zero static char buffer[32]; slibc_u64 remaining = k; ssize_t i = sizeof(buffer) - 1; while (remaining > 0 && i >= 1) { i -= 1; const slibc_u64 digit = remaining % 10; const char asciidigit = digit + '0'; buffer[i] = asciidigit; remaining = remaining / 10; } return buffer + i; }
14.352941
44
0.625
3658a36d2b2a6acd95c4fb309aed736e3cc41522
214
h
C
DirectX3D11/Framework/Model/Model.h
GyumLee/DirectX3D11
6158874aa12e790747e6fd8a53de608071c49574
[ "Apache-2.0" ]
null
null
null
DirectX3D11/Framework/Model/Model.h
GyumLee/DirectX3D11
6158874aa12e790747e6fd8a53de608071c49574
[ "Apache-2.0" ]
null
null
null
DirectX3D11/Framework/Model/Model.h
GyumLee/DirectX3D11
6158874aa12e790747e6fd8a53de608071c49574
[ "Apache-2.0" ]
null
null
null
#pragma once class Model : public Transform { protected: ModelReader* reader; WorldBuffer* worldBuffer; public: Model(string name); ~Model(); void Render(); ModelReader* GetReader() { return reader; } };
12.588235
44
0.705607
d2401d334e96d6aaf0dc0be69fcd81bb5c62792e
1,331
h
C
System/Library/PrivateFrameworks/GeoServices.framework/GEOTransitLineItem.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
5
2021-04-29T04:31:43.000Z
2021-08-19T18:59:58.000Z
System/Library/PrivateFrameworks/GeoServices.framework/GEOTransitLineItem.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/GeoServices.framework/GEOTransitLineItem.h
lechium/tvOS145Headers
9940da19adb0017f8037853e9cfccbe01b290dd5
[ "MIT" ]
1
2022-03-19T11:16:23.000Z
2022-03-19T11:16:23.000Z
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, April 28, 2021 at 9:02:51 PM Mountain Standard Time * Operating System: Version 14.5 (Build 18L204) * Image Source: /System/Library/PrivateFrameworks/GeoServices.framework/GeoServices * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @class NSArray, GEOMapRegion; @protocol GEOTransitLineItem <GEOTransitLine> @property (nonatomic,readonly) NSArray * labelItems; @property (nonatomic,readonly) id<GEOTransitAttribution> attribution; @property (nonatomic,readonly) GEOMapRegion * mapRegion; @property (nonatomic,readonly) NSArray * incidents; @property (nonatomic,readonly) BOOL isIncidentsTTLExpired; @property (nonatomic,readonly) BOOL hasIncidentComponent; @property (nonatomic,readonly) BOOL hasEncyclopedicInfo; @property (nonatomic,readonly) id<GEOEncyclopedicInfo> encyclopedicInfo; @required -(NSArray *)incidents; -(id<GEOTransitAttribution>)attribution; -(GEOMapRegion *)mapRegion; -(BOOL)hasEncyclopedicInfo; -(id<GEOEncyclopedicInfo>)encyclopedicInfo; -(NSArray *)labelItems; -(BOOL)isIncidentsTTLExpired; -(BOOL)hasIncidentComponent; @end
40.333333
130
0.7145
82c2eff1391d962fead522e1a16131f67a4755c7
2,153
h
C
include/pkmn-c/daycare.h
ncorgan/libpkmn
c683bf8b85b03eef74a132b5cfdce9be0969d523
[ "MIT" ]
4
2017-06-10T13:21:44.000Z
2019-10-30T21:20:19.000Z
include/pkmn-c/daycare.h
PMArkive/libpkmn
c683bf8b85b03eef74a132b5cfdce9be0969d523
[ "MIT" ]
12
2017-04-05T11:13:34.000Z
2018-06-03T14:31:03.000Z
include/pkmn-c/daycare.h
PMArkive/libpkmn
c683bf8b85b03eef74a132b5cfdce9be0969d523
[ "MIT" ]
2
2019-01-22T21:02:31.000Z
2019-10-30T21:20:20.000Z
/* * p_Copyright (c) 2016-2018 Nicholas Corgan (n.corgan@gmail.com) * * p_Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * p_or copy at http://opensource.org/licenses/MIT) */ #ifndef PKMN_C_DAYCARE_H #define PKMN_C_DAYCARE_H #include <pkmn-c/config.h> #include <pkmn-c/error.h> #include <pkmn-c/pokemon.h> #include <pkmn-c/enums/game.h> #include <pkmn-c/types/pokemon_list.h> #include <stdbool.h> struct pkmn_daycare { enum pkmn_game game; bool can_breed_pokemon; size_t levelup_pokemon_capacity; size_t breeding_pokemon_capacity; void* p_internal; }; #ifdef __cplusplus extern "C" { #endif PKMN_C_API enum pkmn_error pkmn_daycare_init( enum pkmn_game game, struct pkmn_daycare* p_daycare_out ); PKMN_C_API enum pkmn_error pkmn_daycare_free( struct pkmn_daycare* p_daycare ); PKMN_C_API const char* pkmn_daycare_strerror( struct pkmn_daycare* p_daycare ); PKMN_C_API enum pkmn_error pkmn_daycare_get_levelup_pokemon( const struct pkmn_daycare* p_daycare, size_t index, struct pkmn_pokemon* p_levelup_pokemon_out ); PKMN_C_API enum pkmn_error pkmn_daycare_set_levelup_pokemon( const struct pkmn_daycare* p_daycare, size_t index, const struct pkmn_pokemon* p_pokemon ); PKMN_C_API enum pkmn_error pkmn_daycare_get_levelup_pokemon_as_list( const struct pkmn_daycare* p_daycare, struct pkmn_pokemon_list* p_levelup_pokemon_list_out ); PKMN_C_API enum pkmn_error pkmn_daycare_get_breeding_pokemon( const struct pkmn_daycare* p_daycare, size_t index, struct pkmn_pokemon* p_breeding_pokemon_out ); PKMN_C_API enum pkmn_error pkmn_daycare_set_breeding_pokemon( const struct pkmn_daycare* p_daycare, size_t index, const struct pkmn_pokemon* p_pokemon ); PKMN_C_API enum pkmn_error pkmn_daycare_get_breeding_pokemon_as_list( const struct pkmn_daycare* p_daycare, struct pkmn_pokemon_list* p_breeding_pokemon_list_out ); PKMN_C_API enum pkmn_error pkmn_daycare_get_egg( const struct pkmn_daycare* p_daycare, struct pkmn_pokemon* p_egg_out ); #ifdef __cplusplus } #endif #endif /* PKMN_C_DAYCARE_H */
22.904255
79
0.779842
c5ff2828adf03fcfe1f1e6843c5712d0f3fea607
2,075
h
C
System/Library/PrivateFrameworks/SiriVOX.framework/SVXSessionDelegate.h
lechium/tvOS144Headers
e22dcf52662ae03002e3a6d57273f54e74013cb0
[ "MIT" ]
2
2021-04-15T10:50:21.000Z
2021-08-19T19:00:09.000Z
System/Library/PrivateFrameworks/SiriVOX.framework/SVXSessionDelegate.h
lechium/tvOS144Headers
e22dcf52662ae03002e3a6d57273f54e74013cb0
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/SiriVOX.framework/SVXSessionDelegate.h
lechium/tvOS144Headers
e22dcf52662ae03002e3a6d57273f54e74013cb0
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, April 14, 2021 at 2:31:26 PM Mountain Standard Time * Operating System: Version 14.4 (Build 18K802) * Image Source: /System/Library/PrivateFrameworks/SiriVOX.framework/SiriVOX * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @protocol SVXSessionDelegate <NSObject> @required -(void)sessionDidInvalidate:(id)arg1; -(void)session:(id)arg1 willChangeFromState:(long long)arg2 toState:(long long)arg3; -(void)session:(id)arg1 didChangeFromState:(long long)arg2 toState:(long long)arg3; -(void)session:(id)arg1 willBeginUpdateAudioPowerWithType:(long long)arg2 wrapper:(id)arg3; -(void)session:(id)arg1 didEndUpdateAudioPowerWithType:(long long)arg2; -(void)session:(id)arg1 willStartSoundWithID:(long long)arg2; -(void)session:(id)arg1 didStartSoundWithID:(long long)arg2; -(void)session:(id)arg1 didStopSoundWithID:(long long)arg2 error:(id)arg3; -(void)session:(id)arg1 willBecomeActiveWithActivationContext:(id)arg2 activityUUID:(id)arg3; -(void)session:(id)arg1 didBecomeActiveWithActivationContext:(id)arg2 activityUUID:(id)arg3; -(void)session:(id)arg1 willResignActiveWithOptions:(unsigned long long)arg2 duration:(double)arg3 activityUUID:(id)arg4; -(void)session:(id)arg1 didResignActiveWithDeactivationContext:(id)arg2 activityUUID:(id)arg3; -(void)session:(id)arg1 willActivateWithContext:(id)arg2; -(void)session:(id)arg1 didActivateWithContext:(id)arg2; -(void)session:(id)arg1 didNotActivateWithContext:(id)arg2 error:(id)arg3; -(void)session:(id)arg1 willDeactivateWithContext:(id)arg2; -(void)session:(id)arg1 didDeactivateWithContext:(id)arg2; -(void)session:(id)arg1 audioSessionWillBecomeActive:(BOOL)arg2 activationContext:(id)arg3 deactivationContext:(id)arg4; -(void)session:(id)arg1 audioSessionDidBecomeActive:(BOOL)arg2 activationContext:(id)arg3 deactivationContext:(id)arg4; @end
61.029412
130
0.74747
d0a0b21c4590e315795d2dfc048bf62394fd630d
4,343
h
C
ADThirdParty_SDK/MintegralSDK/MTGSDKReward.framework/Versions/Current/Headers/MTGRewardAd.h
Romambo/ADThirdParty_SDK
67088ef2a2633dd623c5aeee7269007214ee5ffc
[ "MIT" ]
null
null
null
ADThirdParty_SDK/MintegralSDK/MTGSDKReward.framework/Versions/Current/Headers/MTGRewardAd.h
Romambo/ADThirdParty_SDK
67088ef2a2633dd623c5aeee7269007214ee5ffc
[ "MIT" ]
null
null
null
ADThirdParty_SDK/MintegralSDK/MTGSDKReward.framework/Versions/Current/Headers/MTGRewardAd.h
Romambo/ADThirdParty_SDK
67088ef2a2633dd623c5aeee7269007214ee5ffc
[ "MIT" ]
null
null
null
// // MTGRewardAd.h // MTGSDK // // Copyright © 2019 Mintegral. All rights reserved. // #import <Foundation/Foundation.h> #if __has_include(<MTGSDK/MTGSDK.h>) #import <MTGSDK/MTGRewardAdInfo.h> #else #import "MTGRewardAdInfo.h" #endif #define MTGRewardVideoSDKVersion @"6.6.1" /** * This protocol defines a listener for ad video load events. */ @protocol MTGRewardAdLoadDelegate <NSObject> @optional /** * Called when the ad is loaded , but not ready to be displayed,need to wait load video completely * @param placementId - the placementId string of the Ad that was loaded. * @param unitId - the unitId string of the Ad that was loaded. */ - (void)onAdLoadSuccess:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called when the ad is successfully load , and is ready to be displayed * @param placementId - the placementId string of the Ad that was loaded. * @param unitId - the unitId string of the Ad that was loaded. */ - (void)onVideoAdLoadSuccess:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called when there was an error loading the ad. * @param placementId - the placementId string of the Ad that was loaded. * @param unitId - the unitId string of the Ad that failed to load. * @param error - error object that describes the exact error encountered when loading the ad. */ - (void)onVideoAdLoadFailed:(nullable NSString *)placementId unitId:(nullable NSString *)unitId error:(nonnull NSError *)error; @end /** * This protocol defines a listener for ad video show events. */ @protocol MTGRewardAdShowDelegate <NSObject> @optional /** * Called when the ad display success * @param placementId - the placementId string of the Ad that display success. * @param unitId - the unitId string of the Ad that display success. */ - (void)onVideoAdShowSuccess:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called when the ad failed to display for some reason * @param placementId - the placementId string of the Ad that failed to be displayed. * @param unitId - the unitId string of the Ad that failed to be displayed. * @param error - error object that describes the exact error encountered when showing the ad. */ - (void)onVideoAdShowFailed:(nullable NSString *)placementId unitId:(nullable NSString *)unitId withError:(nonnull NSError *)error; /** * Called only when the ad has a video content, and called when the video play completed. * @param placementId - the placementId string of the Ad that video play completed. * @param unitId - the unitId string of the Ad that video play completed. */ - (void) onVideoPlayCompleted:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called only when the ad has a endcard content, and called when the endcard show. * @param placementId - the placementId string of the Ad that endcard show. * @param unitId - the unitId string of the Ad that endcard show. */ - (void) onVideoEndCardShowSuccess:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called when the ad is clicked * * @param placementId - the placementId string of the Ad clicked. * @param unitId - the unitId string of the Ad clicked. */ - (void)onVideoAdClicked:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; /** * Called when the ad will dismiss from being displayed, and control will return to your app * * @param placementId - the placementId string of the Ad that has been dismissed * @param unitId - the unitId string of the Ad that has been dismissed * @param converted - BOOL describing whether the ad has converted * @param rewardInfo - the rewardInfo object containing the info that should be given to your user. */ - (void)onVideoAdDismissed:(nullable NSString *)placementId unitId:(nullable NSString *)unitId withConverted:(BOOL)converted withRewardInfo:(nullable MTGRewardAdInfo *)rewardInfo; /** * Called when the ad did dismissed; * * @param unitId - the unitId string of the Ad that video play did dismissed. * @param placementId - the placementId string of the Ad that video play did dismissed. */ - (void)onVideoAdDidClosed:(nullable NSString *)placementId unitId:(nullable NSString *)unitId; @end
36.191667
179
0.732673
d0c2a6b33f6d37bf577716ed65f6cbdc10a922c7
1,373
h
C
i3v/Marlin_RAMPS_EPCOS_i3v/motion_control.h
joshuabenuck/notebook
7dd06e2e5a08d8e12cea3226df75b633d263f84c
[ "MIT" ]
1
2015-06-16T15:16:02.000Z
2015-06-16T15:16:02.000Z
i3v/Marlin_RAMPS_EPCOS_i3v/motion_control.h
joshuabenuck/notebook
7dd06e2e5a08d8e12cea3226df75b633d263f84c
[ "MIT" ]
null
null
null
i3v/Marlin_RAMPS_EPCOS_i3v/motion_control.h
joshuabenuck/notebook
7dd06e2e5a08d8e12cea3226df75b633d263f84c
[ "MIT" ]
null
null
null
/* motion_control.h - high level interface for issuing motion commands Part of Grbl Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Grbl 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 Grbl. If not, see <http://www.gnu.org/licenses/>. */ #ifndef motion_control_h #define motion_control_h // Execute an arc in offset mode format. position == current xyz, target == target xyz, // offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is // the direction of helical travel, radius == circle radius, isclockwise boolean. Used // for vector transformation direction. void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1, unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder); #endif
41.606061
105
0.763292
ca4dab7e092a5c139b6e3e7146f6dd4753a6677b
640
h
C
include/cnl/_impl/elastic_integer/is_wrapper.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
include/cnl/_impl/elastic_integer/is_wrapper.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
include/cnl/_impl/elastic_integer/is_wrapper.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
// Copyright John McFarlane 2019. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file ../LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #if !defined(CNL_IMPL_ELASTIC_INTEGER_IS_WRAPPER_H) #define CNL_IMPL_ELASTIC_INTEGER_IS_WRAPPER_H #include "../wrapper/is_wrapper.h" #include "declaration.h" /// compositional numeric library namespace cnl { namespace _impl { template<int Digits, typename Narrowest> inline constexpr auto is_wrapper<elastic_integer<Digits, Narrowest>> = true; } } #endif // CNL_IMPL_ELASTIC_INTEGER_IS_WRAPPER_H
29.090909
84
0.732813
ca62060745bc284eefe7a9d2f7c1ac723799f68e
2,430
h
C
PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-24T19:10:26.000Z
2019-02-19T11:45:32.000Z
PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-23T13:40:24.000Z
2019-12-05T21:16:03.000Z
PhysicsTools/PatUtils/plugins/ShiftedPFCandidateProducerForPFNoPUMEt.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
5
2018-08-21T16:37:52.000Z
2020-01-09T13:33:17.000Z
#ifndef PhysicsTools_PatUtils_ShiftedPFCandidateProducerForPFNoPUMEt_h #define PhysicsTools_PatUtils_ShiftedPFCandidateProducerForPFNoPUMEt_h /** \class ShiftedPFCandidateProducerForPFNoPUMEt * * Vary energy of PFCandidates which are (are not) within jets of Pt > 10 GeV * by jet energy uncertainty (by 10% "unclustered" energy uncertainty) * * NOTE: Auxiliary class specific to estimating systematic uncertainty * on PFMET reconstructed by no-PU MET reconstruction algorithm * (implemented in JetMETCorrections/Type1MET/src/PFNoPUMETProducer.cc) * * In case all PFCandidates not within jets of Pt > 30 GeV would be varied * by the 10% "unclustered" energy uncertainty, the systematic uncertainty * on the reconstructed no-PU MET would be overestimated significantly !! * * \author Christian Veelken, LLR * * * */ #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/Utilities/interface/InputTag.h" #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h" #include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h" #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/JetReco/interface/PFJetCollection.h" #include <string> #include <vector> class ShiftedPFCandidateProducerForPFNoPUMEt : public edm::EDProducer { public: explicit ShiftedPFCandidateProducerForPFNoPUMEt(const edm::ParameterSet&); ~ShiftedPFCandidateProducerForPFNoPUMEt() override; private: void produce(edm::Event&, const edm::EventSetup&) override; std::string moduleLabel_; edm::EDGetTokenT<reco::PFCandidateCollection> srcPFCandidatesToken_; edm::EDGetTokenT<reco::PFJetCollection> srcJetsToken_; edm::FileInPath jetCorrInputFileName_; std::string jetCorrPayloadName_; std::string jetCorrUncertaintyTag_; JetCorrectorParameters* jetCorrParameters_; JetCorrectionUncertainty* jecUncertainty_; bool jecValidFileName_; double minJetPt_; double shiftBy_; double unclEnUncertainty_; }; #endif
30.759494
80
0.796296
30eafb3a41b66cf4550319e264d13d1db6abaac2
3,224
c
C
src/cmd/9660srv/iobuf.c
spangey/plan9port
8048d0a677be636aa06cc797f332dc6a04ace421
[ "LPL-1.02" ]
1
2015-01-01T12:37:38.000Z
2015-01-01T12:37:38.000Z
src/cmd/9660srv/iobuf.c
spangey/plan9port
8048d0a677be636aa06cc797f332dc6a04ace421
[ "LPL-1.02" ]
null
null
null
src/cmd/9660srv/iobuf.c
spangey/plan9port
8048d0a677be636aa06cc797f332dc6a04ace421
[ "LPL-1.02" ]
null
null
null
#include <u.h> #include <libc.h> #include <auth.h> #include <fcall.h> #include "dat.h" #include "fns.h" /* * We used to use 100 i/o buffers of size 2kb (Sectorsize). * Unfortunately, reading 2kb at a time often hopping around * the disk doesn't let us get near the disk bandwidth. * * Based on a trace of iobuf address accesses taken while * tarring up a Plan 9 distribution CD, we now use 16 128kb * buffers. This works for ISO9660 because data is required * to be laid out contiguously; effectively we're doing agressive * readahead. Because the buffers are so big and the typical * disk accesses so concentrated, it's okay that we have so few * of them. * * If this is used to access multiple discs at once, it's not clear * how gracefully the scheme degrades, but I'm not convinced * it's worth worrying about. -rsc */ /* trying a larger value to get greater throughput - geoff */ #define BUFPERCLUST 256 /* sectors/cluster; was 64, 64*Sectorsize = 128kb */ #define NCLUST 16 int nclust = NCLUST; static Ioclust* iohead; static Ioclust* iotail; static Ioclust* getclust(Xdata*, long); static void putclust(Ioclust*); static void xread(Ioclust*); void iobuf_init(void) { int i, j, n; Ioclust *c; Iobuf *b; uchar *mem; n = nclust*sizeof(Ioclust) + nclust*BUFPERCLUST*(sizeof(Iobuf)+Sectorsize); mem = sbrk(n); if(mem == (void*)-1) panic(0, "iobuf_init"); memset(mem, 0, n); for(i=0; i<nclust; i++){ c = (Ioclust*)mem; mem += sizeof(Ioclust); c->addr = -1; c->prev = iotail; if(iotail) iotail->next = c; iotail = c; if(iohead == nil) iohead = c; c->buf = (Iobuf*)mem; mem += BUFPERCLUST*sizeof(Iobuf); c->iobuf = mem; mem += BUFPERCLUST*Sectorsize; for(j=0; j<BUFPERCLUST; j++){ b = &c->buf[j]; b->clust = c; b->addr = -1; b->iobuf = c->iobuf+j*Sectorsize; } } } void purgebuf(Xdata *dev) { Ioclust *p; for(p=iohead; p!=nil; p=p->next) if(p->dev == dev){ p->addr = -1; p->busy = 0; } } static Ioclust* getclust(Xdata *dev, long addr) { Ioclust *c, *f; f = nil; for(c=iohead; c; c=c->next){ if(!c->busy) f = c; if(c->addr == addr && c->dev == dev){ c->busy++; return c; } } if(f == nil) panic(0, "out of buffers"); f->addr = addr; f->dev = dev; f->busy++; if(waserror()){ f->addr = -1; /* stop caching */ putclust(f); nexterror(); } xread(f); poperror(); return f; } static void putclust(Ioclust *c) { if(c->busy <= 0) panic(0, "putbuf"); c->busy--; /* Link onto head for LRU */ if(c == iohead) return; c->prev->next = c->next; if(c->next) c->next->prev = c->prev; else iotail = c->prev; c->prev = nil; c->next = iohead; iohead->prev = c; iohead = c; } Iobuf* getbuf(Xdata *dev, ulong addr) { int off; Ioclust *c; off = addr%BUFPERCLUST; c = getclust(dev, addr - off); if(c->nbuf < off){ c->busy--; error("I/O read error"); } return &c->buf[off]; } void putbuf(Iobuf *b) { putclust(b->clust); } static void xread(Ioclust *c) { int n; Xdata *dev; dev = c->dev; seek(dev->dev, (vlong)c->addr * Sectorsize, 0); n = readn(dev->dev, c->iobuf, BUFPERCLUST*Sectorsize); if(n < Sectorsize) error("I/O read error"); c->nbuf = n/Sectorsize; }
18.11236
76
0.620658
342434d20266844951a4a9c32d6908a0d43eaad1
1,387
h
C
ConstructSensors/MobileSensors/iOSVideoSensor/sensor/ColumbiaCollegeShare/Code Drop - Feb 5 - 2012/Windows/packages/ffmpeg/Source/libavformat/http.h
dgerding/Construct
ecbb0ee5591a89e71906ad676bc6684583716d84
[ "MIT" ]
2
2017-08-03T07:15:00.000Z
2018-06-18T10:32:53.000Z
ConstructSensors/MobileSensors/iOSVideoSensor/sensor/ColumbiaCollegeShare/Code Drop - Feb 5 - 2012/Windows/packages/ffmpeg/Source/libavformat/http.h
dgerding/Construct
ecbb0ee5591a89e71906ad676bc6684583716d84
[ "MIT" ]
null
null
null
ConstructSensors/MobileSensors/iOSVideoSensor/sensor/ColumbiaCollegeShare/Code Drop - Feb 5 - 2012/Windows/packages/ffmpeg/Source/libavformat/http.h
dgerding/Construct
ecbb0ee5591a89e71906ad676bc6684583716d84
[ "MIT" ]
2
2019-03-04T22:57:42.000Z
2020-03-06T01:32:26.000Z
/* * HTTP definitions * Copyright (c) 2010 Josh Allmann * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVFORMAT_HTTP_H #define AVFORMAT_HTTP_H #include "url.h" /** * Initialize the authentication state based on another HTTP URLContext. * This can be used to pre-initialize the authentication parameters if * they are known beforehand, to avoid having to do an initial failing * request just to get the parameters. * * @param dest URL context whose authentication state gets updated * @param src URL context whose authentication state gets copied */ void ff_http_init_auth_state(URLContext *dest, const URLContext *src); #endif /* AVFORMAT_HTTP_H */
35.564103
79
0.755588
2e90f0ee284a947ce22227632c0d927ab412c215
165
h
C
level1/p12_warehouse/warehouse.h
lishiqianhugh/c2019
62929d7ab521cb0f0e0fc045793ed5c59bb09174
[ "MIT" ]
1
2019-04-03T11:34:39.000Z
2019-04-03T11:34:39.000Z
level1/p12_warehouse/warehouse.h
lishiqianhugh/c2019
62929d7ab521cb0f0e0fc045793ed5c59bb09174
[ "MIT" ]
null
null
null
level1/p12_warehouse/warehouse.h
lishiqianhugh/c2019
62929d7ab521cb0f0e0fc045793ed5c59bb09174
[ "MIT" ]
null
null
null
#include<stdio.h> #include<stdlib.h> #include<string.h> #define N 5 void display(); void in(); void out(); void quit(); void changefile(); extern struct goods g[N];
15
25
0.690909
2c128fc353b8b9a7fe768f14770bee287fa51ac5
1,351
c
C
Arrays & Matrices/Check whether two matrices are equal or not.c
paurav11/C
f603eef11ea14a730a5fb41e36b3dba5f852fe01
[ "MIT" ]
null
null
null
Arrays & Matrices/Check whether two matrices are equal or not.c
paurav11/C
f603eef11ea14a730a5fb41e36b3dba5f852fe01
[ "MIT" ]
null
null
null
Arrays & Matrices/Check whether two matrices are equal or not.c
paurav11/C
f603eef11ea14a730a5fb41e36b3dba5f852fe01
[ "MIT" ]
null
null
null
#include <stdio.h> #include <conio.h> int i,j,r1,c1,r2,c2; void equal(int a[r1][c1],int b[r2][c2]) { int flag=0; if(r1==r2 && c1==c2) { printf("\nEnter elements of Matrix A: \n"); for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { scanf("%d",&a[i][j]); } printf("\n"); } printf("\nEnter elements of Matrix B: \n"); for(i=0;i<r2;i++) { for(j=0;j<c2;j++) { scanf("%d",&b[i][j]); } printf("\n"); } for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { if(a[i][j]==b[i][j]) { flag=1; } else { flag=0; goto label; } } } label: if(flag==1) { printf("\nMatrices are equal."); } else { printf("\nMatrices are not equal."); } } else { printf("\nMatrices are not equal."); } } void main() { int a[20][20],b[20][20]; printf("Enter no. of rows & columns of Matrix A: "); scanf("%d%d",&r1,&c1); printf("\nEnter no. of rows & columns of Matrix B: "); scanf("%d%d",&r2,&c2); equal(a,b); getch(); }
19.57971
58
0.355292
2c50449046e52828aa49e289caf53658c578fd64
745
h
C
src/devices/ni/MaschineMikroMK1.h
ni-dshashlov/cabl
23f13a366ca91882d08f70c7d10436d043a6ed13
[ "MIT" ]
112
2016-06-20T01:03:40.000Z
2022-03-11T18:43:12.000Z
src/devices/ni/MaschineMikroMK1.h
ni-dshashlov/cabl
23f13a366ca91882d08f70c7d10436d043a6ed13
[ "MIT" ]
15
2017-03-07T07:18:28.000Z
2021-08-05T19:13:17.000Z
src/devices/ni/MaschineMikroMK1.h
ni-dshashlov/cabl
23f13a366ca91882d08f70c7d10436d043a6ed13
[ "MIT" ]
27
2016-08-28T15:10:55.000Z
2022-03-04T10:56:33.000Z
/* ########## Copyright (C) 2015 Vincenzo Pacella ## ## Distributed under MIT license, see file LICENSE ## ## or <http://opensource.org/licenses/MIT> ## ## ########## ############################################################# shaduzlabs.com #####*/ #pragma once #include "Device.h" namespace sl { namespace cabl { namespace devices { //-------------------------------------------------------------------------------------------------- class MaschineMikroMK1 : public Device { public: MaschineMikroMK1(); ~MaschineMikroMK1() override; }; //-------------------------------------------------------------------------------------------------- } // devices } // cabl } // sl
21.911765
100
0.359732
d6ca5454d685841f42b5098b30d3bb0bf11f4a69
1,990
c
C
src/kem/threebears/kem_threebears_mamabear_ephem.c
thomwiggers/liboqs
24eb40f12143d8ae1a0fe212ba79d1d0703d2a27
[ "MIT" ]
null
null
null
src/kem/threebears/kem_threebears_mamabear_ephem.c
thomwiggers/liboqs
24eb40f12143d8ae1a0fe212ba79d1d0703d2a27
[ "MIT" ]
null
null
null
src/kem/threebears/kem_threebears_mamabear_ephem.c
thomwiggers/liboqs
24eb40f12143d8ae1a0fe212ba79d1d0703d2a27
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <oqs/kem_threebears.h> #ifdef OQS_ENABLE_KEM_threebears_mamabear_ephem OQS_KEM *OQS_KEM_threebears_mamabear_ephem_new() { OQS_KEM *kem = malloc(sizeof(OQS_KEM)); if (kem == NULL) { return NULL; } kem->method_name = OQS_KEM_alg_threebears_mamabear_ephem; kem->alg_version = "https://sourceforge.net/p/threebears/code/ci/f4ce0ebfc84a5e01a75bfc8297b6d175e993cfa4/"; kem->claimed_nist_level = 3; kem->ind_cca = false; kem->length_public_key = OQS_KEM_threebears_mamabear_ephem_length_public_key; kem->length_secret_key = OQS_KEM_threebears_mamabear_ephem_length_secret_key; kem->length_ciphertext = OQS_KEM_threebears_mamabear_ephem_length_ciphertext; kem->length_shared_secret = OQS_KEM_threebears_mamabear_ephem_length_shared_secret; kem->keypair = OQS_KEM_threebears_mamabear_ephem_keypair; kem->encaps = OQS_KEM_threebears_mamabear_ephem_encaps; kem->decaps = OQS_KEM_threebears_mamabear_ephem_decaps; return kem; } int PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_keypair(unsigned char *pk, unsigned char *sk); int PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_enc(unsigned char *ct, unsigned char *ss, const unsigned char *pk); int PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned char *sk); OQS_API OQS_STATUS OQS_KEM_threebears_mamabear_ephem_keypair(uint8_t *public_key, uint8_t *secret_key) { return (OQS_STATUS) PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_keypair(public_key, secret_key); } OQS_API OQS_STATUS OQS_KEM_threebears_mamabear_ephem_encaps(uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) { return (OQS_STATUS) PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_enc(ciphertext, shared_secret, public_key); } OQS_API OQS_STATUS OQS_KEM_threebears_mamabear_ephem_decaps(uint8_t *shared_secret, const unsigned char *ciphertext, const uint8_t *secret_key) { return (OQS_STATUS) PQCLEAN_MAMABEAREPHEM_CLEAN_crypto_kem_dec(shared_secret, ciphertext, secret_key); } #endif
43.26087
145
0.839698
031e50d41fd0ecd2d96db12fb3d81643fc9f0b91
2,948
h
C
vtkm/worklet/MaskIndices.h
Kitware/vtk-m
b24a878f72b288d69c9da8c7ac33f08db6d39ba9
[ "BSD-3-Clause" ]
14
2019-10-25T03:25:47.000Z
2022-01-19T02:14:53.000Z
vtkm/worklet/MaskIndices.h
Kitware/vtk-m
b24a878f72b288d69c9da8c7ac33f08db6d39ba9
[ "BSD-3-Clause" ]
null
null
null
vtkm/worklet/MaskIndices.h
Kitware/vtk-m
b24a878f72b288d69c9da8c7ac33f08db6d39ba9
[ "BSD-3-Clause" ]
3
2019-08-20T10:49:49.000Z
2021-12-22T17:39:15.000Z
//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_worklet_MaskIndices_h #define vtk_m_worklet_MaskIndices_h #include <vtkm/cont/Algorithm.h> #include <vtkm/worklet/internal/MaskBase.h> namespace vtkm { namespace worklet { /// \brief Mask using a given array of indices to include in the output. /// /// \c MaskIndices is a worklet mask object that is used to select elements in the output of a /// worklet to include in the output. This is done by providing a mask array. This array contains /// an entry for every output to create. Any output index not included is not generated. /// /// It is OK to give indices that are out of order, but any index must be provided at most one /// time. It is an error to have the same index listed twice. /// class MaskIndices : public internal::MaskBase { public: using ThreadToOutputMapType = vtkm::cont::ArrayHandle<vtkm::Id>; //@{ /// \brief Construct using an index array. /// /// When you construct a \c MaskSelect with the \c IndexArray tag, you provide an array /// containing an index for each output to produce. It is OK to give indices that are out of /// order, but any index must be provided at most one time. It is an error to have the same index /// listed twice. /// /// Note that depending on the type of the array passed in, the index may be shallow copied /// or deep copied into the state of this mask object. Thus, it is a bad idea to alter the /// array once given to this object. /// explicit MaskIndices( const vtkm::cont::ArrayHandle<vtkm::Id>& indexArray, vtkm::cont::DeviceAdapterId vtkmNotUsed(device) = vtkm::cont::DeviceAdapterTagAny()) { this->ThreadToOutputMap = indexArray; } template <typename T, typename S> explicit MaskIndices(const vtkm::cont::ArrayHandle<T, S>& indexArray, vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny()) { vtkm::cont::Algorithm::Copy(device, indexArray, this->ThreadToOutputMap); } //@} // TODO? Create a version that accepts an UnknownArrayHandle. Is this needed? template <typename RangeType> vtkm::Id GetThreadRange(RangeType vtkmNotUsed(outputRange)) const { return this->ThreadToOutputMap.GetNumberOfValues(); } template <typename RangeType> ThreadToOutputMapType GetThreadToOutputMap(RangeType vtkmNotUsed(outputRange)) const { return this->ThreadToOutputMap; } private: ThreadToOutputMapType ThreadToOutputMap; }; } } // namespace vtkm::worklet #endif //vtk_m_worklet_MaskIndices_h
35.518072
99
0.689281
03ea8930bd29fcc62ed705faabc217174af71d4b
2,752
c
C
src/main/c/de_jcm_discordgamesdk_OverlayManager.c
Pablete1234/discord-game-sdk4j
80f2671b2ed894a202e4cf9ad6749e9c1f20d40e
[ "MIT" ]
52
2020-05-04T18:21:30.000Z
2022-03-26T06:19:50.000Z
src/main/c/de_jcm_discordgamesdk_OverlayManager.c
Pablete1234/discord-game-sdk4j
80f2671b2ed894a202e4cf9ad6749e9c1f20d40e
[ "MIT" ]
29
2020-05-05T20:23:59.000Z
2022-02-25T15:48:43.000Z
src/main/c/de_jcm_discordgamesdk_OverlayManager.c
Pablete1234/discord-game-sdk4j
80f2671b2ed894a202e4cf9ad6749e9c1f20d40e
[ "MIT" ]
13
2020-06-05T09:45:13.000Z
2022-03-30T18:44:37.000Z
#include <stdlib.h> #include <discord_game_sdk.h> #include "de_jcm_discordgamesdk_OverlayManager.h" #include "Callback.h" JNIEXPORT jboolean JNICALL Java_de_jcm_discordgamesdk_OverlayManager_isEnabled(JNIEnv *env, jobject object, jlong pointer) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; bool enabled; overlay_manager->is_enabled(overlay_manager, &enabled); return enabled; } JNIEXPORT jboolean JNICALL Java_de_jcm_discordgamesdk_OverlayManager_isLocked(JNIEnv *env, jobject object, jlong pointer) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; bool locked; overlay_manager->is_locked(overlay_manager, &locked); return locked; } JNIEXPORT void JNICALL Java_de_jcm_discordgamesdk_OverlayManager_setLocked(JNIEnv *env, jobject object, jlong pointer, jboolean locked, jobject callback) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; struct CallbackData* cbd = malloc(sizeof(struct CallbackData)); prepare_callback_data(env, callback, cbd); overlay_manager->set_locked(overlay_manager, locked, cbd, simple_callback); } JNIEXPORT void JNICALL Java_de_jcm_discordgamesdk_OverlayManager_openActivityInvite(JNIEnv *env, jobject object, jlong pointer, jint type, jobject callback) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; struct CallbackData* cbd = malloc(sizeof(struct CallbackData)); prepare_callback_data(env, callback, cbd); // enum DiscordActivityActionType starts with index 1, so add 1 to translate from "normal" enum overlay_manager->open_activity_invite(overlay_manager, type+1, cbd, simple_callback); } JNIEXPORT void JNICALL Java_de_jcm_discordgamesdk_OverlayManager_openGuildInvite(JNIEnv *env, jobject object, jlong pointer, jstring code, jobject callback) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; struct CallbackData* cbd = malloc(sizeof(struct CallbackData)); prepare_callback_data(env, callback, cbd); const char *nativeString = (*env)->GetStringUTFChars(env, code, 0); overlay_manager->open_guild_invite(overlay_manager, nativeString, cbd, simple_callback); (*env)->ReleaseStringUTFChars(env, code, nativeString); } JNIEXPORT void JNICALL Java_de_jcm_discordgamesdk_OverlayManager_openVoiceSettings(JNIEnv *env, jobject object, jlong pointer, jobject callback) { struct IDiscordOverlayManager *overlay_manager = (struct IDiscordOverlayManager*) pointer; struct CallbackData* cbd = malloc(sizeof(struct CallbackData)); prepare_callback_data(env, callback, cbd); overlay_manager->open_voice_settings(overlay_manager, cbd, simple_callback); }
39.884058
156
0.817587
141a662dac29ffa3aab36e521cc5f087a36b4ddb
641
h
C
Source/Public/HeliosGetterProxy_Int.h
HeliosOrg/SimpleDataIntegrationPlugin
db1a6aa2dca50d9d2e1b7b36840b8278f22d71cf
[ "MIT" ]
7
2016-08-07T03:58:20.000Z
2021-01-30T09:03:04.000Z
Source/Public/HeliosGetterProxy_Int.h
HeliosOrg/SimpleDataIntegrationPlugin
db1a6aa2dca50d9d2e1b7b36840b8278f22d71cf
[ "MIT" ]
1
2018-05-01T15:06:21.000Z
2018-05-01T16:03:18.000Z
Source/Public/HeliosGetterProxy_Int.h
HeliosOrg/SimpleDataIntegrationPlugin
db1a6aa2dca50d9d2e1b7b36840b8278f22d71cf
[ "MIT" ]
4
2016-12-20T04:56:42.000Z
2019-01-19T13:05:24.000Z
// Copyright 2016 Helios. All Rights Reserved. #pragma once #include "HeliosGetterProxy_Int.generated.h" DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FHeliosGetterIntRequestDelegate, int, OutputValue); UCLASS(MinimalAPI) class UHeliosGetterProxy_Int : public UObject { GENERATED_UCLASS_BODY() UPROPERTY(BlueprintAssignable) FHeliosGetterIntRequestDelegate OnSuccess; UPROPERTY(BlueprintAssignable) FHeliosGetterIntRequestDelegate OnFail; public: void SendHeliosRequest(const FName HeliosClass, const FName ServerUrl); void OnHeliosRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded); };
26.708333
107
0.848674
b304b0a8beaafee547f651b63030e5e9dbe72da2
2,587
h
C
src/messagebox.h
tipiak75/php-sdl
36956f39c93448172f58cd9aff64fd8a4a895118
[ "PHP-3.01" ]
44
2019-09-05T09:18:11.000Z
2022-03-23T21:30:47.000Z
src/messagebox.h
tipiak75/php-sdl
36956f39c93448172f58cd9aff64fd8a4a895118
[ "PHP-3.01" ]
26
2019-09-03T19:30:03.000Z
2022-03-23T18:18:27.000Z
src/messagebox.h
tipiak75/php-sdl
36956f39c93448172f58cd9aff64fd8a4a895118
[ "PHP-3.01" ]
6
2020-02-26T14:00:17.000Z
2022-01-15T05:56:22.000Z
/* +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Santiago Lizardo <santiagolizardo@php.net> | | Remi Collet <remi@php.net> | +----------------------------------------------------------------------+ */ #ifndef PHP_SDL_MESSAGEBOX_H #define PHP_SDL_MESSAGEBOX_H #ifdef __cplusplus extern "C" { #endif #include "php_sdl.h" zend_class_entry *get_php_sdl_messageboxcolor_ce(void); zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *value); zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color); zend_class_entry *get_php_sdl_messageboxbuttondata_ce(void); zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, zval *value); zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData *data); zend_class_entry *get_php_sdl_messageboxdata_ce(void); zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint32 flags); SDL_MessageBoxData *zval_to_sdl_messageboxdata(zval *z_val); ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_ShowMessageBox, 0, 0, 2) ZEND_ARG_INFO(0, messageboxdata) ZEND_ARG_INFO(1, buttonid) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_ShowSimpleMessageBox, 0, 0, 3) ZEND_ARG_INFO(0, flags) ZEND_ARG_INFO(0, title) ZEND_ARG_INFO(0, message) ZEND_ARG_OBJ_INFO(0, window, SDL_Window, 1) ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_ShowMessageBox); PHP_FUNCTION(SDL_ShowSimpleMessageBox); PHP_MINIT_FUNCTION(sdl_messagebox); #ifdef __cplusplus } // extern "C" #endif #endif /* PHP_SDL_MESSAGEBOX_H */
39.8
94
0.594898
8c20d8f03b22fa31c5c25e6de2c8bdab96b59206
2,977
h
C
DigitalWorkprint/lib/common/include/mle/DwpStage.h
magic-lantern-studio/mle-core-dwp
c9d7dcf0295f961baa3e23ffea1aa1c446ea2baa
[ "MIT" ]
null
null
null
DigitalWorkprint/lib/common/include/mle/DwpStage.h
magic-lantern-studio/mle-core-dwp
c9d7dcf0295f961baa3e23ffea1aa1c446ea2baa
[ "MIT" ]
null
null
null
DigitalWorkprint/lib/common/include/mle/DwpStage.h
magic-lantern-studio/mle-core-dwp
c9d7dcf0295f961baa3e23ffea1aa1c446ea2baa
[ "MIT" ]
null
null
null
/** @defgroup MleDWPModel Magic Lantern Digital Workprint Library API - Model */ /** * @file DwpStage.h * @ingroup MleDWPModel * * Magic Lantern Digital Workprint Library API. */ // COPYRIGHT_BEGIN // // The MIT License (MIT) // // Copyright (c) 2015-2020 Wizzer Works // // 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. // // For information concerning this header file, contact Mark S. Millard, // of Wizzer Works at msm@wizzerworks.com. // // More information concerning Wizzer Works may be found at // // http://www.wizzerworks.com // // COPYRIGHT_END #ifndef __MLE_DWP_STAGE_H_ #define __MLE_DWP_STAGE_H_ //Include Digital Workprint header files. #include "mle/DwpItem.h" /** * This defines a stage and its type * * WORKPRINT SYNTAX * * EXAMPLE * Syntax: (Stage <name> <stageClassName>) * * Contained by: none * * Contains: MleDwpForum, MleDwpProperty * END * * Stage class names the actual DSO class to use as stage, * (e.g., MleSGIIvStage), whereas name defines the tag to use * to ID items for the stage (e.g., inventor). * * @see MleDwpForum, MleDwpItem */ class MLE_DWP_API MleDwpStage : public MleDwpItem { MLE_DWP_HEADER(MleDwpStage); public: /** * The default constructor. */ MleDwpStage(void); /** * The destructor. */ virtual ~MleDwpStage(void); /** * Sets the stage's class name, which is used to load the * stage's DSO. */ void setStageClass(const char *); /** * Gets the stage's class name. */ const char *getStageClass(void) const; /** * Override operator new. * * @param tSize The size, in bytes, to allocate. */ void* operator new(size_t tSize); /** * Override operator delete. * * @param p A pointer to the memory to delete. */ void operator delete(void *p); protected: virtual int readContents(MleDwpInput *in); virtual int writeContents(MleDwpOutput *out); char *m_stageClass; }; #endif /* __MLE_DWP_STAGE_H_ */
24.603306
81
0.709439
e9f489879812936f77ed90ae1855549a289bc33e
15,403
c
C
source/dcc/dcc_logic.c
ytsurui/dcc-motordecoder-firmware
51b0f09fa33e326fb22790e21740686e02eea64b
[ "MIT" ]
1
2020-10-21T14:21:19.000Z
2020-10-21T14:21:19.000Z
source/dcc/dcc_logic.c
ytsurui/dcc-motordecoder-firmware
51b0f09fa33e326fb22790e21740686e02eea64b
[ "MIT" ]
null
null
null
source/dcc/dcc_logic.c
ytsurui/dcc-motordecoder-firmware
51b0f09fa33e326fb22790e21740686e02eea64b
[ "MIT" ]
null
null
null
/* * dcc_logic.c * * Created: 2016/12/13 20:17:37 * Project: motordecoder_simple_v1 * Version: 1.00 * Target: ATtiny45 * Author: Y.Tsurui */ #include <avr/io.h> #include "cv.h" #include "../app/train_ctrl.h" #include "../peripheral/pwm_motor_ctrl.h" #include "../app/delay.h" #define DCC_PACKET_LENGTH 8 uint8_t packet_cache[DCC_PACKET_LENGTH]; uint8_t packet_cache_length; uint8_t packet_cache_enable_flag; uint8_t packet_prog_cache[DCC_PACKET_LENGTH]; uint8_t service_mode_flag; uint8_t basic_ack_counter; uint8_t basic_ack_flag = 0; #define BASIC_ACK_COUNT_MAX 12 volatile uint8_t page_r = 0; volatile uint8_t page_verify_r, page_verify_r_flag = 0; uint8_t consist_addr_cache = 0xFF; uint8_t consist_addr_count = 0; #define CONSIST_ADDR_COUNT_MAX 100 uint8_t speed_128step_cache = 0xFF; uint8_t speed_128step_count = 0; uint8_t speed_28step_cache = 0xFF; uint8_t speed_28step_count = 0; #define SPEED_RECV_COUNT_MAX 100 uint8_t ops_mode_cache[3]; uint8_t ops_mode_recv_count = 0; #define OPS_MODE_RECV_COUNT_MAX 100 uint8_t service_page_reg_flag = 0; //uint8_t debug_cv_write_pos = 130; void basic_ack(void) { //pwm_set_direction(PWM_DIRECTION_FOR); //pwm_set_spd(255); pwm_prog_mode(PWM_PROG_STAT_ON); //delay_ms(BASIC_ACK_COUNT_MAX); //pwm_prog_mode(PWM_PROG_STAT_OFF); basic_ack_counter = 1; basic_ack_flag = 1; } void clear_dcc_packet_cache(void) { packet_cache_length = 0; packet_cache_enable_flag = 0; } void put_dcc_packet_cache(uint8_t data) { if (packet_cache_length >= DCC_PACKET_LENGTH) return; packet_cache[packet_cache_length] = data; packet_cache_length++; } void set_dcc_packet_cache_filled_flag(void) { packet_cache_enable_flag = 1; } uint8_t get_dcc_packet_cache_filled(void) { if (packet_cache_enable_flag) { packet_cache_enable_flag = 0; return (1); } return (0); } /* void debug_write(void) { //write_cv_byte(debug_cv_write_pos, packet_prog_cache[0]); //debug_cv_write_pos++; //write_cv_byte(debug_cv_write_pos, packet_prog_cache[1]); //debug_cv_write_pos++; //write_cv_byte(debug_cv_write_pos, packet_prog_cache[2]); //debug_cv_write_pos++; } */ uint8_t compareIntArray(uint8_t *ar1, uint8_t *ar2, uint8_t length) { uint8_t i; for (i = 0; i < length; i++) { if (ar1[i] != ar2[i]) return (0); } return (1); } void dcc_prog_paged(void) { uint16_t cv_addr; uint8_t byte_tmp; //if (compareIntArray(packet_cache, packet_prog_cache, 3)) { if ((packet_cache[0] == packet_prog_cache[0]) && (packet_cache[1] == packet_prog_cache[1]) && (packet_cache[2] == packet_prog_cache[2])) { //if (basic_ack_counter == 0xFF) return; //if (basic_ack_flag) return; if ((packet_prog_cache[0] & 0x04) == 0) { byte_tmp = packet_prog_cache[0] & 0x03; cv_addr = ((page_r - 1) * 4 + byte_tmp + 1); //write_cv_byte(130, cv_addr & 0x00FF); //write_cv_byte(131, byte_tmp); if (packet_prog_cache[0] & 0x08) { //Write //if (~service_page_reg_flag & 0x04) { write_cv_byte(cv_addr, packet_prog_cache[1]); service_page_reg_flag |= 0x04; basic_ack(); //} } else { //Verify page_verify_r = read_cv(cv_addr); if (page_verify_r == packet_prog_cache[1]) { //Data match //if (~service_page_reg_flag & 0x02) { service_page_reg_flag |= 0x02; basic_ack(); //} } } //debug_write(); return; } else if ((packet_prog_cache[0] & 0x07) == 0x05) { //Paged Mode, Write Page Register if (~service_page_reg_flag & 0x01) { page_r = packet_prog_cache[1]; service_page_reg_flag |= 0x01; basic_ack(); //write_cv_byte(129, page_r); } //debug_write(); return; } else if ((packet_prog_cache[0] & 0x07) == 0x04) { //Phys Mode, CV #29 (Basic Configuration) if (packet_prog_cache[0] & 0x08) { //Write write_cv_byte(29, packet_prog_cache[1]); if (~service_page_reg_flag & 0x04) { service_page_reg_flag |= 0x04; basic_ack(); } } else { //Verify page_verify_r = read_cv(29); if (page_verify_r == packet_prog_cache[1]) { if (~service_page_reg_flag & 0x02) { service_page_reg_flag |= 0x02; basic_ack(); } } } //debug_write(); } else if ((packet_prog_cache[0] & 0x07) == 0x06) { //Phys Mode, CV #7 (Version Number) if (packet_prog_cache[0] & 0x08) { //Write write_cv_byte(7, packet_prog_cache[1]); if (~service_page_reg_flag & 0x04) { service_page_reg_flag |= 0x04; basic_ack(); } } else { //Verify page_verify_r = read_cv(7); if (page_verify_r == packet_prog_cache[1]) { if (~service_page_reg_flag & 0x02) { service_page_reg_flag |= 0x02; basic_ack(); } } } //debug_write(); } else if ((packet_prog_cache[0] & 0x07) == 0x07) { //Phys Mode, CV #8 (Manufacturer ID Number) if (packet_prog_cache[0] & 0x08) { //Write write_cv_byte(8, packet_prog_cache[1]); if (~service_page_reg_flag & 0x04) { service_page_reg_flag |= 0x04; basic_ack(); } } else { //Verify page_verify_r = read_cv(8); if (page_verify_r == packet_prog_cache[1]) { if (~service_page_reg_flag & 0x02) { service_page_reg_flag |= 0x02; basic_ack(); } } } //debug_write(); } } else { packet_prog_cache[0] = packet_cache[0]; packet_prog_cache[1] = packet_cache[1]; packet_prog_cache[2] = packet_cache[2]; //basic_ack_counter = 0; basic_ack_flag = 0; /* write_cv_byte(debug_cv_write_pos, packet_prog_cache[0]); debug_cv_write_pos++; write_cv_byte(debug_cv_write_pos, packet_prog_cache[1]); debug_cv_write_pos++; write_cv_byte(debug_cv_write_pos, packet_prog_cache[2]); debug_cv_write_pos++; */ } } void dcc_prog_direct(void) { uint16_t cv_addr; uint8_t int_t; //if (compareIntArray(packet_cache, packet_prog_cache, 4)) { if ((packet_cache[0] == packet_prog_cache[0]) && (packet_cache[1] == packet_prog_cache[1]) && (packet_cache[2] == packet_prog_cache[2]) && (packet_cache[3] == packet_prog_cache[3])) { //if (basic_ack_counter == 0xFF) return; if (basic_ack_flag) return; cv_addr = (packet_prog_cache[0] & 0x03) + packet_prog_cache[1] + 1; switch (packet_prog_cache[0] & 0x0C) { case 0x08: //Bit Manipulation if (packet_prog_cache[2] & 0x10) { //Write Bit write_cv_bit(cv_addr, packet_prog_cache[2]); basic_ack(); } else { //Verify Bit } break; case 0x04: //Verify Byte int_t = read_cv(cv_addr); if (int_t == packet_prog_cache[2]) { basic_ack(); } break; case 0x0C: //Write Byte write_cv_byte(cv_addr, packet_prog_cache[2]); basic_ack(); break; case 0x00: //Reserved break; } } else { packet_prog_cache[0] = packet_cache[0]; packet_prog_cache[1] = packet_cache[1]; packet_prog_cache[2] = packet_cache[2]; packet_prog_cache[3] = packet_cache[3]; //basic_ack_counter = 0; basic_ack_flag = 0; } } void dcc_normal_operation(void) { uint8_t consist_flag = 0; uint8_t packet_read_start_pos; uint8_t byte_tmp; uint8_t direction_flag; uint8_t i; //PORTB |= 0x08; if (packet_cache_length == 3) { if ((packet_cache[0] == 0) && (packet_cache[1] == 0) && (packet_cache[2] == 0)) { //Reset service_mode_flag = 30; service_page_reg_flag = 0; pwm_set_prog_mode(1); return; } else if ((packet_cache[0] == 0xFF) && (packet_cache[1] == 0x00) && (packet_cache[2] == 0xFF)) { //Idle, Exit Service-Mode service_mode_flag = 0; return; } } if (CV19 != 0) { //Consist Mode if (((packet_cache[0] & 0x80) == 0) && ((packet_cache[1] & 0xE0) != 0xE0)) { consist_flag = CV19; } } if (consist_flag != 0) { if ((packet_cache[0] != 0) && (consist_flag == (packet_cache[0] & 0x7F))) { //7-Bit Addr Consist Mode packet_read_start_pos = 1; } else { return; } } else if (((packet_cache[0] & 0x80) == 0) && (CV29 & 0x20) == 0) { //7-Bit Addr if (packet_cache[0] != CV1_6[0]) { // if ((CV19 & 0x7F) == 0) return; // if (((packet_cache[1] & 0xE0) != 0x00) && ((packet_cache[1] & 0xE0) != 0xE0)) { // consist_flag = 0xFF; // } return; } packet_read_start_pos = 1; } else if (((packet_cache[0] & 0xC0) == 0xC0) && (CV29 & 0x20)) { //14-Bit Addr if ((packet_cache[0] != CV17) || (packet_cache[1] != CV18)) { // if ((CV19 & 0x7F) == 0) return; // if ((packet_cache[1] & 0xE0) != 0x00) return; return; } packet_read_start_pos = 2; } else { //Not for Mobile Decoder Packet return; } /* if (consist_flag) { //Consist Mode if ((CV19 & 0x7F) != packet_cache[0]) { //Not match consist Address return; } } */ byte_tmp = packet_cache[packet_read_start_pos] & 0xE0; switch (byte_tmp) { case 0x00: /* if (packet_cache[packet_read_start_pos] & 0x10) { //Consist Control if (packet_cache[packet_read_start_pos] & 0x03) { packet_cache[packet_read_start_pos + 1] |= 0x80; } if (consist_addr_cache == packet_cache[packet_read_start_pos + 1]) { write_cv_byte(19, packet_cache[packet_read_start_pos + 1]); consist_addr_cache = 0xFF; consist_addr_count = 0; } else { consist_addr_cache = packet_cache[packet_read_start_pos + 1]; } } else { //Decoder Control } */ break; case 0x20: if (packet_cache_length != (packet_read_start_pos + 3)) { return; } if ((packet_cache[packet_read_start_pos] & 0x1F) != 0x1F) return; //Advanced Instructions (128-step) if (1) { //if ((packet_cache[packet_read_start_pos] & 0x1F) == 0x1F) { byte_tmp = packet_cache[packet_read_start_pos + 1] & 0x7F; if (speed_128step_cache == byte_tmp) { if (packet_cache[packet_read_start_pos + 1] & 0x80) { //Forward if (CV29 & 0x01) { direction_flag = 2; } else { direction_flag = 1; } } else { //Backward if (CV29 & 0x01) { direction_flag = 1; } else { direction_flag = 2; } } setspeed_128step(direction_flag, byte_tmp); speed_128step_cache = 0xFF; speed_128step_count = 0; } else { speed_128step_cache = byte_tmp; speed_128step_count = 1; } } break; /* case 0x40: if (speed_28step_cache == packet_cache[packet_read_start_pos]) { speed_28step_cache = 0xFF; speed_28step_count = 0; if (CV29 & 0x01) { //direction_flag = 0; setspeed_28step(1, packet_cache[packet_read_start_pos]); } else { //direction_flag = 1; setspeed_28step(2, packet_cache[packet_read_start_pos]); } } else { speed_28step_cache = packet_cache[packet_read_start_pos]; speed_28step_count = 1; } break; case 0x60: //Forward Speed Instruction (14-step, 28-step) if (speed_28step_cache == packet_cache[packet_read_start_pos]) { speed_28step_cache = 0xFF; speed_28step_count = 0; if (CV29 & 0x01) { //direction_flag = 1; setspeed_28step(2, packet_cache[packet_read_start_pos]); } else { //direction_flag = 0; setspeed_28step(1, packet_cache[packet_read_start_pos]); } } else { speed_28step_cache = packet_cache[packet_read_start_pos]; speed_28step_count = 1; } break; */ case 0x40: case 0x60: // Speed Instruction (14-step, 28-step) if (packet_cache_length != (packet_read_start_pos + 2)) { return; } if (1) { //if (speed_28step_cache == packet_cache[packet_read_start_pos]) { speed_28step_cache = 0xFF; speed_28step_count = 0; if (byte_tmp & 0x20) { if (CV29 & 0x01) { direction_flag = 2; } else { direction_flag = 1; } } else { if (CV29 & 0x01) { direction_flag = 1; } else { direction_flag = 2; } } setspeed_28step(direction_flag, packet_cache[packet_read_start_pos]); } else { speed_28step_cache = packet_cache[packet_read_start_pos]; speed_28step_count = 1; } break; /* case 0x80: //Function1 (F0-F4) break; case 0xA0: //Function2, Function3 (F5-F8, F9-F12) break; case 0xC0: //Future Expansion Instruction //Function4 (F13-F20), Function5 (F21-F28) break */ case 0xE0: //Operation Mode CV Instruction for (i = 0; i < 3; i++) { if (ops_mode_cache[i] != packet_cache[packet_read_start_pos + i]) { ops_mode_cache[0] = packet_cache[packet_read_start_pos]; ops_mode_cache[1] = packet_cache[packet_read_start_pos + 1]; ops_mode_cache[2] = packet_cache[packet_read_start_pos + 2]; ops_mode_recv_count = 1; return; } } ops_mode_recv_count = 0; if (packet_cache[packet_read_start_pos] & 0x08) { //Write if (packet_cache[packet_read_start_pos] & 0x04) { //Byte Mode write_cv_byte((((packet_cache[packet_read_start_pos] & 0x03) << 8) + packet_cache[packet_read_start_pos + 1] + 1), packet_cache[packet_read_start_pos + 2]); } else { //Bit Mode write_cv_bit((((packet_cache[packet_read_start_pos] & 0x03) << 8) + packet_cache[packet_read_start_pos + 1] + 1), packet_cache[packet_read_start_pos + 2]); } } break; } } void dcc_exec(void) { if (packet_cache_length == 2) { //2-Byte Packet (none) return; } //if (service_mode_flag) { if (service_mode_flag && ((packet_cache[0] & 0x70) == 0x70)) { //DCC Service Mode service_mode_flag = 30; //PORTB &= ~0x08; switch (packet_cache_length) { case 3: //3-Byte Packet if ((packet_cache[0] == 0) && (packet_cache[1] == 0) && (packet_cache[2] == 0)) { //Reset service_mode_flag = 30; //service_page_reg_flag = 0; return; } else if ((packet_cache[0] == 0xFF) && (packet_cache[1] == 0x00) && (packet_cache[2] == 0xFF)) { //Idle, Exit Service-Mode return; /* } else if ((packet_cache[0] > 0x7F) && (packet_cache[0] < 0xC0) && (packet_cache[1] & 0x80)) { //Accessory Addr return; */ } else { //Paged Mode, Phys Mode, Address only Mode dcc_prog_paged(); } break; case 4: //4-Byte Packet //Direct Mode dcc_prog_direct(); break; } } else { //Normal Operation Mode dcc_normal_operation(); //PORTB |= 0x08; } } void clock_receiver_dcc_exec(void) { uint8_t i; if (service_mode_flag) { service_mode_flag--; if (service_mode_flag == 0) pwm_set_prog_mode(0); } if (basic_ack_counter != 0) { basic_ack_counter++; if (basic_ack_counter > BASIC_ACK_COUNT_MAX) { //basic_ack_counter = 0xFF; basic_ack_counter = 0; basic_ack_flag = 1; pwm_prog_mode(PWM_PROG_STAT_OFF); } } if (consist_addr_count != 0) { consist_addr_count++; if (consist_addr_count >= CONSIST_ADDR_COUNT_MAX) { consist_addr_cache = 0xFF; consist_addr_count = 0; } } if (speed_128step_count != 0) { speed_128step_count++; if (speed_128step_count >= SPEED_RECV_COUNT_MAX) { speed_128step_cache = 0xFF; speed_128step_count = 0; } } if (speed_28step_count != 0) { speed_28step_count++; if (speed_28step_count >= SPEED_RECV_COUNT_MAX) { speed_28step_cache = 0xFF; speed_28step_count = 0; } } if (ops_mode_recv_count != 0) { ops_mode_recv_count++; if (ops_mode_recv_count >= OPS_MODE_RECV_COUNT_MAX) { for (i = 0; i < 3; i++) { ops_mode_cache[i] = 0xFF; } ops_mode_recv_count = 0; } } }
23.232278
184
0.642083
18bbbe3ca66a9ee6373b367bbdc66c2ec6d16641
486
h
C
ecm/SpriteComponent.h
Moto28/TDChampionshipRacer
7296ca3ea6b4244ebb8cd7d9ef5487c29be99696
[ "MIT" ]
null
null
null
ecm/SpriteComponent.h
Moto28/TDChampionshipRacer
7296ca3ea6b4244ebb8cd7d9ef5487c29be99696
[ "MIT" ]
null
null
null
ecm/SpriteComponent.h
Moto28/TDChampionshipRacer
7296ca3ea6b4244ebb8cd7d9ef5487c29be99696
[ "MIT" ]
null
null
null
#pragma once #include "SFML\Graphics.hpp" #include "ecm.h" //#include "positionComponent.h" class SpriteComponent : public Component { private: //PositionComponent * position; sf::Texture spritesheet; sf::IntRect _sprite; sf::Sprite sprite; public: //default constructor SpriteComponent(); //constructor that takes a sprite SpriteComponent(sf::IntRect, float, float, const char*); void update() override; void draw(sf::RenderWindow &); }; extern sf::Texture spritesheet;
19.44
57
0.740741
a0c07a19577d454db7e2e09ad43d0c570b0e0f72
1,401
h
C
experimental/svg/model/SkSVGRect.h
henry-luo/skia
2f2187b66dca1761f590668d3cbdf07453df7b6f
[ "BSD-3-Clause" ]
1
2019-10-29T14:36:32.000Z
2019-10-29T14:36:32.000Z
experimental/svg/model/SkSVGRect.h
henry-luo/skia
2f2187b66dca1761f590668d3cbdf07453df7b6f
[ "BSD-3-Clause" ]
1
2017-06-18T00:25:03.000Z
2017-11-29T16:01:48.000Z
experimental/svg/model/SkSVGRect.h
henry-luo/skia
2f2187b66dca1761f590668d3cbdf07453df7b6f
[ "BSD-3-Clause" ]
5
2017-11-30T06:06:50.000Z
2022-03-31T21:48:49.000Z
/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkSVGRect_DEFINED #define SkSVGRect_DEFINED #include "SkSVGShape.h" #include "SkSVGTypes.h" class SkRRect; class SkSVGRect final : public SkSVGShape { public: virtual ~SkSVGRect() = default; static sk_sp<SkSVGRect> Make() { return sk_sp<SkSVGRect>(new SkSVGRect()); } void setX(const SkSVGLength&); void setY(const SkSVGLength&); void setWidth(const SkSVGLength&); void setHeight(const SkSVGLength&); void setRx(const SkSVGLength&); void setRy(const SkSVGLength&); protected: void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&, SkPath::FillType) const override; SkPath onAsPath(const SkSVGRenderContext&) const override; private: SkSVGRect(); SkRRect resolve(const SkSVGLengthContext&) const; SkSVGLength fX = SkSVGLength(0); SkSVGLength fY = SkSVGLength(0); SkSVGLength fWidth = SkSVGLength(0); SkSVGLength fHeight = SkSVGLength(0); // The x radius for rounded rects. SkSVGLength fRx = SkSVGLength(0); // The y radius for rounded rects. SkSVGLength fRy = SkSVGLength(0); typedef SkSVGShape INHERITED; }; #endif // SkSVGRect_DEFINED
25.472727
80
0.698787
9dbab5cd94acad8ec3736b74bf85dcf89fb4473a
1,651
h
C
System/Library/AccessibilityBundles/QuickSpeak.bundle/WKContentView_QSExtras.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/AccessibilityBundles/QuickSpeak.bundle/WKContentView_QSExtras.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/AccessibilityBundles/QuickSpeak.bundle/WKContentView_QSExtras.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 12:33:02 PM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/AccessibilityBundles/QuickSpeak.bundle/QuickSpeak * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <QuickSpeak/__WKContentView_QSExtras_super.h> @interface WKContentView_QSExtras : __WKContentView_QSExtras_super +(id)safeCategoryTargetClassName; +(void)_accessibilityPerformValidations:(id)arg1 ; +(Class)safeCategoryBaseClass; -(void)_selectionChanged; -(void)accessibilitySpeakSelectionSetContent:(id)arg1 ; -(void)_accessibilityDidGetSelectionRects:(id)arg1 withGranularity:(long long)arg2 atOffset:(long long)arg3 ; -(id)_accessibilityQuickSpeakContent; -(id)_accessibilitySpeakSelectionTextInputResponder; -(id)_accessibilityRetrieveRectsForGuanularity:(long long)arg1 atSelectionOffset:(long long)arg2 wordText:(id)arg3 ; -(BOOL)_accessibilityShouldUpdateQuickSpeakContent; -(BOOL)_accessibilitySystemShouldShowSpeakBubble; -(BOOL)_accessibilityShouldShowSpeakBubble; -(BOOL)_accessibilityShouldShowSpeakSpellOut; -(BOOL)_accessibilityShouldShowSpeakLanguageBubble; -(void)_axWaitForSpeakSelectionContentResults; -(unsigned long long)_axSelectedTextLength; -(void)_axWaitForSpeakSelectionRectResultsForGuanularity:(long long)arg1 atSelectionOffset:(long long)arg2 wordText:(id)arg3 ; -(id)accessibilityQSSentenceRects; -(id)accessibilityQSWordRects; -(void)accessibilitySetQSWordRects:(id)arg1 ; -(id)_webTextRectsFromWKTextRects:(id)arg1 ; -(void)accessibilitySetQSSentenceRects:(id)arg1 ; @end
45.861111
126
0.837674
e465551780f2dd0030de8e08b3aaf20a59374817
8,686
h
C
platform/micrium_os/fs/include/fs_core_partition.h
PascalGuenther/gecko_sdk
2e82050dc8823c9fe0e8908c1b2666fb83056230
[ "Zlib" ]
82
2016-06-29T17:24:43.000Z
2021-04-16T06:49:17.000Z
platform/micrium_os/fs/include/fs_core_partition.h
GoldSora/sdk_support
5f92c311a302e2ba06040ec37f8ac4eba91b3d5d
[ "Zlib" ]
7
2020-08-25T02:41:16.000Z
2022-03-21T19:55:46.000Z
platform/micrium_os/fs/include/fs_core_partition.h
GoldSora/sdk_support
5f92c311a302e2ba06040ec37f8ac4eba91b3d5d
[ "Zlib" ]
56
2016-08-02T10:50:50.000Z
2021-07-19T08:57:34.000Z
/***************************************************************************//** * @file * @brief File System - Core Partition Operations ******************************************************************************* * # License * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b> ******************************************************************************* * * The licensor of this software is Silicon Laboratories Inc. Your use of this * software is governed by the terms of Silicon Labs Master Software License * Agreement (MSLA) available at * www.silabs.com/about-us/legal/master-software-license-agreement. * The software is governed by the sections of the MSLA applicable to Micrium * Software. * ******************************************************************************/ /****************************************************************************************************//** * @addtogroup FS_CORE * @{ *******************************************************************************************************/ /******************************************************************************************************** ******************************************************************************************************** * MODULE ******************************************************************************************************** *******************************************************************************************************/ #ifndef FS_CORE_PARTITION_H_ #define FS_CORE_PARTITION_H_ /******************************************************************************************************** ******************************************************************************************************** * INCLUDE FILES ******************************************************************************************************** *******************************************************************************************************/ // ------------------------ FS ------------------------ #include <fs/include/fs_core.h> #include <fs/include/fs_blk_dev.h> // ----------------------- EXT ------------------------ #include <common/include/rtos_err.h> #include <cpu/include/cpu.h> #include <common/include/lib_mem.h> /******************************************************************************************************** ******************************************************************************************************** * DEFINES * * Note(s) : (1) Table 5.3 of the book "File System Forensic Analysis, Carrier Brian, 2005" gives various * values used in the partition type field of DOS partitions. The book explained that some * operating systems do not rely on this marker during file system type determination. * Others, such as Microsoft Windows, do. This page gives also the list of partition * identifiers for PCs: http://www.win.tue.nl/~aeb/partitions/partition_types-1.html. ******************************************************************************************************** *******************************************************************************************************/ #define FS_PARTITION_NBR_VOID ((FS_PARTITION_NBR)-1) // See Note #1. #define FS_PARTITION_TYPE_EMPTY 0x00u #define FS_PARTITION_TYPE_FAT12_CHS 0x01u #define FS_PARTITION_TYPE_FAT16_16_32MB 0x04u #define FS_PARTITION_TYPE_CHS_MICROSOFT_EXT 0x05u #define FS_PARTITION_TYPE_FAT16_CHS_32MB_2GB 0x06u #define FS_PARTITION_TYPE_FAT32_CHS 0x0Bu #define FS_PARTITION_TYPE_FAT32_LBA 0x0Cu #define FS_PARTITION_TYPE_FAT16_LBA_32MB_2GB 0x0Eu #define FS_PARTITION_TYPE_LBA_MICROSOFT_EXT 0x0Fu #define FS_PARTITION_TYPE_HID_FAT12_CHS 0x11u #define FS_PARTITION_TYPE_HID_FAT16_16_32MB_CHS 0x14u #define FS_PARTITION_TYPE_HID_FAT16_CHS_32MB_2GB 0x15u #define FS_PARTITION_TYPE_HID_CHS_FAT32 0x1Bu #define FS_PARTITION_TYPE_HID_LBA_FAT32 0x1Cu #define FS_PARTITION_TYPE_HID_FAT16_LBA_32MB_2GB 0x1Eu #define FS_PARTITION_TYPE_NTFS 0x07u #define FS_PARTITION_TYPE_MICROSOFT_MBR 0x42u #define FS_PARTITION_TYPE_SOLARIS_X86 0x82u #define FS_PARTITION_TYPE_LINUX_SWAP 0x82u #define FS_PARTITION_TYPE_LINUX 0x83u #define FS_PARTITION_TYPE_HIBERNATION_A 0x84u #define FS_PARTITION_TYPE_LINUX_EXT 0x85u #define FS_PARTITION_TYPE_NTFS_VOLSETA 0x86u #define FS_PARTITION_TYPE_NTFS_VOLSETB 0x87u #define FS_PARTITION_TYPE_HIBERNATION_B 0xA0u #define FS_PARTITION_TYPE_HIBERNATION_C 0xA1u #define FS_PARTITION_TYPE_FREE_BSD 0xA5u #define FS_PARTITION_TYPE_OPEN_BSD 0xA6u #define FS_PARTITION_TYPE_MAX_OSX 0xA8u #define FS_PARTITION_TYPE_NET_BSD 0xA9u #define FS_PARTITION_TYPE_MAC_OSX_BOOT 0xABu #define FS_PARTITION_TYPE_BSDI 0xB7u #define FS_PARTITION_TYPE_BSDI_SWAP 0xB8u #define FS_PARTITION_TYPE_EFI_GPT_DISK 0xEEu #define FS_PARTITION_TYPE_EFI_SYS_PART 0xEFu #define FS_PARTITION_TYPE_VMWARE_FILE_SYS 0xFBu #define FS_PARTITION_TYPE_VMWARE_SWAP 0xFCu /******************************************************************************************************** ******************************************************************************************************** * DATA TYPES ******************************************************************************************************** *******************************************************************************************************/ typedef struct fs_partition_info { FS_LB_NBR StartSec; ///< Sector number where the partition starts. FS_LB_QTY SecCnt; ///< Number of sectors composing the partition. CPU_INT08U Type; ///< Partition type found in DOS partition table entry. } FS_PARTITION_INFO; /******************************************************************************************************** ******************************************************************************************************** * FUNCTION PROTOTYPES ******************************************************************************************************** *******************************************************************************************************/ #ifdef __cplusplus extern "C" { #endif void FSPartition_Query(FS_BLK_DEV_HANDLE blk_dev_handle, FS_PARTITION_NBR partition_nbr, FS_PARTITION_INFO *p_partition_info, RTOS_ERR *p_err); #if (FS_CORE_CFG_PARTITION_EN == DEF_ENABLED) FS_PARTITION_NBR FSPartition_CntGet(FS_BLK_DEV_HANDLE blk_dev_handle, RTOS_ERR *p_err); #if (FS_CORE_CFG_RD_ONLY_EN == DEF_DISABLED) FS_PARTITION_NBR FSPartition_Add(FS_BLK_DEV_HANDLE blk_dev_handle, FS_LB_QTY partition_sec_cnt, RTOS_ERR *p_err); void FSPartition_Init(FS_BLK_DEV_HANDLE blk_dev_handle, FS_LB_QTY partition_sec_cnt, RTOS_ERR *p_err); #endif #endif #ifdef __cplusplus } #endif /****************************************************************************************************//** ******************************************************************************************************** * @} MODULE ******************************************************************************************************** *******************************************************************************************************/ #endif
56.402597
119
0.377849
77e1c5f2aaa75a423187c8748531bca0ef91e598
558
h
C
ios/versioned/sdk44/EXUpdates/EXUpdates/SelectionPolicy/ABI44_0_0EXUpdatesLoaderSelectionPolicyFilterAware.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
1
2022-01-18T23:59:15.000Z
2022-01-18T23:59:15.000Z
ios/versioned/sdk44/EXUpdates/EXUpdates/SelectionPolicy/ABI44_0_0EXUpdatesLoaderSelectionPolicyFilterAware.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
6
2020-08-06T12:31:23.000Z
2021-02-05T12:47:10.000Z
ios/versioned/sdk44/EXUpdates/EXUpdates/SelectionPolicy/ABI44_0_0EXUpdatesLoaderSelectionPolicyFilterAware.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
1
2020-05-27T08:06:46.000Z
2020-05-27T08:06:46.000Z
// Copyright © 2021 650 Industries. All rights reserved. #import <ABI44_0_0EXUpdates/ABI44_0_0EXUpdatesLoaderSelectionPolicy.h> NS_ASSUME_NONNULL_BEGIN /** * An ABI44_0_0EXUpdatesLoaderSelectionPolicy which decides whether or not to load an update, taking filters into * account. Returns true (should load the update) if we don't have an existing newer update that * matches the given manifest filters. */ @interface ABI44_0_0EXUpdatesLoaderSelectionPolicyFilterAware : NSObject <ABI44_0_0EXUpdatesLoaderSelectionPolicy> @end NS_ASSUME_NONNULL_END
32.823529
114
0.824373
3e90edc763af97cdca0b2a0c16f1977ae9a0bd86
457
h
C
head/crypto/heimdal/lib/wind/punycode_examples.h
dplbsd/soc2013
c134f5e2a5725af122c94005c5b1af3720706ce3
[ "BSD-2-Clause" ]
34
2015-02-04T18:03:14.000Z
2020-11-10T06:45:28.000Z
head/crypto/heimdal/lib/wind/punycode_examples.h
dplbsd/soc2013
c134f5e2a5725af122c94005c5b1af3720706ce3
[ "BSD-2-Clause" ]
21
2016-08-11T09:43:43.000Z
2017-01-29T12:52:56.000Z
head/crypto/heimdal/lib/wind/punycode_examples.h
dplbsd/soc2013
c134f5e2a5725af122c94005c5b1af3720706ce3
[ "BSD-2-Clause" ]
15
2015-10-29T14:21:58.000Z
2022-01-19T07:33:14.000Z
/* ./punycode_examples.h */ /* Automatically generated at 2012-01-11T14:07:08.539140 */ #ifndef PUNYCODE_EXAMPLES_H #define PUNYCODE_EXAMPLES_H 1 #include <krb5-types.h> #define MAX_LENGTH 40 struct punycode_example { size_t len; uint32_t val[MAX_LENGTH]; const char *pc; const char *description; }; extern const struct punycode_example punycode_examples[]; extern const size_t punycode_examples_size; #endif /* PUNYCODE_EXAMPLES_H */
20.772727
59
0.754923
6b9f3c7d25c02431f989d225a47e027316c0da63
3,371
h
C
src/x11glvnd/x11glvnd.h
bluca/libglvnd
ba0b05a5691006b8e954af6494a58c057514bb6e
[ "Unlicense" ]
1
2019-04-22T09:09:11.000Z
2019-04-22T09:09:11.000Z
src/x11glvnd/x11glvnd.h
bluca/libglvnd
ba0b05a5691006b8e954af6494a58c057514bb6e
[ "Unlicense" ]
null
null
null
src/x11glvnd/x11glvnd.h
bluca/libglvnd
ba0b05a5691006b8e954af6494a58c057514bb6e
[ "Unlicense" ]
null
null
null
/* * Copyright (c) 2013, NVIDIA CORPORATION. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * unaltered in all copies or substantial portions of the Materials. * Any additions, deletions, or changes to the original source files * must be clearly indicated in accompanying documentation. * * If only executable code is distributed, then the accompanying * documentation must state that "this software is based in part on the * work of the Khronos Group." * * THE MATERIALS ARE 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 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #ifndef __X11GLVND_H__ #define __X11GLVND_H__ #include <X11/Xlib.h> /* * Describes the client-side functions implemented by the x11glvnd extension. * This is a simple extension to query the X server for XID -> screen and screen * -> vendor mappings, used by libGLX. This may eventually be replaced by a * server-side GLX extension which does the same thing. */ #define XGLV_EXTENSION_NAME "x11glvnd" /*! * Determines if the x11glvnd extension is supported. * * \param[out] event_base_return Returns the base event code. * \param[out] error_base_return Returns the base error code. * \return True if the extension is available, or False if it is not. */ Bool XGLVQueryExtension(Display *dpy, int *event_base_return, int *error_base_return); /*! * Returns the version of the x11glvnd extension supported by the server. * * \param[out] major Returns the major version number. * \param[out] minor Returns the minor version number. * \return nonzero if the server supports a compatible version of x11glvnd. */ Bool XGLVQueryVersion(Display *dpy, int *major, int *minor); /*! * Returns the screen associated with this XID, or -1 if there was an error. */ int XGLVQueryXIDScreenMapping( Display *dpy, XID xid ); /*! * Returns the vendor associated with this screen, or NULL if there was an * error. * * The caller must free the string with XFree. */ char *XGLVQueryScreenVendorMapping( Display *dpy, int screen ); /* * Registers a callback with x11glvnd which is fired whenever XCloseDisplay() * is called. This gives x11glvnd clients a lightweight alternative to * declaring themselves an X11 extension and using XESetCloseDisplay(). * * This is NOT a thread-safe operation. */ void XGLVRegisterCloseDisplayCallback(void (*callback)(Display *)); /* * Unregisters all registered callbacks. */ void XGLVUnregisterCloseDisplayCallbacks(void); #endif // __X11GLVND_H__
35.114583
86
0.752596
5c6f57dbeedaca381066aa5a3e864ebac32a04a7
4,855
c
C
pjproject_android/pjlib/src/pjlib-test/test.c
WachterJud/qaul.net_legacy
9c2be0a38ad6e90fadc0d1150340e37d220997ae
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
1
2019-07-30T14:44:29.000Z
2019-07-30T14:44:29.000Z
pjproject_android/pjlib/src/pjlib-test/test.c
WachterJud/qaul.net_legacy
9c2be0a38ad6e90fadc0d1150340e37d220997ae
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
pjproject_android/pjlib/src/pjlib-test/test.c
WachterJud/qaul.net_legacy
9c2be0a38ad6e90fadc0d1150340e37d220997ae
[ "MIT", "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
/* $Id: test.c 3553 2011-05-05 06:14:19Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "test.h" #include <pjlib.h> #ifdef _MSC_VER # pragma warning(disable:4127) #endif #define DO_TEST(test) do { \ PJ_LOG(3, ("test", "Running %s...", #test)); \ rc = test; \ PJ_LOG(3, ("test", \ "%s(%d)", \ (rc ? "..ERROR" : "..success"), rc)); \ if (rc!=0) goto on_return; \ } while (0) pj_pool_factory *mem; int param_echo_sock_type; const char *param_echo_server = ECHO_SERVER_ADDRESS; int param_echo_port = ECHO_SERVER_START_PORT; int param_log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME | PJ_LOG_HAS_MICRO_SEC; int null_func() { return 0; } int test_inner(void) { pj_caching_pool caching_pool; const char *filename; int line; int rc = 0; mem = &caching_pool.factory; pj_log_set_level(3); pj_log_set_decor(param_log_decor); rc = pj_init(); if (rc != 0) { app_perror("pj_init() error!!", rc); return rc; } //pj_dump_config(); pj_caching_pool_init( &caching_pool, NULL, 0 ); #if INCLUDE_ERRNO_TEST DO_TEST( errno_test() ); #endif #if INCLUDE_EXCEPTION_TEST DO_TEST( exception_test() ); #endif #if INCLUDE_OS_TEST DO_TEST( os_test() ); #endif #if INCLUDE_RAND_TEST DO_TEST( rand_test() ); #endif #if INCLUDE_LIST_TEST DO_TEST( list_test() ); #endif #if INCLUDE_POOL_TEST DO_TEST( pool_test() ); #endif #if INCLUDE_POOL_PERF_TEST DO_TEST( pool_perf_test() ); #endif #if INCLUDE_STRING_TEST DO_TEST( string_test() ); #endif #if INCLUDE_FIFOBUF_TEST DO_TEST( fifobuf_test() ); #endif #if INCLUDE_RBTREE_TEST DO_TEST( rbtree_test() ); #endif #if INCLUDE_HASH_TEST DO_TEST( hash_test() ); #endif #if INCLUDE_TIMESTAMP_TEST DO_TEST( timestamp_test() ); #endif #if INCLUDE_ATOMIC_TEST DO_TEST( atomic_test() ); #endif #if INCLUDE_MUTEX_TEST DO_TEST( mutex_test() ); #endif #if INCLUDE_TIMER_TEST DO_TEST( timer_test() ); #endif #if INCLUDE_SLEEP_TEST DO_TEST( sleep_test() ); #endif #if INCLUDE_THREAD_TEST DO_TEST( thread_test() ); #endif #if INCLUDE_SOCK_TEST DO_TEST( sock_test() ); #endif #if INCLUDE_SOCK_PERF_TEST DO_TEST( sock_perf_test() ); #endif #if INCLUDE_SELECT_TEST DO_TEST( select_test() ); #endif #if INCLUDE_UDP_IOQUEUE_TEST DO_TEST( udp_ioqueue_test() ); #endif #if PJ_HAS_TCP && INCLUDE_TCP_IOQUEUE_TEST DO_TEST( tcp_ioqueue_test() ); #endif #if INCLUDE_IOQUEUE_PERF_TEST DO_TEST( ioqueue_perf_test() ); #endif #if INCLUDE_IOQUEUE_UNREG_TEST DO_TEST( udp_ioqueue_unreg_test() ); #endif #if INCLUDE_ACTIVESOCK_TEST DO_TEST( activesock_test() ); #endif #if INCLUDE_FILE_TEST DO_TEST( file_test() ); #endif #if INCLUDE_SSLSOCK_TEST DO_TEST( ssl_sock_test() ); #endif #if INCLUDE_ECHO_SERVER //echo_server(); //echo_srv_sync(); udp_echo_srv_ioqueue(); #elif INCLUDE_ECHO_CLIENT if (param_echo_sock_type == 0) param_echo_sock_type = pj_SOCK_DGRAM(); echo_client( param_echo_sock_type, param_echo_server, param_echo_port); #endif goto on_return; on_return: pj_caching_pool_destroy( &caching_pool ); PJ_LOG(3,("test", "")); pj_thread_get_stack_info(pj_thread_this(), &filename, &line); PJ_LOG(3,("test", "Stack max usage: %u, deepest: %s:%u", pj_thread_get_stack_max_usage(pj_thread_this()), filename, line)); if (rc == 0) PJ_LOG(3,("test", "Looks like everything is okay!..")); else PJ_LOG(3,("test", "Test completed with error(s)")); pj_shutdown(); return 0; } #include <pj/sock.h> int test_main(void) { int i; PJ_USE_EXCEPTION; i = pj_AF_INET(); PJ_TRY { return test_inner(); } PJ_CATCH_ANY { int id = PJ_GET_EXCEPTION(); PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)", id, pj_exception_id_name(id))); } PJ_END; return -1; }
20.659574
77
0.665911
55b59258c0214a6faf1f42206a21d3f058e455e3
8,913
h
C
Tudat/Astrodynamics/MissionSegments/oscillatingFunctionNovak.h
sebranchett/tudat
24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44
[ "BSD-3-Clause" ]
null
null
null
Tudat/Astrodynamics/MissionSegments/oscillatingFunctionNovak.h
sebranchett/tudat
24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44
[ "BSD-3-Clause" ]
null
null
null
Tudat/Astrodynamics/MissionSegments/oscillatingFunctionNovak.h
sebranchett/tudat
24e5f3cc85c250fcbed0aac37f026c1dd7fd6c44
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 2010-2019, Delft University of Technology * All rigths reserved * * This file is part of the Tudat. Redistribution and use in source and * binary forms, with or without modification, are permitted exclusively * under the terms of the Modified BSD license. You should have received * a copy of the license with this file. If not, please or visit: * http://tudat.tudelft.nl/LICENSE. * * References * Novak, D.M. Methods and Tools for Preliminary Low Thrust Mission Analysis. PhD Thesis, * University of Glasgow, UK, 2012. * Novak, D.M. and M. Vasile. Improved Shaping Approach to the Preliminary Design of Low- * Thrust Trajectories, Journal of Guidance, Control, and Dynamics 34(1), pp. 128147, * 2011. * Wall, B.J. and D. Novak. A 3D Shape-Based Approximation Method for Low-Thrust Trajectory * Design, Advances in the Astronautical Sciences 142(2), pp. 1163-1176, 2012. * * Notes * This file contains a specific oscillating function, which is described by Novak and Vasile * [2011] (See also Novak [2012] and Wall and Novak [2012]). This function is a mathematical * representation of the (out-of-plane) elevation angle, phi (in spherical coordinates), of a * thrusting spacecraft. This oscillating function can be used to approximate a * continuous-thrust trajectory (also referred to as a low-thrust trajectory), when combined * with a function which represents the radial position, r (in spherical coordinates), of a * thrusting spacecraft. The spherical coordinate system that is used for the calculations and * the descriptions is taken from Novak and Vasile [2011]. */ #ifndef TUDAT_OSCILLATING_FUNCTION_NOVAK_H #define TUDAT_OSCILLATING_FUNCTION_NOVAK_H #include <functional> #include <boost/make_shared.hpp> #include <Eigen/Core> #include "Tudat/Mathematics/BasicMathematics/function.h" namespace tudat { namespace mission_segments { //! Oscillating function approximating the (out-of-plane) elevation angle of a thrusting //! spacecraft. /*! * This class contains an oscillating function, and its exact first and second derivative w.r.t. * the azimuthal angle \f$ \theta \f$. It is a mathematical function, and can be used to * approximate the out-of-plane motion of a thrusting spacecraft. The function is documented by * Novak and Vasile [2011]. It approximates the (out-of-plane) elevation angle of the spacecraft. * The (out-of-plane) elevation angle is parameterized in terms of an independent variable, the * (in-plane) azimuthal angle \f$ \theta \f$. The first and second derivative are taken with * respect to this independent variable. * * The function is completely described by the independent variable \f$ \theta \f$ and a set of * four parameters. These parameters are related to the boundary conditions of the problem: two * initial conditions and two final conditions. These parameters are passed to this class as * std::functions to facilitate the flexible external manipulation of their values. * */ class OscillatingFunctionNovak : public basic_mathematics::Function< > { public: //! Default constructor with immediate definition of parameters. /*! * Default constructor with immediate definition of parameters through std::functions. * This setup allows for a flexible external manipulation of the values of the parameters. * * \param aSetOfBoundaryParameters A set of four parameters, related to the boundary conditions. * These parameters are equivalent to the parameters b0, b1, b2, and b3 from Novak and * Vasile [2011]. The order is important! * aSetOfBoundaryParameters.first( 0 ) = b0 * aSetOfBoundaryParameters.first( 1 ) = b1 * aSetOfBoundaryParameters.second( 0 ) = b2 * aSetOfBoundaryParameters.second( 1 ) = b3 */ OscillatingFunctionNovak( const std::function< std::pair< Eigen::Vector2d, const Eigen::Vector2d >( ) > aSetOfBoundaryParameters ) : boundaryParameters_( aSetOfBoundaryParameters ){ } //! Default destructor. /*! * Default destructor. */ ~OscillatingFunctionNovak( ){ } //! Evaluate the function value for a given (in-plane) azimuthal angle. /*! * Evaluates the oscillating function for a given (in-plane) azimuthal angle \f$ \theta \f$. * * The function is given by Novak and Vasile [2011] as: * * \f[ * \phi ( \theta ) = \left( b_0 + b_1 \theta \right) \cos \theta + * \left( b_2 + b_3 \theta \right) sin \theta * \f] * * in which \f$ \phi \f$ is the (out-of-plane) elevation angle of the spacecraft, * \f$ \theta \f$ is the (in-plane) azimuthal angle and \f$ ( b_0 ,b_1, b_2, b_3) \f$ are * parameters that define the shape of the trajectory. * * \param anAzimuthalAngle Value of the (in-plane) azimuthal angle [rad]. * \return The (out-of-plane) elevation angle at \f$ \theta \f$ [m]. */ double evaluate( const double anAzimuthalAngle ); //! Compute the derivative of the function. /*! * Computes the derivative of a given order of the function, for a given (in-plane) azimuthal * angle \f$ \theta \f$. It only evaluates the first, second or third derivative, therefore the * order should be 1, 2 or 3. * * The first derivative of the function is: * * \f[ * \frac{ d \phi }{ d \theta } ( \theta ) = * \left( b_1 + b_2 + b_3 \theta \right) \cos \theta - * \left( b_0 + b_1 \theta - b_3 \right) \sin \theta * \f] * * The second derivative of the function is: * * \f[ * \frac{ d^2 \phi }{ d \theta^2 } ( \theta ) = * \left( - b_0 - b_1 \theta + 2 b_3 \right) \cos \theta - * \left( 2 b_1 + b_2 + b_3 \theta \right) \sin \theta * \f] * * The third derivative of the function is: * * \f[ * \frac{ d^3 \phi }{ d \theta^3 } ( \theta ) = * - \left( 3 b_1 + b_2 + b_3 \theta \right) \cos \theta - * \left( b_0 + b_1 \theta - 3 b_3 \right) \sin \theta * \f] * * In these formulas \f$ \phi \f$ is the (out-of-plane) elevation angle of the spacecraft, * \f$ \theta \f$ is the (in-plane) azimuthal angle, the prime indicates the derivative with * respect to \f$ \theta \f$, and \f$ ( b_0 ,b_1, b_2, b_3 ) \f$ are parameters that define the * shape of the trajectory. * * \param order Order of the derivative to evaluate. Can be either 1, 2 or 3. * \param anAzimuthalAngle Value of the (in-plane) azimuthal angle [rad]. * \return Value of the derivative of order 1, 2 or 3 of the function [-, rad^-1, rad^-2]. */ double computeDerivative( const unsigned int order, const double anAzimuthalAngle ); //! Compute the definite integral of the function. /*! * This function throws a runtime error when it is called. The integral of the inverse * polynomial function is not part of the shape-based method. * * \param order Order of the integral to evaluate. * \param lowerBound Integration lower bound (integrate from this point). * \param upperBound Integration upper bound (integrate to this point). * \return Value of the integral. * * \throws std::runtime_error when this function is used. */ double computeDefiniteIntegral( const unsigned int order, const double lowerBound, const double upperBound ); protected: private: //! The parameters of the function, related to the boundary conditions. /*! * The four parameters of the function. These parameters determine the shape of the trajectory * and are dependent on the initial and final boundary conditions. * * The first two parameters are dependent on the initial boundary conditions and the last two * parameters are dependent on the final boundary conditions. The parameters correspond to * Novak and Vasile [2011] in the following manner: the first two parameters are \f$ b_0 \f$ * and \f$ b_1 \f$; the last two parameters are \f$ b_2 \f$ and \f$ b_3 \f$. * * The order is important! * boundaryParameters_.first( 0 ) = b_0 * boundaryParameters_.first( 1 ) = b_1 * boundaryParameters_.second( 0 ) = b_2 * boundaryParameters_.second( 1 ) = b_3 */ std::function< std::pair< Eigen::Vector2d, Eigen::Vector2d >( ) > boundaryParameters_; }; //! Typedef for shared-pointer to oscillatingFunctionNovak object. typedef std::shared_ptr< OscillatingFunctionNovak > OscillatingFunctionNovakPointer; } // namespace mission_segments } // namespace tudat #endif // TUDAT_OSCILLATING_FUNCTION_NOVAK_H
45.47449
100
0.663076