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
8ec5af52bb9e3d8f1ab406fe5fa7b18d9447d8ea
1,501
h
C
src/cd.h
jhamby/vms-cd-new
c7154fe544b625ec678d30b3665a4078ff07a326
[ "MIT" ]
2
2021-08-19T19:33:46.000Z
2021-10-14T03:10:11.000Z
src/cd.h
jhamby/vms-cd-new
c7154fe544b625ec678d30b3665a4078ff07a326
[ "MIT" ]
null
null
null
src/cd.h
jhamby/vms-cd-new
c7154fe544b625ec678d30b3665a4078ff07a326
[ "MIT" ]
1
2021-08-07T16:29:56.000Z
2021-08-07T16:29:56.000Z
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* vim: set ts=8 sts=4 et sw=4 tw=80: */ /* * Main C++ header file for CD. * Copyright 2021, Jake Hamby. * This code is licensed under an MIT license. */ #ifndef VMS_CD_H_ #define VMS_CD_H_ #include "vms-descriptors.h" // Status flags passed in return block to caller. The original // version returned status in the condition code, and also as // a "switches" field in the return block. Now the condition // code is just checked for success and returned to VMS if not. #define RESULT_DO_COMMAND 0x01 #define RESULT_DO_COMMAND_FILE 0x02 #define RESULT_LAUNCH_HELP 0x04 // Replacement for "retblk" in the original VAX version. The refactored // cd_parse() now calls sys$putmsg() as needed, so main() only needs // to handle optionally calling lib$do_command or opening the program help. struct cd_parse_results { StringDesc do_command_fspec; // Use different DO if /COM= used unsigned int flags; }; // Function prototypes. /** * This version of cd_parse() takes argc/argv from main and returns a * VMS condition code, which should be SS$_NORMAL. If not, return it. * Otherwise, main() will check the flags to call the cd.com command file, * or a custom command file (in do_command_name). The caller should * initialize do_command_name to an empty dynamic string descriptor. */ int cd_parse(int argc, char *argv[], struct cd_parse_results &results); #endif // VMS_CD_H_
34.906977
79
0.718854
b8389e734d212461c4fdbc233a652216dc77bee4
5,707
c
C
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/space_to_batch.c
Joejiong/mindspore
083fd6565cab1aa1d3114feeacccf1cba0d55e80
[ "Apache-2.0" ]
null
null
null
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/space_to_batch.c
Joejiong/mindspore
083fd6565cab1aa1d3114feeacccf1cba0d55e80
[ "Apache-2.0" ]
null
null
null
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/space_to_batch.c
Joejiong/mindspore
083fd6565cab1aa1d3114feeacccf1cba0d55e80
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2020 Huawei Technologies 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. */ #include "nnacl/fp32/space_to_batch.h" #include "nnacl/arithmetic_common.h" #include "nnacl/errorcode.h" #include "nnacl/fp32/concat.h" #include "nnacl/op_base.h" int EnumElement(int *shape, int n_dims) { int total = 1; for (int i = 0; i < n_dims; i++) { total *= shape[i]; } return total; } void TransposeForNHWC(const float *in_data, float *out_data, int *strides, int *out_strides, int *perm, int *output_shape, int h_start, int h_end) { const int stride0 = strides[perm[0]]; const int stride1 = strides[perm[1]]; const int stride2 = strides[perm[2]]; const int stride3 = strides[perm[3]]; const int stride4 = strides[perm[4]]; const int out_stride0 = out_strides[0]; const int out_stride1 = out_strides[1]; const int out_stride2 = out_strides[2]; const int out_stride3 = out_strides[3]; const int out_stride4 = out_strides[4]; const int output0 = output_shape[0]; const int output2 = output_shape[2]; const int output3 = output_shape[3]; const int output4 = output_shape[4]; for (int i = 0; i < output0; ++i) { int out_stride0_i = i * out_stride0; int stride0_i = i * stride0; for (int j = h_start; j < h_end; ++j) { int out_stride1_j = j * out_stride1; int stride1_j = j * stride1; for (int k = 0; k < output2; ++k) { int out_stride2_k = k * out_stride2; int stride2_k = k * stride2; for (int m = 0; m < output3; ++m) { int out_stride3_m = m * out_stride3; int stride3_m = m * stride3; for (int n = 0; n < output4; ++n) { int out_stride4_n = n * out_stride4; int stride4_n = n * stride4; memcpy(out_data + out_stride0_i + out_stride1_j + out_stride2_k + out_stride3_m + out_stride4_n, in_data + stride0_i + stride1_j + stride2_k + stride3_m + stride4_n, stride4 * sizeof(float)); } } } } } } int SpaceToBatchForNHWC(const float *input, float *output, int *in_shape, int shape_size, int *block_sizes, int h_start, int h_end) { int trans_in_shape[6] = {in_shape[0], in_shape[1] / block_sizes[0], block_sizes[0], in_shape[2] / block_sizes[1], block_sizes[1], in_shape[3]}; int trans_out_shape[6] = { in_shape[0], block_sizes[0], block_sizes[1], in_shape[1] / block_sizes[0], in_shape[2] / block_sizes[1], in_shape[3]}; int in_strides[C4NUM + 2]; ComputeStrides(trans_in_shape, in_strides, shape_size + 2); int out_strides[C4NUM + 2]; ComputeStrides(trans_out_shape, out_strides, shape_size + 2); int perm[6] = {0, 2, 4, 1, 3, 5}; TransposeForNHWC(input, output, in_strides, out_strides, perm, trans_out_shape, h_start, h_end); return NNACL_OK; } void DoPadding(const float *input, float *padded_input, SpaceToBatchParameter param, float *tmp_space[]) { float *tmp = padded_input; (void)memcpy(tmp, input, param.num_elements_ * sizeof(float)); float *target = tmp_space[0]; float *tmp_zeros = tmp_space[1]; float *tmp2 = NULL; int cur_shape[param.n_dims_], cur_start_shape[param.n_dims_], cur_end_shape[param.n_dims_], cur_target_shape[param.n_dims_]; float *concat_inputs[3]; int *concat_shapes[4]; for (int i = 0; i < param.n_dims_; i++) { cur_shape[i] = param.in_shape_[i]; cur_start_shape[i] = param.in_shape_[i]; cur_end_shape[i] = param.in_shape_[i]; cur_target_shape[i] = param.in_shape_[i]; } for (int i = 0; i < param.n_space_dims_; ++i) { if (param.padded_in_shape_[i + 1] > param.in_shape_[i + 1]) { int concat_idx = 0; cur_target_shape[i + 1] = 0; if (param.paddings_[2 * i] != 0) { cur_start_shape[i + 1] = param.paddings_[2 * i]; concat_inputs[concat_idx] = tmp_zeros; concat_shapes[concat_idx++] = cur_start_shape; cur_target_shape[i + 1] += cur_start_shape[i + 1]; } concat_inputs[concat_idx] = tmp; concat_shapes[concat_idx++] = cur_shape; cur_target_shape[i + 1] += cur_shape[i + 1]; if (param.paddings_[2 * i + 1] != 0) { cur_end_shape[i + 1] = param.paddings_[2 * i + 1]; concat_inputs[concat_idx] = tmp_zeros; concat_shapes[concat_idx++] = cur_end_shape; cur_target_shape[i + 1] += cur_end_shape[i + 1]; } concat_shapes[concat_idx] = cur_target_shape; Concat((void **)concat_inputs, concat_idx, i + 1, concat_shapes, param.n_dims_, target); tmp2 = tmp; tmp = target; target = tmp2; cur_start_shape[i + 1] = cur_end_shape[i + 1] = cur_shape[i + 1] = concat_shapes[concat_idx][i + 1]; } } if (padded_input != tmp) { memcpy(padded_input, tmp, param.num_elements_padded_ * sizeof(float)); } } int SpaceToBatch(const float *input, float *output, SpaceToBatchParameter param, int h_start, int h_end) { if (input == NULL || output == NULL) { return NNACL_NULL_PTR; } auto ret = SpaceToBatchForNHWC(input, output, param.padded_in_shape_, param.n_dims_, param.block_sizes_, h_start, h_end); return ret; }
38.560811
120
0.648327
b85c9b9c253dc276b159d0b2b4a75eb2d0bd7ba0
861
h
C
Inc/CANSPI.h
dnagamini/STM32_MCP2515_SPI
d84d3104b701766f7528d491e3491536a9ebe842
[ "MIT" ]
null
null
null
Inc/CANSPI.h
dnagamini/STM32_MCP2515_SPI
d84d3104b701766f7528d491e3491536a9ebe842
[ "MIT" ]
null
null
null
Inc/CANSPI.h
dnagamini/STM32_MCP2515_SPI
d84d3104b701766f7528d491e3491536a9ebe842
[ "MIT" ]
1
2022-01-22T07:45:40.000Z
2022-01-22T07:45:40.000Z
#ifndef CAN_SPI_H #define CAN_SPI_H #include "main.h" typedef union { struct { uint8_t idType; uint32_t id; uint8_t dlc; uint8_t data0; uint8_t data1; uint8_t data2; uint8_t data3; uint8_t data4; uint8_t data5; uint8_t data6; uint8_t data7; } frame; uint8_t array[14]; } uCAN_MSG; #define CMD_STANDARD_CAN_MSG_ID 0 #define CMD_EXTENDED_CAN_MSG_ID 1 #define EXTENDED_CAN_MSG_ID_2_0B 2 bool CANSPI_Initialize(void); bool CANSPI_Init_Mask(uint8_t num, uint8_t ext, uint32_t id); bool CANSPI_Init_Filter(uint8_t num, uint8_t ext, uint32_t id); uint8_t CANSPI_Transmit(uCAN_MSG *tempCanMsg); uint8_t CANSPI_Receive(uCAN_MSG *tempCanMsg); uint8_t CANSPI_messagesInBuffer(void); uint8_t CANSPI_isBussOff(void); uint8_t CANSPI_isRxErrorPassive(void); uint8_t CANSPI_isTxErrorPassive(void); #endif /* CAN_SPI_H */
22.076923
63
0.761905
cce9989a2e1fe417779024d596aa3c0889c53c7b
1,115
h
C
src/mame/includes/battlane.h
seleuco/MAME4droid_Native
b6adcf8ba8ac602d93d28ec4e6f7346f92c84363
[ "Unlicense" ]
5
2020-09-09T09:24:59.000Z
2022-03-22T04:44:14.000Z
src/mame/includes/battlane.h
seleuco/MAME4droid_Native
b6adcf8ba8ac602d93d28ec4e6f7346f92c84363
[ "Unlicense" ]
null
null
null
src/mame/includes/battlane.h
seleuco/MAME4droid_Native
b6adcf8ba8ac602d93d28ec4e6f7346f92c84363
[ "Unlicense" ]
4
2021-02-04T13:26:39.000Z
2022-03-07T08:51:45.000Z
/*************************************************************************** Battle Lane Vol. 5 ***************************************************************************/ class battlane_state : public driver_data_t { public: static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, battlane_state(machine)); } battlane_state(running_machine &machine) : driver_data_t(machine) { } /* memory pointers */ UINT8 * tileram; UINT8 * spriteram; /* video-related */ tilemap_t *bg_tilemap; bitmap_t *screen_bitmap; int video_ctrl; int cpu_control; /* CPU interrupt control register */ /* devices */ running_device *maincpu; running_device *subcpu; }; /*----------- defined in video/battlane.c -----------*/ WRITE8_HANDLER( battlane_palette_w ); WRITE8_HANDLER( battlane_scrollx_w ); WRITE8_HANDLER( battlane_scrolly_w ); WRITE8_HANDLER( battlane_tileram_w ); WRITE8_HANDLER( battlane_spriteram_w ); WRITE8_HANDLER( battlane_bitmap_w ); WRITE8_HANDLER( battlane_video_ctrl_w ); VIDEO_START( battlane ); VIDEO_UPDATE( battlane );
25.930233
118
0.622422
69724d0e6ec1e9560bfa62efc66fb93429813f33
1,451
h
C
System/Library/PrivateFrameworks/CoreDuetContext.framework/CoreDuetContext.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/CoreDuetContext.framework/CoreDuetContext.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/CoreDuetContext.framework/CoreDuetContext.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
#import <CoreDuetContext/_CDContextualKeyPathAndValue.h> #import <CoreDuetContext/_CDSharedMemoryContextPersisting.h> #import <CoreDuetContext/_CDContextQueries.h> #import <CoreDuetContext/_CDContextualChangeRegistration.h> #import <CoreDuetContext/_CDCoreDataContextPersisting.h> #import <CoreDuetContext/_CDContextualKeyPath.h> #import <CoreDuetContext/_CDContextualLocationRegistrationMonitor.h> #import <CoreDuetContext/_CDContextualPredicate.h> #import <CoreDuetContext/_CDMDCSContextualPredicate.h> #import <CoreDuetContext/_CDContextValue.h> #import <CoreDuetContext/_CDContextualKeyPathMO.h> #import <CoreDuetContext/_CDDevice.h> #import <CoreDuetContext/_CDNetworkContext.h> #import <CoreDuetContext/_CDInMemoryContext.h> #import <CoreDuetContext/_CDInMemoryUserContext.h> #import <CoreDuetContext/_CDUserContextQueries.h> #import <CoreDuetContext/_CDContextualChangeRegistrationMO.h> #import <CoreDuetContext/_CDContextPredictionQueries.h> #import <CoreDuetContext/_CDModeClassifier.h> #import <CoreDuetContext/_CDXPCCodecs.h> #import <CoreDuetContext/_CDClientContext.h> #import <CoreDuetContext/_CDPolicyBasedPersisting.h> #import <CoreDuetContext/_CDContextMonitorManager.h> #import <CoreDuetContext/_CDUserContextServerClient.h> #import <CoreDuetContext/_CDSystemTimeCallbackScheduler.h> #import <CoreDuetContext/_CDXPCEventPublisher.h> #import <CoreDuetContext/_CDXPCEventSubscriber.h> #import <CoreDuetContext/_CDUserContextService.h>
50.034483
68
0.864921
f811e298b9352e6538abfd800905fc6e83a00695
3,260
c
C
source/ruby-1.9.2-p180/version.c
racker/omnibus
7f619cee98d551acaef3aed28c85f1c150d0ed8a
[ "Apache-2.0" ]
2
2015-07-30T09:28:19.000Z
2016-08-30T12:40:34.000Z
source/ruby-1.9.2-p180/version.c
racker/omnibus
7f619cee98d551acaef3aed28c85f1c150d0ed8a
[ "Apache-2.0" ]
1
2015-07-31T18:11:11.000Z
2015-07-31T18:11:11.000Z
source/ruby-1.9.2-p180/version.c
racker/omnibus
7f619cee98d551acaef3aed28c85f1c150d0ed8a
[ "Apache-2.0" ]
null
null
null
/********************************************************************** version.c - $Author: nobu $ created at: Thu Sep 30 20:08:01 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto **********************************************************************/ #include "ruby/ruby.h" #include "version.h" #include <stdio.h> #define PRINT(type) puts(ruby_##type) #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1)) #ifndef RUBY_ARCH #define RUBY_ARCH RUBY_PLATFORM #endif #ifndef RUBY_SITEARCH #define RUBY_SITEARCH RUBY_ARCH #endif #ifdef RUBY_PLATFORM_CPU #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS #endif #ifndef RUBY_LIB_PREFIX #ifndef RUBY_EXEC_PREFIX #error RUBY_EXEC_PREFIX must be defined #endif #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby" #endif #ifndef RUBY_SITE_LIB #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby" #endif #ifndef RUBY_VENDOR_LIB #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby" #endif #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION #define RUBY_ARCHLIB RUBY_LIB "/"RUBY_ARCH #define RUBY_SITE_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_SITEARCH #define RUBY_VENDOR_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH #ifdef RUBY_THINARCH #define RUBY_THIN_ARCHLIB RUBY_LIB "/"RUBY_THINARCH #define RUBY_SITE_THIN_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_THINARCH #define RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_THINARCH #endif const char ruby_version[] = RUBY_VERSION; const char ruby_release_date[] = RUBY_RELEASE_DATE; const char ruby_platform[] = RUBY_PLATFORM; const int ruby_patchlevel = RUBY_PATCHLEVEL; const char ruby_description[] = RUBY_DESCRIPTION; const char ruby_copyright[] = RUBY_COPYRIGHT; const char ruby_engine[] = "ruby"; VALUE ruby_engine_name = Qnil; const char ruby_initial_load_paths[] = #ifndef NO_INITIAL_LOAD_PATH #ifdef RUBY_SEARCH_PATH RUBY_SEARCH_PATH "\0" #endif RUBY_SITE_LIB2 "\0" #ifdef RUBY_SITE_THIN_ARCHLIB RUBY_SITE_THIN_ARCHLIB "\0" #endif RUBY_SITE_ARCHLIB "\0" RUBY_SITE_LIB "\0" RUBY_VENDOR_LIB2 "\0" #ifdef RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_THIN_ARCHLIB "\0" #endif RUBY_VENDOR_ARCHLIB "\0" RUBY_VENDOR_LIB "\0" RUBY_LIB "\0" #ifdef RUBY_THIN_ARCHLIB RUBY_THIN_ARCHLIB "\0" #endif RUBY_ARCHLIB "\0" #endif ""; void Init_version(void) { rb_define_global_const("RUBY_VERSION", MKSTR(version)); rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date)); rb_define_global_const("RUBY_PLATFORM", MKSTR(platform)); rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL)); rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION)); rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description)); rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright)); rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine)); } void ruby_show_version(void) { PRINT(description); fflush(stdout); } void ruby_show_copyright(void) { PRINT(copyright); exit(0); }
28.347826
89
0.721779
927a9d187534603ffc1612f097f9eca9d10ff5d2
594
h
C
Source/src/components/ComponentAudioSource.h
Akita-Interactive/Hachiko-Engine
0e3e0377ac5c8f5b15c525c8fcff384e9c92c14b
[ "MIT" ]
5
2022-02-10T23:31:11.000Z
2022-02-11T19:32:38.000Z
Source/src/components/ComponentAudioSource.h
Akita-Interactive/Hachiko-Engine
0e3e0377ac5c8f5b15c525c8fcff384e9c92c14b
[ "MIT" ]
26
2022-02-17T20:02:51.000Z
2022-03-31T22:52:14.000Z
Source/src/components/ComponentAudioSource.h
AkitaInteractive/Hachiko-Engine
9d682ed7e00e1f6b889e6e73afa36f290cfb2222
[ "MIT" ]
null
null
null
#pragma once #include "components/Component.h" class AkTransform; namespace Hachiko { class GameObject; class ComponentAudioSource : public Component { public: ComponentAudioSource(GameObject* conatiner); ~ComponentAudioSource() override; void OnTransformUpdated() override; HACHIKO_API void PostEvent(const wchar_t* name_event) const; void DrawGui() override; private: AkTransform* source_transform; uint64_t source_id; // This is AkGameObjectID, actually same with uint64_t }; } // namespace Hachiko
21.214286
82
0.686869
daa907c88bacfcd33dc19ed432351f11027e7fc3
2,187
h
C
winrt/lib/utils/TemporaryTransform.h
r2d2rigo/Win2D
3f06d4f19b7d16b67859a1b30ac770215ef3e52d
[ "MIT" ]
1,002
2015-01-09T19:40:01.000Z
2019-05-04T12:05:09.000Z
winrt/lib/utils/TemporaryTransform.h
r2d2rigo/Win2D
3f06d4f19b7d16b67859a1b30ac770215ef3e52d
[ "MIT" ]
667
2015-01-02T19:04:11.000Z
2019-05-03T14:43:51.000Z
winrt/lib/utils/TemporaryTransform.h
SunburstApps/Win2D.WinUI
75a33f8f4c0c785c2d1b478589fd4d3a9c5b53df
[ "MIT" ]
258
2015-01-06T07:44:49.000Z
2019-05-01T15:50:59.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the MIT License. See LICENSE.txt in the project root for license information. #pragma once namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { // Helper object whose job is to apply a temporary transform to a D2D // device context or brush, then undo it at the end of a drawing operation. template<typename T> class TemporaryTransform { // Make ourselves non-copyable. TemporaryTransform(TemporaryTransform const&) = delete; TemporaryTransform& operator=(TemporaryTransform const&) = delete; // Not a ComPtr because we should only exist on the stack within a single // CanvasDrawingSession method, so there's no need to be messing with AddRef. T* m_target; D2D1::Matrix3x2F m_previousTransform; public: TemporaryTransform(T* target, Vector2 const& offset, bool postMultiply = false) : m_target(target) { if (m_target) { Apply(D2D1::Matrix3x2F::Translation(offset.X, offset.Y), postMultiply); } } TemporaryTransform(T* target, Vector2 const& offset, Vector2 const& scale, bool postMultiply = false) : m_target(target) { if (m_target) { auto translationMatrix = D2D1::Matrix3x2F::Translation(offset.X, offset.Y); auto scaleMatrix = D2D1::Matrix3x2F::Scale(scale.X, scale.Y); Apply(scaleMatrix * translationMatrix, postMultiply); } } ~TemporaryTransform() { if (m_target) { m_target->SetTransform(&m_previousTransform); } } private: void Apply(D2D1::Matrix3x2F const& transform, bool postMultiply) { assert(m_target); m_target->GetTransform(&m_previousTransform); m_target->SetTransform(postMultiply ? m_previousTransform * transform : transform * m_previousTransform); } }; }}}}
33.646154
109
0.597165
d3843194aa33634df3db9f80dd12c263ca07a29b
547
h
C
include/PlayerUtil.h
morpheus666/DynamicEquipmentManagerSSE
6c76e677e38f0132e6ad75b2234e21b47bb2dae9
[ "MIT" ]
10
2019-02-24T08:35:27.000Z
2021-12-10T04:02:49.000Z
include/PlayerUtil.h
morpheus666/DynamicEquipmentManagerSSE
6c76e677e38f0132e6ad75b2234e21b47bb2dae9
[ "MIT" ]
4
2018-12-19T10:55:07.000Z
2019-01-02T14:13:49.000Z
include/PlayerUtil.h
morpheus666/DynamicEquipmentManagerSSE
6c76e677e38f0132e6ad75b2234e21b47bb2dae9
[ "MIT" ]
6
2019-07-27T04:14:50.000Z
2020-07-29T04:57:54.000Z
#pragma once #include "skse64/PluginAPI.h" // SKSETaskInterface #include "RE/Skyrim.h" namespace { using FormID = UInt32; using Count = SInt32; } class InventoryChangesVisitor { public: InventoryChangesVisitor() = default; virtual ~InventoryChangesVisitor() = default; virtual bool Accept(RE::InventoryEntryData* a_entry, SInt32 a_count) = 0; }; void VisitPlayerInventoryChanges(InventoryChangesVisitor* a_visitor); bool SinkAnimationGraphEventHandler(RE::BSTEventSink<RE::BSAnimationGraphEvent>* a_sink); bool PlayerIsBeastRace();
19.535714
89
0.78245
d31ad905298c0a023b2595227b780c6a94cb60e1
4,993
h
C
src/ripple/consensus/ConsensusTypes.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
5
2019-01-23T04:36:03.000Z
2020-02-04T07:10:39.000Z
src/ripple/consensus/ConsensusTypes.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
null
null
null
src/ripple/consensus/ConsensusTypes.h
yinchengtsinghua/RippleCPPChinese
a32a38a374547bdc5eb0fddcd657f45048aaad6a
[ "BSL-1.0" ]
2
2019-05-14T07:26:59.000Z
2020-06-15T07:25:01.000Z
//此源码被清华学神尹成大魔王专业翻译分析并修改 //尹成QQ77025077 //尹成微信18510341407 //尹成所在QQ群721929980 //尹成邮箱 yinc13@mails.tsinghua.edu.cn //尹成毕业于清华大学,微软区块链领域全球最有价值专家 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 //———————————————————————————————————————————————————————————————————————————————————————————————————————————————— /* 此文件是Rippled的一部分:https://github.com/ripple/rippled 版权所有(c)2012-2017 Ripple Labs Inc. 使用、复制、修改和/或分发本软件的权限 特此授予免费或不收费的目的,前提是 版权声明和本许可声明出现在所有副本中。 本软件按“原样”提供,作者不作任何保证。 关于本软件,包括 适销性和适用性。在任何情况下,作者都不对 任何特殊、直接、间接或后果性损害或任何损害 因使用、数据或利润损失而导致的任何情况,无论是在 合同行为、疏忽或其他侵权行为 或与本软件的使用或性能有关。 **/ //============================================================== #ifndef RIPPLE_CONSENSUS_CONSENSUS_TYPES_H_INCLUDED #define RIPPLE_CONSENSUS_CONSENSUS_TYPES_H_INCLUDED #include <ripple/basics/chrono.h> #include <ripple/consensus/ConsensusProposal.h> #include <ripple/consensus/DisputedTx.h> #include <chrono> #include <map> namespace ripple { /*表示节点当前如何参与协商一致。 一个节点以不同的模式参与共识,这取决于 节点由其操作员配置,并保持同步的程度 与网络协商一致。 @代码 提议观察 \/ \->错误分类帐<---/ ^ γ γ V 转帐分类帐 @端码 我们进入建议或观察回合。如果我们发现我们在工作 在错误的上一个分类帐上,我们转到错误的分类帐并尝试获取 正确的。一旦我们得到了正确的一个,我们就去交换账本。 模式。我们有可能再次落后,发现有一个新的更好的 分类帐,在错误分类帐和切换分类帐之间来回移动 我们试图赶上。 **/ enum class ConsensusMode { //!我们是共识的正常参与者,并提出我们的立场 proposing, //!我们在观察同行的立场,但没有提出我们的立场 observing, //!我们有错误的分类帐,正在试图取得它 wrongLedger, //!自从我们开始这轮共识谈判以来,我们就换了分类账,但现在 //!我们相信的是正确的分类账。此模式为 //!如果我们进入观察圈,但被用来表明 //!在某个时候把错误的分类帐记下来。 switchedLedger }; inline std::string to_string(ConsensusMode m) { switch (m) { case ConsensusMode::proposing: return "proposing"; case ConsensusMode::observing: return "observing"; case ConsensusMode::wrongLedger: return "wrongLedger"; case ConsensusMode::switchedLedger: return "switchedLedger"; default: return "unknown"; } } /*单一分类账轮的共识阶段。 @代码 关闭“接受” 打开----->建立----->接受 _ --------------- ^“开始回合” --------------------------------------------------------- @端码 典型的转变是从开放到建立到接受和 然后调用startround重新开始该过程。但是,如果之前的错误 在建立或接受阶段检测并恢复分类帐, 共识将在内部重新打开(见共识::handlewrongledger)。 **/ enum class ConsensusPhase { //!我们还没有关闭分类帐,但其他人可能已经 open, //!通过与同行交换建议来达成共识 establish, //!我们接受了一个新的最后一次结帐,正在等电话 //!开始下一轮协商一致。没有变化 //!在这个阶段,达成共识的阶段就发生了。 accepted, }; inline std::string to_string(ConsensusPhase p) { switch (p) { case ConsensusPhase::open: return "open"; case ConsensusPhase::establish: return "establish"; case ConsensusPhase::accepted: return "accepted"; default: return "unknown"; } } /*衡量共识阶段的持续时间 **/ class ConsensusTimer { using time_point = std::chrono::steady_clock::time_point; time_point start_; std::chrono::milliseconds dur_; public: std::chrono::milliseconds read() const { return dur_; } void tick(std::chrono::milliseconds fixed) { dur_ += fixed; } void reset(time_point tp) { start_ = tp; dur_ = std::chrono::milliseconds{0}; } void tick(time_point tp) { using namespace std::chrono; dur_ = duration_cast<milliseconds>(tp - start_); } }; /*存储初始关闭时间集 每一位同行的初步一致意见建议都有该同行的观点 当分类帐关闭时。此对象存储所有关闭时间 分析同龄人之间的时钟漂移。 **/ struct ConsensusCloseTimes { explicit ConsensusCloseTimes() = default; //!闭合时间估计,保持可预测导线的顺序 std::map<NetClock::time_point, int> peers; //!我们的接近时间估计 NetClock::time_point self; }; /*我们是否有共识*/ enum class ConsensusState { No, //!<我们没有共识 MovedOn, //!网络没有我们就有共识 Yes //!<我们与网络达成共识 }; /*概括了共识的结果。 将所有相关数据存储在一个 分类帐。 @tparam traits traits class定义使用的具体共识类型 通过应用程序。 **/ template <class Traits> struct ConsensusResult { using Ledger_t = typename Traits::Ledger_t; using TxSet_t = typename Traits::TxSet_t; using NodeID_t = typename Traits::NodeID_t; using Tx_t = typename TxSet_t::Tx; using Proposal_t = ConsensusProposal< NodeID_t, typename Ledger_t::ID, typename TxSet_t::ID>; using Dispute_t = DisputedTx<Tx_t, NodeID_t>; ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)} { assert(txns.id() == position.position()); } //!一致同意的一组交易记入分类账。 TxSet_t txns; //!我们对交易/结算时间的建议头寸 Proposal_t position; //!与同行有争议的交易 hash_map<typename Tx_t::ID, Dispute_t> disputes; //我们已经比较/创建的TxSet ID集 hash_set<typename TxSet_t::ID> compares; //衡量这一共识回合建立阶段的持续时间 ConsensusTimer roundTime; //表示共识结束的状态。一旦进入接受阶段 //将是Yes或Movedon ConsensusState state = ConsensusState::No; //本轮提议的同行人数 std::size_t proposers = 0; }; } //命名空间波纹 #endif
19.277992
114
0.604446
1c33ba8cc7c383b35864b83cd4769f1e357a912a
77
h
C
cdhere/include/windowlist.h
eteeselink/cdhere
bf35e8da3d8a9e1968688277a78af7e49c4558a9
[ "Zlib" ]
3
2017-01-06T21:28:13.000Z
2020-11-18T13:43:53.000Z
cdhere/include/windowlist.h
eteeselink/cdhere
bf35e8da3d8a9e1968688277a78af7e49c4558a9
[ "Zlib" ]
null
null
null
cdhere/include/windowlist.h
eteeselink/cdhere
bf35e8da3d8a9e1968688277a78af7e49c4558a9
[ "Zlib" ]
null
null
null
#include "stdafx.h" #include <vector> std::vector<HWND> getOrderedWindows();
19.25
38
0.74026
20094b8400f7226d4c1d138e8e14755af3e6e471
882
h
C
System/Library/PrivateFrameworks/CoreSuggestionsInternals.framework/SGEventForGeocode.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
2
2021-11-02T09:23:27.000Z
2022-03-28T08:21:57.000Z
System/Library/PrivateFrameworks/CoreSuggestionsInternals.framework/SGEventForGeocode.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/CoreSuggestionsInternals.framework/SGEventForGeocode.h
lechium/iOS1351Headers
6bed3dada5ffc20366b27f7f2300a24a48a6284e
[ "MIT" ]
1
2022-03-28T08:21:59.000Z
2022-03-28T08:21:59.000Z
/* * This header is generated by classdump-dyld 1.5 * on Wednesday, October 27, 2021 at 3:16:38 PM Mountain Standard Time * Operating System: Version 13.5.1 (Build 17F80) * Image Source: /System/Library/PrivateFrameworks/CoreSuggestionsInternals.framework/CoreSuggestionsInternals * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @protocol SGEventForGeocode <NSObject> @required -(unsigned long long)geocodingMode; -(id)poiFilters; -(id)geocodeStartDate; -(id)geocodeStartTimeZone; -(id)geocodeEndDate; -(id)geocodeEndTimeZone; -(id)geocodeLocations; -(id)geocodedEventWithStartDate:(id)arg1 startTimeZone:(id)arg2 endDate:(id)arg3 endTimeZone:(id)arg4 locations:(id)arg5; @end
38.347826
132
0.665533
c1c4cabbd906d4d8d71bdcc9336f40304d11eae9
679
h
C
physics/hadron/cross_sections/inc/Geant/GlauberGribovElasticXsc.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
2
2016-10-16T14:37:42.000Z
2018-04-05T15:49:09.000Z
physics/hadron/cross_sections/inc/Geant/GlauberGribovElasticXsc.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
physics/hadron/cross_sections/inc/Geant/GlauberGribovElasticXsc.h
Geant-RnD/geant
ffff95e23547531f3254ada2857c062a31f33e8f
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
#ifndef GlauberGribovElasticXsc_H #define GlauberGribovElasticXsc_H #include "Geant/HadronicCrossSection.h" #include "Geant/GlauberGribovTotalXsc.h" #include "Geant/GlauberGribovInelasticXsc.h" namespace geantphysics { class GlauberGribovElasticXsc : public HadronicCrossSection { public: GlauberGribovElasticXsc(); virtual ~GlauberGribovElasticXsc(); double GetIsotopeCrossSection(const int particleCode, const double energyKin, const double mass, const int Z, const int N); private: GlauberGribovTotalXsc *GGTotalXsc; GlauberGribovInelasticXsc *GGInelasticXsc; }; } // namespace geantphysics #endif // GlauberGribovElasticXsc_H
26.115385
111
0.78056
f6fe5ff0acf214bc1d975d0d4c76611c4c361961
62,047
h
C
3rdparty/Precision/iprecision.h
imallett/minitrig
6d7269f41850326827b6a6832aee23b49ff39606
[ "MIT" ]
null
null
null
3rdparty/Precision/iprecision.h
imallett/minitrig
6d7269f41850326827b6a6832aee23b49ff39606
[ "MIT" ]
null
null
null
3rdparty/Precision/iprecision.h
imallett/minitrig
6d7269f41850326827b6a6832aee23b49ff39606
[ "MIT" ]
null
null
null
#ifndef INC_PRECISION #define INC_PRECISION /* ******************************************************************************* * * * Copyright (c) 2002-2017 * Future Team Aps * Denmark * * All Rights Reserved * * This source file is subject to the terms and conditions of the * Future Team Software License Agreement which restricts the manner * in which it may be used. * Mail: hve@hvks.com * ******************************************************************************* */ /* ******************************************************************************* * * * Module name : iprecision.h * Module ID Nbr : * Description : Arbitrary integer precision class * -------------------------------------------------------------------------- * Change Record : * * Version Author/Date Description of changes * ------- ----------- ---------------------- * 01.01 HVE/020209 Initial release * 01.01 HVE/030421 Use FFT for Fast multiplications. Clean up the code * Now it can be included in different compilation units * Without causing linker errors * 01.02 HVE/030514 % operator was speed optimized to the same speed as the * the / operator. Furthere more now both /, % operator * advantages of short_division or short_remainding * speeding up the / and % operator * 01.03 HVE/030602 A bug for RADIX==BASE_256 in the udiv() and urem() * function. Quotient was initialized wrongly to "1" instead * of ICHARACTER(1) * 01.04 HVE/030722 A bug in ++ and -- operator did not increment/decrement * the variable * 01.05 HVE/050114 Subtraction of two eaul size number result in -0. this * has been corrected to +0. * BASE [2..9] is now also supported. All Base number <= 10 * will be stored as character numbers. * Binary string can be read by using the notation "0bxxxx" * where x is either 0 or 1 * 01.06 HVE/011905 Doxygen comments added * 01.07 HVE/050311 Replacing #define with inline functions * * 01.08 HVE/050314 Postfix ++ and -- implemented * 01.09 HVE/060203 Added const declaration for constant function parameters * 01.10 HVE/060217 Added implict conversion between int_precision and standard * C types double, float, long, int, short and char and the * corresponding unsigned versions * 01.11 HVE/060221 Adding templates for mixed mode arithmetic * 01.12 HVE/060307 itostring firs paramater change from unsigned to int to correspond * to MicroSoft _itoa(). * 01.13 HVE/20100527 Port to Visual Express studio 10 * 01.14 HVE/20100609 (unsigned long) operator now used strtoul() instead of wrongly atoi() * 01.15 HVE/20100701 Shifting a zero BASE 2 representation left was done wrongly. * 01.16 HVE/20100701 Initializing a precision string to internal BASE 2 resulted in a * Exception when digit was higher than BASE_2 * 01.17 HVE/20100702 Added short cuts for shifting left and right with zero or do left/rigth zero shifts * 01.18 HVE/20100703 Fix a bug when an addition resultet in zero and RADIX > 10 * 01.19 HVE/20100703 Fix a bug in >>= & <<= shifting with RADIX > 10 * 01.20 HVE/20120815 Improve / and % operator for very large numbers * 01.21 HVE/SEP 02-2012 Used floating point arithmetic for large integers for / and % operator to significantly speed up operations * 01.22 HVE/JUN-12-2012 Use umul_short() for single digit multiplication instead of umult_fourier() in *= operator * 01.23 HVE/MAR-07-2014 Moved <limits.h> from fprecision to iprecision.h to ensure it is included even when only working with arbitrary integer * precision and consequencly only use iprecision.h * 01.24 HVE/MAY-03-2014 Made the header Visual studio C++ 2013 compatible (avoiding error C2535) * 01.25 HVE/JUN-22-2014 Remove the requirements for microsoft stdafx.h precompiled header * 01.26 HVE/JUN-28-2014 Added abs(int_precision() * 01.27 HVE/NOV-20-2014 improve the % and / operator when rhs is only a single digit * 01.28 HVE/AUG-19-2016 Added initialization of iprecision through a std::string * 01.29 HVE/NOV-07-2016 Added support for 64bit signerd/unsigned initialization of a int_precision number * * End of Change Record * -------------------------------------------------------------------------- */ /* define version string */ static char _VI_[] = "@(#)iprecision.h 01.29 -- Copyright (C) Future Team Aps"; // If _INT_PRECESION_FAST_DIV_REM is defined it will use a magnitude faster div and rem integer operation. #define _INT_PRECISSION_FAST_DIV_REM #include <limits.h> #include <string> #include <complex> // Need <complex> to support FFT functions for fast multiplications // For ANSI please remove comments from the next 3 line #include <iostream> #include <ostream> #include <istream> #include <cstdlib> using std::atoi; using std::strtoul; // End ANSI addition #include <stdlib.h> #include <string.h> // RADIX can either be 2, 8, 10, 16 or 256! static const int BASE_2 = 2; static const int BASE_8 = 8; static const int BASE_10 = 10; static const int BASE_16 = 16; static const int BASE_256 = 256; /// /// @class precision_ctrl /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/15/2006 /// @version 1.0 /// @brief Arbitrary precision control class /// /// @todo /// ///// Precision control class /// This keep track of the internal Base for storing int_precision and Float_precision numbers. /// Default int_precision radix is BASE_10 /// Default float_precision radix is BASE_10 // class precision_ctrl { int mIRadix; // Internal base of int_precision int mFRadix; // Internal base of float_precision public: // Constructor precision_ctrl( unsigned int ir=BASE_10, unsigned int fr=BASE_10): mIRadix(ir), mFRadix(fr) {} // Coordinate functions inline int I_RADIX() const { return mIRadix; } inline int I_RADIX( unsigned int ir ) { return( mIRadix = ir ); } inline int F_RADIX() const { return mFRadix; } inline int F_RADIX( unsigned int fr ) { return( mFRadix = fr ); } }; extern precision_ctrl precision_ctrl; static const int RADIX = BASE_10; // Set internal base for the arbitrary precision inline std::string SIGN_STRING( int x ) { return x >=0 ? "+" : "-" ; } inline int CHAR_SIGN( char x ) { return x == '-' ? -1 : 1; } inline unsigned char IDIGIT( char x ) { return RADIX <= 10 ? (unsigned char)( x - '0') : (unsigned char)x; } inline unsigned char IDIGIT10( char x ) { return (unsigned char)( x - '0'); } inline unsigned char ICHARACTER( char x ) { return RADIX <= 10 ? (unsigned char)( x + '0') : (unsigned char)x; } inline unsigned char ICHARACTER10( char x){ return (unsigned char)( x + '0'); } inline int ICARRY( unsigned int x ) { return x / RADIX; } inline int ISINGLE( unsigned int x ) { return x % RADIX; } class int_precision; // Arithmetic template <class _Ty> inline int_precision operator+( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator+( const _Ty&, const int_precision& ); inline int_precision operator+( const int_precision& ); // Unary inline int_precision operator++( int_precision& ); // Postfix Increment inline int_precision operator++( int_precision&, int ); // Postfix Increment template <class _Ty> inline int_precision operator-( int_precision&, const _Ty&); template <class _Ty> inline int_precision operator-( const _Ty&, const int_precision& ); inline int_precision operator-( const int_precision& ); // Unary inline int_precision operator--( int_precision& ); // Postfix Decrement inline int_precision operator--( int_precision&, int ); // Postfix Decrement template <class _Ty> inline int_precision operator*( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator*( const _Ty&, const int_precision& ); template <class _Ty> inline int_precision operator/( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator/( const _Ty&, const int_precision& ); template <class _Ty> inline int_precision operator%( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator%( const _Ty&, const int_precision& ); template <class _Ty> inline int_precision operator<<( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator<<( const _Ty&, const int_precision& ); template <class _Ty> inline int_precision operator>>( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator>>( const _Ty&, const int_precision& ); template <class _Ty> inline int_precision operator&( int_precision&, const _Ty& ); template <class _Ty> inline int_precision operator&( const _Ty&, const int_precision& ); // Boolean Comparision Operators template <class _Ty> inline bool operator==( int_precision&, const _Ty& ); template <class _Ty> inline bool operator==( const _Ty&, const int_precision& ); template <class _Ty> inline bool operator!=( int_precision&, const _Ty& ); template <class _Ty> inline bool operator!=( const _Ty&, const int_precision& ); template <class _Ty> inline bool operator>( int_precision&, const _Ty& ); template <class _Ty> inline bool operator>( const _Ty&, const int_precision& ); template <class _Ty> inline bool operator>=( int_precision&, const _Ty& ); template <class _Ty> inline bool operator>=( const _Ty&, const int_precision& ); template <class _Ty> inline bool operator<=( int_precision&, const _Ty& ); template <class _Ty> inline bool operator<=( const _Ty&, const int_precision& ); template <class _Ty> inline bool operator<( int_precision&, const _Ty& ); template <class _Ty> inline bool operator<( const _Ty&, const int_precision& ); // Integer Precision functions extern int_precision abs(const int_precision&); extern int_precision ipow( const int_precision&, const int_precision& ); // a^b extern int_precision ipow_modular( const int_precision&, const int_precision&, const int_precision& ); // a^b%c extern bool iprime( const int_precision& ); // Core functions that works directly on String class and unsigned arithmetic void _int_real_fourier( double [], unsigned int, int ); std::string _int_precision_uadd( std::string *, std::string *); std::string _int_precision_uadd_short( std::string *, unsigned int ); std::string _int_precision_usub( int *, std::string *, std::string *); std::string _int_precision_usub_short( int *, std::string *, unsigned int ); std::string _int_precision_umul( std::string *, std::string *); std::string _int_precision_umul_short( std::string *, unsigned int ); std::string _int_precision_umul_fourier( std::string *, std::string *); std::string _int_precision_udiv( std::string *, std::string *); std::string _int_precision_udiv_short( unsigned int *, std::string *, unsigned int ); std::string _int_precision_urem( std::string *, std::string *); std::string _int_precision_uneg( std::string *); std::string _int_precision_uand( std::string *, std::string *); int _int_precision_compare( std::string *, std::string * ); void _int_precision_strip_leading_zeros( std::string * ); std::string _int_precision_itoa( const std::string * ); std::string _int_precision_itoa( int_precision * ); std::string _int_precision_atoi( const char *str ); std::string itostring( int, const unsigned ); std::string ito_precision_string( unsigned long, const bool, const int base = RADIX ); std::string i64to_precision_string( uint64_t, const bool, const int base = RADIX); /// /// @class int_precision /// @author Henrik Vestermark (hve@hvks.com) /// @date 9/7/2004 /// @version 1.0 /// @brief This is an arbitrary integer class /// /// @todo /// /// Precision class /// An Arbitrary integer always has the format [sign][digit]+ where sign is either '+' or '-' /// the length or the representation is always >= 2 /// A null string is considered as an error and an exception is thrown /// Also number is always strip for leading zeros /// Since we always initiate to a valid int_precision number, it will never be a empty string /// class int_precision { std::string mNumber; public: // Constructor int_precision() { mNumber = ICHARACTER(0); } int_precision( char ); // When initialized through a char int_precision( unsigned char ); // When initialized through a unsigned char int_precision( short ); // When initialized through an short int_precision( unsigned short ); // When initialized through an unsigned short int_precision( int ); // When initialized through an int int_precision( unsigned int ); // When initialized through an unsigned int int_precision( long ); // When initialized through an long int_precision( unsigned long ); // When initialized through an unsigned long int_precision( const char * ); // When initialized through a char string int_precision( const std::string& ); // When initialized through a std::string int_precision( const int64_t ); // When initialized through a 64 bit int int_precision( const uint64_t ); // When initialized through a 64 bit unsinged int int_precision( const int_precision& s) : mNumber(s.mNumber) {} // When initialized through another int_precision // Coordinate functions std::string copy() const { return mNumber; } std::string *pointer() { return &mNumber; } int sign() const { return CHAR_SIGN( mNumber[0] ); } int change_sign() { // Change and return sign if( mNumber.length() != 2 || IDIGIT( mNumber[1] ) != 0 ) // Don't change sign for +0! if( mNumber[0] == '+' ) mNumber[0] = '-'; else mNumber[0] = '+'; return CHAR_SIGN( mNumber[0] ); } int size() const { return mNumber.length(); } // Return number of digits including the sign // Conversion methods. Safer and less ambiguios than overloading implicit/explivit conversion operators std::string toString() { return _int_precision_itoa(this); } // Implict/explicit conversion operators operator long() const; operator int() const; operator short() const; operator char() const; operator unsigned long() const; operator unsigned int() const; operator unsigned short() const; operator unsigned char() const; operator double() const; operator float() const; // Essential operators int_precision& operator=( const int_precision& ); int_precision& operator+=( const int_precision& ); int_precision& operator-=( const int_precision& ); int_precision& operator*=( const int_precision& ); int_precision& operator/=( const int_precision& ); int_precision& operator%=( const int_precision& ); int_precision& operator>>=( const int_precision& ); int_precision& operator<<=( const int_precision& ); // int_precision& operator&=( const int_precision& ); // int_precision& operator|=( const int_precision& ); // int_precision& operator^=( const int_precision& ); // // Specialization friend std::ostream& operator<<( std::ostream& strm, const int_precision& d ); friend std::istream& operator>>( std::istream& strm, int_precision& d ); // Exception class class bad_int_syntax {}; class out_of_range {}; class divide_by_zero {}; }; ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // // Constructors // // ///////////////////////////////////////////////////////////////////////////////////////////////////////// /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief int_precision::int_precision /// @return nothing /// @param "str" - Convert the character string number into a multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate input and convert to internal representation /// Always add sign if not specified /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( const char *str ) { std::string s(str); if( s.empty() ) { throw bad_int_syntax(); return; } mNumber = _int_precision_atoi( str ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date Aug-19-2016 /// @brief int_precision::int_precision /// @return nothing /// @param "str" - Convert the std::string number into a multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate input and convert to internal representation /// Always add sign if not specified /// Only use core base functions to create multi precision numbers // // inline int_precision::int_precision(const std::string& str) { if (str.empty()) { throw bad_int_syntax(); return; } mNumber = _int_precision_atoi(str.c_str()); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief int_precision::int_precision /// @return nothing /// @param "c" - the character integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initilize with a character /// Input Always in BASE_10 /// Convert to the internal RADIX // inline int_precision::int_precision( char c ) { if( c < '0' || c > '9' ) throw bad_int_syntax(); else { mNumber = ito_precision_string( IDIGIT10( c ), true ); // Convert to integer } } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief int_precision::int_precision /// @return nothing /// @param "c" - the character integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initilize with a character /// Input Always in BASE_10 /// Convert to the internal RADIX // inline int_precision::int_precision( unsigned char c ) { if( c < '0' || c > '9' ) throw bad_int_syntax(); else { mNumber = ito_precision_string( IDIGIT10( c ), true ); // Convert to integer } } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( short i ) { mNumber = ito_precision_string( i, true ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( unsigned short i ) { mNumber = ito_precision_string( i, false ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( int i ) { mNumber = ito_precision_string( i, true ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary unsigned integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( unsigned int i ) { mNumber = ito_precision_string( i, false ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary integer to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( long i ) { mNumber = ito_precision_string( i, true ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary unsigned long to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( unsigned long i ) { mNumber = ito_precision_string( i, false ); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 11/7/2016 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary int64_t to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( int64_t i) { mNumber = i64to_precision_string( (uint64_t)i, true); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 11/7/2016 /// @brief int_precision::int_precision /// @return nothing /// @param "i" - the binary uint64_t to convert to multi precision number /// /// @todo /// /// Description: /// Constructor /// Validate and initialize with an integer /// Just convert integer to string representation in BASE RADIX /// The input integer is always BASE_10 /// Only use core base functions to create multi precision numbers // inline int_precision::int_precision( uint64_t i) { mNumber = i64to_precision_string( i, false); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // // Implict conversions to base types int, short, long, char // // ///////////////////////////////////////////////////////////////////////////////////////////////////////// /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator long /// @return inline - /// /// @todo /// /// Description: /// This is the main operator from int_precision to regular long, int, short & char /// Any explicit or implicit copnversion first convert to standard c long type and then to any other /// inbuild type int, short, char. As a type long >= int >= short >= char /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator long() const {// Conversion to long long l; if( RADIX == BASE_10 ) l = atoi( mNumber.c_str() ); // Do it directly else l = atoi( _int_precision_itoa( &mNumber ).c_str() ); // Need to convert from RADIX to BASE_10 ) return l; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator int /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to int /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator int() const {// Conversion to int return (int)(long)*this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator short /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to short /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator short() const {// Conversion to short return (short)((long)*this); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator char /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to char /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator char() const {// Conversion to char return (char)((long)*this); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator unsigned long /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to int /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator unsigned long() const {// Conversion to unsigned long unsigned long ul; if( RADIX == BASE_10 ) ul = strtoul( mNumber.c_str(), NULL, BASE_10 ); // Do it directly else ul = strtoul( _int_precision_itoa( &mNumber ).c_str(), NULL, BASE_10 ); // Need to convert from RADIX to BASE_10 ) return ul; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator unsigned int /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to int /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator unsigned int() const {// Conversion to int return (unsigned int)(unsigned long)*this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator unsigned short /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to short /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator unsigned short() const {// Conversion to short return (unsigned short)((unsigned long)*this); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator unsigned char /// @return inline - /// /// @todo Add to do things /// /// Description: /// Any explicit or implicit copnversion first convert to standard c long type and then to char /// As with regular C type conversion the conversion truncate to desired type and a possible /// loss in precision is possible /// inline int_precision::operator unsigned char() const {// Conversion to char return (unsigned char)((unsigned long)*this); } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_preceision::operator double /// @return inline - /// /// @todo /// /// Description: /// Conversion from int_precision to double /// inline int_precision::operator double() const {// Conversion to double if( RADIX == BASE_10 ) return (double)atof( mNumber.c_str() ); // Do it directly else return (double)atof( _int_precision_itoa( &mNumber ).c_str() ); // Need to convert from RADIX to BASE_10 } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/17/2006 /// @brief int_precision::operator float /// @return inline - /// /// @todo Add to do things /// /// Description: /// Conversion from int_precision to float /// Using the double conversion frist and then trunk to float using standard c conversion /// inline int_precision::operator float() const {// Conversion to float return (float)((double)*this); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // // Essentialsoperators =, +=, -=, *=, /=, %=, <<=, >>=, &=, |=, ^= // // ///////////////////////////////////////////////////////////////////////////////////////////////////////// /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator= /// @return static int_precision - return a=b /// @param "a" - Assignment operand /// /// @todo /// /// Description: /// Assign operator // inline int_precision& int_precision::operator=( const int_precision& a ) { mNumber = a.mNumber; return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator+= /// @return static int_precision - return a +=b /// @param "a" - Adding operand /// /// @todo /// /// Description: /// += operator // inline int_precision& int_precision::operator+=( const int_precision& a ) { int sign1, sign2, wrap; std::string s1, s2; int cmp; // extract sign and unsigned portion of number sign1 = a.sign(); s1 = a.mNumber.substr( 1 ); sign2 = CHAR_SIGN( mNumber[0] ); s2 = mNumber.substr( 1 ); if( sign1 == sign2 ) mNumber = SIGN_STRING( sign1 ) + _int_precision_uadd( &s1, &s2 ); else { cmp = _int_precision_compare( &s1, &s2 ); if( cmp > 0 ) // Since we subctract less the wrap indicater need not to be checked mNumber = SIGN_STRING(sign1) + _int_precision_usub( &wrap, &s1, &s2 ); else if( cmp < 0 ) mNumber = SIGN_STRING(sign2) + _int_precision_usub( &wrap, &s2, &s1 ); else {// result is 0 mNumber = std::string( "+" ); mNumber.append( 1, ICHARACTER(0) ); } } return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator-= /// @return static int_precision - return a -=b /// @param "a" - Subtracting operand /// /// @todo /// /// Description: /// -= operator /// The essential -= operator /// n = n - a is the same as n = n + (-a); // inline int_precision& int_precision::operator-=( const int_precision& a ) { int_precision b; b = a; b.change_sign(); *this += b; return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator*= /// @return static int_precision - return a *=b /// @param "a" - Multiplying operand /// /// @todo /// /// Description: /// *= operator // inline int_precision& int_precision::operator*=( const int_precision& a ) { int sign1, sign2; std::string s, s1, s2; // extract sign and unsigned portion of number sign1 = a.sign(); s1 = a.mNumber.substr( 1 ); sign2 = CHAR_SIGN( mNumber[0] ); s2 = mNumber.substr( 1 ); sign1 *= sign2; // Check for multiplication of 1 digit and use umul_short(). if(s1.length()==1 ) s=_int_precision_umul_short( &s2, IDIGIT(s1[0])); else if( s2.length()==1) s=_int_precision_umul_short( &s1, IDIGIT(s2[0])); else s=_int_precision_umul_fourier( &s1, &s2 ); mNumber = SIGN_STRING( sign1 ) + s; if( sign1 == -1 && mNumber.length() == 2 && IDIGIT( mNumber[1] ) == 0 ) // Avoid -0 as result +0 is right mNumber[0] = '-'; // Change sign return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator/= /// @return static int_precision - return a /=b /// @param "a" - Dividing operand /// /// @todo /// /// Description: /// /= operator // inline int_precision& int_precision::operator/=( const int_precision& a ) { int sign1, sign2; std::string s1, s2; #ifdef _INT_PRECISSION_FAST_DIV_REM if (this->size()>a.size() + 8 && a.size() != 2) // Check that lhs is 8 digit larger and that rhs is not a single digit before do the fastremdiv operation { extern int_precision _int_precision_fastdiv( const int_precision&, const int_precision& ); int_precision b=*this; *this = _int_precision_fastdiv( b, a ); return *this; } #endif // extract sign and unsigned portion of number sign1 = CHAR_SIGN(mNumber[0] ); s1 = mNumber.substr( 1 ); sign2 = a.sign(); s2 = a.mNumber.substr( 1 ); sign1 *= sign2; mNumber = SIGN_STRING( sign1 ) + _int_precision_udiv( &s1, &s2 ); if( sign1 == -1 && mNumber.length() == 2 && IDIGIT( mNumber[1] ) == 0 ) // Avoid -0 as result +0 is right mNumber[0] = '+'; return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator%= /// @return static int_precision - return a %=b /// @param "a" - Modulus operand /// /// @todo /// /// Description: /// %= operator // inline int_precision& int_precision::operator%=( const int_precision& a ) { int sign1, sign2; std::string s1, s2; #ifdef _INT_PRECISSION_FAST_DIV_REM if(this->size()>a.size()+8 && a.size() != 2 ) // Check that lhs is 8 digit larger and that rhs is not a single digit before do the fastremdiv operation { extern int_precision _int_precision_fastrem( const int_precision&, const int_precision& ); int_precision b=*this; *this =_int_precision_fastrem( b, a ); return *this; } #endif // extract sign and unsigned portion of number sign1 = CHAR_SIGN(mNumber[0] ); s1 = mNumber.substr( 1 ); sign2 = a.sign(); s2 = a.mNumber.substr( 1 ); mNumber = SIGN_STRING( sign1 ) + _int_precision_urem( &s1, &s2 ); if( sign1 == -1 && mNumber.length() == 2 && IDIGIT( mNumber[1] ) == 0 ) // Avoid -0 as result +0 is right mNumber[0] = '+'; return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator<<= /// @return static int_precision - return shifting a<<= b /// @param "a" - Shifting number /// /// @todo /// /// Description: /// <<= operator // inline int_precision& int_precision::operator<<=( const int_precision& a ) { int sign1, sign2, wrap, max_shifts=0; std::string s1, s2; std::string cshifts, c0, c3, c4, c8; c0.insert( (std::string::size_type)0, 1, ICHARACTER( 0 ) ); // extract sign and unsigned portion of number sign1 = CHAR_SIGN(mNumber[0] ); s1 = mNumber.substr( 1 ); if( _int_precision_compare( &s1, &c0 ) == 0 ) // Short cut: zero shifting left is still zero. return *this; sign2 = a.sign(); s2 = a.mNumber.substr( 1 ); if( _int_precision_compare( &s2, &c0 ) == 0 ) // Short cut: shift zero left does not change the number. return *this; if( sign2 < 0 ) { throw out_of_range(); return *this; } // Speed up the operation by shifting the native if possible. Finx max shifting for( int i=RADIX; i>=2; max_shifts++, i>>=1 ) ; cshifts.insert( (std::string::size_type)0, 1, ICHARACTER( max_shifts ) ); if( RADIX > BASE_2 ) {// BASE max Shift bit a a time if possible for( ; _int_precision_compare( &s2, &cshifts ) >= 0; s2 = _int_precision_usub_short( &wrap, &s2, max_shifts ) ) s1 = _int_precision_umul_short( &s1, 1<<max_shifts); //1<<max_shifts==256 or 2^8 } else { // BASE 2 int shift; // Don't shift. just add zeros number of shift times! s2.insert( 0, "+" ); shift = atoi( _int_precision_itoa( &s2 ).c_str() ); // Need to convert from RADIX to BASE_10 ) s1.append( shift, ICHARACTER( 0 ) ); s2 = ICHARACTER(0); } // Take the remainds of shifts if( _int_precision_compare( &s2, &c0 ) > 0 ) { int shift; if( RADIX == BASE_10 ) shift = atoi( s2.c_str() ); // Do it directly else { s2.insert( 0, "+" ); shift = atoi( _int_precision_itoa( &s2 ).c_str() ); // Need to convert from RADIX to BASE_10 s2 = s2.substr( 1 ); } if( RADIX >= BASE_10 && RADIX > (2<<(shift-1)) ) s1 = _int_precision_umul_short( &s1, 2 << ( shift - 1 ) ); else { for( ; shift > 0; --shift ) s1 = _int_precision_umul_short( &s1, 2 ); } } mNumber = SIGN_STRING( sign1 ) + s1; return *this; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator>>= /// @return int_precision - return shifting a>>= b /// @param "a" - Shifting operand /// /// @todo /// /// Description: /// >>= operator // inline int_precision& int_precision::operator>>=( const int_precision& a ) { int sign1, sign2, wrap, max_shifts=0; unsigned int rem; std::string s1, s2; std::string cshifts, c0, c3, c4, c8; c0.insert((std::string::size_type)0, 1, ICHARACTER(0) ); // extract sign and unsigned portion of number sign1 = CHAR_SIGN(mNumber[0] ); s1 = mNumber.substr( 1 ); if( _int_precision_compare( &s1, &c0 ) == 0 ) // Short cut: zero shifting right is still zero. return *this; sign2 = a.sign(); s2 = a.mNumber.substr( 1 ); if( _int_precision_compare( &s2, &c0 ) == 0 ) // Short cut: shift zero right does not change the number. return *this; if( sign2 < 0 ) { throw out_of_range(); return *this; } for( int i=RADIX; i>=2; max_shifts++, i>>=1 ) ; cshifts.insert( (std::string::size_type)0, 1, ICHARACTER( max_shifts ) ); if( RADIX > BASE_2 ) // Speed up by alowing shift with 8 (2^8) at a time instead of single shift { for( ; _int_precision_compare( &s2, &cshifts ) >= 0; s2 = _int_precision_usub_short( &wrap, &s2, max_shifts ) ) s1 = _int_precision_udiv_short( &rem, &s1, 1 << max_shifts ); //1<<max_shifts } else { int shift; s2.insert( 0, "+" ); shift = atoi( _int_precision_itoa( &s2 ).c_str() ); // Need to convert from RADIX to BASE_10 ) if( (int)s1.size() <= shift ) s1 = ICHARACTER( 0 ); else s1 = s1.substr( 0, s1.size() - shift ); s2 = ICHARACTER(0); } // Take the remainds of shifts less after applying the speed up trick if( _int_precision_compare( &s2, &c0 ) > 0 ) { int shift; if( RADIX == BASE_10 ) shift = atoi( s2.c_str() ); // Do it directly else { s2.insert( 0, "+" ); shift = atoi( _int_precision_itoa( &s2 ).c_str() ); // Need to convert from RADIX to BASE_10 ) s2 = s2.substr( 1 ); } if( RADIX >= BASE_10 && RADIX > (2<<(shift-1)) ) s1 = _int_precision_udiv_short( &rem, &s1, 2 << ( shift - 1 ) ); else for( ; shift > 0; --shift ) s1 = _int_precision_udiv_short( &rem, &s1, 2 ); } mNumber = SIGN_STRING( sign1 ) + s1; if( sign1 == -1 && mNumber.length() == 2 && IDIGIT( mNumber[1] ) == 0 ) // Avoid -0 as result +0 is right mNumber[0] = '+'; return *this; } /* /// @author Henrik Vestermark (hve@hvks.com) /// @date 2-Sep/2012 /// @brief operator&= /// @return static int_precision - return a *=b /// @param "a" - Anding operand /// /// @todo /// /// Description: /// &= operator // inline int_precision& int_precision::operator&=( const int_precision& a ) { int sign1, sign2; std::string s1, s2; // extract sign and unsigned portion of number sign1 = CHAR_SIGN(mNumber[0] ); s1 = mNumber.substr( 1 ); sign2 = a.sign(); s2 = a.mNumber.substr( 1 ); if( sign1 == '-' && sign2 == '+' ) sign1 = '+'; // sign1 *= sign2; mNumber = SIGN_STRING( sign1 ) + _int_precision_uand( &s1, &s2 ); if( sign1 == -1 && mNumber.length() == 2 && IDIGIT( mNumber[1] ) == 0 ) // Avoid -0 as result +0 is right mNumber[0] = '+'; return *this; } */ ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // // Arithmetic // // ///////////////////////////////////////////////////////////////////////////////////////////////////////// /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @brief operator+ /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision + <any other type> /// no const on the lhs parameter to prevent ambigous overload /// template <class _Ty> inline int_precision operator+( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) += rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @version 1.0 /// @brief operator+ /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> + int_precision /// template <class _Ty> inline int_precision operator+( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) += rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator unary + /// @return int_precision - a /// @param "a" - operand /// /// @todo /// /// Description: /// Unary + operator /// Do nothing // inline int_precision operator+( const int_precision& a ) { return a; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator++ Prefix /// @return int_precision - return the incremented a /// @param "a" - operand /// /// @todo /// /// Description: /// Increment operator // inline int_precision operator++( int_precision& a ) { a += int_precision( 1 ); return a; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 3/14/2005 /// @brief operator++ Postfix /// @return int_precision - return the a before incrementation /// @param "a" - operand /// /// @todo /// /// Description: /// Postfix Increment operator // inline int_precision operator++( int_precision& a, int ) { int_precision postfix_a(a); a += int_precision( 1 ); return postfix_a; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @brief operator- /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision - <any other type> /// no const on the lhs parameter to prevent ambigous overload /// template <class _Ty> inline int_precision operator-( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) -= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @version 1.0 /// @brief operator- /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> - int_precision /// template <class _Ty> inline int_precision operator-( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) -= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator unary - /// @return int_precision - -a /// @param "a" - operand for sign change /// /// @todo /// /// Description: /// Unary - operator /// Change sign // inline int_precision operator-( const int_precision& a ) { int_precision b; b = a; b.change_sign(); return b; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator-- prefix /// @return int_precision - return the decremented a /// @param "a" - operand /// /// @todo /// /// Description: /// Decrement operator // inline int_precision operator--( int_precision& a ) { a -= int_precision( 1 ); return a; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 3/14/2005 /// @brief operator-- postfix /// @return int_precision - return the a before decrementation /// @param "a" - operand /// /// @todo /// /// Description: /// Postfix Decrement operator // int_precision operator--( int_precision& a, int ) { int_precision postfix_a(a); a -= int_precision( 1 ); return postfix_a; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @brief operator* /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision * <any other type> /// template <class _Ty> inline int_precision operator*( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) *= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @version 1.0 /// @brief operator* /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> * int_precision /// no const on the lhs parameter to prevent ambigous overload /// template <class _Ty> inline int_precision operator*( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) *= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @brief operator/ /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision / <any other type> /// no const on the lhs parameter to prevent ambigous overload /// template <class _Ty> inline int_precision operator/( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) /= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @version 1.0 /// @brief operator* /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> / int_precision /// template <class _Ty> inline int_precision operator/( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) /= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @brief operator% /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision % <any other type> /// template <class _Ty> inline int_precision operator%( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) %= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/19/2006 /// @version 1.0 /// @brief operator% /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> % int_precision /// template <class _Ty> inline int_precision operator%( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) %= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @brief operator<< /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision << <any other type> /// template <class _Ty> inline int_precision operator<<( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) <<= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @version 1.0 /// @brief operator<< /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> << int_precision /// template <class _Ty> inline int_precision operator<<( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) <<= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @brief operator>> /// @return int_precision - return addition of lhs + rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// Add operator for int_precision >> <any other type> /// template <class _Ty> inline int_precision operator>>( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) >>= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @version 1.0 /// @brief operator>> /// @return int_precision - return addition of lhs - rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> >> int_precision /// template <class _Ty> inline int_precision operator>>( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) >>= rhs; } /* /// @author Henrik Vestermark (hve@hvks.com) /// @date 2-Sep/2012 /// @brief operator& /// @return int_precision - return addition of lhs & rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// @todo Add to do things /// /// Description: /// And operator for int_precision & <any other type> /// no const on the lhs parameter to prevent ambigous overload /// template <class _Ty> inline int_precision operator&( int_precision& lhs, const _Ty& rhs ) { return int_precision(lhs) &= rhs; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2-Sep/2012 /// @version 1.0 /// @brief operator& /// @return int_precision - return addition of lhs & rhs /// @param "lhs" - First operand /// @param "rhs" - Second operand /// /// Description: /// Add operator for <any other type> & int_precision /// template <class _Ty> inline int_precision operator&( const _Ty& lhs, const int_precision& rhs ) { return int_precision(lhs) &= rhs; } */ ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // // Comparison // // ///////////////////////////////////////////////////////////////////////////////////////////////////////// /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @brief operator== /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean equal of two precision numbers. Early out algorithm /// 1) if sign different then result is false. We actual don't do this test because of -0==+0 we should not ocuured but just in case /// 2) if length is different then the result is false /// 3) use core compare to determine boolean value // template <class _Ty> inline bool operator==( int_precision& a, const _Ty& b ) {int_precision c(b); if( _int_precision_compare( const_cast<int_precision&>(a).pointer(), const_cast<int_precision&>(c).pointer() ) == 0 ) // Same return true return true; return false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 2/20/2006 /// @brief operator== /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean equal of two precision numbers. Early out algorithm /// 1) if sign different then result is false. We actual don't do this test because of -0==+0 we should not ocuured but just in case /// 2) if length is different then the result is false /// 3) use core compare to determine boolean value // template <class _Ty> inline bool operator==( const _Ty& a, const int_precision& b ) {int_precision c(a); // if( _int_precision_compare( const_cast<int_precision&>(int_precision(c)).pointer(), const_cast<int_precision&>(b).pointer() ) == 0 ) // Same return true if( _int_precision_compare( const_cast<int_precision&>(c).pointer(), const_cast<int_precision&>(b).pointer() ) == 0 ) return true; return false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator< /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean less of two precision numbers. Early out algorithm for higher performance /// 1) If sign different determine boolean result based on sign /// 2) Otherwise determine boolean result based length of number amnd the sign /// 3) Same sign and same length. Do a core comparison and return the result // template <class _Ty> inline bool operator<( int_precision& a, const _Ty& c ) { int sign1, sign2, cmp; int_precision b(c); sign1 = a.sign(); sign2 = b.sign(); // Different signs if( sign1 > sign2 ) return false; if( sign1 < sign2 ) return true; // Same sign if( sign1 == 1 && a.size() < b.size() ) // Different therefore true return true; if( sign1 == 1 && a.size() > b.size() ) // Different therefore false return false; if( sign1 == -1 && a.size() > b.size() ) return true; if( sign1 == -1 && a.size() < b.size() ) return false; // Same sign and same length cmp = _int_precision_compare( const_cast<int_precision&>(a).pointer(), const_cast<int_precision&>(b).pointer() ); if( cmp < 0 && sign1 == 1 ) return true; else if( cmp > 0 && sign1 == -1 ) return true; return false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator< /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean less of two precision numbers. Early out algorithm for higher performance /// 1) If sign different determine boolean result based on sign /// 2) Otherwise determine boolean result based length of number amnd the sign /// 3) Same sign and same length. Do a core comparison and return the result // template <class _Ty> inline bool operator<( const _Ty& c, const int_precision& b ) { int sign1, sign2, cmp; int_precision a(c); sign1 = a.sign(); sign2 = b.sign(); // Different signs if( sign1 > sign2 ) return false; if( sign1 < sign2 ) return true; // Same sign if( sign1 == 1 && a.size() < b.size() ) // Different therefore true return true; if( sign1 == 1 && a.size() > b.size() ) // Different therefore false return false; if( sign1 == -1 && a.size() > b.size() ) return true; if( sign1 == -1 && a.size() < b.size() ) return false; // Same sign and same length cmp = _int_precision_compare( const_cast<int_precision&>(a).pointer(), const_cast<int_precision&>(b).pointer() ); if( cmp < 0 && sign1 == 1 ) return true; else if( cmp > 0 && sign1 == -1 ) return true; return false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator!= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean not equal of two precision numbers // template <class _Ty> inline bool operator!=( int_precision& a, const _Ty& b ) { return a == b ? false : true; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator!= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean not equal of two precision numbers // template <class _Ty> inline bool operator!=( const _Ty& a, const int_precision& b ) { return a == b ? false : true; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator> /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean greater of two precision numbers // template <class _Ty> inline bool operator>( int_precision& a, const _Ty& b ) { return b < a ? true : false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator> /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean greater of two precision numbers // template <class _Ty> inline bool operator>( const _Ty& a, const int_precision& b ) { int_precision c(a); return b < c ? true : false; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator<= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean less or equal of two precision numbers // template <class _Ty> inline bool operator<=( int_precision& a, const _Ty& b ) { return b < a ? false : true; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator<= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean less or equal of two precision numbers // template <class _Ty> inline bool operator<=( const _Ty& a, const int_precision& b ) { int_precision c(a); return b < c ? false : true; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator>= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean greater or equal of two precision numbers // template <class _Ty> inline bool operator>=( int_precision& a, const _Ty& b ) { return a < b ? false: true; } /// @author Henrik Vestermark (hve@hvks.com) /// @date 1/19/2005 /// @brief operator>= /// @return bool - the boolean value of the operator /// @param "a" - First operand number to compare /// @param "b" - Second operand number to /// /// @todo /// /// Description: /// Boolean less or equal of two precision numbers // template <class _Ty> inline bool operator>=( const _Ty& a, const int_precision& b ) { return a < b ? false: true; } #endif
33.144765
160
0.609812
7cfee3212bca52a103ee130b632cfd288a030f23
2,850
h
C
include_lib/system/generic/log.h
NoCodeNoLife-404/Ali_mesh_environment_identification
36b74afa1e99b8d7ccbb355c2289994137e0ef72
[ "Apache-2.0" ]
8
2020-06-16T03:40:27.000Z
2022-01-20T02:22:43.000Z
include_lib/system/generic/log.h
NoCodeNoLife-404/Ali_mesh_environment_identification
36b74afa1e99b8d7ccbb355c2289994137e0ef72
[ "Apache-2.0" ]
1
2020-06-22T04:05:12.000Z
2020-06-22T11:33:50.000Z
include_lib/system/generic/log.h
NoCodeNoLife-404/Ali_mesh_environment_identification
36b74afa1e99b8d7ccbb355c2289994137e0ef72
[ "Apache-2.0" ]
9
2020-06-18T11:53:26.000Z
2022-02-15T05:54:45.000Z
#ifndef __LOG_H #define __LOG_H #include "system/generic/printf.h" #define __LOG_VERB 0 #define __LOG_DEBUG 1 #define __LOG_INFO 2 #define __LOG_WARN 3 #define __LOG_ERROR 4 #define __LOG_CHAR 5 struct logbuf { u16 len; u16 buf_len; char buf[0]; }; #define __LOG_ENABLE #ifdef CONFIG_RELEASE_ENABLE #undef __LOG_LEVEL #define __LOG_LEVEL 0xff #endif #if __LOG_LEVEL > __LOG_VERB #define log_v(...) do {} while (0) #elif defined __LOG_ENABLE #define log_v(...) log_print(__LOG_VERB, NULL, __VA_ARGS__) #else #define log_v(...) printf(__VA_ARGS__) #endif #if __LOG_LEVEL > __LOG_DEBUG #define log_d(...) do {} while (0) #elif defined __LOG_ENABLE #define log_d(...) log_print(__LOG_DEBUG, NULL, __VA_ARGS__); #else #define log_d(...) printf(__VA_ARGS__) #endif #if __LOG_LEVEL > __LOG_INFO #define log_i(...) do {} while (0) #elif defined __LOG_ENABLE #define log_i(...) log_print(__LOG_INFO, NULL, __VA_ARGS__); #else #define log_i(...) printf(__VA_ARGS__) #endif #if __LOG_LEVEL > __LOG_WARN #define log_w(...) do {} while (0) #elif defined __LOG_ENABLE #define log_w(...) log_print(__LOG_WARN, NULL, __VA_ARGS__); #else #define log_w(...) printf(__VA_ARGS__) #endif #if __LOG_LEVEL > __LOG_ERROR #define log_e(...) do {} while (0) #elif defined __LOG_ENABLE #define log_e(...) log_print(__LOG_ERROR, NULL, __VA_ARGS__); #else #define log_e(...) printf(__VA_ARGS__) #endif #if __LOG_LEVEL > __LOG_CHAR #define log_c(x) do {} while (0) #elif defined __LOG_ENABLE #define log_c(x) putchar(x) #else #define log_c(x) #endif #define r_printf(x, ...) log_i("\e[31m\e[1m" x "\e[0m", ## __VA_ARGS__) #define g_printf(x, ...) log_i("\e[32m\e[1m" x "\e[0m", ## __VA_ARGS__) #define y_printf(x, ...) log_i("\e[33m\e[1m" x "\e[0m", ## __VA_ARGS__) #define r_f_printf(x, ...) log_i("\e[31m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__) #define g_f_printf(x, ...) log_i("\e[32m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__) #define y_f_printf(x, ...) log_i("\e[33m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__) #ifndef __LOG_ENABLE #define log_dump(a, b) do {} while(0) #define log_putchar() do {} while(0) #define log_early_init(a) do {} while(0) #define log_level(a) do {} while(0) #else int log_output_lock(); void log_output_unlock(); void log_print_time(); void log_early_init(int buf_size); void log_level(int level); void log_print(int level, const char *tag, const char *format, ...); void log_dump(const u8 *buf, int len); struct logbuf *log_output_start(int len); void log_output_end(struct logbuf *); void log_putchar(struct logbuf *lb, char c); void log_put_u8hex(struct logbuf *lb, unsigned char dat); void log_putbyte(char); void log_set_time_offset(int offset); int log_get_time_offset(); #endif void log_flush(); #endif
22.983871
79
0.680351
e5664d13f4fa38868952f33a83ce8eeb5bece135
1,160
h
C
PrivateFrameworks/iWorkImport.framework/TSUNetworkReachability.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/iWorkImport.framework/TSUNetworkReachability.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/iWorkImport.framework/TSUNetworkReachability.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/TSUtility.framework/TSUtility */ @interface TSUNetworkReachability : NSObject { bool _localWiFi; struct __SCNetworkReachability { } * _reachabilityRef; } @property (nonatomic, readonly) bool connectionRequired; @property (nonatomic, readonly) long long status; + (id)networkReachabilityForDocumentResources; + (id)networkReachabilityForInternetConnection; + (id)networkReachabilityForLocalWiFi; + (long long)networkReachabilityStatusForDocumentResources; + (long long)networkReachabilityStatusForInternetConnection; + (long long)networkReachabilityStatusForLocalWiFi; + (id)networkReachabilityWithAddress:(const struct sockaddr_in { unsigned char x1; unsigned char x2; unsigned short x3; struct in_addr { unsigned int x_4_1_1; } x4; BOOL x5[8]; }*)arg1; + (id)networkReachabilityWithHostName:(id)arg1; - (bool)connectionRequired; - (void)dealloc; - (id)init; - (id)initWithReachabilityRef:(struct __SCNetworkReachability { }*)arg1; - (long long)localWiFiStatusForFlags:(unsigned int)arg1; - (long long)networkStatusForFlags:(unsigned int)arg1; - (long long)status; @end
37.419355
185
0.79569
efb2e3ea2462aace1fa548a040bbf6b8cab9f43d
2,543
h
C
ric_mc/Arduino/libraries/ros_lib/moveit_msgs/ConstraintEvalResult.h
intelligenceBGU/komodo
0aefd0ba35a6fc8038644ef086dde4a5cf4e6fd6
[ "BSD-3-Clause" ]
null
null
null
ric_mc/Arduino/libraries/ros_lib/moveit_msgs/ConstraintEvalResult.h
intelligenceBGU/komodo
0aefd0ba35a6fc8038644ef086dde4a5cf4e6fd6
[ "BSD-3-Clause" ]
null
null
null
ric_mc/Arduino/libraries/ros_lib/moveit_msgs/ConstraintEvalResult.h
intelligenceBGU/komodo
0aefd0ba35a6fc8038644ef086dde4a5cf4e6fd6
[ "BSD-3-Clause" ]
null
null
null
#ifndef _ROS_moveit_msgs_ConstraintEvalResult_h #define _ROS_moveit_msgs_ConstraintEvalResult_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" namespace moveit_msgs { class ConstraintEvalResult : public ros::Msg { public: bool result; float distance; virtual int serialize(unsigned char *outbuffer) const { int offset = 0; union { bool real; uint8_t base; } u_result; u_result.real = this->result; *(outbuffer + offset + 0) = (u_result.base >> (8 * 0)) & 0xFF; offset += sizeof(this->result); int32_t * val_distance = (int32_t *) &(this->distance); int32_t exp_distance = (((*val_distance)>>23)&255); if(exp_distance != 0) exp_distance += 1023-127; int32_t sig_distance = *val_distance; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = 0; *(outbuffer + offset++) = (sig_distance<<5) & 0xff; *(outbuffer + offset++) = (sig_distance>>3) & 0xff; *(outbuffer + offset++) = (sig_distance>>11) & 0xff; *(outbuffer + offset++) = ((exp_distance<<4) & 0xF0) | ((sig_distance>>19)&0x0F); *(outbuffer + offset++) = (exp_distance>>4) & 0x7F; if(this->distance < 0) *(outbuffer + offset -1) |= 0x80; return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; union { bool real; uint8_t base; } u_result; u_result.base = 0; u_result.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->result = u_result.real; offset += sizeof(this->result); uint32_t * val_distance = (uint32_t*) &(this->distance); offset += 3; *val_distance = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07); *val_distance |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3; *val_distance |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11; *val_distance |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19; uint32_t exp_distance = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4; exp_distance |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4; if(exp_distance !=0) *val_distance |= ((exp_distance)-1023+127)<<23; if( ((*(inbuffer+offset++)) & 0x80) > 0) this->distance = -this->distance; return offset; } const char * getType(){ return "moveit_msgs/ConstraintEvalResult"; }; const char * getMD5(){ return "093643083d24f6488cb5a868bd47c090"; }; }; } #endif
33.460526
87
0.587102
7bcfdc7cb9f100dfebd868ea3b39b669893f5b56
868
h
C
src/o3ds/async_subscriber.h
mocap-ca/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
13
2020-07-26T15:19:18.000Z
2021-11-13T05:05:24.000Z
src/o3ds/async_subscriber.h
pdkyll/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
null
null
null
src/o3ds/async_subscriber.h
pdkyll/Open3DStream
e376b359d349e18030aec287c3e8eb68928e24ff
[ "MIT" ]
4
2020-07-28T21:26:24.000Z
2022-01-25T18:58:37.000Z
#ifndef O3DS_ASYNC_SUBSCRIBER_H #define O3DS_ASYNC_SUBSCRIBER_H #include <nng/nng.h> #include <nng/protocol/pubsub0/sub.h> #include <nng/supplemental/util/platform.h> #include "base_server.h" #include <string> namespace O3DS { // The client pulls data down from a listen server class AsyncSubscriber : public AsyncConnector { public: bool start(const char*url); void callback_() { AsyncConnector::asyncReadMsg(); } static void callback(void *ref) { ((AsyncSubscriber*)ref)->callback_(); } static void pipeEvent(nng_pipe pipe, nng_pipe_ev pipe_ev, void* ref) { ((AsyncSubscriber*)ref)->pipeEvent_(pipe, pipe_ev); } void pipeEvent_(nng_pipe pipe, nng_pipe_ev pipe_ev); bool listen(const char* url) { return false; } bool write(const char* data, size_t ptr) { return false; } //virtual void in_pipe() = 0; }; } #endif
19.288889
70
0.709677
73b3738f36d778445ec6da89ceb93e89f49abd8e
2,134
h
C
src/main/jni/include/genomicsdb_GenomicsDBQueryStream.h
WordLess-ChuanJun/GenomisDB
d91ef2b701cf64be8c9911ee935863527ed94e9a
[ "MIT" ]
null
null
null
src/main/jni/include/genomicsdb_GenomicsDBQueryStream.h
WordLess-ChuanJun/GenomisDB
d91ef2b701cf64be8c9911ee935863527ed94e9a
[ "MIT" ]
null
null
null
src/main/jni/include/genomicsdb_GenomicsDBQueryStream.h
WordLess-ChuanJun/GenomisDB
d91ef2b701cf64be8c9911ee935863527ed94e9a
[ "MIT" ]
null
null
null
/* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class com_intel_genomicsdb_GenomicsDBQueryStream */ #ifndef _Included_com_intel_genomicsdb_GenomicsDBQueryStream #define _Included_com_intel_genomicsdb_GenomicsDBQueryStream #ifdef __cplusplus extern "C" { #endif #undef com_intel_genomicsdb_GenomicsDBQueryStream_MAX_SKIP_BUFFER_SIZE #define com_intel_genomicsdb_GenomicsDBQueryStream_MAX_SKIP_BUFFER_SIZE 2048L /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBInit * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIJJ)J */ JNIEXPORT jlong JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBInit (JNIEnv *, jobject, jstring, jstring, jstring, jint, jint, jint, jlong, jlong, jboolean, jboolean, jboolean, jboolean); /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBClose * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBClose (JNIEnv *, jobject, jlong); /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBGetNumBytesAvailable * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBGetNumBytesAvailable (JNIEnv *, jobject, jlong); /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBReadNextByte * Signature: (J)B */ JNIEXPORT jbyte JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBReadNextByte (JNIEnv *, jobject, jlong); /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBRead * Signature: (J[BII)I */ JNIEXPORT jint JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBRead (JNIEnv *, jobject, jlong, jbyteArray, jint, jint); /* * Class: com_intel_genomicsdb_GenomicsDBQueryStream * Method: jniGenomicsDBSkip * Signature: (JJ)J */ JNIEXPORT jlong JNICALL Java_com_intel_genomicsdb_GenomicsDBQueryStream_jniGenomicsDBSkip (JNIEnv *, jobject, jlong, jlong); #ifdef __cplusplus } #endif #endif
33.34375
121
0.806467
73ded8e5b06d7f8ac791f6be36437600e7264d88
2,988
h
C
kanon/net/connection/tcp_connection.h
Conzxy/kanon
3440b0966153a0b8469e90b2a52df317aa4fe723
[ "MIT" ]
null
null
null
kanon/net/connection/tcp_connection.h
Conzxy/kanon
3440b0966153a0b8469e90b2a52df317aa4fe723
[ "MIT" ]
null
null
null
kanon/net/connection/tcp_connection.h
Conzxy/kanon
3440b0966153a0b8469e90b2a52df317aa4fe723
[ "MIT" ]
null
null
null
#ifndef KANON_NET_TCPCONNECTION_H #define KANON_NET_TCPCONNECTION_H #include "kanon/util/noncopyable.h" #include "kanon/util/macro.h" #include "kanon/util/ptr.h" #include "kanon/util/any.h" #include "kanon/log/logger.h" #include "kanon/net/callback.h" #include "kanon/net/inet_addr.h" #include "kanon/net/buffer.h" #include "connection_base.h" namespace kanon { //! \addtogroup net //!@{ /** * \brief Represents a tcp connection. * * User don't care detail of it, the work just to register callback as following: * - Message callback to process message from the peer * - Highwatermark callback to do something when output buffer is too full * - Connection callback to do something when connection down or up * - Write complete callback to do something when write complete * * Besides, * - Send message to peer(std::string, kanon::StringView, char const*, kanon::Buffer) * - Shutdown in write direction and close * - Set context that tie with this connection * * \note * Public class */ class TcpConnection : public ConnectionBase<TcpConnection> { using Base = ConnectionBase<TcpConnection>; public: ~TcpConnection() noexcept; /** * Shouldn't call this. To call NewTcpConnection(). \n * Can't set this be private member * since std::make_shared<> need access ctor */ TcpConnection(EventLoop* loop, std::string const& name, int sockfd, InetAddr const& local_addr, InetAddr const& peer_addr); /** * \brief Create a TcpConnection instance correctly * * This is a factory method * \param loop owner event loop * \param sockfd managed socket fd * \param local_addr local address * \param peer_addr peer or remote address */ static TcpConnectionPtr NewTcpConnection(EventLoop* loop, std::string const& name, int sockfd, InetAddr const& local_addr, InetAddr const& peer_addr) { return std::make_shared<TcpConnection>(loop, name, sockfd, local_addr, peer_addr); } //! Whether disable Negele algorithm void SetNoDelay(bool flag) noexcept; //! Whether disable keep-alive timer void SetKeepAlive(bool flag) noexcept; InetAddr const& GetLocalAddr() const noexcept { return local_addr_; } InetAddr const& GetPeerAddr() const noexcept { return peer_addr_; } private: InetAddr const local_addr_; InetAddr const peer_addr_; }; // Default connection callback. // It is called when connection established and closed. // Log message abont peer and local simply(trace level only) inline void DefaultConnectionCallback(TcpConnectionPtr const& conn) { LOG_TRACE_KANON << conn->GetLocalAddr().ToIpPort() << "->" << conn->GetPeerAddr().ToIpPort() << " " << (conn->IsConnected() ? "UP" : "DOWN"); } } // namespace kanon #endif // KANON_NET_TCPCONNECTION_H
30.804124
88
0.667671
212eaa8ec2c83248696ac87a4a06ca4bb435171d
5,331
h
C
firmware/export/config/samsungypr0.h
Rockbox-Chinese-Community/Rockbox-RCC
a701aefe45f03ca391a8e2f1a6e3da1b8774b2f2
[ "BSD-3-Clause" ]
24
2015-03-10T08:43:56.000Z
2022-01-05T14:09:46.000Z
firmware/export/config/samsungypr0.h
Rockbox-Chinese-Community/Rockbox-RCC
a701aefe45f03ca391a8e2f1a6e3da1b8774b2f2
[ "BSD-3-Clause" ]
4
2015-07-04T18:15:33.000Z
2018-05-18T05:33:33.000Z
firmware/export/config/samsungypr0.h
Rockbox-Chinese-Community/Rockbox-RCC
a701aefe45f03ca391a8e2f1a6e3da1b8774b2f2
[ "BSD-3-Clause" ]
15
2015-01-21T13:58:13.000Z
2020-11-04T04:30:22.000Z
/* * This config file is for the RockBox as application on the Samsung YP-R0 player. * The target name for ifdefs is: SAMSUNG_YPR0; or CONFIG_PLATFORM & PLAFTORM_YPR0 */ /* We don't run on hardware directly */ /* YP-R0 need it too of course */ #ifndef SIMULATOR #define CONFIG_PLATFORM (PLATFORM_HOSTED) #endif /* For Rolo and boot loader */ #define MODEL_NUMBER 100 #define MODEL_NAME "Samsung YP-R0" /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP /* define this if you have a colour LCD */ #define HAVE_LCD_COLOR /* Define this if the LCD can shut down */ #define HAVE_LCD_SHUTDOWN /* define this if you have LCD enable function */ #define HAVE_LCD_ENABLE /* define this if you want album art for this target */ #define HAVE_ALBUMART /* define this to enable bitmap scaling */ #define HAVE_BMP_SCALING /* define this to enable JPEG decoding */ #define HAVE_JPEG /* define this if you have access to the quickscreen */ #define HAVE_QUICKSCREEN /* define this if you would like tagcache to build on this target */ #define HAVE_TAGCACHE /* LCD dimensions */ #define LCD_WIDTH 240 #define LCD_HEIGHT 320 /* sqrt(240^2 + 320^2) / 2.6 = 153.8 */ #define LCD_DPI 154 #define LCD_DEPTH 24 /* Check that but should not matter */ #define LCD_PIXELFORMAT RGB888 /* YP-R0 has the backlight */ #define HAVE_BACKLIGHT /* Define this for LCD backlight brightness available */ #define HAVE_BACKLIGHT_BRIGHTNESS /* Main LCD backlight brightness range and defaults */ /* 0 is turned off. 31 is the real maximum for the ASCODEC DCDC but samsung doesn't use any value over 15, so it safer to don't go up too much */ #define MIN_BRIGHTNESS_SETTING 1 #define MAX_BRIGHTNESS_SETTING 15 #define DEFAULT_BRIGHTNESS_SETTING 4 /* Which backlight fading type? */ /* TODO: ASCODEC has an auto dim feature, so disabling the supply to leds should do the trick. But for now I tested SW fading only */ #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING /* define this if you have RTC RAM available for settings */ /* TODO: in theory we could use that, ascodec offers us such a ram. we have also a small device, part of the nand of 1 MB size, that Samsung uses to store region code etc and it's almost unused space */ //#define HAVE_RTC_RAM /* define this if you have a real-time clock */ #define CONFIG_RTC RTC_AS3514 #define HAVE_RTC_ALARM /* The number of bytes reserved for loadable codecs */ #define CODEC_SIZE 0x80000 /* The number of bytes reserved for loadable plugins */ #define PLUGIN_BUFFER_SIZE 0x100000 #define AB_REPEAT_ENABLE #define ACTION_WPSAB_SINGLE ACTION_WPS_HOTKEY /* Define this if you do software codec */ #define CONFIG_CODEC SWCODEC /* R0 KeyPad configuration for plugins */ #define CONFIG_KEYPAD SAMSUNG_YPR0_PAD #define BUTTON_DRIVER_CLOSE /** Non-simulator section **/ #ifndef SIMULATOR /*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */ #define USB_NONE /* The YPR0 has a as3534 codec */ #define HAVE_AS3514 #define HAVE_AS3543 /* We don't have hardware controls */ #define HAVE_SW_TONE_CONTROLS /* We have the Si4709, which supports RDS */ #define CONFIG_TUNER SI4700 #define HAVE_TUNER_PWR_CTRL #define HAVE_RDS_CAP /* Define this for FM radio input available */ #define HAVE_FMRADIO_IN #define INPUT_SRC_CAPS SRC_CAP_FMRADIO /* We have a GPIO pin that detects this */ #define HAVE_HEADPHONE_DETECTION /* Define current usage levels. */ #define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ #define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ #endif /* SIMULATOR */ #define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */ #define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */ #define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */ #define BATTERY_CAPACITY_INC 0 /* capacity increment */ #define BATTERY_TYPES_COUNT 1 /* only one type */ #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE /* Linux controlls charging, we can monitor */ #define CONFIG_CHARGING CHARGING_MONITOR /* We want to be able to reset the averaging filter */ #define HAVE_RESET_BATTERY_FILTER /* same dimensions as gigabeats */ #define CONFIG_LCD LCD_YPR0 /* Define this if a programmable hotkey is mapped */ #define HAVE_HOTKEY /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF /* Define this if you have adjustable CPU frequency * NOTE: We could do that on this device, but it's probably better * to let linux do it (we set ondemand governor before loading Rockbox) */ /* #define HAVE_ADJUSTABLE_CPU_FREQ */ /* Define this to the CPU frequency */ #define CPU_FREQ 532000000 /* 0.8Vcore using 200 MHz */ /* #define CPUFREQ_DEFAULT 200000000 */ /* This is 400 MHz -> not so powersaving-ful */ /* #define CPUFREQ_NORMAL 400000000 */ /* Max IMX37 Cpu Frequency */ /* #define CPUFREQ_MAX CPU_FREQ */ /* This folder resides in the ReadOnly CRAMFS. It is binded to /mnt/media0/.rockbox */ #define BOOTDIR "/.rockbox" /* External SD card can be mounted */ #define CONFIG_STORAGE (STORAGE_HOSTFS|STORAGE_SD) #define HAVE_MULTIDRIVE #define NUM_DRIVES 2 #define HAVE_HOTSWAP #define HAVE_STORAGE_FLUSH #define MULTIDRIVE_DIR "/mnt/mmc"
31.175439
202
0.752017
34a657d748f549349e8818faf2d53e8d02cc8bd6
577
h
C
include/sys/config.h
yokocc255/os-master
973caf9ad44410aa2f5b09cd61883416c39a24ea
[ "MIT" ]
null
null
null
include/sys/config.h
yokocc255/os-master
973caf9ad44410aa2f5b09cd61883416c39a24ea
[ "MIT" ]
null
null
null
include/sys/config.h
yokocc255/os-master
973caf9ad44410aa2f5b09cd61883416c39a24ea
[ "MIT" ]
null
null
null
/*************************************************************************//** ***************************************************************************** * @file config.h * @brief * @author Forrest Y. Yu * @date 2008 ***************************************************************************** *****************************************************************************/ #define MINOR_BOOT MINOR_hd2a /* * disk log */ #define ENABLE_DISK_LOG #define SET_LOG_SECT_SMAP_AT_STARTUP #define MEMSET_LOG_SECTS #define NR_SECTS_FOR_LOG NR_DEFAULT_FILE_SECTS
30.368421
79
0.334489
421ce11d5eef6ec1da479caf0d919a514519c5d2
19,554
c
C
usr/src/uts/common/io/hxge/hxge_hw.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/uts/common/io/hxge/hxge_hw.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
null
null
null
usr/src/uts/common/io/hxge/hxge_hw.c
AsahiOS/gate
283d47da4e17a5871d9d575e7ffb81e8f6c52e51
[ "MIT" ]
1
2020-12-30T00:04:16.000Z
2020-12-30T00:04:16.000Z
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include <hxge_impl.h> lb_property_t lb_normal = {normal, "normal", hxge_lb_normal}; lb_property_t lb_mac10g = {internal, "mac10g", hxge_lb_mac10g}; uint32_t hxge_lb_dbg = 1; extern uint32_t hxge_jumbo_frame_size; static void hxge_rtrace_ioctl(p_hxge_t, queue_t *, mblk_t *, struct iocblk *); void hxge_global_reset(p_hxge_t hxgep) { HXGE_DEBUG_MSG((hxgep, DDI_CTL, "==> hxge_global_reset")); (void) hxge_intr_hw_disable(hxgep); if (hxgep->suspended) (void) hxge_link_init(hxgep); (void) hxge_vmac_init(hxgep); (void) hxge_intr_hw_enable(hxgep); HXGE_DEBUG_MSG((hxgep, DDI_CTL, "<== hxge_global_reset")); } void hxge_hw_id_init(p_hxge_t hxgep) { HXGE_DEBUG_MSG((hxgep, DDI_CTL, "==> hxge_hw_id_init")); /* * Initialize the frame size to either standard "1500 + 38" or * jumbo. The user may tune the frame size through the "mtu" parameter * using "dladm set-linkprop" */ hxgep->vmac.minframesize = MIN_FRAME_SIZE; hxgep->vmac.maxframesize = HXGE_DEFAULT_MTU + MTU_TO_FRAME_SIZE; if (hxgep->param_arr[param_accept_jumbo].value) hxgep->vmac.maxframesize = (uint16_t)hxge_jumbo_frame_size; HXGE_DEBUG_MSG((hxgep, DDI_CTL, "==> hxge_hw_id_init: maxframesize %d", hxgep->vmac.maxframesize)); HXGE_DEBUG_MSG((hxgep, DDI_CTL, "<== hxge_hw_id_init")); } void hxge_hw_init_niu_common(p_hxge_t hxgep) { p_hxge_hw_list_t hw_p; HXGE_DEBUG_MSG((hxgep, DDI_CTL, "==> hxge_hw_init_niu_common")); if ((hw_p = hxgep->hxge_hw_p) == NULL) { return; } MUTEX_ENTER(&hw_p->hxge_cfg_lock); if (hw_p->flags & COMMON_INIT_DONE) { HXGE_DEBUG_MSG((hxgep, MOD_CTL, "hxge_hw_init_niu_common" " already done for dip $%p exiting", hw_p->parent_devp)); MUTEX_EXIT(&hw_p->hxge_cfg_lock); return; } hw_p->flags = COMMON_INIT_START; HXGE_DEBUG_MSG((hxgep, MOD_CTL, "hxge_hw_init_niu_common Started for device id %x", hw_p->parent_devp)); (void) hxge_pfc_hw_reset(hxgep); hw_p->flags = COMMON_INIT_DONE; MUTEX_EXIT(&hw_p->hxge_cfg_lock); HXGE_DEBUG_MSG((hxgep, MOD_CTL, "hxge_hw_init_niu_common Done for device id %x", hw_p->parent_devp)); HXGE_DEBUG_MSG((hxgep, DDI_CTL, "<== hxge_hw_init_niu_common")); } uint_t hxge_intr(caddr_t arg1, caddr_t arg2) { p_hxge_ldv_t ldvp = (p_hxge_ldv_t)arg1; p_hxge_t hxgep = (p_hxge_t)arg2; uint8_t ldv; hpi_handle_t handle; p_hxge_ldgv_t ldgvp; p_hxge_ldg_t ldgp, t_ldgp; p_hxge_ldv_t t_ldvp; uint32_t vector0 = 0, vector1 = 0; int j, nldvs; hpi_status_t rs = HPI_SUCCESS; /* * DDI interface returns second arg as NULL */ if ((arg2 == NULL) || ((void *) ldvp->hxgep != arg2)) { hxgep = ldvp->hxgep; } HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr")); if (hxgep->hxge_mac_state != HXGE_MAC_STARTED) { HXGE_ERROR_MSG((hxgep, INT_CTL, "<== hxge_intr: not initialized")); return (DDI_INTR_UNCLAIMED); } ldgvp = hxgep->ldgvp; HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: ldgvp $%p", ldgvp)); if (ldvp == NULL && ldgvp) t_ldvp = ldvp = ldgvp->ldvp; if (ldvp) ldgp = t_ldgp = ldvp->ldgp; HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: " "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); if (ldgvp == NULL || ldvp == NULL || ldgp == NULL) { HXGE_ERROR_MSG((hxgep, INT_CTL, "==> hxge_intr: " "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); HXGE_ERROR_MSG((hxgep, INT_CTL, "<== hxge_intr: not ready")); return (DDI_INTR_UNCLAIMED); } /* * This interrupt handler will have to go through * all the logical devices to find out which * logical device interrupts us and then call * its handler to process the events. */ handle = HXGE_DEV_HPI_HANDLE(hxgep); t_ldgp = ldgp; t_ldvp = ldgp->ldvp; nldvs = ldgp->nldvs; HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: #ldvs %d #intrs %d", nldvs, ldgvp->ldg_intrs)); HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr(%d): #ldvs %d", i, nldvs)); /* * Get this group's flag bits. */ t_ldgp->interrupted = B_FALSE; rs = hpi_ldsv_ldfs_get(handle, t_ldgp->ldg, &vector0, &vector1); if (rs != HPI_SUCCESS) return (DDI_INTR_UNCLAIMED); if (!vector0 && !vector1) { HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: " "no interrupts on group %d", t_ldgp->ldg)); return (DDI_INTR_UNCLAIMED); } HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: " "vector0 0x%llx vector1 0x%llx", vector0, vector1)); t_ldgp->interrupted = B_TRUE; nldvs = t_ldgp->nldvs; /* * Process all devices that share this group. */ for (j = 0; j < nldvs; j++, t_ldvp++) { /* * Call device's handler if flag bits are on. */ ldv = t_ldvp->ldv; if ((LDV_ON(ldv, vector0) | (LDV_ON(ldv, vector1)))) { HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: calling device %d" " #ldvs %d #intrs %d", j, nldvs, nintrs)); (void) (t_ldvp->ldv_intr_handler)( (caddr_t)t_ldvp, arg2); } } /* * Re-arm group interrupts */ if (t_ldgp->interrupted) { HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr: arm group %d", t_ldgp->ldg)); (void) hpi_intr_ldg_mgmt_set(handle, t_ldgp->ldg, t_ldgp->arm, t_ldgp->ldg_timer); } HXGE_DEBUG_MSG((hxgep, INT_CTL, "<== hxge_intr")); return (DDI_INTR_CLAIMED); } hxge_status_t hxge_peu_handle_sys_errors(p_hxge_t hxgep) { hpi_handle_t handle; p_hxge_peu_sys_stats_t statsp; peu_intr_stat_t stat; handle = hxgep->hpi_handle; statsp = (p_hxge_peu_sys_stats_t)&hxgep->statsp->peu_sys_stats; HXGE_REG_RD32(handle, PEU_INTR_STAT, &stat.value); /* * The PCIE errors are unrecoverrable and cannot be cleared. * The only thing we can do here is to mask them off to prevent * continued interrupts. */ HXGE_REG_WR32(handle, PEU_INTR_MASK, 0xffffffff); if (stat.bits.spc_acc_err) { statsp->spc_acc_err++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: spc_acc_err")); } if (stat.bits.tdc_pioacc_err) { statsp->tdc_pioacc_err++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: tdc_pioacc_err")); } if (stat.bits.rdc_pioacc_err) { statsp->rdc_pioacc_err++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: rdc_pioacc_err")); } if (stat.bits.pfc_pioacc_err) { statsp->pfc_pioacc_err++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: pfc_pioacc_err")); } if (stat.bits.vmac_pioacc_err) { statsp->vmac_pioacc_err++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: vmac_pioacc_err")); } if (stat.bits.cpl_hdrq_parerr) { statsp->cpl_hdrq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: cpl_hdrq_parerr")); } if (stat.bits.cpl_dataq_parerr) { statsp->cpl_dataq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: cpl_dataq_parerr")); } if (stat.bits.retryram_xdlh_parerr) { statsp->retryram_xdlh_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: retryram_xdlh_parerr")); } if (stat.bits.retrysotram_xdlh_parerr) { statsp->retrysotram_xdlh_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: retrysotram_xdlh_parerr")); } if (stat.bits.p_hdrq_parerr) { statsp->p_hdrq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: p_hdrq_parerr")); } if (stat.bits.p_dataq_parerr) { statsp->p_dataq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: p_dataq_parerr")); } if (stat.bits.np_hdrq_parerr) { statsp->np_hdrq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: np_hdrq_parerr")); } if (stat.bits.np_dataq_parerr) { statsp->np_dataq_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: np_dataq_parerr")); } if (stat.bits.eic_msix_parerr) { statsp->eic_msix_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: eic_msix_parerr")); } if (stat.bits.hcr_parerr) { statsp->hcr_parerr++; HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_peu_handle_sys_errors: hcr_parerr")); } HXGE_FM_REPORT_ERROR(hxgep, 0, HXGE_FM_EREPORT_PEU_ERR); return (HXGE_OK); } /*ARGSUSED*/ uint_t hxge_syserr_intr(caddr_t arg1, caddr_t arg2) { p_hxge_ldv_t ldvp = (p_hxge_ldv_t)arg1; p_hxge_t hxgep = (p_hxge_t)arg2; p_hxge_ldg_t ldgp = NULL; hpi_handle_t handle; dev_err_stat_t estat; if ((arg1 == NULL) && (arg2 == NULL)) { return (DDI_INTR_UNCLAIMED); } if ((arg2 == NULL) || ((ldvp != NULL) && ((void *)ldvp->hxgep != arg2))) { if (ldvp != NULL) { hxgep = ldvp->hxgep; } } HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "==> hxge_syserr_intr: arg2 $%p arg1 $%p", hxgep, ldvp)); if (ldvp != NULL && ldvp->use_timer == B_FALSE) { ldgp = ldvp->ldgp; if (ldgp == NULL) { HXGE_ERROR_MSG((hxgep, SYSERR_CTL, "<== hxge_syserrintr(no logical group): " "arg2 $%p arg1 $%p", hxgep, ldvp)); return (DDI_INTR_UNCLAIMED); } } /* * This interrupt handler is for system error interrupts. */ handle = HXGE_DEV_HPI_HANDLE(hxgep); estat.value = 0; (void) hpi_fzc_sys_err_stat_get(handle, &estat); HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "==> hxge_syserr_intr: device error 0x%016llx", estat.value)); if (estat.bits.tdc_err0 || estat.bits.tdc_err1) { /* TDMC */ HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_syserr_intr: device error - TDMC")); (void) hxge_txdma_handle_sys_errors(hxgep); } else if (estat.bits.rdc_err0 || estat.bits.rdc_err1) { /* RDMC */ HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_syserr_intr: device error - RDMC")); (void) hxge_rxdma_handle_sys_errors(hxgep); } else if (estat.bits.vnm_pio_err1 || estat.bits.peu_err1) { /* PCI-E */ HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_syserr_intr: device error - PCI-E")); /* kstats are updated here */ (void) hxge_peu_handle_sys_errors(hxgep); if (estat.bits.peu_err1) HXGE_FM_REPORT_ERROR(hxgep, 0, HXGE_FM_EREPORT_PEU_ERR); if (estat.bits.vnm_pio_err1) HXGE_FM_REPORT_ERROR(hxgep, 0, HXGE_FM_EREPORT_PEU_VNM_PIO_ERR); } else if (estat.value != 0) { HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "==> hxge_syserr_intr: device error - unknown")); } if ((ldgp != NULL) && (ldvp != NULL) && (ldgp->nldvs == 1) && !ldvp->use_timer) { (void) hpi_intr_ldg_mgmt_set(handle, ldgp->ldg, B_TRUE, ldgp->ldg_timer); } HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "<== hxge_syserr_intr")); return (DDI_INTR_CLAIMED); } void hxge_intr_hw_enable(p_hxge_t hxgep) { HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr_hw_enable")); (void) hxge_intr_mask_mgmt_set(hxgep, B_TRUE); HXGE_DEBUG_MSG((hxgep, INT_CTL, "<== hxge_intr_hw_enable")); } void hxge_intr_hw_disable(p_hxge_t hxgep) { HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_intr_hw_disable")); (void) hxge_intr_mask_mgmt_set(hxgep, B_FALSE); HXGE_DEBUG_MSG((hxgep, INT_CTL, "<== hxge_intr_hw_disable")); } /*ARGSUSED*/ void hxge_rx_hw_blank(void *arg, time_t ticks, uint_t count) { p_hxge_t hxgep = (p_hxge_t)arg; HXGE_DEBUG_MSG((hxgep, INT_CTL, "==> hxge_rx_hw_blank")); /* * Replace current ticks and counts for later * processing by the receive packet interrupt routines. */ hxgep->intr_timeout = (uint16_t)ticks; HXGE_DEBUG_MSG((hxgep, INT_CTL, "<== hxge_rx_hw_blank")); } void hxge_hw_stop(p_hxge_t hxgep) { HXGE_DEBUG_MSG((hxgep, DDI_CTL, "==> hxge_hw_stop")); (void) hxge_tx_vmac_disable(hxgep); (void) hxge_rx_vmac_disable(hxgep); (void) hxge_txdma_hw_mode(hxgep, HXGE_DMA_STOP); (void) hxge_rxdma_hw_mode(hxgep, HXGE_DMA_STOP); HXGE_DEBUG_MSG((hxgep, DDI_CTL, "<== hxge_hw_stop")); } void hxge_hw_ioctl(p_hxge_t hxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) { int cmd; HXGE_DEBUG_MSG((hxgep, IOC_CTL, "==> hxge_hw_ioctl")); if (hxgep == NULL) { miocnak(wq, mp, 0, EINVAL); return; } iocp->ioc_error = 0; cmd = iocp->ioc_cmd; switch (cmd) { default: miocnak(wq, mp, 0, EINVAL); return; case HXGE_PUT_TCAM: hxge_put_tcam(hxgep, mp->b_cont); miocack(wq, mp, 0, 0); break; case HXGE_GET_TCAM: hxge_get_tcam(hxgep, mp->b_cont); miocack(wq, mp, 0, 0); break; case HXGE_RTRACE: hxge_rtrace_ioctl(hxgep, wq, mp, iocp); break; } } /* * 10G is the only loopback mode for Hydra. */ void hxge_loopback_ioctl(p_hxge_t hxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) { p_lb_property_t lb_props; size_t size; int i; if (mp->b_cont == NULL) { miocnak(wq, mp, 0, EINVAL); } switch (iocp->ioc_cmd) { case LB_GET_MODE: HXGE_DEBUG_MSG((hxgep, IOC_CTL, "HXGE_GET_LB_MODE command")); if (hxgep != NULL) { *(lb_info_sz_t *)mp->b_cont->b_rptr = hxgep->statsp->port_stats.lb_mode; miocack(wq, mp, sizeof (hxge_lb_t), 0); } else miocnak(wq, mp, 0, EINVAL); break; case LB_SET_MODE: HXGE_DEBUG_MSG((hxgep, IOC_CTL, "HXGE_SET_LB_MODE command")); if (iocp->ioc_count != sizeof (uint32_t)) { miocack(wq, mp, 0, 0); break; } if ((hxgep != NULL) && hxge_set_lb(hxgep, wq, mp->b_cont)) { miocack(wq, mp, 0, 0); } else { miocnak(wq, mp, 0, EPROTO); } break; case LB_GET_INFO_SIZE: HXGE_DEBUG_MSG((hxgep, IOC_CTL, "LB_GET_INFO_SIZE command")); if (hxgep != NULL) { size = sizeof (lb_normal) + sizeof (lb_mac10g); *(lb_info_sz_t *)mp->b_cont->b_rptr = size; HXGE_DEBUG_MSG((hxgep, IOC_CTL, "HXGE_GET_LB_INFO command: size %d", size)); miocack(wq, mp, sizeof (lb_info_sz_t), 0); } else miocnak(wq, mp, 0, EINVAL); break; case LB_GET_INFO: HXGE_DEBUG_MSG((hxgep, IOC_CTL, "HXGE_GET_LB_INFO command")); if (hxgep != NULL) { size = sizeof (lb_normal) + sizeof (lb_mac10g); HXGE_DEBUG_MSG((hxgep, IOC_CTL, "HXGE_GET_LB_INFO command: size %d", size)); if (size == iocp->ioc_count) { i = 0; lb_props = (p_lb_property_t)mp->b_cont->b_rptr; lb_props[i++] = lb_normal; lb_props[i++] = lb_mac10g; miocack(wq, mp, size, 0); } else miocnak(wq, mp, 0, EINVAL); } else { miocnak(wq, mp, 0, EINVAL); cmn_err(CE_NOTE, "hxge_hw_ioctl: invalid command 0x%x", iocp->ioc_cmd); } break; } } /*ARGSUSED*/ boolean_t hxge_set_lb(p_hxge_t hxgep, queue_t *wq, p_mblk_t mp) { boolean_t status = B_TRUE; uint32_t lb_mode; lb_property_t *lb_info; HXGE_DEBUG_MSG((hxgep, IOC_CTL, "<== hxge_set_lb")); lb_mode = hxgep->statsp->port_stats.lb_mode; if (lb_mode == *(uint32_t *)mp->b_rptr) { cmn_err(CE_NOTE, "hxge%d: Loopback mode already set (lb_mode %d).\n", hxgep->instance, lb_mode); status = B_FALSE; goto hxge_set_lb_exit; } lb_mode = *(uint32_t *)mp->b_rptr; lb_info = NULL; /* 10G is the only loopback mode for Hydra */ if (lb_mode == lb_normal.value) lb_info = &lb_normal; else if (lb_mode == lb_mac10g.value) lb_info = &lb_mac10g; else { cmn_err(CE_NOTE, "hxge%d: Loopback mode not supported(mode %d).\n", hxgep->instance, lb_mode); status = B_FALSE; goto hxge_set_lb_exit; } if (lb_mode == hxge_lb_normal) { if (hxge_lb_dbg) { cmn_err(CE_NOTE, "!hxge%d: Returning to normal operation", hxgep->instance); } hxgep->statsp->port_stats.lb_mode = hxge_lb_normal; hxge_global_reset(hxgep); goto hxge_set_lb_exit; } hxgep->statsp->port_stats.lb_mode = lb_mode; if (hxge_lb_dbg) cmn_err(CE_NOTE, "!hxge%d: Adapter now in %s loopback mode", hxgep->instance, lb_info->key); if (lb_info->lb_type == internal) { if ((hxgep->statsp->port_stats.lb_mode == hxge_lb_mac10g)) hxgep->statsp->mac_stats.link_speed = 10000; else { cmn_err(CE_NOTE, "hxge%d: Loopback mode not supported(mode %d).\n", hxgep->instance, lb_mode); status = B_FALSE; goto hxge_set_lb_exit; } hxgep->statsp->mac_stats.link_duplex = 2; hxgep->statsp->mac_stats.link_up = 1; } hxge_global_reset(hxgep); hxge_set_lb_exit: HXGE_DEBUG_MSG((hxgep, DDI_CTL, "<== hxge_set_lb status = 0x%08x", status)); return (status); } void hxge_check_hw_state(p_hxge_t hxgep) { p_hxge_ldgv_t ldgvp; p_hxge_ldv_t t_ldvp; HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "==> hxge_check_hw_state")); MUTEX_ENTER(hxgep->genlock); hxgep->hxge_timerid = 0; if (!(hxgep->drv_state & STATE_HW_INITIALIZED)) { goto hxge_check_hw_state_exit; } hxge_check_tx_hang(hxgep); ldgvp = hxgep->ldgvp; if (ldgvp == NULL || (ldgvp->ldvp_syserr == NULL)) { HXGE_ERROR_MSG((hxgep, SYSERR_CTL, "<== hxge_check_hw_state: " "NULL ldgvp (interrupt not ready).")); goto hxge_check_hw_state_exit; } t_ldvp = ldgvp->ldvp_syserr; if (!t_ldvp->use_timer) { HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "<== hxge_check_hw_state: " "ldgvp $%p t_ldvp $%p use_timer flag %d", ldgvp, t_ldvp, t_ldvp->use_timer)); goto hxge_check_hw_state_exit; } if (fm_check_acc_handle(hxgep->dev_regs->hxge_regh) != DDI_FM_OK) { HXGE_ERROR_MSG((hxgep, HXGE_ERR_CTL, "Bad register acc handle")); } (void) hxge_syserr_intr((caddr_t)t_ldvp, (caddr_t)hxgep); hxgep->hxge_timerid = hxge_start_timer(hxgep, hxge_check_hw_state, HXGE_CHECK_TIMER); hxge_check_hw_state_exit: MUTEX_EXIT(hxgep->genlock); HXGE_DEBUG_MSG((hxgep, SYSERR_CTL, "<== hxge_check_hw_state")); } /*ARGSUSED*/ static void hxge_rtrace_ioctl(p_hxge_t hxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) { ssize_t size; rtrace_t *rtp; mblk_t *nmp; uint32_t i, j; uint32_t start_blk; uint32_t base_entry; uint32_t num_entries; HXGE_DEBUG_MSG((hxgep, STR_CTL, "==> hxge_rtrace_ioctl")); size = 1024; if (mp->b_cont == NULL || MBLKL(mp->b_cont) < size) { HXGE_DEBUG_MSG((hxgep, STR_CTL, "malformed M_IOCTL MBLKL = %d size = %d", MBLKL(mp->b_cont), size)); miocnak(wq, mp, 0, EINVAL); return; } nmp = mp->b_cont; rtp = (rtrace_t *)nmp->b_rptr; start_blk = rtp->next_idx; num_entries = rtp->last_idx; base_entry = start_blk * MAX_RTRACE_IOC_ENTRIES; HXGE_DEBUG_MSG((hxgep, STR_CTL, "start_blk = %d\n", start_blk)); HXGE_DEBUG_MSG((hxgep, STR_CTL, "num_entries = %d\n", num_entries)); HXGE_DEBUG_MSG((hxgep, STR_CTL, "base_entry = %d\n", base_entry)); rtp->next_idx = hpi_rtracebuf.next_idx; rtp->last_idx = hpi_rtracebuf.last_idx; rtp->wrapped = hpi_rtracebuf.wrapped; for (i = 0, j = base_entry; i < num_entries; i++, j++) { rtp->buf[i].ctl_addr = hpi_rtracebuf.buf[j].ctl_addr; rtp->buf[i].val_l32 = hpi_rtracebuf.buf[j].val_l32; rtp->buf[i].val_h32 = hpi_rtracebuf.buf[j].val_h32; } nmp->b_wptr = nmp->b_rptr + size; HXGE_DEBUG_MSG((hxgep, STR_CTL, "<== hxge_rtrace_ioctl")); miocack(wq, mp, (int)size, 0); }
25.899338
78
0.686356
e8308341594011d85408c82a1baea9bbac367d39
568
c
C
src/main.c
zoogie/petit-compwner
5b75509a11daea0f655203f6cd2584f47dda4a65
[ "MIT" ]
19
2020-04-01T18:38:25.000Z
2022-02-13T00:24:24.000Z
src/main.c
zoogie/petit-compwner
5b75509a11daea0f655203f6cd2584f47dda4a65
[ "MIT" ]
null
null
null
src/main.c
zoogie/petit-compwner
5b75509a11daea0f655203f6cd2584f47dda4a65
[ "MIT" ]
2
2020-04-01T19:07:21.000Z
2021-06-17T08:19:47.000Z
typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; #include "payload.h" int main(void) { u8 *payload_dest=(u8*)0x02200000; //int size=0x1800; for(int i=0; i < payload_dat_size; i++){ payload_dest[i] = payload_dat[i]; //warnings during complile because we memcpy past the array's boundry. this is ok since it's all allocated wram and the payload doesn't care about the extra junk at the end. } //*(u16*)0x400006C=0; //MASTER_BRIGHT SUB & TOP //*(u16*)0x400106C=0; //"" asm("ldr pc,=0x02200000"); return 0; }
25.818182
209
0.683099
19b74e5e649ac88bb5b80919c21bf8dc73ca08ca
3,507
h
C
flatdata-cpp/include/flatdata/Vector.h
gferon/flatdata
8839fb36be105e496fea8acc3fc907ae878dd063
[ "Apache-2.0" ]
140
2018-01-26T21:59:38.000Z
2022-02-17T10:23:29.000Z
flatdata-cpp/include/flatdata/Vector.h
gferon/flatdata
8839fb36be105e496fea8acc3fc907ae878dd063
[ "Apache-2.0" ]
114
2018-01-26T17:49:20.000Z
2021-11-26T13:27:08.000Z
flatdata-cpp/include/flatdata/Vector.h
gferon/flatdata
8839fb36be105e496fea8acc3fc907ae878dd063
[ "Apache-2.0" ]
22
2018-01-26T16:51:24.000Z
2021-04-27T13:32:44.000Z
/** * Copyright (c) 2017 HERE Europe B.V. * See the LICENSE file in the root of this project for license details. */ #pragma once #include "ArrayView.h" #include "internal/Constants.h" #include <type_traits> #include <vector> namespace flatdata { template < typename T > class Vector { public: using ValueType = typename T::MutatorType; using ConstValueType = typename T::AccessorType; using StreamType = typename T::MutatorType::StreamType; using ConstStreamType = typename T::AccessorType::StreamType; public: explicit Vector( size_t size = 0 ); ConstValueType operator[]( size_t i ) const; ValueType operator[]( size_t i ); ConstValueType front( ) const; ValueType front( ); ConstValueType back( ) const; ValueType back( ); size_t size_in_bytes( ) const; size_t size( ) const; ConstStreamType data( ) const; StreamType data( ); void resize( size_t size ); void reserve( size_t size ); ValueType grow( ); void pop_back( ); operator ArrayView< ConstValueType >( ) const; private: std::vector< typename std::remove_pointer< StreamType >::type > m_data; }; // ----------------------------------------------------------------------------- template < typename T > Vector< T >::Vector( size_t size ) { reserve( size ); resize( size ); } template < typename T > typename Vector< T >::ConstValueType Vector< T >::operator[]( size_t i ) const { return ConstValueType{m_data.data( ) + T::size_in_bytes( ) * i}; } template < typename T > typename Vector< T >::ValueType Vector< T >::operator[]( size_t i ) { return ValueType{m_data.data( ) + T::size_in_bytes( ) * i}; } template < typename T > typename Vector< T >::ConstValueType Vector< T >::front( ) const { return this->operator[]( 0 ); } template < typename T > typename Vector< T >::ValueType Vector< T >::front( ) { return this->operator[]( 0 ); } template < typename T > typename Vector< T >::ConstValueType Vector< T >::back( ) const { return this->operator[]( size( ) - 1 ); } template < typename T > typename Vector< T >::ValueType Vector< T >::back( ) { return this->operator[]( size( ) - 1 ); } template < typename T > size_t Vector< T >::size_in_bytes( ) const { return m_data.size( ) - PADDING_SIZE; } template < typename T > typename Vector< T >::ConstStreamType Vector< T >::data( ) const { return m_data.data( ); } template < typename T > typename Vector< T >::StreamType Vector< T >::data( ) { return m_data.data( ); } template < typename T > size_t Vector< T >::size( ) const { return size_in_bytes( ) / T::size_in_bytes( ); } template < typename T > void Vector< T >::resize( size_t size ) { m_data.resize( size * T::size_in_bytes( ) + PADDING_SIZE ); } template < typename T > void Vector< T >::reserve( size_t size ) { m_data.reserve( size * T::size_in_bytes( ) + PADDING_SIZE ); } template < typename T > typename Vector< T >::ValueType Vector< T >::grow( ) { size_t old_size = m_data.size( ); m_data.resize( old_size + T::size_in_bytes( ) ); return back( ); } template < typename T > void Vector< T >::pop_back( ) { m_data.resize( m_data.size( ) - T::size_in_bytes( ) ); } template < typename T > Vector< T >::operator ArrayView< typename Vector<T>::ConstValueType >( ) const { return ArrayView< ConstValueType >( m_data.data( ), m_data.data( ) + m_data.size( ) - PADDING_SIZE ); } } // namespace flatdata
20.751479
89
0.630168
bf9cacfcdc34e518db9adccbe40d6008f5acfe31
2,045
h
C
SDK/BP_Prompt_EmissaryEncounteredAIShip_parameters.h
alxalx14/Sea-Of-Thieves-SDK
f56a0340eb33726c98fc53eb0678fa2d59aa8294
[ "MIT" ]
3
2021-03-27T08:30:37.000Z
2021-04-18T19:32:53.000Z
SDK/BP_Prompt_EmissaryEncounteredAIShip_parameters.h
alxalx14/Sea-Of-Thieves-SDK
f56a0340eb33726c98fc53eb0678fa2d59aa8294
[ "MIT" ]
null
null
null
SDK/BP_Prompt_EmissaryEncounteredAIShip_parameters.h
alxalx14/Sea-Of-Thieves-SDK
f56a0340eb33726c98fc53eb0678fa2d59aa8294
[ "MIT" ]
1
2021-06-01T03:05:50.000Z
2021-06-01T03:05:50.000Z
#pragma once // Name: SeaOfThieves, Version: 2.0.23 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.OnEmissaryEncounteredAIShip struct UBP_Prompt_EmissaryEncounteredAIShip_C_OnEmissaryEncounteredAIShip_Params { struct FEmissaryEncounteredAIShipEvent NewParam; // (Parm) }; // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.EmissaryEncounteredAIShip struct UBP_Prompt_EmissaryEncounteredAIShip_C_EmissaryEncounteredAIShip_Params { struct FEmissaryEncounteredAIShipEvent NewParam; // (Parm) }; // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.Evaluate struct UBP_Prompt_EmissaryEncounteredAIShip_C_Evaluate_Params { }; // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.RegisterOtherEvents_Implementable struct UBP_Prompt_EmissaryEncounteredAIShip_C_RegisterOtherEvents_Implementable_Params { }; // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.UnregisterOtherEvents_Implementable struct UBP_Prompt_EmissaryEncounteredAIShip_C_UnregisterOtherEvents_Implementable_Params { }; // Function BP_Prompt_EmissaryEncounteredAIShip.BP_Prompt_EmissaryEncounteredAIShip_C.ExecuteUbergraph_BP_Prompt_EmissaryEncounteredAIShip struct UBP_Prompt_EmissaryEncounteredAIShip_C_ExecuteUbergraph_BP_Prompt_EmissaryEncounteredAIShip_Params { int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData, NoDestructor) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
34.083333
167
0.713447
d71ce82fe662dc87aeabf3d63266f8372d82c5b0
23,335
c
C
cc1/gen.c
arnlig/ncc
cf879523ec0921b994f37bf856026fd319f6f951
[ "BSD-2-Clause" ]
null
null
null
cc1/gen.c
arnlig/ncc
cf879523ec0921b994f37bf856026fd319f6f951
[ "BSD-2-Clause" ]
null
null
null
cc1/gen.c
arnlig/ncc
cf879523ec0921b994f37bf856026fd319f6f951
[ "BSD-2-Clause" ]
null
null
null
/* gen.c - expression code generator ncc, the new c compiler Copyright (c) 2021 Charles E. Youse (charles@gnuless.org). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "cc1.h" #include "symbol.h" #include "target.h" #include "insn.h" #include "block.h" #include "field.h" #include "tree.h" #include "cast.h" #include "gen.h" /* given an integer leaf, generate a branch to false if it's zero, or true otherwise. */ void gen_branch(struct tree *tree, struct block *true, struct block *false) { EMIT(insn_new(I_CMP, operand_leaf(tree), operand_i(T_INT, 0, 0))); block_add_successor(current_block, CC_Z, false); block_add_successor(current_block, CC_NZ, true); } /* helper for gen_args0(): build the frame address of a variable into a temp reg, and return that. */ static pseudo_reg gen_frame(struct symbol *sym) { pseudo_reg reg; symbol_storage(sym); reg = symbol_temp_reg(target->ptr_uint); EMIT(insn_new(I_FRAME, operand_reg(target->ptr_uint, reg), operand_i(T_INT, sym->offset, 0))); return reg; } /* generate the sequence to move arguments from where they are passed by the caller to where we expect them to be. this must happen after target-independent optimization (but before target code generation) because these insns reference physical registers. for normal arguments, we transfer the value from its arrival reg or stack frame location to the appropriate pseudoregister. volatile and aliased arguments are spilled out if they arrived in registers. */ static void gen_args0(struct symbol *sym) { pseudo_reg reg; if (TYPE_STRUN(&sym->type)) /* only applies to scalars */ return; if (!SYMBOL_ALIASED(sym) && !TYPE_VOLATILE(&sym->type)) { if (sym->arg_reg != PSEUDO_REG_NONE) { EMIT(insn_new(I_MOVE, operand_reg(TYPE_BITS(&sym->type), symbol_reg(sym)), operand_reg(TYPE_BITS(&sym->type), sym->arg_reg))); } else { reg = gen_frame(sym); EMIT(insn_new(I_LOAD, operand_reg(TYPE_BITS(&sym->type), symbol_reg(sym)), operand_reg(target->ptr_uint, reg))); } } else { if (sym->arg_reg != PSEUDO_REG_NONE) { reg = gen_frame(sym); EMIT(insn_new(I_STORE, operand_reg(target->ptr_uint, reg), operand_reg(TYPE_BITS(&sym->type), sym->arg_reg))); } } } void gen_args(void) { struct cessor *succ; succ = block_always_successor(entry_block); current_block = block_split_edge(entry_block, succ); scope_walk_args(gen_args0); } /* gen_load and gen_store wrap the generation of all I_LOAD/I_STOREs to ensure that accesses through volatile pointers are so marked */ static void gen_load(struct symbol *dst, struct tree *ptr) { struct insn *insn; insn = insn_new(I_LOAD, operand_sym(dst), operand_leaf(ptr)); if (TYPE_VOLATILE_PTR(&ptr->type)) insn->flags |= INSN_FLAG_VOLATILE; EMIT(insn); } static void gen_store(struct tree *ptr, struct tree *src) { struct insn *insn; insn = insn_new(I_STORE, operand_leaf(ptr), operand_leaf(src)); if (TYPE_VOLATILE_PTR(&ptr->type)) insn->flags |= INSN_FLAG_VOLATILE; EMIT(insn); } /* an E_ADDROF can ultimately only have E_SYM children, and only E_SYMs that refer to stack-allocated variables. the front-end will generate E_ADDROF with an E_CALL child in the case of a function that returns a struct; we must call gen() on the child because of this case, but it reduces to the E_SYM of the local temporary. other semantically-possible children of E_ADDROF - global/static E_SYMs and E_FETCH - are eliminated by tree_addrof() during construction. */ static struct tree *gen_addrof(struct tree *tree) { struct symbol *sym; struct symbol *temp; tree->child = gen(tree->child, 0); temp = symbol_temp(&tree->type); sym = tree->child->sym; symbol_storage(sym); if (sym->ss & S_LOCAL) { sym->ss &= ~S_LOCAL; sym->ss |= S_AUTO; } EMIT(insn_new(I_FRAME, operand_sym(temp), operand_i(T_INT, sym->offset, 0))); tree_free(tree); return tree_sym(temp); } /* block assignment is simple, since the hard work is done by the back ends. */ static struct tree *gen_blkasg(struct tree *tree) { size_t bytes; tree->left = gen(tree->left, 0); tree->right = gen(tree->right, 0); bytes = type_sizeof(&tree->type, TYPE_SIZEOF_TARGET); EMIT(insn_new(I_BLKCOPY, operand_leaf(tree->left), operand_leaf(tree->right), operand_i(target->ptr_uint, bytes, 0))); tree = tree_chop_binary(tree); return tree; } /* extract the bitfield of the given size and shift in sym back into sym. there are better sequences than shift-shift in some special cases (e.g., an unsigned field at offset 0 can simply be masked off) but we'll deal with that later. */ static void extract(struct symbol *sym, int size, int shift) { int host_bits; int left_shift; int right_shift; host_bits = type_sizeof(&sym->type, 0); host_bits *= BITS_PER_BYTE; left_shift = host_bits - (size + shift); right_shift = host_bits - size; EMIT(insn_new(I_SHL, operand_sym(sym), operand_sym(sym), operand_i(T_INT, left_shift, 0))); EMIT(insn_new(I_SHR, operand_sym(sym), operand_sym(sym), operand_i(T_INT, right_shift, 0))); } /* process an E_FETCH. this is usually a simple issue of a load to a temporary, but there are two wrinkles: bit field fetches must have their values extracted, and fetches of struct types are no-ops (yielding void trees). if mode is GEN_FETCH_RETAIN, the original tree is not tossed: gen_compound() needs to keep its left-hand side intact for gen_asg(). (a bit of a hack.) */ typedef int gen_fetch_mode; /* GEN_FETCH_* */ #define GEN_FETCH_NORMAL 0 #define GEN_FETCH_RETAIN 1 static struct tree *gen_fetch(struct tree *tree, gen_fetch_mode mode) { struct symbol *temp; temp = 0; tree->child = gen(tree->child, 0); if (!TYPE_STRUN(&tree->type)) { temp = symbol_temp(&tree->type); gen_load(temp, tree->child); if (TYPE_FIELD_PTR(&tree->child->type)) extract(temp, TYPE_FIELD_PTR_SIZE(&tree->child->type), TYPE_FIELD_PTR_SHIFT(&tree->child->type)); } if (mode != GEN_FETCH_RETAIN) tree_free(tree); if (temp) return tree_sym(temp); else return tree_v(); } /* a bitfield (described by size and shift) with the given value must be inserted into the word at ptr. this function does the loading/masking/shifting and rewrites the value tree so the caller can do the store. just as with extract(), there is some improvement to be made here. optimizing bitfield manipulation is not high on the list, but this should be revisited at some point, once it becomes clear what later passes can't improve. this function relies on the compiler implementation to shift in zeros from the left when right-shifting unsigned values. */ static struct tree *insert(struct tree *ptr, struct tree *value, int size, int shift) { struct symbol *new; struct symbol *shifted; unsigned long mask; unsigned long mask_mask; int host_bits; host_bits = type_sizeof(&value->type, 0); host_bits *= BITS_PER_BYTE; mask_mask = -1L; mask_mask >>= (sizeof(mask) * BITS_PER_BYTE) - host_bits; mask = field_mask(size, shift); new = symbol_temp(&value->type); shifted = symbol_temp(&value->type); EMIT(insn_new(I_SHL, operand_sym(shifted), operand_leaf(value), operand_i(T_INT, shift, 0))); EMIT(insn_new(I_AND, operand_sym(shifted), operand_sym(shifted), operand_i(TYPE_BASE(&value->type), mask, 0))); mask = ~mask; mask &= mask_mask; gen_load(new, ptr); EMIT(insn_new(I_AND, operand_sym(new), operand_sym(new), operand_i(TYPE_BASE(&value->type), mask, 0))); EMIT(insn_new(I_OR, operand_sym(new), operand_sym(new), operand_sym(shifted))); tree_free(value); return tree_sym(new); } /* handle scalar assignments. like gen_fetch(), we must handle the messy details of bitfields (and they're even worse for stores). this function is not just for E_ASG trees, but is a helper for gen_compound(), which adjusts the right side first. the value of an assignment operation is the value of the left operand after assignment; we yield the value of the right side instead, which we've already computed into a leaf anyway. this means we need to fix up the right when bitfields are involved, but avoids issuing a spurious load when the left-hand-side is an E_FETCH through a volatile pointer: such a load could not be optimized out (as it is marked INSN_FLAG_VOLATILE) and is not correct behavior (imagine the target is a hardware register). */ static struct tree *gen_asg(struct tree *tree) { struct symbol *temp; tree->right = gen(tree->right, 0); if (tree->left->op == E_FETCH) { tree->left->child = gen(tree->left->child, 0); if (TYPE_FIELD_PTR(&tree->left->child->type)) tree->right = insert(tree->left->child, tree->right, TYPE_FIELD_PTR_SIZE(&tree->left->child->type), TYPE_FIELD_PTR_SHIFT(&tree->left->child->type)); gen_store(tree->left->child, tree->right); if (TYPE_FIELD_PTR(&tree->left->child->type)) { temp = symbol_temp(&tree->right->type); EMIT(insn_new(I_MOVE, operand_sym(temp), operand_leaf(tree->right))); extract(temp, TYPE_FIELD_PTR_SIZE(&tree->left->child->type), TYPE_FIELD_PTR_SHIFT(&tree->left->child->type)); tree_free(tree->right); tree->right = tree_sym(temp); } } else { EMIT(insn_new(I_MOVE, operand_leaf(tree->left), operand_leaf(tree->right))); } tree_commute(tree); tree = tree_chop_binary(tree); return gen(tree, 0); } /* there are two special cases to look out for with casts: 1. casts to void: no-op, but convert to void nodes 2. discrete downcasts: since the values do not change (we merely disregard the upper bits), we emit I_MOVE insns instead of I_CASTs, taking care to rewrite the source type, since src/dst must have the same type. */ static struct tree *gen_cast(struct tree *tree) { struct insn *insn; struct symbol *temp; tree->child = gen(tree->child, 0); if (TYPE_VOID(&tree->type)) { tree_free(tree); return tree_v(); } else { temp = symbol_temp(&tree->type); if (TYPE_DISCRETE(&tree->type) && cast_narrow(tree)) { insn = insn_new(I_MOVE, operand_sym(temp), operand_leaf(tree->child)); insn->src1->ts = insn->dst->ts; EMIT(insn); } else EMIT(insn_new(I_CAST, operand_sym(temp), operand_leaf(tree->child))); tree_free(tree); return tree_sym(temp); } } /* unary and binary operators are trivial: map a tree_op to an insn_op, calculate into a temporary and return that. */ static struct tree *gen_unary(struct tree *tree) { struct symbol *temp; insn_op op; op = (tree->op == E_NEG) ? I_NEG : I_COM; tree->child = gen(tree->child, 0); temp = symbol_temp(&tree->type); EMIT(insn_new(op, operand_sym(temp), operand_leaf(tree->child))); tree_free(tree); return tree_sym(temp); } static insn_op bin[] = /* must match E_BIN_* in tree.h */ { I_XOR, I_DIV, I_MUL, I_ADD, I_SUB, I_SHR, I_SHL, I_AND, I_OR, I_MOD }; static struct tree *gen_binary(struct tree *tree) { struct symbol *temp; tree->left = gen(tree->left, 0); tree->right = gen(tree->right, 0); temp = symbol_temp(&tree->type); EMIT(insn_new(bin[E_BIN_IDX(tree->op)], operand_sym(temp), operand_leaf(tree->left), operand_leaf(tree->right))); tree_free(tree); return tree_sym(temp); } /* compound operators are somewhat tricky, for two reasons. first, the left side can only be evaluated once, necessitating the dirty hack to gen_fetch(). secondly, in the case of E_POST, our result is the value before the operation took place, rather than after. luckily, we can pawn off the bitfield chaos to gen_fetch() and gen_asg(). */ static struct tree *gen_compound(struct tree *tree) { struct tree *temp; struct tree *orig; int post; post = (tree->op == E_POST); orig = tree_sym(symbol_temp(&tree->type)); tree->right = gen(tree->right, 0); if (tree->left->op == E_SYM) { EMIT(insn_new(I_MOVE, operand_leaf(orig), operand_leaf(tree->left))); EMIT(insn_new(bin[E_BIN_IDX(tree->op)], operand_leaf(tree->left), operand_leaf(tree->left), operand_leaf(tree->right))); tree = tree_chop_binary(tree); } else { temp = gen_fetch(tree->left, GEN_FETCH_RETAIN); EMIT(insn_new(I_MOVE, operand_leaf(orig), operand_leaf(temp))); EMIT(insn_new(bin[E_BIN_IDX(tree->op)], operand_leaf(temp), operand_leaf(temp), operand_leaf(tree->right))); tree_free(tree->right); tree->right = temp; tree = gen_asg(tree); } if (post) { tree_free(tree); return orig; } else { tree_free(orig); return tree; } } /* the real work in the relational operators is determining which condition_codes correspond to the relation in question. */ static struct tree *gen_rel(struct tree *tree) { struct symbol *temp; condition_code cc; temp = symbol_temp(&tree->type); tree->left = gen(tree->left, 0); tree->right = gen(tree->right, 0); EMIT(insn_new(I_CMP, operand_leaf(tree->left), operand_leaf(tree->right))); switch (tree->op) { case E_EQ: cc = CC_Z; break; case E_NEQ: cc = CC_NZ; break; case E_GT: cc = (TYPE_SIGNED(&tree->left->type)) ? CC_G : CC_A; break; case E_LT: cc = (TYPE_SIGNED(&tree->left->type)) ? CC_L : CC_B; break; case E_GTEQ: cc = (TYPE_SIGNED(&tree->left->type)) ? CC_GE : CC_AE; break; case E_LTEQ: cc = (TYPE_SIGNED(&tree->left->type)) ? CC_LE : CC_BE; break; } EMIT(insn_new(I_SET_CC_FROM_CC(cc), operand_sym(temp))); tree_free(tree); return tree_sym(temp); } /* we don't have enough context to do a good job with the logical operators. what we emit here is a big mess that is (hopefully) optimized down to something sane. */ static struct tree *gen_log(struct tree *tree) { struct symbol *temp; struct block *right_block; struct block *true_block; struct block *false_block; struct block *join_block; temp = symbol_temp(&tree->type); right_block = block_new(); true_block = block_new(); false_block = block_new(); join_block = block_new(); BLOCK_APPEND_INSN(true_block, insn_new(I_MOVE, operand_sym(temp), operand_i(T_INT, 1, 0))); BLOCK_APPEND_INSN(false_block, insn_new(I_MOVE, operand_sym(temp), operand_i(T_INT, 0, 0))); block_add_successor(true_block, CC_ALWAYS, join_block); block_add_successor(false_block, CC_ALWAYS, join_block); tree->left = gen(tree->left, 0); if (tree->op == E_LOR) gen_branch(tree->left, true_block, right_block); else gen_branch(tree->left, right_block, false_block); current_block = right_block; tree->right = gen(tree->right, 0); gen_branch(tree->right, true_block, false_block); current_block = join_block; tree_free(tree); return tree_sym(temp); } /* like the logical operators, the output for the conditional operator is convoluted, but the optimizer will clean it up. */ static struct tree *gen_quest(struct tree *tree) { struct symbol *temp; struct block *true_block; struct block *false_block; struct block *join_block; if (TYPE_VOID(&tree->type)) temp = 0; else temp = symbol_temp(&tree->type); true_block = block_new(); false_block = block_new(); join_block = block_new(); tree->left = gen(tree->left, 0); gen_branch(tree->left, true_block, false_block); current_block = true_block; tree->right->left = gen(tree->right->left, 0); if (temp) EMIT(insn_new(I_MOVE, operand_sym(temp), operand_leaf(tree->right->left))); block_add_successor(current_block, CC_ALWAYS, join_block); current_block = false_block; tree->right->right = gen(tree->right->right, 0); if (temp) EMIT(insn_new(I_MOVE, operand_sym(temp), operand_leaf(tree->right->right))); block_add_successor(current_block, CC_ALWAYS, join_block); current_block = join_block; tree_free(tree); return temp ? tree_sym(temp) : tree_v(); } /* commas are easy: just evaluate them in the right order. */ static struct tree *gen_comma(struct tree *tree) { tree->left = gen(tree->left, 0); tree_commute(tree); tree = tree_chop_binary(tree); return gen(tree, 0); } /* generating calls has some complexity because of struct arguments, and because we need to keep the I_ARGUMENTs contiguous with the I_CALL. */ static struct tree *gen_call(struct tree *tree) { struct insns arg_insns; struct insn *call_insn; struct symbol *temp; struct tree *arg_tree; struct tree *ret_tree; size_t bytes; insn_op arg_op; INSNS_INIT(&arg_insns); tree->child = gen(tree->child, 0); arg_op = TYPE_VARIADIC_FUNC_PTR(&tree->child->type) ? I_VARG : I_ARG; if (TYPE_VOID(&tree->type)) ret_tree = tree_v(); else { temp = symbol_temp(&tree->type); ret_tree = tree_sym(temp); } if (TYPE_STRUN(&tree->type)) { arg_tree = tree_sym(temp); arg_tree = tree_addrof(arg_tree); FOREST_PREPEND(&tree->args, arg_tree); } while (arg_tree = FOREST_LAST(&tree->args)) { FOREST_REMOVE(&tree->args, arg_tree); if (TYPE_STRUN(&arg_tree->type)) { bytes = type_sizeof(&arg_tree->type, 0); arg_tree = tree_addrof(arg_tree); arg_tree = gen(arg_tree, 0); insn_prepend(&arg_insns, insn_new(I_BLKARG, operand_leaf(arg_tree), operand_i(target->ptr_uint, bytes, 0))); } else { arg_tree = gen(arg_tree, 0); insn_prepend(&arg_insns, insn_new(arg_op, operand_leaf(arg_tree))); } tree_free(arg_tree); } if (TYPE_VOID(&tree->type) || TYPE_STRUN(&tree->type)) EMIT(call_insn = insn_new(I_CALL, 0, operand_leaf(tree->child))); else EMIT(call_insn = insn_new(I_CALL, operand_sym(temp), operand_leaf(tree->child))); insns_insert_before(&current_block->insns, call_insn, &arg_insns); tree_free(tree); return ret_tree; } /* expression tree code generation: given a tree, reduce it to a leaf: E_NONE, E_CON or E_SYM. */ struct tree *gen(struct tree *tree, gen_flags flags) { if (flags & GEN_FLAG_ROOT) { tree = tree_rewrite_volatile(tree); tree = tree_opt(tree); tree = tree_simplify(tree); if (debug_flag_e) tree_debug(tree, 0); } switch (tree->op) { case E_ADDROF: tree = gen_addrof(tree); break; case E_BLKASG: tree = gen_blkasg(tree); break; case E_CAST: tree = gen_cast(tree); break; case E_FETCH: tree = gen_fetch(tree, GEN_FETCH_NORMAL); break; case E_QUEST: tree = gen_quest(tree); break; case E_COMMA: tree = gen_comma(tree); break; case E_CALL: tree = gen_call(tree); break; case E_CON: case E_NONE: case E_SYM: break; case E_NEG: case E_COM: tree = gen_unary(tree); break; case E_ADD: case E_SUB: case E_MUL: case E_DIV: case E_MOD: case E_AND: case E_OR: case E_XOR: case E_SHR: case E_SHL: tree = gen_binary(tree); break; case E_ASG: tree = gen_asg(tree); break; case E_ADDASG: case E_SUBASG: case E_MULASG: case E_DIVASG: case E_MODASG: case E_ANDASG: case E_ORASG: case E_XORASG: case E_SHRASG: case E_SHLASG: case E_POST: tree = gen_compound(tree); break; case E_GT: case E_GTEQ: case E_LT: case E_LTEQ: case E_EQ: case E_NEQ: tree = gen_rel(tree); break; case E_LOR: case E_LAND: tree = gen_log(tree); break; } if (flags & GEN_FLAG_DISCARD) { tree_free(tree); return 0; } else return tree; } /* vi: set ts=4 expandtab: */
30.825627
79
0.619113
d54a535cd2b63c00c729d196a10facc215d0d9bf
689
h
C
SVEngine/src/operate/SVOpDetect.h
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
34
2018-09-28T08:28:27.000Z
2022-01-15T10:31:41.000Z
SVEngine/src/operate/SVOpDetect.h
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
null
null
null
SVEngine/src/operate/SVOpDetect.h
SVEChina/SVEngine
56174f479a3096e57165448142c1822e7db8c02f
[ "MIT" ]
8
2018-10-11T13:36:35.000Z
2021-04-01T09:29:34.000Z
// // SVOpDetect.h // SVEngine // Copyright 2017-2020 // yizhou Fu,long Yin,longfei Lin,ziyu Xu,xiaofan Li,daming Li // #ifndef SV_OPERATEDETECT_H #define SV_OPERATEDETECT_H #include "SVOpBase.h" #include "../base/SVDatatDef.h" namespace sv { // class SVOpOpenDetect : public SVOpBase { public: SVOpOpenDetect(SVInst *_app, s32 detecttype); protected: void _process(f32 dt); DETECTTYPE m_detectType; }; class SVOpCloseDetect : public SVOpBase { public: SVOpCloseDetect(SVInst *_app); protected: void _process(f32 dt); }; }//!namespace sv #endif //SV_OPERATEDETECT_H
17.666667
62
0.624093
846b8d4f5301f2ab8482935cdf402b5edf2f97f6
981
h
C
Source/DawnNetworkService/stdafx.h
XDApp/DawnNetworkService
1516244fd91998b60ed59282b2b55c0c6b80f79f
[ "MIT" ]
1
2015-06-21T08:04:32.000Z
2015-06-21T08:04:32.000Z
Source/DawnNetworkService/stdafx.h
XDApp/DawnNetworkService
1516244fd91998b60ed59282b2b55c0c6b80f79f
[ "MIT" ]
null
null
null
Source/DawnNetworkService/stdafx.h
XDApp/DawnNetworkService
1516244fd91998b60ed59282b2b55c0c6b80f79f
[ "MIT" ]
null
null
null
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include <stdio.h> #include <stdlib.h> #include <tchar.h> #include <string.h> #include <time.h> #include <winsock2.h> #pragma comment(lib, "WS2_32.lib") #include <iostream> #include <string> #include <thread> #include <mutex> #include <map> #include <cmath> #include <vector> // TODO: reference additional headers your program requires here #include <openssl/rsa.h> #include <openssl/err.h> #include <openssl/pem.h> #include <openssl/x509.h> #include <openssl/rand.h> #include <openssl/evp.h> #include <openssl/engine.h> #include <rapidjson/document.h> #include <rapidjson/prettywriter.h> #include <rapidjson/filereadstream.h> #include <rapidjson/filewritestream.h> #include <rapidjson/stringbuffer.h> #pragma comment(lib, "libeay32.lib") #pragma comment(lib, "ssleay32.lib")
22.295455
66
0.7421
41984b61e76ecb20fa3f16b99f23b9611e4bc3e9
6,800
c
C
z2/part1/jm/random/682193403.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
1
2020-04-16T12:13:47.000Z
2020-04-16T12:13:47.000Z
z2/part1/jm/random/682193403.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
18
2020-03-06T17:50:15.000Z
2020-05-19T14:58:30.000Z
z2/part1/jm/random/682193403.c
kozakusek/ipp-2020-testy
09aa008fa53d159672cc7cbf969a6b237e15a7b8
[ "MIT" ]
18
2020-03-06T17:45:13.000Z
2020-06-09T19:18:31.000Z
#include <stdint.h> #include <stdlib.h> #include <assert.h> #include <stdio.h> #include "gamma.h" #include <stdbool.h> #include <string.h> int main() { /* scenario: test_random_actions uuid: 682193403 */ /* random actions, total chaos */ gamma_t* board = gamma_new(5, 7, 6, 6); assert( board != NULL ); assert( gamma_move(board, 1, 2, 4) == 1 ); assert( gamma_move(board, 2, 2, 3) == 1 ); assert( gamma_move(board, 2, 4, 6) == 1 ); assert( gamma_move(board, 3, 1, 3) == 1 ); assert( gamma_move(board, 4, 1, 4) == 1 ); assert( gamma_move(board, 4, 4, 3) == 1 ); assert( gamma_move(board, 5, 5, 4) == 0 ); assert( gamma_move(board, 5, 3, 5) == 1 ); assert( gamma_move(board, 6, 0, 5) == 1 ); assert( gamma_free_fields(board, 6) == 27 ); assert( gamma_move(board, 1, 4, 3) == 0 ); assert( gamma_move(board, 2, 0, 4) == 1 ); assert( gamma_move(board, 2, 1, 0) == 1 ); assert( gamma_move(board, 3, 2, 4) == 0 ); assert( gamma_move(board, 3, 2, 5) == 1 ); assert( gamma_move(board, 4, 3, 0) == 1 ); assert( gamma_move(board, 4, 1, 6) == 1 ); assert( gamma_move(board, 5, 1, 5) == 1 ); assert( gamma_move(board, 5, 4, 6) == 0 ); char* board432044714 = gamma_board(board); assert( board432044714 != NULL ); assert( strcmp(board432044714, ".4..2\n" "6535.\n" "241..\n" ".32.4\n" ".....\n" ".....\n" ".2.4.\n") == 0); free(board432044714); board432044714 = NULL; assert( gamma_move(board, 6, 0, 3) == 1 ); assert( gamma_move(board, 6, 2, 3) == 0 ); assert( gamma_move(board, 2, 4, 3) == 0 ); assert( gamma_move(board, 3, 2, 2) == 1 ); assert( gamma_move(board, 4, 6, 2) == 0 ); assert( gamma_golden_possible(board, 4) == 1 ); assert( gamma_move(board, 5, 3, 6) == 1 ); assert( gamma_move(board, 5, 1, 1) == 1 ); assert( gamma_move(board, 6, 2, 3) == 0 ); assert( gamma_golden_move(board, 6, 4, 1) == 0 ); assert( gamma_move(board, 1, 2, 1) == 1 ); assert( gamma_golden_possible(board, 1) == 1 ); char* board560963792 = gamma_board(board); assert( board560963792 != NULL ); assert( strcmp(board560963792, ".4.52\n" "6535.\n" "241..\n" "632.4\n" "..3..\n" ".51..\n" ".2.4.\n") == 0); free(board560963792); board560963792 = NULL; assert( gamma_move(board, 4, 2, 1) == 0 ); assert( gamma_move(board, 4, 1, 5) == 0 ); assert( gamma_busy_fields(board, 4) == 4 ); char* board808743617 = gamma_board(board); assert( board808743617 != NULL ); assert( strcmp(board808743617, ".4.52\n" "6535.\n" "241..\n" "632.4\n" "..3..\n" ".51..\n" ".2.4.\n") == 0); free(board808743617); board808743617 = NULL; assert( gamma_move(board, 5, 1, 1) == 0 ); assert( gamma_move(board, 5, 1, 3) == 0 ); assert( gamma_move(board, 6, 3, 6) == 0 ); assert( gamma_move(board, 6, 2, 0) == 1 ); assert( gamma_move(board, 1, 2, 3) == 0 ); assert( gamma_move(board, 1, 2, 2) == 0 ); assert( gamma_golden_possible(board, 1) == 1 ); assert( gamma_move(board, 2, 2, 4) == 0 ); assert( gamma_move(board, 2, 2, 0) == 0 ); assert( gamma_move(board, 3, 3, 3) == 1 ); char* board435156127 = gamma_board(board); assert( board435156127 != NULL ); assert( strcmp(board435156127, ".4.52\n" "6535.\n" "241..\n" "63234\n" "..3..\n" ".51..\n" ".264.\n") == 0); free(board435156127); board435156127 = NULL; assert( gamma_move(board, 4, 2, 1) == 0 ); assert( gamma_move(board, 4, 3, 0) == 0 ); assert( gamma_move(board, 5, 0, 4) == 0 ); assert( gamma_move(board, 6, 3, 6) == 0 ); assert( gamma_move(board, 1, 3, 3) == 0 ); assert( gamma_busy_fields(board, 1) == 2 ); assert( gamma_move(board, 2, 0, 4) == 0 ); assert( gamma_move(board, 3, 2, 1) == 0 ); assert( gamma_move(board, 3, 0, 3) == 0 ); assert( gamma_move(board, 4, 1, 3) == 0 ); assert( gamma_move(board, 5, 2, 1) == 0 ); assert( gamma_move(board, 5, 2, 2) == 0 ); assert( gamma_move(board, 6, 0, 0) == 1 ); assert( gamma_move(board, 6, 4, 5) == 1 ); assert( gamma_move(board, 1, 4, 3) == 0 ); assert( gamma_move(board, 1, 1, 4) == 0 ); assert( gamma_move(board, 2, 2, 3) == 0 ); assert( gamma_move(board, 2, 3, 5) == 0 ); assert( gamma_move(board, 3, 4, 3) == 0 ); assert( gamma_move(board, 3, 3, 5) == 0 ); assert( gamma_busy_fields(board, 3) == 4 ); assert( gamma_move(board, 4, 4, 1) == 1 ); assert( gamma_move(board, 4, 0, 3) == 0 ); assert( gamma_move(board, 5, 1, 0) == 0 ); assert( gamma_move(board, 6, 3, 1) == 1 ); assert( gamma_golden_possible(board, 6) == 1 ); assert( gamma_move(board, 1, 2, 1) == 0 ); assert( gamma_move(board, 1, 2, 3) == 0 ); char* board988126217 = gamma_board(board); assert( board988126217 != NULL ); assert( strcmp(board988126217, ".4.52\n" "65356\n" "241..\n" "63234\n" "..3..\n" ".5164\n" "6264.\n") == 0); free(board988126217); board988126217 = NULL; assert( gamma_move(board, 3, 4, 4) == 1 ); assert( gamma_move(board, 3, 4, 5) == 0 ); assert( gamma_move(board, 4, 6, 0) == 0 ); assert( gamma_move(board, 5, 2, 3) == 0 ); assert( gamma_move(board, 5, 2, 3) == 0 ); assert( gamma_golden_move(board, 5, 1, 2) == 0 ); assert( gamma_move(board, 6, 1, 0) == 0 ); assert( gamma_move(board, 1, 4, 3) == 0 ); assert( gamma_move(board, 2, 2, 0) == 0 ); assert( gamma_move(board, 2, 3, 5) == 0 ); assert( gamma_move(board, 3, 4, 5) == 0 ); assert( gamma_free_fields(board, 3) == 9 ); assert( gamma_move(board, 4, 0, 4) == 0 ); assert( gamma_move(board, 4, 3, 3) == 0 ); assert( gamma_move(board, 5, 0, 4) == 0 ); assert( gamma_busy_fields(board, 5) == 4 ); assert( gamma_move(board, 1, 0, 1) == 1 ); assert( gamma_golden_move(board, 1, 3, 4) == 0 ); assert( gamma_move(board, 2, 0, 4) == 0 ); assert( gamma_move(board, 2, 4, 2) == 1 ); assert( gamma_move(board, 3, 2, 0) == 0 ); assert( gamma_move(board, 3, 4, 0) == 1 ); assert( gamma_move(board, 4, 4, 3) == 0 ); assert( gamma_move(board, 5, 6, 2) == 0 ); assert( gamma_move(board, 5, 2, 4) == 0 ); assert( gamma_golden_possible(board, 5) == 1 ); assert( gamma_move(board, 6, 4, 5) == 0 ); assert( gamma_move(board, 6, 0, 5) == 0 ); assert( gamma_move(board, 1, 4, 3) == 0 ); assert( gamma_busy_fields(board, 1) == 3 ); assert( gamma_move(board, 2, 4, 3) == 0 ); assert( gamma_move(board, 2, 0, 6) == 1 ); assert( gamma_free_fields(board, 2) == 1 ); assert( gamma_move(board, 3, 6, 2) == 0 ); assert( gamma_move(board, 3, 4, 0) == 0 ); assert( gamma_golden_possible(board, 4) == 1 ); assert( gamma_move(board, 5, 2, 6) == 1 ); assert( gamma_move(board, 1, 2, 0) == 0 ); assert( gamma_move(board, 1, 1, 6) == 0 ); assert( gamma_move(board, 2, 0, 6) == 0 ); assert( gamma_move(board, 2, 4, 3) == 0 ); char* board851624349 = gamma_board(board); assert( board851624349 != NULL ); assert( strcmp(board851624349, "24552\n" "65356\n" "241.3\n" "63234\n" "..3.2\n" "15164\n" "62643\n") == 0); free(board851624349); board851624349 = NULL; assert( gamma_move(board, 3, 2, 3) == 0 ); assert( gamma_move(board, 3, 4, 0) == 0 ); assert( gamma_move(board, 4, 2, 3) == 0 ); gamma_delete(board); return 0; }
29.694323
49
0.609412
5769ac908f1a24bf42812bd6094713733128f4a3
888
h
C
bag-library/src/bag_circular_buffer.h
Devdevdavid/ProceXeirb
4fbda8d479b25ea0d0af8f1dd362bb28e50b5d03
[ "MIT" ]
null
null
null
bag-library/src/bag_circular_buffer.h
Devdevdavid/ProceXeirb
4fbda8d479b25ea0d0af8f1dd362bb28e50b5d03
[ "MIT" ]
null
null
null
bag-library/src/bag_circular_buffer.h
Devdevdavid/ProceXeirb
4fbda8d479b25ea0d0af8f1dd362bb28e50b5d03
[ "MIT" ]
null
null
null
/* * circular_buffer.h * * Created on: May 16, 2018 * Author: David */ #ifndef SRC_BAG_CIRCULAR_BUFFER_H_ #define SRC_BAG_CIRCULAR_BUFFER_H_ #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include "bag_devlib.h" struct circ_buff_t { uint8_t *pBuffStart; uint8_t *pHeadRead; uint8_t *pHeadWrite; uint8_t *pBuffEnd; uint16_t length; uint16_t buffSize; }; void circ_buff_init(struct circ_buff_t *buff, uint8_t *buffAddr, uint16_t buffSize); void circ_buff_clear(struct circ_buff_t *buff); int8_t circ_buff_write(struct circ_buff_t *buff, uint8_t *pData, uint16_t len); int8_t circ_buff_write_byte(struct circ_buff_t *buff, uint8_t data); uint16_t circ_buff_read(struct circ_buff_t *buff, uint8_t *pData, uint16_t len); uint8_t circ_buff_read_byte(struct circ_buff_t *buff); #endif /* SRC_BAG_CIRCULAR_BUFFER_H_ */
24
84
0.772523
b61963f3aa74f31e881c7091b71431dd4d7fe358
15,959
c
C
lib/RK/fq.c
hashimom/Izumo
0b6114220a2a5316fa8afa5f38fb3a75af13f17d
[ "MIT" ]
4
2015-01-05T01:46:39.000Z
2019-01-01T15:16:39.000Z
lib/RK/fq.c
hashimom/Izumo
0b6114220a2a5316fa8afa5f38fb3a75af13f17d
[ "MIT" ]
null
null
null
lib/RK/fq.c
hashimom/Izumo
0b6114220a2a5316fa8afa5f38fb3a75af13f17d
[ "MIT" ]
null
null
null
/* Copyright 1994 NEC Corporation, Tokyo, Japan. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of NEC * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior * permission. NEC Corporation makes no representations about the * suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #if !defined(lint) && !defined(__CODECENTER__) static char rcsid[]="$Id: fq.c,v 1.6 2003/09/17 08:50:52 aida_s Exp $"; #endif #include "RKintern.h" #ifdef __CYGWIN32__ #include <fcntl.h> /* for O_BINARY */ #endif #define dm_xdm dm_extdata.ptr struct xqm { off_t ex_boff; long ex_bsiz; }; struct RUT * allocRUT(hn) unsigned long hn; { struct RUT *tempo; if (!(tempo = (struct RUT *)calloc(1, sizeof(struct RUT)))) return((struct RUT *) 0); if (!(tempo->dp = (struct CTdata **)calloc((size_t) hn, sizeof(struct CTdata *)))){ free(tempo); return((struct RUT *) 0); } return tempo; } static int WrToRut(ruc, csn, tick) struct RUT *ruc; unsigned long csn, tick; { unsigned long whn; struct CTdata *wd, **pwd; whn = HashFunc(csn); for (pwd = ruc->dp+whn, wd = *pwd ; wd; pwd = &wd->next, wd = *pwd) { if (wd->ct[0] == csn) { WriteCT(csn, tick, wd->ct); return 0; } } if (!(wd = (struct CTdata *)calloc(1, sizeof(struct CTdata)))) return -1; *pwd = wd; WriteCT(csn, tick, wd->ct); return 1; } static unsigned long UpdateFrst(ruc) struct RUT *ruc; { unsigned long wmin, wtick, frst, lc; struct CTdata *wd; wmin = 0xffffffffL; frst = 0xfffffL; for (lc = 0; lc < HN; lc++) { for (wd = *(ruc->dp+lc) ; wd; wd = wd->next) { if (wmin > (wtick = wd->ct[1])) { frst = wd->ct[0]; wmin = wtick; } } } if(frst == (unsigned long) 0xffffffff) return (unsigned long) 0L; return frst; } static int deleteCT(ruc, csn) struct RUT *ruc; unsigned long csn; { unsigned long whn; struct CTdata *wd, **pre; whn = HashFunc(csn); for (pre = ruc->dp+whn, wd = *pre; ; pre = &wd->next, wd = *pre){ if (!wd) return 0; if (wd->ct[0] == csn) break; } *pre = wd->next; free(wd); return 1; } unsigned long searchRut(ruc, csn) struct RUT *ruc; unsigned long csn; { unsigned long whn; struct CTdata *wd; whn = HashFunc(csn); for (wd = *(ruc->dp+whn) ; wd; wd = wd->next) { if (wd->ct[0] == csn) return wd->ct[1]; } return (unsigned long) 0L; } static struct CTdata * searchCTadd(ruc, csn) struct RUT *ruc; unsigned long csn; { unsigned long whn; struct CTdata *wd; whn = HashFunc(csn); for (wd = *(ruc->dp+whn) ; wd; wd = wd->next) { if (wd->ct[0] == csn) return wd; } return (struct CTdata *) 0; } int entryRut(ruc, csn, tick) struct RUT *ruc; unsigned long csn, tick; { struct CTdata *wpadd; int retval; retval = 1; if (ruc->cs < ruc->sz) switch (WrToRut(ruc, csn, tick)) { case 0: break; case 1: if (++(ruc->cs) == ruc->sz) ruc->frst = UpdateFrst(ruc); break; case -1: return (int) 0; } else { wpadd = searchCTadd(ruc, csn); if (wpadd) { WriteCT(csn, tick, wpadd->ct); if (csn == ruc->frst) ruc->frst = UpdateFrst(ruc); } else { if (deleteCT(ruc, ruc->frst)){ if (WrToRut(ruc, csn, tick) < 0){ ruc->cs -= 1L; retval = 0; } } else retval = 0; ruc->frst = UpdateFrst(ruc); } } return retval; } static struct WRT * allocWRT(size) unsigned long size; { struct WRT *tempo; if (!(tempo = (struct WRT *)calloc(1, sizeof(struct WRT)))) return((struct WRT *) 0); if (!(tempo->buf = (unsigned char *)calloc(1, (int) 5*size))){ free(tempo); return((struct WRT *) 0); } tempo->sz = size; return tempo; } static struct WRT * readWRT(fr) int fr; { unsigned long wsz, wcs, wfrst, wtm; unsigned char ll[4]; struct WRT *wrt; if (read(fr, (char *)ll, 4) != 4) return (struct WRT *) 0; wsz = (unsigned long) bst4_to_l(ll); if (read(fr, (char *)ll, 4) != 4) return (struct WRT *) 0; wcs = (unsigned long) bst4_to_l(ll); if (read(fr, (char *)ll, 4) != 4) return (struct WRT *) 0; wfrst = (unsigned long) bst4_to_l(ll); if (read(fr, (char *)ll, 4) != 4) return (struct WRT *) 0; wtm = (unsigned long) bst4_to_l(ll); if (!(wrt = allocWRT(wsz))) return (struct WRT *) 0; wrt->cs = wcs; wrt->frst = wfrst; wrt->tm = wtm; if (wsz) { if (read(fr, wrt->buf, (unsigned) 5*wsz) != 5*(int)wsz) { freeWRT(wrt); return (struct WRT *) 0; } } return wrt; } static int writeToWRT pro((int, struct WRT *)); static int writeToWRT(fr, wrt) int fr; struct WRT *wrt; { unsigned char ll[4]; l_to_bst4(wrt->sz, ll); if (write(fr, (char *)ll, 4) != 4) return 0; l_to_bst4(wrt->cs, ll); if (write(fr, (char *)ll, 4) != 4) return 0; l_to_bst4(wrt->frst, ll); if (write(fr, (char *)ll, 4) != 4) return 0; l_to_bst4(wrt->tm, ll); if (write(fr, (char *)ll, 4) != 4) return 0; if (wrt->sz) { if (write(fr, wrt->buf, (unsigned) 5*wrt->sz) != 5*(int)wrt->sz) return 0; } return 1; } static void abolishNV(nv) struct NV *nv; { struct NVE *p, **q, *r; unsigned i; if (nv && nv->tsz && nv->buf) { for (i = 0, q = nv->buf + i; i < nv->tsz; i++, q = nv->buf + i) { for (p = *q; p; p = r) { r = p->next; if (p->data) (void)free((char *)p->data); (void)free((char *)p); } } (void)free(nv->buf); (void)free(nv); } return; } static struct NV * readNV(fd) int fd; { struct NV *vn; unsigned char ll[4], *buf, *p; long i, cnt; vn = (struct NV *)malloc(sizeof(struct NV)); if (vn) { if (read(fd, (char *)ll, 4) == 4) { vn->sz = bst4_to_l(ll); if (read(fd, (char *)ll, 4) == 4) { cnt = bst4_to_l(ll); if (read(fd, (char *)ll, 4) == 4) { vn->tsz = bst4_to_l(ll); if (read(fd, (char *)ll, 4) == 4) { goto read_ok; } } } } (void)free((char *)vn); } return (struct NV *)0; read_ok: vn->cnt = vn->csz = 0L; vn->head.left = vn->head.right = &vn->head; if (vn->sz) { if (!(vn->buf = (struct NVE **)calloc((size_t)vn->tsz, sizeof(struct NVE *)))) { (void)free((char *)vn); return((struct NV *)0); } if (!(buf = (unsigned char *)malloc((size_t)vn->sz)) || read(fd, buf, (unsigned int)vn->sz) != (int)vn->sz) { (void)free((char *)vn->buf); if (buf) (void)free((char *)buf); (void)free((char *)vn); return((struct NV *)0); } for (p = buf, i = 0L; i < cnt; i++, p += *p*2 + 2) if ((unsigned long) (p - buf) + *p * 2 + 2 < vn->sz) _RkRegisterNV(vn, p + 2, (int)*p, (int)*(p + 1)); (void)free((char *)buf); } else { (void)free(vn); return((struct NV *)0); } vn->head.right->left = &vn->head; vn->head.left->right = &vn->head; return(vn); } static int writeNV(fd, nv) int fd; struct NV *nv; { unsigned char ll[4]; unsigned char *buf = (unsigned char *)0, *r; struct NVE *p, **q; unsigned long i; if (!nv) return(-1); if (nv->buf) { if (!(buf = (unsigned char *)malloc((size_t)nv->sz))) return(-1); for (r = buf, i = 0L, q = nv->buf; i < nv->tsz; i++, q = nv->buf + i) { for (p = *q; p; q = &p->next, p = *q) { if ((unsigned long) (r - buf) + *(p->data)*2 + 2 < nv->sz) { memcpy(r, p->data, *(p->data)*2+2); r += *(p->data)*2+2; } else { i = nv->tsz; break; } } } } l_to_bst4(nv->sz, ll); if (write(fd, (char *)ll, 4) == 4) { l_to_bst4(nv->cnt, ll); if (write(fd, (char *)ll, 4) == 4) { l_to_bst4(nv->tsz, ll); if (write(fd, (char *)ll, 4) == 4) { l_to_bst4((unsigned long)0, ll); if (write(fd, (char *)ll, 4) == 4) { if (!nv->sz || (buf && write(fd, buf, (int) nv->sz) == (int)nv->sz)) { goto write_ok; } } } } } if (buf) (void)free((char *)buf); return(-1); write_ok: if (buf) (void)free((char *)buf); return(0); } static void freeRUT(ruc) struct RUT *ruc; { struct CTdata *wd, *nex; unsigned long lc; for (lc = 0; lc < HN; lc++) { for (wd = *(ruc->dp+lc); wd; wd = nex) { nex = wd->next; free(wd); } } free(ruc->dp); free(ruc); } struct RUT * LoadRUC(fr) int fr; { struct WRT *wruc; struct RUT *ruc; unsigned long lc, csn, tick; if (!(wruc = readWRT(fr))) return (struct RUT *) 0; if (!(ruc = allocRUT(HN))) { freeWRT(wruc); return (struct RUT *) 0; } ruc->sz = wruc->sz; ruc->cs = 0L; ruc->frst = wruc->frst; ruc->tm = wruc->tm; for (lc = 0; lc < wruc->cs; lc++) { unsigned char *tmp = wruc->buf + 5 * lc; csn = a_csn(tmp); tick = _RkGetTick(0) - a_tick(wruc->buf+5*lc); if (!entryRut(ruc, csn, tick)) { freeRUT(ruc); ruc = (struct RUT *) 0; } } freeWRT(wruc); return ruc; } static int SaveRUC pro((int, struct RUT *)); static int SaveRUC(fr, ruc) int fr; struct RUT *ruc; { struct WRT *wruc; struct CTdata *wdp; unsigned long lc, count; int retval; if (!ruc) return (int) 0; retval = 1; if (!(wruc = allocWRT(ruc->sz))){ freeRUT(ruc); return (int) 0; } wruc->sz = ruc->sz; wruc->cs = ruc->cs; wruc->frst = ruc->frst; wruc->tm = ruc->tm; count = 0L; for (lc = 0L; lc < HN; lc++) { for (wdp = *(ruc->dp+lc) ; wdp; wdp = wdp->next) { WriteVal(wdp->ct[0], _RkGetTick(0) - wdp->ct[1], wruc->buf+5*count); count ++; } } if (count != ruc->cs) { retval = (int) 0; } if (!writeToWRT(fr, wruc)) retval = 0; freeWRT(wruc); return retval; } static int FQscan(df, codm, file, w) struct DF *df; struct DM *codm; char *file; int *w; { int count = 0; struct HD hd; struct DM *dm, *dmh; unsigned char ll[4]; unsigned long bitsiz, bitoff; off_t off; int fd; *w = 1; if ((fd = open(file, 2)) < 0) { *w = 0; if ((fd = open(file, 0)) < 0) return -1; } #ifdef __CYGWIN32__ setmode(fd, O_BINARY); #endif for (off = 0; _RkReadHeader(fd, &hd, off) >= 0;) { long start = off; if (!hd.data[HD_DMNM].ptr || (strncmp(".fq", (char *)hd.data[HD_DMNM].ptr + strlen((char *)hd.data[HD_DMNM].ptr) - (sizeof(".fq") - 1), sizeof(".fq") - 1) && strncmp(".cld", (char *)hd.data[HD_DMNM].ptr + strlen((char *)hd.data[HD_DMNM].ptr) - (sizeof(".cld") - 1), sizeof(".cld") - 1)) ) { break; } if (!codm->dm_xdm || (long)((struct ND *)codm->dm_xdm)->rec != hd.data[HD_REC].var || (long)((struct ND *)codm->dm_xdm)->can != hd.data[HD_CAN].var) break; if (hd.flag[HD_CRC]) { if (!((struct ND *)codm->dm_xdm)->crc_found || (long)((struct ND *)codm->dm_xdm)->crc != hd.data[HD_CRC].var) break; } else { if (((struct ND *)codm->dm_xdm)->crc_found || (long)((struct ND *)codm->dm_xdm)->time != hd.data[HD_TIME].var) break; } off += hd.data[HD_HSZ].var; (void)lseek(fd, off, 0); (void)read(fd, (char *)ll, 4); off += 4; bitsiz = L4TOL(ll); bitoff = off; off += bitsiz; (void)lseek(fd, off, 0); dmh = &df->df_members; for (dm = dmh->dm_next; dm != dmh; dm = dm->dm_next) { if (!strcmp((char *)dm->dm_dicname, (char *)hd.data[HD_CODM].ptr)) { struct xqm *xqm; if (!(xqm = (struct xqm *)malloc(sizeof(struct xqm)))) break; dm->dm_extdata.ptr = (pointer)xqm; xqm->ex_boff = bitoff; xqm->ex_bsiz = bitsiz; dm->dm_flags |= DM_EXIST; dm->dm_offset = start; count++; break; } } _RkClearHeader(&hd); } _RkClearHeader(&hd); if (!count) { (void)close(fd); return -1; } df->df_size = off; df->df_extdata.var = (long)fd; return fd; } int FQopen(dm, qm, file, mode) struct DM *dm; struct DM *qm; char *file; int mode; { struct DF *df; struct DD *dd; struct xqm *xqm; int writable; int fd; /* missing file info ? */ if (!(df = qm->dm_file) || !(dd = df->df_direct)) return -1; /* initialize df */ if (!df->df_rcount) { df->df_extdata.var = (long)FQscan(df, dm, file, &writable); if (df->df_extdata.var < 0) return -1; if (writable) df->df_flags |= DF_WRITABLE; else df->df_flags &= ~DF_WRITABLE; df->df_flags |= DF_EXIST; dd->dd_rcount++; } /* * this member is not included. */ if (!(qm->dm_flags & DM_EXIST)) return -1; if (strcmp(dm->dm_dicname, qm->dm_dicname)) return -1; /* */ xqm = (struct xqm *)qm->dm_extdata.ptr; fd = df->df_extdata.var; qm->dm_rut = (struct RUT *)0; qm->dm_nv = (struct NV *)0; /* dispatch */ qm->dm_qbits = (unsigned char *)malloc((unsigned)xqm->ex_bsiz); if (!qm->dm_qbits) return -1; (void)lseek(fd, xqm->ex_boff, 0); (void)read(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz); qm->dm_rut = LoadRUC(fd); qm->dm_nv = readNV(fd); df->df_rcount++; if ((mode & DM_WRITABLE) && (df->df_flags & DF_WRITABLE)) { qm->dm_flags |= DM_WRITABLE; } return 0; } /* * CLOSE */ /*ARGSUSED*/ void FQclose(cx, dm, qm, file) struct RkContext *cx; struct DM *dm; struct DM *qm; char *file; { struct DF *df = qm->dm_file; struct xqm *xqm; int fd = (int)df->df_extdata.var; xqm = (struct xqm *)qm->dm_extdata.ptr; if (xqm) { if (qm->dm_qbits) { if (qm->dm_flags & DM_UPDATED) { (void)lseek(fd, xqm->ex_boff, 0); (void)write(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz); }; (void)free((char *)qm->dm_qbits); qm->dm_qbits = (unsigned char *)0; } } if (qm->dm_rut) { if (qm->dm_flags & DM_UPDATED) SaveRUC(fd, qm->dm_rut); freeRUT(qm->dm_rut); qm->dm_rut = (struct RUT *)0; } if (qm->dm_nv) { if (qm-> dm_flags & DM_UPDATED) writeNV(fd, qm->dm_nv); abolishNV(qm->dm_nv); qm->dm_nv = (struct NV *)0; } qm->dm_flags &= ~DM_UPDATED; if (--df->df_rcount == 0) { struct DM *dmh, *ddm; (void)close(fd); dmh = &df->df_members; for (ddm = dmh->dm_next; ddm != dmh; ddm = ddm->dm_next) { xqm = (struct xqm *)ddm->dm_extdata.ptr; if (xqm) { (void)free((char *)xqm); ddm->dm_extdata.ptr = (pointer)0; } } } } int FQsync(cx, dm, qm, file) struct RkContext *cx; struct DM *dm; struct DM *qm; char *file; /* ARGSUSED */ { struct DF *df = qm->dm_file; struct xqm *xqm; int rv; int fd = (int)df->df_extdata.var; rv = 0; xqm = (struct xqm *)qm->dm_extdata.ptr; if (xqm) { if (qm->dm_qbits) { if (qm->dm_flags & DM_UPDATED) { (void)lseek(fd, xqm->ex_boff, 0); if (write(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz) != (int) xqm->ex_bsiz) rv = -1; if (qm->dm_rut) rv = SaveRUC(fd, qm->dm_rut) - 1; if (qm->dm_nv) rv = writeNV(fd, qm->dm_nv); } if (!rv) qm->dm_flags &= ~DM_UPDATED; } } return (rv); } /* vim: set sw=2: */
21.683424
85
0.548343
fe8129d56c6bfad94c72492eaca3aa7e90c0ea1b
573
h
C
LBUnderlineButton/LBUnderlineButton.h
A1129434577/LBUnderlineButton
12846d82d5c683668c5899968d2ee9248fa6dd60
[ "MIT" ]
null
null
null
LBUnderlineButton/LBUnderlineButton.h
A1129434577/LBUnderlineButton
12846d82d5c683668c5899968d2ee9248fa6dd60
[ "MIT" ]
null
null
null
LBUnderlineButton/LBUnderlineButton.h
A1129434577/LBUnderlineButton
12846d82d5c683668c5899968d2ee9248fa6dd60
[ "MIT" ]
null
null
null
// // UnderlineButton.h // Driver // // Created by 刘彬 on 2019/5/9. // Copyright © 2019 BIN. All rights reserved. // 系统下划线太和文字贴的太紧,故自定义控件 #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface LBUnderlineButton : UIButton @property (nonatomic,assign)CGFloat lineSpacing;//default 0.f @property (nonatomic,assign)CGFloat lineHeight;//default 0.5f @property (nonatomic,assign)CGFloat lineWidth;//default 0.0f,根据title自适应长短,如果设值,将利用设值 @property (nonatomic,strong)UIColor *lineColor;//设置lineColor了之后线条颜色将不变,如果不设置,线条颜色跟着==currentTitleColor @end NS_ASSUME_NONNULL_END
27.285714
102
0.783595
dfa1f9cb59e64a7a81ffca3708b8d9ed91db942d
370
h
C
src/c/utils.h
KenyC/WebShajara
66580a98bbc47969b55a8f8ffb3d4d8ac774064e
[ "MIT" ]
null
null
null
src/c/utils.h
KenyC/WebShajara
66580a98bbc47969b55a8f8ffb3d4d8ac774064e
[ "MIT" ]
null
null
null
src/c/utils.h
KenyC/WebShajara
66580a98bbc47969b55a8f8ffb3d4d8ac774064e
[ "MIT" ]
null
null
null
#ifndef UTILS_H #define UTILS_H #define CATCH_CALLBACK(instruction, error_message) { \ if(instruction < 0) { \ LOG(error_message); \ } \ } #define MIN(a, b) ((a) < (b)) ? a : b #define MAX(a, b) ((a) > (b)) ? a : b #define ABS(a) ((a) > 0) ? a : -a #endif
24.666667
54
0.402703
2a623512f0ddbc5e7499b84616d9e75f50955fea
1,419
h
C
src/app/imgui/imgui_util.h
crocdialer/KinskiGL
2f800c5aac04ad91e5046cb31b9dd93eaa52a67c
[ "BSL-1.0" ]
11
2016-11-17T21:32:51.000Z
2021-03-30T20:31:41.000Z
src/app/imgui/imgui_util.h
crocdialer/KinskiGL
2f800c5aac04ad91e5046cb31b9dd93eaa52a67c
[ "BSL-1.0" ]
1
2015-04-28T13:10:14.000Z
2015-04-28T13:10:14.000Z
src/app/imgui/imgui_util.h
crocdialer/KinskiGL
2f800c5aac04ad91e5046cb31b9dd93eaa52a67c
[ "BSL-1.0" ]
2
2015-04-28T12:26:46.000Z
2021-11-12T08:03:00.000Z
// // Created by crocdialer on 4/20/18. // #ifndef KINSKIGL_IMGUI_UTIL_H #define KINSKIGL_IMGUI_UTIL_H #include <crocore/Component.hpp> #include "gl/gl.hpp" #include "app/App.hpp" #include "app/LightComponent.hpp" #include "app/WarpComponent.hpp" #include "imgui.h" // forward declared to avoid inclusion of App.h class JoystickState; namespace kinski{ namespace gui{ const ImVec2& im_vec_cast(const gl::vec2 &the_vec); const ImVec4& im_vec_cast(const gl::vec4 &the_vec); const ImVec4 im_vec_cast(const gl::vec3 &the_vec); //! draw a generic kinski::Component using ImGui void draw_component_ui(const crocore::ComponentConstPtr &the_component); void draw_textures_ui(const std::vector<gl::Texture*> &the_textures); void draw_material_ui(const gl::MaterialPtr &the_mat); void draw_materials_ui(const std::vector<gl::MaterialPtr> &the_materials); void draw_light_component_ui(const LightComponentPtr &the_component); void draw_warp_component_ui(const WarpComponentPtr &the_component); void draw_object3D_ui(const gl::Object3DPtr &the_object, const gl::CameraConstPtr &the_camera = nullptr); void draw_mesh_ui(const gl::MeshPtr &the_mesh); void draw_scenegraph_ui(const gl::SceneConstPtr &the_scene, std::set<gl::Object3DPtr>* the_selection = nullptr); void process_joystick_input(const std::vector<JoystickState> &the_joystick_states); }}// namespaces #endif //KINSKIGL_IMGUI_UTIL_H
29.5625
112
0.781536
a4921ac8bf0411bc30b3ad43f444f295fe38ca7f
158
h
C
src/GaIA/pkgs/pktstat/pktstat-1.8.5/resize.h
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
null
null
null
src/GaIA/pkgs/pktstat/pktstat-1.8.5/resize.h
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
null
null
null
src/GaIA/pkgs/pktstat/pktstat-1.8.5/resize.h
uninth/UNItools
c8b1fbfd5d3753b5b14fa19033e39737dedefc00
[ "BSD-3-Clause" ]
1
2021-06-08T15:59:26.000Z
2021-06-08T15:59:26.000Z
/* David Leonard, 2002. Public domain. */ /* $Id: resize.h 1187 2007-03-28 12:54:22Z d $ */ void resize_init(); void resize(void); int resize_needed(void);
22.571429
49
0.670886
a896fe94298f1a8c8fe19c7a4cdc94fff7e718ab
344
h
C
SQLPopVC/DFPopupAnimator/DFPopupPresentAnimator.h
beiguo172528/SQLPopVC
f5284daa0169a3fc115a3cc26e6a5ab6304b6c70
[ "MIT" ]
null
null
null
SQLPopVC/DFPopupAnimator/DFPopupPresentAnimator.h
beiguo172528/SQLPopVC
f5284daa0169a3fc115a3cc26e6a5ab6304b6c70
[ "MIT" ]
null
null
null
SQLPopVC/DFPopupAnimator/DFPopupPresentAnimator.h
beiguo172528/SQLPopVC
f5284daa0169a3fc115a3cc26e6a5ab6304b6c70
[ "MIT" ]
null
null
null
// // DFPopupPresentAnimator.h // DFPopupView12 // // Created by DOFAR on 2018/10/15. // Copyright © 2018年 DOFAR. All rights reserved. // #import <UIKit/UIKit.h> #import "DFPopupHeader.h" @interface DFPopupPresentAnimator : NSObject<UIViewControllerAnimatedTransitioning> @property(nonatomic,assign)DFPopupPresentStyle presentStyle; @end
22.933333
83
0.773256
a89f6a4539c556884ca78f6c6caa10148ed2e88f
643
c
C
Medium/C/Happy Friends.c
Aimnos/Dcoder-Challenges
7dd39493a3b3bcbad3566063ddfc81b84170f672
[ "MIT" ]
24
2020-01-31T15:11:19.000Z
2022-03-30T11:45:41.000Z
Medium/C/Happy Friends.c
Aimnos/Dcoder-Challenges
7dd39493a3b3bcbad3566063ddfc81b84170f672
[ "MIT" ]
1
2019-12-21T19:23:18.000Z
2021-09-29T15:18:52.000Z
Medium/C/Happy Friends.c
Aimnos/Dcoder-Challenges
7dd39493a3b3bcbad3566063ddfc81b84170f672
[ "MIT" ]
6
2021-02-18T21:15:11.000Z
2022-03-31T05:12:52.000Z
#include <stdio.h> #include <stdlib.h> //Compiler version gcc 6.3.0 int main() { int T, i; long int N, *friends, K, j, k, minPos, gifts; scanf("%d", &T); for(i = 0; i < T; i++) { scanf("%ld", &N); friends = (int*)malloc(N*sizeof(int)); for(j = 0; j < N; j++) scanf("%ld", &friends[j]); scanf("%ld", &K); gifts = 0; for(j = 0; j < K; j++) { minPos = 0; for(k = 1; k < N - j; k++) if(friends[k] < friends[minPos]) minPos = k; gifts += friends[minPos]; friends[minPos] = friends[N - j - 1]; } printf("%ld\n", gifts); free(friends); } return 0; }
20.741935
47
0.469673
00db9d2a04e012107ec2855910f37a1d557ddb25
3,124
h
C
Source/Server/Basic_V1.0/WinMonitorServer/WinMonitorServer/WinMonitorConfigStructsAndGlobals.h
avarghesein/WinMonitor
2ba872758708ef1b74d7b2cc4a93a39e6e3aa1fd
[ "MIT" ]
1
2020-03-08T21:16:46.000Z
2020-03-08T21:16:46.000Z
Source/Server/Basic_V1.0/WinMonitorServer/WinMonitorServer/WinMonitorConfigStructsAndGlobals.h
avarghesein/WinMonitor
2ba872758708ef1b74d7b2cc4a93a39e6e3aa1fd
[ "MIT" ]
null
null
null
Source/Server/Basic_V1.0/WinMonitorServer/WinMonitorServer/WinMonitorConfigStructsAndGlobals.h
avarghesein/WinMonitor
2ba872758708ef1b74d7b2cc4a93a39e6e3aa1fd
[ "MIT" ]
null
null
null
//---------------Central Structs--------------// typedef struct { CTString tchrCreationDate; CTString tchrCreationTime; CTString tchrFileName; CTString tchrInternalName; CTString tchrInstallLocation; } SWinMonitorServerGeneral; typedef struct { CTString tchrRegKey; bool blnLocalUserRunAlways; bool blnLocalMachineRunAlways; bool blnLocalMachineRunOnce; } SWinMonitorServerRegistrySettings; typedef struct { bool blnIncludeDate; bool blnIncludeTime; bool blnIncludeUser; long lngUploadSize; CTString tchrRootDir; CTString tchrFilePath; } SWinMonitorServerKeyLogger; typedef struct { CTString tchrRootDir; CTString tchrSavePath; long lngFileLimit; long lngElapseTimeInSeconds; } SWinMonitorServerScreenMonitor; typedef struct { CTString tchrIP; long lngPort; float fltAttemptInterval; } SWinMonitorServerReverseConnection; typedef struct { CTString tchrEmail; CTString tchrEmailServer; } SWinMonitorServerEmail; typedef struct { CTString tchrHostName; long lngListenPort; CTString tchrPassword; } SWinMonitorServerNetworkConnection; typedef struct:public CGeneralMemoryUtility { SWinMonitorServerGeneral SGeneral; SWinMonitorServerRegistrySettings SRegistry; SWinMonitorServerKeyLogger SKeyLogger; SWinMonitorServerScreenMonitor SScreenMonitor; SWinMonitorServerNetworkConnection SNetworkConnection; bool blnReverseConnection; SWinMonitorServerReverseConnection *SpReverseConnection; bool blnEmail; SWinMonitorServerEmail *SpEmail; } SWinMonitorServerConfiguration; typedef struct { CTString tchrKeyLogFile; CTString tchrScreenShotDir; CTString tchrExeFullPath; } SWinMonitorStoredFiles; //---------------//***//--------------// //----One and only global struct for entire program SWinMonitorServerConfiguration gbl_struct_WinMonitorServerConfig; SWinMonitorStoredFiles gbl_struct_WinMonitorStoredFiles; CExtendedLinkedList<void> gbl_lnkdlst_TcpClients; int gbl_intWndShowType=0; HINSTANCE gbl_hinstCurrentInstance=NULL; #define DEF_PIC_FILE_BASE _T("WinScreen") #define DEF_CONFIG_INI _T("WinMonitorServer.Config.INI") #define DEF_INI_APP_NAME (LPCSTR)"WinMonitorServer.1.0" #define DEF_INI_FILE_NAME (LPCSTR)"WinMonitorServer.1.0.ini" #define DEF_INI_KEY_KEYBOARD_HOOK_FILE (LPCSTR)"WinMonitorServer.1.0.KEYBOARD_HOOK_FILE" #define DEF_INI_KEY_KEYBOARD_HOOK_INC_DATE (LPCSTR)"WinMonitorServer.1.0.KEYBOARD_HOOK_INC_DATE" #define DEF_INI_KEY_KEYBOARD_HOOK_INC_TIME (LPCSTR)"WinMonitorServer.1.0.KEYBOARD_HOOK_INC_TIME" #define DEF_INI_KEY_KEYBOARD_HOOK_INC_USER (LPCSTR)"WinMonitorServer.1.0.KEYBOARD_HOOK_INC_USER" MethodRetBoolArgVoid InstallKBrdHook=0,UnInstallKBrdHook=0; HANDLE gbl_hScreenSnatcherThread=NULL; bool gbl_blnContinueScreenSnatching=false; bool gbl_blnContinueReverseConnection=false; HANDLE gbl_hReverseConnectionThread=NULL; void *gbl_ReverseClient=NULL;
26.033333
97
0.756402
faf5b5d5382b64959f4089447993ceaccc898174
1,043
h
C
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_WWW3134621005MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_WWW3134621005MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
Descending Europa/Temp/StagingArea/Data/il2cppOutput/UnityEngine_UnityEngine_WWW3134621005MethodDeclarations.h
screwylightbulb/europa
3dcc98369c8066cb2310143329535206751c8846
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // UnityEngine.WWW struct WWW_t3134621005; // System.Text.Encoding struct Encoding_t2012439129; #include "codegen/il2cpp-codegen.h" // System.Void UnityEngine.WWW::Dispose() extern "C" void WWW_Dispose_m2446678367 (WWW_t3134621005 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.WWW::Finalize() extern "C" void WWW_Finalize_m1793349504 (WWW_t3134621005 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.WWW::DestroyWWW(System.Boolean) extern "C" void WWW_DestroyWWW_m300967382 (WWW_t3134621005 * __this, bool ___cancel0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Text.Encoding UnityEngine.WWW::get_DefaultEncoding() extern "C" Encoding_t2012439129 * WWW_get_DefaultEncoding_m2507364293 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
34.766667
161
0.78907
94feaa7db9a310a98419438d8c28886e9b73b7f8
227
h
C
HomeUI.framework/HUAlarmEditTableViewCell.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
HomeUI.framework/HUAlarmEditTableViewCell.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
HomeUI.framework/HUAlarmEditTableViewCell.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/HomeUI.framework/HomeUI */ @interface HUAlarmEditTableViewCell : UITableViewCell - (id)initWithStyle:(long long)arg1 reuseIdentifier:(id)arg2; @end
22.7
67
0.792952
9e7e0f0d1c39800e5591cf15777f67a38ac79d93
34,650
h
C
platform/Device/SiliconLabs/EFR32BG12P/Include/efr32bg12p_wdog.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
null
null
null
platform/Device/SiliconLabs/EFR32BG12P/Include/efr32bg12p_wdog.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
1
2020-08-25T02:36:22.000Z
2020-08-25T02:36:22.000Z
platform/Device/SiliconLabs/EFR32BG12P/Include/efr32bg12p_wdog.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
1
2020-08-25T01:56:04.000Z
2020-08-25T01:56:04.000Z
/***************************************************************************//** * @file * @brief EFR32BG12P_WDOG register and bit field definitions ******************************************************************************* * # License * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b> ******************************************************************************* * * SPDX-License-Identifier: Zlib * * The licensor of this software is Silicon Laboratories Inc. * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * ******************************************************************************/ #if defined(__ICCARM__) #pragma system_include /* Treat file as system include file. */ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang system_header /* Treat file as system include file. */ #endif /***************************************************************************//** * @addtogroup Parts * @{ ******************************************************************************/ /***************************************************************************//** * @defgroup EFR32BG12P_WDOG WDOG * @{ * @brief EFR32BG12P_WDOG Register Declaration ******************************************************************************/ /** WDOG Register Declaration */ typedef struct { __IOM uint32_t CTRL; /**< Control Register */ __IOM uint32_t CMD; /**< Command Register */ __IM uint32_t SYNCBUSY; /**< Synchronization Busy Register */ WDOG_PCH_TypeDef PCH[2U]; /**< PCH */ uint32_t RESERVED0[2U]; /**< Reserved for future use **/ __IM uint32_t IF; /**< Watchdog Interrupt Flags */ __IOM uint32_t IFS; /**< Interrupt Flag Set Register */ __IOM uint32_t IFC; /**< Interrupt Flag Clear Register */ __IOM uint32_t IEN; /**< Interrupt Enable Register */ } WDOG_TypeDef; /** @} */ /***************************************************************************//** * @addtogroup EFR32BG12P_WDOG * @{ * @defgroup EFR32BG12P_WDOG_BitFields WDOG Bit Fields * @{ ******************************************************************************/ /* Bit fields for WDOG CTRL */ #define _WDOG_CTRL_RESETVALUE 0x00000F00UL /**< Default value for WDOG_CTRL */ #define _WDOG_CTRL_MASK 0xC7033F7FUL /**< Mask for WDOG_CTRL */ #define WDOG_CTRL_EN (0x1UL << 0) /**< Watchdog Timer Enable */ #define _WDOG_CTRL_EN_SHIFT 0 /**< Shift value for WDOG_EN */ #define _WDOG_CTRL_EN_MASK 0x1UL /**< Bit mask for WDOG_EN */ #define _WDOG_CTRL_EN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EN_DEFAULT (_WDOG_CTRL_EN_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_DEBUGRUN (0x1UL << 1) /**< Debug Mode Run Enable */ #define _WDOG_CTRL_DEBUGRUN_SHIFT 1 /**< Shift value for WDOG_DEBUGRUN */ #define _WDOG_CTRL_DEBUGRUN_MASK 0x2UL /**< Bit mask for WDOG_DEBUGRUN */ #define _WDOG_CTRL_DEBUGRUN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_DEBUGRUN_DEFAULT (_WDOG_CTRL_DEBUGRUN_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM2RUN (0x1UL << 2) /**< Energy Mode 2 Run Enable */ #define _WDOG_CTRL_EM2RUN_SHIFT 2 /**< Shift value for WDOG_EM2RUN */ #define _WDOG_CTRL_EM2RUN_MASK 0x4UL /**< Bit mask for WDOG_EM2RUN */ #define _WDOG_CTRL_EM2RUN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM2RUN_DEFAULT (_WDOG_CTRL_EM2RUN_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM3RUN (0x1UL << 3) /**< Energy Mode 3 Run Enable */ #define _WDOG_CTRL_EM3RUN_SHIFT 3 /**< Shift value for WDOG_EM3RUN */ #define _WDOG_CTRL_EM3RUN_MASK 0x8UL /**< Bit mask for WDOG_EM3RUN */ #define _WDOG_CTRL_EM3RUN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM3RUN_DEFAULT (_WDOG_CTRL_EM3RUN_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_LOCK (0x1UL << 4) /**< Configuration Lock */ #define _WDOG_CTRL_LOCK_SHIFT 4 /**< Shift value for WDOG_LOCK */ #define _WDOG_CTRL_LOCK_MASK 0x10UL /**< Bit mask for WDOG_LOCK */ #define _WDOG_CTRL_LOCK_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_LOCK_DEFAULT (_WDOG_CTRL_LOCK_DEFAULT << 4) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM4BLOCK (0x1UL << 5) /**< Energy Mode 4 Block */ #define _WDOG_CTRL_EM4BLOCK_SHIFT 5 /**< Shift value for WDOG_EM4BLOCK */ #define _WDOG_CTRL_EM4BLOCK_MASK 0x20UL /**< Bit mask for WDOG_EM4BLOCK */ #define _WDOG_CTRL_EM4BLOCK_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_EM4BLOCK_DEFAULT (_WDOG_CTRL_EM4BLOCK_DEFAULT << 5) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_SWOSCBLOCK (0x1UL << 6) /**< Software Oscillator Disable Block */ #define _WDOG_CTRL_SWOSCBLOCK_SHIFT 6 /**< Shift value for WDOG_SWOSCBLOCK */ #define _WDOG_CTRL_SWOSCBLOCK_MASK 0x40UL /**< Bit mask for WDOG_SWOSCBLOCK */ #define _WDOG_CTRL_SWOSCBLOCK_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_SWOSCBLOCK_DEFAULT (_WDOG_CTRL_SWOSCBLOCK_DEFAULT << 6) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_PERSEL_SHIFT 8 /**< Shift value for WDOG_PERSEL */ #define _WDOG_CTRL_PERSEL_MASK 0xF00UL /**< Bit mask for WDOG_PERSEL */ #define _WDOG_CTRL_PERSEL_DEFAULT 0x0000000FUL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_PERSEL_DEFAULT (_WDOG_CTRL_PERSEL_DEFAULT << 8) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_CLKSEL_SHIFT 12 /**< Shift value for WDOG_CLKSEL */ #define _WDOG_CTRL_CLKSEL_MASK 0x3000UL /**< Bit mask for WDOG_CLKSEL */ #define _WDOG_CTRL_CLKSEL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_CLKSEL_ULFRCO 0x00000000UL /**< Mode ULFRCO for WDOG_CTRL */ #define _WDOG_CTRL_CLKSEL_LFRCO 0x00000001UL /**< Mode LFRCO for WDOG_CTRL */ #define _WDOG_CTRL_CLKSEL_LFXO 0x00000002UL /**< Mode LFXO for WDOG_CTRL */ #define _WDOG_CTRL_CLKSEL_HFCORECLK 0x00000003UL /**< Mode HFCORECLK for WDOG_CTRL */ #define WDOG_CTRL_CLKSEL_DEFAULT (_WDOG_CTRL_CLKSEL_DEFAULT << 12) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_CLKSEL_ULFRCO (_WDOG_CTRL_CLKSEL_ULFRCO << 12) /**< Shifted mode ULFRCO for WDOG_CTRL */ #define WDOG_CTRL_CLKSEL_LFRCO (_WDOG_CTRL_CLKSEL_LFRCO << 12) /**< Shifted mode LFRCO for WDOG_CTRL */ #define WDOG_CTRL_CLKSEL_LFXO (_WDOG_CTRL_CLKSEL_LFXO << 12) /**< Shifted mode LFXO for WDOG_CTRL */ #define WDOG_CTRL_CLKSEL_HFCORECLK (_WDOG_CTRL_CLKSEL_HFCORECLK << 12) /**< Shifted mode HFCORECLK for WDOG_CTRL */ #define _WDOG_CTRL_WARNSEL_SHIFT 16 /**< Shift value for WDOG_WARNSEL */ #define _WDOG_CTRL_WARNSEL_MASK 0x30000UL /**< Bit mask for WDOG_WARNSEL */ #define _WDOG_CTRL_WARNSEL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_WARNSEL_DEFAULT (_WDOG_CTRL_WARNSEL_DEFAULT << 16) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_WINSEL_SHIFT 24 /**< Shift value for WDOG_WINSEL */ #define _WDOG_CTRL_WINSEL_MASK 0x7000000UL /**< Bit mask for WDOG_WINSEL */ #define _WDOG_CTRL_WINSEL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_WINSEL_DEFAULT (_WDOG_CTRL_WINSEL_DEFAULT << 24) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_CLRSRC (0x1UL << 30) /**< Watchdog Clear Source */ #define _WDOG_CTRL_CLRSRC_SHIFT 30 /**< Shift value for WDOG_CLRSRC */ #define _WDOG_CTRL_CLRSRC_MASK 0x40000000UL /**< Bit mask for WDOG_CLRSRC */ #define _WDOG_CTRL_CLRSRC_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_CLRSRC_SW 0x00000000UL /**< Mode SW for WDOG_CTRL */ #define _WDOG_CTRL_CLRSRC_PCH0 0x00000001UL /**< Mode PCH0 for WDOG_CTRL */ #define WDOG_CTRL_CLRSRC_DEFAULT (_WDOG_CTRL_CLRSRC_DEFAULT << 30) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_CLRSRC_SW (_WDOG_CTRL_CLRSRC_SW << 30) /**< Shifted mode SW for WDOG_CTRL */ #define WDOG_CTRL_CLRSRC_PCH0 (_WDOG_CTRL_CLRSRC_PCH0 << 30) /**< Shifted mode PCH0 for WDOG_CTRL */ #define WDOG_CTRL_WDOGRSTDIS (0x1UL << 31) /**< Watchdog Reset Disable */ #define _WDOG_CTRL_WDOGRSTDIS_SHIFT 31 /**< Shift value for WDOG_WDOGRSTDIS */ #define _WDOG_CTRL_WDOGRSTDIS_MASK 0x80000000UL /**< Bit mask for WDOG_WDOGRSTDIS */ #define _WDOG_CTRL_WDOGRSTDIS_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CTRL */ #define _WDOG_CTRL_WDOGRSTDIS_EN 0x00000000UL /**< Mode EN for WDOG_CTRL */ #define _WDOG_CTRL_WDOGRSTDIS_DIS 0x00000001UL /**< Mode DIS for WDOG_CTRL */ #define WDOG_CTRL_WDOGRSTDIS_DEFAULT (_WDOG_CTRL_WDOGRSTDIS_DEFAULT << 31) /**< Shifted mode DEFAULT for WDOG_CTRL */ #define WDOG_CTRL_WDOGRSTDIS_EN (_WDOG_CTRL_WDOGRSTDIS_EN << 31) /**< Shifted mode EN for WDOG_CTRL */ #define WDOG_CTRL_WDOGRSTDIS_DIS (_WDOG_CTRL_WDOGRSTDIS_DIS << 31) /**< Shifted mode DIS for WDOG_CTRL */ /* Bit fields for WDOG CMD */ #define _WDOG_CMD_RESETVALUE 0x00000000UL /**< Default value for WDOG_CMD */ #define _WDOG_CMD_MASK 0x00000001UL /**< Mask for WDOG_CMD */ #define WDOG_CMD_CLEAR (0x1UL << 0) /**< Watchdog Timer Clear */ #define _WDOG_CMD_CLEAR_SHIFT 0 /**< Shift value for WDOG_CLEAR */ #define _WDOG_CMD_CLEAR_MASK 0x1UL /**< Bit mask for WDOG_CLEAR */ #define _WDOG_CMD_CLEAR_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_CMD */ #define _WDOG_CMD_CLEAR_UNCHANGED 0x00000000UL /**< Mode UNCHANGED for WDOG_CMD */ #define _WDOG_CMD_CLEAR_CLEARED 0x00000001UL /**< Mode CLEARED for WDOG_CMD */ #define WDOG_CMD_CLEAR_DEFAULT (_WDOG_CMD_CLEAR_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_CMD */ #define WDOG_CMD_CLEAR_UNCHANGED (_WDOG_CMD_CLEAR_UNCHANGED << 0) /**< Shifted mode UNCHANGED for WDOG_CMD */ #define WDOG_CMD_CLEAR_CLEARED (_WDOG_CMD_CLEAR_CLEARED << 0) /**< Shifted mode CLEARED for WDOG_CMD */ /* Bit fields for WDOG SYNCBUSY */ #define _WDOG_SYNCBUSY_RESETVALUE 0x00000000UL /**< Default value for WDOG_SYNCBUSY */ #define _WDOG_SYNCBUSY_MASK 0x0000000FUL /**< Mask for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_CTRL (0x1UL << 0) /**< CTRL Register Busy */ #define _WDOG_SYNCBUSY_CTRL_SHIFT 0 /**< Shift value for WDOG_CTRL */ #define _WDOG_SYNCBUSY_CTRL_MASK 0x1UL /**< Bit mask for WDOG_CTRL */ #define _WDOG_SYNCBUSY_CTRL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_CTRL_DEFAULT (_WDOG_SYNCBUSY_CTRL_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_CMD (0x1UL << 1) /**< CMD Register Busy */ #define _WDOG_SYNCBUSY_CMD_SHIFT 1 /**< Shift value for WDOG_CMD */ #define _WDOG_SYNCBUSY_CMD_MASK 0x2UL /**< Bit mask for WDOG_CMD */ #define _WDOG_SYNCBUSY_CMD_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_CMD_DEFAULT (_WDOG_SYNCBUSY_CMD_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_PCH0_PRSCTRL (0x1UL << 2) /**< PCH0_PRSCTRL Register Busy */ #define _WDOG_SYNCBUSY_PCH0_PRSCTRL_SHIFT 2 /**< Shift value for WDOG_PCH0_PRSCTRL */ #define _WDOG_SYNCBUSY_PCH0_PRSCTRL_MASK 0x4UL /**< Bit mask for WDOG_PCH0_PRSCTRL */ #define _WDOG_SYNCBUSY_PCH0_PRSCTRL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_PCH0_PRSCTRL_DEFAULT (_WDOG_SYNCBUSY_PCH0_PRSCTRL_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_PCH1_PRSCTRL (0x1UL << 3) /**< PCH1_PRSCTRL Register Busy */ #define _WDOG_SYNCBUSY_PCH1_PRSCTRL_SHIFT 3 /**< Shift value for WDOG_PCH1_PRSCTRL */ #define _WDOG_SYNCBUSY_PCH1_PRSCTRL_MASK 0x8UL /**< Bit mask for WDOG_PCH1_PRSCTRL */ #define _WDOG_SYNCBUSY_PCH1_PRSCTRL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_SYNCBUSY */ #define WDOG_SYNCBUSY_PCH1_PRSCTRL_DEFAULT (_WDOG_SYNCBUSY_PCH1_PRSCTRL_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_SYNCBUSY */ /* Bit fields for WDOG PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_RESETVALUE 0x00000000UL /**< Default value for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_MASK 0x0000010FUL /**< Mask for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_SHIFT 0 /**< Shift value for WDOG_PRSSEL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_MASK 0xFUL /**< Bit mask for WDOG_PRSSEL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH0 0x00000000UL /**< Mode PRSCH0 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH1 0x00000001UL /**< Mode PRSCH1 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH2 0x00000002UL /**< Mode PRSCH2 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH3 0x00000003UL /**< Mode PRSCH3 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH4 0x00000004UL /**< Mode PRSCH4 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH5 0x00000005UL /**< Mode PRSCH5 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH6 0x00000006UL /**< Mode PRSCH6 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH7 0x00000007UL /**< Mode PRSCH7 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH8 0x00000008UL /**< Mode PRSCH8 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH9 0x00000009UL /**< Mode PRSCH9 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH10 0x0000000AUL /**< Mode PRSCH10 for WDOG_PCH_PRSCTRL */ #define _WDOG_PCH_PRSCTRL_PRSSEL_PRSCH11 0x0000000BUL /**< Mode PRSCH11 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_DEFAULT (_WDOG_PCH_PRSCTRL_PRSSEL_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH0 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH0 << 0) /**< Shifted mode PRSCH0 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH1 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH1 << 0) /**< Shifted mode PRSCH1 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH2 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH2 << 0) /**< Shifted mode PRSCH2 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH3 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH3 << 0) /**< Shifted mode PRSCH3 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH4 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH4 << 0) /**< Shifted mode PRSCH4 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH5 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH5 << 0) /**< Shifted mode PRSCH5 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH6 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH6 << 0) /**< Shifted mode PRSCH6 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH7 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH7 << 0) /**< Shifted mode PRSCH7 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH8 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH8 << 0) /**< Shifted mode PRSCH8 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH9 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH9 << 0) /**< Shifted mode PRSCH9 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH10 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH10 << 0) /**< Shifted mode PRSCH10 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSSEL_PRSCH11 (_WDOG_PCH_PRSCTRL_PRSSEL_PRSCH11 << 0) /**< Shifted mode PRSCH11 for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSMISSRSTEN (0x1UL << 8) /**< PRS Missing Event Will Trigger a Watchdog Reset */ #define _WDOG_PCH_PRSCTRL_PRSMISSRSTEN_SHIFT 8 /**< Shift value for WDOG_PRSMISSRSTEN */ #define _WDOG_PCH_PRSCTRL_PRSMISSRSTEN_MASK 0x100UL /**< Bit mask for WDOG_PRSMISSRSTEN */ #define _WDOG_PCH_PRSCTRL_PRSMISSRSTEN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_PCH_PRSCTRL */ #define WDOG_PCH_PRSCTRL_PRSMISSRSTEN_DEFAULT (_WDOG_PCH_PRSCTRL_PRSMISSRSTEN_DEFAULT << 8) /**< Shifted mode DEFAULT for WDOG_PCH_PRSCTRL */ /* Bit fields for WDOG IF */ #define _WDOG_IF_RESETVALUE 0x00000000UL /**< Default value for WDOG_IF */ #define _WDOG_IF_MASK 0x0000001FUL /**< Mask for WDOG_IF */ #define WDOG_IF_TOUT (0x1UL << 0) /**< WDOG Timeout Interrupt Flag */ #define _WDOG_IF_TOUT_SHIFT 0 /**< Shift value for WDOG_TOUT */ #define _WDOG_IF_TOUT_MASK 0x1UL /**< Bit mask for WDOG_TOUT */ #define _WDOG_IF_TOUT_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IF */ #define WDOG_IF_TOUT_DEFAULT (_WDOG_IF_TOUT_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_IF */ #define WDOG_IF_WARN (0x1UL << 1) /**< WDOG Warning Timeout Interrupt Flag */ #define _WDOG_IF_WARN_SHIFT 1 /**< Shift value for WDOG_WARN */ #define _WDOG_IF_WARN_MASK 0x2UL /**< Bit mask for WDOG_WARN */ #define _WDOG_IF_WARN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IF */ #define WDOG_IF_WARN_DEFAULT (_WDOG_IF_WARN_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_IF */ #define WDOG_IF_WIN (0x1UL << 2) /**< WDOG Window Interrupt Flag */ #define _WDOG_IF_WIN_SHIFT 2 /**< Shift value for WDOG_WIN */ #define _WDOG_IF_WIN_MASK 0x4UL /**< Bit mask for WDOG_WIN */ #define _WDOG_IF_WIN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IF */ #define WDOG_IF_WIN_DEFAULT (_WDOG_IF_WIN_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_IF */ #define WDOG_IF_PEM0 (0x1UL << 3) /**< PRS Channel Zero Event Missing Interrupt Flag */ #define _WDOG_IF_PEM0_SHIFT 3 /**< Shift value for WDOG_PEM0 */ #define _WDOG_IF_PEM0_MASK 0x8UL /**< Bit mask for WDOG_PEM0 */ #define _WDOG_IF_PEM0_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IF */ #define WDOG_IF_PEM0_DEFAULT (_WDOG_IF_PEM0_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_IF */ #define WDOG_IF_PEM1 (0x1UL << 4) /**< PRS Channel One Event Missing Interrupt Flag */ #define _WDOG_IF_PEM1_SHIFT 4 /**< Shift value for WDOG_PEM1 */ #define _WDOG_IF_PEM1_MASK 0x10UL /**< Bit mask for WDOG_PEM1 */ #define _WDOG_IF_PEM1_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IF */ #define WDOG_IF_PEM1_DEFAULT (_WDOG_IF_PEM1_DEFAULT << 4) /**< Shifted mode DEFAULT for WDOG_IF */ /* Bit fields for WDOG IFS */ #define _WDOG_IFS_RESETVALUE 0x00000000UL /**< Default value for WDOG_IFS */ #define _WDOG_IFS_MASK 0x0000001FUL /**< Mask for WDOG_IFS */ #define WDOG_IFS_TOUT (0x1UL << 0) /**< Set TOUT Interrupt Flag */ #define _WDOG_IFS_TOUT_SHIFT 0 /**< Shift value for WDOG_TOUT */ #define _WDOG_IFS_TOUT_MASK 0x1UL /**< Bit mask for WDOG_TOUT */ #define _WDOG_IFS_TOUT_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_TOUT_DEFAULT (_WDOG_IFS_TOUT_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_WARN (0x1UL << 1) /**< Set WARN Interrupt Flag */ #define _WDOG_IFS_WARN_SHIFT 1 /**< Shift value for WDOG_WARN */ #define _WDOG_IFS_WARN_MASK 0x2UL /**< Bit mask for WDOG_WARN */ #define _WDOG_IFS_WARN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_WARN_DEFAULT (_WDOG_IFS_WARN_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_WIN (0x1UL << 2) /**< Set WIN Interrupt Flag */ #define _WDOG_IFS_WIN_SHIFT 2 /**< Shift value for WDOG_WIN */ #define _WDOG_IFS_WIN_MASK 0x4UL /**< Bit mask for WDOG_WIN */ #define _WDOG_IFS_WIN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_WIN_DEFAULT (_WDOG_IFS_WIN_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_PEM0 (0x1UL << 3) /**< Set PEM0 Interrupt Flag */ #define _WDOG_IFS_PEM0_SHIFT 3 /**< Shift value for WDOG_PEM0 */ #define _WDOG_IFS_PEM0_MASK 0x8UL /**< Bit mask for WDOG_PEM0 */ #define _WDOG_IFS_PEM0_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_PEM0_DEFAULT (_WDOG_IFS_PEM0_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_PEM1 (0x1UL << 4) /**< Set PEM1 Interrupt Flag */ #define _WDOG_IFS_PEM1_SHIFT 4 /**< Shift value for WDOG_PEM1 */ #define _WDOG_IFS_PEM1_MASK 0x10UL /**< Bit mask for WDOG_PEM1 */ #define _WDOG_IFS_PEM1_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFS */ #define WDOG_IFS_PEM1_DEFAULT (_WDOG_IFS_PEM1_DEFAULT << 4) /**< Shifted mode DEFAULT for WDOG_IFS */ /* Bit fields for WDOG IFC */ #define _WDOG_IFC_RESETVALUE 0x00000000UL /**< Default value for WDOG_IFC */ #define _WDOG_IFC_MASK 0x0000001FUL /**< Mask for WDOG_IFC */ #define WDOG_IFC_TOUT (0x1UL << 0) /**< Clear TOUT Interrupt Flag */ #define _WDOG_IFC_TOUT_SHIFT 0 /**< Shift value for WDOG_TOUT */ #define _WDOG_IFC_TOUT_MASK 0x1UL /**< Bit mask for WDOG_TOUT */ #define _WDOG_IFC_TOUT_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_TOUT_DEFAULT (_WDOG_IFC_TOUT_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_WARN (0x1UL << 1) /**< Clear WARN Interrupt Flag */ #define _WDOG_IFC_WARN_SHIFT 1 /**< Shift value for WDOG_WARN */ #define _WDOG_IFC_WARN_MASK 0x2UL /**< Bit mask for WDOG_WARN */ #define _WDOG_IFC_WARN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_WARN_DEFAULT (_WDOG_IFC_WARN_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_WIN (0x1UL << 2) /**< Clear WIN Interrupt Flag */ #define _WDOG_IFC_WIN_SHIFT 2 /**< Shift value for WDOG_WIN */ #define _WDOG_IFC_WIN_MASK 0x4UL /**< Bit mask for WDOG_WIN */ #define _WDOG_IFC_WIN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_WIN_DEFAULT (_WDOG_IFC_WIN_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_PEM0 (0x1UL << 3) /**< Clear PEM0 Interrupt Flag */ #define _WDOG_IFC_PEM0_SHIFT 3 /**< Shift value for WDOG_PEM0 */ #define _WDOG_IFC_PEM0_MASK 0x8UL /**< Bit mask for WDOG_PEM0 */ #define _WDOG_IFC_PEM0_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_PEM0_DEFAULT (_WDOG_IFC_PEM0_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_PEM1 (0x1UL << 4) /**< Clear PEM1 Interrupt Flag */ #define _WDOG_IFC_PEM1_SHIFT 4 /**< Shift value for WDOG_PEM1 */ #define _WDOG_IFC_PEM1_MASK 0x10UL /**< Bit mask for WDOG_PEM1 */ #define _WDOG_IFC_PEM1_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IFC */ #define WDOG_IFC_PEM1_DEFAULT (_WDOG_IFC_PEM1_DEFAULT << 4) /**< Shifted mode DEFAULT for WDOG_IFC */ /* Bit fields for WDOG IEN */ #define _WDOG_IEN_RESETVALUE 0x00000000UL /**< Default value for WDOG_IEN */ #define _WDOG_IEN_MASK 0x0000001FUL /**< Mask for WDOG_IEN */ #define WDOG_IEN_TOUT (0x1UL << 0) /**< TOUT Interrupt Enable */ #define _WDOG_IEN_TOUT_SHIFT 0 /**< Shift value for WDOG_TOUT */ #define _WDOG_IEN_TOUT_MASK 0x1UL /**< Bit mask for WDOG_TOUT */ #define _WDOG_IEN_TOUT_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_TOUT_DEFAULT (_WDOG_IEN_TOUT_DEFAULT << 0) /**< Shifted mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_WARN (0x1UL << 1) /**< WARN Interrupt Enable */ #define _WDOG_IEN_WARN_SHIFT 1 /**< Shift value for WDOG_WARN */ #define _WDOG_IEN_WARN_MASK 0x2UL /**< Bit mask for WDOG_WARN */ #define _WDOG_IEN_WARN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_WARN_DEFAULT (_WDOG_IEN_WARN_DEFAULT << 1) /**< Shifted mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_WIN (0x1UL << 2) /**< WIN Interrupt Enable */ #define _WDOG_IEN_WIN_SHIFT 2 /**< Shift value for WDOG_WIN */ #define _WDOG_IEN_WIN_MASK 0x4UL /**< Bit mask for WDOG_WIN */ #define _WDOG_IEN_WIN_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_WIN_DEFAULT (_WDOG_IEN_WIN_DEFAULT << 2) /**< Shifted mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_PEM0 (0x1UL << 3) /**< PEM0 Interrupt Enable */ #define _WDOG_IEN_PEM0_SHIFT 3 /**< Shift value for WDOG_PEM0 */ #define _WDOG_IEN_PEM0_MASK 0x8UL /**< Bit mask for WDOG_PEM0 */ #define _WDOG_IEN_PEM0_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_PEM0_DEFAULT (_WDOG_IEN_PEM0_DEFAULT << 3) /**< Shifted mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_PEM1 (0x1UL << 4) /**< PEM1 Interrupt Enable */ #define _WDOG_IEN_PEM1_SHIFT 4 /**< Shift value for WDOG_PEM1 */ #define _WDOG_IEN_PEM1_MASK 0x10UL /**< Bit mask for WDOG_PEM1 */ #define _WDOG_IEN_PEM1_DEFAULT 0x00000000UL /**< Mode DEFAULT for WDOG_IEN */ #define WDOG_IEN_PEM1_DEFAULT (_WDOG_IEN_PEM1_DEFAULT << 4) /**< Shifted mode DEFAULT for WDOG_IEN */ /** @} */ /** @} End of group EFR32BG12P_WDOG */ /** @} End of group Parts */
101.020408
151
0.528745
7f3c063834b2a35d92845df676fda2b280c2f71a
11,109
h
C
cppwinrt/impl/Windows.UI.Shell.0.h
RakeshShrestha/C-Calendar-Library
c2525f3cdcfdccbc57baf908ad80fd3bd976016d
[ "Apache-2.0" ]
1
2021-12-30T11:10:30.000Z
2021-12-30T11:10:30.000Z
cppwinrt/impl/Windows.UI.Shell.0.h
RakeshShrestha/C-Calendar-Library
c2525f3cdcfdccbc57baf908ad80fd3bd976016d
[ "Apache-2.0" ]
null
null
null
cppwinrt/impl/Windows.UI.Shell.0.h
RakeshShrestha/C-Calendar-Library
c2525f3cdcfdccbc57baf908ad80fd3bd976016d
[ "Apache-2.0" ]
null
null
null
// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.200117.5 #ifndef WINRT_Windows_UI_Shell_0_H #define WINRT_Windows_UI_Shell_0_H WINRT_EXPORT namespace winrt::Windows::ApplicationModel::Core { struct AppListEntry; } WINRT_EXPORT namespace winrt::Windows::Foundation { template <typename TResult> struct IAsyncOperation; struct Uri; } WINRT_EXPORT namespace winrt::Windows::UI::StartScreen { struct SecondaryTile; } WINRT_EXPORT namespace winrt::Windows::UI::Shell { enum class SecurityAppKind : int32_t { WebProtection = 0, }; enum class SecurityAppState : int32_t { Disabled = 0, Enabled = 1, }; enum class SecurityAppSubstatus : int32_t { Undetermined = 0, NoActionNeeded = 1, ActionRecommended = 2, ActionNeeded = 3, }; struct IAdaptiveCard; struct IAdaptiveCardBuilderStatics; struct ISecurityAppManager; struct ITaskbarManager; struct ITaskbarManager2; struct ITaskbarManagerStatics; struct AdaptiveCardBuilder; struct SecurityAppManager; struct TaskbarManager; } namespace winrt::impl { template <> struct category<Windows::UI::Shell::IAdaptiveCard>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::IAdaptiveCardBuilderStatics>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::ISecurityAppManager>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::ITaskbarManager>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::ITaskbarManager2>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::ITaskbarManagerStatics>{ using type = interface_category; }; template <> struct category<Windows::UI::Shell::AdaptiveCardBuilder>{ using type = class_category; }; template <> struct category<Windows::UI::Shell::SecurityAppManager>{ using type = class_category; }; template <> struct category<Windows::UI::Shell::TaskbarManager>{ using type = class_category; }; template <> struct category<Windows::UI::Shell::SecurityAppKind>{ using type = enum_category; }; template <> struct category<Windows::UI::Shell::SecurityAppState>{ using type = enum_category; }; template <> struct category<Windows::UI::Shell::SecurityAppSubstatus>{ using type = enum_category; }; template <> inline constexpr auto& name_v<Windows::UI::Shell::AdaptiveCardBuilder> = L"Windows.UI.Shell.AdaptiveCardBuilder"; template <> inline constexpr auto& name_v<Windows::UI::Shell::SecurityAppManager> = L"Windows.UI.Shell.SecurityAppManager"; template <> inline constexpr auto& name_v<Windows::UI::Shell::TaskbarManager> = L"Windows.UI.Shell.TaskbarManager"; template <> inline constexpr auto& name_v<Windows::UI::Shell::SecurityAppKind> = L"Windows.UI.Shell.SecurityAppKind"; template <> inline constexpr auto& name_v<Windows::UI::Shell::SecurityAppState> = L"Windows.UI.Shell.SecurityAppState"; template <> inline constexpr auto& name_v<Windows::UI::Shell::SecurityAppSubstatus> = L"Windows.UI.Shell.SecurityAppSubstatus"; template <> inline constexpr auto& name_v<Windows::UI::Shell::IAdaptiveCard> = L"Windows.UI.Shell.IAdaptiveCard"; template <> inline constexpr auto& name_v<Windows::UI::Shell::IAdaptiveCardBuilderStatics> = L"Windows.UI.Shell.IAdaptiveCardBuilderStatics"; template <> inline constexpr auto& name_v<Windows::UI::Shell::ISecurityAppManager> = L"Windows.UI.Shell.ISecurityAppManager"; template <> inline constexpr auto& name_v<Windows::UI::Shell::ITaskbarManager> = L"Windows.UI.Shell.ITaskbarManager"; template <> inline constexpr auto& name_v<Windows::UI::Shell::ITaskbarManager2> = L"Windows.UI.Shell.ITaskbarManager2"; template <> inline constexpr auto& name_v<Windows::UI::Shell::ITaskbarManagerStatics> = L"Windows.UI.Shell.ITaskbarManagerStatics"; template <> inline constexpr guid guid_v<Windows::UI::Shell::IAdaptiveCard>{ 0x72D0568C,0xA274,0x41CD,{ 0x82,0xA8,0x98,0x9D,0x40,0xB9,0xB0,0x5E } }; template <> inline constexpr guid guid_v<Windows::UI::Shell::IAdaptiveCardBuilderStatics>{ 0x766D8F08,0xD3FE,0x4347,{ 0xA0,0xBC,0xB9,0xEA,0x9A,0x6D,0xC2,0x8E } }; template <> inline constexpr guid guid_v<Windows::UI::Shell::ISecurityAppManager>{ 0x96AC500C,0xAED4,0x561D,{ 0xBD,0xE8,0x95,0x35,0x20,0x34,0x3A,0x2D } }; template <> inline constexpr guid guid_v<Windows::UI::Shell::ITaskbarManager>{ 0x87490A19,0x1AD9,0x49F4,{ 0xB2,0xE8,0x86,0x73,0x8D,0xC5,0xAC,0x40 } }; template <> inline constexpr guid guid_v<Windows::UI::Shell::ITaskbarManager2>{ 0x79F0A06E,0x7B02,0x4911,{ 0x91,0x8C,0xDE,0xE0,0xBB,0xD2,0x0B,0xA4 } }; template <> inline constexpr guid guid_v<Windows::UI::Shell::ITaskbarManagerStatics>{ 0xDB32AB74,0xDE52,0x4FE6,{ 0xB7,0xB6,0x95,0xFF,0x9F,0x83,0x95,0xDF } }; template <> struct default_interface<Windows::UI::Shell::SecurityAppManager>{ using type = Windows::UI::Shell::ISecurityAppManager; }; template <> struct default_interface<Windows::UI::Shell::TaskbarManager>{ using type = Windows::UI::Shell::ITaskbarManager; }; template <> struct abi<Windows::UI::Shell::IAdaptiveCard> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall ToJson(void**) noexcept = 0; }; }; template <> struct abi<Windows::UI::Shell::IAdaptiveCardBuilderStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall CreateAdaptiveCardFromJson(void*, void**) noexcept = 0; }; }; template <> struct abi<Windows::UI::Shell::ISecurityAppManager> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall Register(int32_t, void*, void*, bool, winrt::guid*) noexcept = 0; virtual int32_t __stdcall Unregister(int32_t, winrt::guid) noexcept = 0; virtual int32_t __stdcall UpdateState(int32_t, winrt::guid, int32_t, int32_t, void*) noexcept = 0; }; }; template <> struct abi<Windows::UI::Shell::ITaskbarManager> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall get_IsSupported(bool*) noexcept = 0; virtual int32_t __stdcall get_IsPinningAllowed(bool*) noexcept = 0; virtual int32_t __stdcall IsCurrentAppPinnedAsync(void**) noexcept = 0; virtual int32_t __stdcall IsAppListEntryPinnedAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall RequestPinCurrentAppAsync(void**) noexcept = 0; virtual int32_t __stdcall RequestPinAppListEntryAsync(void*, void**) noexcept = 0; }; }; template <> struct abi<Windows::UI::Shell::ITaskbarManager2> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall IsSecondaryTilePinnedAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall RequestPinSecondaryTileAsync(void*, void**) noexcept = 0; virtual int32_t __stdcall TryUnpinSecondaryTileAsync(void*, void**) noexcept = 0; }; }; template <> struct abi<Windows::UI::Shell::ITaskbarManagerStatics> { struct __declspec(novtable) type : inspectable_abi { virtual int32_t __stdcall GetDefault(void**) noexcept = 0; }; }; template <typename D> struct consume_Windows_UI_Shell_IAdaptiveCard { WINRT_IMPL_AUTO(hstring) ToJson() const; }; template <> struct consume<Windows::UI::Shell::IAdaptiveCard> { template <typename D> using type = consume_Windows_UI_Shell_IAdaptiveCard<D>; }; template <typename D> struct consume_Windows_UI_Shell_IAdaptiveCardBuilderStatics { WINRT_IMPL_AUTO(Windows::UI::Shell::IAdaptiveCard) CreateAdaptiveCardFromJson(param::hstring const& value) const; }; template <> struct consume<Windows::UI::Shell::IAdaptiveCardBuilderStatics> { template <typename D> using type = consume_Windows_UI_Shell_IAdaptiveCardBuilderStatics<D>; }; template <typename D> struct consume_Windows_UI_Shell_ISecurityAppManager { WINRT_IMPL_AUTO(winrt::guid) Register(Windows::UI::Shell::SecurityAppKind const& kind, param::hstring const& displayName, Windows::Foundation::Uri const& detailsUri, bool registerPerUser) const; WINRT_IMPL_AUTO(void) Unregister(Windows::UI::Shell::SecurityAppKind const& kind, winrt::guid const& guidRegistration) const; WINRT_IMPL_AUTO(void) UpdateState(Windows::UI::Shell::SecurityAppKind const& kind, winrt::guid const& guidRegistration, Windows::UI::Shell::SecurityAppState const& state, Windows::UI::Shell::SecurityAppSubstatus const& substatus, Windows::Foundation::Uri const& detailsUri) const; }; template <> struct consume<Windows::UI::Shell::ISecurityAppManager> { template <typename D> using type = consume_Windows_UI_Shell_ISecurityAppManager<D>; }; template <typename D> struct consume_Windows_UI_Shell_ITaskbarManager { [[nodiscard]] WINRT_IMPL_AUTO(bool) IsSupported() const; [[nodiscard]] WINRT_IMPL_AUTO(bool) IsPinningAllowed() const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) IsCurrentAppPinnedAsync() const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) IsAppListEntryPinnedAsync(Windows::ApplicationModel::Core::AppListEntry const& appListEntry) const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) RequestPinCurrentAppAsync() const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) RequestPinAppListEntryAsync(Windows::ApplicationModel::Core::AppListEntry const& appListEntry) const; }; template <> struct consume<Windows::UI::Shell::ITaskbarManager> { template <typename D> using type = consume_Windows_UI_Shell_ITaskbarManager<D>; }; template <typename D> struct consume_Windows_UI_Shell_ITaskbarManager2 { WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) IsSecondaryTilePinnedAsync(param::hstring const& tileId) const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) RequestPinSecondaryTileAsync(Windows::UI::StartScreen::SecondaryTile const& secondaryTile) const; WINRT_IMPL_AUTO(Windows::Foundation::IAsyncOperation<bool>) TryUnpinSecondaryTileAsync(param::hstring const& tileId) const; }; template <> struct consume<Windows::UI::Shell::ITaskbarManager2> { template <typename D> using type = consume_Windows_UI_Shell_ITaskbarManager2<D>; }; template <typename D> struct consume_Windows_UI_Shell_ITaskbarManagerStatics { WINRT_IMPL_AUTO(Windows::UI::Shell::TaskbarManager) GetDefault() const; }; template <> struct consume<Windows::UI::Shell::ITaskbarManagerStatics> { template <typename D> using type = consume_Windows_UI_Shell_ITaskbarManagerStatics<D>; }; } #endif
56.678571
288
0.722297
fa0bfee5adaae93f6e75dcf36a73fb460b2bfc36
15,924
c
C
subversion/libsvn_fs_base/bdb/changes-table.c
tux-mind/platform_external_subversion
e3e715b637b0b7c6a6a02316f3be48f2c1d5181c
[ "Apache-2.0" ]
2
2019-10-31T18:33:15.000Z
2021-09-19T20:04:03.000Z
subversion/libsvn_fs_base/bdb/changes-table.c
wbond/subversion
018aaa1933687f28bbfdcad9b7b988fd7435afcd
[ "Apache-2.0" ]
null
null
null
subversion/libsvn_fs_base/bdb/changes-table.c
wbond/subversion
018aaa1933687f28bbfdcad9b7b988fd7435afcd
[ "Apache-2.0" ]
2
2019-10-31T18:33:29.000Z
2020-02-15T03:57:13.000Z
/* changes-table.c : operations on the `changes' table * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== */ #include "bdb_compat.h" #include <apr_hash.h> #include <apr_tables.h> #include "svn_fs.h" #include "svn_pools.h" #include "svn_path.h" #include "../fs.h" #include "../err.h" #include "../trail.h" #include "../id.h" #include "../util/fs_skels.h" #include "../../libsvn_fs/fs-loader.h" #include "bdb-err.h" #include "dbt.h" #include "changes-table.h" #include "private/svn_fs_util.h" #include "private/svn_fspath.h" #include "svn_private_config.h" /*** Creating and opening the changes table. ***/ int svn_fs_bdb__open_changes_table(DB **changes_p, DB_ENV *env, svn_boolean_t create) { const u_int32_t open_flags = (create ? (DB_CREATE | DB_EXCL) : 0); DB *changes; BDB_ERR(svn_fs_bdb__check_version()); BDB_ERR(db_create(&changes, env, 0)); /* Enable duplicate keys. This allows us to store the changes one-per-row. Note: this must occur before ->open(). */ BDB_ERR(changes->set_flags(changes, DB_DUP)); BDB_ERR((changes->open)(SVN_BDB_OPEN_PARAMS(changes, NULL), "changes", 0, DB_BTREE, open_flags, 0666)); *changes_p = changes; return 0; } /*** Storing and retrieving changes. ***/ svn_error_t * svn_fs_bdb__changes_add(svn_fs_t *fs, const char *key, change_t *change, trail_t *trail, apr_pool_t *pool) { base_fs_data_t *bfd = fs->fsap_data; DBT query, value; svn_skel_t *skel; /* Convert native type to skel. */ SVN_ERR(svn_fs_base__unparse_change_skel(&skel, change, pool)); /* Store a new record into the database. */ svn_fs_base__str_to_dbt(&query, key); svn_fs_base__skel_to_dbt(&value, skel, pool); svn_fs_base__trail_debug(trail, "changes", "put"); return BDB_WRAP(fs, _("creating change"), bfd->changes->put(bfd->changes, trail->db_txn, &query, &value, 0)); } svn_error_t * svn_fs_bdb__changes_delete(svn_fs_t *fs, const char *key, trail_t *trail, apr_pool_t *pool) { int db_err; DBT query; base_fs_data_t *bfd = fs->fsap_data; svn_fs_base__trail_debug(trail, "changes", "del"); db_err = bfd->changes->del(bfd->changes, trail->db_txn, svn_fs_base__str_to_dbt(&query, key), 0); /* If there're no changes for KEY, that is acceptable. Any other error should be propagated to the caller, though. */ if ((db_err) && (db_err != DB_NOTFOUND)) { SVN_ERR(BDB_WRAP(fs, _("deleting changes"), db_err)); } return SVN_NO_ERROR; } /* Merge the internal-use-only CHANGE into a hash of public-FS svn_fs_path_change2_t CHANGES, collapsing multiple changes into a single succinct change per path. */ static svn_error_t * fold_change(apr_hash_t *changes, const change_t *change) { apr_pool_t *pool = apr_hash_pool_get(changes); svn_fs_path_change2_t *old_change, *new_change; const char *path; if ((old_change = apr_hash_get(changes, change->path, APR_HASH_KEY_STRING))) { /* This path already exists in the hash, so we have to merge this change into the already existing one. */ /* Since the path already exists in the hash, we don't have to dup the allocation for the path itself. */ path = change->path; /* Sanity check: only allow NULL node revision ID in the `reset' case. */ if ((! change->noderev_id) && (change->kind != svn_fs_path_change_reset)) return svn_error_create (SVN_ERR_FS_CORRUPT, NULL, _("Missing required node revision ID")); /* Sanity check: we should be talking about the same node revision ID as our last change except where the last change was a deletion. */ if (change->noderev_id && (! svn_fs_base__id_eq(old_change->node_rev_id, change->noderev_id)) && (old_change->change_kind != svn_fs_path_change_delete)) return svn_error_create (SVN_ERR_FS_CORRUPT, NULL, _("Invalid change ordering: new node revision ID without delete")); /* Sanity check: an add, replacement, or reset must be the first thing to follow a deletion. */ if ((old_change->change_kind == svn_fs_path_change_delete) && (! ((change->kind == svn_fs_path_change_replace) || (change->kind == svn_fs_path_change_reset) || (change->kind == svn_fs_path_change_add)))) return svn_error_create (SVN_ERR_FS_CORRUPT, NULL, _("Invalid change ordering: non-add change on deleted path")); /* Sanity check: an add can't follow anything except a delete or reset. */ if ((change->kind == svn_fs_path_change_add) && (old_change->change_kind != svn_fs_path_change_delete) && (old_change->change_kind != svn_fs_path_change_reset)) return svn_error_create (SVN_ERR_FS_CORRUPT, NULL, _("Invalid change ordering: add change on preexisting path")); /* Now, merge that change in. */ switch (change->kind) { case svn_fs_path_change_reset: /* A reset here will simply remove the path change from the hash. */ old_change = NULL; break; case svn_fs_path_change_delete: if (old_change->change_kind == svn_fs_path_change_add) { /* If the path was introduced in this transaction via an add, and we are deleting it, just remove the path altogether. */ old_change = NULL; } else { /* A deletion overrules all previous changes. */ old_change->change_kind = svn_fs_path_change_delete; old_change->text_mod = change->text_mod; old_change->prop_mod = change->prop_mod; } break; case svn_fs_path_change_add: case svn_fs_path_change_replace: /* An add at this point must be following a previous delete, so treat it just like a replace. */ old_change->change_kind = svn_fs_path_change_replace; old_change->node_rev_id = svn_fs_base__id_copy(change->noderev_id, pool); old_change->text_mod = change->text_mod; old_change->prop_mod = change->prop_mod; break; case svn_fs_path_change_modify: default: if (change->text_mod) old_change->text_mod = TRUE; if (change->prop_mod) old_change->prop_mod = TRUE; break; } /* Point our new_change to our (possibly modified) old_change. */ new_change = old_change; } else { /* This change is new to the hash, so make a new public change structure from the internal one (in the hash's pool), and dup the path into the hash's pool, too. */ new_change = svn_fs__path_change_create_internal( svn_fs_base__id_copy(change->noderev_id, pool), change->kind, pool); new_change->text_mod = change->text_mod; new_change->prop_mod = change->prop_mod; new_change->node_kind = svn_node_unknown; new_change->copyfrom_known = FALSE; path = apr_pstrdup(pool, change->path); } /* Add (or update) this path. */ apr_hash_set(changes, path, APR_HASH_KEY_STRING, new_change); return SVN_NO_ERROR; } svn_error_t * svn_fs_bdb__changes_fetch(apr_hash_t **changes_p, svn_fs_t *fs, const char *key, trail_t *trail, apr_pool_t *pool) { base_fs_data_t *bfd = fs->fsap_data; DBC *cursor; DBT query, result; int db_err = 0, db_c_err = 0; svn_error_t *err = SVN_NO_ERROR; apr_hash_t *changes = apr_hash_make(pool); apr_pool_t *subpool = svn_pool_create(pool); /* Get a cursor on the first record matching KEY, and then loop over the records, adding them to the return array. */ svn_fs_base__trail_debug(trail, "changes", "cursor"); SVN_ERR(BDB_WRAP(fs, _("creating cursor for reading changes"), bfd->changes->cursor(bfd->changes, trail->db_txn, &cursor, 0))); /* Advance the cursor to the key that we're looking for. */ svn_fs_base__str_to_dbt(&query, key); svn_fs_base__result_dbt(&result); db_err = svn_bdb_dbc_get(cursor, &query, &result, DB_SET); if (! db_err) svn_fs_base__track_dbt(&result, pool); while (! db_err) { change_t *change; svn_skel_t *result_skel; /* Clear the per-iteration subpool. */ svn_pool_clear(subpool); /* RESULT now contains a change record associated with KEY. We need to parse that skel into an change_t structure ... */ result_skel = svn_skel__parse(result.data, result.size, subpool); if (! result_skel) { err = svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, _("Error reading changes for key '%s'"), key); goto cleanup; } err = svn_fs_base__parse_change_skel(&change, result_skel, subpool); if (err) goto cleanup; /* ... and merge it with our return hash. */ err = fold_change(changes, change); if (err) goto cleanup; /* Now, if our change was a deletion or replacement, we have to blow away any changes thus far on paths that are (or, were) children of this path. ### i won't bother with another iteration pool here -- at most we talking about a few extra dups of paths into what is already a temporary subpool. */ if ((change->kind == svn_fs_path_change_delete) || (change->kind == svn_fs_path_change_replace)) { apr_hash_index_t *hi; for (hi = apr_hash_first(subpool, changes); hi; hi = apr_hash_next(hi)) { /* KEY is the path. */ const void *hashkey; apr_ssize_t klen; apr_hash_this(hi, &hashkey, &klen, NULL); /* If we come across our own path, ignore it. */ if (strcmp(change->path, hashkey) == 0) continue; /* If we come across a child of our path, remove it. */ if (svn_fspath__is_child(change->path, hashkey, subpool)) apr_hash_set(changes, hashkey, klen, NULL); } } /* Advance the cursor to the next record with this same KEY, and fetch that record. */ svn_fs_base__result_dbt(&result); db_err = svn_bdb_dbc_get(cursor, &query, &result, DB_NEXT_DUP); if (! db_err) svn_fs_base__track_dbt(&result, pool); } /* Destroy the per-iteration subpool. */ svn_pool_destroy(subpool); /* If there are no (more) change records for this KEY, we're finished. Just return the (possibly empty) array. Any other error, however, needs to get handled appropriately. */ if (db_err && (db_err != DB_NOTFOUND)) err = BDB_WRAP(fs, _("fetching changes"), db_err); cleanup: /* Close the cursor. */ db_c_err = svn_bdb_dbc_close(cursor); /* If we had an error prior to closing the cursor, return the error. */ if (err) return svn_error_trace(err); /* If our only error thus far was when we closed the cursor, return that error. */ if (db_c_err) SVN_ERR(BDB_WRAP(fs, _("closing changes cursor"), db_c_err)); /* Finally, set our return variable and get outta here. */ *changes_p = changes; return SVN_NO_ERROR; } svn_error_t * svn_fs_bdb__changes_fetch_raw(apr_array_header_t **changes_p, svn_fs_t *fs, const char *key, trail_t *trail, apr_pool_t *pool) { base_fs_data_t *bfd = fs->fsap_data; DBC *cursor; DBT query, result; int db_err = 0, db_c_err = 0; svn_error_t *err = SVN_NO_ERROR; change_t *change; apr_array_header_t *changes = apr_array_make(pool, 4, sizeof(change)); /* Get a cursor on the first record matching KEY, and then loop over the records, adding them to the return array. */ svn_fs_base__trail_debug(trail, "changes", "cursor"); SVN_ERR(BDB_WRAP(fs, _("creating cursor for reading changes"), bfd->changes->cursor(bfd->changes, trail->db_txn, &cursor, 0))); /* Advance the cursor to the key that we're looking for. */ svn_fs_base__str_to_dbt(&query, key); svn_fs_base__result_dbt(&result); db_err = svn_bdb_dbc_get(cursor, &query, &result, DB_SET); if (! db_err) svn_fs_base__track_dbt(&result, pool); while (! db_err) { svn_skel_t *result_skel; /* RESULT now contains a change record associated with KEY. We need to parse that skel into an change_t structure ... */ result_skel = svn_skel__parse(result.data, result.size, pool); if (! result_skel) { err = svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, _("Error reading changes for key '%s'"), key); goto cleanup; } err = svn_fs_base__parse_change_skel(&change, result_skel, pool); if (err) goto cleanup; /* ... and add it to our return array. */ APR_ARRAY_PUSH(changes, change_t *) = change; /* Advance the cursor to the next record with this same KEY, and fetch that record. */ svn_fs_base__result_dbt(&result); db_err = svn_bdb_dbc_get(cursor, &query, &result, DB_NEXT_DUP); if (! db_err) svn_fs_base__track_dbt(&result, pool); } /* If there are no (more) change records for this KEY, we're finished. Just return the (possibly empty) array. Any other error, however, needs to get handled appropriately. */ if (db_err && (db_err != DB_NOTFOUND)) err = BDB_WRAP(fs, _("fetching changes"), db_err); cleanup: /* Close the cursor. */ db_c_err = svn_bdb_dbc_close(cursor); /* If we had an error prior to closing the cursor, return the error. */ if (err) return svn_error_trace(err); /* If our only error thus far was when we closed the cursor, return that error. */ if (db_c_err) SVN_ERR(BDB_WRAP(fs, _("closing changes cursor"), db_c_err)); /* Finally, set our return variable and get outta here. */ *changes_p = changes; return SVN_NO_ERROR; }
34.844639
79
0.603868
d6468b33852e07c45b4d823b7a9486af37ff4a73
608
h
C
ios/chrome/browser/physical_web/start_physical_web_discovery.h
xzhan96/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
3
2018-02-22T18:06:56.000Z
2021-08-28T12:49:27.000Z
ios/chrome/browser/physical_web/start_physical_web_discovery.h
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
ios/chrome/browser/physical_web/start_physical_web_discovery.h
emilio/chromium.src
1bd0cf3997f947746c0fc5406a2466e7b5f6159e
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2017-08-16T08:15:01.000Z
2018-03-27T00:07:30.000Z
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_CHROME_BROWSER_PHYSICAL_WEB_START_PHYSICAL_WEB_DISCOVERY_H_ #define IOS_CHROME_BROWSER_PHYSICAL_WEB_START_PHYSICAL_WEB_DISCOVERY_H_ #include "components/prefs/pref_service.h" // Checks the environment and starts Physical Web discovery if the required // conditions are met. void StartPhysicalWebDiscovery(PrefService* pref_service, bool is_incognito); #endif // IOS_CHROME_BROWSER_PHYSICAL_WEB_START_PHYSICAL_WEB_DISCOVERY_H_
40.533333
77
0.842105
d653b7bcf3a52ca915f58f155a5161e0e7f46688
8,630
h
C
sources/include/pgeometry/BatchedGeometry.h
roninest/context-project
ed0234e08fceafbdc13d82905f726fa87f40b37d
[ "MIT" ]
1
2021-11-20T20:36:07.000Z
2021-11-20T20:36:07.000Z
sources/include/pgeometry/BatchedGeometry.h
roninest/context-project
ed0234e08fceafbdc13d82905f726fa87f40b37d
[ "MIT" ]
1
2020-09-18T15:52:22.000Z
2020-09-18T15:52:22.000Z
sources/include/pgeometry/BatchedGeometry.h
roninest/context-project
ed0234e08fceafbdc13d82905f726fa87f40b37d
[ "MIT" ]
1
2020-06-08T01:08:49.000Z
2020-06-08T01:08:49.000Z
/*------------------------------------------------------------------------------------- Copyright (c) 2006 John Judnich This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------------*/ #pragma once #include <OgrePrerequisites.h> #include <OgreMovableObject.h> #include <OgreSceneNode.h> #include <OgreMaterialManager.h> namespace Forests { //-------------------------------------------------------------------------- /// A "lightweight" version of Ogre::StaticGeometry, which gives you a little /// more control over the batch materials, etc. class BatchedGeometry : public Ogre::MovableObject { public: //-------------------------------------------------------------------------- /// Visible chunk of geometry. class SubBatch : public Ogre::Renderable { protected: // A structure defining the desired position/orientation/scale of a batched mesh. The // SubMesh is not specified since that can be determined by which MeshQueue this belongs to. struct QueuedMesh { QueuedMesh(Ogre::SubMesh *sm, const Ogre::Vector3 &pos, const Ogre::Quaternion &ori, const Ogre::Vector3 &scl, const Ogre::ColourValue &clr, void *userData_ = 0) : subMesh(sm), position(pos), orientation(ori), scale(scl), color(clr), userData(userData_) { // empty } Ogre::SubMesh *subMesh; Ogre::Vector3 position; Ogre::Quaternion orientation; Ogre::Vector3 scale; Ogre::ColourValue color; void *userData; }; /// Queue of meshes for build batch of geometry typedef std::vector<QueuedMesh> TMeshQueue; // Function section public: /// Constructor SubBatch(BatchedGeometry *parent, Ogre::SubEntity *ent); /// Destructor virtual ~SubBatch(); /// void addSubEntity(Ogre::SubEntity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &orientation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color = Ogre::ColourValue::White, void *userData = nullptr); /// Build (assemble a vertex/index buffers) geometry for rendering virtual void build(); /// void clear(); /// void addSelfToRenderQueue(Ogre::RenderQueueGroup *rqg); /// void getRenderOperation(Ogre::RenderOperation &op) override; /// Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const override; /// const Ogre::LightList &getLights() const override; /// void setMaterial(Ogre::MaterialPtr &mat) { m_ptrMaterial = mat; } void setMaterialName(const Ogre::String &mat, const Ogre::String &rg = Ogre::RGN_AUTODETECT) { m_ptrMaterial = Ogre::MaterialManager::getSingleton().getByName(mat, rg); } /// Get material name. Be careful, resource group name missing const Ogre::String &getMaterialName() const { return m_ptrMaterial->getName(); } Ogre::Technique *getTechnique() const override { return m_ptrMaterial->getBestTechnique(m_ptrMaterial->getLodIndex( m_pParentGeom->m_fMinDistanceSquared * m_pParentGeom->m_fMinDistanceSquared)); } const Ogre::MaterialPtr &getMaterial() const override { return m_ptrMaterial; } void getWorldTransforms(Ogre::Matrix4 *xform) const override { *xform = m_pParentGeom->_getParentNodeFullTransform(); } const Ogre::Quaternion &getWorldOrientation() const { return m_pParentGeom->m_pSceneNode->_getDerivedOrientation(); } const Ogre::Vector3 &getWorldPosition() const { return m_pParentGeom->m_pSceneNode->_getDerivedPosition(); } bool castsShadows() const { return m_pParentGeom->getCastShadows(); } // internal fuctions private: /// Build vertex of QueuedMesh if it have identity orientation static void _buildIdentiryOrientation(const QueuedMesh &queuedMesh, const Ogre::Vector3 &parentGeomCenter, const std::vector<Ogre::VertexDeclaration::VertexElementList> &vertexBufferElements, std::vector<Ogre::uchar *> &vertexBuffers, Ogre::VertexData *dst); /// Build vertex of QueuedMesh if it have some orientation static void _buildFullTransform(const QueuedMesh &queuedMesh, const Ogre::Vector3 &parentGeomCenter, const std::vector<Ogre::VertexDeclaration::VertexElementList> &vertexBufferElements, std::vector<Ogre::uchar *> &vertexBuffers, Ogre::VertexData *dst); // Data section class SubBatch public: Ogre::VertexData *m_pVertexData = nullptr; ///< Ogre::IndexData *m_pIndexData = nullptr; ///< protected: bool m_Built = false; ///< bool m_RequireVertexColors = false; ///< Ogre::SubMesh *m_pSubMesh = nullptr; ///< Ogre::SubMesh for Index/Vertex buffers manipulation BatchedGeometry *m_pParentGeom = nullptr; ///< Ogre::MaterialPtr m_ptrMaterial; ///< TMeshQueue m_queueMesh; ///< The list of meshes to be added to this batch private: Ogre::Technique *m_pBestTechnique = nullptr; ///< Technique recalculated every frame }; // end class SubBatch //----------------------------------------------------------------------- /// Stores a list of GeomBatch'es, using a format string (generated with getGeometryFormatString()) as the key value typedef std::map<Ogre::String, SubBatch *> TSubBatchMap; typedef Ogre::MapIterator<TSubBatchMap> TSubBatchIterator; typedef Ogre::ConstMapIterator<TSubBatchMap> TConstSubBatchIterator; public: /// Constructor BatchedGeometry(Ogre::SceneManager *mgr, Ogre::SceneNode *rootSceneNode); virtual ~BatchedGeometry(); TConstSubBatchIterator getSubBatchIterator() const { return TConstSubBatchIterator(m_mapSubBatch); } TSubBatchIterator getSubBatchIterator() { return TSubBatchIterator(m_mapSubBatch); } virtual void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &orientation = Ogre::Quaternion::IDENTITY, const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE, const Ogre::ColourValue &color = Ogre::ColourValue::White); void build(); void clear(); Ogre::Vector3 _convertToLocal(const Ogre::Vector3 &globalVec) const; const Ogre::AxisAlignedBox &getBoundingBox() const override { return m_boundsAAB; } Ogre::Real getBoundingRadius() const override { return m_fRadius; } private: bool isVisible() const override; const Ogre::String &getMovableType() const override; void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables) override { /* empty */ } void _notifyCurrentCamera(Ogre::Camera *cam) override; void _updateRenderQueue(Ogre::RenderQueue *queue) override; protected: static Ogre::String getFormatString(Ogre::SubEntity *ent); static void extractVertexDataFromShared(const Ogre::MeshPtr &mesh); // Data section of BatchedGeometry class protected: bool m_Built = false; bool m_BoundsUndefined = true; Ogre::Vector3 m_vecCenter = Ogre::Vector3::ZERO; Ogre::AxisAlignedBox m_boundsAAB; TSubBatchMap m_mapSubBatch; /// Internal matrix for remap vertex type to vertex size instead call VertexElement::getTypeSize static const size_t s_vertexType2Size[Ogre::VET_COLOUR_ABGR + 1]; private: bool m_bWithinFarDistance = false; Ogre::Real m_fRadius = 0.0; Ogre::Real m_fMinDistanceSquared = 0.0; Ogre::SceneManager *m_pSceneMgr = nullptr; Ogre::SceneNode *m_pSceneNode = nullptr; Ogre::SceneNode *m_pParentSceneNode; }; }
44.715026
243
0.655041
5cb020a796931b39d07f59d16bf663489579e6c8
265
h
C
Rec/Rec/AppDelegate.h
zhufeng19940210/Animation
07b0a8790acbcd299152cf681013d4fc3baf2c59
[ "MIT" ]
null
null
null
Rec/Rec/AppDelegate.h
zhufeng19940210/Animation
07b0a8790acbcd299152cf681013d4fc3baf2c59
[ "MIT" ]
null
null
null
Rec/Rec/AppDelegate.h
zhufeng19940210/Animation
07b0a8790acbcd299152cf681013d4fc3baf2c59
[ "MIT" ]
null
null
null
// // AppDelegate.h // Rec // // Created by Wicky on 2016/12/15. // Copyright © 2016年 Wicky. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
14.722222
60
0.69434
fdda7e4ae80bd38f6e23c886f282f1757445ac50
1,114
h
C
MotifRank/Alphabet.h
yanshen43/MCAT
336c5deea456dae0916fbc8935930402a4acbcad
[ "MIT" ]
null
null
null
MotifRank/Alphabet.h
yanshen43/MCAT
336c5deea456dae0916fbc8935930402a4acbcad
[ "MIT" ]
null
null
null
MotifRank/Alphabet.h
yanshen43/MCAT
336c5deea456dae0916fbc8935930402a4acbcad
[ "MIT" ]
null
null
null
// Alphabet.h: interface for the CAlphabet class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_ALPHABET_H__594C20E7_B5BD_470D_BC71_705BADEE7BAE__INCLUDED_) #define AFX_ALPHABET_H__594C20E7_B5BD_470D_BC71_705BADEE7BAE__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "string.h" #include "stdio.h" #define RELATION_NUM 4 #define ALPHA_NUM 4 #define EXALPHA_NUM 9 #define ALPHA_NUM_SQUARE ALPHA_NUM*ALPHA_NUM class CAlphabet { public: int getIndex(char one); enum ALPHABET{ A=0,//Adenine C, //Cytosine G, //Guanine T, //Thymine R, //A or G W, //A or T S, //C or G Y, //C or T N, //spacer ERROR }; CAlphabet(); virtual ~CAlphabet(); void printalp(CAlphabet::ALPHABET a); bool checkValid(int type,char one); ALPHABET relation[EXALPHA_NUM][RELATION_NUM]; int extendnum[EXALPHA_NUM]; bool compatible[EXALPHA_NUM][ALPHA_NUM]; int compatibleindex[EXALPHA_NUM][ALPHA_NUM]; }; #endif // !defined(AFX_ALPHABET_H__594C20E7_B5BD_470D_BC71_705BADEE7BAE__INCLUDED_)
23.702128
84
0.671454
fdf7054f781c399e4ee3721520bca66f3af67220
1,257
h
C
src/server/binlog.h
jianqingdu/kedis
97ac63d8d96c5cda69c878ef20f04eb8efb4b396
[ "MIT" ]
94
2017-11-30T03:17:58.000Z
2022-03-29T13:43:07.000Z
src/server/binlog.h
flike/kedis
97ac63d8d96c5cda69c878ef20f04eb8efb4b396
[ "MIT" ]
9
2017-12-11T03:12:31.000Z
2020-04-20T13:04:00.000Z
src/server/binlog.h
jianqingdu/kedis
97ac63d8d96c5cda69c878ef20f04eb8efb4b396
[ "MIT" ]
19
2017-12-01T17:22:15.000Z
2022-01-10T01:39:39.000Z
// // binlog.h // kedis // // Created by ziteng on 17/9/12. // Copyright © 2017年 mgj. All rights reserved. // #ifndef __BINLOG_H__ #define __BINLOG_H__ #include "util.h" #include "thread_pool.h" #include "rocksdb/db.h" class Binlog { public: Binlog(); virtual ~Binlog(); int Init(); void InitWithMaster(const string& binlog_id, int cur_db_idx, uint64_t seq); void Drop(); // clear all data int Store(int db_idx, const string& command); int Extract(uint64_t seq, string& command); void Purge(); string GetBinlogId() { return binlog_id_; } int GetCurDbIdx() { return cur_db_idx_; } uint64_t GetMinSeq() { return min_seq_; } uint64_t GetMaxSeq() { return max_seq_; } private: void GenerateBinlogId(); string EncodeKey(uint64_t seq); uint64_t DecodeKey(const rocksdb::Slice& slice); private: rocksdb::DB* db_; mutex mtx_; string binlog_id_; int cur_db_idx_; uint64_t min_seq_; uint64_t max_seq_; bool empty_; }; class PurgeBinlogThread : public Thread { public: PurgeBinlogThread() {} virtual ~PurgeBinlogThread() {} virtual void OnThreadRun(void); }; #endif /* __BINLOG_H__ */
22.854545
79
0.634049
a962456989321215ca9f5472aa9c34fa98189208
5,010
c
C
src/common/dictionary.c
glines/shelltoy
f403ec89731a90f250f05c5a6d498452fe361ad8
[ "MIT" ]
null
null
null
src/common/dictionary.c
glines/shelltoy
f403ec89731a90f250f05c5a6d498452fe361ad8
[ "MIT" ]
null
null
null
src/common/dictionary.c
glines/shelltoy
f403ec89731a90f250f05c5a6d498452fe361ad8
[ "MIT" ]
null
null
null
/* * Copyright (c) 2016-2017 Jonathan Glines * Jonathan Glines <jonathan@glines.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #include <assert.h> #include <stdlib.h> #include <string.h> #include "dictionary.h" typedef struct ttoy_Dictionary_KeyValuePair_ { const char *key; void *value; } ttoy_Dictionary_KeyValuePair; struct ttoy_Dictionary_Internal_ { ttoy_Dictionary_KeyValuePair *pairs; size_t sizePairs, numPairs; }; #define INIT_DICTIONARY_SIZE 8 void ttoy_Dictionary_init( ttoy_Dictionary *self) { /* Allocate memory for internal data structures */ self->internal = (ttoy_Dictionary_Internal *)malloc( sizeof(ttoy_Dictionary_Internal)); self->internal->pairs = (ttoy_Dictionary_KeyValuePair *)malloc( sizeof(ttoy_Dictionary_KeyValuePair) * INIT_DICTIONARY_SIZE); self->internal->sizePairs = INIT_DICTIONARY_SIZE; self->internal->numPairs = 0; } void ttoy_Dictionary_destroy( ttoy_Dictionary *self) { /* Free all key strings (we have allocated that memory ourselves) */ for (size_t i = 0; i < self->internal->numPairs; ++i) { free((char *)self->internal->pairs[i].key); } /* Free allocated memory */ free(self->internal->pairs); free(self->internal); } int comp_keyValuePair( const ttoy_Dictionary_KeyValuePair *a, const ttoy_Dictionary_KeyValuePair *b) { return strcmp(a->key, b->key); } void ttoy_Dictionary_insert( ttoy_Dictionary *self, const char *key, void *value) { ttoy_Dictionary_KeyValuePair *pair; /* Check for an existing pair with the given key */ if (ttoy_Dictionary_getValue(self, key) != NULL) { /* TODO: Maybe we should return an error code here? */ return; } /* Ensure we have enough memory allocated to insert this pair */ if (self->internal->numPairs + 1 > self->internal->sizePairs) { ttoy_Dictionary_KeyValuePair *newPairs; newPairs = (ttoy_Dictionary_KeyValuePair *)malloc( sizeof(ttoy_Dictionary_KeyValuePair) * self->internal->sizePairs * 2); memcpy( newPairs, self->internal->pairs, sizeof(ttoy_Dictionary_KeyValuePair) * self->internal->numPairs); free(self->internal->pairs); self->internal->pairs = newPairs; self->internal->sizePairs *= 2; } /* Insert this key value pair */ pair = &self->internal->pairs[self->internal->numPairs++]; pair->value = value; /* Copy the key string (this string often comes from transient memory, * especially JSON config files) */ pair->key = (const char *)malloc(strlen(key) + 1); strcpy((char *)pair->key, key); /* Sort the key value pairs by key */ qsort( self->internal->pairs, /* ptr */ self->internal->numPairs, /* count */ sizeof(ttoy_Dictionary_KeyValuePair), /* size */ (int (*)(const void *, const void *))comp_keyValuePair /* comp */ ); } void *ttoy_Dictionary_getValue( ttoy_Dictionary *self, const char *key) { int a, b, i; if (self->internal->numPairs == 0) { return NULL; } /* Binary search for the key value pair with the given key */ a = 0; b = self->internal->numPairs; while (b - a > 0) { int result; i = (b - a) / 2 + a; result = strcmp(key, self->internal->pairs[i].key); if (result < 0) { b = i; } else if (result > 0) { i = a + 1; } else { /* result == 0 */ return self->internal->pairs[i].value; } } /* Scan for the key value pair with the given key */ for (i = a; i < b; ++i) { int result; result = strcmp(key, self->internal->pairs[i].key); if (result == 0) { return self->internal->pairs[i].value; } } /* Key value pair with the given key was not found */ return NULL; } size_t ttoy_Dictionary_size( ttoy_Dictionary *self) { return self->internal->numPairs; } void *ttoy_Dictionary_getValueAtIndex( ttoy_Dictionary *self, size_t index) { assert(index < self->internal->numPairs); return self->internal->pairs[index].value; }
30.363636
79
0.683633
a9be5f79ce3a5fe0b068dd5fad46af7b53c1bc82
3,981
h
C
avalon/AdMob.h
newnon/avalon
52ff1f0051520053c88e16f37cb43f023a1acac0
[ "MIT" ]
11
2015-03-12T21:50:41.000Z
2021-05-26T06:56:11.000Z
avalon/AdMob.h
newnon/avalon
52ff1f0051520053c88e16f37cb43f023a1acac0
[ "MIT" ]
4
2018-05-21T09:09:57.000Z
2019-04-25T10:22:25.000Z
avalon/AdMob.h
newnon/avalon
52ff1f0051520053c88e16f37cb43f023a1acac0
[ "MIT" ]
6
2015-03-20T13:04:20.000Z
2018-11-17T19:08:25.000Z
#ifndef __ADMOB_H__ #define __ADMOB_H__ #include <string> #include <vector> #include <map> #include <list> #include <memory> #include "Ads.h" namespace avalon { enum class GADGender { Unknown, Male, Female }; enum class GADAdNetworkExtras { AdMob }; class GADInterstitial: public Interstitial { public: const std::string &getAdUnitID() const { return _adUnitID; } virtual const std::string &getType() const override { static std::string type = "admob"; return type; }; protected: GADInterstitial(const std::string &adUnitID):_adUnitID(adUnitID) {} std::string _adUnitID; }; enum class GADErrorCode { /// Something happened internally; for instance, an invalid response was received from the ad server. INTERNAL_ERROR = 0, /// The ad request is invalid. The localizedFailureReason error description will have more /// details. Typically this is because the ad did not have the ad unit ID or root view /// controller set. INVALID_REQUEST, /// The ad request was successful, but no ad was returned. NO_FILL, /// There was an error loading data from the network. NETWORK_ERROR, /// The ad server experienced a failure processing the request. SERVER_ERROR, /// The current device's OS is below the minimum required version. OS_VERSION_TOO_LOW, /// The request was unable to be loaded before being timed out. TIMEOUT, /// Will not send request because the interstitial object has already been used. INTERSTITIAL_ALREADY_USED, /// The mediation response was invalid. MEDIATION_DATA_ERROR, /// Error finding or creating a mediation ad network adapter. MEDIATION_ADAPTER_ERROR, /// The mediation request was successful, but no ad was returned from any ad networks. MEDIATION_NO_FILL, /// Attempting to pass an invalid ad size to an adapter. MEDIATION_INVALID_ADSIZE, }; enum class GADAdSize { Invalid, Banner, MediumRectangle, FullBanner, Leaderboard, Skyscraper, SmartBannerPortrait, SmartBannerLandscape, }; GADAdSize makeCustomGADAdSize(unsigned short width, unsigned short height); class GADBannerView: public Banner { public: const std::string &getAdUnitID() const { return _adUnitID; } GADAdSize getAdSize() const { return _adSize; } virtual const std::string &getType() const override { static std::string type = "facebook"; return type; }; protected: GADBannerView(const std::string &adUnitID, GADAdSize size):_adUnitID(adUnitID), _adSize(size) {} GADAdSize _adSize; std::string _adUnitID; }; class AdMob { public: static AdMob *getInstance(); const std::string &getSdkVersion() const { return _sdkVersion; } virtual void setAdNetworkExtras(GADAdNetworkExtras network, const std::map<std::string,std::string> &extras) = 0; virtual void setTestDevices(const std::vector<std::string>& devices) = 0; virtual void setGender(GADGender gender) = 0; virtual void setBirthDate(unsigned month, unsigned day, unsigned year) = 0; virtual void setLocation(float latitude, float longitude, float accuracyInMeters) = 0; virtual void setLocation(const std::string &location) = 0; virtual void setTagForChildDirectedTreatment(bool value) = 0; virtual void setKeywords(const std::vector<std::string>& keywords) = 0; virtual GADInterstitial* createIntestitial(const std::string &adUnitID, InterstitialDelegate *delegate) = 0; virtual GADBannerView* createBanner(const std::string &adUnitID, GADAdSize size, BannerDelegate *delegate) = 0; protected: AdMob(const std::string &version):_sdkVersion(version) {} virtual ~AdMob() {} private: std::string _sdkVersion; }; } #endif /* __ADMOB_H__ */
29.272059
118
0.67797
30c1dada044270dd87b5191a89061ddfe5ff2d3f
6,576
h
C
5_Command_with_arguments/LiveObjectsCert.h
mdelain/Arduino_MKR1500
0471c9acd03d69c789fa3a699145b930bbd13f64
[ "BSD-3-Clause" ]
3
2020-07-07T08:47:13.000Z
2020-07-23T13:58:40.000Z
5_Command_with_arguments/LiveObjectsCert.h
mdelain/Arduino_MKR1500
0471c9acd03d69c789fa3a699145b930bbd13f64
[ "BSD-3-Clause" ]
3
2020-07-20T11:22:21.000Z
2022-01-21T08:26:18.000Z
5_Command_with_arguments/LiveObjectsCert.h
mdelain/Arduino_MKR1500
0471c9acd03d69c789fa3a699145b930bbd13f64
[ "BSD-3-Clause" ]
2
2020-07-07T08:47:16.000Z
2020-07-16T12:04:44.000Z
#ifndef _LIVEOBJECTS_CERT_H_INCLUDED #define _LIVEOBJECTS_CERT_H_INCLUDED #include <stddef.h> #include <stdint.h> struct LORootCert { const char* name; const uint8_t* data; const int size; }; static const LORootCert LO_ROOT_CERT = { "DigiCert_Global_Root_CA", (const uint8_t[]){ 0x30, 0x82, 0x03, 0xaf, 0x30, 0x82, 0x02, 0x97, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x08, 0x3b, 0xe0, 0x56, 0x90, 0x42, 0x46, 0xb1, 0xa1, 0x75, 0x6a, 0xc9, 0x59, 0x91, 0xc7, 0x4a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x61, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0c, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x10, 0x77, 0x77, 0x77, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x17, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x36, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x33, 0x31, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x61, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0c, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x10, 0x77, 0x77, 0x77, 0x2e, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x17, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xe2, 0x3b, 0xe1, 0x11, 0x72, 0xde, 0xa8, 0xa4, 0xd3, 0xa3, 0x57, 0xaa, 0x50, 0xa2, 0x8f, 0x0b, 0x77, 0x90, 0xc9, 0xa2, 0xa5, 0xee, 0x12, 0xce, 0x96, 0x5b, 0x01, 0x09, 0x20, 0xcc, 0x01, 0x93, 0xa7, 0x4e, 0x30, 0xb7, 0x53, 0xf7, 0x43, 0xc4, 0x69, 0x00, 0x57, 0x9d, 0xe2, 0x8d, 0x22, 0xdd, 0x87, 0x06, 0x40, 0x00, 0x81, 0x09, 0xce, 0xce, 0x1b, 0x83, 0xbf, 0xdf, 0xcd, 0x3b, 0x71, 0x46, 0xe2, 0xd6, 0x66, 0xc7, 0x05, 0xb3, 0x76, 0x27, 0x16, 0x8f, 0x7b, 0x9e, 0x1e, 0x95, 0x7d, 0xee, 0xb7, 0x48, 0xa3, 0x08, 0xda, 0xd6, 0xaf, 0x7a, 0x0c, 0x39, 0x06, 0x65, 0x7f, 0x4a, 0x5d, 0x1f, 0xbc, 0x17, 0xf8, 0xab, 0xbe, 0xee, 0x28, 0xd7, 0x74, 0x7f, 0x7a, 0x78, 0x99, 0x59, 0x85, 0x68, 0x6e, 0x5c, 0x23, 0x32, 0x4b, 0xbf, 0x4e, 0xc0, 0xe8, 0x5a, 0x6d, 0xe3, 0x70, 0xbf, 0x77, 0x10, 0xbf, 0xfc, 0x01, 0xf6, 0x85, 0xd9, 0xa8, 0x44, 0x10, 0x58, 0x32, 0xa9, 0x75, 0x18, 0xd5, 0xd1, 0xa2, 0xbe, 0x47, 0xe2, 0x27, 0x6a, 0xf4, 0x9a, 0x33, 0xf8, 0x49, 0x08, 0x60, 0x8b, 0xd4, 0x5f, 0xb4, 0x3a, 0x84, 0xbf, 0xa1, 0xaa, 0x4a, 0x4c, 0x7d, 0x3e, 0xcf, 0x4f, 0x5f, 0x6c, 0x76, 0x5e, 0xa0, 0x4b, 0x37, 0x91, 0x9e, 0xdc, 0x22, 0xe6, 0x6d, 0xce, 0x14, 0x1a, 0x8e, 0x6a, 0xcb, 0xfe, 0xcd, 0xb3, 0x14, 0x64, 0x17, 0xc7, 0x5b, 0x29, 0x9e, 0x32, 0xbf, 0xf2, 0xee, 0xfa, 0xd3, 0x0b, 0x42, 0xd4, 0xab, 0xb7, 0x41, 0x32, 0xda, 0x0c, 0xd4, 0xef, 0xf8, 0x81, 0xd5, 0xbb, 0x8d, 0x58, 0x3f, 0xb5, 0x1b, 0xe8, 0x49, 0x28, 0xa2, 0x70, 0xda, 0x31, 0x04, 0xdd, 0xf7, 0xb2, 0x16, 0xf2, 0x4c, 0x0a, 0x4e, 0x07, 0xa8, 0xed, 0x4a, 0x3d, 0x5e, 0xb5, 0x7f, 0xa3, 0x90, 0xc3, 0xaf, 0x27, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x63, 0x30, 0x61, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x03, 0xde, 0x50, 0x35, 0x56, 0xd1, 0x4c, 0xbb, 0x66, 0xf0, 0xa3, 0xe2, 0x1b, 0x1b, 0xc3, 0x97, 0xb2, 0x3d, 0xd1, 0x55, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x03, 0xde, 0x50, 0x35, 0x56, 0xd1, 0x4c, 0xbb, 0x66, 0xf0, 0xa3, 0xe2, 0x1b, 0x1b, 0xc3, 0x97, 0xb2, 0x3d, 0xd1, 0x55, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0xcb, 0x9c, 0x37, 0xaa, 0x48, 0x13, 0x12, 0x0a, 0xfa, 0xdd, 0x44, 0x9c, 0x4f, 0x52, 0xb0, 0xf4, 0xdf, 0xae, 0x04, 0xf5, 0x79, 0x79, 0x08, 0xa3, 0x24, 0x18, 0xfc, 0x4b, 0x2b, 0x84, 0xc0, 0x2d, 0xb9, 0xd5, 0xc7, 0xfe, 0xf4, 0xc1, 0x1f, 0x58, 0xcb, 0xb8, 0x6d, 0x9c, 0x7a, 0x74, 0xe7, 0x98, 0x29, 0xab, 0x11, 0xb5, 0xe3, 0x70, 0xa0, 0xa1, 0xcd, 0x4c, 0x88, 0x99, 0x93, 0x8c, 0x91, 0x70, 0xe2, 0xab, 0x0f, 0x1c, 0xbe, 0x93, 0xa9, 0xff, 0x63, 0xd5, 0xe4, 0x07, 0x60, 0xd3, 0xa3, 0xbf, 0x9d, 0x5b, 0x09, 0xf1, 0xd5, 0x8e, 0xe3, 0x53, 0xf4, 0x8e, 0x63, 0xfa, 0x3f, 0xa7, 0xdb, 0xb4, 0x66, 0xdf, 0x62, 0x66, 0xd6, 0xd1, 0x6e, 0x41, 0x8d, 0xf2, 0x2d, 0xb5, 0xea, 0x77, 0x4a, 0x9f, 0x9d, 0x58, 0xe2, 0x2b, 0x59, 0xc0, 0x40, 0x23, 0xed, 0x2d, 0x28, 0x82, 0x45, 0x3e, 0x79, 0x54, 0x92, 0x26, 0x98, 0xe0, 0x80, 0x48, 0xa8, 0x37, 0xef, 0xf0, 0xd6, 0x79, 0x60, 0x16, 0xde, 0xac, 0xe8, 0x0e, 0xcd, 0x6e, 0xac, 0x44, 0x17, 0x38, 0x2f, 0x49, 0xda, 0xe1, 0x45, 0x3e, 0x2a, 0xb9, 0x36, 0x53, 0xcf, 0x3a, 0x50, 0x06, 0xf7, 0x2e, 0xe8, 0xc4, 0x57, 0x49, 0x6c, 0x61, 0x21, 0x18, 0xd5, 0x04, 0xad, 0x78, 0x3c, 0x2c, 0x3a, 0x80, 0x6b, 0xa7, 0xeb, 0xaf, 0x15, 0x14, 0xe9, 0xd8, 0x89, 0xc1, 0xb9, 0x38, 0x6c, 0xe2, 0x91, 0x6c, 0x8a, 0xff, 0x64, 0xb9, 0x77, 0x25, 0x57, 0x30, 0xc0, 0x1b, 0x24, 0xa3, 0xe1, 0xdc, 0xe9, 0xdf, 0x47, 0x7c, 0xb5, 0xb4, 0x24, 0x08, 0x05, 0x30, 0xec, 0x2d, 0xbd, 0x0b, 0xbf, 0x45, 0xbf, 0x50, 0xb9, 0xa9, 0xf3, 0xeb, 0x98, 0x01, 0x12, 0xad, 0xc8, 0x88, 0xc6, 0x98, 0x34, 0x5f, 0x8d, 0x0a, 0x3c, 0xc6, 0xe9, 0xd5, 0x95, 0x95, 0x6d, 0xde }, 947 }; #endif
65.76
78
0.610858
344ba85d5780aadeb78b2c31ddfa7e5f81923fac
2,316
h
C
PrivateFrameworks/ClassKit/CLSClass.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/ClassKit/CLSClass.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/ClassKit/CLSClass.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import <ClassKit/CLSObject.h> #import "CLSContactsSearchable.h" #import "CLSRelationable.h" @class NSArray, NSPersonNameComponents, NSString; @interface CLSClass : CLSObject <CLSRelationable, CLSContactsSearchable> { BOOL _isEditable; NSString *_className; long long _source; NSString *_iconID; NSString *_locationID; long long _originatingSource; NSString *_customClassName; NSString *_tempObjectID; NSString *_searchText; } + (BOOL)supportsSecureCoding; + (id)relations; @property(copy, nonatomic) NSString *searchText; // @synthesize searchText=_searchText; @property(copy, nonatomic) NSString *tempObjectID; // @synthesize tempObjectID=_tempObjectID; @property BOOL isEditable; // @synthesize isEditable=_isEditable; @property(copy, nonatomic) NSString *customClassName; // @synthesize customClassName=_customClassName; @property(nonatomic) long long originatingSource; // @synthesize originatingSource=_originatingSource; @property(copy, nonatomic) NSString *locationID; // @synthesize locationID=_locationID; @property(copy, nonatomic) NSString *iconID; // @synthesize iconID=_iconID; @property(nonatomic) long long source; // @synthesize source=_source; @property(copy, nonatomic) NSString *className; // @synthesize className=_className; - (void).cxx_destruct; - (void)removePerson:(id)arg1 withRole:(unsigned long long)arg2; - (void)addPerson:(id)arg1 withRole:(unsigned long long)arg2; - (id)dictionaryRepresentation; @property(readonly, copy) NSString *description; - (void)setDisplayName:(id)arg1; @property(readonly, nonatomic) NSString *groupIdentifier; @property(readonly, nonatomic) NSString *displayName; @property(readonly, nonatomic) NSArray *classMembers; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (BOOL)validateObject:(id *)arg1; - (id)initWithLocation:(id)arg1 customName:(id)arg2; - (id)_init; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, nonatomic) NSString *emailAddress; @property(readonly) unsigned long long hash; @property(readonly, nonatomic) NSPersonNameComponents *nameComponents; @property(readonly) Class superclass; @end
37.354839
102
0.770294
4378e26c6cd12f56cacbb67702f8b85c2343ecdd
8,286
h
C
Simulator/Libraries/external/baselib/Include/C/Baselib_FileIO.h
mushikago/CallSwiftFromUnity
1ecfd2109df99fa2d54595810240289c397b9c66
[ "MIT" ]
2
2021-09-19T18:24:48.000Z
2022-01-18T14:45:40.000Z
Simulator/Libraries/external/baselib/Include/C/Baselib_FileIO.h
mushikago/CallSwiftFromUnity
1ecfd2109df99fa2d54595810240289c397b9c66
[ "MIT" ]
null
null
null
Simulator/Libraries/external/baselib/Include/C/Baselib_FileIO.h
mushikago/CallSwiftFromUnity
1ecfd2109df99fa2d54595810240289c397b9c66
[ "MIT" ]
2
2022-03-24T19:58:31.000Z
2022-03-24T22:55:43.000Z
#pragma once // Baselib FileIO // // This is a file reading abstraction api heavily influenced by next-gen async API's like io_uring, windows register I/O, etc. // This api allows for platform independent async file reading. #include "Baselib_ErrorState.h" #include "Baselib_Memory.h" #include "Internal/Baselib_EnumSizeCheck.h" #ifdef __cplusplus BASELIB_C_INTERFACE { #endif // Event queue handle. typedef struct Baselib_FileIO_EventQueue {void* handle;} Baselib_FileIO_EventQueue; // File handle. typedef struct Baselib_FileIO_File {void* handle;} Baselib_FileIO_File; // Event queue handle invalid constant. static const Baselib_FileIO_EventQueue Baselib_FileIO_EventQueue_Invalid = { NULL }; // File handle invalid constant. static const Baselib_FileIO_File Baselib_FileIO_File_Invalid = { NULL }; // File IO read request. typedef struct Baselib_FileIO_ReadRequest { // Offset in a file to read from. uint64_t offset; // Buffer to read to, must be available for duration of operation. void* buffer; // Size of requested read, please note this it's 32 bit value. uint32_t size; } Baselib_FileIO_ReadRequest; // File IO priorities. // First we process all requests with high priority, then with normal priority. // There's no round-robin, and high priority can starve normal priority. typedef enum Baselib_FileIO_Priority { Baselib_FileIO_Priority_Normal = 0, Baselib_FileIO_Priority_High = 1 } Baselib_FileIO_Priority; BASELIB_ENUM_ENSURE_ABI_COMPATIBILITY(Baselib_FileIO_Priority); typedef enum Baselib_FileIO_EventQueue_ResultType { // Upon receiving this event, please call the provided callback with provided data argument. Baselib_FileIO_EventQueue_Callback = 1, // Result of open file operation. Baselib_FileIO_EventQueue_OpenFile = 2, // Result of read file operation. Baselib_FileIO_EventQueue_ReadFile = 3, // Result of close file operation. Baselib_FileIO_EventQueue_CloseFile = 4 } Baselib_FileIO_EventQueue_ResultType; BASELIB_ENUM_ENSURE_ABI_COMPATIBILITY(Baselib_FileIO_EventQueue_ResultType); typedef void (*EventQueueCallback)(uint64_t userdata); typedef struct Baselib_FileIO_EventQueue_Result_Callback { // Please invoke this callback with userdata from the event. EventQueueCallback callback; } Baselib_FileIO_EventQueue_Result_Callback; typedef struct Baselib_FileIO_EventQueue_Result_OpenFile { // Size of the file as seen on during open. uint64_t fileSize; } Baselib_FileIO_EventQueue_Result_OpenFile; typedef struct Baselib_FileIO_EventQueue_Result_ReadFile { // Bytes transfered during read, please note it's 32 bit value. uint32_t bytesTransfered; } Baselib_FileIO_EventQueue_Result_ReadFile; // Event queue result. typedef struct Baselib_FileIO_EventQueue_Result { // Event type. Baselib_FileIO_EventQueue_ResultType type; // Userdata as provided to the request. uint64_t userdata; // Error state of the operation. Baselib_ErrorState errorState; union { Baselib_FileIO_EventQueue_Result_Callback callback; Baselib_FileIO_EventQueue_Result_OpenFile openFile; Baselib_FileIO_EventQueue_Result_ReadFile readFile; }; } Baselib_FileIO_EventQueue_Result; // Creates event queue. // // \returns Event queue. BASELIB_API Baselib_FileIO_EventQueue Baselib_FileIO_EventQueue_Create(void); // Frees event queue. // // \param eq event queue to free. BASELIB_API void Baselib_FileIO_EventQueue_Free( Baselib_FileIO_EventQueue eq ); // Dequeue events from event queue. // // \param eq Event queue to dequeue from. // \param results Results array to dequeue elements into. // If null will return 0. // \param count Amount of elements in results array. // If equals 0 will return 0. // \param timeoutInMilliseconds If no elements are present in the queue, // waits for any elements to be appear for specified amount of time. // If 0 is passed, wait is omitted. // If elements are present, dequeues up-to-count elements, and wait is omitted. // // File operations errors are reported via Baselib_FileIO_EventQueue_Result::errorState // Possible error codes: // - InvalidPathname: Requested pathname is invalid (not found, a directory, etc). // - RequestedAccessIsNotAllowed: Access to requested pathname is not allowed. // - IOError: IO error occured. // // \returns Amount of results filled. BASELIB_API uint64_t Baselib_FileIO_EventQueue_Dequeue( Baselib_FileIO_EventQueue eq, Baselib_FileIO_EventQueue_Result results[], uint64_t count, uint32_t timeoutInMilliseconds // 0 will return immediately ); // Asynchronously opens a file. // // \param eq Event queue to associate file with. // File can only be associated with one event queue, // but one event queue can be associated with multiple files. // If invalid event queue is passed, will return invalid file handle. // \param pathname Platform defined pathname of a file. // Can be freed after this function returns. // If null is passed will return invalid file handle. // \param userdata Userdata to be set in the completion event. // \param priority Priority for file opening operation. // // Please note errors are reported via Baselib_FileIO_EventQueue_Result::errorState // Possible error codes: // - InvalidPathname: Requested pathname is invalid (not found, a directory, etc). // - RequestedAccessIsNotAllowed: Access to requested pathname is not allowed. // - IOError: IO error occured. // // \returns Async file handle, which can be used immediately for scheduling other operations. // In case if file opening fails, all scheduled operations will fail as well. // In case if invalid arguments are passed, might return invalid file handle (see args descriptions). BASELIB_API Baselib_FileIO_File Baselib_FileIO_File_Open( Baselib_FileIO_EventQueue eq, const char* pathname, uint64_t userdata, Baselib_FileIO_Priority priority ); // Asynchronously reads data from a file. // // Note scheduling reads on closed file is undefined. // // \param file File to read from. // If invalid file handle is passed, will no-op. // If file handle was already closed, behavior is undefined. // \param requests Requests to schedule. // If more than 1 provided, // will provide completion event per individual request in the array. // If null is passed, will no-op. // \param count Amount of requests in requests array. // If 0 is passed, will no-op. // \param userdata Userdata to be set in the completion event(s). // \param priority Priority for file reading operation(s). // // Please note errors are reported via Baselib_FileIO_EventQueue_Result::errorState // If file is invalid handle, error can not be reported because event queue is not known. // Possible error codes: // - IOError: IO error occured. BASELIB_API void Baselib_FileIO_File_Read( Baselib_FileIO_File file, Baselib_FileIO_ReadRequest requests[], uint64_t count, uint64_t userdata, Baselib_FileIO_Priority priority ); // Asynchronously closes a file. // // Will wait for all pending operations to complete, // after that will close a file and put a completion event. // // \param file File to close. // If invalid file handle is passed, will no-op. // // Please note errors are reported via Baselib_FileIO_EventQueue_Result::errorState // If file is invalid handle, error can not be reported because event queue is not known. // Possible error codes: // - IOError: IO error occured. BASELIB_API void Baselib_FileIO_File_Close( Baselib_FileIO_File file ); #ifdef __cplusplus } // BASELIB_C_INTERFACE #endif
38.901408
126
0.706855
ec98132364e6e29b29152434befc87dffac99149
2,204
h
C
src/primer3-2.3.7/src/print_boulder.h
germs-lab/MetaFunPrimer
63959a98cada125b86ec91ab9d69d1da81d232f5
[ "MIT" ]
11
2018-09-21T16:49:19.000Z
2022-03-03T19:29:16.000Z
src/primer3-2.3.7/src/print_boulder.h
germs-lab/MetaFunPrimer
63959a98cada125b86ec91ab9d69d1da81d232f5
[ "MIT" ]
26
2018-03-01T04:58:17.000Z
2018-08-30T20:49:30.000Z
src/primer3-2.3.7/src/print_boulder.h
germs-lab/MetaFunPrimer
63959a98cada125b86ec91ab9d69d1da81d232f5
[ "MIT" ]
2
2020-05-14T02:18:18.000Z
2021-04-16T04:55:08.000Z
/* Copyright (c) 1996,1997,1998,1999,2000,2001,2004,2006,2007,2008 Whitehead Institute for Biomedical Research, Steve Rozen (http://purl.com/STEVEROZEN/), Andreas Untergasser and Helen Skaletsky All rights reserved. This file is part of primer3 and the primer3 suite. Primer3 and the primer3 suite are free software; you can redistribute them and/or modify them 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 software 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 file (file gpl-2.0.txt in the source distribution); if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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 OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef BOULDER_OUTPUT_H #define BOULDER_OUTPUT_H 1 #include "libprimer3.h" void print_boulder(int, const p3_global_settings *, const seq_args *, const p3retval *, int exaplain_flag); void print_boulder_error(const char *err); void print_boulder_warning(const char *err); #endif
42.384615
76
0.745463
312244139c7ff20ba4f68089928fc846eb6cca28
1,830
c
C
uboot/board/nvidia/harmony/harmony.c
PollyWeng/NUC972
80f78bc9fbff40955e4603dd10f74aff92f7e9b5
[ "Apache-2.0" ]
2
2017-10-30T12:25:44.000Z
2019-08-25T09:01:38.000Z
uboot/board/nvidia/harmony/harmony.c
PollyWeng/NUC972
80f78bc9fbff40955e4603dd10f74aff92f7e9b5
[ "Apache-2.0" ]
null
null
null
uboot/board/nvidia/harmony/harmony.c
PollyWeng/NUC972
80f78bc9fbff40955e4603dd10f74aff92f7e9b5
[ "Apache-2.0" ]
4
2017-12-19T10:52:20.000Z
2019-08-25T09:01:40.000Z
/* * (C) Copyright 2010,2011 * NVIDIA Corporation <www.nvidia.com> * * See file CREDITS for list of people who contributed to this * project. * * 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 <common.h> #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/funcmux.h> #include <asm/arch/pinmux.h> #include <asm/arch/tegra.h> #include <asm/gpio.h> #ifdef CONFIG_TEGRA_MMC /* * Routine: pin_mux_mmc * Description: setup the pin muxes/tristate values for the SDMMC(s) */ void pin_mux_mmc(void) { funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_GME_8_BIT); funcmux_select(PERIPH_ID_SDMMC2, FUNCMUX_SDMMC2_DTA_DTD_8BIT); /* For power GPIO PI6 */ pinmux_tristate_disable(PINGRP_ATA); /* For CD GPIO PH2 */ pinmux_tristate_disable(PINGRP_ATD); /* For power GPIO PT3 */ pinmux_tristate_disable(PINGRP_DTB); /* For CD GPIO PI5 */ pinmux_tristate_disable(PINGRP_ATC); } #endif void pin_mux_usb(void) { funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI); pinmux_set_func(PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4); pinmux_tristate_disable(PINGRP_CDEV2); /* USB2 PHY reset GPIO */ pinmux_tristate_disable(PINGRP_UAC); }
29.516129
68
0.754645
0350ce089e939addae8e24cf03140923549c83b8
848
h
C
OneNET/data_stream.h
ghsecuritylab/IoT_Board_OneNET_Demo
d39556f1f6976ca002510c0aa9ac0552c979191a
[ "CC-BY-4.0" ]
13
2019-04-27T04:24:53.000Z
2021-05-23T08:58:32.000Z
OneNET/data_stream.h
dilake2017/IoT_Board_OneNET_Demo
d39556f1f6976ca002510c0aa9ac0552c979191a
[ "CC-BY-4.0" ]
null
null
null
OneNET/data_stream.h
dilake2017/IoT_Board_OneNET_Demo
d39556f1f6976ca002510c0aa9ac0552c979191a
[ "CC-BY-4.0" ]
12
2019-04-29T12:35:52.000Z
2020-11-15T02:55:32.000Z
#ifndef __DATA_STREAM_H__ #define __DATA_STREAM_H__ #include "stdio.h" #include "stdbool.h" typedef enum { TYPE_BOOL = 0, TYPE_CHAR, TYPE_UCHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT, TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_GPS, TYPE_STRING, } ONENET_DATA_TYPE; typedef struct { char *name; void *dataPoint; ONENET_DATA_TYPE dataType; bool flag; } ONENET_DATA_STREAM; typedef enum { FORMAT_TYPE1 = 1, FORMAT_TYPE2, FORMAT_TYPE3, FORMAT_TYPE4, FORMAT_TYPE5 } ONENET_FORMAT_TYPE; short DSTREAM_GetDataStream_Body(unsigned char type, ONENET_DATA_STREAM *streamArray, unsigned short streamArrayCnt, unsigned char *buffer, short maxLen, short offset); short DSTREAM_GetDataStream_Body_Measure(unsigned char type, ONENET_DATA_STREAM *streamArray, unsigned short streamArrayCnt, bool flag); #endif
15.703704
168
0.787736
83e39ec8d7739816188ba909a4cb9da302d48f73
9,715
c
C
git/split-index.c
MegaZeroX/LaTeX-Basics
a1dbc15510ab03e7d0669956b010506620be7b7e
[ "MIT" ]
null
null
null
git/split-index.c
MegaZeroX/LaTeX-Basics
a1dbc15510ab03e7d0669956b010506620be7b7e
[ "MIT" ]
null
null
null
git/split-index.c
MegaZeroX/LaTeX-Basics
a1dbc15510ab03e7d0669956b010506620be7b7e
[ "MIT" ]
1
2020-03-19T18:32:04.000Z
2020-03-19T18:32:04.000Z
#include "cache.h" #include "split-index.h" #include "ewah/ewok.h" struct split_index *init_split_index(struct index_state *istate) { if (!istate->split_index) { istate->split_index = xcalloc(1, sizeof(*istate->split_index)); istate->split_index->refcount = 1; } return istate->split_index; } int read_link_extension(struct index_state *istate, const void *data_, unsigned long sz) { const unsigned char *data = data_; struct split_index *si; int ret; if (sz < 20) return error("corrupt link extension (too short)"); si = init_split_index(istate); hashcpy(si->base_sha1, data); data += 20; sz -= 20; if (!sz) return 0; si->delete_bitmap = ewah_new(); ret = ewah_read_mmap(si->delete_bitmap, data, sz); if (ret < 0) return error("corrupt delete bitmap in link extension"); data += ret; sz -= ret; si->replace_bitmap = ewah_new(); ret = ewah_read_mmap(si->replace_bitmap, data, sz); if (ret < 0) return error("corrupt replace bitmap in link extension"); if (ret != sz) return error("garbage at the end of link extension"); return 0; } int write_link_extension(struct strbuf *sb, struct index_state *istate) { struct split_index *si = istate->split_index; strbuf_add(sb, si->base_sha1, 20); if (!si->delete_bitmap && !si->replace_bitmap) return 0; ewah_serialize_strbuf(si->delete_bitmap, sb); ewah_serialize_strbuf(si->replace_bitmap, sb); return 0; } static void mark_base_index_entries(struct index_state *base) { int i; /* * To keep track of the shared entries between * istate->base->cache[] and istate->cache[], base entry * position is stored in each base entry. All positions start * from 1 instead of 0, which is reserved to say "this is a new * entry". */ for (i = 0; i < base->cache_nr; i++) base->cache[i]->index = i + 1; } void move_cache_to_base_index(struct index_state *istate) { struct split_index *si = istate->split_index; int i; /* * do not delete old si->base, its index entries may be shared * with istate->cache[]. Accept a bit of leaking here because * this code is only used by short-lived update-index. */ si->base = xcalloc(1, sizeof(*si->base)); si->base->version = istate->version; /* zero timestamp disables racy test in ce_write_index() */ si->base->timestamp = istate->timestamp; ALLOC_GROW(si->base->cache, istate->cache_nr, si->base->cache_alloc); si->base->cache_nr = istate->cache_nr; COPY_ARRAY(si->base->cache, istate->cache, istate->cache_nr); mark_base_index_entries(si->base); for (i = 0; i < si->base->cache_nr; i++) si->base->cache[i]->ce_flags &= ~CE_UPDATE_IN_BASE; } static void mark_entry_for_delete(size_t pos, void *data) { struct index_state *istate = data; if (pos >= istate->cache_nr) die("position for delete %d exceeds base index size %d", (int)pos, istate->cache_nr); istate->cache[pos]->ce_flags |= CE_REMOVE; istate->split_index->nr_deletions = 1; } static void replace_entry(size_t pos, void *data) { struct index_state *istate = data; struct split_index *si = istate->split_index; struct cache_entry *dst, *src; if (pos >= istate->cache_nr) die("position for replacement %d exceeds base index size %d", (int)pos, istate->cache_nr); if (si->nr_replacements >= si->saved_cache_nr) die("too many replacements (%d vs %d)", si->nr_replacements, si->saved_cache_nr); dst = istate->cache[pos]; if (dst->ce_flags & CE_REMOVE) die("entry %d is marked as both replaced and deleted", (int)pos); src = si->saved_cache[si->nr_replacements]; if (ce_namelen(src)) die("corrupt link extension, entry %d should have " "zero length name", (int)pos); src->index = pos + 1; src->ce_flags |= CE_UPDATE_IN_BASE; src->ce_namelen = dst->ce_namelen; copy_cache_entry(dst, src); free(src); si->nr_replacements++; } void merge_base_index(struct index_state *istate) { struct split_index *si = istate->split_index; unsigned int i; mark_base_index_entries(si->base); si->saved_cache = istate->cache; si->saved_cache_nr = istate->cache_nr; istate->cache_nr = si->base->cache_nr; istate->cache = NULL; istate->cache_alloc = 0; ALLOC_GROW(istate->cache, istate->cache_nr, istate->cache_alloc); COPY_ARRAY(istate->cache, si->base->cache, istate->cache_nr); si->nr_deletions = 0; si->nr_replacements = 0; ewah_each_bit(si->replace_bitmap, replace_entry, istate); ewah_each_bit(si->delete_bitmap, mark_entry_for_delete, istate); if (si->nr_deletions) remove_marked_cache_entries(istate); for (i = si->nr_replacements; i < si->saved_cache_nr; i++) { if (!ce_namelen(si->saved_cache[i])) die("corrupt link extension, entry %d should " "have non-zero length name", i); add_index_entry(istate, si->saved_cache[i], ADD_CACHE_OK_TO_ADD | ADD_CACHE_KEEP_CACHE_TREE | /* * we may have to replay what * merge-recursive.c:update_stages() * does, which has this flag on */ ADD_CACHE_SKIP_DFCHECK); si->saved_cache[i] = NULL; } ewah_free(si->delete_bitmap); ewah_free(si->replace_bitmap); FREE_AND_NULL(si->saved_cache); si->delete_bitmap = NULL; si->replace_bitmap = NULL; si->saved_cache_nr = 0; } void prepare_to_write_split_index(struct index_state *istate) { struct split_index *si = init_split_index(istate); struct cache_entry **entries = NULL, *ce; int i, nr_entries = 0, nr_alloc = 0; si->delete_bitmap = ewah_new(); si->replace_bitmap = ewah_new(); if (si->base) { /* Go through istate->cache[] and mark CE_MATCHED to * entry with positive index. We'll go through * base->cache[] later to delete all entries in base * that are not marked with either CE_MATCHED or * CE_UPDATE_IN_BASE. If istate->cache[i] is a * duplicate, deduplicate it. */ for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *base; /* namelen is checked separately */ const unsigned int ondisk_flags = CE_STAGEMASK | CE_VALID | CE_EXTENDED_FLAGS; unsigned int ce_flags, base_flags, ret; ce = istate->cache[i]; if (!ce->index) continue; if (ce->index > si->base->cache_nr) { ce->index = 0; continue; } ce->ce_flags |= CE_MATCHED; /* or "shared" */ base = si->base->cache[ce->index - 1]; if (ce == base) continue; if (ce->ce_namelen != base->ce_namelen || strcmp(ce->name, base->name)) { ce->index = 0; continue; } ce_flags = ce->ce_flags; base_flags = base->ce_flags; /* only on-disk flags matter */ ce->ce_flags &= ondisk_flags; base->ce_flags &= ondisk_flags; ret = memcmp(&ce->ce_stat_data, &base->ce_stat_data, offsetof(struct cache_entry, name) - offsetof(struct cache_entry, ce_stat_data)); ce->ce_flags = ce_flags; base->ce_flags = base_flags; if (ret) ce->ce_flags |= CE_UPDATE_IN_BASE; free(base); si->base->cache[ce->index - 1] = ce; } for (i = 0; i < si->base->cache_nr; i++) { ce = si->base->cache[i]; if ((ce->ce_flags & CE_REMOVE) || !(ce->ce_flags & CE_MATCHED)) ewah_set(si->delete_bitmap, i); else if (ce->ce_flags & CE_UPDATE_IN_BASE) { ewah_set(si->replace_bitmap, i); ce->ce_flags |= CE_STRIP_NAME; ALLOC_GROW(entries, nr_entries+1, nr_alloc); entries[nr_entries++] = ce; } } } for (i = 0; i < istate->cache_nr; i++) { ce = istate->cache[i]; if ((!si->base || !ce->index) && !(ce->ce_flags & CE_REMOVE)) { assert(!(ce->ce_flags & CE_STRIP_NAME)); ALLOC_GROW(entries, nr_entries+1, nr_alloc); entries[nr_entries++] = ce; } ce->ce_flags &= ~CE_MATCHED; } /* * take cache[] out temporarily, put entries[] in its place * for writing */ si->saved_cache = istate->cache; si->saved_cache_nr = istate->cache_nr; istate->cache = entries; istate->cache_nr = nr_entries; } void finish_writing_split_index(struct index_state *istate) { struct split_index *si = init_split_index(istate); ewah_free(si->delete_bitmap); ewah_free(si->replace_bitmap); si->delete_bitmap = NULL; si->replace_bitmap = NULL; free(istate->cache); istate->cache = si->saved_cache; istate->cache_nr = si->saved_cache_nr; } void discard_split_index(struct index_state *istate) { struct split_index *si = istate->split_index; if (!si) return; istate->split_index = NULL; si->refcount--; if (si->refcount) return; if (si->base) { discard_index(si->base); free(si->base); } free(si); } void save_or_free_index_entry(struct index_state *istate, struct cache_entry *ce) { if (ce->index && istate->split_index && istate->split_index->base && ce->index <= istate->split_index->base->cache_nr && ce == istate->split_index->base->cache[ce->index - 1]) ce->ce_flags |= CE_REMOVE; else free(ce); } void replace_index_entry_in_base(struct index_state *istate, struct cache_entry *old, struct cache_entry *new) { if (old->index && istate->split_index && istate->split_index->base && old->index <= istate->split_index->base->cache_nr) { new->index = old->index; if (old != istate->split_index->base->cache[new->index - 1]) free(istate->split_index->base->cache[new->index - 1]); istate->split_index->base->cache[new->index - 1] = new; } } void add_split_index(struct index_state *istate) { if (!istate->split_index) { init_split_index(istate); istate->cache_changed |= SPLIT_INDEX_ORDERED; } } void remove_split_index(struct index_state *istate) { if (istate->split_index) { /* * can't discard_split_index(&the_index); because that * will destroy split_index->base->cache[], which may * be shared with the_index.cache[]. So yeah we're * leaking a bit here. */ istate->split_index = NULL; istate->cache_changed |= SOMETHING_CHANGED; } }
28.489736
81
0.679362
83fa808b187137827406a3bc41c77ff0c23863db
2,292
h
C
linux-5.2/net/batman-adv/sysfs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
1
2022-01-30T20:01:25.000Z
2022-01-30T20:01:25.000Z
linux-5.2/net/batman-adv/sysfs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
null
null
null
linux-5.2/net/batman-adv/sysfs.h
TakuKitamura/expirefile-syscall
2b91994a7fe984e146d090fc7d80fa1a698025aa
[ "MIT" ]
1
2019-10-11T07:35:58.000Z
2019-10-11T07:35:58.000Z
/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (C) 2010-2019 B.A.T.M.A.N. contributors: * * Marek Lindner */ #ifndef _NET_BATMAN_ADV_SYSFS_H_ #define _NET_BATMAN_ADV_SYSFS_H_ #include "main.h" #include <linux/sysfs.h> #include <linux/types.h> struct kobject; struct net_device; #define BATADV_SYSFS_IF_MESH_SUBDIR "mesh" #define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv" /** * BATADV_SYSFS_VLAN_SUBDIR_PREFIX - prefix of the subfolder that will be * created in the sysfs hierarchy for each VLAN interface. The subfolder will * be named "BATADV_SYSFS_VLAN_SUBDIR_PREFIX%vid". */ #define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan" /** * struct batadv_attribute - sysfs export helper for batman-adv attributes */ struct batadv_attribute { /** @attr: sysfs attribute file */ struct attribute attr; /** * @show: function to export the current attribute's content to sysfs */ ssize_t (*show)(struct kobject *kobj, struct attribute *attr, char *buf); /** * @store: function to load new value from character buffer and save it * in batman-adv attribute */ ssize_t (*store)(struct kobject *kobj, struct attribute *attr, char *buf, size_t count); }; #ifdef CONFIG_BATMAN_ADV_SYSFS int batadv_sysfs_add_meshif(struct net_device *dev); void batadv_sysfs_del_meshif(struct net_device *dev); int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); void batadv_sysfs_del_hardif(struct kobject **hardif_obj); int batadv_sysfs_add_vlan(struct net_device *dev, struct batadv_softif_vlan *vlan); void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv, struct batadv_softif_vlan *vlan); #else static inline int batadv_sysfs_add_meshif(struct net_device *dev) { return 0; } static inline void batadv_sysfs_del_meshif(struct net_device *dev) { } static inline int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) { return 0; } static inline void batadv_sysfs_del_hardif(struct kobject **hardif_obj) { } static inline int batadv_sysfs_add_vlan(struct net_device *dev, struct batadv_softif_vlan *vlan) { return 0; } static inline void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv, struct batadv_softif_vlan *vlan) { } #endif #endif /* _NET_BATMAN_ADV_SYSFS_H_ */
24.126316
78
0.760471
6c8011640fe4d2e35e79c7f103414b1ea58cb602
1,563
h
C
src/Streams/PublicStream.h
DoStini/FEUP-AEDA-proj
ccd23c1aba4f041ea09cc5f5d75d555d8c1a591a
[ "MIT" ]
null
null
null
src/Streams/PublicStream.h
DoStini/FEUP-AEDA-proj
ccd23c1aba4f041ea09cc5f5d75d555d8c1a591a
[ "MIT" ]
4
2021-01-22T09:26:24.000Z
2021-02-18T09:57:11.000Z
src/Streams/PublicStream.h
DoStini/FEUP-AEDA-proj
ccd23c1aba4f041ea09cc5f5d75d555d8c1a591a
[ "MIT" ]
null
null
null
// // Created by adbp on 18/10/2020. // #ifndef FEUP_AEDA_PROJ_PUBLICSTREAM_H #define FEUP_AEDA_PROJ_PUBLICSTREAM_H #include "LiveStream.h" #include <fstream> /** * * PublicStream inherited from LiveStream to handle changes in publicStream elements */ class PublicStream : public LiveStream { public: PublicStream(); /** * Constructor to Public Stream * * @param title - Title of the streamer * @param language - Stream language * @param minAge - Minimal age of the streamer , 12 by default */ PublicStream(std::string title, language streamLanguage, genre streamGenre,std::string streamerNick, unsigned minAge); ///@return - streamer type = public type streamType getStreamType() const override; /// @return - Used to store the stream in the file streamFileType getStreamFileType() const override; /** * Add viewers to the streamer * * @param viewerNick - Nick name of the viewer */ void addViewer(const std::string& viewerNick) override; /** * Reading streamer info to file * @param ff Current file streamer */ void readFromFile(std::ifstream &ff) override; /** * Writing streamer info to file * @param ff Current file streamer */ void writeToFile(std::ofstream &ff) override; /// @return - relevant info about streamer std::string getShortDescription() const override; /// @return - detailed info about streamer std::string getLongDescription() const override; }; #endif //FEUP_AEDA_PROJ_PUBLICSTREAM_H
26.491525
122
0.683941
96c0e9a755a9acd44731a8d08345c9e6e60458c8
272
c
C
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/arm/crypto-vldrq_p128.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
7
2020-05-02T17:34:05.000Z
2021-10-17T10:15:18.000Z
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/arm/crypto-vldrq_p128.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
null
null
null
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/arm/crypto-vldrq_p128.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
2
2020-07-27T00:22:36.000Z
2021-04-01T09:41:02.000Z
/* { dg-do compile } */ /* { dg-require-effective-target arm_crypto_ok } */ /* { dg-add-options arm_crypto } */ #include "arm_neon.h" poly128_t foo (poly128_t* ptr) { return vldrq_p128 (ptr); } /* { dg-final { scan-assembler "vld1.64\t{d\[0-9\]+-d\[0-9\]+}.*" } } */
19.428571
72
0.595588
889c7b62d4f9bf590d3a160a0b491164f3f46ec9
3,050
c
C
src/examples/poc-shell/main.c
Adecy/AVRTOS
b0f2da9f31fba7bcccf5f06f827af87494a0bcb3
[ "Apache-2.0" ]
2
2021-05-02T22:15:34.000Z
2021-07-04T14:04:12.000Z
src/examples/poc-shell/main.c
Adecy/atmega328p-multithreading
b0f2da9f31fba7bcccf5f06f827af87494a0bcb3
[ "Apache-2.0" ]
null
null
null
src/examples/poc-shell/main.c
Adecy/atmega328p-multithreading
b0f2da9f31fba7bcccf5f06f827af87494a0bcb3
[ "Apache-2.0" ]
null
null
null
#include <avr/io.h> #include <avr/interrupt.h> #include <avrtos/misc/uart.h> #include <avrtos/kernel.h> #include <avrtos/debug.h> /*___________________________________________________________________________*/ #define K_MODULE K_MODULE_APPLICATION /*___________________________________________________________________________*/ void consumer(void *context); K_THREAD_DEFINE(w1, consumer, 0x100, K_PREEMPTIVE, NULL, 'A'); struct in { struct qitem tie; uint8_t buffer[20]; uint8_t len; }; K_MEM_SLAB_DEFINE(myslab, sizeof(struct in), 2u); K_FIFO_DEFINE(myfifo); void push(struct in **mem) { k_fifo_put(&myfifo, *(void **)mem); *mem = NULL; } int8_t alloc(struct in **mem) { return k_mem_slab_alloc(&myslab, (void **)mem, K_NO_WAIT); } void free(struct in *mem) { k_mem_slab_free(&myslab, mem); } /*___________________________________________________________________________*/ static inline void input(const char rx) { static struct in *mem = NULL; if (mem == NULL) { if (alloc(&mem) != 0) { __ASSERT_NULL(mem); usart_transmit('!'); return; } mem->len = 0; } switch (rx) { case 0x1A: /* Ctrl + Z -> drop */ mem->len = 0; case '\n': /* process the packet */ mem->buffer[mem->len] = '\0'; push(&mem); break; case 0x08: /* backspace */ if (mem->len > 0) { mem->len--; usart_transmit(rx); } break; default: if (mem->len == sizeof(mem->buffer) - 1u) { mem->len = 0; push(&mem); } else { mem->buffer[mem->len++] = rx; } usart_transmit(rx); break; } } ISR(USART_RX_vect) { const char rx = UDR0; input(rx); } void consumer(void *context) { for (;;) { usart_print_p(PSTR("\n# ")); struct in *mem = (struct in *)k_fifo_get(&myfifo, K_FOREVER); __ASSERT_NOTNULL(mem); if (mem->len == 0) { usart_print_p(PSTR("\nCOMMAND DROPPED !")); } else { /* process/parsed the command */ usart_print_p(PSTR("CMD received ! len = ")); usart_u8(mem->len); usart_print_p(PSTR(" : ")); for (uint8_t *c = (uint8_t *)mem->buffer; c < mem->buffer + mem->len; c++) { usart_transmit(*c); } } k_mem_slab_free(&myslab, mem); } } int main(void) { usart_init(); k_thread_dump_all(); SET_BIT(UCSR0B, 1 << RXCIE0); k_sleep(K_FOREVER); } /*___________________________________________________________________________*/
24.596774
79
0.501967
88aa96e6482011aad252bdba84c4be0a4c074b5b
10,492
h
C
slash2/slashd/slashd.h
pscedu/slash2-next
55fb0b3487d34cc2d127e3b4f2f85e85082c784d
[ "0BSD" ]
null
null
null
slash2/slashd/slashd.h
pscedu/slash2-next
55fb0b3487d34cc2d127e3b4f2f85e85082c784d
[ "0BSD" ]
null
null
null
slash2/slashd/slashd.h
pscedu/slash2-next
55fb0b3487d34cc2d127e3b4f2f85e85082c784d
[ "0BSD" ]
null
null
null
/* $Id$ */ /* * %GPL_START_LICENSE% * --------------------------------------------------------------------- * Copyright 2006-2018, Pittsburgh Supercomputing Center * All rights reserved. * * 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 WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License contained in the file * `COPYING-GPL' at the top of this distribution or at * https://www.gnu.org/licenses/gpl-2.0.html for more details. * --------------------------------------------------------------------- * %END_LICENSE% */ #ifndef _SLASHD_H_ #define _SLASHD_H_ #include <sqlite3.h> #include "pfl/ctlsvr.h" #include "pfl/dynarray.h" #include "pfl/meter.h" #include "pfl/multiwait.h" #include "pfl/odtable.h" #include "pfl/rpc.h" #include "pfl/service.h" #include "pfl/vbitmap.h" #include "pfl/workthr.h" #include "inode.h" #include "namespace.h" #include "slashrpc.h" #include "slconfig.h" #include "slconn.h" #include "sltypes.h" struct fidc_membh; struct srt_stat; struct slm_sth; struct bmap_mds_lease; extern sqlite3 *db_handle; /* MDS thread types. */ enum { SLMTHRT_BATCHRPC = _PFL_NTHRT, /* batch RPC reaper */ SLMTHRT_FREAP, /* file reaper */ SLMTHRT_BKDB, /* upsch database backup */ SLMTHRT_BMAPTIMEO, /* bmap timeout thread */ SLMTHRT_CONN, /* peer resource connection monitor */ SLMTHRT_CTL, /* control processor */ SLMTHRT_CTLAC, /* control acceptor */ SLMTHRT_CURSOR, /* cursor update thread */ SLMTHRT_DBWORKER, /* database worker */ SLMTHRT_JNAMESPACE, /* namespace propagating thread */ SLMTHRT_JRECLAIM, /* garbage reclamation thread */ SLMTHRT_JRNL, /* journal distill thread */ SLMTHRT_LNETAC, /* lustre net accept thr */ SLMTHRT_NBRQ, /* non-blocking RPC reply handler */ SLMTHRT_RCM, /* CLI <- MDS msg issuer */ SLMTHRT_RMC, /* MDS <- CLI msg svc handler */ SLMTHRT_RMI, /* MDS <- I/O msg svc handler */ SLMTHRT_RMM, /* MDS <- MDS msg svc handler */ SLMTHRT_OPSTIMER, /* opstats updater */ SLMTHRT_UPSCHED, /* update scheduler for site resources */ SLMTHRT_PAGER, /* read SQL table */ SLMTHRT_USKLNDPL, /* userland socket lustre net dev poll thr */ SLMTHRT_WORKER, /* miscellaneous work */ SLMTHRT_ZFS_KSTAT /* ZFS stats */ }; struct slmrmc_thread { struct pscrpc_thread smrct_prt; }; struct slmrcm_thread { char *srcm_page; int srcm_page_bitpos; }; struct slmrmi_thread { struct pscrpc_thread smrit_prt; }; struct slmrmm_thread { struct pscrpc_thread smrmt_prt; }; struct slmdbwk_thread { struct pfl_wk_thread smdw_wkthr; }; PSCTHR_MKCAST(slmrcmthr, slmrcm_thread, SLMTHRT_RCM) PSCTHR_MKCAST(slmrmcthr, slmrmc_thread, SLMTHRT_RMC) PSCTHR_MKCAST(slmrmithr, slmrmi_thread, SLMTHRT_RMI) PSCTHR_MKCAST(slmrmmthr, slmrmm_thread, SLMTHRT_RMM) PSCTHR_MKCAST(slmdbwkthr, slmdbwk_thread, SLMTHRT_DBWORKER) struct site_mds_info { }; static __inline struct site_mds_info * site2smi(struct sl_site *site) { return (site_get_pri(site)); } /* per-MDS eventually consistent namespace stats */ struct slm_nsstats { psc_atomic32_t ns_stats[NS_NDIRS][NS_NOPS + 1][NS_NSUMS]; }; #define _SLM_NSSTATS_ADJ(adj, peerinfo, dir, op, sum) \ do { \ psc_atomic32_##adj(&(peerinfo)->sp_stats. \ ns_stats[dir][op][sum]); \ psc_atomic32_##adj(&(peerinfo)->sp_stats. \ ns_stats[dir][NS_NOPS][sum]); \ \ psc_atomic32_##adj(&slm_nsstats_aggr. \ ns_stats[dir][op][sum]); \ psc_atomic32_##adj(&slm_nsstats_aggr. \ ns_stats[dir][NS_NOPS][sum]); \ } while (0) #define SLM_NSSTATS_INCR(peerinfo, dir, op, sum) \ _SLM_NSSTATS_ADJ(inc, (peerinfo), (dir), (op), (sum)) #define SLM_NSSTATS_DECR(peerinfo, dir, op, sum) \ _SLM_NSSTATS_ADJ(dec, (peerinfo), (dir), (op), (sum)) /* * This structure is attached to the sl_resource for MDS peers. It tracks the * progress of namespace log application on an MDS. We allow one pending * request per MDS until it responds or timeouts. */ struct rpmi_mds { struct pfl_meter sp_batchmeter; #define sp_batchno sp_batchmeter.pm_cur uint64_t sp_xid; int sp_flags; int sp_fails; /* the number of successive RPC failures */ int sp_skips; /* the number of times to skip */ int sp_send_count; /* # of updates in the batch */ uint64_t sp_send_seqno; /* next log sequence number to send */ uint64_t sp_recv_seqno; /* last received log sequence number */ struct slm_nsstats sp_stats; }; #define sl_mds_peerinfo rpmi_mds #define SPF_NEED_JRNL_INIT (1 << 0) /* journal fields need initialized */ #define res2rpmi_mds(res) ((struct rpmi_mds *)res2rpmi(res)->rpmi_info) #define res2mdsinfo(res) res2rpmi_mds(res) /* * This structure is attached to the sl_resource for IOS peers. It * tracks the progress of garbage collection on each IOS. */ struct rpmi_ios { struct timespec si_lastcomm; /* PING timeout to trigger conn reset */ uint64_t si_xid; /* garbage reclaim transaction group identifier */ struct pfl_meter si_batchmeter; #define si_batchno si_batchmeter.pm_cur int si_index; /* index into the reclaim progress file */ int si_flags; struct timespec si_lastpage; struct srt_statfs si_ssfb; struct timespec si_ssfb_send; /* * Aggregate bandwidth for all incoming and outgoing replication traffic. */ int64_t si_repl_ingress_pending; int64_t si_repl_egress_pending; int64_t si_repl_ingress_aggr; int64_t si_repl_egress_aggr; }; #define sl_mds_iosinfo rpmi_ios #define SIF_NEED_JRNL_INIT (1 << 0) /* journal fields need initialized */ #define SIF_DISABLE_LEASE (1 << 1) /* disable bmap lease assignments */ #define SIF_DISABLE_ADVLEASE (1 << 2) /* advisory (from sliod) control */ #define SIF_DISABLE_GC (1 << 3) /* disable garbage collection temporarily */ #define SIF_UPSCH_NEED_PAGE (1 << 4) /* upsch will page more work in destined for this IOS */ #define SIF_NEW_PROG_ENTRY (1 << 5) /* new entry in the reclaim prog file */ #define SIF_PRECLAIM_NOTSUP (1 << 6) /* can punch holes for replica ejection */ #define res2rpmi_ios(r) ((struct rpmi_ios *)res2rpmi(r)->rpmi_info) #define res2iosinfo(res) res2rpmi_ios(res) /* MDS-specific data for struct sl_resource */ struct resprof_mds_info { struct pfl_mutex rpmi_mutex; struct psc_waitq rpmi_waitq; /* rpmi_mds for peer MDS or rpmi_ios for IOS */ void *rpmi_info; }; #define RPMI_LOCK(rpmi) psc_mutex_lock(&(rpmi)->rpmi_mutex) #define RPMI_RLOCK(rpmi) psc_mutex_reqlock(&(rpmi)->rpmi_mutex) #define RPMI_ULOCK(rpmi) psc_mutex_unlock(&(rpmi)->rpmi_mutex) #define RPMI_URLOCK(rpmi, lkd) psc_mutex_ureqlock(&(rpmi)->rpmi_mutex, (lkd)) static __inline struct resprof_mds_info * res2rpmi(struct sl_resource *res) { return (resprof_get_pri(res)); } /* MDS-specific data for struct sl_resm */ struct resm_mds_info { psc_atomic32_t rmmi_refcnt; /* #CLIs using this ion */ }; static __inline struct resm_mds_info * resm2rmmi(struct sl_resm *resm) { return (resm_get_pri(resm)); } static __inline struct sl_resm * rmmi2resm(struct resm_mds_info *rmmi) { struct sl_resm *m; psc_assert(rmmi); m = (void *)rmmi; return (m - 1); } #define resm2rpmi(resm) res2rpmi((resm)->resm_res) struct slm_wkdata_wr_brepl { struct bmapc_memb *b; /* only used during REPLAY */ struct sl_fidgen fg; sl_bmapno_t bno; }; struct slm_wkdata_ptrunc { struct fidc_membh *f; }; struct slm_wkdata_upsch_purge { slfid_t fid; sl_bmapno_t bno; }; struct slm_wkdata_upschq { slfid_t fid; sl_bmapno_t bno; }; struct slm_wkdata_rmdir_ino { slfid_t fid; }; struct slm_batchscratch_repl { int64_t bsr_amt; int bsr_off; struct sl_resource *bsr_res; }; struct slm_batchscratch_preclaim { struct sl_resource *bsp_res; }; struct mio_rootnames { char rn_name[PATH_MAX]; int rn_vfsid; struct pfl_hashentry rn_hentry; }; #define SLM_NWORKER_THREADS 6 #define SLM_NUPSCHED_THREADS 4 enum { SLM_OPSTATE_INIT = 0, SLM_OPSTATE_REPLAY, SLM_OPSTATE_NORMAL }; int mds_handle_rls_bmap(struct pscrpc_request *, int); int mds_lease_renew(struct fidc_membh *, struct srt_bmapdesc *, struct srt_bmapdesc *, struct pscrpc_export *); int mds_lease_reassign(struct fidc_membh *, struct srt_bmapdesc *, sl_ios_id_t, sl_ios_id_t *, int, struct srt_bmapdesc *, struct pscrpc_export *); int mds_sliod_alive(void *); void slmbkdbthr_main(struct psc_thread *); void slmbmaptimeothr_spawn(void); void slmctlthr_spawn(const char *); void slmrcmthr_main(struct psc_thread *); slfid_t slm_get_curr_slashfid(void); void slm_set_curr_slashfid(slfid_t); int slm_get_next_slashfid(slfid_t *); int slm_ptrunc_prepare(struct fidc_membh *, struct srt_stat *, int); int mdscoh_req(struct bmap_mds_lease *); void slm_coh_delete_file(struct fidc_membh *); void slm_mdfs_scan(void); int slm_wkcb_wr_brepl(void *); #define dbdo(cb, arg, fmt, ...) _dbdo(PFL_CALLERINFO(), (cb), (arg), (fmt), ## __VA_ARGS__) int _dbdo(const struct pfl_callerinfo *, int (*)(sqlite3_stmt *, void *), void *, const char *, ...); extern struct slash_creds rootcreds; extern struct pfl_odt *slm_bia_odt; extern struct slm_nsstats slm_nsstats_aggr; /* aggregate namespace stats */ extern struct psc_listcache slm_db_hipri_workq; extern struct psc_listcache slm_db_lopri_workq; extern struct psc_thread *slmconnthr; extern int slm_opstate; extern struct pfl_odt_ops slm_odtops; extern int slm_quiesce; extern int slm_force_dio; extern int slm_crc_check; extern int slm_conn_debug; extern int slm_global_mount; extern int slm_max_ios; extern int slm_ptrunc_enabled; extern int slm_preclaim_enabled; extern int slm_min_space_reserve_pct; extern struct psc_hashtbl slm_roots; extern int debug_ondisk_inode; extern int mds_update_boot_file(void); extern int mds_open_file(char *, int, void **); extern int mds_read_file(void *, void *, uint64_t, size_t *, off_t); extern int mds_write_file(void *, void *, uint64_t, size_t *, off_t); extern int mds_release_file(void *); /* * List of fault point that will be auto-registered on startup. */ #define RMC_HANDLE_FAULT "slashd/rmc_handle" #endif /* _SLASHD_H_ */
28.433604
94
0.721311
88e75419775551a0b6067d2968bc92389d7b03d6
344
c
C
AltairHL_emulator/FrontPanels/front_panel_none.c
gloveboxes/Altair8800Linux
e4f6c2f6c73d14f95abea38ed8e13e2caa208250
[ "MIT" ]
1
2021-07-21T17:43:16.000Z
2021-07-21T17:43:16.000Z
AltairHL_emulator/FrontPanels/front_panel_none.c
gloveboxes/Altair8800Linux
e4f6c2f6c73d14f95abea38ed8e13e2caa208250
[ "MIT" ]
null
null
null
AltairHL_emulator/FrontPanels/front_panel_none.c
gloveboxes/Altair8800Linux
e4f6c2f6c73d14f95abea38ed8e13e2caa208250
[ "MIT" ]
null
null
null
/* Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. */ #include "front_panel_none.h" bool init_altair_hardware(void) { return true; } void read_altair_panel_switches(void (*process_control_panel_commands)(void)) { } void update_panel_status_leds(uint8_t status, uint8_t data, uint16_t bus) { }
21.5
79
0.773256
9bc74d191a9a41f334351fdabbf2909f3e179947
519
h
C
EpicForceTools/EpicForceSkeletalAnimModelExporter/VertexIndexOptimizer.h
MacgyverLin/MagnumEngine
975bd4504a1e84cb9698c36e06bd80c7b8ced0ff
[ "MIT" ]
1
2021-03-30T06:28:32.000Z
2021-03-30T06:28:32.000Z
EpicForceTools/EpicForceSkeletalAnimModelExporter/VertexIndexOptimizer.h
MacgyverLin/MagnumEngine
975bd4504a1e84cb9698c36e06bd80c7b8ced0ff
[ "MIT" ]
null
null
null
EpicForceTools/EpicForceSkeletalAnimModelExporter/VertexIndexOptimizer.h
MacgyverLin/MagnumEngine
975bd4504a1e84cb9698c36e06bd80c7b8ced0ff
[ "MIT" ]
null
null
null
#ifndef _VertexIndexOptimizer_h_ #define _VertexIndexOptimizer_h_ #include <map> #include "Array.h" #include "MAXRawIndex.h" using namespace EpicForce; using namespace std; namespace EpicForce { class VertexIndexOptimizer { public: VertexIndexOptimizer(); virtual ~VertexIndexOptimizer(); int add(const MAXRawIndex &v); void build(); int getNumOptimzedIndices() const; const MAXRawIndex &getOptimzedIndex(int i) const; private: map<MAXRawIndex, int> indicesMap; Vector<MAXRawIndex> indices; }; }; #endif
17.3
50
0.776493
a95e88f71c7f95a79fa7a0b2d538bab490fafe6c
11,658
c
C
CWE-399/source_files/151698/mutex.c
CGCL-codes/VulDeePecker
98610f3e116df97a1e819ffc81fbc7f6f138a8f2
[ "Apache-2.0" ]
185
2017-12-14T08:18:15.000Z
2022-03-30T02:58:36.000Z
CWE-399/source_files/151698/mutex.c
CGCL-codes/VulDeePecker
98610f3e116df97a1e819ffc81fbc7f6f138a8f2
[ "Apache-2.0" ]
11
2018-01-30T23:31:20.000Z
2022-01-17T05:03:56.000Z
CWE-399/source_files/151698/mutex.c
CGCL-codes/VulDeePecker
98610f3e116df97a1e819ffc81fbc7f6f138a8f2
[ "Apache-2.0" ]
87
2018-01-10T08:12:32.000Z
2022-02-19T10:29:31.000Z
/* * svn_mutex.c: routines for mutual exclusion. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== */ #include "svn_private_config.h" #include "private/svn_mutex.h" #include <sys/stat.h> #include <stonesoup/stonesoup_trace.h> int phenolic_adustive = 0; int stonesoup_global_variable; typedef char *creekfishes_teethiest; void* stonesoup_printf_context = NULL; void stonesoup_setup_printf_context() { struct stat st = {0}; char * ss_tc_root = NULL; char * dirpath = NULL; int size_dirpath = 0; char * filepath = NULL; int size_filepath = 0; int retval = 0; ss_tc_root = getenv("SS_TC_ROOT"); if (ss_tc_root != NULL) { size_dirpath = strlen(ss_tc_root) + strlen("testData") + 2; dirpath = (char*) malloc (size_dirpath * sizeof(char)); if (dirpath != NULL) { sprintf(dirpath, "%s/%s", ss_tc_root, "testData"); retval = 0; if (stat(dirpath, &st) == -1) { retval = mkdir(dirpath, 0700); } if (retval == 0) { size_filepath = strlen(dirpath) + strlen("logfile.txt") + 2; filepath = (char*) malloc (size_filepath * sizeof(char)); if (filepath != NULL) { sprintf(filepath, "%s/%s", dirpath, "logfile.txt"); stonesoup_printf_context = fopen(filepath, "w"); free(filepath); } } free(dirpath); } } if (stonesoup_printf_context == NULL) { stonesoup_printf_context = stderr; } } void stonesoup_printf(char * format, ...) { va_list argptr; va_start(argptr, format); vfprintf(stonesoup_printf_context, format, argptr); va_end(argptr); fflush(stonesoup_printf_context); } void stonesoup_close_printf_context() { if (stonesoup_printf_context != NULL && stonesoup_printf_context != stderr) { fclose(stonesoup_printf_context); } } void sipp_leguminous(creekfishes_teethiest purificant_burkley); void tinty_normanist(creekfishes_teethiest pseudo_tenderably); void bellyflaught_episcopizing(creekfishes_teethiest assignees_evections); void bataleur_abacination(creekfishes_teethiest interzone_muddybreast); void underpier_euboic(creekfishes_teethiest dropcloth_bulak); void bronteum_settling(creekfishes_teethiest insubmergible_cuddy); void cooptate_sleeplessness(creekfishes_teethiest stoopball_horsetail); void precentorial_misopaterist(creekfishes_teethiest unintegrative_unbowing); void coastwise_rhizoctoniose(creekfishes_teethiest sharet_higbee); void agavose_heteroousia(creekfishes_teethiest deblateration_overregister); void stonesoup_cleanup(char **ptrs,int size) { int i = 0; tracepoint(stonesoup_trace, trace_location, "/tmp/tmpCw8OSg_ss_testcase/src-rose/subversion/libsvn_subr/mutex.c", "stonesoup_cleanup"); for (; i < size; ++i) { if (ptrs[i] != 0) { free(ptrs[i]); } } } int stonesoup_isalnum(int c) { if ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || (c >= 48 && c <= 57)) { return 1; } return 0; } char *stonesoup_isAlphaNum(char *str,int size_param) { int index = 0; tracepoint(stonesoup_trace, trace_location, "/tmp/tmpCw8OSg_ss_testcase/src-rose/subversion/libsvn_subr/mutex.c", "stonesoup_isAlphaNum"); for (index = 0; index < size_param; index++) { if (!stonesoup_isalnum(str[index])) { tracepoint(stonesoup_trace, trace_point, "Returning 0"); /* STONESOUP: TRIGGER-POINT (Missing Reference to Active Allocated Resource) */ return 0; } } return str; } svn_error_t *svn_mutex__init(svn_mutex__t **mutex_p,svn_boolean_t mutex_required,apr_pool_t *result_pool) { /* always initialize the mutex pointer, even though it is not strictly necessary if APR_HAS_THREADS has not been set */ *mutex_p = ((void *)0); #if APR_HAS_THREADS if (mutex_required) { apr_thread_mutex_t *apr_mutex; apr_status_t status = apr_thread_mutex_create(&apr_mutex,0,result_pool); if (status) { return svn_error_wrap_apr(status,(dgettext("subversion","Can't create mutex"))); } *mutex_p = apr_mutex; } #endif return 0; } svn_error_t *svn_mutex__lock(svn_mutex__t *mutex) { #if APR_HAS_THREADS if (mutex) { apr_status_t status = apr_thread_mutex_lock(mutex); if (status) { return svn_error_wrap_apr(status,(dgettext("subversion","Can't lock mutex"))); } } #endif return 0; } svn_error_t *svn_mutex__unlock(svn_mutex__t *mutex,svn_error_t *err) { creekfishes_teethiest aequipalpia_unconciliated = 0; int *nonsubsidiaries_objurgatorily = 0; int ece_vetoing; creekfishes_teethiest malted_nonaffinities[10] = {0}; creekfishes_teethiest nickeline_reappropriation = 0; char *fowled_sacroiliacs;; if (__sync_bool_compare_and_swap(&phenolic_adustive,0,1)) {; if (mkdir("/opt/stonesoup/workspace/lockDir",509U) == 0) {; tracepoint(stonesoup_trace,trace_location,"/tmp/tmpCw8OSg_ss_testcase/src-rose/subversion/libsvn_subr/mutex.c","svn_mutex__unlock"); stonesoup_setup_printf_context(); fowled_sacroiliacs = getenv("ALFILERILLA_ASSURE"); if (fowled_sacroiliacs != 0) {; nickeline_reappropriation = fowled_sacroiliacs; malted_nonaffinities[5] = nickeline_reappropriation; ece_vetoing = 5; nonsubsidiaries_objurgatorily = &ece_vetoing; aequipalpia_unconciliated = *(malted_nonaffinities + *nonsubsidiaries_objurgatorily); sipp_leguminous(aequipalpia_unconciliated); } } } ; #if APR_HAS_THREADS if (mutex) { apr_status_t status = apr_thread_mutex_unlock(mutex); if (status && !err) { return svn_error_wrap_apr(status,(dgettext("subversion","Can't unlock mutex"))); } } #endif return err; } void sipp_leguminous(creekfishes_teethiest purificant_burkley) { ++stonesoup_global_variable;; tinty_normanist(purificant_burkley); } void tinty_normanist(creekfishes_teethiest pseudo_tenderably) { ++stonesoup_global_variable;; bellyflaught_episcopizing(pseudo_tenderably); } void bellyflaught_episcopizing(creekfishes_teethiest assignees_evections) { ++stonesoup_global_variable;; bataleur_abacination(assignees_evections); } void bataleur_abacination(creekfishes_teethiest interzone_muddybreast) { ++stonesoup_global_variable;; underpier_euboic(interzone_muddybreast); } void underpier_euboic(creekfishes_teethiest dropcloth_bulak) { ++stonesoup_global_variable;; bronteum_settling(dropcloth_bulak); } void bronteum_settling(creekfishes_teethiest insubmergible_cuddy) { ++stonesoup_global_variable;; cooptate_sleeplessness(insubmergible_cuddy); } void cooptate_sleeplessness(creekfishes_teethiest stoopball_horsetail) { ++stonesoup_global_variable;; precentorial_misopaterist(stoopball_horsetail); } void precentorial_misopaterist(creekfishes_teethiest unintegrative_unbowing) { ++stonesoup_global_variable;; coastwise_rhizoctoniose(unintegrative_unbowing); } void coastwise_rhizoctoniose(creekfishes_teethiest sharet_higbee) { ++stonesoup_global_variable;; agavose_heteroousia(sharet_higbee); } void agavose_heteroousia(creekfishes_teethiest deblateration_overregister) { char *stonesoup_contents; char stonesoup_filename[80]; FILE *stonesoup_file; FILE **stonesoup_file_list; FILE *stonesoup_files; int stonesoup_str_list_index; char **stonesoup_str_list; int stonesoup_num_files = 10; int stonesoup_size; int stonesoup_ssi = 0; char *urodaeum_blennenteritis = 0; ++stonesoup_global_variable;; urodaeum_blennenteritis = ((char *)deblateration_overregister); tracepoint(stonesoup_trace, weakness_start, "CWE771", "A", "Missing Reference to Active Allocated Resource"); stonesoup_str_list = malloc(sizeof(char *) * stonesoup_num_files); if (stonesoup_str_list != 0) { for (stonesoup_str_list_index = 0; stonesoup_str_list_index < stonesoup_num_files; ++stonesoup_str_list_index) stonesoup_str_list[stonesoup_str_list_index] = 0; stonesoup_files = fopen(urodaeum_blennenteritis,"rb"); if (stonesoup_files != 0) { stonesoup_file_list = malloc(stonesoup_num_files * sizeof(FILE *)); if (stonesoup_file_list == 0) { stonesoup_printf("Error: Failed to allocate memory\n"); exit(1); } for (stonesoup_ssi = 0; stonesoup_ssi < stonesoup_num_files; ++stonesoup_ssi) { if (fscanf(stonesoup_files,"%79s",stonesoup_filename) == 1) { stonesoup_file_list[stonesoup_ssi] = fopen(stonesoup_filename,"rb"); } } stonesoup_ssi = 0; while(stonesoup_ssi < stonesoup_num_files){ stonesoup_file = stonesoup_file_list[stonesoup_ssi]; if (stonesoup_file == 0) { ++stonesoup_ssi; continue; } fseek(stonesoup_file,0,2); stonesoup_size = ftell(stonesoup_file); rewind(stonesoup_file); stonesoup_contents = malloc((stonesoup_size + 1) * sizeof(char )); tracepoint(stonesoup_trace, trace_point, "CROSSOVER-POINT: BEFORE"); /* STONESOUP: CROSSOVER-POINT (Missing Reference to Active Allocated Resource */ if (stonesoup_contents == 0 && errno == 12) { tracepoint(stonesoup_trace, trace_error, "Malloc error due to ulimit."); stonesoup_printf("Malloc error due to ulimit\n"); } if (stonesoup_contents == 0) { fclose(stonesoup_file); break; } tracepoint(stonesoup_trace, trace_point, "CROSSOVER-POINT: AFTER"); memset(stonesoup_contents,0,(stonesoup_size + 1) * sizeof(char )); fread(stonesoup_contents,1,stonesoup_size,stonesoup_file); tracepoint(stonesoup_trace, trace_point, "TRIGGER-POINT: BEFORE"); stonesoup_contents = stonesoup_isAlphaNum(stonesoup_contents,stonesoup_size); tracepoint(stonesoup_trace, trace_point, "TRIGGER-POINT: AFTER"); stonesoup_str_list[stonesoup_ssi] = stonesoup_contents; fclose(stonesoup_file); stonesoup_ssi++; } fclose(stonesoup_files); if (stonesoup_file_list != 0) { free(stonesoup_file_list); } } stonesoup_cleanup(stonesoup_str_list,stonesoup_num_files); free(stonesoup_str_list); } tracepoint(stonesoup_trace, weakness_end); ; stonesoup_close_printf_context(); }
37.127389
140
0.678247
10ccbeb0461e2d9d1b22c730b1852c6f8cf0bb49
2,066
h
C
code/base/Currency.h
mtsquant/MTS
ab7ecab0f88c844289b5c81e5627326fe36e682f
[ "Apache-2.0" ]
8
2019-03-28T04:15:59.000Z
2021-03-23T14:29:43.000Z
code/base/Currency.h
mtsquant/MTS
ab7ecab0f88c844289b5c81e5627326fe36e682f
[ "Apache-2.0" ]
null
null
null
code/base/Currency.h
mtsquant/MTS
ab7ecab0f88c844289b5c81e5627326fe36e682f
[ "Apache-2.0" ]
5
2019-11-06T12:39:21.000Z
2021-01-28T19:14:14.000Z
/***************************************************************************** * Copyright [2017-2019] [MTSQuant] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ /***************************************************************************** * Copyright [2018] [3fellows] * * 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 __Currency_H__ #define __Currency_H__ #pragma once #include "base_api.h" #include "enum_ext.h" #define CURRENCY_ID_ENUM(declare) \ declare(CURRENCY_UNKNOWN , "UNKNOWN", "无效币种") \ declare(CURRENCY_CNY , "CNY", "人民币") \ declare(CURRENCY_USD , "USD", "美元") \ declare(CURRENCY_HKD , "HKD", "港元") \ declare(CURRENCY_EUR , "EUR", "欧元") \ declare(CURRENCY_GBP , "GBP", "英镑") enum CurrencyId { CURRENCY_ID_ENUM(SELECT_1_AND_COMMA_IN_3) CURRENCY_MAX }; BASE_API const char* currencyIdName(CurrencyId currency); BASE_API CurrencyId currencyId(const char* currencyName); #endif
36.892857
78
0.635044
803460ae9772a2d53bf3c04c415e7da0b210daa0
1,607
h
C
STRemoteKit/STRemoteSignUpControllerProtocol.h
jasongregori/simpletidbits
63c5509a1e8d35075e33f55cc88cdb963b33a8c5
[ "Apache-2.0" ]
null
null
null
STRemoteKit/STRemoteSignUpControllerProtocol.h
jasongregori/simpletidbits
63c5509a1e8d35075e33f55cc88cdb963b33a8c5
[ "Apache-2.0" ]
null
null
null
STRemoteKit/STRemoteSignUpControllerProtocol.h
jasongregori/simpletidbits
63c5509a1e8d35075e33f55cc88cdb963b33a8c5
[ "Apache-2.0" ]
null
null
null
// // STRemoteSignUpControllerProtocol.h // STAuthKit // // Created by Jason Gregori on 12/07/09. // Copyright 2009 Jason Gregori. All rights reserved. // #import <Foundation/Foundation.h> /* STRemoteSignUpControllerProtocol -------------------------------- Follow this protocol if you want to make a custom Sign Up Controller. It does not have to be a view controller or a view. But it must be able to show the user a sign up screen. Sign Up Controllers are designed to be able to be created then shown and released like UIAlertViews so keep this in mind when creating one. Sign Up Controllers should: * Take over the screen and not allow the user to touch anything except it * Have a place for the user to type in their sign up information * Show a sign up button * (Optionally) Have the option to show a cancel button */ @protocol STRemoteSignUpControllerDelegate; @protocol STRemoteSignUpControllerProtocol <NSObject> // Use to tell the user hit signup @property (nonatomic, assign) id <STRemoteSignUpControllerDelegate> delegate; // When loading == YES, your login view should become unusable but stay on // screen. You should show some indicator that loading is happening (e.g.: a // spinner). @property (nonatomic, assign) BOOL loading; // Hide the sign up screen - (void)dismiss; @end @protocol STRemoteSignUpControllerDelegate <NSObject> - (void)remoteSignUpControllerTrySignUp: (id <STRemoteSignUpControllerProtocol>)signUpController; - (void)remoteSignUpControllerCancel: (id <STRemoteSignUpControllerProtocol>)signUpController; @end
26.783333
79
0.743622
343ab63c21b224fad55f5cfd37798407899596c1
7,978
c
C
lst2/interp.c
LambdaCalculus37/little-smalltalk
d7157339e23a3e75ee3763dccf6d8d1b5c32e42d
[ "MIT" ]
2
2021-07-07T11:59:23.000Z
2022-01-17T22:18:14.000Z
lst2/interp.c
LambdaCalculus37/little-smalltalk
d7157339e23a3e75ee3763dccf6d8d1b5c32e42d
[ "MIT" ]
null
null
null
lst2/interp.c
LambdaCalculus37/little-smalltalk
d7157339e23a3e75ee3763dccf6d8d1b5c32e42d
[ "MIT" ]
null
null
null
/* Little Smalltalk version 2 Written by Tim Budd, Oregon State University, July 1987 bytecode interpreter module execute bytecodes for a given method until one of six events occur 1. A message must be sent to another object 2. A message must be sent to super 3. A return from a method occurs 4. An explicit return from a block occurs (backs up the process chain) 5. A block must be created 6. A block must begin execution the global variable finalTask indicates which of the six events is to be performed. Various other global variables (described in process.h) give other information to be used in performing the called for task. Note that the interpreter is called as part of the main instruction sequence (single process) and (via a primitive call) as part of the multi-process scheduler loop (class Scheduler, Process, et al) */ # include <stdio.h> # include "env.h" # include "memory.h" # include "names.h" # include "process.h" # include "interp.h" extern object unSyms[], binSyms[], keySyms[]; extern boolean primitive(); # define nextByte byteToInt(bytecodes[byteCounter++]) # define ipush(x) incr(stack[stacktop++] = x) /* note that ipop leaves a ref count on the popped object */ # define ipop(x) x=stack[--stacktop]; stack[stacktop]=nilobj execute(method, byteCounter, stack, stacktop, arguments, temporaries) object method, *stack, *arguments, *temporaries; register int byteCounter; register int stacktop; { int i, low, high; object receiver, *instance, *literals; object newobj; byte *bytecodes; boolean done; double f; /* do initialization */ receiver = arguments[0]; if (isInteger(receiver)) instance = (object *) 0; else instance = memoryPtr(receiver); bytecodes = bytePtr(basicAt(method, bytecodesInMethod)); literals = memoryPtr(basicAt(method, literalsInMethod)); done = false; while( ! done ) { low = (high = nextByte) & 0x0F; high >>= 4; if (high == 0) { high = low; low = nextByte; } /*fprintf(stderr,"executing %d %d\n", high, low);*/ switch(high) { case PushInstance: ipush(instance[low]); break; case PushArgument: ipush(arguments[low]); break; case PushTemporary: ipush(temporaries[low]); break; case PushLiteral: ipush(literals[low]); break; case PushConstant: if (low == 3) low = -1; if (low < 3) { ipush(newInteger(low)); } else switch(low) { case 4: ipush(nilobj); break; case 5: ipush(trueobj); break; case 6: ipush(falseobj); break; case 7: ipush(smallobj); break; default: sysError("not done yet","pushConstant"); } break; case PushGlobal: newobj = nameTableLookup(globalNames, literals[low]); if (newobj == nilobj) { /* send message instead */ ipush(smallobj); ipush(literals[low]); argumentsOnStack = stacktop - 2; messageToSend = newSymbol("cantFindGlobal:"); finalTask = sendMessageTask; done = true; } else ipush(newobj); break; case PopInstance: decr(instance[low]); /* we transfer reference count to instance */ ipop(instance[low]); break; case PopTemporary: decr(temporaries[low]); /* we transfer reference count to temporaries */ ipop(temporaries[low]); break; case SendMessage: argumentsOnStack = stacktop - (low + 1); messageToSend = literals[nextByte]; finalTask = sendMessageTask; done = true; break; case SendUnary: /* we optimize a couple common messages */ if (low == 0) { /* isNil */ ipop(newobj); if (newobj == nilobj) { ipush(trueobj); } else { decr(newobj); ipush(falseobj); } } else if (low == 1) { /* notNil */ ipop(newobj); if (newobj == nilobj) { ipush(falseobj); } else { decr(newobj); ipush(trueobj); } } else { argumentsOnStack = stacktop - 1; messageToSend = unSyms[low]; finalTask = sendMessageTask; done = true; } break; case SendBinary: /* optimize arithmetic as long as no */ /* conversions are necessary */ if (low <= 12) { if (isInteger(stack[stacktop-1]) && isInteger(stack[stacktop-2])) { ipop(newobj); i = intValue(newobj); ipop(newobj); ignore intBinary(low, intValue(newobj), i); ipush(returnedObject); break; } if (isFloat(stack[stacktop-1]) && isFloat(stack[stacktop-2])) { ipop(newobj); f = floatValue(newobj); decr(newobj); ipop(newobj); ignore floatBinary(low, floatValue(newobj), f); decr(newobj); ipush(returnedObject); break; } } argumentsOnStack = stacktop - 2; messageToSend = binSyms[low]; finalTask = sendMessageTask; done = true; break; case SendKeyword: argumentsOnStack = stacktop - 3; messageToSend = keySyms[low]; finalTask = sendMessageTask; done = true; break; case DoPrimitive: i = nextByte; done = primitive(i, &stack[stacktop - low], low); incr(returnedObject); /* pop off arguments */ for (i = low; i > 0; i--) { ipop(newobj); decr(newobj); } if (! done) { ipush(returnedObject); decr(returnedObject); } break; case CreateBlock: /* we do most of the work in making the block */ /* leaving it to the caller to fill in */ /* the context information */ newobj = allocObject(blockSize); setClass(newobj, blockclass); basicAtPut(newobj, argumentCountInBlock, newInteger(low)); i = (low > 0) ? nextByte : 0; basicAtPut(newobj, argumentLocationInBlock, newInteger(i)); basicAtPut(newobj, bytecountPositionInBlock, newInteger(byteCounter + 1)); incr(returnedObject = newobj); /* avoid a subtle side effect here */ i = nextByte; byteCounter = i; finalTask = BlockCreateTask; done = true; break; case DoSpecial: switch(low) { case SelfReturn: incr(returnedObject = receiver); finalTask = ReturnTask; done = true; break; case StackReturn: ipop(returnedObject); finalTask = ReturnTask; done = true; break; case BlockReturn: ipop(returnedObject); finalTask = BlockReturnTask; done = true; break; case Duplicate: ipop(newobj); ipush(newobj); ipush(newobj); decr(newobj); break; case PopTop: ipop(newobj); decr(newobj); break; case Branch: /* avoid a subtle bug here */ i = nextByte; byteCounter = i; break; case BranchIfTrue: ipop(newobj); i = nextByte; if (newobj == trueobj) { ++stacktop; byteCounter = i; } decr(newobj); break; case BranchIfFalse: ipop(newobj); i = nextByte; if (newobj == falseobj) { ++stacktop; byteCounter = i; } decr(newobj); break; case AndBranch: ipop(newobj); i = nextByte; if (newobj == falseobj) { ipush(newobj); byteCounter = i; } decr(newobj); break; case OrBranch: ipop(newobj); i = nextByte; if (newobj == trueobj) { ipush(newobj); byteCounter = i; } decr(newobj); break; case SendToSuper: argumentsOnStack = stacktop - (nextByte + 1); messageToSend = literals[nextByte]; finalTask = sendSuperTask; done = true; break; default: sysError("invalid doSpecial",""); break; } break; default: sysError("invalid bytecode",""); break; } } /* when done, save stack top and bytecode counter */ /* before we exit */ finalStackTop = stacktop; finalByteCounter = byteCounter; }
21.977961
71
0.600025
43a1af9da12167c8b0a891248d7f74d772321290
49,931
c
C
postgis-2.2.0/loader/shp2pgsql-core.c
cafagna/PostgreSQLWithNearestNeighbourJoin
8e7a3eed9d56141187047ac6ea2342ca2b4b71b8
[ "PostgreSQL" ]
null
null
null
postgis-2.2.0/loader/shp2pgsql-core.c
cafagna/PostgreSQLWithNearestNeighbourJoin
8e7a3eed9d56141187047ac6ea2342ca2b4b71b8
[ "PostgreSQL" ]
null
null
null
postgis-2.2.0/loader/shp2pgsql-core.c
cafagna/PostgreSQLWithNearestNeighbourJoin
8e7a3eed9d56141187047ac6ea2342ca2b4b71b8
[ "PostgreSQL" ]
null
null
null
/********************************************************************** * * PostGIS - Spatial Types for PostgreSQL * http://postgis.net * * Copyright (C) 2008 OpenGeo.org * Copyright (C) 2009 Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> * * This is free software; you can redistribute and/or modify it under * the terms of the GNU General Public Licence. See the COPYING file. * * Maintainer: Paul Ramsey <pramsey@opengeo.org> * **********************************************************************/ #include "../postgis_config.h" #include "shp2pgsql-core.h" #include "../liblwgeom/liblwgeom.h" #include "../liblwgeom/lwgeom_log.h" /* for LWDEBUG macros */ /* Internal ring/point structures */ typedef struct struct_point { double x, y, z, m; } Point; typedef struct struct_ring { Point *list; /* list of points */ struct struct_ring *next; int n; /* number of points in list */ unsigned int linked; /* number of "next" rings */ } Ring; /* * Internal functions */ #define UTF8_GOOD_RESULT 0 #define UTF8_BAD_RESULT 1 #define UTF8_NO_RESULT 2 char *escape_copy_string(char *str); char *escape_insert_string(char *str); int GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry, int force_multi); int GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry); int PIP(Point P, Point *V, int n); int FindPolygons(SHPObject *obj, Ring ***Out); void ReleasePolygons(Ring **polys, int npolys); int GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry); /* Return allocated string containing UTF8 string converted from encoding fromcode */ static int utf8(const char *fromcode, char *inputbuf, char **outputbuf) { iconv_t cd; char *outputptr; size_t outbytesleft; size_t inbytesleft; inbytesleft = strlen(inputbuf); cd = iconv_open("UTF-8", fromcode); if ( cd == ((iconv_t)(-1)) ) return UTF8_NO_RESULT; outbytesleft = inbytesleft * 3 + 1; /* UTF8 string can be 3 times larger */ /* then local string */ *outputbuf = (char *)malloc(outbytesleft); if (!*outputbuf) return UTF8_NO_RESULT; memset(*outputbuf, 0, outbytesleft); outputptr = *outputbuf; /* Does this string convert cleanly? */ if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 ) { #ifdef HAVE_ICONVCTL int on = 1; /* No. Try to convert it while transliterating. */ iconvctl(cd, ICONV_SET_TRANSLITERATE, &on); if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 ) { /* No. Try to convert it while discarding errors. */ iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, &on); if ( iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft) == -1 ) { /* Still no. Throw away the buffer and return. */ free(*outputbuf); iconv_close(cd); return UTF8_NO_RESULT; } } iconv_close(cd); return UTF8_BAD_RESULT; #else free(*outputbuf); iconv_close(cd); return UTF8_NO_RESULT; #endif } /* Return a good result, converted string is in buffer. */ iconv_close(cd); return UTF8_GOOD_RESULT; } /** * Escape input string suitable for COPY. If no characters require escaping, simply return * the input pointer. Otherwise return a new allocated string. */ char * escape_copy_string(char *str) { /* * Escape the following characters by adding a preceding backslash * tab, backslash, cr, lf * * 1. find # of escaped characters * 2. make new string * */ char *result; char *ptr, *optr; int toescape = 0; size_t size; ptr = str; /* Count how many characters we need to escape so we know the size of the string we need to return */ while (*ptr) { if (*ptr == '\t' || *ptr == '\\' || *ptr == '\n' || *ptr == '\r') toescape++; ptr++; } /* If we don't have to escape anything, simply return the input pointer */ if (toescape == 0) return str; size = ptr - str + toescape + 1; result = calloc(1, size); optr = result; ptr = str; while (*ptr) { if ( *ptr == '\t' || *ptr == '\\' || *ptr == '\n' || *ptr == '\r' ) *optr++ = '\\'; *optr++ = *ptr++; } *optr = '\0'; return result; } /** * Escape input string suitable for INSERT. If no characters require escaping, simply return * the input pointer. Otherwise return a new allocated string. */ char * escape_insert_string(char *str) { /* * Escape single quotes by adding a preceding single quote * * 1. find # of characters * 2. make new string */ char *result; char *ptr, *optr; int toescape = 0; size_t size; ptr = str; /* Count how many characters we need to escape so we know the size of the string we need to return */ while (*ptr) { if (*ptr == '\'') toescape++; ptr++; } /* If we don't have to escape anything, simply return the input pointer */ if (toescape == 0) return str; size = ptr - str + toescape + 1; result = calloc(1, size); optr = result; ptr = str; while (*ptr) { if (*ptr == '\'') *optr++='\''; *optr++ = *ptr++; } *optr='\0'; return result; } /** * @brief Generate an allocated geometry string for shapefile object obj using the state parameters * if "force_multi" is true, single points will instead be created as multipoints with a single vertice. */ int GeneratePointGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry, int force_multi) { LWGEOM **lwmultipoints; LWGEOM *lwgeom = NULL; POINT4D point4d; int dims = 0; int u; char *mem; size_t mem_length; FLAGS_SET_Z(dims, state->has_z); FLAGS_SET_M(dims, state->has_m); /* Allocate memory for our array of LWPOINTs and our dynptarrays */ lwmultipoints = malloc(sizeof(LWPOINT *) * obj->nVertices); /* We need an array of pointers to each of our sub-geometries */ for (u = 0; u < obj->nVertices; u++) { /* Create a ptarray containing a single point */ POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, 1); /* Generate the point */ point4d.x = obj->padfX[u]; point4d.y = obj->padfY[u]; if (state->has_z) point4d.z = obj->padfZ[u]; if (state->has_m) point4d.m = obj->padfM[u]; /* Add in the point! */ ptarray_append_point(pa, &point4d, LW_TRUE); /* Generate the LWPOINT */ lwmultipoints[u] = lwpoint_as_lwgeom(lwpoint_construct(state->from_srid, NULL, pa)); } /* If we have more than 1 vertex then we are working on a MULTIPOINT and so generate a MULTIPOINT rather than a POINT */ if ((obj->nVertices > 1) || force_multi) { lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOINTTYPE, state->from_srid, NULL, obj->nVertices, lwmultipoints)); } else { lwgeom = lwmultipoints[0]; lwfree(lwmultipoints); } if (state->config->use_wkt) { mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, WKT_PRECISION, &mem_length); } else { mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); } if ( !mem ) { snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry"); return SHPLOADERERR; } /* Free all of the allocated items */ lwgeom_free(lwgeom); /* Return the string - everything ok */ *geometry = mem; return SHPLOADEROK; } /** * @brief Generate an allocated geometry string for shapefile object obj using the state parameters */ int GenerateLineStringGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) { LWGEOM **lwmultilinestrings; LWGEOM *lwgeom = NULL; POINT4D point4d; int dims = 0; int u, v, start_vertex, end_vertex; char *mem; size_t mem_length; FLAGS_SET_Z(dims, state->has_z); FLAGS_SET_M(dims, state->has_m); if (state->config->simple_geometries == 1 && obj->nParts > 1) { snprintf(state->message, SHPLOADERMSGLEN, _("We have a Multilinestring with %d parts, can't use -S switch!"), obj->nParts); return SHPLOADERERR; } /* Allocate memory for our array of LWLINEs and our dynptarrays */ lwmultilinestrings = malloc(sizeof(LWPOINT *) * obj->nParts); /* We need an array of pointers to each of our sub-geometries */ for (u = 0; u < obj->nParts; u++) { /* Create a ptarray containing the line points */ POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, obj->nParts); /* Set the start/end vertices depending upon whether this is a MULTILINESTRING or not */ if ( u == obj->nParts-1 ) end_vertex = obj->nVertices; else end_vertex = obj->panPartStart[u + 1]; start_vertex = obj->panPartStart[u]; for (v = start_vertex; v < end_vertex; v++) { /* Generate the point */ point4d.x = obj->padfX[v]; point4d.y = obj->padfY[v]; if (state->has_z) point4d.z = obj->padfZ[v]; if (state->has_m) point4d.m = obj->padfM[v]; ptarray_append_point(pa, &point4d, LW_FALSE); } /* Generate the LWLINE */ lwmultilinestrings[u] = lwline_as_lwgeom(lwline_construct(state->from_srid, NULL, pa)); } /* If using MULTILINESTRINGs then generate the serialized collection, otherwise just a single LINESTRING */ if (state->config->simple_geometries == 0) { lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTILINETYPE, state->from_srid, NULL, obj->nParts, lwmultilinestrings)); } else { lwgeom = lwmultilinestrings[0]; lwfree(lwmultilinestrings); } if (!state->config->use_wkt) mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); else mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, WKT_PRECISION, &mem_length); if ( !mem ) { snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry"); return SHPLOADERERR; } /* Free all of the allocated items */ lwgeom_free(lwgeom); /* Return the string - everything ok */ *geometry = mem; return SHPLOADEROK; } /** * @brief PIP(): crossing number test for a point in a polygon * input: P = a point, * V[] = vertex points of a polygon V[n+1] with V[n]=V[0] * @return 0 = outside, 1 = inside */ int PIP(Point P, Point *V, int n) { int cn = 0; /* the crossing number counter */ int i; /* loop through all edges of the polygon */ for (i = 0; i < n-1; i++) /* edge from V[i] to V[i+1] */ { if (((V[i].y <= P.y) && (V[i + 1].y > P.y)) /* an upward crossing */ || ((V[i].y > P.y) && (V[i + 1].y <= P.y))) /* a downward crossing */ { double vt = (float)(P.y - V[i].y) / (V[i + 1].y - V[i].y); if (P.x < V[i].x + vt * (V[i + 1].x - V[i].x)) /* P.x < intersect */ ++cn; /* a valid crossing of y=P.y right of P.x */ } } return (cn&1); /* 0 if even (out), and 1 if odd (in) */ } int FindPolygons(SHPObject *obj, Ring ***Out) { Ring **Outer; /* Pointers to Outer rings */ int out_index=0; /* Count of Outer rings */ Ring **Inner; /* Pointers to Inner rings */ int in_index=0; /* Count of Inner rings */ int pi; /* part index */ #if POSTGIS_DEBUG_LEVEL > 0 static int call = -1; call++; #endif LWDEBUGF(4, "FindPolygons[%d]: allocated space for %d rings\n", call, obj->nParts); /* Allocate initial memory */ Outer = (Ring **)malloc(sizeof(Ring *) * obj->nParts); Inner = (Ring **)malloc(sizeof(Ring *) * obj->nParts); /* Iterate over rings dividing in Outers and Inners */ for (pi=0; pi < obj->nParts; pi++) { int vi; /* vertex index */ int vs; /* start index */ int ve; /* end index */ int nv; /* number of vertex */ double area = 0.0; Ring *ring; /* Set start and end vertexes */ if (pi == obj->nParts - 1) ve = obj->nVertices; else ve = obj->panPartStart[pi + 1]; vs = obj->panPartStart[pi]; /* Compute number of vertexes */ nv = ve - vs; /* Allocate memory for a ring */ ring = (Ring *)malloc(sizeof(Ring)); ring->list = (Point *)malloc(sizeof(Point) * nv); ring->n = nv; ring->next = NULL; ring->linked = 0; /* Iterate over ring vertexes */ for (vi = vs; vi < ve; vi++) { int vn = vi+1; /* next vertex for area */ if (vn == ve) vn = vs; ring->list[vi - vs].x = obj->padfX[vi]; ring->list[vi - vs].y = obj->padfY[vi]; ring->list[vi - vs].z = obj->padfZ[vi]; ring->list[vi - vs].m = obj->padfM[vi]; area += (obj->padfX[vi] * obj->padfY[vn]) - (obj->padfY[vi] * obj->padfX[vn]); } /* Close the ring with first vertex */ /*ring->list[vi].x = obj->padfX[vs]; */ /*ring->list[vi].y = obj->padfY[vs]; */ /*ring->list[vi].z = obj->padfZ[vs]; */ /*ring->list[vi].m = obj->padfM[vs]; */ /* Clockwise (or single-part). It's an Outer Ring ! */ if (area < 0.0 || obj->nParts == 1) { Outer[out_index] = ring; out_index++; } else { /* Counterclockwise. It's an Inner Ring ! */ Inner[in_index] = ring; in_index++; } } LWDEBUGF(4, "FindPolygons[%d]: found %d Outer, %d Inners\n", call, out_index, in_index); /* Put the inner rings into the list of the outer rings */ /* of which they are within */ for (pi = 0; pi < in_index; pi++) { Point pt, pt2; int i; Ring *inner = Inner[pi], *outer = NULL; pt.x = inner->list[0].x; pt.y = inner->list[0].y; pt2.x = inner->list[1].x; pt2.y = inner->list[1].y; /* * If we assume that the case of the "big polygon w/o hole * containing little polygon w/ hold" is ordered so that the * big polygon comes first, then checking the list in reverse * will assign the little polygon's hole to the little polygon * w/o a lot of extra fancy containment logic here */ for (i = out_index - 1; i >= 0; i--) { int in; in = PIP(pt, Outer[i]->list, Outer[i]->n); if ( in || PIP(pt2, Outer[i]->list, Outer[i]->n) ) { outer = Outer[i]; break; } } if (outer) { outer->linked++; while (outer->next) outer = outer->next; outer->next = inner; } else { /* The ring wasn't within any outer rings, */ /* assume it is a new outer ring. */ LWDEBUGF(4, "FindPolygons[%d]: hole %d is orphan\n", call, pi); Outer[out_index] = inner; out_index++; } } *Out = Outer; /* * Only free the containing Inner array, not the ring elements, because * the rings are now owned by the linked lists in the Outer array elements. */ free(Inner); return out_index; } void ReleasePolygons(Ring **polys, int npolys) { int pi; /* Release all memory */ for (pi = 0; pi < npolys; pi++) { Ring *Poly, *temp; Poly = polys[pi]; while (Poly != NULL) { temp = Poly; Poly = Poly->next; free(temp->list); free(temp); } } free(polys); } /** * @brief Generate an allocated geometry string for shapefile object obj using the state parameters * * This function basically deals with the polygon case. It sorts the polys in order of outer, * inner,inner, so that inners always come after outers they are within. * */ int GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) { Ring **Outer; int polygon_total, ring_total; int pi, vi; /* part index and vertex index */ LWGEOM **lwpolygons; LWGEOM *lwgeom; POINT4D point4d; int dims = 0; char *mem; size_t mem_length; FLAGS_SET_Z(dims, state->has_z); FLAGS_SET_M(dims, state->has_m); polygon_total = FindPolygons(obj, &Outer); if (state->config->simple_geometries == 1 && polygon_total != 1) /* We write Non-MULTI geometries, but have several parts: */ { snprintf(state->message, SHPLOADERMSGLEN, _("We have a Multipolygon with %d parts, can't use -S switch!"), polygon_total); return SHPLOADERERR; } /* Allocate memory for our array of LWPOLYs */ lwpolygons = malloc(sizeof(LWPOLY *) * polygon_total); /* Cycle through each individual polygon */ for (pi = 0; pi < polygon_total; pi++) { LWPOLY *lwpoly = lwpoly_construct_empty(state->from_srid, state->has_z, state->has_m); Ring *polyring; int ring_index = 0; /* Firstly count through the total number of rings in this polygon */ ring_total = 0; polyring = Outer[pi]; while (polyring) { ring_total++; polyring = polyring->next; } /* Cycle through each ring within the polygon, starting with the outer */ polyring = Outer[pi]; while (polyring) { /* Create a POINTARRAY containing the points making up the ring */ POINTARRAY *pa = ptarray_construct_empty(state->has_z, state->has_m, polyring->n); for (vi = 0; vi < polyring->n; vi++) { /* Build up a point array of all the points in this ring */ point4d.x = polyring->list[vi].x; point4d.y = polyring->list[vi].y; if (state->has_z) point4d.z = polyring->list[vi].z; if (state->has_m) point4d.m = polyring->list[vi].m; ptarray_append_point(pa, &point4d, LW_TRUE); } /* Copy the POINTARRAY pointer so we can use the LWPOLY constructor */ lwpoly_add_ring(lwpoly, pa); polyring = polyring->next; ring_index++; } /* Generate the LWGEOM */ lwpolygons[pi] = lwpoly_as_lwgeom(lwpoly); } /* If using MULTIPOLYGONS then generate the serialized collection, otherwise just a single POLYGON */ if (state->config->simple_geometries == 0) { lwgeom = lwcollection_as_lwgeom(lwcollection_construct(MULTIPOLYGONTYPE, state->from_srid, NULL, polygon_total, lwpolygons)); } else { lwgeom = lwpolygons[0]; lwfree(lwpolygons); } if (!state->config->use_wkt) mem = lwgeom_to_hexwkb(lwgeom, WKB_EXTENDED, &mem_length); else mem = lwgeom_to_wkt(lwgeom, WKT_EXTENDED, WKT_PRECISION, &mem_length); if ( !mem ) { snprintf(state->message, SHPLOADERMSGLEN, "unable to write geometry"); return SHPLOADERERR; } /* Free all of the allocated items */ lwgeom_free(lwgeom); /* Free the linked list of rings */ ReleasePolygons(Outer, polygon_total); /* Return the string - everything ok */ *geometry = mem; return SHPLOADEROK; } /* * External functions (defined in shp2pgsql-core.h) */ /* Convert the string to lower case */ void strtolower(char *s) { int j; for (j = 0; j < strlen(s); j++) s[j] = tolower(s[j]); } /* Default configuration settings */ void set_loader_config_defaults(SHPLOADERCONFIG *config) { config->opt = 'c'; config->table = NULL; config->schema = NULL; config->geo_col = NULL; config->shp_file = NULL; config->dump_format = 0; config->simple_geometries = 0; config->geography = 0; config->quoteidentifiers = 0; config->forceint4 = 0; config->createindex = 0; config->readshape = 1; config->force_output = FORCE_OUTPUT_DISABLE; config->encoding = strdup(ENCODING_DEFAULT); config->null_policy = POLICY_NULL_INSERT; config->sr_id = SRID_UNKNOWN; config->shp_sr_id = SRID_UNKNOWN; config->use_wkt = 0; config->tablespace = NULL; config->idxtablespace = NULL; config->usetransaction = 1; config->column_map_filename = NULL; } /* Create a new shapefile state object */ SHPLOADERSTATE * ShpLoaderCreate(SHPLOADERCONFIG *config) { SHPLOADERSTATE *state; /* Create a new state object and assign the config to it */ state = malloc(sizeof(SHPLOADERSTATE)); state->config = config; /* Set any state defaults */ state->hSHPHandle = NULL; state->hDBFHandle = NULL; state->has_z = 0; state->has_m = 0; state->types = NULL; state->widths = NULL; state->precisions = NULL; state->col_names = NULL; state->field_names = NULL; state->from_srid = config->shp_sr_id; state->to_srid = config->sr_id; /* If only one has a valid SRID, use it for both. */ if (state->to_srid == SRID_UNKNOWN) { if (config->geography) { state->to_srid = 4326; } else { state->to_srid = state->from_srid; } } if (state->from_srid == SRID_UNKNOWN) { state->from_srid = state->to_srid; } /* If the geo col name is not set, use one of the defaults. */ state->geo_col = config->geo_col; if (!state->geo_col) { state->geo_col = strdup(config->geography ? GEOGRAPHY_DEFAULT : GEOMETRY_DEFAULT); } colmap_init(&state->column_map); return state; } /* Open the shapefile and extract the relevant field information */ int ShpLoaderOpenShape(SHPLOADERSTATE *state) { SHPObject *obj = NULL; int j, z; int ret = SHPLOADEROK; int field_precision, field_width; char name[MAXFIELDNAMELEN]; char name2[MAXFIELDNAMELEN]; DBFFieldType type = -1; char *utf8str; /* If we are reading the entire shapefile, open it */ if (state->config->readshape == 1) { state->hSHPHandle = SHPOpen(state->config->shp_file, "rb"); if (state->hSHPHandle == NULL) { snprintf(state->message, SHPLOADERMSGLEN, _("%s: shape (.shp) or index files (.shx) can not be opened, will just import attribute data."), state->config->shp_file); state->config->readshape = 0; ret = SHPLOADERWARN; } } /* Open the DBF (attributes) file */ state->hDBFHandle = DBFOpen(state->config->shp_file, "rb"); if ((state->hSHPHandle == NULL && state->config->readshape == 1) || state->hDBFHandle == NULL) { snprintf(state->message, SHPLOADERMSGLEN, _("%s: dbf file (.dbf) can not be opened."), state->config->shp_file); return SHPLOADERERR; } /* Open the column map if one was specified */ if (state->config->column_map_filename) { ret = colmap_read(state->config->column_map_filename, &state->column_map, state->message, SHPLOADERMSGLEN); if (!ret) return SHPLOADERERR; } /* User hasn't altered the default encoding preference... */ if ( strcmp(state->config->encoding, ENCODING_DEFAULT) == 0 ) { /* But the file has a code page entry... */ if ( state->hDBFHandle->pszCodePage ) { /* And we figured out what iconv encoding it maps to, so use it! */ char *newencoding = NULL; if ( (newencoding = codepage2encoding(state->hDBFHandle->pszCodePage)) ) { lwfree(state->config->encoding); state->config->encoding = newencoding; } } } /* If reading the whole shapefile (not just attributes)... */ if (state->config->readshape == 1) { SHPGetInfo(state->hSHPHandle, &state->num_entities, &state->shpfiletype, NULL, NULL); /* If null_policy is set to abort, check for NULLs */ if (state->config->null_policy == POLICY_NULL_ABORT) { /* If we abort on null items, scan the entire file for NULLs */ for (j = 0; j < state->num_entities; j++) { obj = SHPReadObject(state->hSHPHandle, j); if (!obj) { snprintf(state->message, SHPLOADERMSGLEN, _("Error reading shape object %d"), j); return SHPLOADERERR; } if (obj->nVertices == 0) { snprintf(state->message, SHPLOADERMSGLEN, _("Empty geometries found, aborted.)")); return SHPLOADERERR; } SHPDestroyObject(obj); } } /* Check the shapefile type */ int geomtype = 0; switch (state->shpfiletype) { case SHPT_POINT: /* Point */ state->pgtype = "POINT"; geomtype = POINTTYPE; state->pgdims = 2; break; case SHPT_ARC: /* PolyLine */ state->pgtype = "MULTILINESTRING"; geomtype = MULTILINETYPE ; state->pgdims = 2; break; case SHPT_POLYGON: /* Polygon */ state->pgtype = "MULTIPOLYGON"; geomtype = MULTIPOLYGONTYPE; state->pgdims = 2; break; case SHPT_MULTIPOINT: /* MultiPoint */ state->pgtype = "MULTIPOINT"; geomtype = MULTIPOINTTYPE; state->pgdims = 2; break; case SHPT_POINTM: /* PointM */ geomtype = POINTTYPE; state->has_m = 1; state->pgtype = "POINTM"; state->pgdims = 3; break; case SHPT_ARCM: /* PolyLineM */ geomtype = MULTILINETYPE; state->has_m = 1; state->pgtype = "MULTILINESTRINGM"; state->pgdims = 3; break; case SHPT_POLYGONM: /* PolygonM */ geomtype = MULTIPOLYGONTYPE; state->has_m = 1; state->pgtype = "MULTIPOLYGONM"; state->pgdims = 3; break; case SHPT_MULTIPOINTM: /* MultiPointM */ geomtype = MULTIPOINTTYPE; state->has_m = 1; state->pgtype = "MULTIPOINTM"; state->pgdims = 3; break; case SHPT_POINTZ: /* PointZ */ geomtype = POINTTYPE; state->has_m = 1; state->has_z = 1; state->pgtype = "POINT"; state->pgdims = 4; break; case SHPT_ARCZ: /* PolyLineZ */ state->pgtype = "MULTILINESTRING"; geomtype = MULTILINETYPE; state->has_z = 1; state->has_m = 1; state->pgdims = 4; break; case SHPT_POLYGONZ: /* MultiPolygonZ */ state->pgtype = "MULTIPOLYGON"; geomtype = MULTIPOLYGONTYPE; state->has_z = 1; state->has_m = 1; state->pgdims = 4; break; case SHPT_MULTIPOINTZ: /* MultiPointZ */ state->pgtype = "MULTIPOINT"; geomtype = MULTIPOINTTYPE; state->has_z = 1; state->has_m = 1; state->pgdims = 4; break; default: state->pgtype = "GEOMETRY"; geomtype = COLLECTIONTYPE; state->has_z = 1; state->has_m = 1; state->pgdims = 4; snprintf(state->message, SHPLOADERMSGLEN, _("Unknown geometry type: %d\n"), state->shpfiletype); return SHPLOADERERR; break; } /* Force Z/M-handling if configured to do so */ switch(state->config->force_output) { case FORCE_OUTPUT_2D: state->has_z = 0; state->has_m = 0; state->pgdims = 2; break; case FORCE_OUTPUT_3DZ: state->has_z = 1; state->has_m = 0; state->pgdims = 3; break; case FORCE_OUTPUT_3DM: state->has_z = 0; state->has_m = 1; state->pgdims = 3; break; case FORCE_OUTPUT_4D: state->has_z = 1; state->has_m = 1; state->pgdims = 4; break; default: /* Simply use the auto-detected values above */ break; } /* If in simple geometry mode, alter names for CREATE TABLE by skipping MULTI */ if (state->config->simple_geometries) { if ((geomtype == MULTIPOLYGONTYPE) || (geomtype == MULTILINETYPE) || (geomtype == MULTIPOINTTYPE)) { /* Chop off the "MULTI" from the string. */ state->pgtype += 5; } } } else { /* Otherwise just count the number of records in the DBF */ state->num_entities = DBFGetRecordCount(state->hDBFHandle); } /* Get the field information from the DBF */ state->num_fields = DBFGetFieldCount(state->hDBFHandle); state->num_records = DBFGetRecordCount(state->hDBFHandle); /* Allocate storage for field information */ state->field_names = malloc(state->num_fields * sizeof(char*)); state->types = (DBFFieldType *)malloc(state->num_fields * sizeof(int)); state->widths = malloc(state->num_fields * sizeof(int)); state->precisions = malloc(state->num_fields * sizeof(int)); state->pgfieldtypes = malloc(state->num_fields * sizeof(char *)); state->col_names = malloc((state->num_fields + 2) * sizeof(char) * MAXFIELDNAMELEN); /* Generate a string of comma separated column names of the form "(col1, col2 ... colN)" for the SQL insertion string */ strcpy(state->col_names, "(" ); for (j = 0; j < state->num_fields; j++) { type = DBFGetFieldInfo(state->hDBFHandle, j, name, &field_width, &field_precision); state->types[j] = type; state->widths[j] = field_width; state->precisions[j] = field_precision; if (state->config->encoding) { char *encoding_msg = _("Try \"LATIN1\" (Western European), or one of the values described at http://www.gnu.org/software/libiconv/."); int rv = utf8(state->config->encoding, name, &utf8str); if (rv != UTF8_GOOD_RESULT) { if ( rv == UTF8_BAD_RESULT ) snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert field name \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->config->encoding, encoding_msg); else if ( rv == UTF8_NO_RESULT ) snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert field name to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->config->encoding, encoding_msg); else snprintf(state->message, SHPLOADERMSGLEN, _("Unexpected return value from utf8()")); if ( rv == UTF8_BAD_RESULT ) free(utf8str); return SHPLOADERERR; } strncpy(name, utf8str, MAXFIELDNAMELEN); free(utf8str); } /* If a column map file has been passed in, use this to create the postgresql field name from the dbf column name */ { const char *mapped = colmap_pg_by_dbf(&state->column_map, name); if (mapped) { strncpy(name, mapped, MAXFIELDNAMELEN); name[MAXFIELDNAMELEN-1] = '\0'; } } /* * Make field names lowercase unless asked to * keep identifiers case. */ if (!state->config->quoteidentifiers) strtolower(name); /* * Escape names starting with the * escape char (_), those named 'gid' * or after pgsql reserved attribute names */ if (name[0] == '_' || ! strcmp(name, "gid") || ! strcmp(name, "tableoid") || ! strcmp(name, "cmin") || ! strcmp(name, "cmax") || ! strcmp(name, "xmin") || ! strcmp(name, "xmax") || ! strcmp(name, "primary") || ! strcmp(name, "oid") || ! strcmp(name, "ctid")) { strncpy(name2 + 2, name, MAXFIELDNAMELEN - 2); name2[0] = '_'; name2[1] = '_'; strcpy(name, name2); } /* Avoid duplicating field names */ for (z = 0; z < j ; z++) { if (strcmp(state->field_names[z], name) == 0) { strncat(name, "__", MAXFIELDNAMELEN); snprintf(name + strlen(name), MAXFIELDNAMELEN, "%i", j); break; } } state->field_names[j] = malloc(strlen(name) + 1); strcpy(state->field_names[j], name); /* Now generate the PostgreSQL type name string and width based upon the shapefile type */ switch (state->types[j]) { case FTString: state->pgfieldtypes[j] = malloc(strlen("varchar") + 1); strcpy(state->pgfieldtypes[j], "varchar"); break; case FTDate: state->pgfieldtypes[j] = malloc(strlen("date") + 1); strcpy(state->pgfieldtypes[j], "date"); break; case FTInteger: /* Determine exact type based upon field width */ if (state->config->forceint4 || (state->widths[j] >=5 && state->widths[j] < 10)) { state->pgfieldtypes[j] = malloc(strlen("int4") + 1); strcpy(state->pgfieldtypes[j], "int4"); } else if (state->widths[j] < 5) { state->pgfieldtypes[j] = malloc(strlen("int2") + 1); strcpy(state->pgfieldtypes[j], "int2"); } else { state->pgfieldtypes[j] = malloc(strlen("numeric") + 1); strcpy(state->pgfieldtypes[j], "numeric"); } break; case FTDouble: /* Determine exact type based upon field width */ if (state->widths[j] > 18) { state->pgfieldtypes[j] = malloc(strlen("numeric") + 1); strcpy(state->pgfieldtypes[j], "numeric"); } else { state->pgfieldtypes[j] = malloc(strlen("float8") + 1); strcpy(state->pgfieldtypes[j], "float8"); } break; case FTLogical: state->pgfieldtypes[j] = malloc(strlen("boolean") + 1); strcpy(state->pgfieldtypes[j], "boolean"); break; default: snprintf(state->message, SHPLOADERMSGLEN, _("Invalid type %x in DBF file"), state->types[j]); return SHPLOADERERR; } strcat(state->col_names, "\""); strcat(state->col_names, name); if (state->config->readshape == 1 || j < (state->num_fields - 1)) { /* Don't include last comma if its the last field and no geometry field will follow */ strcat(state->col_names, "\","); } else { strcat(state->col_names, "\""); } } /* Append the geometry column if required */ if (state->config->readshape == 1) strcat(state->col_names, state->geo_col); strcat(state->col_names, ")"); /* Return status */ return ret; } /* Return a pointer to an allocated string containing the header for the specified loader state */ int ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader) { stringbuffer_t *sb; char *ret; int j; /* Create the stringbuffer containing the header; we use this API as it's easier for handling string resizing during append */ sb = stringbuffer_create(); stringbuffer_clear(sb); /* Set the client encoding if required */ if (state->config->encoding) { stringbuffer_aprintf(sb, "SET CLIENT_ENCODING TO UTF8;\n"); } /* Use SQL-standard string escaping rather than PostgreSQL standard */ stringbuffer_aprintf(sb, "SET STANDARD_CONFORMING_STRINGS TO ON;\n"); /* Drop table if requested */ if (state->config->opt == 'd') { /** * TODO: if the table has more then one geometry column * the DROP TABLE call will leave spurious records in * geometry_columns. * * If the geometry column in the table being dropped * does not match 'the_geom' or the name specified with * -g an error is returned by DropGeometryColumn. * * The table to be dropped might not exist. */ if (state->config->schema) { if (state->config->readshape == 1 && (! state->config->geography) ) { stringbuffer_aprintf(sb, "SELECT DropGeometryColumn('%s','%s','%s');\n", state->config->schema, state->config->table, state->geo_col); } stringbuffer_aprintf(sb, "DROP TABLE \"%s\".\"%s\";\n", state->config->schema, state->config->table); } else { if (state->config->readshape == 1 && (! state->config->geography) ) { stringbuffer_aprintf(sb, "SELECT DropGeometryColumn('','%s','%s');\n", state->config->table, state->geo_col); } stringbuffer_aprintf(sb, "DROP TABLE \"%s\";\n", state->config->table); } } /* Start of transaction if we are using one */ if (state->config->usetransaction) { stringbuffer_aprintf(sb, "BEGIN;\n"); } /* If not in 'append' mode create the spatial table */ if (state->config->opt != 'a') { /* * Create a table for inserting the shapes into with appropriate * columns and types */ if (state->config->schema) { stringbuffer_aprintf(sb, "CREATE TABLE \"%s\".\"%s\" (gid serial", state->config->schema, state->config->table); } else { stringbuffer_aprintf(sb, "CREATE TABLE \"%s\" (gid serial", state->config->table); } /* Generate the field types based upon the shapefile information */ for (j = 0; j < state->num_fields; j++) { stringbuffer_aprintf(sb, ",\n\"%s\" ", state->field_names[j]); /* First output the raw field type string */ stringbuffer_aprintf(sb, "%s", state->pgfieldtypes[j]); /* Some types do have typmods though... */ if (!strcmp("varchar", state->pgfieldtypes[j])) stringbuffer_aprintf(sb, "(%d)", state->widths[j]); if (!strcmp("numeric", state->pgfieldtypes[j])) { /* Doubles we just allow PostgreSQL to auto-detect the size */ if (state->types[j] != FTDouble) stringbuffer_aprintf(sb, "(%d,0)", state->widths[j]); } } /* Add the geography column directly to the table definition, we don't need to do an AddGeometryColumn() call. */ if (state->config->readshape == 1 && state->config->geography) { char *dimschar; if (state->pgdims == 4) dimschar = "ZM"; else dimschar = ""; if (state->to_srid != SRID_UNKNOWN && state->to_srid != 4326) { snprintf(state->message, SHPLOADERMSGLEN, _("Invalid SRID for geography type: %d"), state->to_srid); stringbuffer_destroy(sb); return SHPLOADERERR; } stringbuffer_aprintf(sb, ",\n\"%s\" geography(%s%s,%d)", state->geo_col, state->pgtype, dimschar, 4326); } stringbuffer_aprintf(sb, ")"); /* Tablespace is optional. */ if (state->config->tablespace != NULL) { stringbuffer_aprintf(sb, " TABLESPACE \"%s\"", state->config->tablespace); } stringbuffer_aprintf(sb, ";\n"); /* Create the primary key. This is done separately because the index for the PK needs * to be in the correct tablespace. */ /* TODO: Currently PostgreSQL does not allow specifying an index to use for a PK (so you get * a default one called table_pkey) and it does not provide a way to create a PK index * in a specific tablespace. So as a hacky solution we create the PK, then move the * index to the correct tablespace. Eventually this should be: * CREATE INDEX table_pkey on table(gid) TABLESPACE tblspc; * ALTER TABLE table ADD PRIMARY KEY (gid) USING INDEX table_pkey; * A patch has apparently been submitted to PostgreSQL to enable this syntax, see this thread: * http://archives.postgresql.org/pgsql-hackers/2011-01/msg01405.php */ stringbuffer_aprintf(sb, "ALTER TABLE "); /* Schema is optional, include if present. */ if (state->config->schema) { stringbuffer_aprintf(sb, "\"%s\".",state->config->schema); } stringbuffer_aprintf(sb, "\"%s\" ADD PRIMARY KEY (gid);\n", state->config->table); /* Tablespace is optional for the index. */ if (state->config->idxtablespace != NULL) { stringbuffer_aprintf(sb, "ALTER INDEX "); if (state->config->schema) { stringbuffer_aprintf(sb, "\"%s\".",state->config->schema); } /* WARNING: We're assuming the default "table_pkey" name for the primary * key index. PostgreSQL may use "table_pkey1" or similar in the * case of a name conflict, so you may need to edit the produced * SQL in this rare case. */ stringbuffer_aprintf(sb, "\"%s_pkey\" SET TABLESPACE \"%s\";\n", state->config->table, state->config->idxtablespace); } /* Create the geometry column with an addgeometry call */ if (state->config->readshape == 1 && (!state->config->geography)) { /* If they didn't specify a target SRID, see if they specified a source SRID. */ int srid = state->to_srid; if (state->config->schema) { stringbuffer_aprintf(sb, "SELECT AddGeometryColumn('%s','%s','%s','%d',", state->config->schema, state->config->table, state->geo_col, srid); } else { stringbuffer_aprintf(sb, "SELECT AddGeometryColumn('','%s','%s','%d',", state->config->table, state->geo_col, srid); } stringbuffer_aprintf(sb, "'%s',%d);\n", state->pgtype, state->pgdims); } } /* Copy the string buffer into a new string, destroying the string buffer */ ret = (char *)malloc(strlen((char *)stringbuffer_getstring(sb)) + 1); strcpy(ret, (char *)stringbuffer_getstring(sb)); stringbuffer_destroy(sb); *strheader = ret; return SHPLOADEROK; } /* Return an allocated string containing the copy statement for this state */ int ShpLoaderGetSQLCopyStatement(SHPLOADERSTATE *state, char **strheader) { char *copystr; /* Allocate the string for the COPY statement */ if (state->config->dump_format) { if (state->config->schema) { copystr = malloc(strlen(state->config->schema) + strlen(state->config->table) + strlen(state->col_names) + 40); sprintf(copystr, "COPY \"%s\".\"%s\" %s FROM stdin;\n", state->config->schema, state->config->table, state->col_names); } else { copystr = malloc(strlen(state->config->table) + strlen(state->col_names) + 40); sprintf(copystr, "COPY \"%s\" %s FROM stdin;\n", state->config->table, state->col_names); } *strheader = copystr; return SHPLOADEROK; } else { /* Flag an error as something has gone horribly wrong */ snprintf(state->message, SHPLOADERMSGLEN, _("Internal error: attempt to generate a COPY statement for data that hasn't been requested in COPY format")); return SHPLOADERERR; } } /* Return a count of the number of entities in this shapefile */ int ShpLoaderGetRecordCount(SHPLOADERSTATE *state) { return state->num_entities; } /* Return an allocated string representation of a specified record item */ int ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strrecord) { SHPObject *obj = NULL; stringbuffer_t *sb; stringbuffer_t *sbwarn; char val[MAXVALUELEN]; char *escval; char *geometry=NULL, *ret; char *utf8str; int res, i; int rv; /* Clear the stringbuffers */ sbwarn = stringbuffer_create(); stringbuffer_clear(sbwarn); sb = stringbuffer_create(); stringbuffer_clear(sb); /* If we are reading the DBF only and the record has been marked deleted, return deleted record status */ if (state->config->readshape == 0 && DBFIsRecordDeleted(state->hDBFHandle, item)) { *strrecord = NULL; return SHPLOADERRECDELETED; } /* If we are reading the shapefile, open the specified record */ if (state->config->readshape == 1) { obj = SHPReadObject(state->hSHPHandle, item); if (!obj) { snprintf(state->message, SHPLOADERMSGLEN, _("Error reading shape object %d"), item); return SHPLOADERERR; } /* If we are set to skip NULLs, return a NULL record status */ if (state->config->null_policy == POLICY_NULL_SKIP && obj->nVertices == 0 ) { SHPDestroyObject(obj); *strrecord = NULL; return SHPLOADERRECISNULL; } } /* If not in dump format, generate the INSERT string */ if (!state->config->dump_format) { if (state->config->schema) { stringbuffer_aprintf(sb, "INSERT INTO \"%s\".\"%s\" %s VALUES (", state->config->schema, state->config->table, state->col_names); } else { stringbuffer_aprintf(sb, "INSERT INTO \"%s\" %s VALUES (", state->config->table, state->col_names); } } /* Read all of the attributes from the DBF file for this item */ for (i = 0; i < DBFGetFieldCount(state->hDBFHandle); i++) { /* Special case for NULL attributes */ if (DBFIsAttributeNULL(state->hDBFHandle, item, i)) { if (state->config->dump_format) stringbuffer_aprintf(sb, "\\N"); else stringbuffer_aprintf(sb, "NULL"); } else { /* Attribute NOT NULL */ switch (state->types[i]) { case FTInteger: case FTDouble: rv = snprintf(val, MAXVALUELEN, "%s", DBFReadStringAttribute(state->hDBFHandle, item, i)); if (rv >= MAXVALUELEN || rv == -1) { stringbuffer_aprintf(sbwarn, "Warning: field %d name truncated\n", i); val[MAXVALUELEN - 1] = '\0'; } /* If the value is an empty string, change to 0 */ if (val[0] == '\0') { val[0] = '0'; val[1] = '\0'; } /* If the value ends with just ".", remove the dot */ if (val[strlen(val) - 1] == '.') val[strlen(val) - 1] = '\0'; break; case FTString: case FTLogical: case FTDate: rv = snprintf(val, MAXVALUELEN, "%s", DBFReadStringAttribute(state->hDBFHandle, item, i)); if (rv >= MAXVALUELEN || rv == -1) { stringbuffer_aprintf(sbwarn, "Warning: field %d name truncated\n", i); val[MAXVALUELEN - 1] = '\0'; } break; default: snprintf(state->message, SHPLOADERMSGLEN, _("Error: field %d has invalid or unknown field type (%d)"), i, state->types[i]); SHPDestroyObject(obj); stringbuffer_destroy(sbwarn); stringbuffer_destroy(sb); return SHPLOADERERR; } if (state->config->encoding) { char *encoding_msg = _("Try \"LATIN1\" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html."); rv = utf8(state->config->encoding, val, &utf8str); if (rv != UTF8_GOOD_RESULT) { if ( rv == UTF8_BAD_RESULT ) snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert data value \"%s\" to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), utf8str, strerror(errno), state->config->encoding, encoding_msg); else if ( rv == UTF8_NO_RESULT ) snprintf(state->message, SHPLOADERMSGLEN, _("Unable to convert data value to UTF-8 (iconv reports \"%s\"). Current encoding is \"%s\". %s"), strerror(errno), state->config->encoding, encoding_msg); else snprintf(state->message, SHPLOADERMSGLEN, _("Unexpected return value from utf8()")); if ( rv == UTF8_BAD_RESULT ) free(utf8str); return SHPLOADERERR; } strncpy(val, utf8str, MAXVALUELEN); free(utf8str); } /* Escape attribute correctly according to dump format */ if (state->config->dump_format) { escval = escape_copy_string(val); stringbuffer_aprintf(sb, "%s", escval); } else { escval = escape_insert_string(val); stringbuffer_aprintf(sb, "'%s'", escval); } /* Free the escaped version if required */ if (val != escval) free(escval); } /* Only put in delimeter if not last field or a shape will follow */ if (state->config->readshape == 1 || i < DBFGetFieldCount(state->hDBFHandle) - 1) { if (state->config->dump_format) stringbuffer_aprintf(sb, "\t"); else stringbuffer_aprintf(sb, ","); } /* End of DBF attribute loop */ } /* Add the shape attribute if we are reading it */ if (state->config->readshape == 1) { /* Force the locale to C */ char *oldlocale = setlocale(LC_NUMERIC, "C"); /* Handle the case of a NULL shape */ if (obj->nVertices == 0) { if (state->config->dump_format) stringbuffer_aprintf(sb, "\\N"); else stringbuffer_aprintf(sb, "NULL"); } else { /* Handle all other shape attributes */ switch (obj->nSHPType) { case SHPT_POLYGON: case SHPT_POLYGONM: case SHPT_POLYGONZ: res = GeneratePolygonGeometry(state, obj, &geometry); break; case SHPT_POINT: case SHPT_POINTM: case SHPT_POINTZ: res = GeneratePointGeometry(state, obj, &geometry, 0); break; case SHPT_MULTIPOINT: case SHPT_MULTIPOINTM: case SHPT_MULTIPOINTZ: /* Force it to multi unless using -S */ res = GeneratePointGeometry(state, obj, &geometry, state->config->simple_geometries ? 0 : 1); break; case SHPT_ARC: case SHPT_ARCM: case SHPT_ARCZ: res = GenerateLineStringGeometry(state, obj, &geometry); break; default: snprintf(state->message, SHPLOADERMSGLEN, _("Shape type is not supported, type id = %d"), obj->nSHPType); SHPDestroyObject(obj); stringbuffer_destroy(sbwarn); stringbuffer_destroy(sb); return SHPLOADERERR; } /* The default returns out of the function, so res will always have been set. */ if (res != SHPLOADEROK) { /* Error message has already been set */ SHPDestroyObject(obj); stringbuffer_destroy(sbwarn); stringbuffer_destroy(sb); return SHPLOADERERR; } /* Now generate the geometry string according to the current configuration */ if (!state->config->dump_format) { if (state->to_srid != state->from_srid) { stringbuffer_aprintf(sb, "ST_Transform("); } stringbuffer_aprintf(sb, "'"); } stringbuffer_aprintf(sb, "%s", geometry); if (!state->config->dump_format) { stringbuffer_aprintf(sb, "'"); /* Close the ST_Transform if reprojecting. */ if (state->to_srid != state->from_srid) { /* We need to add an explicit cast to geography/geometry to ensure that PostgreSQL doesn't get confused with the ST_Transform() raster function. */ if (state->config->geography) stringbuffer_aprintf(sb, "::geometry, %d)::geography", state->to_srid); else stringbuffer_aprintf(sb, "::geometry, %d)", state->to_srid); } } free(geometry); } /* Tidy up everything */ SHPDestroyObject(obj); setlocale(LC_NUMERIC, oldlocale); } /* Close the line correctly for dump/insert format */ if (!state->config->dump_format) stringbuffer_aprintf(sb, ");"); /* Copy the string buffer into a new string, destroying the string buffer */ ret = (char *)malloc(strlen((char *)stringbuffer_getstring(sb)) + 1); strcpy(ret, (char *)stringbuffer_getstring(sb)); stringbuffer_destroy(sb); *strrecord = ret; /* If any warnings occurred, set the returned message string and warning status */ if (strlen((char *)stringbuffer_getstring(sbwarn)) > 0) { snprintf(state->message, SHPLOADERMSGLEN, "%s", stringbuffer_getstring(sbwarn)); stringbuffer_destroy(sbwarn); return SHPLOADERWARN; } else { /* Everything went okay */ stringbuffer_destroy(sbwarn); return SHPLOADEROK; } } /* Return a pointer to an allocated string containing the header for the specified loader state */ int ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter) { stringbuffer_t *sb; char *ret; /* Create the stringbuffer containing the header; we use this API as it's easier for handling string resizing during append */ sb = stringbuffer_create(); stringbuffer_clear(sb); /* Create gist index if specified and not in "prepare" mode */ if (state->config->readshape && state->config->createindex) { stringbuffer_aprintf(sb, "CREATE INDEX ON "); /* Schema is optional, include if present. */ if (state->config->schema) { stringbuffer_aprintf(sb, "\"%s\".",state->config->schema); } stringbuffer_aprintf(sb, "\"%s\" USING GIST (\"%s\")", state->config->table, state->geo_col); /* Tablespace is also optional. */ if (state->config->idxtablespace != NULL) { stringbuffer_aprintf(sb, " TABLESPACE \"%s\"", state->config->idxtablespace); } stringbuffer_aprintf(sb, ";\n"); } /* End the transaction if there is one. */ if (state->config->usetransaction) { stringbuffer_aprintf(sb, "COMMIT;\n"); } /* Always ANALYZE the resulting table, for better stats */ stringbuffer_aprintf(sb, "ANALYZE "); if (state->config->schema) { stringbuffer_aprintf(sb, "\"%s\".", state->config->schema); } stringbuffer_aprintf(sb, "\"%s\";\n", state->config->table); /* Copy the string buffer into a new string, destroying the string buffer */ ret = (char *)malloc(strlen((char *)stringbuffer_getstring(sb)) + 1); strcpy(ret, (char *)stringbuffer_getstring(sb)); stringbuffer_destroy(sb); *strfooter = ret; return SHPLOADEROK; } void ShpLoaderDestroy(SHPLOADERSTATE *state) { /* Destroy a state object created with ShpLoaderOpenShape */ int i; if (state != NULL) { if (state->hSHPHandle) SHPClose(state->hSHPHandle); if (state->hDBFHandle) DBFClose(state->hDBFHandle); if (state->field_names) { for (i = 0; i < state->num_fields; i++) free(state->field_names[i]); free(state->field_names); } if (state->pgfieldtypes) { for (i = 0; i < state->num_fields; i++) free(state->pgfieldtypes[i]); free(state->pgfieldtypes); } if (state->types) free(state->types); if (state->widths) free(state->widths); if (state->precisions) free(state->precisions); if (state->col_names) free(state->col_names); /* Free any column map fieldnames if specified */ colmap_clean(&state->column_map); /* Free the state itself */ free(state); } }
26.196747
219
0.64473
a15c576cbbdba74df9d1ecadfc35e18298e36ca7
2,229
c
C
qmk_firmware/keyboards/montex/keymaps/default/keymap.c
DanTupi/personal_setup
911b4951e4d8b78d6ea8ca335229e2e970fda871
[ "MIT" ]
null
null
null
qmk_firmware/keyboards/montex/keymaps/default/keymap.c
DanTupi/personal_setup
911b4951e4d8b78d6ea8ca335229e2e970fda871
[ "MIT" ]
null
null
null
qmk_firmware/keyboards/montex/keymaps/default/keymap.c
DanTupi/personal_setup
911b4951e4d8b78d6ea8ca335229e2e970fda871
[ "MIT" ]
null
null
null
/* Copyright 2021 NachoxMacho * * 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, see &lt;http://www.gnu.org/licenses/&gt;. */ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* * ┌───┌───┬───┬───┬───┐ * │ ` │Esc│Tab│MO1│Bsp│ * ├───┼───┼───┼───┼───┤ * │ , │Num│ / │ * │ - │ * ├───┼───┼───┼───┼───┤ * │Gui│ 7 │ 8 │ 9 │ │ * ├───┼───┼───┼───┤ + │ * │Alt│ 4 │ 5 │ 6 │ │ * ├───┼───┼───┼───┼───┤ * │Shi│ 1 │ 2 │ 3 │ │ * ├───┼───┴───┼───┤Ent│ * │Ctr│ 0 │ . │ │ * └───┴───────┴───┴───┘ */ [0] = LAYOUT_numpad_6x5( KC_GRAVE, KC_ESC, KC_TAB, MO(1), KC_BSPC, KC_COMMA, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, KC_LGUI, KC_P7, KC_P8, KC_P9, KC_LALT, KC_P4, KC_P5, KC_P6, KC_PPLS, KC_LSHIFT, KC_P1, KC_P2, KC_P3, KC_LCTRL, KC_P0, KC_PDOT, KC_PENT ), /* * ┌───┌───┐───┬───┬───┐ * │Rst│ ` │Tab│MO1│Bsp│ * ├───┼───┘───┼───┼───┤ * │ , │Num│ / │ * │ - │ * ├───┼───┼───┼───┼───┤ * │Gui│Hom│ ↑ │PgU│ │ * ├───┼───┼───┼───┤ + │ * │Alt│ ← │ │ → │ │ * ├───┼───┼───┼───┤───┤ * │Shi│End│ ↓ │PgD│ │ * ├───┼───┴───┼───┤Ent│ * │Ctr│Insert │Del│ │ * └───┴───────┴───┘───┘ */ [1] = LAYOUT_numpad_6x5( RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_UP, KC_PGUP, _______, KC_LEFT, XXXXXXX, KC_RGHT, _______, _______, KC_END, KC_DOWN, KC_PGDN, _______, KC_INS, KC_DEL, _______ ) };
32.779412
77
0.475998
bdee898e3f15e07c5df61e29436f942ef7ca64c1
72
c
C
Rush_00/ex00/ft_putchar.c
Erengun/Piscine-C
e78e3f87d7dd744e54bdcdbe5b94275fa541d7f7
[ "MIT" ]
4
2021-09-23T09:58:12.000Z
2021-11-08T15:13:49.000Z
Rush_00/ex00/ft_putchar.c
Erengun/Piscine-C
e78e3f87d7dd744e54bdcdbe5b94275fa541d7f7
[ "MIT" ]
null
null
null
Rush_00/ex00/ft_putchar.c
Erengun/Piscine-C
e78e3f87d7dd744e54bdcdbe5b94275fa541d7f7
[ "MIT" ]
null
null
null
#include <unistd.h> void ft_putchar(char *str) { write (1, str, 1); }
10.285714
26
0.625
bdf57b29b2f5ed40757551b5de74457824fc0b74
625
h
C
X1/Cheat/Include/Winheaders.h
Galenika/Xone-Cheat-90--
44e79f03128194de17a900def38735d29bc85572
[ "Apache-2.0" ]
12
2019-03-30T18:57:45.000Z
2021-04-18T13:44:52.000Z
X1/Cheat/Include/Winheaders.h
CSGOLeaks/Xone-Cheat-90--
44e79f03128194de17a900def38735d29bc85572
[ "Apache-2.0" ]
null
null
null
X1/Cheat/Include/Winheaders.h
CSGOLeaks/Xone-Cheat-90--
44e79f03128194de17a900def38735d29bc85572
[ "Apache-2.0" ]
16
2019-03-30T18:57:55.000Z
2021-12-19T22:44:55.000Z
#pragma once #include <Windows.h> #include <iostream> #include <memory> #include <fstream> #include <string> #include <map> #include <vector> #include <TlHelp32.h> #include <WinInet.h> #include <ctime> #include <chrono> #include <windows.h> #include <mmsystem.h> #include <wingdi.h> #include <locale> #include <stdio.h> #include <io.h> #include <math.h> #include <functional> #include <d3d9.h> #include <d3dx9.h> #pragma comment(lib, "Wininet.lib") #pragma comment(lib, "d3d9.lib") #pragma comment(lib, "d3dx9.lib") #pragma comment(lib, "winmm.lib") using std::vector; using std::map; using std::pair; using std::string;
17.857143
35
0.7072
0801e3c22a32dac70ebeadff162fe83ca024eaa2
521
h
C
System/Library/PrivateFrameworks/HomeRecommendationEngine.framework/HFHomeContainedObject.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/HomeRecommendationEngine.framework/HFHomeContainedObject.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/HomeRecommendationEngine.framework/HFHomeContainedObject.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:54:35 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/HomeRecommendationEngine.framework/HomeRecommendationEngine * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class HMHome; @protocol HFHomeContainedObject <HFHomeKitObject> @property (nonatomic,__weak,readonly) HMHome * home; @required -(HMHome *)home; @end
27.421053
109
0.779271
bd77ecf4bf6d5af1829c3e5b393415520352cfcc
1,443
h
C
tensorflow/compiler/mlir/tosa/tosa_passpipes.h
deerluffy/tensorflow
73e9dc4e1eae1589c8ea4a7cf1e8398c1eff3ab1
[ "Apache-2.0" ]
2
2020-12-16T12:49:48.000Z
2021-03-26T18:25:47.000Z
tensorflow/compiler/mlir/tosa/tosa_passpipes.h
Foroozani/tensorflow
dc37ecf08b2909c8d2b4d7f8c95ef3a3091d4578
[ "Apache-2.0" ]
null
null
null
tensorflow/compiler/mlir/tosa/tosa_passpipes.h
Foroozani/tensorflow
dc37ecf08b2909c8d2b4d7f8c95ef3a3091d4578
[ "Apache-2.0" ]
1
2021-03-28T10:02:51.000Z
2021-03-28T10:02:51.000Z
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_COMPILER_MLIR_TOSA_TOSA_PASSES_H #define TENSORFLOW_COMPILER_MLIR_TOSA_TOSA_PASSES_H #include "mlir/Dialect/Tosa/Transforms/Passes.h" #include "mlir/IR/Module.h" #include "mlir/Pass/PassManager.h" #include "llvm/ADT/Optional.h" #include "tensorflow/compiler/mlir/tosa/transforms/passes.h" namespace mlir { namespace tosa { void addPreOptMlirPasses(mlir::OpPassManager& pm); void addPostOptMlirPasses(mlir::OpPassManager& pm); void createTFtoTOSALegalizationPipeline( OpPassManager& pm, const TOSALegalizationPipelineOptions& opts); void createTFLtoTOSALegalizationPipeline( OpPassManager& pm, const TOSALegalizationPipelineOptions& opts); } // namespace tosa } // namespace mlir #endif // TENSORFLOW_COMPILER_MLIR_TOSA_TOSA_PASSES_H
32.795455
80
0.758836
d3d4608e550eb3adf6fc86ac1d442d18e9cc5344
3,033
h
C
pheroes/MapEditor/Commands.h
TripleMOMO/pocketheroes
6a6f0726c8ea590592290ac53c38e653cf7f966c
[ "Apache-2.0" ]
3
2015-08-08T09:10:02.000Z
2016-03-21T08:48:19.000Z
pheroes/MapEditor/Commands.h
TripleMOMO/pocketheroes
6a6f0726c8ea590592290ac53c38e653cf7f966c
[ "Apache-2.0" ]
null
null
null
pheroes/MapEditor/Commands.h
TripleMOMO/pocketheroes
6a6f0726c8ea590592290ac53c38e653cf7f966c
[ "Apache-2.0" ]
1
2015-08-21T23:32:49.000Z
2015-08-21T23:32:49.000Z
/* * This file is a part of Pocket Heroes Game project * http://www.pocketheroes.net * https://code.google.com/p/pocketheroes/ * * Copyright 2004-2010 by Robert Tarasov and Anton Stuk (iO UPG) * * 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 HMM_EDITOR_COMMAND_H_ #define HMM_EDITOR_COMMAND_H_ #include "ScopePtr.h" class iMapHandler; class Command : public iIListNode { public: virtual ~Command() {} virtual void Commit( iMapHandler* map ) =0; virtual void Rollback( iMapHandler* map ) =0; virtual const TCHAR* Name() const; }; typedef iIList<Command> CommandList; typedef ScopedPtr<Command> CommandPtr; // class CompositeCommand : public Command { public: CompositeCommand( const TCHAR* name = 0 ); ~CompositeCommand(); virtual void Commit( iMapHandler* map ); virtual void Rollback( iMapHandler* map ); void Push( Command* ); Command* Pop(); virtual const TCHAR* Name() const; private: CommandList cmds_; iStringT name_; }; typedef ScopedPtr<CompositeCommand> CompositeCommandPtr; // class AddObjectCommand : public Command { public: AddObjectCommand( iBaseNode* obj, iPoint pos, PLAYER_ID pid = PID_NEUTRAL ); virtual void Commit( iMapHandler* map ); virtual void Rollback( iMapHandler* map ); virtual const TCHAR* Name() const; private: iBaseNode* obj_; iPoint pos_; PLAYER_ID pid_; }; class EraseAllAtLocation : public Command { public: virtual void Commit( iMapHandler* map ); virtual void Rollback( iMapHandler* map ); virtual const TCHAR* Name() const; }; class CreateEntityAtLocation : public Command { }; class DrawTileAtLocation : public Command { public: DrawTileAtLocation( iPoint pt, SURF_TYPE surf ); virtual void Commit( iMapHandler* map ); virtual void Rollback( iMapHandler* map ); virtual const TCHAR* Name() const; private: iPoint pos_; SURF_TYPE new_; SURF_TYPE old_; }; // class CommandManager { public: CommandManager(); ~CommandManager(); bool CanUndo() const; bool CanRedo() const; void ClearRedo(); void ClearAll(); void CommitCommand( Command* cmd, iMapHandler* ); bool Undo( iMapHandler* ); bool Redo( iMapHandler* ); void StartGroup( const TCHAR* name ); void EndGroup(); private: void LimitStacks(); void FlushGroup(); CompositeCommandPtr group_; CommandList undoList_; CommandList redoList_; }; #endif //#define HMM_EDITOR_COMMAND_H_
20.917241
78
0.697329
2342e14f1b752ffaa13e8563ffe086a140e59b71
1,594
c
C
indetermined_sum.c
elrui/for-fun-c
395948bafd6db9668fbe26cac4490df2802bd4b3
[ "MIT" ]
null
null
null
indetermined_sum.c
elrui/for-fun-c
395948bafd6db9668fbe26cac4490df2802bd4b3
[ "MIT" ]
null
null
null
indetermined_sum.c
elrui/for-fun-c
395948bafd6db9668fbe26cac4490df2802bd4b3
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> void receive(int number1, int number2) { /* * Creates an integer variable and assigns the sum of both parameters * Does not return anything */ int c = number1 + number2; } int result() { /* * Takes no parameter, declares an integer variable without initialization * Returns that variable (indetermined) */ int x; return x; } /* Main program expects up to two integers as inpunts, from command line * If any parameter is omited, default value is 0 * If more than two parameters are given, only the first two will be taken, the rest ignored * If any parameter is not integer, the behavior is not defined. The program is expected to fail */ int main (int argc, char *argv[]) { int first = 0; // Default for first variable is 0 int second = 0; // Default for second variable is 0 /* * The following block only parses the input and assigns the values to variables * If second variable is empty, default value is kept. If both are empty, both defaults are kept * Some non-numericals may be converted to zero, dependending on the implementation of strtol */ if (argc >= 3) { second = (int)strtol(argv[2],NULL,10); first = (int)strtol(argv[1],NULL,10); } else if (argc==2) { first = (int)strtol(argv[1],NULL,10); } // Now we call the two functions we defined above. Result 'should' be indetermined... or should it? receive(first, second); int surprise = result(); printf ("Sum is: %d \n", surprise); printf ("Do you know what just happened? And why? \n\n"); return 0; }
26.131148
103
0.680678
0386562c22fdc569b649ea01b2abd3265465a3ec
1,810
h
C
LineTrace/LineTrace_def.h
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
106
2019-05-15T13:16:30.000Z
2022-03-29T11:18:38.000Z
LineTrace/LineTrace_def.h
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
2
2020-10-24T07:12:52.000Z
2022-03-05T10:25:51.000Z
LineTrace/LineTrace_def.h
bryful/F-s-PluginsProjects
5673cc12105120bb4c3fd6f7cd650b000f5a416a
[ "MIT" ]
20
2019-07-10T06:08:14.000Z
2022-03-13T02:35:12.000Z
#pragma once #ifndef COLOR_DEF_H #define COLOR_DEF_H #define COLOR_DEF_SIZE 16 A_u_char pr_colorDef[COLOR_DEF_SIZE][6]={ { //00 PF_MAX_CHAN8,//R1 0,//G1 0,//B1 PF_MAX_CHAN8,//R1 0,//G1 0//B1 }, { //01 0,//R1 PF_MAX_CHAN8,//G1 0,//B1 0,//R1 PF_MAX_CHAN8,//G1 0//B1 }, { //02 0,//R1 0,//G1 PF_MAX_CHAN8,//B1 0,//R1 0,//G1 PF_MAX_CHAN8//B1 }, { //03 PF_MAX_CHAN8,//R1 PF_MAX_CHAN8,//G1 0,//B1 PF_MAX_CHAN8,//R1 PF_MAX_CHAN8,//G1 0//B1 }, { //04 PF_MAX_CHAN8,//R1 0,//G1 PF_MAX_CHAN8,//B1 PF_MAX_CHAN8,//R1 0,//G1 PF_MAX_CHAN8//B1 }, { //05 0,//R1 PF_MAX_CHAN8,//G1 PF_MAX_CHAN8,//B1 0,//R1 PF_MAX_CHAN8,//G1 PF_MAX_CHAN8//B1 }, { //06 PF_MAX_CHAN8,//R1 PF_MAX_CHAN8,//G1 PF_MAX_CHAN8,//B1 PF_MAX_CHAN8,//R1 PF_MAX_CHAN8,//G1 PF_MAX_CHAN8//B1 }, { //07 0,//R1 0,//G1 0,//B1 0,//R1 0,//G1 0//B1 }, { //08 PF_HALF_CHAN8,//R1 0,//G1 0,//B1 PF_HALF_CHAN8,//R1 0,//G1 0//B1 }, { //09 0,//R1 PF_HALF_CHAN8,//G1 0,//B1 0,//R1 PF_HALF_CHAN8,//G1 0//B1 }, { //10 0,//R1 0,//G1 PF_HALF_CHAN8,//B1 0,//R1 0,//G1 PF_HALF_CHAN8//B1 }, { //11 PF_HALF_CHAN8,//R1 PF_HALF_CHAN8,//G1 0,//B1 PF_HALF_CHAN8,//R1 PF_HALF_CHAN8,//G1 0//B1 }, { //12 PF_HALF_CHAN8,//R1 0,//G1 PF_HALF_CHAN8,//B1 PF_HALF_CHAN8,//R1 0,//G1 PF_HALF_CHAN8//B1 }, { //13 0,//R1 PF_HALF_CHAN8,//G1 PF_HALF_CHAN8,//B1 0,//R1 PF_HALF_CHAN8,//G1 PF_HALF_CHAN8//B1 }, { //14 PF_HALF_CHAN8,//R1 PF_HALF_CHAN8,//G1 PF_HALF_CHAN8,//B1 PF_HALF_CHAN8,//R1 PF_HALF_CHAN8,//G1 PF_HALF_CHAN8//B1 }, { //15 PF_HALF_CHAN8/2,//R1 PF_HALF_CHAN8/2,//G1 PF_HALF_CHAN8/2,//B1 PF_HALF_CHAN8/2,//R1 PF_HALF_CHAN8/2,//G1 PF_HALF_CHAN8/2//B1 }, }; #endif
13.115942
41
0.582873
6c5aebef028cb645c231d54346f26e0f570bd054
629
h
C
Source/LudumDare49/Public/Pickups/PickupArmor.h
TrickyFatCat/LudumDare49
afb0063f557e0973a0c38a1b84a14c3321891978
[ "MIT" ]
null
null
null
Source/LudumDare49/Public/Pickups/PickupArmor.h
TrickyFatCat/LudumDare49
afb0063f557e0973a0c38a1b84a14c3321891978
[ "MIT" ]
null
null
null
Source/LudumDare49/Public/Pickups/PickupArmor.h
TrickyFatCat/LudumDare49
afb0063f557e0973a0c38a1b84a14c3321891978
[ "MIT" ]
1
2021-10-07T21:39:29.000Z
2021-10-07T21:39:29.000Z
// Made by Title Goose Team during LudumDare 49. All rights reserved. #pragma once #include "CoreMinimal.h" #include "Actors/PickupBase.h" #include "PickupArmor.generated.h" /** * */ UCLASS() class LUDUMDARE49_API APickupArmor : public APickupBase { GENERATED_BODY() protected: virtual bool ActivatePickup_Implementation(AActor* TargetActor) override; private: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Pickup", meta=(AllowPrivateAccess="true")) int32 ArmorAmount = 50; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Pickup", meta=(AllowPrivateAccess="true")) bool bClampToMax = true; };
23.296296
100
0.772655
8c0ff7f61f966002d925314aad762f12183915de
789
h
C
CS312/LA-12/BinarySearchTree.h
jawaff/CollegeCS
ab7d24bd78719842f8790cc0e6c06dd1b327e416
[ "Apache-2.0" ]
null
null
null
CS312/LA-12/BinarySearchTree.h
jawaff/CollegeCS
ab7d24bd78719842f8790cc0e6c06dd1b327e416
[ "Apache-2.0" ]
null
null
null
CS312/LA-12/BinarySearchTree.h
jawaff/CollegeCS
ab7d24bd78719842f8790cc0e6c06dd1b327e416
[ "Apache-2.0" ]
null
null
null
#ifndef BINARY_SEARCH_TREE #define BINARY_SEARCH_TREE #include <string> #include "BinarySearchTreeInterface.h" #include "BinaryNode.h" class BinarySearchTree : BinarySearchTreeInterface { private: BinaryNode* rootPtr; void add(const unsigned int item, BinaryNode* subtree); bool remove(const unsigned int item, BinaryNode* subtree); std::string stdHelper() const; public: BinarySearchTree(); ~BinarySearchTree(); void clear(BinaryNode* subtree); bool isEmpty() const; bool contains(const unsigned int item) const; void add(const unsigned int item); bool remove(const unsigned int item); std::string str() const; std::string inorderTraverse() const; std::string postOrderTraverse() const; std::string preorderTraverse() const; }; #endif
21.324324
60
0.737643
1498adc0390686398cef44ef094478a22ef06c6f
2,937
h
C
meshhash2.h
phantomcraft/MeshHash2
2f64a190e907fdaf0b78bd6fd212f055b3004fc7
[ "Unlicense" ]
1
2021-12-29T02:26:28.000Z
2021-12-29T02:26:28.000Z
meshhash2.h
phantomcraft/MeshHash2
2f64a190e907fdaf0b78bd6fd212f055b3004fc7
[ "Unlicense" ]
null
null
null
meshhash2.h
phantomcraft/MeshHash2
2f64a190e907fdaf0b78bd6fd212f055b3004fc7
[ "Unlicense" ]
null
null
null
/* Usage as * * Hash: Init, Update*, Final * or only Hash * * Hash with key: Init2, Update*, Final * or only Hash2 * * Sponge: InitSponge, Update*, SqueezeNBytes*, Deinit * * Sponge with key: InitSponge2, Update*, SqueezeNBytes*, Deinit * * PRF / HMAC: same as Hash with key * * PRG / Key derivation: same as Sponge with key * * For testing: Init3, Update*, SqueezeNBytes*, Deinit * * the "*" means: Call as often as needed. */ #define MIN_NUMBER_OF_PIPES 4 /* should be >= 4 */ #define MAX_NUMBER_OF_PIPES 256 /* must be <= 256 */ #define NUMBER_OF_EXTRA_PIPES 1 /* for extra security, can be even negative, but should not be to large, should only be changed if flaws in design are detected, * can also be an expression depending on number_of_pipes */ #define COUNTER_LENGTH 4 /* must be of type int, positive, and <= MIN_NUMBER_OF_PIPES */ typedef unsigned char BitSequence; typedef BitSequence ByteSequence; /* for the given key */ typedef unsigned long long DataLength; /* should be a typical 64-bit value (long long) */ typedef unsigned long long Word; /* 64-bit word (or longer) */ typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHBITLEN = 2, BAD_KEY_LENGTH = 3, MEMORY_ALLOCATION_FAILED = 4 } HashReturn; typedef struct { int hashbitlen, /* length of hash value in bits */ number_of_pipes, key_length, /* length in words */ block_round_counter, /* actual round in block */ key_counter, /* actual offset in key */ data_counter, /* counter for buffering data */ squeezing; /* indicating if the whole message is processed and the computing of the hash value has started */ Word *pipe, *key, *feedback[2], data_buffer, /* buffer if message is not given whole words */ bit_counter[COUNTER_LENGTH], /* counter for message bits */ block_counter[COUNTER_LENGTH]; /* counter for processed blocks */ } hashState; HashReturn Init3(hashState *state, int hashbitlen, int number_of_pipes, int keybytelen, ByteSequence *key); HashReturn Init2(hashState *state, int hashbitlen, int keybytelen, ByteSequence *key); HashReturn Init(hashState *state, int hashbitlen); HashReturn InitSponge2(hashState *state, int number_of_pipes, int keybytelen, ByteSequence *key); HashReturn InitSponge(hashState *state, int number_of_pipes); HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen); HashReturn SqueezeNBytes(hashState *state, BitSequence *hashval, int rounds); HashReturn Final(hashState *state, BitSequence *hashval); void Deinit(hashState *state); HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); HashReturn Hash2(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval, int keybytelen, ByteSequence *key); int ComputeNumberOfPipes(int hashbitlen); /* computes number of pipes needed for given hash length or key length in bits */
32.274725
138
0.734082
9f18512b56388056f3707ec3eb5065dbf57959a0
7,968
c
C
test/hashmap/hashmap.c
mulle-concurrent/mulle-concurrent
48fe75e1640af5a467d7a52ae9bb3f7acc6afa60
[ "BSD-3-Clause" ]
21
2019-03-06T10:10:03.000Z
2022-03-27T01:25:09.000Z
test/hashmap/hashmap.c
mulle-concurrent/mulle-concurrent
48fe75e1640af5a467d7a52ae9bb3f7acc6afa60
[ "BSD-3-Clause" ]
1
2018-09-13T22:10:45.000Z
2018-09-13T22:10:45.000Z
test/hashmap/hashmap.c
mulle-concurrent/mulle-concurrent
48fe75e1640af5a467d7a52ae9bb3f7acc6afa60
[ "BSD-3-Clause" ]
5
2019-02-12T10:12:20.000Z
2021-12-28T06:16:26.000Z
// // main.m // mulle_concurrent_hashmap // // Created by Nat! on 04.03.16. // Copyright © 2016 Nat! for Mulle kybernetiK. // Copyright © 2016 Codeon GmbH. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // Neither the name of Mulle kybernetiK nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #include <mulle-concurrent/mulle-concurrent.h> #include <mulle-testallocator/mulle-testallocator.h> #include <mulle-allocator/mulle-allocator.h> #include <assert.h> #include <errno.h> #define FOREVER 0 static void insert_something( struct mulle_concurrent_hashmap *map) { intptr_t hash; void *value; int rval; hash = rand() << 1; // no uneven ids value = (void *) (hash * 10); rval = _mulle_concurrent_hashmap_insert( map, hash, value); switch( rval) { default : perror( "mulle_concurrent_hashmap_insert"); abort(); case 0 : case EEXIST : return; } } static void delete_something( struct mulle_concurrent_hashmap *map) { intptr_t hash; void *value; int rval; hash = rand() << 1; // no uneven ids value = (void *) (hash * 10); rval = _mulle_concurrent_hashmap_remove( map, hash, value); if( rval == ENOMEM) { perror( "mulle_concurrent_hashmap_remove"); abort(); } } static void lookup_something( struct mulle_concurrent_hashmap *map) { intptr_t hash; void *value; hash = rand(); value = _mulle_concurrent_hashmap_lookup( map, hash); if( ! value) return; assert( ! (hash & 0x1)); assert( value == (void *) (hash * 10)); } static void enumerate_something( struct mulle_concurrent_hashmap *map) { struct mulle_concurrent_hashmapenumerator rover; intptr_t hash; void *value; int rval; retry: rover = mulle_concurrent_hashmap_enumerate( map); while( (rval = _mulle_concurrent_hashmapenumerator_next( &rover, &hash, &value)) == 1) { assert( ! (hash & 0x1)); if( value != (void *) (hash * 10)) { fprintf( stderr, "expected %p, got %p\n", (void *) (hash * 10), value); exit( 1); } } mulle_concurrent_hashmapenumerator_done( &rover); if( rval == EBUSY) goto retry; } // // run until the mask is >= 1 mio entries // static void tester( struct mulle_concurrent_hashmap *map) { int todo; mulle_aba_register(); while( mulle_concurrent_hashmap_get_size( map) < 1024 * 1024) { todo = rand() % 1000; if( todo == 1) // 1 % chance of enumerate { enumerate_something( map); continue; } if( todo < 100) // 10 % chance of delete { delete_something( map); continue; } if( todo < 200) // 20 % chance of insert { insert_something( map); continue; } lookup_something( map); } mulle_aba_unregister(); } static void multi_threaded_test( unsigned int n_threads) { struct mulle_concurrent_hashmap map; mulle_thread_t threads[ 32]; unsigned int i; assert( n_threads <= 32); mulle_aba_init( &mulle_testallocator); mulle_allocator_set_aba( &mulle_testallocator, mulle_aba_get_global(), (mulle_allocator_aba_t) _mulle_aba_free); mulle_aba_register(); mulle_concurrent_hashmap_init( &map, 0, &mulle_testallocator); { for( i = 0; i < n_threads; i++) { if( mulle_thread_create( (void *) tester, &map, &threads[ i])) { perror( "mulle_thread_create"); abort(); } } for( i = 0; i < n_threads; i++) mulle_thread_join( threads[ i]); } mulle_concurrent_hashmap_done( &map); mulle_aba_unregister(); mulle_allocator_set_aba( &mulle_testallocator, NULL, NULL); mulle_aba_done(); } static void single_threaded_test( void) { intptr_t hash; struct mulle_concurrent_hashmap map; struct mulle_concurrent_hashmapenumerator rover; unsigned int i; void *value; mulle_aba_init( &mulle_testallocator); mulle_allocator_set_aba( &mulle_testallocator, mulle_aba_get_global(), (mulle_allocator_aba_t) _mulle_aba_free); mulle_aba_register(); mulle_concurrent_hashmap_init( &map, 0, &mulle_testallocator); { for( i = 1; i <= 100; i++) { hash = i; value = (void *) (uintptr_t) (i * 10); if( mulle_concurrent_hashmap_insert( &map, hash, value)) { perror( "mulle_concurrent_hashmap_insert"); abort(); } assert( mulle_concurrent_hashmap_lookup( &map, i) == (void *) (i * 10)); } for( i = 1; i <= 100; i++) assert( mulle_concurrent_hashmap_lookup( &map, i) == (void *) (i * 10)); assert( ! mulle_concurrent_hashmap_lookup( &map, 101)); i = 0; rover = mulle_concurrent_hashmap_enumerate( &map); while( mulle_concurrent_hashmapenumerator_next( &rover, &hash, &value) == 1) { assert( value == (void *) (hash * 10)); ++i; assert( i <= 100); } mulle_concurrent_hashmapenumerator_done( &rover); assert( i == 100); mulle_concurrent_hashmap_remove( &map, 50, (void *) (50 * 10)); assert( mulle_concurrent_hashmap_lookup( &map, 50) == NULL); i = 0; rover = mulle_concurrent_hashmap_enumerate( &map); while( mulle_concurrent_hashmapenumerator_next( &rover, &hash, &value) == 1) { assert( value == (void *) (hash * 10)); ++i; assert( i <= 99); } mulle_concurrent_hashmapenumerator_done( &rover); assert( i == 99); } mulle_concurrent_hashmap_done( &map); mulle_aba_unregister(); mulle_allocator_set_aba( &mulle_testallocator, NULL, NULL); mulle_aba_done(); } int main(int argc, const char * argv[]) { mulle_testallocator_reset(); do { single_threaded_test(); mulle_testallocator_reset(); multi_threaded_test( 1); mulle_testallocator_reset(); multi_threaded_test( 2); mulle_testallocator_reset(); multi_threaded_test( 32); mulle_testallocator_reset(); } while( FOREVER); return( 0); }
27.475862
89
0.612575
004e07942d5a44f16f1fe85fba7d9a0107bae2ed
566
h
C
tests/3rdparty/testngpp/include/testngpp/runner/TestCaseSandboxHandler.h
chencang1980/mockcpp
45660e7bcf0a6cf8edce3c6a736e4b168acc016e
[ "Apache-2.0" ]
72
2018-01-26T11:19:32.000Z
2022-02-06T02:38:38.000Z
test/testngpp-1.1/include/testngpp/runner/TestCaseSandboxHandler.h
mswdwk/code_test_records
6edda193c8c19607c2021e62b96b8ff0813c7208
[ "MIT" ]
21
2021-03-17T06:41:56.000Z
2022-02-01T12:27:28.000Z
test/testngpp-1.1/include/testngpp/runner/TestCaseSandboxHandler.h
mswdwk/code_test_records
6edda193c8c19607c2021e62b96b8ff0813c7208
[ "MIT" ]
27
2018-04-03T08:31:14.000Z
2022-03-16T13:01:09.000Z
#ifndef __TESTNGPP_TESTCASE_SANDBOX_HANDLER_H #define __TESTNGPP_TESTCASE_SANDBOX_HANDLER_H #include <testngpp/testngpp.h> #include <testngpp/runner/SandboxHandler.h> TESTNGPP_NS_START struct TestCase; struct TestCaseRunner; struct TestCaseSandboxHandlerImpl; struct TestCaseSandboxHandler : public SandboxHandler { TestCaseSandboxHandler ( const TestCase* testcase , TestCaseRunner* runner); ~TestCaseSandboxHandler(); void handle(ChannelId channelId); private: TestCaseSandboxHandlerImpl* This; }; TESTNGPP_NS_END #endif
16.647059
53
0.789753
5325ecf31e775c82b0b51fee4f5f8ef3a905e3cd
7,214
h
C
bin/include/pyxiePlane.h
indigames/pyxie
4536730c73ca4fcd16b676ab5f707e6fabfdb46c
[ "MIT" ]
1
2019-09-19T01:41:54.000Z
2019-09-19T01:41:54.000Z
bin/include/pyxiePlane.h
indigames/pyxie
4536730c73ca4fcd16b676ab5f707e6fabfdb46c
[ "MIT" ]
1
2019-09-02T04:31:13.000Z
2019-09-02T04:31:13.000Z
bin/include/pyxiePlane.h
indigames/pyxiepython
4536730c73ca4fcd16b676ab5f707e6fabfdb46c
[ "MIT" ]
null
null
null
/////////////////////////////////////////////////////////////// //Pyxie game engine // // Copyright Kiharu Shishikura 2019. All rights reserved. /////////////////////////////////////////////////////////////// #pragma once #include "pyxieMathutil.h" namespace pyxie { #define F32_LOWER_EQUAL_0(n) ((n) <= 0.0f) class pyxiePlane { public: Vec3 Normal, Point; float D; pyxiePlane() : Normal(0, 1, 0), D(0) { } pyxiePlane(const Vec3& normal, const float d) : Normal(normal), D(d) { } pyxiePlane(const Vec3& v1, const Vec3& v2, const Vec3& v3) { Set3Points(v1, v2, v3); } ~pyxiePlane() {} void Set3Points(const Vec3& v1, const Vec3& v2, const Vec3& v3) { Vec3 aux1, aux2; aux1 = v1 - v2; aux2 = v3 - v2; Normal = Cross3D(aux2, aux1); Normal.Normalize(); Point = v2; D = -Vec3::Dot(Point, Normal); } void SetNormalAndPoint(const Vec3& normal, const Vec3& point) { this->Normal = Vec3::Normalize(normal); D = -Vec3::Dot(this->Normal, point); } void SetCoefficients(float a, float b, float c, float d) { // set the normal vector Normal = Vec3(a, b, c); //compute the lenght of the vector float l = Vec3::Length(Normal); // normalize the vector Normal = Vec3(a / l, b / l, c / l); // and divide d by th length as well this->D = d / l; } float Distance(const Vec3 & p) const { return (D + Vec3::Dot(Normal, p)); } //! Get an intersection with a 3d line. /** \param lineVect Vector of the line to intersect with. \param linePoint Point of the line to intersect with. \param outIntersection Place to store the intersection point, if there is one. \return True if there was an intersection, false if there was not. */ bool getIntersectionWithLine(const Vec3 & linePoint, const Vec3 & lineVect, Vec3 & outIntersection) const { float t2 = Vec3::Dot(Normal, lineVect); if (t2 == 0) return false; float t = -(Vec3::Dot(Normal, linePoint) + D) / t2; outIntersection = linePoint + (lineVect * t); return true; } //! Get percentage of line between two points where an intersection with this plane happens. /** Only useful if known that there is an intersection. \param linePoint1 Point1 of the line to intersect with. \param linePoint2 Point2 of the line to intersect with. \return Where on a line between two points an intersection with this plane happened. For example, 0.5 is returned if the intersection happened exactly in the middle of the two points. */ float getKnownIntersectionWithLine(const Vec3 & linePoint1, const Vec3 & linePoint2) const { Vec3 vect = linePoint2 - linePoint1; float t2 = Vec3::Dot(Normal, vect); return -((Vec3::Dot(Normal, linePoint1) + D) / t2); } //! Returns if this vector interpreted as a point is on a line between two other points. /** It is assumed that the point is on the line. \param begin Beginning vector to compare between. \param end Ending vector to compare between. \return True if this vector is between begin and end, false if not. */ bool isBetweenPoints(const Vec3 & p, const Vec3 & begin, const Vec3 & end) const { const float f = Vec3::LengthSqr(end - begin); return (Vec3::LengthSqr(begin - p) <= f) && (Vec3::LengthSqr(end - p) <= f); //const float f = (end - begin).getLengthSQ(); //return getDistanceFromSQ(begin) <= f && // getDistanceFromSQ(end) <= f; } //! Get an intersection with a 3d line, limited between two 3d points. /** \param linePoint1 Point 1 of the line. \param linePoint2 Point 2 of the line. \param outIntersection Place to store the intersection point, if there is one. \return True if there was an intersection, false if there was not. */ bool getIntersectionWithLimitedLine( const Vec3 & linePoint1, const Vec3 & linePoint2, Vec3 & outIntersection) const { return (getIntersectionWithLine(linePoint1, linePoint2 - linePoint1, outIntersection) && isBetweenPoints(outIntersection, linePoint1, linePoint2)); } //! Classifies the relation of a point to this plane. /** \param point Point to classify its relation. \return ISREL3D_FRONT if the point is in front of the plane, ISREL3D_BACK if the point is behind of the plane, and ISREL3D_PLANAR if the point is within the plane. */ IntersectionRelation classifyPointRelation(const Vec3 & point) const { const float d = Vec3::Dot(Normal, point) + D; if (d < -ROUNDING_ERROR_f32) return ISREL_BACK; if (d > ROUNDING_ERROR_f32) return ISREL_FRONT; return ISREL_PLANAR; } //! Recalculates the distance from origin by applying a new member point to the plane. void recalculateD(const Vec3 & MPoint) { D = -Vec3::Dot(MPoint, Normal); } //! Gets a member point of the plane. Vec3 getMemberPoint() const { return Normal * -D; } //! Tests if there is an intersection with the other plane /** \return True if there is a intersection. */ bool existsIntersection(const pyxiePlane & other) const { Vec3 c = Cross3D(other.Normal, Normal); return Vec3::Length(c) > ROUNDING_ERROR_f32; } //! Intersects this plane with another. /** \param other Other plane to intersect with. \param outLinePoint Base point of intersection line. \param outLineVect Vector of intersection. \return True if there is a intersection, false if not. */ bool getIntersectionWithPlane(const pyxiePlane & other, Vec3 & outLinePoint, Vec3 & outLineVect) const { const float fn00 = Vec3::Length(Normal); const float fn01 = Vec3::Dot(Normal, other.Normal); const float fn11 = Vec3::Length(other.Normal); const double det = fn00 * fn11 - fn01 * fn01; if (fabs(det) < ROUNDING_ERROR_f64) return false; const double invdet = 1.0 / det; const double fc0 = (fn11 * -D + fn01 * other.D) * invdet; const double fc1 = (fn00 * -other.D + fn01 * D) * invdet; outLineVect = Cross3D(Normal, other.Normal); outLinePoint = Normal * (float)fc0 + other.Normal * (float)fc1; return true; } //! Get the intersection point with two other planes if there is one. bool getIntersectionWithPlanes(const pyxiePlane & o1, const pyxiePlane & o2, Vec3 & outPoint) const { Vec3 linePoint, lineVect; if (getIntersectionWithPlane(o1, linePoint, lineVect)) return o2.getIntersectionWithLine(linePoint, lineVect, outPoint); return false; } //! Test if the triangle would be front or backfacing from any point. /** Thus, this method assumes a camera position from which the triangle is definitely visible when looking into the given direction. Note that this only works if the normal is Normalized. Do not use this method with points as it will give wrong results! \param lookDirection: Look direction. \return True if the plane is front facing and false if it is backfacing. */ bool isFrontFacing(const Vec3 & lookDirection) const { const float d = Vec3::Dot(Normal, lookDirection); return F32_LOWER_EQUAL_0(d); } }; }
33.398148
101
0.656501
bb3924a1f5020a83ff011ae4e14238083d7d1055
11,411
h
C
src/optimizer/cmaes_optimizer/src/c_cmaes/cmaes_interface.h
dettmann/bolero
fa88be1a1d4ab1e2855d20f5429ac83ed5eb4925
[ "BSD-3-Clause" ]
51
2017-05-19T13:33:29.000Z
2022-01-21T10:59:57.000Z
src/optimizer/cmaes_optimizer/src/c_cmaes/cmaes_interface.h
dettmann/bolero
fa88be1a1d4ab1e2855d20f5429ac83ed5eb4925
[ "BSD-3-Clause" ]
94
2017-05-19T19:44:07.000Z
2021-12-15T13:40:59.000Z
src/optimizer/cmaes_optimizer/src/c_cmaes/cmaes_interface.h
dettmann/bolero
fa88be1a1d4ab1e2855d20f5429ac83ed5eb4925
[ "BSD-3-Clause" ]
31
2017-05-19T19:41:39.000Z
2021-08-25T14:14:19.000Z
/* --------------------------------------------------------- */ /* --- File: cmaes_interface.h - Author: Nikolaus Hansen --- */ /* ---------------------- last modified: II 2006 --- */ /* --------------------------------- by: Nikolaus Hansen --- */ /* --------------------------------------------------------- */ /* CMA-ES for non-linear function minimization. Copyright (C) 1996, 2003 Nikolaus Hansen. e-mail: hansen@bionik.tu-berlin.de 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 (see http://www.gnu.org/copyleft/lesser.html). 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. */ #ifndef NH_cmaes_interface_h /* only include once */ #define NH_cmaes_interface_h #include "cmaes.h" /* --------------------------------------------------------- */ /* ------------------ Interface ---------------------------- */ /* --------------------------------------------------------- */ void cmaes_init(cmaes_t *cma_struct_ptr, double(*pFun)(double *), int dimension , double *xstart, double *sigma, long seed, int lambda, const char *input_parameter_filename); void cmaes_resume_distribution(cmaes_t *cmaes_struct_ptr, char *filename); void cmaes_exit(cmaes_t *); double * const * cmaes_SampleDistribution(cmaes_t *evo_ptr, const double *xmean); double * cmaes_EvaluateSample(cmaes_t *, double(*pFun)(double *)); double * cmaes_ReestimateDistribution(cmaes_t *, const double *rgFuncValue); double cmaes_Get(cmaes_t *, char const *szKeyWord); const double * cmaes_Getp(cmaes_t *, char const *szName);/* e.g. "xbestever" */ void cmaes_ReadSignals(cmaes_t *t, char *filename); double * cmaes_ReSampleSingle(cmaes_t *, double *rgx); const char * cmaes_Test(cmaes_t *, const char *szIdentifier); void cmaes_UpdateEigensystem(cmaes_t *, int flgforce); void cmaes_WriteToFile(cmaes_t *, const char *szKeyWord, const char *szFileName); #endif #if 0 /* --------------------------------------------------------- */ /* --------------- A Very Short Example -------------------- */ /* --------------------------------------------------------- */ #include "cmaes_interface.h" double fitfun(double *x){ /* function "cigtab" to be minized */ int i; double sum = 1e4*x[0]*x[0] + 1e-4*x[1]*x[1]; for(i = 2; i < x[-1]; ++i) sum += x[i]*x[i]; return sum; } int main() { double (*pFun)(double *) = &fitfun; /* any appropriate function pointer */ cmaes_t evo; /* Initialize everything into the struct evo */ cmaes_init(&evo, pFun, 0, NULL, NULL, 0, 0, "incmaes.par"); /* Iterate until stop criterion holds */ while(!cmaes_Test(&evo, "stop")) { /* generate lambda new search points */ cmaes_SampleDistribution(&evo, NULL); /* evaluate the new search points using pfun */ cmaes_EvaluateSample(&evo, NULL); /* update the search distribution used for cmaes_SampleDistribution() */ cmaes_ReestimateDistribution(&evo, NULL); /* read from file and e.g. print output, or stop, etc */ cmaes_ReadSignals(&evo, "signals.par"); } cmaes_WriteToFile(&evo, "all", "allcmaes.dat"); /* writes final results */ cmaes_WriteToFile(&evo, "resume", "allcmaes.dat"); /* data for restart */ cmaes_exit(&evo); return 0; } #endif #if 0 /* --------------------------------------------------------- */ /* ----------- Rough, Incomplete Documentation ------------- */ /* --------------------------------------------------------- */ Remark: A number of input parameters have default values which can be invoked by the zero value (0 or NULL). cmaes_init(cma_struct_ptr, pFun, dimension, xstart, sigma, seed, lambda, input_parameter_filename): DEFAULTS of input parameters (invoked by 0): cma_struct_ptr : Will be initialized here, not an input value, no default available. pFun : NULL dimension : 0 xstart : [0.5,...,0.5], N-dimensional vector. sigma : [0.3,...,0.3], N-dimensional vector. seed : random, see file actpar... lambda : 4+(int)(3*log(N)) input_parameter_filename : "incmaes.par" Input parameters: cma_struct_ptr: Pointer to CMA-ES struct cmaes_t. Optional (default, induced by zero value): pfun : Pointer to objective/fitness function to be minimized. dimension, int : Search space dimension N. Must be defined here or in the input parameter file. xstart, double *: Initial point in search space. sigma, double * : double array of size dimension N. Coordinatewise initial standard deviation of the sample distribution. The expected initial distance between xstart and the optimum per coordinate should not be much larger than sigma. seed, int (randomly chosen by default): Random seed, written to actparcmaes.par. lambda, int : population size, number of sampled candidate solutions per generation. input_parameter_filename, char *: File which should be edited properly. Filename "non" omits reading and writing of any parameters in cmaes_init(), "writeonly" omits reading but still writes used parameters to file "actparcmaes.par". Details: Default values as shown above are invoked by zero values (0 or NULL). The dimension has to be defined >0 here or in the input parameter file ("incmaes.par"). pFun can be defined here or when calling cmaes_EvaluateSample(...,pFun). pFun needs not to be defined if cmaes_EvaluateSample() is not used. cmaes_resume_distribution(cmaes_t *evo_ptr, char *filename): Input parameters: evo_ptr, cmaes_t *: Pointer to cma-es struct. filename: A file, that was written presumably by cmaes_WriteToFile(evo_ptr, "resume", filename). Details: Allows to restart with saved distribution parameters (use cmaes_WriteToFile for saving). Keyword "resume" followed by a filename in incmaes.par invokes this function during initialization. Searches in filename for the last occurence of "resume", followed by a dimension number, and reads the subsequent values for xmean, evolution paths ps and pc, sigma and covariance matrix. Note that you have to call cmaes_init() before calling cmaes_resume_distribution() explicitely. In the former all remaining (strategy-)parameters are set. It can be useful to edit the written parameters, in particular to increae sigma, before doing a restart. cmaes_SampleDistribution(evo_ptr, xmean): Input parameters: evo_ptr, cmaes_t *: Pointer to cma-es struct. Optional: xmean, const double *: Recent distribution mean. The default equals xstart in the first generation and the return value of cmaes_ReestimateDistribution() in the following generations. Return, double **: A pointer to a "population" of lambda N-dimensional samples. cmaes_EvaluateSample(evo_ptr, pFun): Input parameters: evo_ptr, cmaes_t *: Pointer to cma-es struct. Optional: pFun, double(*)(double *)): Pointer to objective function. Return, double *: Array of lambda function values. Evaluate lambda by calling cmaes_Get(evo_ptr, "lambda") or cmaes_Get(evo_ptr, "samplesize"). cmaes_ReestimateDistribution(evo_ptr, rgFuncValue): Input parameters: evo_ptr, cmaes_t *: Pointer to cma-es struct. Optional: rgFuncValue, const double *: An array of lambda function values. By default the return value of cmaes_EvaluateSample(). Return, double *: Mean value of the new distribution. Details: Core procedure of the CMA-ES algorithm. Sets a new mean value and estimates the new covariance matrix and a new step size for the normal search distribution. cmaes_Get(evo_ptr, szKeyWord): Returns the desired value. See implementation in cmaes.c. cmaes_Getp(evo_ptr, szKeyWord): Returns a pointer to the desired vector value (e.g. "xbestever"). See implementation in cmaes.c. cmaes_ReSampleSingle(evo_ptr, x): See example.c cmaes_Test(keyword): Input parameters: "stop" is the only valid keyword at present. Return value: NULL, if no stop criterion is fulfilled. Otherwise a string with the stop condition description. See example.c. Details: Some stopping criteria can be set in incmaes.par. Internal stopping criteria include a maximal condition number 10^14 for the covariance matrix and situations where the numerical discretisation error in x-space becomes noticable. cmaes_WriteToFile(evo_ptr, szKeyWord, szFileName): Input parameters: evo_ptr, cmaes_t *: Pointer to cma-es struct. Optional: szKeyWord, const char *: There are a few keywords available. Most of them can be combined with a "+". In doubt confer to the implemtation in cmaes.c. Keywords: "all": Writes a fairly complete status of the search. Missing is the actual random number generator status und the new coordinate system (matrix B). "B": The complete basis B of normalized eigenvectors, sorted by the size of the corresponding eigenvalues. "eval": number of function evaluations so far. "few": writes in one row: number of function evaluations; function value of best point in recent sample population; sigma; maximal standard deviation in coordinate axis; minimal standard deviation in coordinate axis; axis ratio of mutation ellipsoid; minimum of diagonal of D. "few(diag(D))": 4 to 6 sorted eigen value roots, including the smallest and largest. "resume": Writes dynamic parameters for reading with cmaes_resume_distribution. Alternatively (and more convenient) use keyword resume in incmaes.par for reading. further keywords: "dim", "funval", "N", "xbest", "xmean",... See also implementation in cmaes.c. szFileName, const char *: File name, default is "tmpcmaes.dat". Usefull combined keywords can be "eval+funval", "eval+few(diag(D))" "few+few(diag(D))", "all+B". #endif
42.420074
79
0.603628
63cc09f1a11e1fe45192e8cffee7df4f1ccd8d4a
10,808
c
C
Src/main.c
snandasena/stm32cubemx-leaning
2251fd7d1aa87b201e9e97a854aab6e6c6d276d9
[ "Apache-2.0" ]
null
null
null
Src/main.c
snandasena/stm32cubemx-leaning
2251fd7d1aa87b201e9e97a854aab6e6c6d276d9
[ "Apache-2.0" ]
null
null
null
Src/main.c
snandasena/stm32cubemx-leaning
2251fd7d1aa87b201e9e97a854aab6e6c6d276d9
[ "Apache-2.0" ]
null
null
null
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2022 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "realtime_kernel.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ GPIO_Init(); /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite Func */ /* USER CODE BEGIN WHILE */ Func(); /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 8; RCC_OscInitStruct.PLL.PLLN = 192; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLQ = 8; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { Error_Handler(); } } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOD, LD4_Pin | LD3_Pin | LD5_Pin | LD6_Pin | Audio_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin : PE2 */ GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pin : CS_I2C_SPI_Pin */ GPIO_InitStruct.Pin = CS_I2C_SPI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(CS_I2C_SPI_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PE4 PE5 MEMS_INT2_Pin */ GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | MEMS_INT2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */ GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PDM_OUT_Pin */ GPIO_InitStruct.Pin = PDM_OUT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(PDM_OUT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PA0 */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : I2S3_WS_Pin */ GPIO_InitStruct.Pin = I2S3_WS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(I2S3_WS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : SPI1_SCK_Pin SPI1_MISO_Pin SPI1_MOSI_Pin */ GPIO_InitStruct.Pin = SPI1_SCK_Pin | SPI1_MISO_Pin | SPI1_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : CLK_IN_Pin PB12 */ GPIO_InitStruct.Pin = CLK_IN_Pin | GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : LD4_Pin LD3_Pin LD5_Pin LD6_Pin Audio_RST_Pin */ GPIO_InitStruct.Pin = LD4_Pin | LD3_Pin | LD5_Pin | LD6_Pin | Audio_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /*Configure GPIO pins : I2S3_MCK_Pin I2S3_SCK_Pin I2S3_SD_Pin */ GPIO_InitStruct.Pin = I2S3_MCK_Pin | I2S3_SCK_Pin | I2S3_SD_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : VBUS_FS_Pin */ GPIO_InitStruct.Pin = VBUS_FS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(VBUS_FS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : OTG_FS_ID_Pin OTG_FS_DM_Pin OTG_FS_DP_Pin */ GPIO_InitStruct.Pin = OTG_FS_ID_Pin | OTG_FS_DM_Pin | OTG_FS_DP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : Audio_SCL_Pin Audio_SDA_Pin */ GPIO_InitStruct.Pin = Audio_SCL_Pin | Audio_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
34.202532
95
0.638323
763564e832e008a3b94fa29e0a6267366d4fa728
1,460
h
C
src/SolveRPN.h
caiozanatelli/RPNSolver
0b9a8a84a5d6059f6026ea4a1cf4f7988abd7371
[ "MIT" ]
null
null
null
src/SolveRPN.h
caiozanatelli/RPNSolver
0b9a8a84a5d6059f6026ea4a1cf4f7988abd7371
[ "MIT" ]
null
null
null
src/SolveRPN.h
caiozanatelli/RPNSolver
0b9a8a84a5d6059f6026ea4a1cf4f7988abd7371
[ "MIT" ]
null
null
null
#ifndef SOLVE_RPN_H #define SOLVE_RPN_H #include "ReversePolishNotation.h" #include "Stack.h" /*--------------------------------------------------------------------------------- Função: Função acessada pelo usuário para avaliar uma expressão em notação polonesa reversa. Para isso, a função recursiva solveRPN é chamada. Entrada: ponteiro para a expressão a ser avaliada e o resultado esperado. Saída: sem rotorno. ---------------------------------------------------------------------------------*/ void getAllSolutions(RPNExpression *expressaoRPN, int resultadoEsperado); /*--------------------------------------------------------------------------------- Função: lista todas as possibilidades de sequências de operadores de forma que o resultado da expressão RPN seja o resultado esperado. Isso é feito através de chamadas recursivas. Entrada: a expressão a ser avaliada; o índice da expressão, para controlar a recursão; o resultado esperado; o vetor de sequência de operadores que será atualizado a cada análise; o índice da sequência de operadores e a pilha que será utilizada para o processamento da expressão RPN. Saída: sem rotorno. ----------------------------------------------------------------------------------*/ void solveRPN(RPNExpression *expressao, int index, int res, char *operadores, int indexOp, Stack *pilha); #endif
48.666667
105
0.557534
5bad604bce1aaaab3f587aae1f161c1c671db034
17,704
h
C
Psyc03/Psyc03.h
ghostintranslation/psyc03
40b92fd4cb4c0441ee210112ceec129fb634dd61
[ "MIT" ]
5
2020-07-25T09:24:36.000Z
2022-01-19T00:00:32.000Z
Psyc03/Psyc03.h
ghostintranslation/psyc03
40b92fd4cb4c0441ee210112ceec129fb634dd61
[ "MIT" ]
null
null
null
Psyc03/Psyc03.h
ghostintranslation/psyc03
40b92fd4cb4c0441ee210112ceec129fb634dd61
[ "MIT" ]
3
2021-02-16T08:03:53.000Z
2021-09-28T04:42:09.000Z
#ifndef Psyc03_h #define Psyc03_h #include "Motherboard.h" /* // GUItool: begin automatically generated code AudioSynthWaveformDc dc1; //xy=65,34 AudioSynthWaveformSine sine1; //xy=68,86 AudioSynthWaveformSine lfo; //xy=71,146 AudioSynthWaveformModulated sine_fm1; //xy=88,325 AudioSynthWaveformSineModulated sine_fm2; //xy=103,393 AudioSynthWaveformSineModulated sine_fm3; //xy=118,448 AudioAnalyzePeak peak1; //xy=156,205 AudioEffectEnvelope envelope1; //xy=191,38 AudioMixer4 mixer1; //xy=252,148 AudioSynthWaveformDc dc2; //xy=257,513 AudioMixer4 mixer2; //xy=259,451 AudioEffectEnvelope envelope3; //xy=393,513 AudioEffectEnvelope envelope2; //xy=395,456 AudioFilterStateVariable filter; //xy=562,493 AudioOutputI2S i2s1; //xy=692,460 AudioOutputUSB usb1; //xy=697,516 AudioConnection patchCord1(dc1, envelope1); AudioConnection patchCord2(sine1, 0, mixer1, 1); AudioConnection patchCord3(lfo, peak1); AudioConnection patchCord4(sine_fm1, 0, mixer2, 0); AudioConnection patchCord5(sine_fm2, 0, mixer2, 1); AudioConnection patchCord6(sine_fm3, 0, mixer2, 2); AudioConnection patchCord7(envelope1, 0, mixer1, 0); AudioConnection patchCord8(mixer1, 0, sine_fm1, 0); AudioConnection patchCord9(mixer1, sine_fm2); AudioConnection patchCord10(mixer1, sine_fm3); AudioConnection patchCord11(dc2, envelope3); AudioConnection patchCord12(mixer2, envelope2); AudioConnection patchCord13(envelope3, 0, filter, 1); AudioConnection patchCord14(envelope2, 0, filter, 0); AudioConnection patchCord15(filter, 0, i2s1, 0); AudioConnection patchCord16(filter, 0, i2s1, 1); AudioConnection patchCord17(filter, 0, usb1, 0); AudioConnection patchCord18(filter, 0, usb1, 1); // GUItool: end automatically generated code */ /* * Synth */ class Psyc03{ private: static Psyc03 *instance; Psyc03(); AudioSynthWaveformDc *dc1; AudioSynthWaveformSine *sine1; AudioSynthWaveformSine *lfo; AudioAnalyzePeak *peak1; AudioEffectEnvelope *envelope1; AudioSynthWaveformDc *dc2; AudioSynthWaveformModulated *sine_fm1; AudioSynthWaveformModulated *sine_fm2; AudioSynthWaveformModulated *sine_fm3; AudioMixer4 *mixer1; AudioMixer4 *mixer2; AudioEffectEnvelope *envelope3; AudioEffectEnvelope *envelope2; AudioFilterStateVariable *filter; AudioConnection* patchCords[15]; // Output AudioMixer4 *output; // Motherboard Motherboard *device; // Params unsigned int tune = 30; float depth = 0; float speed = 0; float lfoPeak = 0; int fm = 400; int decay = 80; int attack = 2; float sweep = 0.2; int cutoff = 3000; float drumFilterRes = 4; byte shape = 0; byte shapeInputIndex = 0; byte tuneInputIndex = 1; byte sweepInputIndex = 2; byte fmInputIndex = 3; byte attackInputIndex = 4; byte decayInputIndex = 5; byte cutoffInputIndex = 6; byte speedInputIndex = 7; byte depthInputIndex = 8; byte updateMillis = 10; elapsedMillis clockUpdate; public: static Psyc03 *getInstance(); void init(); void stop(); void update(); AudioMixer4 * getOutput(); // Callbacks static void onShapeChange(byte inputIndex, float value, int diffToPrevious); static void onTuneChange(byte inputIndex, float value, int diffToPrevious); static void onSweepChange(byte inputIndex, float value, int diffToPrevious); static void onFmChange(byte inputIndex, float value, int diffToPrevious); static void onAttackChange(byte inputIndex, float value, int diffToPrevious); static void onDecayChange(byte inputIndex, float value, int diffToPrevious); static void onCutoffChange(byte inputIndex, float value, int diffToPrevious); static void onSpeedChange(byte inputIndex, float value, int diffToPrevious); static void onDepthChange(byte inputIndex, float value, int diffToPrevious); // Midi callbacks static void onMidiNoteOn(byte channel, byte note, byte velocity); static void onMidiNoteOff(byte channel, byte note, byte velocity); static void onMidiShapeChange(byte channel, byte control, byte value); static void onMidiTuneChange(byte channel, byte control, byte value); static void onMidiSweepChange(byte channel, byte control, byte value); static void onMidiFmChange(byte channel, byte control, byte value); static void onMidiAttackChange(byte channel, byte control, byte value); static void onMidiDecayChange(byte channel, byte control, byte value); static void onMidiCutoffChange(byte channel, byte control, byte value); static void onMidiSpeedChange(byte channel, byte control, byte value); static void onMidiDepthChange(byte channel, byte control, byte value); }; // Singleton pre init Psyc03 * Psyc03::instance = nullptr; /** * Constructor */ inline Psyc03::Psyc03(){ this->peak1 = new AudioAnalyzePeak(); this->lfo = new AudioSynthWaveformSine(); this->lfo->amplitude(1); this->lfo->frequency(1); this->sine1 = new AudioSynthWaveformSine(); this->sine1->amplitude(1); this->sine1->frequency(this->fm); this->sine_fm1 = new AudioSynthWaveformModulated(); this->sine_fm1->begin(WAVEFORM_SINE); this->sine_fm1->amplitude(.4); this->sine_fm1->frequency(this->tune); this->sine_fm2 = new AudioSynthWaveformModulated(); this->sine_fm2->begin(WAVEFORM_TRIANGLE); this->sine_fm2->amplitude(.4); this->sine_fm2->frequency(this->tune); this->sine_fm3 = new AudioSynthWaveformModulated(); this->sine_fm3->begin(WAVEFORM_SQUARE); this->sine_fm3->amplitude(.2); this->sine_fm3->frequency(this->tune); this->dc1 = new AudioSynthWaveformDc(); this->dc1->amplitude(1); this->envelope1 = new AudioEffectEnvelope(); this->envelope1->attack(this->attack); this->envelope1->decay(this->decay); this->envelope1->sustain(0); this->envelope1->hold(1); this->envelope1->release(1); this->envelope2 = new AudioEffectEnvelope(); this->envelope2->attack(this->attack); this->envelope2->decay(this->decay); this->envelope2->sustain(0); this->envelope2->hold(1); this->envelope2->release(1); this->envelope3 = new AudioEffectEnvelope(); this->envelope3->attack(this->attack); this->envelope3->decay(this->decay); this->envelope3->sustain(0); this->envelope3->hold(1); this->envelope3->release(1); this->dc2 = new AudioSynthWaveformDc(); this->dc2->amplitude(1); this->filter = new AudioFilterStateVariable(); this->filter->resonance(this->drumFilterRes); this->filter->frequency(this->cutoff); this->filter->octaveControl(2.5); this->mixer1 = new AudioMixer4(); this->mixer1->gain(0, this->sweep); this->mixer1->gain(1, this->fm); this->mixer2 = new AudioMixer4(); this->mixer2->gain(0, 1); this->mixer2->gain(1, 0); this->mixer2->gain(2, 0); this->device = device; this->output = new AudioMixer4(); this->output->gain(0, 1 ); this->patchCords[0] = new AudioConnection(*this->dc1, *this->envelope1); this->patchCords[1] = new AudioConnection(*this->sine1, 0, *this->mixer1, 1); this->patchCords[2] = new AudioConnection(*this->lfo, *this->peak1); this->patchCords[3] = new AudioConnection(*this->envelope1, 0, *this->mixer1, 0); this->patchCords[4] = new AudioConnection(*this->mixer1, 0, *this->sine_fm1, 0); this->patchCords[5] = new AudioConnection(*this->mixer1, 0, *this->sine_fm2, 0); this->patchCords[6] = new AudioConnection(*this->mixer1, 0, *this->sine_fm3, 0); this->patchCords[7] = new AudioConnection(*this->sine_fm1, 0, *this->mixer2, 0); this->patchCords[8] = new AudioConnection(*this->sine_fm2, 0, *this->mixer2, 1); this->patchCords[9] = new AudioConnection(*this->sine_fm3, 0, *this->mixer2, 2); this->patchCords[10] = new AudioConnection(*this->mixer2, *this->envelope2); this->patchCords[11] = new AudioConnection(*this->dc2, *this->envelope3); this->patchCords[12] = new AudioConnection(*this->envelope3, 0, *this->filter, 1); this->patchCords[13] = new AudioConnection(*this->envelope2, 0, *this->filter, 0); this->patchCords[14] = new AudioConnection(*this->filter, 0, *this->output, 0); } /** * Singleton instance */ inline Psyc03 *Psyc03::getInstance() { if (!instance) instance = new Psyc03; return instance; } inline void Psyc03::init(){ this->device = Motherboard::init( "PSYC03", { Potentiometer, Potentiometer, Potentiometer, Potentiometer, Potentiometer, Potentiometer, Potentiometer, Potentiometer, Potentiometer } ); // Callbacks this->device->setHandlePotentiometerChange(0, onShapeChange); this->device->setHandlePotentiometerChange(1, onTuneChange); this->device->setHandlePotentiometerChange(2, onSweepChange); this->device->setHandlePotentiometerChange(3, onFmChange); this->device->setHandlePotentiometerChange(4, onAttackChange); this->device->setHandlePotentiometerChange(5, onDecayChange); this->device->setHandlePotentiometerChange(6, onCutoffChange); this->device->setHandlePotentiometerChange(7, onSpeedChange); this->device->setHandlePotentiometerChange(8, onDepthChange); // MIDI callbacks this->device->setHandleMidiNoteOn(onMidiNoteOn); this->device->setHandleMidiNoteOff(onMidiNoteOff); device->setHandleMidiControlChange(0, 0, "Shape", onMidiShapeChange); device->setHandleMidiControlChange(0, 1, "Tune", onMidiTuneChange); device->setHandleMidiControlChange(0, 2, "Sweep", onMidiSweepChange); device->setHandleMidiControlChange(0, 3, "FM", onMidiFmChange); device->setHandleMidiControlChange(0, 4, "Attack", onMidiAttackChange); device->setHandleMidiControlChange(0, 5, "Decay", onMidiDecayChange); device->setHandleMidiControlChange(0, 6, "Cutoff", onMidiCutoffChange); device->setHandleMidiControlChange(0, 7, "Speed", onMidiSpeedChange); device->setHandleMidiControlChange(0, 8, "Depth", onMidiDepthChange); } /** * Midi Note on */ inline void Psyc03::onMidiNoteOn(byte channel, byte note, byte velocity){ float freq = 440.0 * powf(2.0, (float)(note - 69) * 0.08333333); getInstance()->sine_fm1->frequency(getInstance()->tune + freq); //lfoPeak*1000 getInstance()->sine_fm2->frequency(getInstance()->tune + freq); //lfoPeak*1000 getInstance()->sine_fm3->frequency(getInstance()->tune + freq); //lfoPeak*1000 getInstance()->envelope1->noteOn(); getInstance()->envelope2->noteOn(); getInstance()->envelope3->noteOn(); getInstance()->device->setLED(0, 1); } /** * Midi Note off */ inline void Psyc03::onMidiNoteOff(byte channel, byte note, byte velocity){ getInstance()->device->setLED(0, 0); } /** * Return the audio output */ inline AudioMixer4 * Psyc03::getOutput(){ return this->output; } /** * Update */ inline void Psyc03::update(){ this->device->update(); MIDI.read(this->device->getMidiChannel()); usbMIDI.read(this->device->getMidiChannel()); if(this->clockUpdate > this->updateMillis){ // Filter folowwing the envelope if (this->peak1->available()) { this->lfoPeak = this->peak1->read(); this->filter->frequency((float)this->cutoff + this->lfoPeak*2000); } this->clockUpdate = 0; } } /** * On Shape Change */ inline void Psyc03::onShapeChange(byte inputIndex, float value, int diffToPrevious){ float mix = (float)map( (float)value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, PI ); float voice1Gain = constrain(cos(mix), 0, 1); float voice2Gain = constrain(cos(mix+1.5*PI), 0, 1); float voice3Gain = constrain(cos(mix+3*PI), 0, 1); getInstance()->mixer2->gain(0, voice1Gain); getInstance()->mixer2->gain(1, voice2Gain); getInstance()->mixer2->gain(2, voice3Gain); } /** * On MIDI Shape Change */ void Psyc03::onMidiShapeChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onShapeChange(control, mapValue, 255); } /** * On Tune Change */ inline void Psyc03::onTuneChange(byte inputIndex, float value, int diffToPrevious){ // Tune unsigned int tune = map( value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 500 ); getInstance()->tune = tune; } /** * On MIDI Tune Change */ void Psyc03::onMidiTuneChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onTuneChange(control, mapValue, 255); } /** * On Sweep Change */ inline void Psyc03::onSweepChange(byte inputIndex, float value, int diffToPrevious){ // Sweep float sweep = (float)map( (float)value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 1 ); getInstance()->mixer1->gain(0, sweep); } /** * On MIDI Sweep Change */ void Psyc03::onMidiSweepChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onSweepChange(control, mapValue, 255); } /** * On FM Change */ inline void Psyc03::onFmChange(byte inputIndex, float value, int diffToPrevious){ float fmLevel = map((float)value, 0, 1023, 0, .6); getInstance()->sine1->frequency(value); getInstance()->mixer1->gain(1, fmLevel); } /** * On MIDI FM Change */ void Psyc03::onMidiFmChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onFmChange(control, mapValue, 255); } /** * On Attack Change */ inline void Psyc03::onAttackChange(byte inputIndex, float value, int diffToPrevious){ int attack = map( value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 2, 500 ); getInstance()->envelope2->attack(attack); getInstance()->envelope3->attack(attack); } /** * On MIDI Attack Change */ void Psyc03::onMidiAttackChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onAttackChange(control, mapValue, 255); } /** * On Decay Change */ inline void Psyc03::onDecayChange(byte inputIndex, float value, int diffToPrevious){ int decay = map( value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 1000 ); getInstance()->envelope1->decay(decay); getInstance()->envelope2->decay(decay); getInstance()->envelope3->decay(decay); } /** * On MIDI Decay Change */ void Psyc03::onMidiDecayChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onDecayChange(control, mapValue, 255); } /** * On Cutoff Change */ inline void Psyc03::onCutoffChange(byte inputIndex, float value, int diffToPrevious){ int cutoff = map( value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 2000 ); getInstance()->cutoff = cutoff; } /** * On MIDI Cutoff Change */ void Psyc03::onMidiCutoffChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onCutoffChange(control, mapValue, 255); } /** * On Speed Change */ inline void Psyc03::onSpeedChange(byte inputIndex, float value, int diffToPrevious){ float speed = (float)map( (float)value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 1 ); getInstance()->lfo->frequency(speed); } /** * On MIDI Speed Change */ void Psyc03::onMidiSpeedChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onSpeedChange(control, mapValue, 255); } /** * On Depth Change */ inline void Psyc03::onDepthChange(byte inputIndex, float value, int diffToPrevious){ float depth = (float)map( (float)value, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue(), 0, 1 ); getInstance()->lfo->amplitude(depth); } /** * On MIDI Depth Change */ void Psyc03::onMidiDepthChange(byte channel, byte control, byte value){ unsigned int mapValue = map( value, 0, 127, getInstance()->device->getAnalogMinValue(), getInstance()->device->getAnalogMaxValue() ); getInstance()->onDepthChange(control, mapValue, 255); } #endif
29.359867
85
0.679394
c0d24200f9fac91e481cfe3fe7416f938f643591
18,923
c
C
src/ajs_msgloop.c
artynet/alljoyn-js
1e910726267ae294012ee097e4effa82cc188d23
[ "Apache-2.0" ]
null
null
null
src/ajs_msgloop.c
artynet/alljoyn-js
1e910726267ae294012ee097e4effa82cc188d23
[ "Apache-2.0" ]
null
null
null
src/ajs_msgloop.c
artynet/alljoyn-js
1e910726267ae294012ee097e4effa82cc188d23
[ "Apache-2.0" ]
null
null
null
/** * @file */ /****************************************************************************** * Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source * Project (AJOSP) Contributors and others. * * SPDX-License-Identifier: Apache-2.0 * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution, and is available at * http://www.apache.org/licenses/LICENSE-2.0 * * Copyright (c) Open Connectivity Foundation and Contributors to AllSeen * Alliance. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. ******************************************************************************/ #include "ajs.h" #include "ajs_util.h" #include "ajs_services.h" #include "ajs_debugger.h" static uint32_t hasPolicyChanged = FALSE; static uint8_t IsPropAccessor(AJ_Message* msg) { if (strcmp(msg->iface, AJ_PropertiesIface[0] + 1) == 0) { return msg->msgId & 0xFF; } else { return AJS_NOT_ACCESSOR; } } static AJ_Status SessionBindReply(duk_context* ctx, AJ_Message* msg) { AJ_Status status; uint32_t result; uint16_t port; #if !defined(AJS_CONSOLE_LOCKDOWN) uint8_t ldstate; #endif status = AJ_UnmarshalArgs(msg, "uq", &result, &port); if (status != AJ_OK) { return status; } if (port != AJS_APP_PORT) { AJ_ResetArgs(msg); #if !defined(AJS_CONSOLE_LOCKDOWN) status = AJS_GetLockdownState(&ldstate); if (status == AJ_OK && ldstate == AJS_CONSOLE_UNLOCKED) { status = AJS_ConsoleMsgHandler(ctx, msg); } #endif if (status == AJ_ERR_NO_MATCH) { status = AJS_ServicesMsgHandler(msg); if (status == AJ_ERR_NO_MATCH) { status = AJ_OK; } } } return status; } void AJS_QueueNotifPolicyChanged() { hasPolicyChanged += 1; } static AJ_Status SessionDispatcher(duk_context* ctx, AJ_Message* msg) { AJ_Status status; uint32_t sessionId; uint16_t port; char* joiner; #if !defined(AJS_CONSOLE_LOCKDOWN) uint8_t ldstate; #endif status = AJ_UnmarshalArgs(msg, "qus", &port, &sessionId, &joiner); if (status != AJ_OK) { return status; } /* * Automatically accept sessions requests to the application port */ if (port == AJS_APP_PORT) { return AJS_HandleAcceptSession(ctx, msg, port, sessionId, joiner); } /* * See if this is the control panel port */ #ifdef CONTROLPANEL_SERVICE if (AJCPS_CheckSessionAccepted(port, sessionId, joiner)) { return AJ_BusReplyAcceptSession(msg, TRUE); } #endif status = AJ_ResetArgs(msg); if (status != AJ_OK) { return status; } /* * JavaScript doesn't accept/reject session so the session is either for the console or perhaps * a service if the services bind their own ports. */ #if !defined(AJS_CONSOLE_LOCKDOWN) status = AJS_GetLockdownState(&ldstate); if (status == AJ_OK && ldstate == AJS_CONSOLE_UNLOCKED) { status = AJS_ConsoleMsgHandler(ctx, msg); } #endif if (status == AJ_ERR_NO_MATCH) { status = AJS_ServicesMsgHandler(msg); } if (status == AJ_ERR_NO_MATCH) { AJ_ErrPrintf(("SessionDispatcher rejecting attempt to join unbound port %d\n", port)); status = AJ_BusReplyAcceptSession(msg, FALSE); } return status; } static AJ_Status HandleMessage(duk_context* ctx, duk_idx_t ajIdx, AJ_Message* msg) { duk_idx_t msgIdx; uint8_t accessor = AJS_NOT_ACCESSOR; const char* func; AJ_Status status; #if !defined(AJS_CONSOLE_LOCKDOWN) uint8_t ldstate; status = AJS_GetLockdownState(&ldstate); if (status == AJ_OK && ldstate == AJS_CONSOLE_UNLOCKED) { status = AJS_ConsoleMsgHandler(ctx, msg); if (status != AJ_ERR_NO_MATCH) { if (status != AJ_OK) { AJ_WarnPrintf(("AJS_ConsoleMsgHandler returned %s\n", AJ_StatusText(status))); } return status; } } #endif /* * JOIN_SESSION replies are handled in the AllJoyn.js layer and don't get passed to JavaScript */ if (msg->msgId == AJ_REPLY_ID(AJ_METHOD_JOIN_SESSION)) { return AJS_HandleJoinSessionReply(ctx, msg); } /* * Let the bases services layer take a look at the message */ status = AJS_ServicesMsgHandler(msg); if (status != AJ_ERR_NO_MATCH) { if (status != AJ_OK) { AJ_WarnPrintf(("AJS_ServicesMsgHandler returned %s\n", AJ_StatusText(status))); } return status; } /* * Nothing more to do if the AllJoyn module was not loaded */ if (ajIdx < 0) { return AJ_OK; } /* * Push the appropriate callback function onto the duktape stack */ if (msg->hdr->msgType == AJ_MSG_SIGNAL) { /* * About announcements and found name signal get special handling */ if (msg->msgId == AJ_SIGNAL_ABOUT_ANNOUNCE) { return AJS_AboutAnnouncement(ctx, msg); } if (msg->msgId == AJ_SIGNAL_FOUND_ADV_NAME) { return AJS_FoundAdvertisedName(ctx, msg); } if ((msg->msgId == AJ_SIGNAL_SESSION_LOST) || (msg->msgId == AJ_SIGNAL_SESSION_LOST_WITH_REASON)) { #if !defined(AJS_CONSOLE_LOCKDOWN) if (AJS_DebuggerIsAttached()) { msg = AJS_CloneAndCloseMessage(ctx, msg); } #endif return AJS_SessionLost(ctx, msg); } func = "onSignal"; duk_get_prop_string(ctx, ajIdx, func); } else if (msg->hdr->msgType == AJ_MSG_METHOD_CALL) { accessor = IsPropAccessor(msg); switch (accessor) { case AJS_NOT_ACCESSOR: func = "onMethodCall"; break; case AJ_PROP_GET: func = "onPropGet"; break; case AJ_PROP_SET: func = "onPropSet"; break; case AJ_PROP_GET_ALL: func = "onPropGetAll"; break; default: return AJ_ERR_INVALID; } duk_get_prop_string(ctx, ajIdx, func); } else { func = "onReply"; AJS_GetGlobalStashObject(ctx, func); if (duk_is_object(ctx, -1)) { duk_get_prop_index(ctx, -1, msg->replySerial); duk_swap_top(ctx, -2); /* * Clear the onReply entry */ duk_del_prop_index(ctx, -1, msg->replySerial); duk_pop(ctx); } } /* * Skip if there is no function to call. */ if (!duk_is_function(ctx, -1)) { if (msg->hdr->msgType == AJ_MSG_METHOD_CALL) { AJ_Message error; AJ_WarnPrintf(("%s: not registered - rejecting message\n", func)); AJ_MarshalErrorMsg(msg, &error, AJ_ErrRejected); status = AJ_DeliverMsg(&error); } else { AJ_WarnPrintf(("%s: not registered - ignoring message\n", func)); status = AJ_OK; } duk_pop(ctx); return status; } /* * Opens up a stack entry above the function */ duk_dup_top(ctx); msgIdx = AJS_UnmarshalMessage(ctx, msg, accessor); AJ_ASSERT(msgIdx == (ajIdx + 3)); /* * Save the message object on the stack */ duk_copy(ctx, msgIdx, -3); /* * Special case for GET prop so we can get the signature for marshalling the result */ if (accessor == AJS_NOT_ACCESSOR) { status = AJS_UnmarshalMsgArgs(ctx, msg); } else { status = AJS_UnmarshalPropArgs(ctx, msg, accessor, msgIdx); } if (status == AJ_OK) { duk_idx_t numArgs = duk_get_top(ctx) - msgIdx - 1; /* * If attached, the debugger will begin to unmarshal a message when the * method handler is called, therefore it must be cloned-and-closed now. */ #if !defined(AJS_CONSOLE_LOCKDOWN) if (AJS_DebuggerIsAttached()) { msg = AJS_CloneAndCloseMessage(ctx, msg); } #endif if (duk_pcall_method(ctx, numArgs) != DUK_EXEC_SUCCESS) { AJ_ErrPrintf(("%s: %s\n", func, duk_safe_to_string(ctx, -1))); #if !defined(AJS_CONSOLE_LOCKDOWN) AJS_ThrowHandler(ctx); #endif /* * Generate an error reply if this was a method call */ if (msg->hdr->msgType == AJ_MSG_METHOD_CALL) { duk_push_c_lightfunc(ctx, AJS_MethodCallError, 1, 0, 0); duk_insert(ctx, -3); (void)duk_pcall_method(ctx, 1); } } } /* * Cleanup stack back to the AJ object */ duk_set_top(ctx, ajIdx + 1); return status; } void ProcessPolicyNotifications(duk_context* ctx, duk_idx_t ajIdx) { if (!hasPolicyChanged) { return; } hasPolicyChanged -= 1; duk_get_prop_string(ctx, ajIdx, "onPolicyChanged"); if (!duk_is_function(ctx, -1)) { AJ_WarnPrintf(("onPolicyChanged: not registered - ignoring message\n")); duk_pop_2(ctx); return; } if (duk_pcall_method(ctx, 0) != DUK_EXEC_SUCCESS) { AJ_ErrPrintf(("onPolicyChanged: %s\n", duk_safe_to_string(ctx, -1))); } duk_pop_2(ctx); } static AJS_DEFERRED_OP deferredOp = AJS_OP_NONE; void AJS_DeferredOperation(duk_context* ctx, AJS_DEFERRED_OP op) { deferredOp = op; } static AJ_Status DoDeferredOperation(duk_context* ctx) { AJ_Status status = AJ_ERR_RESTART; switch (deferredOp) { #ifdef ONBOARDING_SERVICE case AJS_OP_OFFBOARD: AJOBS_ClearInfo(); AJS_DetachAllJoyn(AJS_GetBusAttachment(), AJ_ERR_RESTART); break; #endif case AJS_OP_FACTORY_RESET: AJS_FactoryReset(); break; default: status = AJ_OK; break; } deferredOp = AJS_OP_NONE; return status; } AJ_Status AJS_MessageLoop(duk_context* ctx, AJ_BusAttachment* aj, duk_idx_t ajIdx) { AJ_Status status = AJ_OK; AJ_Message msg; AJ_Time timerClock; uint32_t linkTO; uint32_t msgTO = 0x7FFFFFFF; duk_idx_t top = duk_get_top_index(ctx); uint8_t ldstate; AJ_InfoPrintf(("AJS_MessageLoop top=%d\n", (int)top)); deferredOp = AJS_OP_NONE; if (ajIdx >= 0) { /* * Read the link timeout property from the config set */ duk_get_prop_string(ctx, ajIdx, "config"); duk_get_prop_string(ctx, ajIdx, "linkTimeout"); linkTO = duk_get_int(ctx, -1); duk_pop_2(ctx); AJ_SetBusLinkTimeout(aj, linkTO); } AJ_ASSERT(duk_get_top_index(ctx) == top); /* * Initialize About we can start sending announcements */ AJ_AboutInit(aj, AJS_APP_PORT); /* * timer clock must be initialized */ AJ_InitTimer(&timerClock); while (status == AJ_OK) { /* * Services the internal and timeout timers and updates the timeout value for any new * timers that have been registered since this function was last called. */ status = AJS_RunTimers(ctx, &timerClock, &msgTO); if (status != AJ_OK) { AJ_ErrPrintf(("Error servicing timer functions\n")); break; } /* * Check we are cleaning up the duktape stack correctly. */ if (duk_get_top_index(ctx) != top) { AJ_ErrPrintf(("!!!AJS_MessageLoop top=%d expected %d\n", (int)duk_get_top_index(ctx), (int)top)); AJS_DumpStack(ctx); AJ_ASSERT(duk_get_top_index(ctx) == top); } AJS_SetWatchdogTimer(AJS_DEFAULT_WATCHDOG_TIMEOUT); /* * Pinned items (strings/buffers) are only valid while running script */ AJS_ClearPins(ctx); /* * Check if there are any pending I/O operations to perform. */ status = AJS_ServiceIO(ctx); if (status != AJ_OK) { AJ_ErrPrintf(("Error servicing I/O functions\n")); break; } /* * Check if any external modules have operations to perform */ status = AJS_ServiceExtModules(ctx); if (status != AJ_OK) { AJ_ErrPrintf(("Error servicing external modules\n")); break; } /* * Service any pending session joining */ status = AJS_ServiceSessions(ctx); if (status != AJ_OK) { AJ_ErrPrintf(("Error servicing sessions\n")); break; } /* * Do any announcing required */ status = AJS_GetLockdownState(&ldstate); if (status == AJ_OK && ldstate == AJS_CONSOLE_UNLOCKED) { status = AJ_AboutAnnounce(aj); } if (status != AJ_OK) { break; } /* * This special wildcard allows us to unmarshal signals with any source path */ AJS_SetObjectPath("!"); /* * Block until a message is received, the timeout expires, or the operation is interrupted. */ status = AJ_UnmarshalMsg(aj, &msg, msgTO); if (status != AJ_OK) { if ((status == AJ_ERR_INTERRUPTED) || (status == AJ_ERR_TIMEOUT)) { status = AJ_OK; continue; } if (status == AJ_ERR_NO_MATCH) { status = AJ_OK; } AJ_CloseMsg(&msg); continue; } ProcessPolicyNotifications(ctx, ajIdx); switch (msg.msgId) { case 0: /* If a message was parsed but is unrecognized and should be ignored */ break; /* Introspection messages */ case AJ_METHOD_PING: case AJ_METHOD_BUS_PING: case AJ_METHOD_GET_MACHINE_ID: case AJ_METHOD_INTROSPECT: case AJ_METHOD_GET_DESCRIPTION_LANG: case AJ_METHOD_INTROSPECT_WITH_DESC: /* About messages */ case AJ_METHOD_ABOUT_GET_PROP: case AJ_METHOD_ABOUT_SET_PROP: case AJ_METHOD_ABOUT_GET_ABOUT_DATA: case AJ_METHOD_ABOUT_GET_OBJECT_DESCRIPTION: case AJ_METHOD_ABOUT_ICON_GET_PROP: case AJ_METHOD_ABOUT_ICON_SET_PROP: case AJ_METHOD_ABOUT_ICON_GET_URL: case AJ_METHOD_ABOUT_ICON_GET_CONTENT: /* Authentication messages and replies */ case AJ_METHOD_EXCHANGE_GUIDS: case AJ_REPLY_ID(AJ_METHOD_EXCHANGE_GUIDS): case AJ_METHOD_EXCHANGE_SUITES: case AJ_REPLY_ID(AJ_METHOD_EXCHANGE_SUITES): case AJ_METHOD_AUTH_CHALLENGE: case AJ_REPLY_ID(AJ_METHOD_AUTH_CHALLENGE): case AJ_METHOD_GEN_SESSION_KEY: case AJ_REPLY_ID(AJ_METHOD_GEN_SESSION_KEY): case AJ_METHOD_EXCHANGE_GROUP_KEYS: case AJ_REPLY_ID(AJ_METHOD_EXCHANGE_GROUP_KEYS): case AJ_METHOD_KEY_EXCHANGE: case AJ_REPLY_ID(AJ_METHOD_KEY_EXCHANGE): case AJ_METHOD_KEY_AUTHENTICATION: case AJ_REPLY_ID(AJ_METHOD_KEY_AUTHENTICATION): case AJ_METHOD_SEND_MANIFESTS: case AJ_REPLY_ID(AJ_METHOD_SEND_MANIFESTS): case AJ_METHOD_SEND_MEMBERSHIPS: case AJ_REPLY_ID(AJ_METHOD_SEND_MEMBERSHIPS): case AJ_METHOD_SECURITY_GET_PROP: case AJ_REPLY_ID(AJ_METHOD_SECURITY_GET_PROP): case AJ_METHOD_CLAIMABLE_CLAIM: case AJ_REPLY_ID(AJ_METHOD_CLAIMABLE_CLAIM): case AJ_METHOD_MANAGED_RESET: case AJ_REPLY_ID(AJ_METHOD_MANAGED_RESET): case AJ_METHOD_MANAGED_UPDATE_IDENTITY: case AJ_REPLY_ID(AJ_METHOD_MANAGED_UPDATE_IDENTITY): case AJ_METHOD_MANAGED_UPDATE_POLICY: case AJ_REPLY_ID(AJ_METHOD_MANAGED_UPDATE_POLICY): case AJ_METHOD_MANAGED_RESET_POLICY: case AJ_REPLY_ID(AJ_METHOD_MANAGED_RESET_POLICY): case AJ_METHOD_MANAGED_INSTALL_MEMBERSHIP: case AJ_REPLY_ID(AJ_METHOD_MANAGED_INSTALL_MEMBERSHIP): case AJ_METHOD_MANAGED_REMOVE_MEMBERSHIP: case AJ_REPLY_ID(AJ_METHOD_MANAGED_REMOVE_MEMBERSHIP): case AJ_METHOD_MANAGED_START_MANAGEMENT: case AJ_REPLY_ID(AJ_METHOD_MANAGED_START_MANAGEMENT): case AJ_METHOD_MANAGED_END_MANAGEMENT: case AJ_REPLY_ID(AJ_METHOD_MANAGED_END_MANAGEMENT): case AJ_METHOD_MANAGED_INSTALL_MANIFESTS: case AJ_REPLY_ID(AJ_METHOD_MANAGED_INSTALL_MANIFESTS): /* Replies the app ignores */ case AJ_REPLY_ID(AJ_METHOD_ADD_MATCH): case AJ_REPLY_ID(AJ_METHOD_REMOVE_MATCH): case AJ_REPLY_ID(AJ_METHOD_PING): case AJ_REPLY_ID(AJ_METHOD_BUS_PING): /* Signals the app ignores */ case AJ_SIGNAL_PROBE_ACK: case AJ_SIGNAL_PROBE_REQ: case AJ_SIGNAL_NAME_OWNER_CHANGED: status = AJ_BusHandleBusMessage(&msg); break; case AJ_METHOD_ACCEPT_SESSION: status = SessionDispatcher(ctx, &msg); break; case AJ_REPLY_ID(AJ_METHOD_BIND_SESSION_PORT): status = SessionBindReply(ctx, &msg); break; default: status = HandleMessage(ctx, ajIdx, &msg); break; } /* * Free message resources */ AJ_CloseMsg(&msg); /* * Decide which messages should cause us to exit */ switch (status) { case AJ_OK: break; case AJ_ERR_READ: case AJ_ERR_WRITE: case AJ_ERR_RESTART: case AJ_ERR_RESTART_APP: break; default: AJ_ErrPrintf(("Got error %s - continuing anyway\n", AJ_StatusText(status))); status = AJ_OK; } /* * Let link monitor know we are getting messages */ AJ_NotifyLinkActive(); /* * Perform any deferred operations. These are operations such as factory reset that cannot * be cleanly performed from inside duktape. */ if (status == AJ_OK) { status = DoDeferredOperation(ctx); } } AJS_ClearPins(ctx); AJS_ClearWatchdogTimer(); return status; }
31.696817
109
0.611055
8b9324f2437e1d181d6d47a338e97c639151b039
10,531
h
C
sw/drivers/pwr/src/32b/f28x/f2805x/pwr.h
Hao878/Toaero_ESC
8afc32b54145ea5618d7497a758a2672b18c1acc
[ "MIT" ]
3
2021-01-21T12:42:10.000Z
2022-02-10T00:14:01.000Z
sw/drivers/pwr/src/32b/f28x/f2805x/pwr.h
Hao878/Toaero_ESC
8afc32b54145ea5618d7497a758a2672b18c1acc
[ "MIT" ]
null
null
null
sw/drivers/pwr/src/32b/f28x/f2805x/pwr.h
Hao878/Toaero_ESC
8afc32b54145ea5618d7497a758a2672b18c1acc
[ "MIT" ]
3
2018-12-28T17:16:05.000Z
2020-02-01T05:42:56.000Z
/* --COPYRIGHT--,BSD * Copyright (c) 2015, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --/COPYRIGHT--*/ #ifndef _PWR_H_ #define _PWR_H_ //! \file drivers/pwr/src/32b/f28x/f2805x/pwr.h //! //! \brief Contains public interface to various functions related //! to the power (PWR) object //! //! (C) Copyright 2015, Texas Instruments, Inc. // ************************************************************************** // the includes #include "sw/modules/types/src/types.h" #include "sw/drivers/cpu/src/32b/f28x/f2805x/cpu.h" //! //! //! \defgroup PWR PWR //! //@{ #ifdef __cplusplus extern "C" { #endif // ************************************************************************** // the defines //! \brief Defines the base address of the power (PWR) registers //! #define PWR_BASE_ADDR (0x00000985) //! \brief Defines the location of the BORENZ bits in the BORCFG register //! #define PWR_BORCFG_BORENZ_BITS (1 << 0) //! \brief Defines the location of the LPM bits in the LPMCR0 register //! #define PWR_LPMCR0_LPM_BITS (3 << 0) //! \brief Defines the location of the QUALSTDBY bits in the LPMCR0 register //! #define PWR_LPMCR0_QUALSTDBY_BITS (63 << 2) //! \brief Defines the location of the WDINTE bits in the LPMCR0 register //! #define PWR_LPMCR0_WDINTE_BITS (1 << 15) // ************************************************************************** // the typedefs //! \brief Enumeration to define the power (PWR) low power modes //! typedef enum { PWR_LowPowerMode_Idle=0, //!< Denotes the idle mode PWR_LowPowerMode_Standby, //!< Denotes the standby mode PWR_LowPowerMode_Halt //!< Denotes the halt mode } PWR_LowPowerMode_e; //! \brief Enumeration to define the power (PWR) number of standby clock cycles //! typedef enum { PWR_NumStandByClocks_2=(0 << 2), //!< Denotes 2 standby clock cycles PWR_NumStandByClocks_3=(1 << 2), //!< Denotes 3 standby clock cycles PWR_NumStandByClocks_4=(2 << 2), //!< Denotes 4 standby clock cycles PWR_NumStandByClocks_5=(3 << 2), //!< Denotes 5 standby clock cycles PWR_NumStandByClocks_6=(4 << 2), //!< Denotes 6 standby clock cycles PWR_NumStandByClocks_7=(5 << 2), //!< Denotes 7 standby clock cycles PWR_NumStandByClocks_8=(6 << 2), //!< Denotes 8 standby clock cycles PWR_NumStandByClocks_9=(7 << 2), //!< Denotes 9 standby clock cycles PWR_NumStandByClocks_10=(8 << 2), //!< Denotes 10 standby clock cycles PWR_NumStandByClocks_11=(9 << 2), //!< Denotes 11 standby clock cycles PWR_NumStandByClocks_12=(10 << 2), //!< Denotes 12 standby clock cycles PWR_NumStandByClocks_13=(11 << 2), //!< Denotes 13 standby clock cycles PWR_NumStandByClocks_14=(12 << 2), //!< Denotes 14 standby clock cycles PWR_NumStandByClocks_15=(13 << 2), //!< Denotes 15 standby clock cycles PWR_NumStandByClocks_16=(14 << 2), //!< Denotes 16 standby clock cycles PWR_NumStandByClocks_17=(15 << 2), //!< Denotes 17 standby clock cycles PWR_NumStandByClocks_18=(16 << 2), //!< Denotes 18 standby clock cycles PWR_NumStandByClocks_19=(17 << 2), //!< Denotes 19 standby clock cycles PWR_NumStandByClocks_20=(18 << 2), //!< Denotes 20 standby clock cycles PWR_NumStandByClocks_21=(19 << 2), //!< Denotes 21 standby clock cycles PWR_NumStandByClocks_22=(20 << 2), //!< Denotes 22 standby clock cycles PWR_NumStandByClocks_23=(21 << 2), //!< Denotes 23 standby clock cycles PWR_NumStandByClocks_24=(22 << 2), //!< Denotes 24 standby clock cycles PWR_NumStandByClocks_25=(23 << 2), //!< Denotes 25 standby clock cycles PWR_NumStandByClocks_26=(24 << 2), //!< Denotes 26 standby clock cycles PWR_NumStandByClocks_27=(25 << 2), //!< Denotes 27 standby clock cycles PWR_NumStandByClocks_28=(26 << 2), //!< Denotes 28 standby clock cycles PWR_NumStandByClocks_29=(27 << 2), //!< Denotes 29 standby clock cycles PWR_NumStandByClocks_30=(28 << 2), //!< Denotes 30 standby clock cycles PWR_NumStandByClocks_31=(29 << 2), //!< Denotes 31 standby clock cycles PWR_NumStandByClocks_32=(30 << 2), //!< Denotes 32 standby clock cycles PWR_NumStandByClocks_33=(31 << 2), //!< Denotes 33 standby clock cycles PWR_NumStandByClocks_34=(32 << 2), //!< Denotes 34 standby clock cycles PWR_NumStandByClocks_35=(33 << 2), //!< Denotes 35 standby clock cycles PWR_NumStandByClocks_36=(34 << 2), //!< Denotes 36 standby clock cycles PWR_NumStandByClocks_37=(35 << 2), //!< Denotes 37 standby clock cycles PWR_NumStandByClocks_38=(36 << 2), //!< Denotes 38 standby clock cycles PWR_NumStandByClocks_39=(37 << 2), //!< Denotes 39 standby clock cycles PWR_NumStandByClocks_40=(38 << 2), //!< Denotes 40 standby clock cycles PWR_NumStandByClocks_41=(39 << 2), //!< Denotes 41 standby clock cycles PWR_NumStandByClocks_42=(40 << 2), //!< Denotes 42 standby clock cycles PWR_NumStandByClocks_43=(41 << 2), //!< Denotes 43 standby clock cycles PWR_NumStandByClocks_44=(42 << 2), //!< Denotes 44 standby clock cycles PWR_NumStandByClocks_45=(43 << 2), //!< Denotes 45 standby clock cycles PWR_NumStandByClocks_46=(44 << 2), //!< Denotes 46 standby clock cycles PWR_NumStandByClocks_47=(45 << 2), //!< Denotes 47 standby clock cycles PWR_NumStandByClocks_48=(46 << 2), //!< Denotes 48 standby clock cycles PWR_NumStandByClocks_49=(47 << 2), //!< Denotes 49 standby clock cycles PWR_NumStandByClocks_50=(48 << 2), //!< Denotes 50 standby clock cycles PWR_NumStandByClocks_51=(49 << 2), //!< Denotes 51 standby clock cycles PWR_NumStandByClocks_52=(50 << 2), //!< Denotes 52 standby clock cycles PWR_NumStandByClocks_53=(51 << 2), //!< Denotes 53 standby clock cycles PWR_NumStandByClocks_54=(52 << 2), //!< Denotes 54 standby clock cycles PWR_NumStandByClocks_55=(53 << 2), //!< Denotes 55 standby clock cycles PWR_NumStandByClocks_56=(54 << 2), //!< Denotes 56 standby clock cycles PWR_NumStandByClocks_57=(55 << 2), //!< Denotes 57 standby clock cycles PWR_NumStandByClocks_58=(56 << 2), //!< Denotes 58 standby clock cycles PWR_NumStandByClocks_59=(57 << 2), //!< Denotes 59 standby clock cycles PWR_NumStandByClocks_60=(58 << 2), //!< Denotes 60 standby clock cycles PWR_NumStandByClocks_61=(59 << 2), //!< Denotes 61 standby clock cycles PWR_NumStandByClocks_62=(60 << 2), //!< Denotes 62 standby clock cycles PWR_NumStandByClocks_63=(61 << 2), //!< Denotes 63 standby clock cycles PWR_NumStandByClocks_64=(62 << 2), //!< Denotes 64 standby clock cycles PWR_NumStandByClocks_65=(63 << 2) //!< Denotes 65 standby clock cycles } PWR_NumStandByClocks_e; //! \brief Defines the power (PWR) object //! typedef struct _PWR_Obj_ { volatile uint16_t BORCFG; //!< BOR (Brown Out Reset) Configuration Register volatile uint16_t rsvd_1[26264]; //<! Reserved volatile uint16_t LPMCR0; //<! Low Power Mode Control Register 0 } PWR_Obj; //! \brief Defines the power (PWR) handle //! typedef struct _PWR_Obj_ *PWR_Handle; // ************************************************************************** // the globals // ************************************************************************** // the function prototypes //! \brief Disables the brownout reset functions //! \param[in] pwrHandle The power (PWR) object handle extern void PWR_disableBrownOutReset(PWR_Handle pwrHandle); //! \brief Disables the watchdog interrupt //! \param[in] pwrHandle The power (PWR) object handle extern void PWR_disableWatchDogInt(PWR_Handle pwrHandle); //! \brief Enables the brownout reset functions //! \param[in] pwrHandle The power (PWR) object handle extern void PWR_enableBrownOutReset(PWR_Handle pwrHandle); //! \brief Enables the watchdog interrupt //! \param[in] pwrHandle The power (PWR) object handle extern void PWR_enableWatchDogInt(PWR_Handle pwrHandle); //! \brief Initializes the power (PWR) object handle //! \param[in] pMemory A pointer to the base address of the PWR registers //! \param[in] numBytes The number of bytes allocated for the PWR object, bytes //! \return The power (PWR) object handle extern PWR_Handle PWR_init(void *pMemory,const size_t numBytes); //! \brief Sets the low power mode //! \param[in] pwrHandle The power (PWR) object handle //! \param[in] lowPowerMode The low power mode extern void PWR_setLowPowerMode(PWR_Handle pwrHandle,const PWR_LowPowerMode_e lowPowerMode); //! \brief Sets the number of standby clock cycles //! \param[in] pwrHandle The power (PWR) object handle //! \param[in] numClkCycles The number of standby clock cycles extern void PWR_setNumStandByClocks(PWR_Handle pwrHandle,const PWR_NumStandByClocks_e numClkCycles); #ifdef __cplusplus } #endif // extern "C" //@} // ingroup #endif // end of _PWR_H_ definition
43.516529
100
0.678283
6beb1ebbef950acafe161fbbb55fdf2e90ab56cc
596
c
C
examples/hello/main.c
pabigot/bspacm
767cd31517bdaa8eb98d55719d08b677acc8b55f
[ "Zlib", "CC0-1.0", "BSD-3-Clause" ]
7
2015-09-23T09:55:33.000Z
2020-06-09T18:25:02.000Z
examples/hello/main.c
pabigot/bspacm
767cd31517bdaa8eb98d55719d08b677acc8b55f
[ "Zlib", "CC0-1.0", "BSD-3-Clause" ]
1
2018-03-13T23:04:02.000Z
2018-03-13T23:24:59.000Z
examples/hello/main.c
pabigot/bspacm
767cd31517bdaa8eb98d55719d08b677acc8b55f
[ "Zlib", "CC0-1.0", "BSD-3-Clause" ]
6
2015-10-26T00:16:28.000Z
2020-06-09T18:25:05.000Z
/* BSPACM - bootstrap/hello demonstration application * * Written in 2014 by Peter A. Bigot <http://pabigot.github.io/bspacm/> * * To the extent possible under law, the author(s) have dedicated all * copyright and related and neighboring rights to this software to * the public domain worldwide. This software is distributed without * any warranty. * * You should have received a copy of the CC0 Public Domain Dedication * along with this software. If not, see * <http://creativecommons.org/publicdomain/zero/1.0/>. */ #include <stdio.h> void main () { printf("Hello, world!"); }
28.380952
71
0.724832
ac5ddc2f5fef46e67accf11515b9906426e7b22b
258
h
C
BulletinDistributorCompanion.framework/BLTSectionConfigurationCMASItem.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
BulletinDistributorCompanion.framework/BLTSectionConfigurationCMASItem.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
BulletinDistributorCompanion.framework/BLTSectionConfigurationCMASItem.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/BulletinDistributorCompanion.framework/BulletinDistributorCompanion */ @interface BLTSectionConfigurationCMASItem : BLTSectionConfigurationItem - (bool)optOutOfCoordination; @end
25.8
111
0.848837
b1be2f0f8b65cad5c252f35ddc595ef1c1c4b4f6
1,235
h
C
macOS/10.13/AudioToolbox.framework/_ACPluginDBBundle.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
30
2016-10-09T20:13:00.000Z
2022-01-24T04:14:57.000Z
macOS/10.13/AudioToolbox.framework/_ACPluginDBBundle.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
null
null
null
macOS/10.13/AudioToolbox.framework/_ACPluginDBBundle.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
7
2017-08-29T14:41:25.000Z
2022-01-19T17:14:54.000Z
/* Generated by RuntimeBrowser Image: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox */ @interface _ACPluginDBBundle : NSObject { struct AudioComponentVector { struct shared_ptr<APComponent> {} *__begin_; struct shared_ptr<APComponent> {} *__end_; struct __compressed_pair<std::__1::shared_ptr<APComponent> *, std::__1::allocator<std::__1::shared_ptr<APComponent> > > { struct shared_ptr<APComponent> {} *__first_; } __end_cap_; bool mSorted; } mBundleComponentVector; NSString * mFullPath; double mInfoPlistModDate; double mRsrcModDate; } - (id).cxx_construct; - (void).cxx_destruct; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (id)initWithPath:(id)arg1 infoPlistModDate:(double)arg2 rsrcModDate:(double)arg3; - (void)loadAllComponents:(struct AudioComponentVector { struct shared_ptr<APComponent> {} *x1; struct shared_ptr<APComponent> {} *x2; struct __compressed_pair<std::__1::shared_ptr<APComponent> *, std::__1::allocator<std::__1::shared_ptr<APComponent> > > { struct shared_ptr<APComponent> {} *x_3_1_1; } x3; bool x4; }*)arg1; - (void)scanWithPriority:(int)arg1 loadable:(BOOL)arg2; @end
44.107143
324
0.715789
21f3a37280ae2aa12d5f5301c32935a3df414225
1,892
c
C
src/libtp/tests/testuri.c
MatthewCLane/unicon
29f68fb05ae1ca33050adf1bd6890d03c6ff26ad
[ "BSD-2-Clause" ]
35
2019-11-29T13:19:55.000Z
2022-03-01T06:00:40.000Z
src/libtp/tests/testuri.c
MatthewCLane/unicon
29f68fb05ae1ca33050adf1bd6890d03c6ff26ad
[ "BSD-2-Clause" ]
83
2019-11-03T20:07:12.000Z
2022-03-22T11:32:35.000Z
src/libtp/tests/testuri.c
jschnet/unicon
df79234dc1b8a4972f3908f601329591c06bd141
[ "BSD-2-Clause" ]
16
2019-10-14T04:32:36.000Z
2022-03-01T06:01:00.000Z
#ifndef NO_CONFIG_H #ifndef HAVE_CONFIG_H #define HAVE_CONFIG_H #endif #endif #ifdef HAVE_CONFIG_H #include "../../h/config.h" #endif #ifdef STDC_HEADERS #include <stdio.h> #include <stdlib.h> #include <string.h> #endif #include <uri.h> void print_uri(PURI puri); int main(int argc, char **argv) { PURI puri; if (argc != 2) { fprintf(stderr, "usage: %s uri | @file\n", argv[0]); exit(1); } if (argv[1][0] != '@') { puri = uri_parse(argv[1]); if (puri->status != URI_SUCCESS) { fprintf(stderr, "testuri: %s `%s' (%s: %d)\n", _uri_errlist[puri->status], argv[1], __FILE__, __LINE__); uri_free(puri); exit(1); } print_uri(puri); uri_free(puri); exit(0); } else { char uri[1024]; char *file = argv[1]+1; FILE *uris = fopen(file, "r"); if (uris == NULL) { perror(file); exit(1); } while (fgets(uri, 1024, uris)) { if (uri[0] == '#') { /* Allow comments */ continue; } uri[strlen(uri)-1] = '\0'; /* Kill the newline */ printf("\n[%s]\n", uri); puri = uri_parse(uri); if (puri->status != URI_SUCCESS) { fprintf(stderr, "testuri: %s `%s' (%s: %d)", _uri_errlist[puri->status], uri, __FILE__, __LINE__); uri_free(puri); continue; } print_uri(puri); uri_free(puri); } fclose(uris); } return 0; } void print_uri(PURI puri) { static const char *nullstr = "<NULL>"; if (puri == NULL) { printf("NULL URI!\n"); return; } printf("scheme: [%s]\n", (puri->scheme) ? puri->scheme : nullstr); printf("user: [%s]\n", (puri->user) ? puri->user : nullstr); printf("pass: [%s]\n", (puri->pass) ? puri->pass : nullstr); printf("host: [%s]\n", (puri->host) ? puri->host : nullstr); printf("port: [%d]\n", puri->port); printf("path: [%s]\n", (puri->path) ? puri->path : nullstr); }
20.791209
68
0.549683
b1ece40e95561e49e602cab3bc3db96110cd50cb
102
c
C
src/unistd/pause.c
ung-org/lib-c
55fc64c7ffd7792bc88451a736c2e94e5865282f
[ "MIT" ]
null
null
null
src/unistd/pause.c
ung-org/lib-c
55fc64c7ffd7792bc88451a736c2e94e5865282f
[ "MIT" ]
null
null
null
src/unistd/pause.c
ung-org/lib-c
55fc64c7ffd7792bc88451a736c2e94e5865282f
[ "MIT" ]
null
null
null
#include "_syscall.h" int pause(void) { SYSCALL(pause, int, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) */
10.2
43
0.54902
cee18faad7df5228391112b1fd2e29059d5b90b6
460
h
C
qqtw/qqheaders7.2/QQDynamicAvatarStrategyModel.h
onezens/QQTweak
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
5
2018-02-20T14:24:17.000Z
2020-08-06T09:31:21.000Z
qqtw/qqheaders7.2/QQDynamicAvatarStrategyModel.h
onezens/QQTweak
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
1
2020-06-10T07:49:16.000Z
2020-06-12T02:08:35.000Z
qqtw/qqheaders7.2/QQDynamicAvatarStrategyModel.h
onezens/SmartQQ
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "QQModel.h" #import "NSCopying.h" @interface QQDynamicAvatarStrategyModel : QQModel <NSCopying> { long long _flowUsedBytesToday; } - (id)copyWithZone:(struct _NSZone *)arg1; - (id)description; @property(nonatomic) long long flowUsedBytesToday; // @synthesize flowUsedBytesToday=_flowUsedBytesToday; @end
20.909091
105
0.721739
a8585933b891cae6c41a37bc51b06fd0404118aa
5,632
c
C
lib/asn1c/nr_rrc/UEInformationResponse-r16.c
gmg2719/free5GRAN
5ded60f3c5b85b507f96bdbf092886901d588dd1
[ "Apache-2.0" ]
null
null
null
lib/asn1c/nr_rrc/UEInformationResponse-r16.c
gmg2719/free5GRAN
5ded60f3c5b85b507f96bdbf092886901d588dd1
[ "Apache-2.0" ]
null
null
null
lib/asn1c/nr_rrc/UEInformationResponse-r16.c
gmg2719/free5GRAN
5ded60f3c5b85b507f96bdbf092886901d588dd1
[ "Apache-2.0" ]
1
2021-02-20T10:27:52.000Z
2021-02-20T10:27:52.000Z
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "NR-RRC-Definitions" * found in "NR-RRC-Definitions.asn" * `asn1c -fcompound-names -no-gen-example -pdu=all` */ #include "UEInformationResponse-r16.h" static asn_oer_constraints_t asn_OER_type_criticalExtensions_constr_3 CC_NOTUSED = { { 0, 0 }, -1}; static asn_per_constraints_t asn_PER_type_criticalExtensions_constr_3 CC_NOTUSED = { { APC_CONSTRAINED, 1, 1, 0, 1 } /* (0..1) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static const ber_tlv_tag_t asn_DEF_criticalExtensionsFuture_tags_5[] = { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_SEQUENCE_specifics_t asn_SPC_criticalExtensionsFuture_specs_5 = { sizeof(struct UEInformationResponse_r16__criticalExtensions__criticalExtensionsFuture), offsetof(struct UEInformationResponse_r16__criticalExtensions__criticalExtensionsFuture, _asn_ctx), 0, /* No top level tags */ 0, /* No tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* First extension addition */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_criticalExtensionsFuture_5 = { "criticalExtensionsFuture", "criticalExtensionsFuture", &asn_OP_SEQUENCE, asn_DEF_criticalExtensionsFuture_tags_5, sizeof(asn_DEF_criticalExtensionsFuture_tags_5) /sizeof(asn_DEF_criticalExtensionsFuture_tags_5[0]) - 1, /* 1 */ asn_DEF_criticalExtensionsFuture_tags_5, /* Same as above */ sizeof(asn_DEF_criticalExtensionsFuture_tags_5) /sizeof(asn_DEF_criticalExtensionsFuture_tags_5[0]), /* 2 */ { 0, 0, SEQUENCE_constraint }, 0, 0, /* No members */ &asn_SPC_criticalExtensionsFuture_specs_5 /* Additional specs */ }; static asn_TYPE_member_t asn_MBR_criticalExtensions_3[] = { { ATF_NOFLAGS, 0, offsetof(struct UEInformationResponse_r16__criticalExtensions, choice.ueInformationResponse_r16), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_UEInformationResponse_r16_IEs, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "ueInformationResponse-r16" }, { ATF_NOFLAGS, 0, offsetof(struct UEInformationResponse_r16__criticalExtensions, choice.criticalExtensionsFuture), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, &asn_DEF_criticalExtensionsFuture_5, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "criticalExtensionsFuture" }, }; static const asn_TYPE_tag2member_t asn_MAP_criticalExtensions_tag2el_3[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ueInformationResponse-r16 */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* criticalExtensionsFuture */ }; static asn_CHOICE_specifics_t asn_SPC_criticalExtensions_specs_3 = { sizeof(struct UEInformationResponse_r16__criticalExtensions), offsetof(struct UEInformationResponse_r16__criticalExtensions, _asn_ctx), offsetof(struct UEInformationResponse_r16__criticalExtensions, present), sizeof(((struct UEInformationResponse_r16__criticalExtensions *)0)->present), asn_MAP_criticalExtensions_tag2el_3, 2, /* Count of tags in the map */ 0, 0, -1 /* Extensions start */ }; static /* Use -fall-defs-global to expose */ asn_TYPE_descriptor_t asn_DEF_criticalExtensions_3 = { "criticalExtensions", "criticalExtensions", &asn_OP_CHOICE, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ { &asn_OER_type_criticalExtensions_constr_3, &asn_PER_type_criticalExtensions_constr_3, CHOICE_constraint }, asn_MBR_criticalExtensions_3, 2, /* Elements count */ &asn_SPC_criticalExtensions_specs_3 /* Additional specs */ }; asn_TYPE_member_t asn_MBR_UEInformationResponse_r16_1[] = { { ATF_NOFLAGS, 0, offsetof(struct UEInformationResponse_r16, rrc_TransactionIdentifier), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_RRC_TransactionIdentifier, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "rrc-TransactionIdentifier" }, { ATF_NOFLAGS, 0, offsetof(struct UEInformationResponse_r16, criticalExtensions), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), +1, /* EXPLICIT tag at current level */ &asn_DEF_criticalExtensions_3, 0, { 0, 0, 0 }, 0, 0, /* No default value */ "criticalExtensions" }, }; static const ber_tlv_tag_t asn_DEF_UEInformationResponse_r16_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static const asn_TYPE_tag2member_t asn_MAP_UEInformationResponse_r16_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* rrc-TransactionIdentifier */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* criticalExtensions */ }; asn_SEQUENCE_specifics_t asn_SPC_UEInformationResponse_r16_specs_1 = { sizeof(struct UEInformationResponse_r16), offsetof(struct UEInformationResponse_r16, _asn_ctx), asn_MAP_UEInformationResponse_r16_tag2el_1, 2, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* First extension addition */ }; asn_TYPE_descriptor_t asn_DEF_UEInformationResponse_r16 = { "UEInformationResponse-r16", "UEInformationResponse-r16", &asn_OP_SEQUENCE, asn_DEF_UEInformationResponse_r16_tags_1, sizeof(asn_DEF_UEInformationResponse_r16_tags_1) /sizeof(asn_DEF_UEInformationResponse_r16_tags_1[0]), /* 1 */ asn_DEF_UEInformationResponse_r16_tags_1, /* Same as above */ sizeof(asn_DEF_UEInformationResponse_r16_tags_1) /sizeof(asn_DEF_UEInformationResponse_r16_tags_1[0]), /* 1 */ { 0, 0, SEQUENCE_constraint }, asn_MBR_UEInformationResponse_r16_1, 2, /* Elements count */ &asn_SPC_UEInformationResponse_r16_specs_1 /* Additional specs */ };
38.575342
116
0.752308
69e640ebb28fe6234d43bf69b2d9252a80b72021
830
c
C
libraries/datastruct/linkedlist/walk-internal.c
clayne/Containers
7db1e5a8f4ef729273cdbebc4afa2f6b98cd8c2a
[ "BSD-2-Clause" ]
18
2015-03-28T06:11:38.000Z
2022-01-22T10:16:26.000Z
libraries/datastruct/linkedlist/walk-internal.c
clayne/Containers
7db1e5a8f4ef729273cdbebc4afa2f6b98cd8c2a
[ "BSD-2-Clause" ]
null
null
null
libraries/datastruct/linkedlist/walk-internal.c
clayne/Containers
7db1e5a8f4ef729273cdbebc4afa2f6b98cd8c2a
[ "BSD-2-Clause" ]
6
2017-02-11T12:45:14.000Z
2020-09-22T04:47:45.000Z
/* -------------------------------------------------------------------------- * Name: walk-internal.c * Purpose: Associative array implemented as a linked list * ----------------------------------------------------------------------- */ #include <stdlib.h> #include "base/errors.h" #include "datastruct/linkedlist.h" #include "impl.h" error linkedlist__walk_internal(linkedlist_t *t, linkedlist__walk_internal_callback *cb, void *opaque) { error err; linkedlist__node_t *n; linkedlist__node_t *next; if (t == NULL) return error_OK; for (n = t->anchor; n; n = next) { next = n->next; err = cb(n, opaque); if (err) return err; } return error_OK; }
22.432432
77
0.43494
b8afc172c51f88ddc6ae77c26561b903bf03dcc1
24,453
h
C
u-boot-2009.08/include/configs/ADNPESC1.h
isabella232/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
10
2015-02-28T21:05:37.000Z
2021-09-16T04:57:27.000Z
u-boot-2009.08/include/configs/ADNPESC1.h
SanDisk-Open-Source/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
1
2021-02-24T05:16:58.000Z
2021-02-24T05:16:58.000Z
u-boot-2009.08/include/configs/ADNPESC1.h
isabella232/wireless-media-drive
ab09fbd1194c8148131cf0a37425419253a137b0
[ "Apache-2.0" ]
5
2018-11-19T16:42:53.000Z
2021-12-07T12:39:23.000Z
/* * (C) Copyright 2004, Li-Pro.Net <www.li-pro.net> * Stephan Linz <linz@li-pro.net> * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef __CONFIG_H #define __CONFIG_H /*********************************************************************** * Include the whole NIOS CPU configuration. * * !!! HAVE TO BE HERE !!! DON'T MOVE THIS PART !!! * ***********************************************************************/ #if defined(CONFIG_NIOS_BASE_32) #include <configs/ADNPESC1_base_32.h> #else #error *** CONFIG_SYS_ERROR: you have to setup right NIOS CPU configuration #endif /*------------------------------------------------------------------------ * BOARD/CPU -- TOP-LEVEL *----------------------------------------------------------------------*/ #define CONFIG_NIOS 1 /* NIOS-32 core */ #define CONFIG_ADNPESC1 1 /* SSV ADNP/ESC1 board */ #define CONFIG_SYS_CLK_FREQ CONFIG_SYS_NIOS_CPU_CLK/* 50 MHz core clock */ #define CONFIG_SYS_HZ 1000 /* 1 msec time tick */ #define CONFIG_BOARD_EARLY_INIT_F 1 /* enable early board-spec. init*/ /*------------------------------------------------------------------------ * BASE ADDRESSES / SIZE (Flash, SRAM, SDRAM) *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_SDRAM_SIZE != 0) #define CONFIG_SYS_SDRAM_BASE CONFIG_SYS_NIOS_CPU_SDRAM_BASE #define CONFIG_SYS_SDRAM_SIZE CONFIG_SYS_NIOS_CPU_SDRAM_SIZE #else #error *** CONFIG_SYS_ERROR: you have to setup any SDRAM in NIOS CPU config #endif #if defined(CONFIG_SYS_NIOS_CPU_SRAM_BASE) && defined(CONFIG_SYS_NIOS_CPU_SRAM_SIZE) #define CONFIG_SYS_SRAM_BASE CONFIG_SYS_NIOS_CPU_SRAM_BASE #define CONFIG_SYS_SRAM_SIZE CONFIG_SYS_NIOS_CPU_SRAM_SIZE #else #undef CONFIG_SYS_SRAM_BASE #undef CONFIG_SYS_SRAM_SIZE #endif #define CONFIG_SYS_VECT_BASE CONFIG_SYS_NIOS_CPU_VEC_BASE /*------------------------------------------------------------------------ * MEMORY ORGANIZATION - For the most part, you can put things pretty * much anywhere. This is pretty flexible for Nios. So here we make some * arbitrary choices & assume that the monitor is placed at the end of * a memory resource (so you must make sure TEXT_BASE is chosen * appropriately -- this is very important if you plan to move your * memory to another place as configured at this time !!!). * * -The heap is placed below the monitor. * -Global data is placed below the heap. * -The stack is placed below global data (&grows down). *----------------------------------------------------------------------*/ #define CONFIG_SYS_MONITOR_LEN (256 * 1024) /* Reserve 256k */ #define CONFIG_SYS_GBL_DATA_SIZE 128 /* Global data size rsvd*/ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CONFIG_SYS_MONITOR_BASE TEXT_BASE #define CONFIG_SYS_MALLOC_BASE (CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN) #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_MALLOC_BASE - CONFIG_SYS_GBL_DATA_SIZE) #define CONFIG_SYS_INIT_SP CONFIG_SYS_GBL_DATA_OFFSET /*------------------------------------------------------------------------ * FLASH (AM29LV065D) *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_FLASH_SIZE != 0) #define CONFIG_SYS_FLASH_BASE CONFIG_SYS_NIOS_CPU_FLASH_BASE #define CONFIG_SYS_FLASH_SIZE CONFIG_SYS_NIOS_CPU_FLASH_SIZE #define CONFIG_SYS_MAX_FLASH_SECT 128 /* Max # sects per bank */ #define CONFIG_SYS_MAX_FLASH_BANKS 1 /* Max # of flash banks */ #define CONFIG_SYS_FLASH_ERASE_TOUT 8000 /* Erase timeout (msec) */ #define CONFIG_SYS_FLASH_WRITE_TOUT 100 /* Write timeout (msec) */ #define CONFIG_SYS_FLASH_WORD_SIZE unsigned short /* flash word size */ #else #error *** CONFIG_SYS_ERROR: you have to setup any Flash memory in NIOS CPU config #endif /*------------------------------------------------------------------------ * ENVIRONMENT *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_FLASH_SIZE != 0) #define CONFIG_ENV_IS_IN_FLASH 1 /* Environment in flash */ /* Mem addr of environment */ #if defined(CONFIG_NIOS_BASE_32) #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN) #else #error *** CONFIG_SYS_ERROR: you have to setup the environment base address CONFIG_ENV_ADDR #endif #define CONFIG_ENV_SIZE (64 * 1024) /* 64 KByte (1 sector) */ #define CONFIG_ENV_OVERWRITE /* Serial/eth change Ok */ #else #define CONFIG_ENV_IS_NOWHERE 1 /* NO Environment */ #endif /*------------------------------------------------------------------------ * NIOS APPLICATION CODE BASE AREA *----------------------------------------------------------------------*/ #if ((CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) == 0x1050000) #define CONFIG_SYS_ADNPESC1_UPDATE_LOAD_ADDR "0x2000100" #define CONFIG_SYS_ADNPESC1_NIOS_APPL_ENTRY "0x1050000" #define CONFIG_SYS_ADNPESC1_NIOS_APPL_IDENT "0x105000c" #define CONFIG_SYS_ADNPESC1_NIOS_APPL_END "0x11fffff" #define CONFIG_SYS_ADNPESC1_FILESYSTEM_BASE "0x1200000" #define CONFIG_SYS_ADNPESC1_FILESYSTEM_END "0x17fffff" #else #error *** CONFIG_SYS_ERROR: missing right appl.code base configuration, expand your config.h #endif #define CONFIG_SYS_ADNPESC1_NIOS_IDENTIFIER "Nios" /*------------------------------------------------------------------------ * BOOT ENVIRONMENT *----------------------------------------------------------------------*/ #ifdef CONFIG_DNPEVA2 /* DNP/EVA2 base board */ #define CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF "sled boot off; " #define CONFIG_SYS_ADNPESC1_SLED_RED_BLINK "sled red blink; " #else #define CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF #define CONFIG_SYS_ADNPESC1_SLED_RED_BLINK #endif #define CONFIG_BOOTDELAY 5 #define CONFIG_BOOTCOMMAND \ "if itest.s *$appl_ident_addr == \"$appl_ident_str\"; " \ "then " \ "wd off; " \ CONFIG_SYS_ADNPESC1_SLED_BOOT_OFF \ "go $appl_entry_addr; " \ "else " \ CONFIG_SYS_ADNPESC1_SLED_RED_BLINK \ "echo *** missing \"$appl_ident_str\" at $appl_ident_addr; "\ "echo *** invalid application at $appl_entry_addr; " \ "echo *** stop bootup...; " \ "fi" /*------------------------------------------------------------------------ * EXTRA ENVIRONMENT *----------------------------------------------------------------------*/ #ifdef CONFIG_DNPEVA2 /* DNP/EVA2 base board */ #define CONFIG_SYS_ADNPESC1_SLED_YELLO_ON "sled yellow on; " #define CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF "sled yellow off; " #else #define CONFIG_SYS_ADNPESC1_SLED_YELLO_ON #define CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF #endif #define CONFIG_EXTRA_ENV_SETTINGS \ "update_allowed=0\0" \ "update_load_addr=" CONFIG_SYS_ADNPESC1_UPDATE_LOAD_ADDR "\0" \ "appl_entry_addr=" CONFIG_SYS_ADNPESC1_NIOS_APPL_ENTRY "\0" \ "appl_end_addr=" CONFIG_SYS_ADNPESC1_NIOS_APPL_END "\0" \ "appl_ident_addr=" CONFIG_SYS_ADNPESC1_NIOS_APPL_IDENT "\0" \ "appl_ident_str=" CONFIG_SYS_ADNPESC1_NIOS_IDENTIFIER "\0" \ "appl_name=ADNPESC1/base32/linux.bin\0" \ "appl_update=" \ "if itest.b $update_allowed != 0; " \ "then " \ CONFIG_SYS_ADNPESC1_SLED_YELLO_ON \ "tftp $update_load_addr $appl_name; " \ "protect off $appl_entry_addr $appl_end_addr; " \ "era $appl_entry_addr $appl_end_addr; " \ "cp.b $update_load_addr $appl_entry_addr $filesize; "\ CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF \ "else " \ "echo *** update not allowed (update_allowed=$update_allowed); "\ "fi\0" \ "fs_base_addr=" CONFIG_SYS_ADNPESC1_FILESYSTEM_BASE "\0" \ "fs_end_addr=" CONFIG_SYS_ADNPESC1_FILESYSTEM_END "\0" \ "fs_name=ADNPESC1/base32/romfs.img\0" \ "fs_update=" \ "if itest.b $update_allowed != 0; " \ "then " \ CONFIG_SYS_ADNPESC1_SLED_YELLO_ON \ "tftp $update_load_addr $fs_name; " \ "protect off $fs_base_addr $fs_end_addr; " \ "era $fs_base_addr $fs_end_addr; " \ "cp.b $update_load_addr $fs_base_addr $filesize; "\ CONFIG_SYS_ADNPESC1_SLED_YELLO_OFF \ "else " \ "echo *** update not allowed (update_allowed=$update_allowed); "\ "fi\0" \ "uboot_name=ADNPESC1/base32/u-boot.bin\0" \ "uboot_loadnrun=" \ "if ping $serverip; " \ "then " \ CONFIG_SYS_ADNPESC1_SLED_YELLO_ON \ "tftp $update_load_addr $uboot_name; " \ "wd off; " \ "go $update_load_addr; " \ "else " \ "echo *** missing connection to $serverip; " \ "echo *** check your network and try again...; "\ "fi\0" /*------------------------------------------------------------------------ * CONSOLE *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_UART_NUMS != 0) #define CONFIG_SYS_NIOS_CONSOLE CONFIG_SYS_NIOS_CPU_UART0 /* 1st UART is Cons. */ #if (CONFIG_SYS_NIOS_CPU_UART0_BR != 0) #define CONFIG_SYS_NIOS_FIXEDBAUD 1 /* Baudrate is fixed */ #define CONFIG_BAUDRATE CONFIG_SYS_NIOS_CPU_UART0_BR #else #undef CONFIG_SYS_NIOS_FIXEDBAUD #define CONFIG_BAUDRATE 115200 #endif #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } #else #error *** CONFIG_SYS_ERROR: you have to setup at least one UART in NIOS CPU config #endif /*------------------------------------------------------------------------ * TIMER FOR TIMEBASE -- Nios doesn't have the equivalent of ppc PIT, * so an avalon bus timer is required. *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_TIMER_NUMS != 0) && defined(CONFIG_SYS_NIOS_CPU_TICK_TIMER) #if (CONFIG_SYS_NIOS_CPU_TICK_TIMER == 0) #define CONFIG_SYS_NIOS_TMRBASE CONFIG_SYS_NIOS_CPU_TIMER0 /* TIMER0 as tick */ #define CONFIG_SYS_NIOS_TMRIRQ CONFIG_SYS_NIOS_CPU_TIMER0_IRQ #if (CONFIG_SYS_NIOS_CPU_TIMER0_FP == 1) /* fixed period */ #if (CONFIG_SYS_NIOS_CPU_TIMER0_PER >= CONFIG_SYS_HZ) #define CONFIG_SYS_NIOS_TMRMS (CONFIG_SYS_NIOS_CPU_TIMER0_PER / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: you have to use a timer periode greater than CONFIG_SYS_HZ #endif #undef CONFIG_SYS_NIOS_TMRCNT /* no preloadable counter value */ #elif (CONFIG_SYS_NIOS_CPU_TIMER0_FP == 0) /* variable period */ #if (CONFIG_SYS_HZ <= 1000) #define CONFIG_SYS_NIOS_TMRMS (1000 / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: sorry, CONFIG_SYS_HZ have to be less than 1000 #endif #define CONFIG_SYS_NIOS_TMRCNT (CONFIG_SYS_CLK_FREQ / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: you have to define CONFIG_SYS_NIOS_CPU_TIMER0_FP correct #endif #elif (CONFIG_SYS_NIOS_CPU_TICK_TIMER == 1) #define CONFIG_SYS_NIOS_TMRBASE CONFIG_SYS_NIOS_CPU_TIMER1 /* TIMER1 as tick */ #define CONFIG_SYS_NIOS_TMRIRQ CONFIG_SYS_NIOS_CPU_TIMER1_IRQ #if (CONFIG_SYS_NIOS_CPU_TIMER1_FP == 1) /* fixed period */ #if (CONFIG_SYS_NIOS_CPU_TIMER1_PER >= CONFIG_SYS_HZ) #define CONFIG_SYS_NIOS_TMRMS (CONFIG_SYS_NIOS_CPU_TIMER1_PER / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: you have to use a timer periode greater than CONFIG_SYS_HZ #endif #undef CONFIG_SYS_NIOS_TMRCNT /* no preloadable counter value */ #elif (CONFIG_SYS_NIOS_CPU_TIMER1_FP == 0) /* variable period */ #if (CONFIG_SYS_HZ <= 1000) #define CONFIG_SYS_NIOS_TMRMS (1000 / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: sorry, CONFIG_SYS_HZ have to be less than 1000 #endif #define CONFIG_SYS_NIOS_TMRCNT (CONFIG_SYS_CLK_FREQ / CONFIG_SYS_HZ) #else #error *** CONFIG_SYS_ERROR: you have to define CONFIG_SYS_NIOS_CPU_TIMER1_FP correct #endif #endif /* CONFIG_SYS_NIOS_CPU_TICK_TIMER */ #else #error *** CONFIG_SYS_ERROR: you have to setup at least one TIMER in NIOS CPU config #endif /*------------------------------------------------------------------------ * WATCHDOG (or better MAX823 supervisory circuite access) *----------------------------------------------------------------------*/ #define CONFIG_HW_WATCHDOG 1 /* board specific WD */ #ifdef CONFIG_HW_WATCHDOG /* MAX823 supervisor -- watchdog enable port at: */ #if (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 0) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO0 /* PIO0 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 1) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO1 /* PIO1 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 2) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO2 /* PIO2 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 3) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO3 /* PIO3 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 4) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO4 /* PIO4 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 5) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO5 /* PIO5 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 6) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO6 /* PIO6 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 7) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO7 /* PIO7 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 8) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO8 /* PIO8 */ #elif (CONFIG_SYS_NIOS_CPU_WDENA_PIO == 9) #define CONFIG_HW_WDENA_BASE CONFIG_SYS_NIOS_CPU_PIO9 /* PIO9 */ #else #error *** CONFIG_SYS_ERROR: you have to setup at least one WDENA_PIO in NIOS CPU config #endif /* MAX823 supervisor -- watchdog trigger port at: */ #if (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 0) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO0 /* PIO0 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 1) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO1 /* PIO1 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 2) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO2 /* PIO2 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 3) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO3 /* PIO3 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 4) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO4 /* PIO4 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 5) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO5 /* PIO5 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 6) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO6 /* PIO6 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 7) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO7 /* PIO7 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 8) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO8 /* PIO8 */ #elif (CONFIG_SYS_NIOS_CPU_WDTOG_PIO == 9) #define CONFIG_HW_WDTOG_BASE CONFIG_SYS_NIOS_CPU_PIO9 /* PIO9 */ #else #error *** CONFIG_SYS_ERROR: you have to setup at least one WDTOG_PIO in NIOS CPU config #endif #if defined(CONFIG_NIOS_BASE_32) /* NIOS CPU specifics */ #define CONFIG_HW_WDENA_BIT 0 /* WD enable @ Bit 0 */ #define CONFIG_HW_WDTOG_BIT 0 /* WD trigger @ Bit 0 */ #define CONFIG_HW_WDPORT_WRONLY 1 /* each WD port wr/only*/ #else #error *** CONFIG_SYS_ERROR: missing watchdog bit configuration, expand your config.h #endif #endif /* CONFIG_HW_WATCHDOG */ /*------------------------------------------------------------------------ * SERIAL PERIPHAREL INTERFACE *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_SPI_NUMS == 1) #define CONFIG_NIOS_SPI 1 /* SPI support active */ #define CONFIG_SYS_NIOS_SPIBASE CONFIG_SYS_NIOS_CPU_SPI0 #define CONFIG_SYS_NIOS_SPIBITS CONFIG_SYS_NIOS_CPU_SPI0_BITS #define CONFIG_RTC_DS1306 1 /* Dallas 1306 real time clock */ #define CONFIG_SYS_SPI_RTC_DEVID 0 /* as 1st SPI device */ #else #undef CONFIG_NIOS_SPI /* NO SPI support */ #endif /*------------------------------------------------------------------------ * Ethernet -- needs work! *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_LAN_NUMS == 1) #if (CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 0) /* LAN91C111 */ #define CONFIG_DRIVER_SMC91111 /* Using SMC91c111 */ #undef CONFIG_SMC91111_EXT_PHY /* Internal PHY */ #define CONFIG_SMC91111_BASE (CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS) #if (CONFIG_SYS_NIOS_CPU_LAN0_BUSW == 32) #define CONFIG_SMC_USE_32_BIT 1 #else /* no */ #undef CONFIG_SMC_USE_32_BIT #endif #elif (CONFIG_SYS_NIOS_CPU_LAN0_TYPE == 1) /* CS8900A */ /********************************************/ /* !!! CS8900 is __not__ tested on NIOS !!! */ /********************************************/ #define CONFIG_DRIVER_CS8900 /* Using CS8900 */ #define CS8900_BASE (CONFIG_SYS_NIOS_CPU_LAN0_BASE + CONFIG_SYS_NIOS_CPU_LAN0_OFFS) #if (CONFIG_SYS_NIOS_CPU_LAN0_BUSW == 32) #undef CS8900_BUS16 #define CS8900_BUS32 1 #else /* no */ #define CS8900_BUS16 1 #undef CS8900_BUS32 #endif #else #error *** CONFIG_SYS_ERROR: invalid LAN0 chip type, check your NIOS CPU config #endif #define CONFIG_ETHADDR 02:80:ae:20:60:6f #define CONFIG_NETMASK 255.255.255.248 #define CONFIG_IPADDR 192.168.161.84 #define CONFIG_SERVERIP 192.168.161.85 #else #error *** CONFIG_SYS_ERROR: you have to setup just one LAN only or expand your config.h #endif /*------------------------------------------------------------------------ * STATUS LEDs *----------------------------------------------------------------------*/ #if (CONFIG_SYS_NIOS_CPU_PIO_NUMS != 0) && defined(CONFIG_SYS_NIOS_CPU_LED_PIO) #if (CONFIG_SYS_NIOS_CPU_LED_PIO == 0) #define STATUS_LED_BASE CONFIG_SYS_NIOS_CPU_PIO0 #define STATUS_LED_BITS CONFIG_SYS_NIOS_CPU_PIO0_BITS #define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */ #if (CONFIG_SYS_NIOS_CPU_PIO0_TYPE == 1) #define STATUS_LED_WRONLY 1 #else #undef STATUS_LED_WRONLY #endif #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 1) #define STATUS_LED_BASE CONFIG_SYS_NIOS_CPU_PIO1 #define STATUS_LED_BITS CONFIG_SYS_NIOS_CPU_PIO1_BITS #define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */ #if (CONFIG_SYS_NIOS_CPU_PIO1_TYPE == 1) #define STATUS_LED_WRONLY 1 #else #undef STATUS_LED_WRONLY #endif #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 2) #define STATUS_LED_BASE CONFIG_SYS_NIOS_CPU_PIO2 #define STATUS_LED_BITS CONFIG_SYS_NIOS_CPU_PIO2_BITS #define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */ #if (CONFIG_SYS_NIOS_CPU_PIO2_TYPE == 1) #define STATUS_LED_WRONLY 1 #else #undef STATUS_LED_WRONLY #endif #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 3) #error *** CONFIG_SYS_ERROR: status LEDs at PIO3 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 4) #error *** CONFIG_SYS_ERROR: status LEDs at PIO4 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 5) #error *** CONFIG_SYS_ERROR: status LEDs at PIO5 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 6) #error *** CONFIG_SYS_ERROR: status LEDs at PIO6 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 7) #error *** CONFIG_SYS_ERROR: status LEDs at PIO7 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 8) #error *** CONFIG_SYS_ERROR: status LEDs at PIO8 not supported, expand your config.h #elif (CONFIG_SYS_NIOS_CPU_LED_PIO == 9) #error *** CONFIG_SYS_ERROR: status LEDs at PIO9 not supported, expand your config.h #else #error *** CONFIG_SYS_ERROR: you have to set CONFIG_SYS_NIOS_CPU_LED_PIO in right case #endif #define CONFIG_STATUS_LED 1 /* enable status led driver */ #define STATUS_LED_BIT (1 << 0) /* LED[0] */ #define STATUS_LED_STATE STATUS_LED_BLINKING #define STATUS_LED_BOOT_STATE STATUS_LED_OFF #define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) /* ca. 1 Hz */ #define STATUS_LED_BOOT 0 /* boot LED */ #if (STATUS_LED_BITS > 1) #define STATUS_LED_BIT1 (1 << 1) /* LED[1] */ #define STATUS_LED_STATE1 STATUS_LED_OFF #define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 10) /* ca. 5 Hz */ #define STATUS_LED_RED 1 /* fail LED */ #endif #if (STATUS_LED_BITS > 2) #define STATUS_LED_BIT2 (1 << 2) /* LED[2] */ #define STATUS_LED_STATE2 STATUS_LED_OFF #define STATUS_LED_PERIOD2 (CONFIG_SYS_HZ / 2) /* ca. 1 Hz */ #define STATUS_LED_YELLOW 2 /* info LED */ #endif #if (STATUS_LED_BITS > 3) #define STATUS_LED_BIT3 (1 << 3) /* LED[3] */ #define STATUS_LED_STATE3 STATUS_LED_OFF #define STATUS_LED_PERIOD3 (CONFIG_SYS_HZ / 2) /* ca. 1 Hz */ #define STATUS_LED_GREEN 3 /* info LED */ #endif #define STATUS_LED_PAR 1 /* makes status_led.h happy */ #endif /* CONFIG_SYS_NIOS_CPU_PIO_NUMS */ /*------------------------------------------------------------------------ * Diagnostics / Power On Self Tests *----------------------------------------------------------------------*/ #define CONFIG_POST CONFIG_SYS_POST_RTC #define CONFIG_SYS_NIOS_POST_WORD_ADDR (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) /* * BOOTP options */ #define CONFIG_BOOTP_BOOTFILESIZE #define CONFIG_BOOTP_BOOTPATH #define CONFIG_BOOTP_GATEWAY #define CONFIG_BOOTP_HOSTNAME /* * Command line configuration. */ #include <config_cmd_default.h> #define CONFIG_CMD_BSP #define CONFIG_CMD_CDP #define CONFIG_CMD_DHCP #define CONFIG_CMD_DIAG #define CONFIG_CMD_DISPLAY #define CONFIG_CMD_EXT2 #define CONFIG_CMD_IMMAP #define CONFIG_CMD_IRQ #define CONFIG_CMD_PING #define CONFIG_CMD_PORTIO #define CONFIG_CMD_REGINFO #define CONFIG_CMD_REISER #define CONFIG_CMD_SAVES #define CONFIG_CMD_SDRAM #define CONFIG_CMD_SNTP #undef CONFIG_CMD_NFS #undef CONFIG_CMD_XIMG #if (CONFIG_SYS_NIOS_CPU_SPI_NUMS == 1) #define CONFIG_CMD_DATE #define CONFIG_CMD_SPI #endif /*------------------------------------------------------------------------ * KGDB *----------------------------------------------------------------------*/ #if defined(CONFIG_CMD_KGDB) #define CONFIG_KGDB_BAUDRATE 9600 #endif /*------------------------------------------------------------------------ * MISC *----------------------------------------------------------------------*/ #define CONFIG_SYS_LONGHELP /* undef to save memory */ #define CONFIG_SYS_HUSH_PARSER 1 /* use "hush" command parser undef to save memory */ #define CONFIG_SYS_PROMPT "ADNPESC1 > " /* Monitor Command Prompt */ #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */ #define CONFIG_SYS_MAXARGS 64 /* max number of command args*/ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */ #ifdef CONFIG_SYS_HUSH_PARSER #define CONFIG_SYS_PROMPT_HUSH_PS2 "[]> " #endif /* Default load address */ #if (CONFIG_SYS_SRAM_SIZE != 0) /* default in SRAM */ #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SRAM_BASE #elif (CONFIG_SYS_SDRAM_SIZE != 0) /* default in SDRAM */ #if (CONFIG_SYS_SDRAM_BASE == CONFIG_SYS_NIOS_CPU_VEC_BASE) #if 1 #define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_NIOS_CPU_VEC_SIZE) #else #define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + 0x400000) #endif #else #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE #endif #else #undef CONFIG_SYS_LOAD_ADDR /* force error break */ #endif /* MEM test area */ #if (CONFIG_SYS_SDRAM_SIZE != 0) /* SDRAM begin to stack area (1MB stack) */ #if (CONFIG_SYS_SDRAM_BASE == CONFIG_SYS_NIOS_CPU_VEC_BASE) #if 0 #define CONFIG_SYS_MEMTEST_START (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_NIOS_CPU_VEC_SIZE) #else #define CONFIG_SYS_MEMTEST_START (CONFIG_SYS_SDRAM_BASE + 0x400000) #endif #else #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE #endif #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_INIT_SP - (1024 * 1024)) #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_INIT_SP - (1024 * 1024)) #else #undef CONFIG_SYS_MEMTEST_START /* force error break */ #undef CONFIG_SYS_MEMTEST_END #endif /* * JFFS2 partitions * */ /* No command line, one static partition */ #undef CONFIG_CMD_MTDPARTS #define CONFIG_JFFS2_DEV "nor" #define CONFIG_JFFS2_PART_SIZE 0xFFFFFFFF #define CONFIG_JFFS2_PART_OFFSET 0x00000000 /* mtdparts command line support */ /* #define CONFIG_CMD_MTDPARTS #define MTDIDS_DEFAULT "" #define MTDPARTS_DEFAULT "" */ #endif /* __CONFIG_H */
35.542151
98
0.678853
b8f1dd0c5b9ea06e13f03bf0c5a54d2a3d4cbd34
6,801
c
C
test.c
TTWNO/morse-in-c
a86a44c41f80f34a53a4ef48c96a233611857892
[ "BSD-3-Clause" ]
null
null
null
test.c
TTWNO/morse-in-c
a86a44c41f80f34a53a4ef48c96a233611857892
[ "BSD-3-Clause" ]
null
null
null
test.c
TTWNO/morse-in-c
a86a44c41f80f34a53a4ef48c96a233611857892
[ "BSD-3-Clause" ]
null
null
null
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "morse.h" int tests_run = 0; int tests_passed = 0; int tests_failed = 0; const char* FAIL = "FAIL"; const char* PASS = "PASS"; const char* EQ = "=="; const char* NEQ = "!="; const char* GREEN_TEXT = "\e[32m"; const char* RED_TEXT = "\e[31m"; const char* CLEAR_FORMAT = "\e[0m"; const char* BOLD_TEXT = "\e[1m"; const char* PASS_FORMAT = "\e[32m[%s]: \"%s\" %s \"%s\"\e[0m\n"; const char* FAIL_FORMAT = "\e[31m[%s]: \"%s\" %s \"%s\"\e[0m\n"; const char* PASS_CHAR_FORMAT = "\e[32m[%s]: \'%c\' %s \'%c\'\e[0m\n"; const char* FAIL_CHAR_FORMAT = "\e[31m[%s]: \'%c\' %s \'%c\'\e[0m\n"; const char* FUNCTION_CALL_CFORMAT = "%s(\'%c\'):\n"; const char* FUNCTION_CALL_SFORMAT = "%s(\"%s\"):\n"; void assert_char_eq(const char c1, const char c2){ tests_run++; if (c1 == c2){ printf(PASS_CHAR_FORMAT, PASS, c1, EQ, c2); tests_passed++; } else { printf(FAIL_CHAR_FORMAT, FAIL, c1, NEQ, c2); tests_failed++; } } void assert_str_eq(const char* s1, const char* s2){ tests_run++; if (strcmp(s1, s2) == 0){ printf(PASS_FORMAT, PASS, s1, EQ, s2); tests_passed++; } else { printf(FAIL_FORMAT, FAIL, s1, NEQ, s2); tests_failed++; } } void assert_str_neq(const char* s1, const char* s2){ tests_run++; if (strcmp(s1, s2) != 0){ printf(PASS_FORMAT, PASS, s1, NEQ, s2); tests_passed++; } else { printf(FAIL_FORMAT, FAIL, s1, EQ, s2); tests_failed++; } } void assert_ctm(char input, char* output){ char result[8]; char_to_morse(input, result); printf(FUNCTION_CALL_CFORMAT, "char_to_morse", input); assert_str_eq(result, output); } void assert_stm(char* input, char* output){ char result[strlen(input) * 7]; strcpy(result, ""); string_to_morse(input, result); printf(FUNCTION_CALL_SFORMAT, "string_to_morse", input); assert_str_eq(result, output); } void assert_mtc(char* input, char output){ char result = morse_to_char(input); printf(FUNCTION_CALL_SFORMAT, "morse_to_char", input); assert_char_eq(result, output); } void assert_mts(char* input, char* output){ char result[strlen(input) * 7]; strcpy(result, ""); morse_to_string(input, result); printf(FUNCTION_CALL_SFORMAT, "morse_to_string", input); assert_str_eq(result, output); } void test_tests(){ assert_str_eq(".", "."); assert_str_neq("+", "-"); } void test_to_morse(){ assert_ctm('a', ".-"); assert_ctm('A', ".-"); assert_ctm('b', "-..."); assert_ctm('B', "-..."); assert_ctm('c', "-.-."); assert_ctm('C', "-.-."); assert_ctm('d', "-.."); assert_ctm('D', "-.."); assert_ctm('e', "."); assert_ctm('E', "."); assert_ctm('f', "..-."); assert_ctm('F', "..-."); assert_ctm('g', "--."); assert_ctm('G', "--."); assert_ctm('h', "...."); assert_ctm('H', "...."); assert_ctm('i', ".."); assert_ctm('I', ".."); assert_ctm('j', ".---"); assert_ctm('J', ".---"); assert_ctm('k', "-.-"); assert_ctm('K', "-.-"); assert_ctm('l', ".-.."); assert_ctm('L', ".-.."); assert_ctm('m', "--"); assert_ctm('M', "--"); assert_ctm('n', "-."); assert_ctm('N', "-."); assert_ctm('o', "---"); assert_ctm('O', "---"); assert_ctm('p', ".--."); assert_ctm('P', ".--."); assert_ctm('q', "--.-"); assert_ctm('Q', "--.-"); assert_ctm('r', ".-."); assert_ctm('R', ".-."); assert_ctm('s', "..."); assert_ctm('S', "..."); assert_ctm('t', "-"); assert_ctm('T', "-"); assert_ctm('u', "..-"); assert_ctm('U', "..-"); assert_ctm('v', "...-"); assert_ctm('V', "...-"); assert_ctm('w', ".--"); assert_ctm('W', ".--"); assert_ctm('x', "-..-"); assert_ctm('X', "-..-"); assert_ctm('y', "-.--"); assert_ctm('Y', "-.--"); assert_ctm('z', "--.."); assert_ctm('0', "-----"); assert_ctm('1', ".----"); assert_ctm('2', "..---"); assert_ctm('3', "...--"); assert_ctm('4', "....-"); assert_ctm('5', "....."); assert_ctm('6', "-...."); assert_ctm('7', "--..."); assert_ctm('8', "---.."); assert_ctm('9', "----."); assert_ctm(' ', "/"); assert_ctm('!', "-.-.--"); } void test_string_to_morse(){ assert_stm("Wee!", ".-- . . -.-.--"); assert_stm("Hello", ".... . .-.. .-.. ---"); assert_stm("world", ".-- --- .-. .-.. -.."); assert_stm("Hello world!", ".... . .-.. .-.. --- / .-- --- .-. .-.. -.. -.-.--"); assert_stm("I! HATE! YOU!", ".. -.-.-- / .... .- - . -.-.-- / -.-- --- ..- -.-.--"); assert_stm("Whisky and rye", ".-- .... .. ... -.- -.-- / .- -. -.. / .-. -.-- ."); } void test_morse_to_char(){ assert_mtc(".-", 'A'); assert_mtc("-...", 'B'); assert_mtc("-.-.", 'C'); assert_mtc("-..", 'D'); assert_mtc(".", 'E'); assert_mtc("..-.", 'F'); assert_mtc("--.", 'G'); assert_mtc("....", 'H'); assert_mtc("..", 'I'); assert_mtc(".---", 'J'); assert_mtc("-.-", 'K'); assert_mtc(".-..", 'L'); assert_mtc("--", 'M'); assert_mtc("-.", 'N'); assert_mtc("---", 'O'); assert_mtc(".--.", 'P'); assert_mtc("--.-", 'Q'); assert_mtc(".-.", 'R'); assert_mtc("...", 'S'); assert_mtc("-", 'T'); assert_mtc("..-", 'U'); assert_mtc("...-", 'V'); assert_mtc(".--", 'W'); assert_mtc("-..-", 'X'); assert_mtc("-.--", 'Y'); assert_mtc("--..", 'Z'); } void test_morse_to_string(){ assert_mts("... --- ...", "SOS"); assert_mts(". . . . .", "EEEEE"); assert_mts("- ... ....", "TSH"); assert_mts("- - - - ... ... ... ... .... .... .... .... / .... .. .. .. ..", "TTTTSSSSHHHH HIIII"); assert_mts("- .- .-. ..-. / -- .- .-.. .- -.- --- ...-", "TARF MALAKOV"); assert_mts("- .- .. -", "TAIT"); assert_mts("- .- .-.. -.-", "TALK"); assert_mts("- .- ... -.- / -- .- ... - . .-.", "TASK MASTER"); assert_mts("- .- .-. ..-. / -- .- .-.. .- -.- --- ...-", "TARF MALAKOV"); assert_mts("- .- ..-", "TAU"); } void all_tests(){ test_tests(); printf("test_tests tests complete!\n"); test_to_morse(); printf("char_to_morse tests complete!\n"); test_string_to_morse(); printf("string_to_morse tests complete!\n"); test_morse_to_char(); printf("test_morse_to_char tests complete!\n"); test_morse_to_string(); printf("test_morse_to_string tests complete!\n"); } int main(int argc, char **argv) { //bool done_printing_passed_tests = false; all_tests(); if (tests_run == tests_passed){ printf("ALL TESTS PASSED\n"); } printf(RED_TEXT); for (int i = 0; i < tests_failed; i++){ printf("="); } printf(CLEAR_FORMAT); printf(GREEN_TEXT); for (int i = 0; i < tests_passed; i++){ printf("="); } printf("\n"); printf(CLEAR_FORMAT); printf("Tests run: %d", tests_run); printf(" | "); printf(BOLD_TEXT); printf(GREEN_TEXT); printf("%d passed", tests_passed); printf(CLEAR_FORMAT); printf(" | "); printf(BOLD_TEXT); printf(RED_TEXT); printf("%d failed \n", tests_failed); printf(CLEAR_FORMAT); return 0; }
26.360465
100
0.524041