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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4ab898c0188f53bfefc9de32f87453d66e6ce322 | 12,588 | c | C | hal/modules/Startrampe-TOSV_v1.0.c | trinamic/TOSV-Firmware | 5a7547d4f7651b12cb6d42ffa7a5a11b241601fc | [
"MIT"
] | 3 | 2020-04-18T01:47:30.000Z | 2021-07-26T15:58:18.000Z | hal/modules/Startrampe-TOSV_v1.0.c | trinamic/TOSV-Firmware | 5a7547d4f7651b12cb6d42ffa7a5a11b241601fc | [
"MIT"
] | null | null | null | hal/modules/Startrampe-TOSV_v1.0.c | trinamic/TOSV-Firmware | 5a7547d4f7651b12cb6d42ffa7a5a11b241601fc | [
"MIT"
] | 1 | 2020-10-05T21:49:02.000Z | 2020-10-05T21:49:02.000Z | /*
* Startrampe-TOSV.c
*
* Created on: 31.03.2020
* Author: ED
*/
#include "BLDC.h"
#include "Startrampe-TOSV_v1.0.h"
#if DEVICE==STARTRAMPE_TOSV_V10
// general module settings
const char *VersionString="0020V101";
uint32_t PLL_M = 8;
uint32_t PLL_N = 120;
// ADC configuration
#define ADC1_DR_ADDRESS ((uint32_t)0x4001204C)
#define ADC1_CHANNELS 3
static volatile uint16_t ADC1Value[ADC1_CHANNELS]; // array for analog values (filled by DMA)
// ADC1
uint8_t ADC_VOLTAGE = 0; // unused
uint8_t ADC_MOT_TEMP = 0; // unused
void tmcm_initModuleConfig()
{
moduleConfig.baudrate = 7; // UART 115200bps
moduleConfig.serialModuleAddress = 1;
moduleConfig.serialHostAddress = 2;
}
void tmcm_initMotorConfig()
{
motorConfig[0].maximumCurrent = 2700;
motorConfig[0].maxVelocity = 80000;
motorConfig[0].acceleration = 20000;
motorConfig[0].useVelocityRamp = true;
motorConfig[0].openLoopCurrent = 1000;
motorConfig[0].motorType = TMC4671_THREE_PHASE_BLDC;
motorConfig[0].motorPolePairs = 2;
motorConfig[0].commutationMode = COMM_MODE_FOC_DISABLED;
motorConfig[0].adc_I0_offset = 33200;
motorConfig[0].adc_I1_offset = 33200;
motorConfig[0].hallPolarity = 0;
motorConfig[0].hallDirection = 0;
motorConfig[0].hallInterpolation = 1;
motorConfig[0].hallPhiEOffset = 0;
motorConfig[0].dualShuntFactor = 230;// u8.s8 // todo: check with current probe! (ED)
motorConfig[0].shaftBit = 1;
motorConfig[0].pidTorque_P_param = 1500;
motorConfig[0].pidTorque_I_param = 100;
motorConfig[0].pidVelocity_P_param = 200;
motorConfig[0].pidVelocity_I_param = 100;
motorConfig[0].pidPressure_P_param = 3000;
motorConfig[0].pidPressure_I_param = 3000;
motorConfig[0].pwm_freq = 100000;
// init ramp generator
tmc_linearRamp_init(&rampGenerator[0]);
// tosv control
tosv_init(&tosvConfig[0]);
}
void tmcm_updateConfig()
{
// === configure linear ramp generator
rampGenerator[0].maxVelocity = motorConfig[0].maxVelocity;
rampGenerator[0].acceleration = motorConfig[0].acceleration;
rampGenerator[0].rampEnabled = motorConfig[0].useVelocityRamp;
// use motor config to update tosv values with EEPROM stored values
// todo: (like tosvConfig[0]->timeStartup = motorConfig[0].tosvTimeStartup;)
// config->timeStartup = 2000;
// config->timeState1 = 500;
// config->timeState2 = 1000;
// config->timeState3 = 500;
// config->timeState4 = 1000;
// config->maxPressure = 2000;
// config->peepPressure = 1200;
// === configure TMC6200 ===
tmc6200_writeInt(DEFAULT_DRV, TMC6200_GCONF, 0); // normal pwm control
tmc6200_writeInt(DEFAULT_DRV, TMC6200_DRV_CONF, 0); // BBM_OFF and DRVSTRENGTH to weak
// === configure TMC4671 ===
// Motor type & PWM configuration
tmc4671_writeInt(DEFAULT_MC, TMC4671_MOTOR_TYPE_N_POLE_PAIRS, ((u32)motorConfig[0].motorType << TMC4671_MOTOR_TYPE_SHIFT) | motorConfig[0].motorPolePairs);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PWM_POLARITIES, 0x00000000);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PWM_MAXCNT, 0x00000F9F);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PWM_BBM_H_BBM_L, 0x00001919);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PWM_SV_CHOP, 0x00000107);
// ADC configuration
tmc4671_writeInt(DEFAULT_MC, TMC4671_ADC_I_SELECT, 0x18000100);
tmc4671_writeInt(DEFAULT_MC, TMC4671_dsADC_MCFG_B_MCFG_A, 0x00100010);
tmc4671_writeInt(DEFAULT_MC, TMC4671_dsADC_MCLK_A, 0x10000000);
tmc4671_writeInt(DEFAULT_MC, TMC4671_dsADC_MCLK_B, 0x00000000);
tmc4671_writeInt(DEFAULT_MC, TMC4671_dsADC_MDEC_B_MDEC_A, 0x014E014E);
tmc4671_writeInt(DEFAULT_MC, TMC4671_ADC_I0_SCALE_OFFSET, 0x01000000 | motorConfig[0].adc_I0_offset);
tmc4671_writeInt(DEFAULT_MC, TMC4671_ADC_I1_SCALE_OFFSET, 0x01000000 | motorConfig[0].adc_I1_offset);
// hall configuration
bldc_updateHallSettings(DEFAULT_MC);
// PI configuration
tmc4671_setTorqueFluxPI(DEFAULT_MC, motorConfig[0].pidTorque_P_param, motorConfig[0].pidTorque_I_param);
tmc4671_setVelocityPI(DEFAULT_MC, motorConfig[0].pidVelocity_P_param, motorConfig[0].pidVelocity_I_param);
// limit configuration
tmc4671_writeInt(DEFAULT_MC, TMC4671_PID_VELOCITY_LIMIT, motorConfig[0].maxVelocity * motorConfig[0].motorPolePairs);
tmc4671_writeInt(DEFAULT_MC, TMC4671_OPENLOOP_ACCELERATION, motorConfig[0].acceleration);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PIDOUT_UQ_UD_LIMITS, 0x7FFF);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PID_TORQUE_FLUX_TARGET_DDT_LIMITS, 0x7FFF);
tmc4671_setTorqueFluxLimit_mA(DEFAULT_MC, motorConfig[0].dualShuntFactor, motorConfig[0].maximumCurrent);
// reset target values
tmc4671_writeInt(DEFAULT_MC, TMC4671_UQ_UD_EXT, 0);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PIDIN_TORQUE_TARGET_FLUX_TARGET, 0);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PIDIN_VELOCITY_TARGET, 0);
tmc4671_writeInt(DEFAULT_MC, TMC4671_OPENLOOP_VELOCITY_TARGET, 0);
tmc4671_writeInt(DEFAULT_MC, TMC4671_OPENLOOP_ACCELERATION, 0x0000FFFF);
tmc4671_writeInt(DEFAULT_MC, TMC4671_PIDIN_POSITION_TARGET, 0);
}
/* expected by the libTMC library for io_init()*/
void tmcm_initModuleSpecificIO()
{
GPIO_InitTypeDef GPIO_InitStructure;
// === enable port A ===
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
// analog inputs port A
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; // AI0
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// outputs port A
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_15; // EN_Weasel | CS_Weasel
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIOA->BSRRL = GPIO_Pin_0; // enable EN_Weasel
GPIOA->BSRRL = GPIO_Pin_15; // disable CS_Weasel
GPIO_Init(GPIOA, &GPIO_InitStructure);
// === enable port B ===
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
// analog inputs port B
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; // AI1 | AI2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOB, &GPIO_InitStructure);
// outputs port B
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; // CS_EEPROM
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIOB->BSRRL = GPIO_Pin_6; // disable CS_EEPROM
// === enable port C ===
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
// outputs port C
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; // CS_BOB_EEPROM
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIOC->BSRRL = GPIO_Pin_0; // disable CS_BOB_EEPROM
GPIO_Init(GPIOC, &GPIO_InitStructure);
// === enable port D ===
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
// === enable port E ===
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
// outputs port E
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_15; // CS_Dragon
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIOE->BSRRH = GPIO_Pin_0;
GPIOE->BSRRL = GPIO_Pin_1;
GPIOE->BSRRL = GPIO_Pin_15; // disable CS_Dragon
// === enable dac clock ===
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
}
void tmcm_initModuleSpecificADC()
{
// enable clock for ADC1 and DMA
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
// DMA2 Stream0 channel0 configuration
DMA_InitTypeDef DMAInit;
DMA_DeInit(DMA2_Stream0);
DMA_StructInit(&DMAInit);
DMAInit.DMA_Channel = DMA_Channel_0;
DMAInit.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_ADDRESS;
DMAInit.DMA_Memory0BaseAddr = (uint32_t)&ADC1Value;
DMAInit.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMAInit.DMA_BufferSize = ADC1_CHANNELS;
DMAInit.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMAInit.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMAInit.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMAInit.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMAInit.DMA_Mode = DMA_Mode_Circular;
DMAInit.DMA_Priority = DMA_Priority_High;
DMAInit.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMAInit.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMAInit.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMAInit.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMAInit);
DMA_Cmd(DMA2_Stream0, ENABLE);
// initialize ADC_Common
ADC_CommonInitTypeDef ADC_CommonInitStructure;
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);
// ADC1 configuration
ADC_InitTypeDef ADCInit;
ADC_StructInit(&ADCInit);
ADCInit.ADC_Resolution = ADC_Resolution_12b;
ADCInit.ADC_ScanConvMode = ENABLE;
ADCInit.ADC_ContinuousConvMode = ENABLE;
ADCInit.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADCInit.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
ADCInit.ADC_DataAlign = ADC_DataAlign_Right;
ADCInit.ADC_NbrOfConversion = ADC1_CHANNELS;
ADC_Init(ADC1, &ADCInit);
// enable ADC1 and ADC2 DMA
ADC_DMACmd(ADC1, ENABLE);
// select adc channels for ADC1
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 1, ADC_SampleTime_15Cycles); // use ADC_AI0
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 2, ADC_SampleTime_15Cycles); // use ADC_AI1
ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 3, ADC_SampleTime_15Cycles); // use ADC_AI2
// Enable DMA request after last transfer (Single-ADC mode)
ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
// Enable ADC1
ADC_Cmd(ADC1, ENABLE);
ADC_SoftwareStartConv(ADC1); // update ADC1 values
}
void tmcm_led_run_toggle()
{
GPIOE->ODR ^= GPIO_Pin_0;
}
void tmcm_enableDriver(uint8_t motor)
{
if (motor == DEFAULT_MC)
GPIOA->BSRRL = BIT0;
}
void tmcm_disableDriver(uint8_t motor)
{
if (motor == DEFAULT_MC)
GPIOA->BSRRH = BIT0;
}
uint8_t tmcm_getDriverState(uint8_t motor)
{
if (motor == DEFAULT_MC)
return (GPIOA->IDR & BIT0) ? 1:0;
return 0;
}
void tmcm_enableCsWeasel(uint8_t motor)
{
if (motor == DEFAULT_MC)
GPIOA->BSRRH = GPIO_Pin_15;
}
void tmcm_disableCsWeasel(uint8_t motor)
{
if (motor == DEFAULT_MC)
GPIOA->BSRRL = GPIO_Pin_15;
}
void tmcm_enableCsDragon(uint8_t motor)
{
if (motor == DEFAULT_DRV)
GPIOE->BSRRH = GPIO_Pin_15;
}
void tmcm_disableCsDragon(uint8_t motor)
{
if (motor == DEFAULT_DRV)
GPIOE->BSRRL = GPIO_Pin_15;
}
void tmcm_enableCsMem()
{
GPIOB->BSRRH = GPIO_Pin_6;
}
void tmcm_disableCsMem()
{
GPIOB->BSRRL = GPIO_Pin_6;
}
// RS242/RS485 configuration
void tmcm_setRS485ToSendMode(){}
void tmcm_setRS485ToReceiveMode(){}
uint8_t tmcm_isRS485Sending(){ return false; }
void tmcm_clearModuleSpecificIOPin(uint8_t pin)
{
switch(pin)
{
case 0:
GPIOA->BSRRH = GPIO_Pin_0; // EN_4671
break;
}
}
void tmcm_setModuleSpecificIOPin(uint8_t pin)
{
switch(pin)
{
case 0:
GPIOA->BSRRL = GPIO_Pin_0; // EN_4671
break;
}
}
uint8_t tmcm_getModuleSpecificIOPinStatus(uint8_t pin)
{
switch (pin)
{
case 0:
return (GPIOA->IDR & GPIO_Pin_0) ? 1:0; // EN_4671
break;
}
return 0;
}
uint16_t tmcm_getModuleSpecificADCValue(uint8_t pin)
{
switch(pin)
{
case 0:
return ADC1Value[0]; // ADC_AI0
break;
case 1:
return ADC1Value[1]; // ADC_AI1
break;
case 2:
return ADC1Value[2]; // ADC_AI2
break;
}
return 0;
}
#endif
| 31.949239 | 157 | 0.75564 |
602202a5bb5ccb31fa07d9045e8a1889ba82119c | 406 | h | C | Example/BSFrameworks/Function/DemoGroup/SuanFa/Calculation/BSFibonacciSequence.h | BlackStarLang/BSFrameWork | b2ba9a2f926df7cb9f8cd86018c44b04a2a86990 | [
"MIT"
] | 17 | 2020-10-20T02:30:36.000Z | 2022-03-16T08:23:58.000Z | Example/BSFrameworks/Function/DemoGroup/SuanFa/Calculation/BSFibonacciSequence.h | BlackStarLang/BSFrameWork | b2ba9a2f926df7cb9f8cd86018c44b04a2a86990 | [
"MIT"
] | 2 | 2021-09-14T08:37:21.000Z | 2021-12-09T08:15:13.000Z | Example/BSFrameworks/Function/DemoGroup/SuanFa/Calculation/BSFibonacciSequence.h | BlackStarLang/BSFrameWork | b2ba9a2f926df7cb9f8cd86018c44b04a2a86990 | [
"MIT"
] | 2 | 2020-09-18T10:12:55.000Z | 2022-02-17T12:13:47.000Z | //
// BSFibonacciSequence.h
// BSFrameworks_Example
//
// Created by 叶一枫 on 2021/3/5.
// Copyright © 2021 blackstar_lang@163.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
// 斐波那契 数列
@interface BSFibonacciSequence : NSObject
/// 输出 Fn(n) 斐波那契数组 (n = 0 , array[0] = 1)
+(NSArray*)getFibonacciArrayWithNumberN:(NSInteger)numberN;
@end
NS_ASSUME_NONNULL_END
| 17.652174 | 65 | 0.731527 |
6d4bc4fac12bf61f495a8555b14847cbd656ca4e | 501 | c | C | gcc-gcc-7_3_0-release/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.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/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/libgomp/testsuite/libgomp.c/examples-4/declare_target-1.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | /* { dg-do run } */
#include <stdlib.h>
#define THRESHOLD 20
#pragma omp declare target
int fib (int n)
{
if (n <= 0)
return 0;
else if (n == 1)
return 1;
else
return fib (n - 1) + fib (n - 2);
}
#pragma omp end declare target
int fib_wrapper (int n)
{
int x = 0;
#pragma omp target if(n > THRESHOLD) map(from:x)
x = fib (n);
return x;
}
int main ()
{
if (fib (15) != fib_wrapper (15))
abort ();
if (fib (25) != fib_wrapper (25))
abort ();
return 0;
}
| 13.540541 | 50 | 0.548902 |
7a6cc6444ab07b34f8afcac1e93680a19f90bbb2 | 5,583 | h | C | Code/Applications/regseg.h | xiaochengcike/RegSeg | e2cff93ef4f195bfd59c518e047cf8f37560b6a8 | [
"MIT"
] | 14 | 2016-05-16T08:47:04.000Z | 2022-01-07T14:57:16.000Z | Code/Applications/regseg.h | xiaochengcike/RegSeg | e2cff93ef4f195bfd59c518e047cf8f37560b6a8 | [
"MIT"
] | 5 | 2016-01-24T02:52:55.000Z | 2017-10-18T02:13:15.000Z | Code/Applications/regseg.h | oesteban/RegSeg | e2cff93ef4f195bfd59c518e047cf8f37560b6a8 | [
"MIT"
] | 8 | 2015-12-24T21:13:43.000Z | 2022-03-25T00:06:35.000Z | // This file is part of RegSeg
//
// Copyright 2014-2017, Oscar Esteban <code@oscaresteban.es>
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#ifndef REGSEG_H_
#define REGSEG_H_
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <boost/program_options.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
#include <itkVector.h>
#include <itkVectorImage.h>
#include <itkImage.h>
#include <itkThresholdImageFilter.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkQuadEdgeMesh.h>
#include <itkVTKPolyDataReader.h>
#include "rstkVTKPolyDataWriter.h"
#include "rstkCoefficientsWriter.h"
#include <itkVectorImageToImageAdaptor.h>
#include <itkBSplineInterpolateImageFunction.h>
#include <itkDisplacementFieldTransform.h>
#include <itkResampleImageFilter.h>
#include <itkWarpImageFilter.h>
#include "ACWERegistrationMethod.h"
#include "SparseMatrixTransform.h"
#include "DisplacementFieldFileWriter.h"
#include "DisplacementFieldComponentsFileWriter.h"
#include "LevelObserver.h"
using namespace rstk;
namespace bpo = boost::program_options;
namespace bfs = boost::filesystem;
const static unsigned int DIMENSION = 3;
typedef float ChannelPixelType;
typedef itk::Image<ChannelPixelType, DIMENSION> ChannelType;
typedef itk::VectorImage<ChannelPixelType, DIMENSION> ImageType;
typedef typename ImageType::PixelType VectorPixelType;
typedef float ScalarType;
typedef BSplineSparseMatrixTransform<ScalarType,
DIMENSION, 3u> TransformType;
typedef TransformType::Pointer TransformPointer;
typedef typename TransformType::CoefficientsImageType CoefficientsType;
typedef typename TransformType::AltCoeffType AltCoeffType;
typedef SparseMatrixTransform<ScalarType, DIMENSION > BaseTransformType;
typedef BaseTransformType::Pointer BaseTransformPointer;
typedef typename BaseTransformType::AltCoeffType AltCoeffType;
typedef itk::ThresholdImageFilter< ChannelType > ThresholdFilter;
typedef typename ThresholdFilter::Pointer ThresholdPointer;
typedef itk::ResampleImageFilter
< ChannelType, ChannelType > ResampleFilter;
typedef typename ResampleFilter::Pointer ResamplePointer;
typedef itk::BSplineInterpolateImageFunction
< ChannelType > DefaultInterpolator;
typedef ACWERegistrationMethod< ImageType, TransformType, ScalarType > RegistrationType;
typedef typename RegistrationType::Pointer RegistrationPointer;
typedef typename RegistrationType::PriorsList ContourList;
typedef typename RegistrationType::OptimizerType OptimizerType;
typedef typename RegistrationType::FunctionalType FunctionalType;
typedef typename FunctionalType::ProbabilityMapType ProbabilityMapType;
typedef typename OptimizerType::FieldType FieldType;
typedef itk::ImageFileReader<ChannelType> ImageReader;
typedef itk::ImageFileWriter<ChannelType> ImageWriter;
typedef rstk::DisplacementFieldComponentsFileWriter
<FieldType> ComponentsWriter;
typedef itk::ImageFileWriter< ProbabilityMapType > ProbabilityMapWriter;
typedef itk::ImageFileWriter< CoefficientsType > CoefficientsWriter;
typedef rstk::DisplacementFieldFileWriter< FieldType > FieldWriter;
typedef rstk::CoefficientsWriter< AltCoeffType > CoeffWriter;
typedef itk::WarpImageFilter
< ChannelType, ChannelType, FieldType > WarpFilter;
typedef typename WarpFilter::Pointer WarpFilterPointer;
typedef LevelObserver< RegistrationType > LevelObserverType;
typedef typename LevelObserverType::Pointer LevelObserverPointer;
typedef typename RegistrationType::PriorsType PriorType;
typedef rstk::VTKPolyDataWriter<PriorType> WriterType;
// typedef itk::MeshFileWriter<PriorType> WriterType;
#ifndef NDEBUG
const static size_t DEFAULT_VERBOSITY = 5;
#else
const static size_t DEFAULT_VERBOSITY = 1;
#endif
int main(int argc, char *argv[]);
#endif /* REGSEG_H_ */
| 41.977444 | 90 | 0.712878 |
7a7a83e286f77843df4cc5a3ecc48d54ca56f653 | 3,624 | c | C | protocol/arms_res_builder.c | seil-smf/libarms | 5cc1c07b729ccf4a39d144b961e723093cc063f2 | [
"BSD-2-Clause"
] | 2 | 2015-10-29T05:43:48.000Z | 2015-10-29T05:43:51.000Z | protocol/arms_res_builder.c | seil-smf/libarms | 5cc1c07b729ccf4a39d144b961e723093cc063f2 | [
"BSD-2-Clause"
] | null | null | null | protocol/arms_res_builder.c | seil-smf/libarms | 5cc1c07b729ccf4a39d144b961e723093cc063f2 | [
"BSD-2-Clause"
] | null | null | null | /* $Id: arms_res_builder.c 20800 2012-01-19 05:13:45Z m-oki $ */
/*
* Copyright (c) 2012, Internet Initiative Japan, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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 "config.h"
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <axp_extern.h>
#include <libarms/malloc.h>
#include <transaction/transaction.h>
#include <protocol/arms_methods.h>
/*
* transaction_reflect --> build_generic_res
* &abuf_tmp --> buf, len, wrote
* void *u (== tr_ctx) --> tr
*/
int
build_generic_res(transaction *tr, char *buf, int len, int *wrote)
{
int size;
size = arms_write_begin_message(tr, buf, len);
buf += size;
len -= size;
/* no body */
size += arms_write_end_message(tr, buf, len);
*wrote = size;
return TR_WRITE_DONE;
}
/*
* response builder: method is selected by pm_type.
*/
int
arms_res_builder(transaction *tr, char *buf, int len, int *wrote)
{
tr_ctx_t *tr_ctx = &tr->tr_ctx;
arms_method_t *method;
int rv;
if (tr_ctx->write_done != TR_WANT_WRITE)
return tr_ctx->write_done;
method = tr_ctx->pm;
if (method == NULL) {
/*
* request type is not found, return generic-error.
*/
tr_ctx->pm_type = ARMS_TR_GENERIC_ERROR;
if (tr_ctx->pm == NULL)
tr_ctx->pm = &generic_error_methods;
tr_ctx->id = 0;
tr_ctx->result = 202;
rv = build_generic_res(tr, buf, len, wrote);
tr_ctx->write_done = rv;
return TR_WANT_WRITE;
}
if (method->pm_response == NULL) {
/*
* request type is found, return "NOT SUPPORTED".
*/
tr_ctx->pm_type = ARMS_TR_GENERIC_ERROR;
if (tr_ctx->pm == NULL)
tr_ctx->pm = &generic_error_methods;
tr_ctx->id = 0;
tr_ctx->result = 505;
rv = build_generic_res(tr, buf, len, wrote);
tr_ctx->write_done = rv;
return TR_WANT_WRITE;
}
/*
* chack too many transaction
*/
if (method->pm_done == NULL) {
/* sync'd method running immediately. */
if (tr_ctx->result == 406)
tr_ctx->result = 100;
}
if (tr_ctx->result >= 200) {
/*
* error detected in -request parser.
* e.g. too many transaction,
* distribution-id mismatch,
*/
if (tr_ctx->pm == NULL)
tr->tr_ctx.pm = &generic_error_methods;
rv = build_generic_res(tr, buf, len, wrote);
tr_ctx->write_done = rv;
return TR_WANT_WRITE;
}
rv = method->pm_response(tr, buf, len, wrote);
tr_ctx->write_done = rv;
return TR_WANT_WRITE;
}
| 28.992 | 78 | 0.701711 |
9e384740ff5add0ddbc60750707d90accdd9f41e | 6,666 | c | C | sys/src/cmd/pic/main.c | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | 1 | 2021-03-23T22:40:43.000Z | 2021-03-23T22:40:43.000Z | sys/src/cmd/pic/main.c | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | null | null | null | sys/src/cmd/pic/main.c | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | 1 | 2021-12-21T06:19:58.000Z | 2021-12-21T06:19:58.000Z | #include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include "pic.h"
#include "y.tab.h"
obj **objlist = 0; /* store the elements here */
int nobjlist = 0; /* size of objlist array */
int nobj = 0;
Attr *attr; /* attributes stored here as collected */
int nattrlist = 0;
int nattr = 0; /* number of entries in attr_list */
Text *text = 0; /* text strings stored here as collected */
int ntextlist = 0; /* size of text[] array */
int ntext = 0;
int ntext1 = 0; /* record ntext here on entry to each figure */
double curx = 0;
double cury = 0;
int hvmode = R_DIR; /* R => join left to right, D => top to bottom, etc. */
int codegen = 0; /* 1=>output for this picture; 0=>no output */
int PEseen = 0; /* 1=> PE seen during parsing */
double deltx = 6; /* max x value in output, for scaling */
double delty = 6; /* max y value in output, for scaling */
int dbg = 0;
int lineno = 0;
char *filename = "-";
int synerr = 0;
int anyerr = 0; /* becomes 1 if synerr ever 1 */
char *cmdname;
double xmin = 30000; /* min values found in actual data */
double ymin = 30000;
double xmax = -30000; /* max */
double ymax = -30000;
char *version = "version May 7, 1990";
void fpecatch(long);
void getdata(void), setdefaults(void);
void setfval(char *, double);
int getpid(void);
main(int argc, char *argv[])
{
char buf[20];
signal(SIGFPE, fpecatch);
cmdname = argv[0];
while (argc > 1 && *argv[1] == '-') {
switch (argv[1][1]) {
case 'd':
dbg = atoi(&argv[1][2]);
if (dbg == 0)
dbg = 1;
fprintf(stderr, "%s\n", version);
break;
}
argc--;
argv++;
}
setdefaults();
objlist = (obj **) grow((char *)objlist, "objlist", nobjlist += 1000, sizeof(obj *));
text = (Text *) grow((char *)text, "text", ntextlist += 1000, sizeof(Text));
attr = (Attr *) grow((char *)attr, "attr", nattrlist += 100, sizeof(Attr));
sprintf(buf, "/%d/", getpid());
pushsrc(String, buf);
definition("pid");
curfile = infile;
pushsrc(File, curfile->fname);
if (argc <= 1) {
curfile->fin = stdin;
curfile->fname = tostring("-");
getdata();
} else
while (argc-- > 1) {
if ((curfile->fin = fopen(*++argv, "r")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", cmdname, *argv);
exit(1);
}
curfile->fname = tostring(*argv);
getdata();
fclose(curfile->fin);
free(curfile->fname);
}
exit(anyerr);
}
void fpecatch(long n)
{
ERROR "floating point exception" FATAL;
}
char *grow(char *ptr, char *name, int num, int size) /* make array bigger */
{
char *p;
if (ptr == NULL)
p = malloc(num * size);
else
p = realloc(ptr, num * size);
if (p == NULL)
ERROR "can't grow %s to %d", name, num * size FATAL;
return p;
}
static struct {
char *name;
double val;
short scalable; /* 1 => adjust when "scale" changes */
} defaults[] ={
"scale", SCALE, 1,
"lineht", HT, 1,
"linewid", HT, 1,
"moveht", HT, 1,
"movewid", HT, 1,
"dashwid", HT10, 1,
"boxht", HT, 1,
"boxwid", WID, 1,
"circlerad", HT2, 1,
"arcrad", HT2, 1,
"ellipseht", HT, 1,
"ellipsewid", WID, 1,
"arrowht", HT5, 1,
"arrowwid", HT10, 1,
"arrowhead", 2, 0, /* arrowhead style */
"textht", 0.0, 1, /* 6 lines/inch is also a useful value */
"textwid", 0.0, 1,
"maxpsht", MAXHT, 0,
"maxpswid", MAXWID, 0,
"fillval", 0.3, 0, /* gray value for filling boxes */
NULL, 0, 0
};
void setdefaults(void) /* set default sizes for variables like boxht */
{
int i;
YYSTYPE v;
for (i = 0; defaults[i].name != NULL; i++) {
v.f = defaults[i].val;
makevar(tostring(defaults[i].name), VARNAME, v);
}
}
void resetvar(void) /* reset variables listed */
{
int i, j;
if (nattr == 0) { /* none listed, so do all */
setdefaults();
return;
}
for (i = 0; i < nattr; i++) {
for (j = 0; defaults[j].name != NULL; j++)
if (strcmp(defaults[j].name, attr[i].a_val.p) == 0) {
setfval(defaults[j].name, defaults[j].val);
free(attr[i].a_val.p);
break;
}
}
}
void checkscale(char *s) /* if s is "scale", adjust default variables */
{
int i;
double scale;
if (strcmp(s, "scale") == 0) {
scale = getfval("scale");
for (i = 1; defaults[i].name != NULL; i++)
if (defaults[i].scalable)
setfval(defaults[i].name, defaults[i].val * scale);
}
}
void getdata(void)
{
char *p, buf[1000], buf1[100];
int ln;
void reset(void), openpl(char *), closepl(int), print(void);
int yyparse(void);
curfile->lineno = 0;
printlf(1, curfile->fname);
while (fgets(buf, sizeof buf, curfile->fin) != NULL) {
curfile->lineno++;
if (*buf == '.' && *(buf+1) == 'P' && *(buf+2) == 'S') {
for (p = &buf[3]; *p == ' '; p++)
;
if (*p++ == '<') {
Infile svfile;
svfile = *curfile;
sscanf(p, "%s", buf1);
if ((curfile->fin=fopen(buf1, "r")) == NULL)
ERROR "can't open %s", buf1 FATAL;
curfile->fname = tostring(buf1);
getdata();
fclose(curfile->fin);
free(curfile->fname);
*curfile = svfile;
printlf(curfile->lineno, curfile->fname);
continue;
}
reset();
yyparse();
anyerr += synerr;
/* yylval.i now contains 'E' or 'F' from .PE or .PF */
deltx = (xmax - xmin) / getfval("scale");
delty = (ymax - ymin) / getfval("scale");
if (buf[3] == ' ') { /* next things are wid & ht */
if (sscanf(&buf[4],"%lf %lf", &deltx, &delty) < 2)
delty = deltx * (ymax-ymin) / (xmax-xmin);
/* else {
/* double xfac, yfac; */
/* xfac = deltx / (xmax-xmin);
/* yfac = delty / (ymax-ymin);
/* if (xfac <= yfac)
/* delty = xfac * (ymax-ymin);
/* else
/* deltx = yfac * (xmax-xmin);
/*}
*/
}
dprintf("deltx = %g, delty = %g\n", deltx, delty);
if (codegen && !synerr) {
openpl(&buf[3]); /* puts out .PS, with ht & wid stuck in */
printlf(curfile->lineno+1, NULL);
print(); /* assumes \n at end */
closepl(yylval.i); /* does the .PE/F */
}
printlf(curfile->lineno+1, NULL);
fflush(stdout);
} else if (buf[0] == '.' && buf[1] == 'l' && buf[2] == 'f') {
if (sscanf(buf+3, "%d %s", &ln, buf1) == 2) {
free(curfile->fname);
printlf(curfile->lineno = ln, curfile->fname = tostring(buf1));
} else
printlf(curfile->lineno = ln, NULL);
} else
fputs(buf, stdout);
}
}
void reset(void)
{
obj *op;
int i;
extern int nstack;
extern void freesymtab(struct symtab *);
for (i = 0; i < nobj; i++) {
op = objlist[i];
if (op->o_type == BLOCK)
freesymtab(op->o_symtab);
free((char *)objlist[i]);
}
nobj = 0;
nattr = 0;
for (i = 0; i < ntext; i++)
if (text[i].t_val)
free(text[i].t_val);
ntext = ntext1 = 0;
codegen = synerr = 0;
nstack = 0;
curx = cury = 0;
PEseen = 0;
hvmode = R_DIR;
xmin = ymin = 30000;
xmax = ymax = -30000;
}
| 23.72242 | 86 | 0.573507 |
9e9ec3e30ce02bdc2330b922381beadea74fac39 | 1,094 | h | C | Source/FactoryGame/UndefinedBool.h | iam-Legend/Project-Assembly | 1ff3587704232d5e330515bc0d2aceb64ff09a7f | [
"MIT"
] | null | null | null | Source/FactoryGame/UndefinedBool.h | iam-Legend/Project-Assembly | 1ff3587704232d5e330515bc0d2aceb64ff09a7f | [
"MIT"
] | null | null | null | Source/FactoryGame/UndefinedBool.h | iam-Legend/Project-Assembly | 1ff3587704232d5e330515bc0d2aceb64ff09a7f | [
"MIT"
] | null | null | null | #pragma once
#include "UObject/Class.h"
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
/** A bool that can be undefined */
UENUM()
enum class EUndefinedBool : uint8
{
UB_Undefined = 0, // MODDING EDIT (= 0)
UB_False = 1, // MODDING EDIT (= 1)
UB_True = 2 // MODDING EDIT (= 2)
};
inline bool operator==( EUndefinedBool e, bool b );
inline bool operator==( bool b, EUndefinedBool e );
inline bool operator!=( EUndefinedBool e, bool b );
inline bool operator!=( bool b, EUndefinedBool e );
inline EUndefinedBool ToEnum( bool b );
bool operator==( EUndefinedBool e, bool b )
{
if( b == true && e == EUndefinedBool::UB_True )
{
return true;
}
else if( b == false && e == EUndefinedBool::UB_False )
{
return true;
}
return false;
}
bool operator==( bool b, EUndefinedBool e )
{
return e == b;
}
bool operator!=( EUndefinedBool e, bool b )
{
bool result = !( e == b );
return result;
}
bool operator!=( bool b, EUndefinedBool e )
{
return !( e == b );
}
EUndefinedBool ToEnum( bool b )
{
return b ? EUndefinedBool::UB_True : EUndefinedBool::UB_False;
} | 19.192982 | 63 | 0.657221 |
fa36f1b259773a943a734f45f0f038522bbbcfbb | 195 | h | C | server/server/route.h | moonlight8978/network_programming_20171 | b255f39c776ae48d8aa21e70a1cb0a8dc8fa38cc | [
"MIT"
] | null | null | null | server/server/route.h | moonlight8978/network_programming_20171 | b255f39c776ae48d8aa21e70a1cb0a8dc8fa38cc | [
"MIT"
] | null | null | null | server/server/route.h | moonlight8978/network_programming_20171 | b255f39c776ae48d8aa21e70a1cb0a8dc8fa38cc | [
"MIT"
] | null | null | null | #include "stdafx.h"
void define_routes() {
ROUTES[0].path = "/idols";
ROUTES[0].get = true;
ROUTES[0].post = true;
ROUTES[1].path = "/";
ROUTES[1].get = true;
TOTAL_ROUTES = 2;
}
| 13.928571 | 28 | 0.584615 |
9a89261dcd2a6b71f005a63fff8a67541c34d5d4 | 4,817 | c | C | arch/x86/kernel/x86_init.c | CPU-Code/-Linux_kernel | 44dc3358bc640197528f5b10dbed0fd3717af65b | [
"AFL-3.0"
] | null | null | null | arch/x86/kernel/x86_init.c | CPU-Code/-Linux_kernel | 44dc3358bc640197528f5b10dbed0fd3717af65b | [
"AFL-3.0"
] | null | null | null | arch/x86/kernel/x86_init.c | CPU-Code/-Linux_kernel | 44dc3358bc640197528f5b10dbed0fd3717af65b | [
"AFL-3.0"
] | null | null | null | /*
* Copyright (C) 2009 Thomas Gleixner <tglx@linutronix.de>
*
* For licencing details see kernel-base/COPYING
*/
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <asm/acpi.h>
#include <asm/bios_ebda.h>
#include <asm/paravirt.h>
#include <asm/pci_x86.h>
#include <asm/mpspec.h>
#include <asm/setup.h>
#include <asm/apic.h>
#include <asm/e820/api.h>
#include <asm/time.h>
#include <asm/irq.h>
#include <asm/io_apic.h>
#include <asm/hpet.h>
#include <asm/pat.h>
#include <asm/tsc.h>
#include <asm/iommu.h>
#include <asm/mach_traps.h>
void x86_init_noop(void) { }
void __init x86_init_uint_noop(unsigned int unused) { }
static int __init iommu_init_noop(void) { return 0; }
static void iommu_shutdown_noop(void) { }
bool __init bool_x86_init_noop(void) { return false; }
void x86_op_int_noop(int cpu) { }
static __init int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
static __init void get_rtc_noop(struct timespec64 *now) { }
static __initconst const struct of_device_id of_cmos_match[] = {
{ .compatible = "motorola,mc146818" },
{}
};
/*
* Allow devicetree configured systems to disable the RTC by setting the
* corresponding DT node's status property to disabled. Code is optimized
* out for CONFIG_OF=n builds.
*/
static __init void x86_wallclock_init(void)
{
struct device_node *node = of_find_matching_node(NULL, of_cmos_match);
if (node && !of_device_is_available(node)) {
x86_platform.get_wallclock = get_rtc_noop;
x86_platform.set_wallclock = set_rtc_noop;
}
}
/*
* The platform setup functions are preset with the default functions
* for standard PC hardware.
*/
struct x86_init_ops x86_init __initdata = {
.resources = {
.probe_roms = probe_roms,
.reserve_resources = reserve_standard_io_resources,
.memory_setup = e820__memory_setup_default,
},
.mpparse = {
.mpc_record = x86_init_uint_noop,
.setup_ioapic_ids = x86_init_noop,
.mpc_apic_id = default_mpc_apic_id,
.smp_read_mpc_oem = default_smp_read_mpc_oem,
.mpc_oem_bus_info = default_mpc_oem_bus_info,
.find_smp_config = default_find_smp_config,
.get_smp_config = default_get_smp_config,
},
.irqs = {
.pre_vector_init = init_ISA_irqs,
.intr_init = native_init_IRQ,
.trap_init = x86_init_noop,
.intr_mode_select = apic_intr_mode_select,
.intr_mode_init = apic_intr_mode_init
},
.oem = {
.arch_setup = x86_init_noop,
.banner = default_banner,
},
.paging = {
.pagetable_init = native_pagetable_init,
},
.timers = {
.setup_percpu_clockev = setup_boot_APIC_clock,
.timer_init = hpet_time_init,
.wallclock_init = x86_wallclock_init,
},
.iommu = {
.iommu_init = iommu_init_noop,
},
.pci = {
.init = x86_default_pci_init,
.init_irq = x86_default_pci_init_irq,
.fixup_irqs = x86_default_pci_fixup_irqs,
},
.hyper = {
.init_platform = x86_init_noop,
.guest_late_init = x86_init_noop,
.x2apic_available = bool_x86_init_noop,
.init_mem_mapping = x86_init_noop,
.init_after_bootmem = x86_init_noop,
},
.acpi = {
.set_root_pointer = x86_default_set_root_pointer,
.get_root_pointer = x86_default_get_root_pointer,
.reduced_hw_early_init = acpi_generic_reduced_hw_init,
},
};
struct x86_cpuinit_ops x86_cpuinit = {
.early_percpu_clock_init = x86_init_noop,
.setup_percpu_clockev = setup_secondary_APIC_clock,
};
static void default_nmi_init(void) { };
struct x86_platform_ops x86_platform __ro_after_init = {
.calibrate_cpu = native_calibrate_cpu_early,
.calibrate_tsc = native_calibrate_tsc,
.get_wallclock = mach_get_cmos_time,
.set_wallclock = mach_set_rtc_mmss,
.iommu_shutdown = iommu_shutdown_noop,
.is_untracked_pat_range = is_ISA_range,
.nmi_init = default_nmi_init,
.get_nmi_reason = default_get_nmi_reason,
.save_sched_clock_state = tsc_save_sched_clock_state,
.restore_sched_clock_state = tsc_restore_sched_clock_state,
.hyper.pin_vcpu = x86_op_int_noop,
};
EXPORT_SYMBOL_GPL(x86_platform);
#if defined(CONFIG_PCI_MSI)
struct x86_msi_ops x86_msi __ro_after_init = {
.setup_msi_irqs = native_setup_msi_irqs,
.teardown_msi_irq = native_teardown_msi_irq,
.teardown_msi_irqs = default_teardown_msi_irqs,
.restore_msi_irqs = default_restore_msi_irqs,
};
/* MSI arch specific hooks */
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
return x86_msi.setup_msi_irqs(dev, nvec, type);
}
void arch_teardown_msi_irqs(struct pci_dev *dev)
{
x86_msi.teardown_msi_irqs(dev);
}
void arch_teardown_msi_irq(unsigned int irq)
{
x86_msi.teardown_msi_irq(irq);
}
void arch_restore_msi_irqs(struct pci_dev *dev)
{
x86_msi.restore_msi_irqs(dev);
}
#endif
struct x86_apic_ops x86_apic_ops __ro_after_init = {
.io_apic_read = native_io_apic_read,
.restore = native_restore_boot_irq_mode,
};
| 26.179348 | 80 | 0.757318 |
36f7b9d44764673105489faf60c06baee5178d3f | 372 | h | C | prj/src/PrecHeader.h | ujoychou/eco | 4845b42799f62a591fb36ae20fa5b7b06ef12761 | [
"MIT"
] | 8 | 2018-04-08T08:37:36.000Z | 2022-01-31T16:14:34.000Z | prj/src/PrecHeader.h | ujoychou/eco | 4845b42799f62a591fb36ae20fa5b7b06ef12761 | [
"MIT"
] | 1 | 2021-12-22T22:02:35.000Z | 2021-12-22T22:05:20.000Z | prj/src/PrecHeader.h | ujoychou/eco | 4845b42799f62a591fb36ae20fa5b7b06ef12761 | [
"MIT"
] | 2 | 2018-04-08T08:56:34.000Z | 2018-09-03T11:17:44.000Z | #ifndef PREC_HEADER_H
#define PREC_HEADER_H
////////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <iostream>
#include <eco/Type.h>
#include <eco/log/Log.h>
#include <eco/Implement.h>
#include <eco/thread/Thread.h>
////////////////////////////////////////////////////////////////////////////////
#endif PREC_HEADER_H | 28.615385 | 80 | 0.427419 |
3c12ea7c4f648164efd3ae489288ad452d1b44c6 | 1,225 | c | C | arch/arm/memcpy-neon-register.c | maemo-tools-old/sp-mem-throughput | b95a3d5b52d06be8b168731f239f2f50c631d064 | [
"BSD-3-Clause"
] | 1 | 2021-11-11T06:45:17.000Z | 2021-11-11T06:45:17.000Z | arch/arm/memcpy-neon-register.c | maemo-tools-old/sp-mem-throughput | b95a3d5b52d06be8b168731f239f2f50c631d064 | [
"BSD-3-Clause"
] | null | null | null | arch/arm/memcpy-neon-register.c | maemo-tools-old/sp-mem-throughput | b95a3d5b52d06be8b168731f239f2f50c631d064 | [
"BSD-3-Clause"
] | 1 | 2021-11-11T06:45:23.000Z | 2021-11-11T06:45:23.000Z | /* This file is part of sp-mem-throughput.
*
* Copyright (C) 2010 by Nokia Corporation
*
* Authors: Siarhei Siamashka <siarhei.siamashka@nokia.com>
* Contact: Eero Tamminen <eero.tamminen@nokia.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef __ARM_NEON__
#include "routine.h"
void *memcpy_neon(void *, const void *, size_t);
void *memcpy_neon_unal(void *, const void *, size_t);
ROUTINE_REGISTER_MEMCPY(memcpy_neon,
"ARM NEON memcpy (from Siarhei Siamashka)")
ROUTINE_REGISTER_MEMCPY(memcpy_neon_unal,
"ARM NEON memcpy, unaligned writes (from Siarhei Siamashka)")
#endif /* __ARM_NEON__ */
| 35 | 79 | 0.751837 |
d2133a54f4db518f391dab73327558581d69bca6 | 29 | h | C | busybox-1.28.0/include/config/udhcp/debug.h | HenryLong/Android_busybox | 2feaa19e13f3dc226396627869629ae7672002d1 | [
"Apache-2.0"
] | null | null | null | busybox-1.28.0/include/config/udhcp/debug.h | HenryLong/Android_busybox | 2feaa19e13f3dc226396627869629ae7672002d1 | [
"Apache-2.0"
] | null | null | null | busybox-1.28.0/include/config/udhcp/debug.h | HenryLong/Android_busybox | 2feaa19e13f3dc226396627869629ae7672002d1 | [
"Apache-2.0"
] | null | null | null | #define CONFIG_UDHCP_DEBUG 9
| 14.5 | 28 | 0.862069 |
c55b348ae8561a2c4da804f3eb50eebb73c267da | 1,498 | h | C | Example/Pods/Headers/Private/Vuforia_LatestVersion/VideoBackgroundTextureInfo.h | pzhtpf/Vuforia_LatestVersion | 99f7cb2cde3a42089d4a5362fe3c4d6889484bba | [
"MIT"
] | 1 | 2018-07-16T16:10:58.000Z | 2018-07-16T16:10:58.000Z | Example/Pods/Headers/Private/Vuforia_LatestVersion/VideoBackgroundTextureInfo.h | pzhtpf/Vuforia_LatestVersion | 99f7cb2cde3a42089d4a5362fe3c4d6889484bba | [
"MIT"
] | null | null | null | Example/Pods/Headers/Private/Vuforia_LatestVersion/VideoBackgroundTextureInfo.h | pzhtpf/Vuforia_LatestVersion | 99f7cb2cde3a42089d4a5362fe3c4d6889484bba | [
"MIT"
] | null | null | null | /*===============================================================================
Copyright (c) 2015-2016 PTC Inc. All Rights Reserved.
Copyright (c) 2010-2014 Qualcomm Connected Experiences, Inc. All Rights Reserved.
Vuforia is a trademark of PTC Inc., registered in the United States and other
countries.
@file
VideoBackgroundConfig.h
@brief
Header file for VideoBackgroundConfig struct.
===============================================================================*/
#ifndef _VUFORIA_VIDEOBACKGROUNDTEXTUREINFO_H_
#define _VUFORIA_VIDEOBACKGROUNDTEXTUREINFO_H_
// Include files
#include <Vuforia/Vectors.h>
#include <Vuforia/Vuforia.h>
namespace Vuforia
{
/// Video background configuration
struct VideoBackgroundTextureInfo
{
/// Width and height of the video background texture in pixels
/**
* Describes the size of the texture in the graphics unit
* depending on the particular hardware it will be a power of two
* value immediately after the image size
*/
Vec2I mTextureSize;
/// Width and height of the video background image in pixels
/**
* Describe the size of the image inside the texture. This corresponds
* to the size of the image delivered by the camera
*/
Vec2I mImageSize;
/// Format of the video background image
/**
* Describe the pixel format of the camera image.
*/
PIXEL_FORMAT mPixelFormat;
};
} // namespace Vuforia
#endif //_VUFORIA_VIDEOBACKGROUNDTEXTUREINFO_H_
| 28.264151 | 81 | 0.649533 |
682aca00906578ce428bd24077d1eaf9c6bf2b80 | 508 | h | C | cudaPrograms/runnercuda.h | CristobalM/FastHOGGPU | d593607dde3124a1dc87f21c0686753380f0da50 | [
"MIT"
] | null | null | null | cudaPrograms/runnercuda.h | CristobalM/FastHOGGPU | d593607dde3124a1dc87f21c0686753380f0da50 | [
"MIT"
] | null | null | null | cudaPrograms/runnercuda.h | CristobalM/FastHOGGPU | d593607dde3124a1dc87f21c0686753380f0da50 | [
"MIT"
] | null | null | null |
#ifndef PROJECT_RUNNER_CUDA_H
#define PROJECT_RUNNER_CUDA_H
#include <cstddef>
#include <memory>
#include <opencv2/core/mat.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "ISVMManagerGPU.h"
#include "IImageManagerGPU.h"
using uchar = unsigned char;
std::unique_ptr<ISVMManagerGPU> loadSVMWeights(float *svmWeights, size_t size);
std::unique_ptr<IImageManagerGPU> loadImageToGPU(cv::Mat& imageMat);
#endif //PROJECT_RUNNER_CUDA_H
| 22.086957 | 80 | 0.78937 |
d0ab6185d6fc10eb3cbad6b531347e4b44601d25 | 1,315 | h | C | chrome/browser/sync/send_tab_to_self_sync_service_factory.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-10-18T02:33:40.000Z | 2020-10-18T02:33:40.000Z | chrome/browser/sync/send_tab_to_self_sync_service_factory.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3 | 2021-05-17T16:28:52.000Z | 2021-05-21T22:42:22.000Z | chrome/browser/sync/send_tab_to_self_sync_service_factory.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2019 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 CHROME_BROWSER_SYNC_SEND_TAB_TO_SELF_SYNC_SERVICE_FACTORY_H_
#define CHROME_BROWSER_SYNC_SEND_TAB_TO_SELF_SYNC_SERVICE_FACTORY_H_
#include "base/macros.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
class Profile;
namespace base {
template <typename T>
struct DefaultSingletonTraits;
} // namespace base
namespace send_tab_to_self {
class SendTabToSelfSyncService;
} // namespace send_tab_to_self
class SendTabToSelfSyncServiceFactory
: public BrowserContextKeyedServiceFactory {
public:
static send_tab_to_self::SendTabToSelfSyncService* GetForProfile(
Profile* profile);
static SendTabToSelfSyncServiceFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<SendTabToSelfSyncServiceFactory>;
SendTabToSelfSyncServiceFactory();
~SendTabToSelfSyncServiceFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
DISALLOW_COPY_AND_ASSIGN(SendTabToSelfSyncServiceFactory);
};
#endif // CHROME_BROWSER_SYNC_SEND_TAB_TO_SELF_SYNC_SERVICE_FACTORY_H_
| 30.581395 | 83 | 0.828137 |
fdaaadff95c1170fd9b745783977c03ad171600b | 6,823 | c | C | sdk-6.5.20/libs/sdklt/bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*******************************************************************************
*
* DO NOT EDIT THIS FILE!
* This file is auto-generated by fltg from
* INTERNAL/fltg/xgs/vfi/bcm56990_b0/bcm56990_b0_VFI_ING_EGR_MEMBER_PORTS_PROFILE.map.ltl for
* bcm56990_b0
*
* Tool: $SDK/INTERNAL/fltg/bin/fltg
*
* Edits to this file will be lost when it is regenerated.
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
#include <bcmlrd/bcmlrd_internal.h>
#include <bcmlrd/chip/bcmlrd_id.h>
#include <bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_field_data.h>
#include <bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_ltm_intf.h>
#include <bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_xfrm_field_desc.h>
#include <bcmdrd/chip/bcm56990_b0_enum.h>
#include "bcmltd/chip/bcmltd_common_enumpool.h"
#include "bcm56990_b0_lrd_enumpool.h"
#include <bcmltd/bcmltd_handler.h>
/* VFI_ING_EGR_MEMBER_PORTS_PROFILE field init */
static const bcmlrd_field_data_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_field_data_mmd[] = {
{ /* 0 VFI_ING_EGR_MEMBER_PORTS_PROFILE_ID */
.flags = BCMLTD_FIELD_F_KEY,
.min = &bcm56990_b0_lrd_ifd_u16_0x0,
.def = &bcm56990_b0_lrd_ifd_u16_0x0,
.max = &bcm56990_b0_lrd_ifd_u16_0x7ff,
.depth = 0,
.width = 11,
.edata = NULL,
},
{ /* 1 EGR_MEMBER_PORTS */
.flags = 0,
.min = &bcm56990_b0_lrd_ifd_is_true_0x0,
.def = &bcm56990_b0_lrd_ifd_is_true_0x0,
.max = &bcm56990_b0_lrd_ifd_is_true_0x1,
.depth = 272,
.width = 1,
.edata = NULL,
},
};
const bcmlrd_map_field_data_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_field_data = {
.fields = 2,
.field = bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_field_data_mmd
};
static const bcmlrd_map_table_attr_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_attr_entry[] = {
{ /* 0 */
.key = BCMLRD_MAP_TABLE_ATTRIBUTE_INTERACTIVE,
.value = FALSE,
},
{ /* 1 */
.key = BCMLRD_MAP_TABLE_ATTRIBUTE_TABLE_MAX_INDEX,
.value = 2047,
},
{ /* 2 */
.key = BCMLRD_MAP_TABLE_ATTRIBUTE_TABLE_MIN_INDEX,
.value = 0,
},
};
static const bcmlrd_map_attr_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_attr_group = {
.attributes = 3,
.attr = bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_attr_entry,
};
const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_src_field_desc_s20[1] = {
{
.field_id = VFI_ING_EGR_MEMBER_PORTS_PROFILEt_EGR_MEMBER_PORTSf,
.field_idx = 0,
.minbit = 0,
.maxbit = 0,
.entry_idx = 0,
.reserved = 0
},
};
const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_vfi_ing_egr_member_ports_profile_dst_field_desc_d2[1] = {
{
.field_id = BITMAPf,
.field_idx = 0,
.minbit = 0,
.maxbit = 271,
.entry_idx = 0,
.reserved = 0,
},
};
const bcmlrd_field_xfrm_desc_t
bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_fwd_s20_d2_desc = {
.handler_id = BCMLTD_TRANSFORM_BCM56990_B0_LTA_BCMLTX_PORT_ARRAY_TO_PBMP_XFRM_HANDLER_FWD_S20_D2_ID,
.src_fields = 1,
.src = bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_src_field_desc_s20,
.dst_fields = 1,
.dst = bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_vfi_ing_egr_member_ports_profile_dst_field_desc_d2,
};
const bcmlrd_field_xfrm_desc_t
bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_rev_s20_d2_desc = {
.handler_id = BCMLTD_TRANSFORM_BCM56990_B0_LTA_BCMLTX_PORT_ARRAY_TO_PBMP_XFRM_HANDLER_REV_S20_D2_ID,
.src_fields = 1,
.src = bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_vfi_ing_egr_member_ports_profile_dst_field_desc_d2,
.dst_fields = 1,
.dst = bcm56990_b0_lrd_bcmltx_port_array_to_pbmp_src_field_desc_s20,
};
static const bcmlrd_map_entry_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_port_bitmap_profile_map_entry[] = {
{ /* 0 */
.entry_type = BCMLRD_MAP_ENTRY_MAPPED_KEY,
.desc = {
.field_id = BCMLRD_FIELD_INDEX,
.field_idx = 0,
.minbit = 0,
.maxbit = 10,
.entry_idx = 0,
.reserved = 0
},
.u = {
.mapped = {
.src = {
.field_id = VFI_ING_EGR_MEMBER_PORTS_PROFILEt_VFI_ING_EGR_MEMBER_PORTS_PROFILE_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 10,
.entry_idx = 0,
.reserved = 0
}
}
},
},
{ /* 1 */
.entry_type = BCMLRD_MAP_ENTRY_FWD_VALUE_FIELD_XFRM_HANDLER,
.desc = {
.field_id = 0,
.field_idx = 0,
.minbit = 0,
.maxbit = 0,
.entry_idx = 0,
.reserved = 0
},
.u = {
.xfrm = {
/* handler: bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_fwd_s20_d2 */
.desc = &bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_fwd_s20_d2_desc,
},
},
},
{ /* 2 */
.entry_type = BCMLRD_MAP_ENTRY_REV_VALUE_FIELD_XFRM_HANDLER,
.desc = {
.field_id = 0,
.field_idx = 0,
.minbit = 0,
.maxbit = 0,
.entry_idx = 0,
.reserved = 0
},
.u = {
.xfrm = {
/* handler: bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_rev_s20_d2 */
.desc = &bcm56990_b0_lta_bcmltx_port_array_to_pbmp_xfrm_handler_rev_s20_d2_desc,
},
},
},
};
static const bcmlrd_map_group_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_group[] = {
{
.dest = {
.kind = BCMLRD_MAP_PHYSICAL,
.id = PORT_BITMAP_PROFILEm,
},
.entries = 3,
.entry = bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_port_bitmap_profile_map_entry
},
};
const bcmlrd_map_t bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map = {
.src_id = VFI_ING_EGR_MEMBER_PORTS_PROFILEt,
.field_data = &bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_field_data,
.groups = 1,
.group = bcm56990_b0_lrd_vfi_ing_egr_member_ports_profile_map_group,
.table_attr = &bcm56990_b0_lrd_vfi_ing_egr_member_ports_profilet_attr_group,
.entry_ops = BCMLRD_MAP_TABLE_ENTRY_OPERATION_LOOKUP | BCMLRD_MAP_TABLE_ENTRY_OPERATION_TRAVERSE | BCMLRD_MAP_TABLE_ENTRY_OPERATION_INSERT | BCMLRD_MAP_TABLE_ENTRY_OPERATION_UPDATE | BCMLRD_MAP_TABLE_ENTRY_OPERATION_DELETE
};
| 35.536458 | 226 | 0.661879 |
a90fea62e12cedcfb6f1ac51652642ed9d0737fd | 5,463 | h | C | System/Library/PrivateFrameworks/HealthDaemon.framework/HDHealthEntity.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | System/Library/PrivateFrameworks/HealthDaemon.framework/HDHealthEntity.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/HealthDaemon.framework/HDHealthEntity.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Saturday, June 1, 2019 at 6:49:34 PM Mountain Standard Time
* Operating System: Version 12.1.1 (Build 16C5050a)
* Image Source: /System/Library/PrivateFrameworks/HealthDaemon.framework/HealthDaemon
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <HealthDaemon/HealthDaemon-Structs.h>
#import <HealthDaemon/HDSQLiteEntity.h>
#import <libobjc.A.dylib/HDHealthEntityEncoding.h>
@interface HDHealthEntity : HDSQLiteEntity <HDHealthEntityEncoding>
+(id)defaultForeignKey;
+(id)entityEncoderForProfile:(id)arg1 database:(id)arg2 purpose:(long long)arg3 encodingOptions:(id)arg4 authorizationFilter:(/*^block*/id)arg5 ;
+(BOOL)performWriteTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 usingBlock:(/*^block*/id)arg3 ;
+(BOOL)performReadTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 block:(/*^block*/id)arg3 ;
+(id)uniquedColumns;
+(long long)protectionClass;
+(id)propertyForSyncProvenance;
+(id)propertyForSyncAnchor;
+(id)anyWithPredicate:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 ;
+(BOOL)deleteEntitiesWithPredicate:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 ;
+(id)databaseName;
+(BOOL)performReadTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 usingBlock:(/*^block*/id)arg3 ;
+(BOOL)enumerateEntitiesForSyncWithProperties:(id)arg1 predicate:(id)arg2 session:(id)arg3 syncAnchorRange:(HDSyncAnchorRange)arg4 limit:(unsigned long long)arg5 lastSyncAnchor:(long long*)arg6 healthDatabase:(id)arg7 error:(id*)arg8 block:(/*^block*/id)arg9 ;
+(long long)nextSyncAnchorWithStartAnchor:(long long)arg1 predicate:(id)arg2 session:(id)arg3 healthDatabase:(id)arg4 error:(id*)arg5 ;
+(BOOL)performWriteTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 usingBlock:(/*^block*/id)arg3 inaccessibilityHandler:(/*^block*/id)arg4 ;
+(BOOL)enumerateProperties:(id)arg1 withPredicate:(id)arg2 healthDatabase:(id)arg3 error:(id*)arg4 enumerationHandler:(/*^block*/id)arg5 ;
+(BOOL)performWriteTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 block:(/*^block*/id)arg3 inaccessibilityHandler:(/*^block*/id)arg4 ;
+(id)predicateForSyncWithPredicate:(id)arg1 syncEntityClass:(Class)arg2 session:(id)arg3 syncAnchorRange:(HDSyncAnchorRange)arg4 ;
+(id)protectedDatabaseName;
+(id)createTableSQL;
+(id)updateSQLForTimeOffsetWithBindingCount:(unsigned long long*)arg1 ;
+(id)maxRowIDForPredicate:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 ;
+(long long)countOfObjectsWithPredicate:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 ;
+(id)columnNamesForTimeOffset;
+(BOOL)performPostJournalMergeCleanupWithTransaction:(id)arg1 profile:(id)arg2 error:(id*)arg3 ;
+(id)insertOrReplaceEntity:(BOOL)arg1 healthDatabase:(id)arg2 properties:(id)arg3 error:(id*)arg4 bindingHandler:(/*^block*/id)arg5 ;
+(BOOL)enumerateEntitiesForSyncWithProperties:(id)arg1 predicate:(id)arg2 syncEntityClass:(Class)arg3 session:(id)arg4 syncAnchorRange:(HDSyncAnchorRange)arg5 orderingProperties:(id)arg6 orderingDirections:(id)arg7 limit:(unsigned long long)arg8 lastSyncAnchor:(long long*)arg9 healthDatabase:(id)arg10 error:(id*)arg11 block:(/*^block*/id)arg12 ;
+(id)_syncQueryWithDatabase:(id)arg1 predicate:(id)arg2 orderingProperties:(id)arg3 orderingDirections:(id)arg4 limit:(unsigned long long)arg5 anchorProperty:(id)arg6 ;
+(long long)nextSyncAnchorWithStartAnchor:(long long)arg1 predicate:(id)arg2 syncEntityClass:(Class)arg3 session:(id)arg4 orderingProperties:(id)arg5 orderingDirections:(id)arg6 limit:(unsigned long long)arg7 healthDatabase:(id)arg8 error:(id*)arg9 ;
+(id)_syncQueryDescriptorWithPredicate:(id)arg1 orderingProperties:(id)arg2 orderingDirections:(id)arg3 limit:(unsigned long long)arg4 anchorProperty:(id)arg5 ;
+(BOOL)performWriteTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 block:(/*^block*/id)arg3 ;
+(BOOL)performHighPriorityReadTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 block:(/*^block*/id)arg3 ;
+(BOOL)_isNilDatabase:(id)arg1 error:(id*)arg2 ;
+(unsigned long long)_transactionOptionsForWriting:(BOOL)arg1 ;
+(BOOL)updateProperties:(id)arg1 predicate:(id)arg2 healthDatabase:(id)arg3 error:(id*)arg4 bindingHandler:(/*^block*/id)arg5 ;
+(id)propertyValueForAnyWithProperty:(id)arg1 predicate:(id)arg2 healthDatabase:(id)arg3 error:(id*)arg4 ;
+(BOOL)performHighPriorityReadTransactionWithHealthDatabase:(id)arg1 error:(id*)arg2 usingBlock:(/*^block*/id)arg3 ;
-(BOOL)getValuesForProperties:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 handler:(/*^block*/id)arg4 ;
-(id)valueForProperty:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 ;
-(BOOL)updateProperties:(id)arg1 healthDatabase:(id)arg2 error:(id*)arg3 bindingHandler:(/*^block*/id)arg4 ;
-(id)stringForProperty:(id)arg1 healthDatabase:(id)arg2 error:(out id*)arg3 ;
-(id)dateForProperty:(id)arg1 transaction:(id)arg2 error:(id*)arg3 ;
-(BOOL)setDate:(id)arg1 forProperty:(id)arg2 transaction:(id)arg3 error:(id*)arg4 ;
-(id)stringForProperty:(id)arg1 transaction:(id)arg2 error:(id*)arg3 ;
-(BOOL)setString:(id)arg1 forProperty:(id)arg2 transaction:(id)arg3 error:(id*)arg4 ;
-(id)numberForProperty:(id)arg1 transaction:(id)arg2 error:(id*)arg3 ;
-(BOOL)setNumber:(id)arg1 forProperty:(id)arg2 transaction:(id)arg3 error:(id*)arg4 ;
-(id)foreignKeyEntity:(Class)arg1 forProperty:(id)arg2 transaction:(id)arg3 error:(id*)arg4 ;
-(BOOL)setForeignKeyEntity:(id)arg1 forProperty:(id)arg2 transaction:(id)arg3 error:(id*)arg4 ;
@end
| 84.046154 | 347 | 0.787846 |
a9b3644791eda5e620ac60b4041bb67e831aa215 | 21,512 | c | C | src/hg/liftAgp/liftAgp.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 171 | 2015-04-22T15:16:02.000Z | 2022-03-18T20:21:53.000Z | src/hg/liftAgp/liftAgp.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 60 | 2016-10-03T15:15:06.000Z | 2022-03-30T15:21:52.000Z | src/hg/liftAgp/liftAgp.c | andypohl/kent | af7a004c8f3fa909cd8c2cfc2e5bea60e3421cd1 | [
"MIT"
] | 80 | 2015-04-16T10:39:48.000Z | 2022-03-29T16:36:30.000Z | /* Program to lift tracks that have nearly the same agp, but slightly
different. Initially designed for chr21 and chr22 which are starting
to accumulate ticky tack changes. A fair bit of this code was stolen from
hgLoadBed. */
/* Copyright (C) 2014 The Regents of the University of California
* See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
#include "common.h"
#include "agpFrag.h"
#include "linefile.h"
#include "hash.h"
#include "cheapcgi.h"
struct bedStub
/* A line in a bed file with chromosome, start, end position parsed out. */
{
struct bedStub *next; /* Next in list. */
char *chrom; /* Chromosome . */
unsigned chromStart; /* Start position. */
unsigned chromEnd; /* End position. */
char *line; /* Line. */
};
struct commonBlock
/* A Region of a chromsome that is the same between two assemblies. */
{
struct commonBlock *next; /* Next in list. */
char *chrom; /* Name of chromosome, 'chr22' */
unsigned chromStartA; /* Start of block on version A of .agp */
unsigned chromEndA; /* End of block on version A of .agp */
unsigned chromStartB; /* Start of block on version B of .agp */
unsigned chromEndB; /* End of block on version B of .agp */
};
enum testResult
/* Enumerate test categories. */
{
trNA,
trPassed,
trFailed,
trMissing,
};
struct testPoint
/* A single point in the genome to use for testing. Idea is to create these
randomly and see if they end up where they should in the genome via the .agp. */
{
struct testPoint *next; /* Next in list. */
char *chrom; /* Name of chromosome, 'chr22' */
unsigned chromStart; /* Start of block on version B of .agp */
unsigned chromEnd; /* End of block on version B of .agp */
char *clone; /* Name of clone. */
unsigned chromStartA; /* Start of block on version A of .agp */
unsigned chromEndA; /* End of block on version A of .agp */
unsigned cloneStart; /* Start in clone. */
unsigned cloneEnd; /* End in clone. */
enum testResult result; /* Result of lifting this point. */
};
FILE *diagnostics = NULL; /* Output file for some diagnostics. */
int cannotConvert = 0; /* Keep track of how many get dropped. */
int canConvert = 0; /* Keep track of how many we successfully convert. */
boolean testMode = FALSE; /* Are we in self-test mode or not? */
void usage()
{
errAbort("liftAgp - Program to lift tracks that have nearly the same .agp file,\n"
"but slightly different. Initially designed for chr21 and chr22 which\n"
"are starting to accumulate ticky-tacky changes. Currently works for files\n"
"which have a bed like structure, i.e. chr, chrStart, chrEnd.\n"
"usage:\n\t"
"liftAgp <oldGenomeAgp> <newGenomeAgp> <oldBedFiles...>\n\n"
"There is also a special testing mode which is called like so:\n\t"
"liftAgp <oldGenomeAgp> <newGenomeAgp> -test\n" );
}
void commonBlockFree(struct commonBlock **pEl)
/* Free a single dynamically allocated commonBlock */
{
struct commonBlock *el;
if ((el = *pEl) == NULL) return;
freeMem(el->chrom);
freez(pEl);
}
void commonBlockFreeList(struct commonBlock **pList)
/* Free a list of dynamically allocated commonBlock's */
{
struct commonBlock *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
commonBlockFree(&el);
}
*pList = NULL;
}
void bedStubFree(struct bedStub **pEl)
/* Free a single dynamically allocated bedStub */
{
struct bedStub *el;
if ((el = *pEl) == NULL) return;
freeMem(el->chrom);
freeMem(el->line);
freez(pEl);
}
void bedStubFreeList(struct bedStub **pList)
/* Free a list of dynamically allocated bedStub's */
{
struct bedStub *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
bedStubFree(&el);
}
*pList = NULL;
}
void testPointFree(struct testPoint **pEl)
/* Free a single dynamically allocated testPoint */
{
struct testPoint *el;
if ((el = *pEl) == NULL) return;
freeMem(el->chrom);
freeMem(el->clone);
freez(pEl);
}
void testPointFreeList(struct testPoint **pList)
/* Free a list of dynamically allocated testPoint's */
{
struct testPoint *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
testPointFree(&el);
}
*pList = NULL;
}
int findBedSize(char *fileName)
/* Read first line of file and figure out how many words in it. */
{
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *words[32];
int wordCount;
wordCount = lineFileChop(lf, words);
if (wordCount == 0)
errAbort("%s appears to be empty", fileName);
lineFileClose(&lf);
return wordCount;
}
void loadOneBed(char *fileName, int bedSize, struct bedStub **pList)
/* Load one bed file. Make sure all lines have bedSize fields.
* Put results in *pList. */
{
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *words[64], *line, *dupe;
int wordCount;
struct bedStub *bed;
printf("Reading %s\n", fileName);
while (lineFileNext(lf, &line, NULL))
{
dupe = cloneString(line);
wordCount = chopLine(line, words);
lineFileExpectWords(lf, bedSize, wordCount);
AllocVar(bed);
bed->chrom = cloneString(words[0]);
bed->chromStart = lineFileNeedNum(lf, words, 1);
bed->chromEnd = lineFileNeedNum(lf, words, 2);
bed->line = dupe;
slAddHead(pList, bed);
}
lineFileClose(&lf);
}
void writeBedTab(char *fileName, struct bedStub *bedList, int bedSize)
/* Write out bed list to tab-separated file. */
{
struct bedStub *bed;
FILE *f = mustOpen(fileName, "w");
char *words[64];
int i, wordCount;
for (bed = bedList; bed != NULL; bed = bed->next)
{
wordCount = chopLine(bed->line, words);
fprintf(f, "%s\t%d\t%d", bed->chrom, bed->chromStart, bed->chromEnd);
if (2 == wordCount-1)
fputc('\n', f);
else
fputc('\t', f);
for (i=3; i<wordCount; ++i)
{
fputs(words[i], f);
if (i == wordCount-1)
fputc('\n', f);
else
fputc('\t', f);
}
}
fclose(f);
}
int agpFragChrCmp(const void *va, const void *vb)
/* Compare to sort based on chrom, chromStart */
{
const struct agpFrag *a = *((struct agpFrag **)va);
const struct agpFrag *b = *((struct agpFrag **)vb);
int dif;
dif = strcmp(a->chrom, b->chrom);
if (dif == 0)
dif = a->chromStart - b->chromStart;
return dif;
}
struct hash *hashAgpByClone(struct agpFrag *afList)
/* Load all of the agp's in a file into a hash indexed by the chromosome. */
{
struct hash *retHash = newHash(10);
struct agpFrag *af= NULL;
for(af = afList; af != NULL; af = af->next)
{
hashAddUnique(retHash, af->frag, af);
}
return retHash;
}
boolean sameSequence(struct agpFrag *a, struct agpFrag *b)
/* same if clone name, start, end, strand are the same. */
{
if(a == NULL || b == NULL)
return FALSE;
if(a->fragStart != b->fragStart || a->fragEnd != b->fragEnd)
return FALSE;
if(differentString(a->frag, b->frag))
return FALSE;
if(differentString(a->strand, b->strand))
return FALSE;
return TRUE;
}
static boolean findOverlap(struct agpFrag *a, struct agpFrag *b,
unsigned int *commonStart, unsigned int *commonEnd)
/* Find where the agpFrags overlap */
{
unsigned int start=0, end=0;
assert(a && b);
assert(sameString(a->frag, b->frag));
assert(sameString(a->strand, b->strand));
/* if we don't overlap abort */
if(rangeIntersection(a->fragStart, a->fragEnd, b->fragStart, b->fragEnd) <= 0)
return FALSE;
/* find start */
if(a->fragStart < b->fragStart)
start = b->fragStart;
else
start = a->fragStart;
/* find end */
if(a->fragEnd > b->fragEnd)
end = b->fragEnd;
else
end = a->fragEnd;
*commonStart = start;
*commonEnd = end;
return TRUE;
}
void findSubSeq(struct agpFrag *a, struct agpFrag *b)
/* Find where the common sub-sequence between a and b is. */
{
boolean foundOverlap;
unsigned int commonStart=0, commonEnd=0;
int startDiff = 0;
int endDiff =0;
assert(sameString(a->frag, b->frag));
foundOverlap = findOverlap(a, b, &commonStart, &commonEnd);
assert(foundOverlap);
startDiff = commonStart - a->fragStart;
endDiff = a->fragEnd - commonEnd;
a->chromStart += startDiff;
a->chromEnd -= endDiff;
a->fragStart = commonStart;
a->fragEnd = commonEnd;
startDiff = commonStart - b->fragStart;
endDiff = b->fragEnd - commonEnd;
b->chromStart += startDiff;
b->chromEnd -= endDiff;
b->fragStart = commonStart;
b->fragEnd = commonEnd;
}
boolean isSubSeq(struct agpFrag *a, struct agpFrag *b)
/* Is there a common sub-sequence between a and b? */
{
boolean answer;
unsigned int commonStart = 0, commonEnd = 0;
if(a==NULL || b == NULL)
return FALSE;
if(differentString(a->frag, b->frag))
return FALSE;
if(differentString(a->strand, b->strand))
return FALSE;
if(findOverlap(a,b,&commonStart, &commonEnd))
return TRUE;
return FALSE;
}
boolean noGap(struct agpFrag *a, struct agpFrag *b)
/* Return TRUE if there is no gap, FALSE if there is a gap. */
{
if(b->chromStart == a->chromEnd) // || b->chromStart == a->chromEnd -1 ) // Strange off by one value...
return TRUE;
return FALSE;
}
void extendCommonBlock( struct agpFrag **oldFrag, struct agpFrag **newFrag,
struct commonBlock *cb)
/* Extend the common block as long as new and old agps are the same. */
{
struct agpFrag *oldNext = NULL, *oldIt = NULL;
struct agpFrag *newNext = NULL, *newIt = NULL;
oldIt = *oldFrag;
newIt = *newFrag;
while(1)
{
oldNext = oldIt->next;
newNext = newIt->next;
/* if we're the same extend otherwise cap the common block and return. */
if(sameSequence(oldNext, newNext) && noGap(oldIt, oldNext) && noGap(newIt, newNext))
{
oldIt = oldNext;
newIt = newNext;
}
else
{
cb->chromEndA = oldIt->chromEnd;
cb->chromEndB = newIt->chromEnd;
break;
}
}
*oldFrag = oldNext;
*newFrag = newNext;
}
struct commonBlock *createCommonBlocks(struct agpFrag *oldFrag, struct agpFrag *newFrag)
/* Create a list of common blocks in the chromosomes. */
{
struct agpFrag *newIt, *oldIt; /* Iterators for the lists. */
struct agpFrag *newMark, *oldMark; /* Placeholders in the lists. */
struct commonBlock *cbList = NULL, *cb = NULL;
boolean blockSearch = 0;
boolean increment = 0;
newMark = newIt = newFrag;
oldMark = oldIt = oldFrag;
while(newIt != NULL && oldIt != NULL)
{
blockSearch = FALSE;
/* Check to see if we can find a match on the new sequecne for the old. */
for(newMark = newIt; newMark != NULL && !blockSearch; newMark = newMark->next)
{
if(sameSequence(newMark, oldIt))
{
blockSearch = TRUE;
newIt = newMark;
break;
}
else if(isSubSeq(newIt, oldIt))
{
findSubSeq(newIt, oldIt);
blockSearch = TRUE;
break;
}
}
/* if we have a match extend it. */
if(sameSequence(newIt, oldIt))
{
AllocVar(cb);
cb->chrom = cloneString(oldIt->chrom);
cb->chromStartA = oldIt->chromStart;
cb->chromStartB = newIt->chromStart;
extendCommonBlock(&oldIt, &newIt, cb);
slAddHead(&cbList, cb);
}
if(!blockSearch && newIt != NULL && oldIt != NULL)
{
/* Couldn't find a match for these guys try the next pair. */
newIt = newIt->next;
oldIt = oldIt->next;
}
}
return cbList;
}
unsigned int calcAgpSize(struct agpFrag *agpList)
{
struct agpFrag *agp = NULL;
unsigned int size =0;
for(agp = agpList; agp != NULL; agp = agp->next)
{
size += agp->chromEnd - agp->chromStart;
}
return size;
}
unsigned int calcCbSize(struct commonBlock *cbList)
{
struct commonBlock *cb = NULL;
unsigned int size = 0;
for(cb = cbList; cb != NULL; cb = cb->next)
{
size += cb->chromEndA - cb->chromStartA;
}
return size;
}
struct commonBlock *findCommonBlockForBed(struct bedStub *bs, struct commonBlock *cbList)
/* just a linear search for a block which contains the bedStub, return NULL if not
found. */
{
struct commonBlock *cb = NULL;
for(cb = cbList; cb != NULL; cb = cb->next)
{
if(sameString(cb->chrom, bs->chrom) &&
cb->chromStartA <= bs->chromStart &&
cb->chromEndA > bs->chromEnd)
{
return cb;
}
}
return NULL;
}
boolean convertBedStub(void *p, struct commonBlock *cbList)
/* Convert a bedStub to clone coordinates via the old agp and then
from clone coordinates in the newAgp to new chrom coordinates */
{
struct commonBlock *cb = NULL;
struct bedStub *bs = p;
cb = findCommonBlockForBed(bs, cbList);
if(cb == NULL)
{
if(diagnostics != NULL)
fprintf(diagnostics, "Can't convert %s:%u-%u\n", bs->chrom, bs->chromStart, bs->chromEnd);
cannotConvert++;
if(testMode)
{
struct testPoint *tp = p;
testPointFree(&tp);
}
else
bedStubFree(&bs);
return FALSE;
}
else
{
int diff = cb->chromStartB - cb->chromStartA;
canConvert++;
bs->chromStart += diff;
bs->chromEnd += diff;
}
return TRUE;
}
void commonBlockTabOut(FILE *out, struct commonBlock *cbList)
{
struct commonBlock *cb = NULL;
for(cb = cbList; cb != NULL; cb = cb->next)
{
fprintf(out, "%s\t%u\t%u\t%u\t%u\t%u\t%u\n", cb->chrom, cb->chromStartA, cb->chromEndA,
cb->chromEndA - cb->chromStartA,
cb->chromStartB, cb->chromEndB,
cb->chromEndB - cb->chromStartB);
}
}
void *convertBeds(void *list, struct commonBlock *cbList)
/* convert a list of bed Stubs using the conversion table created. */
{
struct bedStub *bsList = list;
struct bedStub *bs = NULL, *bsNext;
struct bedStub *convertedList = NULL;
int bedCount = 0;
boolean converted = FALSE;
warn("Converting beds.");
for(bs = bsList; bs != NULL; bs = bsNext)
{
/* litte UI stuff to let the user know we're making progress... */
if(bedCount % 1000 == 0)
{
fprintf(stderr, ".");
fflush(stderr);
}
bedCount++;
/* Actual conversion */
bsNext = bs->next;
converted = convertBedStub(bs, cbList);
if(converted)
{
slAddHead(&convertedList, bs);
}
else
{
bs = NULL;
}
}
return convertedList;
}
void liftAgp(char *oldAgpFile, char *newAgpFile, int numFiles, char *oldBedFiles[])
/* Convert oldBedFile to clone space via oldAgpFile then from clone space to new
assembly via new .agp file. */
{
struct bedStub *bsList = NULL, *bs = NULL, *bsNext = NULL;
struct bedStub *convertedList = NULL;
struct dyString *bedFile = newDyString(1024);
int bedCount = 0;
int convertedBedCount = 0;
int i=0;
unsigned int dnaSize = 0;
unsigned int dnaLifted = 0;
struct agpFrag *newFrag = NULL, *oldFrag = NULL, *tmpFrag = NULL;
struct commonBlock *cbList = NULL;
/* Load the agp fragments. */
warn("Loading oldAgp from %s", oldAgpFile);
oldFrag = agpFragLoadAllNotGaps(oldAgpFile);
for (tmpFrag=oldFrag; tmpFrag != NULL; tmpFrag=tmpFrag->next)
{
// file is 1-based but agpFragLoad() now assumes 0-based:
tmpFrag->chromStart -= 1;
tmpFrag->fragStart -= 1;
}
slSort(&oldFrag, agpFragChrCmp);
warn("Loading newAgp from %s", newAgpFile);
newFrag = agpFragLoadAllNotGaps(newAgpFile);
for (tmpFrag=newFrag; tmpFrag != NULL; tmpFrag=tmpFrag->next)
{
// file is 1-based but agpFragLoad() now assumes 0-based:
tmpFrag->chromStart -= 1;
tmpFrag->fragStart -= 1;
}
slSort(&newFrag, agpFragChrCmp);
dnaSize = calcAgpSize(newFrag);
/* Find the common blocks between the two agps. */
warn("Creating conversion table.\n");
cbList = createCommonBlocks(oldFrag, newFrag);
dnaLifted = calcCbSize(cbList);
warn("lifted %u of %u bases from old agp (%4.2f%%) in %d blocks.", dnaLifted, dnaSize, (100*(double)dnaLifted/dnaSize), slCount(cbList));
if(diagnostics != NULL)
commonBlockTabOut(diagnostics, cbList);
/* Do the conversion. */
for(i=0; i<numFiles; i++)
{
int bedSize = findBedSize(oldBedFiles[i]);
dyStringClear(bedFile);
dyStringPrintf(bedFile, "%s.lft", oldBedFiles[i]);
/* Load the beds into memory, (I should probably do this one at a time.) */
warn("Loading beds from %s", oldBedFiles[i]);
loadOneBed(oldBedFiles[i], bedSize, &bsList);
bedCount = slCount(bsList);
convertedList = convertBeds(bsList, cbList);
convertedBedCount = slCount(convertedList);
warn(", Converted %d of %d beds. %4.2f%%\n", convertedBedCount, bedCount,
(100*(float)convertedBedCount/(float)bedCount));
warn("Writing converted beds to %s", bedFile->string);
/* Write out the converted beds. */
writeBedTab(bedFile->string, convertedList, bedSize);
bedStubFreeList(&convertedList);
bsList = NULL;
}
/* Cleanup. */
agpFragFreeList(&newFrag);
agpFragFreeList(&oldFrag);
commonBlockFreeList(&cbList);
warn("Done.");
}
/* ---------------- Begin code for testing self. ---------------------- */
struct testPoint *createPoint(struct agpFrag *agp, int cloneCoordinate)
/* create a test point in the clone, determined by the cloneCoordinate */
{
struct testPoint *tp = NULL;
AllocVar(tp);
tp->chrom = cloneString(agp->chrom);
tp->clone = cloneString(agp->frag);
assert(cloneCoordinate >= agp->fragStart && cloneCoordinate < agp->fragEnd);
tp->cloneStart = cloneCoordinate;
tp->cloneEnd = cloneCoordinate+1;
tp->chromStart = tp->chromStartA = agp->chromStart - agp->fragStart + tp->cloneStart;
tp->chromEnd = tp->chromEndA = agp->chromStart - agp->fragStart + tp->cloneEnd;
return tp;
}
unsigned getRandCoord(unsigned start, unsigned end)
/* return a random nubmer uniformly distributed between start and end. */
{
unsigned ran = rand();
unsigned size = end - start;
assert(size >= 0);
ran = ran % size;
ran = start + ran;
return ran;
}
struct testPoint *generateRandomTestPoints(struct agpFrag *agpList, int pointsPerClone)
/* create a bunch of random points on each clone. */
{
struct testPoint *tp = NULL, *tpList = NULL;
struct agpFrag *agp = NULL;
int tpCount;
assert(pointsPerClone >= 2);
srand(1);
for(agp = agpList; agp != NULL; agp = agp->next)
{
tp = createPoint(agp, agp->fragStart);
slAddHead(&tpList, tp);
tp = createPoint(agp, agp->fragEnd-1);
slAddHead(&tpList, tp);
for(tpCount = 2; tpCount < pointsPerClone; tpCount++)
{
int coordinate = getRandCoord(agp->fragStart, agp->fragEnd);
if(diagnostics != NULL)
fprintf(diagnostics, "%u\n", coordinate - agp->fragStart + agp->chromStart);
tp = createPoint(agp, coordinate);
slAddHead(&tpList, tp);
}
}
return tpList;
}
void checkConversion(struct testPoint *tpList, struct hash *oldAgpHash, struct hash *newAgpHash,
int *correct, int *wrong, struct commonBlock *cbList)
/* Loop through our converted coordinates and see which are correct and which are wrong. */
{
struct testPoint *tp = NULL;
struct agpFrag *newAgp = NULL, *oldAgp = NULL;
unsigned start=0, end=0;
for(tp = tpList; tp != NULL; tp = tp->next)
{
newAgp = hashFindVal(newAgpHash, tp->clone);
oldAgp = hashFindVal(oldAgpHash, tp->clone);
if(newAgp != NULL && oldAgp != NULL)
{
start = newAgp->chromStart - newAgp->fragStart + tp->cloneStart;
end= newAgp->chromStart - newAgp->fragStart + tp->cloneEnd;
if(start == tp->chromStart && end == tp->chromEnd)
{
tp->result = trPassed;
(*correct)++;
}
else
{
tp->result = trFailed;
(*wrong)++;
}
}
else
{
errAbort("Can't find %s", tp->clone);
}
}
}
void testLiftAgp(char *oldAgpFile, char *newAgpFile)
/* do a test lift of artificially generated track. */
{
struct testPoint *tp=NULL, *tpList = NULL;
struct testPoint *convertedList = NULL;
struct commonBlock *cbList = NULL;
int tpCount = 0;
int passedTpCount = 0;
int numTpPerClone = 100;
unsigned int dnaSize = 0;
unsigned int dnaLifted = 0;
struct hash *oldAgpHash = NULL;
struct hash *newAgpHash = NULL;
struct agpFrag *newFrag = NULL, *oldFrag = NULL, *tmpFrag = NULL;
int correct =0, wrong=0;
/* Loading and hashing agps. */
warn("Loading oldAgp from %s", oldAgpFile);
oldFrag = agpFragLoadAllNotGaps(oldAgpFile);
slSort(&oldFrag, agpFragChrCmp);
warn("Loading newAgp from %s", newAgpFile);
newFrag = agpFragLoadAllNotGaps(newAgpFile);
slSort(&newFrag, agpFragChrCmp);
oldAgpHash = hashAgpByClone(oldFrag);
newAgpHash = hashAgpByClone(newFrag);
/* Create the common blocks. */
warn("Creating conversion table.\n");
dnaSize = calcAgpSize(newFrag);
cbList = createCommonBlocks(oldFrag, newFrag);
dnaLifted = calcCbSize(cbList);
warn("lifted %u of %u bases from old agp (%4.2f%%) in %d blocks.\n", dnaLifted, dnaSize, (100*(double)dnaLifted/dnaSize), slCount(cbList));
/* Generate some random data points. */
tpList = generateRandomTestPoints(oldFrag, numTpPerClone);
tpCount = slCount(tpList);
/* Convert and check lifts. */
convertedList = convertBeds(tpList, cbList);
checkConversion(convertedList, oldAgpHash, newAgpHash, &correct, &wrong, cbList);
/* Do some cleanup and reporting. */
agpFragFreeList(&newFrag);
agpFragFreeList(&oldFrag);
testPointFreeList(&convertedList);
commonBlockFreeList(&cbList);
hashFree(&newAgpHash);
hashFree(&oldAgpHash);
warn("%d converted, %d correct, %d wrong %d total.\n", canConvert, correct, wrong, tpCount);
warn("%4.2f%% correct and %4.2f%% converted.", 100*((float)(correct)/(float)canConvert), 100*((float)canConvert/(float)tpCount));
}
/* ---------------- End code for testing self. ---------------------- */
int main(int argc, char *argv[])
{
if(argc <= 3)
usage();
cgiSpoof(&argc, argv);
testMode = cgiBoolean("test");
if(cgiBoolean("diagnostics"))
diagnostics = mustOpen("liftAgp.diagnostics", "w");
if(testMode)
testLiftAgp(argv[1], argv[2]);
else
liftAgp(argv[1], argv[2], argc-3, argv+3);
if(cgiBoolean("diagnostics"))
carefulClose(&diagnostics);
return 0;
}
| 28.568393 | 139 | 0.668232 |
8017493e4c4789a21c6ace36e671c7c161cbf4c5 | 5,696 | c | C | vm_primitives.c | tramdas/memstatpoller | 38fbb15efc9b28db508d21ef557c89b4b29fd94e | [
"BSD-3-Clause"
] | null | null | null | vm_primitives.c | tramdas/memstatpoller | 38fbb15efc9b28db508d21ef557c89b4b29fd94e | [
"BSD-3-Clause"
] | null | null | null | vm_primitives.c | tramdas/memstatpoller | 38fbb15efc9b28db508d21ef557c89b4b29fd94e | [
"BSD-3-Clause"
] | null | null | null | #include "vm_primitives.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <mach/mach_host.h>
/*
* This is what the vm_statistics structure looks like in xnu-2422.1.72 :
*/
//struct vm_statistics64 {
// natural_t free_count; /* # of pages free */
// natural_t active_count; /* # of pages active */
// natural_t inactive_count; /* # of pages inactive */
// natural_t wire_count; /* # of pages wired down */
// uint64_t zero_fill_count; /* # of zero fill pages */
// uint64_t reactivations; /* # of pages reactivated */
// uint64_t pageins; /* # of pageins */
// uint64_t pageouts; /* # of pageouts */
// uint64_t faults; /* # of faults */
// uint64_t cow_faults; /* # of copy-on-writes */
// uint64_t lookups; /* object cache lookups */
// uint64_t hits; /* object cache hits */
// uint64_t purges; /* # of pages purged */
// natural_t purgeable_count; /* # of pages purgeable */
// /*
// * NB: speculative pages are already accounted for in "free_count",
// * so "speculative_count" is the number of "free" pages that are
// * used to hold data that was read speculatively from disk but
// * haven't actually been used by anyone so far.
// */
// natural_t speculative_count; /* # of pages speculative */
//
// /* added for rev1 */
// uint64_t decompressions; /* # of pages decompressed */
// uint64_t compressions; /* # of pages compressed */
// uint64_t swapins; /* # of pages swapped in (via compression segments) */
// uint64_t swapouts; /* # of pages swapped out (via compression segments) */
// natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */
// natural_t throttled_count; /* # of pages throttled */
// natural_t external_page_count; /* # of pages that are file-backed (non-swap) */
// natural_t internal_page_count; /* # of pages that are anonymous */
// uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */
//} __attribute__((aligned(8)));
#define VMSTAT_FAIL_WARN(d) {printf("%s - get_vmstat failed with errno %d", __FUNCTION__, (d));}
#define VMSTAT_FAIL_DIE(d) {VMSTAT_FAIL_WARN(d); abort();}
static int get_vmstat(vm_statistics64_data_t* vmstat)
{
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) vmstat, &count) != KERN_SUCCESS) {
return errno;
}
return 0;
}
static vm_statistics64_data_t _get_vmstat()
{
vm_statistics64_data_t vmstat;
int ret = get_vmstat(&vmstat);
if (ret) {
VMSTAT_FAIL_DIE(ret);
}
return vmstat;
}
uint64_t vmstat_free_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.free_count;
}
uint64_t vmstat_active_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.active_count;
}
uint64_t vmstat_inactive_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.inactive_count;
}
uint64_t vmstat_wire_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.wire_count;
}
uint64_t vmstat_zero_fill_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.zero_fill_count;
}
uint64_t vmstat_reactivations()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.reactivations;
}
uint64_t vmstat_pageins()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.pageins;
}
uint64_t vmstat_pageouts()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.pageouts;
}
uint64_t vmstat_faults()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.faults;
}
uint64_t vmstat_cow_faults()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.cow_faults;
}
uint64_t vmstat_lookups()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.lookups;
}
uint64_t vmstat_hits()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.hits;
}
uint64_t vmstat_purges()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.purges;
}
uint64_t vmstat_purgable_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.purgeable_count;
}
uint64_t vmstat_speculative_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.speculative_count;
}
uint64_t vmstat_decompressions()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.decompressions;
}
uint64_t vmstat_compressions()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.compressions;
}
uint64_t vmstat_swapins()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.swapins;
}
uint64_t vmstat_swapouts()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.swapouts;
}
natural_t vmstat_compressor_page_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.compressor_page_count;
}
natural_t vmstat_throttled_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.throttled_count;
}
natural_t vmstat_external_page_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.external_page_count;
}
natural_t vmstat_internal_page_count()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.internal_page_count;
}
uint64_t vmstat_total_uncompressed_pages_in_compressor()
{
vm_statistics64_data_t vmstat = _get_vmstat();
return vmstat.total_uncompressed_pages_in_compressor;
}
//int main(void)
//{
// printf("A rough thing to just test this\n");
// printf("%llu\n", vmstat_free_count());
// printf("%llu\n", vmstat_inactive_count());
//}
| 26.12844 | 113 | 0.721559 |
a2873341899b098d8d70e3c87e197af782b1fa78 | 644 | h | C | FacialAnimationSystem/playBackManager.h | jdg534/FYP_POST_HANDIN | 367e3eed3a7594ffb08b3e1eb8a7104b46af14cc | [
"MIT"
] | null | null | null | FacialAnimationSystem/playBackManager.h | jdg534/FYP_POST_HANDIN | 367e3eed3a7594ffb08b3e1eb8a7104b46af14cc | [
"MIT"
] | null | null | null | FacialAnimationSystem/playBackManager.h | jdg534/FYP_POST_HANDIN | 367e3eed3a7594ffb08b3e1eb8a7104b46af14cc | [
"MIT"
] | null | null | null | #ifndef _PLAYBACK_MANAGER_H_
#define _PLAYBACK_MANAGER_H_
#include <fmod.hpp>
#include <vector>
class PlayBackManager // manages audio playback
{
public:
~PlayBackManager();
bool isInitialised()
{
return m_initialised;
}
bool init();
void shutdown();
FMOD::System * getSoundSystemPtr()
{
return m_soundSystem;
}
static PlayBackManager * getInstance();
void playSound(FMOD::Sound * s, bool looped);
void update(float dt);
private:
PlayBackManager(); // singleton
FMOD::System * m_soundSystem;
FMOD::Channel * m_playChannel;
unsigned int m_numChannels;
FMOD::Sound * m_toPlay;
bool m_initialised;
};
#endif | 13.702128 | 47 | 0.72205 |
317608a57c6379935e2705febc5d40e8e32422cd | 570 | h | C | src/ucm/util/ucm_config.h | ybwang1cbs/ucx | 1c650ec2f9b0fbee4b8b1ba74942994d62a4436a | [
"BSD-3-Clause"
] | 1 | 2020-04-29T07:43:41.000Z | 2020-04-29T07:43:41.000Z | src/ucm/util/ucm_config.h | ybwang1cbs/ucx | 1c650ec2f9b0fbee4b8b1ba74942994d62a4436a | [
"BSD-3-Clause"
] | 129 | 2020-04-27T15:59:39.000Z | 2022-03-31T18:31:56.000Z | src/ucm/util/ucm_config.h | ybwang1cbs/ucx | 1c650ec2f9b0fbee4b8b1ba74942994d62a4436a | [
"BSD-3-Clause"
] | 2 | 2021-11-30T12:26:06.000Z | 2021-11-30T12:38:19.000Z | /**
* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
#ifndef UCM_UTIL_CONFIG_H_
#define UCM_UTIL_CONFIG_H_
#include <ucs/config/types.h>
#include <ucs/debug/log.h>
#include <stdio.h>
typedef struct ucm_config {
ucs_log_level_t log_level;
int enable_events;
int enable_mmap_reloc;
int enable_malloc_hooks;
int enable_malloc_reloc;
size_t alloc_alignment;
} ucm_config_t;
extern ucm_config_t ucm_global_config;
#endif
| 20.357143 | 76 | 0.670175 |
319899017eeada0cb1d163e63cfbf1ab95dea1d1 | 388 | c | C | projects/MPI/hardway/MPI_name.c | jskyzero/C.Playground | 4a89e688b2e89942a157d3e32babd7a4a35c54ad | [
"MIT"
] | null | null | null | projects/MPI/hardway/MPI_name.c | jskyzero/C.Playground | 4a89e688b2e89942a157d3e32babd7a4a35c54ad | [
"MIT"
] | null | null | null | projects/MPI/hardway/MPI_name.c | jskyzero/C.Playground | 4a89e688b2e89942a157d3e32babd7a4a35c54ad | [
"MIT"
] | null | null | null | #include <mpi.h>
#include <stdio.h>
int main(int argc, char **argv) {
int len;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
// int MPI_Get_processor_name ( char *name, int *resultlen)
// char *name : 实际节点的唯一说明字;
// int *resultlen:在name中返回结果的长度;
MPI_Get_processor_name(name, &len);
printf("Hello, world. I am %s.\n", name);
MPI_Finalize();
return 0;
} | 21.555556 | 61 | 0.667526 |
d94c36c3fb1de50ad53996298079f9c15ed0dbfb | 2,003 | h | C | src/printers/printer.h | cppan/cppan | b4bbdf5e56f9d237f2820301152b7024ca10907b | [
"Apache-2.0"
] | 117 | 2016-03-14T08:26:32.000Z | 2021-12-09T10:17:34.000Z | src/printers/printer.h | fuyanbin/cppan | 77e0f8d6f3e372cd191e9b3af1704403f824c0de | [
"Apache-2.0"
] | 55 | 2016-06-30T10:01:27.000Z | 2019-08-10T19:18:37.000Z | src/printers/printer.h | fuyanbin/cppan | 77e0f8d6f3e372cd191e9b3af1704403f824c0de | [
"Apache-2.0"
] | 25 | 2017-04-21T06:38:17.000Z | 2022-02-02T05:02:25.000Z | /*
* Copyright (C) 2016-2017, Egor Pugin
*
* 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.
*/
#pragma once
#include "checks.h"
#include "project.h"
#define CPP_HEADER_FILENAME "cppan.h"
#define CPPAN_EXPORT "CPPAN_EXPORT"
#define CPPAN_EXPORT_PREFIX "CPPAN_API_"
#define CPPAN_PROLOG "CPPAN_PROLOG"
#define CPPAN_EPILOG "CPPAN_EPILOG"
#define CPPAN_LOCAL_BUILD_PREFIX "cppan-build-"
#define CPPAN_CONFIG_FILENAME "config.cmake"
extern const Strings configuration_types;
extern const Strings configuration_types_normal;
extern const Strings configuration_types_no_rel;
enum class PrinterType
{
CMake,
//Ninja,
// add more here
};
struct BuildSettings;
struct Config;
struct Directories;
struct Settings;
struct Printer
{
Package d;
class AccessTable *access_table = nullptr;
path cwd;
Settings &settings;
Printer();
virtual ~Printer() = default;
virtual void prepare_build(const BuildSettings &bs) const = 0;
virtual void prepare_rebuild() const = 0;
virtual int generate(const BuildSettings &bs) const = 0;
virtual int build(const BuildSettings &bs) const = 0;
virtual void print() const = 0;
virtual void print_meta() const = 0;
virtual void clear_cache() const = 0;
virtual void clear_exports() const = 0;
virtual void clear_export(const path &p) const = 0;
virtual void parallel_vars_check(const ParallelCheckOptions &options) const = 0;
static std::unique_ptr<Printer> create(PrinterType type);
};
| 27.067568 | 84 | 0.738392 |
d96072eb3aa860ffa8625a4c233596c25a60d84c | 1,505 | c | C | aed2 codebench/lista4 - recursividade/questao6.c | RodSalg/PROJECTS-IN-C--AEDI-AND-AEDII- | b49b660c85f7d6e1e17bce1c14501e7a4bcefe39 | [
"MIT"
] | 2 | 2021-08-18T15:49:10.000Z | 2021-08-20T14:39:00.000Z | aed2 codebench/lista4 - recursividade/questao6.c | RodSalg/PROJECTS-IN-C--AEDI-AND-AEDII- | b49b660c85f7d6e1e17bce1c14501e7a4bcefe39 | [
"MIT"
] | null | null | null | aed2 codebench/lista4 - recursividade/questao6.c | RodSalg/PROJECTS-IN-C--AEDI-AND-AEDII- | b49b660c85f7d6e1e17bce1c14501e7a4bcefe39 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void funcao(int a, int b);
void repete(int a, int b);
bool zero(int x){
if(x == 0 ){
return true;
}
return false;
}
int incr(int x){
return x + 1;
}
int decr(int x){
return x - 1;
}
int incrementa_n(int a, int cont){
//antes de entrar o cont é igual ao A
if(cont == 0){
return a;
}else{
if(a < 0){
a =decr(a);
cont = incr(cont);
}else{
a = incr(a);
cont = decr(cont);
}
return incrementa_n(a, cont);
}
}
int multiplica(int x, int b,int cont){
//printf("o x no inicio da funcao eh: %d\n",x);
//printf("o b no inicio da funcao eh: %d\n",b);
if(b == 1){
//printf("o x final eh: %d\n",x);
return x;
}else{
//printf("o x eh: %d\n", x);
x = incrementa_n(x, cont);
b = decr(b);
//printf("o b eh: %d\n",b);
return multiplica(x, b, cont);
}
}
void funcao(int a, int b){
if(b < 0 && a > 0){
b = b * - 1;
a = a * - 1;
}
int aux = a;
a = multiplica(a, b, aux);
printf("%d\n", a);
scanf("%d", &a);
scanf("%d", &b);
repete(a, b);
}
void repete(int a, int b){
if( a == 0 && b == 0){
exit(1);
}else{
return funcao(a, b);
}
}
int main(){
int a;
int b;
scanf("%d", &a);
scanf("%d", &b);
repete(a, b);
}
| 14.754902 | 51 | 0.431894 |
c17981d63511e3ef4b1d3e43b03e77944dad1f6b | 36,022 | c | C | src/cli/ofp_cli.c | ybbh/ofp | 1d6f0f92fd6c7e3da2fc9b221766b5717d760d74 | [
"BSD-3-Clause"
] | null | null | null | src/cli/ofp_cli.c | ybbh/ofp | 1d6f0f92fd6c7e3da2fc9b221766b5717d760d74 | [
"BSD-3-Clause"
] | null | null | null | src/cli/ofp_cli.c | ybbh/ofp | 1d6f0f92fd6c7e3da2fc9b221766b5717d760d74 | [
"BSD-3-Clause"
] | null | null | null | /*-
* Copyright (c) 2014 ENEA Software AB
* Copyright (c) 2014 Nokia
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <pwd.h>
#include <time.h>
#include <errno.h>
#include <odp_api.h>
#include "ofp_errno.h"
#include "ofpi.h"
#include "ofpi_pkt_processing.h"
#include "ofpi_cli.h"
#include "ofpi_log.h"
#include "ofpi_util.h"
#include "ofpi_portconf.h"
#ifdef CLI
void ofpcli_ipsec_init(void);
/*
* Only core 0 runs this.
*/
static int close_cli;
int cli_display_width = 80, cli_display_height = 24;
int cli_curses = 0;
int cli_display_row = 2, cli_display_col = 5;
int cli_display_rows = 10, cli_display_cols = 30;
/** CLI Commands node
*/
struct cli_node {
void (*func)(struct cli_conn *, const char *);
struct cli_node *nextword;
struct cli_node *nextpossibility;
char *word;
const char *help;
char type;
};
/** CLI Command descriptor
*/
struct cli_command {
const char *command;
const char *help;
void (*func)(struct cli_conn *, const char *);
};
/* status bits */
#define CONNECTION_ON 1
#define DO_ECHO 2 /* telnet */
#define DO_SUPPRESS 4 /* telnet */
#define WILL_SUPPRESS 8 /* telnet */
#define WAITING_TELNET_1 16
#define WAITING_TELNET_2 32
#define WAITING_ESC_1 64
#define WAITING_ESC_2 128
#define WAITING_PASSWD 256
#define ENABLED_OK 512
static struct cli_conn connection;
int run_alias = -1;
static void addchars(struct cli_conn *conn, const char *s);
static void parse(struct cli_conn *conn, int extra);
static void close_connection(struct cli_conn *conn)
{
(void)conn;
OFP_DBG("Closing connection...\r\n");
close_cli = 1; /* tell server to close the socket */
}
static int int_ok(char *val)
{
if ((val[0] == '0') &&
(val[1] == 'x' || val[1] == 'X')) {
val += 2;
while (*val) {
if (!((*val >= '0' && *val <= '9') ||
(*val >= 'a' && *val <= 'f') ||
(*val >= 'A' && *val <= 'F')))
return 0;
val++;
}
return 1;
}
while (*val) {
if (*val < '0' || *val > '9')
return 0;
val++;
}
return 1;
}
static int ip4addr_ok(char *val)
{
char b[100], *p, *octet;
int i;
strcpy(b, val);
p = b;
for (i = 0; i < 4; i++) {
octet = strsep(&p, ".");
if (strlen(octet) > 3)
return 0;
if (strlen(octet) == 0)
return 0;
if (!int_ok(octet))
return 0;
if (i < 3 && p == NULL)
return 0;
}
if (p)
return 0;
return 1;
}
static int topname_ok(char *val)
{
if (!strncmp("parse", val, 3))
return 1;
if (!strncmp("resolve", val, 3))
return 1;
if (!strncmp("modify", val, 3))
return 1;
if (!strncmp("search", val, 3))
return 1;
if (!strncmp("learn", val, 3))
return 1;
return 0;
}
static int dev_ok(char *val)
{
int port, vlan;
port = ofp_name_to_port_vlan(val, &vlan);
return (port >= 0 && port < ofp_get_num_ports());
}
static int ip4net_ok(char *val)
{
char b[100], *p, *octet;
int i;
strcpy(b, val);
p = b;
for (i = 0; i < 5; i++) {
if (i == 3)
octet = strsep(&p, "/");
else
octet = strsep(&p, ".");
if (strlen(octet) > 3)
return 0;
if (strlen(octet) == 0)
return 0;
if (!int_ok(octet))
return 0;
if (i < 4 && p == NULL)
return 0;
}
return 1;
}
static int mac_ok(char *val)
{
char *tk_start, *tk_end, *val_end, *pch;
int tk_cnt;
val_end = val + strlen(val);
tk_start = val;
tk_cnt = 0;
while (tk_start != val_end) {
tk_end = strchr(tk_start, ':');
if (tk_end == NULL)
tk_end = val_end;
for (pch = tk_start; pch != tk_end; pch++)
if (!((*pch >= '0' && *pch <= '9') ||
(*pch >= 'a' && *pch <= 'f') ||
(*pch >= 'A' && *pch <= 'F')))
return 0;
if ((tk_end - tk_start) != 2 &&
(tk_end - tk_start) != 1)
return 0;
tk_cnt++;
tk_start = (tk_end == val_end) ? tk_end : tk_end + 1;
}
if (tk_cnt != OFP_ETHER_ADDR_LEN)
return 0;
return 1;
}
static int ip6addr_check_ok(char *val, int len)
{
char *it, *last;
char *last_colon;
char *group_start;
int colon_cnt;
int group_cnt;
odp_bool_t short_format;
it = val;
last = it + len;
last_colon = NULL;
colon_cnt = 0;
group_cnt = 0;
short_format = 0;
while (it < last) {
if ((*it) == ':') {
if ((last_colon != NULL) && (it - 1 == last_colon))
short_format = 1;
last_colon = it;
it++;
colon_cnt++;
} else if (((*it) >= '0' && (*it) <= '9') ||
((*it) >= 'a' && (*it) <= 'f') ||
((*it) >= 'A' && (*it) <= 'F')) {
group_start = it;
while ((it < last) &&
(((*it) >= '0' && (*it) <= '9') ||
((*it) >= 'a' && (*it) <= 'f') ||
((*it) >= 'A' && (*it) <= 'F'))) {
it++;
}
if ((it - group_start > 4) ||
(it - group_start == 0))
return 0;
group_cnt++;
} else
return 0;
}
if (short_format) {
if (colon_cnt > 7 || group_cnt > 8)
return 0;
} else {
if (colon_cnt != 7 || group_cnt != 8)
return 0;
}
return 1;
}
static int ip6addr_ok(char *val)
{
return ip6addr_check_ok(val, strlen(val));
}
static int ip6net_ok(char *val)
{
char *prefix_position;
prefix_position = strstr(val, "/");
if (prefix_position == NULL)
return 0;
if (ip6addr_check_ok(val, prefix_position - val) == 0)
return 0;
prefix_position++;
if (strlen(prefix_position) > 3)
return 0;
if (strlen(prefix_position) == 0)
return 0;
if (!int_ok(prefix_position))
return 0;
return 1;
}
static uint8_t txt_to_hex(char val)
{
if (val >= '0' && val <= '9')
return(val - '0');
if (val >= 'a' && val <= 'f')
return(val - 'a' + 10);
if (val >= 'A' && val <= 'F')
return(val - 'A' + 10);
return 255;
}
int ip4addr_get(const char *tk, uint32_t *addr)
{
int a, b, c, d;
if (sscanf(tk, "%d.%d.%d.%d", &a, &b, &c, &d) < 4)
return 0;
*addr = odp_cpu_to_be_32((a << 24) | (b << 16) | (c << 8) | d);
return 1;
}
int ip4net_get(const char *tk, uint32_t *addr, int *mask)
{
int a, b, c, d;
if (sscanf(tk, "%d.%d.%d.%d/%d", &a, &b, &c, &d, mask) < 5)
return 0;
*addr = odp_cpu_to_be_32((a << 24) | (b << 16) | (c << 8) | d);
return 1;
}
int ip6addr_get(const char *tk, int tk_len, uint8_t *addr)
{
const char *it, *last;
const char *last_colon;
const char *group_start;
int group_cnt;
int group_len;
int dbl_colon_pos;
int i;
memset(addr, 0, 16);
it = tk;
last = it + tk_len;
last_colon = NULL;
group_cnt = 0;
dbl_colon_pos = -1;
while (it < last) {
if ((*it) == ':') {
if ((last_colon != NULL) &&
(it - 1 == last_colon)) {
if (dbl_colon_pos != -1)
return 0;
dbl_colon_pos = group_cnt;
}
last_colon = it;
it++;
} else if (((*it) >= '0' && (*it) <= '9') ||
((*it) >= 'a' && (*it) <= 'f') ||
((*it) >= 'A' && (*it) <= 'F')) {
group_start = it;
while ((it < last) &&
(((*it) >= '0' && (*it) <= '9') ||
((*it) >= 'a' && (*it) <= 'f') ||
((*it) >= 'A' && (*it) <= 'F'))) {
it++;
}
group_len = it - group_start;
if ((group_len > 4) ||
(group_len == 0))
return 0;
if (group_len >= 1)
addr[group_cnt * 2 + 1] =
txt_to_hex(*(it - 1));
if (group_len >= 2)
addr[group_cnt * 2 + 1] |=
txt_to_hex(*(it - 2)) << 4;
if (group_len >= 3)
addr[group_cnt * 2] =
txt_to_hex(*(it - 3));
if (group_len == 4)
addr[group_cnt * 2] |=
txt_to_hex(*(it - 4)) << 4;
group_cnt++;
} else
return 0;
}
if (dbl_colon_pos != -1) {
for (i = 0; i < 16 - (dbl_colon_pos * 2); i++) {
if (i < (group_cnt - dbl_colon_pos) * 2)
addr[15 - i] =
addr[group_cnt * 2 - 1 - i];
else
addr[15 - i] = 0;
}
}
return 1;
}
static void sendstr(struct cli_conn *conn, const char *s)
{
if (S_ISSOCK(conn->fd))
send(conn->fd, s, strlen(s), 0);
else
(void)(write(conn->fd, s, strlen(s)) + 1);
}
void sendcrlf(struct cli_conn *conn)
{
if ((conn->status & DO_ECHO) == 0)
sendstr(conn, "\n"); /* no extra prompts */
else if (conn->status & ENABLED_OK)
sendstr(conn, "\r\n# ");
else
sendstr(conn, "\r\n> ");
}
static void sendprompt(struct cli_conn *conn)
{
if (conn->status & ENABLED_OK)
sendstr(conn, "\r# ");
else
sendstr(conn, "\r> ");
}
static void cli_send_welcome_banner(int fd)
{
struct cli_conn *conn;
char sendbuf[100];
(void)fd;
conn = &connection;
sprintf(sendbuf,
"\r\n"
"--==--==--==--==--==--==--\r\n"
"-- WELCOME to OFP CLI --\r\n"
"--==--==--==--==--==--==--\r\n"
);
sendstr(conn, sendbuf);
sendcrlf(conn);
}
static void cli_send_goodbye_banner(struct cli_conn *conn)
{
sendstr(conn,
"\r\n"
"--==--==--==--\r\n"
"-- Goodbye! --\r\n"
"--==--==--==--\r\n"
);
sendcrlf(conn);
}
/***********************************************
* Functions to be called. *
***********************************************/
static void f_exit(struct cli_conn *conn, const char *s)
{
(void)s;
if (conn->status & ENABLED_OK) {
conn->status &= ~ENABLED_OK;
cli_send_goodbye_banner(conn);
sendcrlf(conn);
return;
}
cli_send_goodbye_banner(conn);
close_connection(conn);
}
static void f_help(struct cli_conn *conn, const char *s)
{
(void)s;
ofp_sendf(conn->fd, "Display help information for CLI commands:\r\n"
" help <command>\r\n"
" command: alias, address, arp, debug, exit, ifconfig, ");
ofp_sendf(conn->fd, "ipsec, loglevel, netstat, route, show, stat, ");
ofp_sendf(conn->fd, "sysctl\r\n\r\n");
sendcrlf(conn);
}
static void f_help_exit(struct cli_conn *conn, const char *s)
{
(void)s;
sendstr(conn, "Exit closes the current connection.\r\n"
"You can type ctl-D, too.");
sendcrlf(conn);
}
static void f_help_show(struct cli_conn *conn, const char *s)
{
(void)s;
ofp_sendf(conn->fd, "Display current status:\r\n"
" show <command>\r\n"
" command: alias, address, arp, debug, ifconfig, ipsec, ");
ofp_sendf(conn->fd, "loglevel, netstat, route, stat sysctl\r\n\r\n");
sendcrlf(conn);
}
static int authenticate(const char *user, const char *passwd)
{
(void)user;
(void)passwd;
#if 0
struct passwd *pw;
char *epasswd;
if ((pw = getpwnam(user)) == NULL) return 0;
if (pw->pw_passwd == 0) return 1;
epasswd = crypt(passwd, pw->pw_passwd);
if (strcmp(epasswd, pw->pw_passwd)) return 0;
#endif
return 1;
}
/*******************************************/
/**< Special Parameter keywords in commands */
static char NUMBER[] = "<number>";
static char IP4ADDR[] = "<a.b.c.d>";
static char TOPNAME[] = "<top name>";
static char STRING[] = "<string>";
static char DEV[] = "<dev>";
static char IP4NET[] = "<a.b.c.d/n>";
static char IP6ADDR[] = "<a:b:c:d:e:f:g:h>";
static char IP6NET[] = "<a:b:c:d:e:f:g:h/n>";
static char MAC[] = "<a:b:c:d:e:f>";
/** Check if the given word is a built-in "Parameter Keyword",
* and if so returns the Parameter string address, used as an identifier in the parser;
*
* @input str const char*: word to be checked
* @return char*
* @return NULL: the input word is not a Parameter
* @return else the Parameter string address
*
*/
static char *get_param_string(const char *str)
{
#define IS_PARAM(str, param) (!strncmp(str, #param, strlen(#param)))
if IS_PARAM(str, NUMBER)
return NUMBER;
if IS_PARAM(str, IP4ADDR)
return IP4ADDR;
if IS_PARAM(str, TOPNAME)
return TOPNAME;
if IS_PARAM(str, STRING)
return STRING;
if IS_PARAM(str, DEV)
return DEV;
if IS_PARAM(str, IP4NET)
return IP4NET;
if IS_PARAM(str, IP6NET)
return IP6NET;
if IS_PARAM(str, IP6ADDR)
return IP6ADDR;
if IS_PARAM(str, MAC)
return MAC;
#undef IS_PARAM
return NULL;
}
static struct cli_node end = {0, 0, 0, 0, 0, 0};
static struct cli_node *start = &end;
/* CLI Commands list */
/* Command Parameters are indicated by the following keywords:
* NUMBER,IP4ADDR,TOPNAME,STRING,DEV,IP4NET
*/
struct cli_command commands[] = {
{
"exit",
"Quit the connection",
f_exit
},
{
"show",
"Display information",
f_help_show
},
{
"show help",
"Display information",
f_help_show
},
{
"show arp",
NULL,
f_arp
},
{
"show debug",
NULL,
f_debug_show
},
{
"show loglevel",
NULL,
f_loglevel_show
},
{
"show route",
NULL,
f_route_show
},
{
"show alias",
NULL,
f_alias_show
},
{
"show stat",
NULL,
f_stat_show
},
{
"show ifconfig",
NULL,
f_ifconfig_show
},
{
"show netstat",
NULL,
f_netstat_all
},
{
"show address",
NULL,
f_address_show
},
{
"show sysctl",
NULL,
f_sysctl_dump
},
{
"debug",
"Print traffic to file (and console) or to a pcap file",
f_debug_show
},
{
"debug NUMBER",
"Bit mask of categories whose traffic to print (15 or 0xf for everything)",
f_debug
},
{
"debug help",
"Print help",
f_help_debug
},
{
"debug show",
"Show debug settings",
f_debug_show
},
{
"debug capture NUMBER",
"Port mask whose traffic to save in pcap format (15 or 0xf for ports 0-3)",
f_debug_capture
},
{
"debug capture info NUMBER",
"Non-zero = Include port number info by overwriting the first octet of dest MAC",
f_debug_info
},
{
"debug capture file STRING",
"File to save captured packets",
f_debug_capture_file
},
{
"loglevel",
"Show or set log level",
f_loglevel_show
},
{
"loglevel set STRING",
"Set log level",
f_loglevel
},
{
"loglevel help",
"Print help",
f_help_loglevel
},
{
"loglevel show",
"Show log level",
f_loglevel_show
},
{
"help",
NULL,
f_help
},
{
"help exit",
NULL,
f_help_exit
},
{
"help show",
NULL,
f_help_show
},
{
"help debug",
NULL,
f_help_debug
},
{
"help loglevel",
NULL,
f_help_loglevel
},
{
"help route",
NULL,
f_help_route
},
{
"help arp",
NULL,
f_help_arp
},
{
"help alias",
NULL,
f_help_alias
},
{
"help stat",
NULL,
f_help_stat
},
{
"help ifconfig",
NULL,
f_help_ifconfig
},
{
"help netstat",
NULL,
f_help_netstat
},
{
"help sysctl",
NULL,
f_help_sysctl
},
{
"arp",
"Show arp table",
f_arp
},
{
"arp flush",
"Flush arp table",
f_arp_flush
},
{
"arp cleanup",
"Clean old entries from arp table",
f_arp_cleanup
},
{
"arp set IP4ADDR MAC dev DEV",
"Add static entry to arp table",
f_arp_add
},
{
"arp help",
NULL,
f_help_arp
},
{
"route",
"Show route table",
f_route_show
},
{
"route show",
"Show route table",
f_route_show
},
{
"route add IP4NET gw IP4ADDR dev DEV",
"Add route",
f_route_add
},
{
"route -A inet4 add IP4NET gw IP4ADDR dev DEV",
"Add route",
f_route_add
},
#ifdef INET6
{
"route -A inet6 add IP6NET gw IP6ADDR dev DEV",
"Add route",
f_route_add_v6
},
#endif /* INET6 */
{
"route add vrf NUMBER IP4NET gw IP4ADDR dev DEV",
"Add route to VRF",
f_route_add_vrf
},
{
"route -A inet4 add vrf NUMBER IP4NET gw IP4ADDR dev DEV",
"Add route to VRF",
f_route_add_vrf
},
{
"route delete IP4NET",
"Delete route",
f_route_del
},
{
"route -A inet4 delete IP4NET",
"Delete route",
f_route_del
},
{
"route delete vrf NUMBER IP4NET",
"Delete route",
f_route_del_vrf
},
{
"route -A inet4 delete vrf NUMBER IP4NET",
"Delete route",
f_route_del_vrf
},
#ifdef INET6
{
"route -A inet6 delete IP6NET",
"Delete route",
f_route_del_v6
},
#endif /* INET6 */
{
"route add from DEV to DEV",
"Add route from interface to interface",
f_route_add_dev_to_dev
},
{
"route help",
NULL,
f_help_route
},
{
"ifconfig",
"Show interfaces",
f_ifconfig_show
},
{
"ifconfig show",
NULL,
f_ifconfig_show
},
{
"ifconfig DEV IP4NET",
"Create interface",
f_ifconfig
},
{
"ifconfig -A inet4 DEV IP4NET",
"Create interface",
f_ifconfig
},
#ifdef INET6
{
"ifconfig -A inet6 DEV IP6NET",
"Create interface",
f_ifconfig_v6
},
#endif /* INET6 */
{
"ifconfig DEV IP4NET vrf NUMBER",
"Create interface",
f_ifconfig
},
{
"ifconfig -A inet4 DEV IP4NET vrf NUMBER",
"Create interface",
f_ifconfig
},
{
"ifconfig tunnel gre DEV local IP4ADDR remote IP4ADDR peer IP4ADDR IP4ADDR",
"Create GRE tunnel interface",
f_ifconfig_tun
},
{
"ifconfig tunnel gre DEV local IP4ADDR remote IP4ADDR peer IP4ADDR IP4ADDR vrf NUMBER",
"Create GRE tunnel interface",
f_ifconfig_tun
},
{
"ifconfig vxlan DEV group IP4ADDR dev DEV IP4NET",
"Create VXLAN interface",
f_ifconfig_vxlan
},
{
"ifconfig DEV down",
"Delete interface",
f_ifconfig_down
},
{
"ifconfig help",
NULL,
f_help_ifconfig
},
{
"address add IP4NET DEV",
"Add IP address to interface",
f_address_add
},
{
"address del IP4NET DEV",
"Remove IP address to interface",
f_address_del
},
{
"address show",
"Show IP addresses",
f_address_show
},
{
"help address",
NULL,
f_address_help
},
{
"alias",
NULL,
f_alias_show
},
{
"alias set STRING STRING",
"Define an alias",
f_alias_set
},
{
"alias show",
NULL,
f_alias_show
},
{
"alias help",
NULL,
f_help_alias
},
{
"stat",
"Show statistics",
f_stat_show
},
{
"stat show",
NULL,
f_stat_show
},
{
"stat set NUMBER",
NULL,
f_stat_set
},
{
"stat perf",
NULL,
f_stat_perf
},
{
"stat clear",
NULL,
f_stat_clear
},
{
"stat help",
NULL,
f_help_stat
},
{
"sysctl dump",
"Dump sysctl tree",
f_sysctl_dump
},
{
"sysctl r STRING",
"Read sysctl variable",
f_sysctl_read
},
{
"sysctl w STRING STRING",
"Set sysctl variable",
f_sysctl_write
},
{
"sysctl help",
NULL,
f_help_sysctl
},
{
"netstat",
"Show all open ports",
f_netstat_all
},
{
"netstat -t",
"Show TCP open ports",
f_netstat_tcp
},
{
"netstat -u",
"Show UDP open ports",
f_netstat_udp
},
{
"netstat help",
NULL,
f_help_netstat
},
{ NULL, NULL, NULL }
};
static void print_nodes(int fd, struct cli_node *node)
{
struct cli_node *n;
static int depth = 0;
int i;
int ni = 0;
struct cli_node *stack[100];
if (node == &end)
return;
for (i = 0; i < depth; i++)
ofp_sendf(fd, " ");
for (n = node; n != &end; n = n->nextword) {
depth += strlen(n->word) + 1;
stack[ni++] = n;
ofp_sendf(fd, "%s ", n->word);
}
ofp_sendf(fd, "\n");
while (ni > 0) {
n = stack[--ni];
depth -= strlen(n->word) + 1;
print_nodes(fd, n->nextpossibility);
}
}
static struct cli_node *add_command(struct cli_node *root, struct cli_command *cc)
{
struct cli_node *s;
struct cli_node *cn = root;
struct cli_node *new;
struct cli_node *n;
int nextpossibility = 0;
size_t len;
char *nw;
char *param;
const char *str;
const char *w;
w = cc->command;
s = cn;
while (cn != &end) {
nw = strchr(w, ' ');
str = get_param_string(w);
if (!str) {
str = w;
if (nw)
len = nw - w;
else
len = strlen(w);
} else {
len = strlen(str);
}
while (cn != &end && (strncmp(str, cn->word, len)
|| len != strlen(cn->word))) {
s = cn;
cn = cn->nextpossibility;
}
if (cn == &end) {
nextpossibility = 1;
} else {
if (!nw)
ofp_generate_coredump();
w = nw + 1;
s = cn;
cn = cn->nextword;
}
}
new = NULL;
cn = NULL;
while (w) {
n = malloc(sizeof(*cn));
n->help = NULL;
n->func = NULL;
n->nextword = &end;
n->nextpossibility = &end;
if (!new)
new = n;
if (cn)
cn->nextword = n;
cn = n;
param = get_param_string(w);
nw = strchr(w, ' ');
if (!nw) {
if (param)
n->word = param;
else
n->word = strdup(w);
break;
}
/* else */
if (param) {
n->word = param;
} else {
n->word = malloc(nw - w + 1);
memcpy(n->word, w, nw - w);
n->word[nw - w] = '\0';
}
w = nw + 1;
}
cn->func = cc->func;
cn->help = cc->help;
if (root == &end)
root = new;
else if (nextpossibility)
s->nextpossibility = new;
else
s->nextword = new;
return root;
}
static void f_run_alias(struct cli_conn *conn, const char *s)
{
(void)s;
char *line = conn->inbuf;
int i;
for (i = 0; i < ALIAS_TABLE_LEN; i++) {
if (alias_table[i].name == 0 || alias_table[i].cmd == 0)
continue;
if (strncmp(line, alias_table[i].name,
strlen(alias_table[i].name)) == 0) {
run_alias = i;
return;
}
}
}
void f_add_alias_command(const char *name)
{
struct cli_command a;
a.command = name;
a.help = "Alias command";
a.func = f_run_alias;
start = add_command(start, &a);
}
void ofp_cli_add_command(const char *cmd, const char *help,
ofp_cli_cb_func func)
{
struct cli_command a;
a.command = cmd;
a.help = help;
a.func = (void (*)(struct cli_conn *, const char *))func;
start = add_command(start, &a);
}
int ofp_cli_get_fd(void *handle)
{
struct cli_conn *conn = handle;
return conn->fd;
}
static void cli_init_commands(void)
{
unsigned i = 0;
static int initialized = 0;
struct cli_conn conn;
if (initialized)
return;
initialized = 1;
/* virtual connection */
memset(&conn, 0, sizeof(conn));
conn.fd = 1; /* stdout */
conn.status = CONNECTION_ON; /* no prompt */
/* Initalize alias table*/
for (i = 0; i < ALIAS_TABLE_LEN; i++) {
alias_table[i].name = NULL;
alias_table[i].cmd = NULL;
}
/* Add regular commands */
for (i = 0; commands[i].command; i++)
start = add_command(start, &commands[i]);
/* Add IPsec commands */
ofpcli_ipsec_init();
/* Print nodes */
if (ofp_debug_logging_enabled()) {
ofp_sendf(conn.fd, "CLI Command nodes:\n");
print_nodes(conn.fd, start);
}
}
static void cli_process_file(char *file_name)
{
FILE *f;
struct cli_conn conn;
/* virtual connection */
memset(&conn, 0, sizeof(conn));
conn.fd = 1; /* stdout */
conn.status = CONNECTION_ON; /* no prompt */
if (file_name != NULL) {
f = fopen(file_name, "r");
if (!f) {
OFP_ERR("OFP CLI file not found.\n");
return;
}
while (fgets(conn.inbuf, sizeof(conn.inbuf), f)) {
if (conn.inbuf[0] == '#' || conn.inbuf[0] <= ' ')
continue;
ofp_sendf(conn.fd, "CLI: %s\n",
conn.inbuf);
parse(&conn, 0);
}
fclose(f);
}
else {
OFP_DBG("OFP CLI file not set.\n");
}
}
static void print_q(struct cli_conn *conn, struct cli_node *s, struct cli_node *ok)
{
char sendbuf[200];
if (s == &end || (ok && ok->func)) {
sendstr(conn, "\r\n <cr>");
//return;
}
while (s != &end) {
if (s->help)
sprintf(sendbuf, "\r\n %-20s(%.158s)", s->word, s->help);
else
sprintf(sendbuf, "\r\n %.178s", s->word);
sendstr(conn, sendbuf);
s = s->nextpossibility;
}
sendcrlf(conn);
return;
}
static struct cli_node *find_next_vertical(struct cli_node *s, char *word)
{
int foundcnt = 0;
size_t len = strlen(word);
struct cli_node *found = 0;
while (s != &end) {
if ((strncmp(s->word, word, len) == 0 &&
strlen(s->word) == len) ||
(s->word == NUMBER && int_ok(word)) ||
(s->word == IP4ADDR && ip4addr_ok(word)) ||
(s->word == TOPNAME && topname_ok(word)) ||
(s->word == DEV && dev_ok(word)) ||
(s->word == IP4NET && ip4net_ok(word)) ||
(s->word == STRING) ||
(s->word == IP6ADDR && ip6addr_ok(word)) ||
(s->word == IP6NET && ip6net_ok(word)) ||
(s->word == MAC && mac_ok(word))) {
foundcnt++;
if (foundcnt > 1) return 0;
found = s;
}
s = s->nextpossibility;
}
return found;
}
static int is_parameter(struct cli_node *s)
{
return ((s->word == NUMBER) ||
(s->word == IP4ADDR) ||
(s->word == TOPNAME) ||
(s->word == DEV) ||
(s->word == IP4NET) ||
(s->word == STRING) ||
(s->word == IP6ADDR) ||
(s->word == IP6NET) ||
(s->word == MAC));
}
/** parse(): parse a Command line
*
* @param conn struct cli_conn*
* @param extra int
* @return void
*
*/
static void parse(struct cli_conn *conn, int extra)
{
char **ap, *argv[50], **token, *msg, *lasttoken = 0;
char b[sizeof(conn->inbuf)];
struct cli_node *p = start, *horpos = &end, *lastok = 0;
int paramlen;
char paramlist[100];
char *line = conn->inbuf;
int linelen = strlen(line);
if (linelen > 0 && line[linelen-1] == ' ' && extra) extra = '?';
else if (linelen == 0 && extra) extra = '?';
else if (extra) extra = '\t';
if (linelen == 0) {
print_q(conn, p, 0);
return;
}
strcpy(b, line);
msg = b;
for (ap = argv; (*ap = strsep(&msg, " \r\n")) != NULL;) {
if (**ap != '\0') {
if (++ap >= &argv[49])
break;
if (msg != NULL && *msg == '\"') {
msg += 1;
*ap = strsep(&msg, "\"\r\n");
if (++ap >= &argv[49])
break;
}
}
}
token = argv;
horpos = p;
paramlen = 0;
paramlist[0] = 0;
while (*token && p != &end) {
struct cli_node *found;
found = find_next_vertical(p, *token);
if (found) {
lastok = found;
lasttoken = *token;
p = found->nextword;
horpos = p;
if ((found->word == NUMBER && int_ok(*token)) ||
(found->word == IP4ADDR && ip4addr_ok(*token)) ||
(found->word == TOPNAME && topname_ok(*token)) ||
(found->word == DEV && dev_ok(*token)) ||
(found->word == IP4NET && ip4net_ok(*token)) ||
(found->word == STRING) ||
(found->word == IP6ADDR && ip6addr_ok(*token)) ||
(found->word == IP6NET && ip6net_ok(*token)) ||
(found->word == MAC && mac_ok(*token))) {
paramlen += sprintf(paramlist + paramlen,
"%s ", *token);
}
token++;
} else {
p = &end;
}
}
if (extra && p == &end && *token == 0) {
if (is_parameter(lastok) ||
strlen(lastok->word) == strlen(lasttoken)) {
sendstr(conn, "\r\n <cr>");
sendcrlf(conn);
sendstr(conn, line);
} else {
addchars(conn, lastok->word + strlen(lasttoken));
addchars(conn, " ");
sendstr(conn, lastok->word + strlen(lasttoken));
sendstr(conn, " ");
}
return;
}
if (lastok && lastok->func && extra == 0) {
lastok->func(conn, paramlist);
return;
}
if (extra == '?') {
print_q(conn, horpos, lastok);
sendstr(conn, line);
return;
}
if (extra == '\t') {
struct cli_node *found = 0;
if (*token == NULL) {
addchars(conn, lastok->word + strlen(lasttoken));
addchars(conn, " ");
sendstr(conn, lastok->word + strlen(lasttoken));
sendstr(conn, " ");
return;
}
found = find_next_vertical(horpos, *token);
if (found) {
addchars(conn, found->word + strlen(*token));
addchars(conn, " ");
sendstr(conn, found->word + strlen(*token));
sendstr(conn, " ");
return;
}
print_q(conn, horpos, lastok);
sendstr(conn, line);
return;
}
sendstr(conn, "syntax error\r\n");
sendcrlf(conn);
return;
}
static char telnet_echo_off[] = {
0xff, 0xfb, 0x01, /* IAC WILL ECHO */
0xff, 0xfb, 0x03, /* IAC WILL SUPPRESS_GO_AHEAD */
0xff, 0xfd, 0x03, /* IAC DO SUPPRESS_GO_AHEAD */
};
static void addchars(struct cli_conn *conn, const char *s)
{
strcat(conn->inbuf, s);
conn->pos += strlen(s);
}
static int cli_read(int fd)
{
struct cli_conn *conn = &connection;
unsigned char c;
//receive data from client
if (recv(fd, &c, 1, 0) <= 0) {
OFP_ERR("Failed to recive data on socket: %s", strerror(errno));
close_connection(conn);
return -1;
}
if (conn->status & WAITING_PASSWD) {
unsigned int plen = strlen(conn->passwd);
if (c == 10 || c == 13) {
conn->status &= ~WAITING_PASSWD;
if (authenticate("admin", conn->passwd)) {
conn->status |= ENABLED_OK;
sendcrlf(conn);
} else {
sendstr(conn, "Your password fails!");
sendcrlf(conn);
}
} else if (plen < (sizeof(conn->passwd)-1)) {
conn->passwd[plen] = c;
conn->passwd[plen+1] = 0;
}
return 0;
} else if (conn->status & WAITING_TELNET_1) {
conn->ch1 = c;
conn->status &= ~WAITING_TELNET_1;
conn->status |= WAITING_TELNET_2;
return 0;
} else if (conn->status & WAITING_TELNET_2) {
static int num_dsp_chars = 0;
static char dsp_chars[8];
if (num_dsp_chars) {
dsp_chars[6 - num_dsp_chars--] = c;
if (num_dsp_chars == 0) {
conn->status &= ~WAITING_TELNET_2;
cli_display_width = dsp_chars[1];
cli_display_height = dsp_chars[3];
}
return 0;
}
if (conn->ch1 == 0xfd && c == 0x01) conn->status |= DO_ECHO;
else if (conn->ch1 == 0xfd && c == 0x03) conn->status |= DO_SUPPRESS;
else if (conn->ch1 == 0xfb && c == 0x03) {
conn->status |= WILL_SUPPRESS;
// ask for display size
char com[] = {255, 253, 31};
send(fd, com, sizeof(com), 0);
} else if (conn->ch1 == (unsigned char)0x251 && c == 31) {
// IAC WILL NAWS (display size)
} else if (conn->ch1 == 250 && c == 31) { // (display size info)
num_dsp_chars = 6;
return 0;
}
conn->status &= ~WAITING_TELNET_2;
return 0;
} else if (conn->status & WAITING_ESC_1) {
conn->ch1 = c;
conn->status &= ~WAITING_ESC_1;
conn->status |= WAITING_ESC_2;
return 0;
} else if (conn->status & WAITING_ESC_2) {
conn->status &= ~WAITING_ESC_2;
if (conn->ch1 != 0x5b)
return 0;
switch (c) {
case 0x41: // up
c = 0x10; /* arrow up = ctl-P */
break;
case 0x42: // down
c = 0x0e; /* arrow down = ctl-N */
break;
case 0x44: // left
c = 8; /* arrow left = backspace */
break;
case 0x31: // home
cli_curses = !cli_curses;
return 0;
case 0x32: // ins
case 0x33: // delete
case 0x34: // end
case 0x35: // pgup
case 0x36: // pgdn
case 0x43: // right
case 0x45: // 5
return 0;
}
}
if (c == 4) { /* ctl-D */
close_connection(conn);
return 0;
} else if (c == 0x10 || c == 0x0e) { /* ctl-P or ctl-N */
strcpy(conn->inbuf, conn->oldbuf[conn->old_get_cnt]);
if (c == 0x10) {
conn->old_get_cnt--;
if (conn->old_get_cnt < 0)
conn->old_get_cnt = NUM_OLD_BUFS - 1;
} else {
conn->old_get_cnt++;
if (conn->old_get_cnt >= NUM_OLD_BUFS)
conn->old_get_cnt = 0;
}
conn->pos = strlen(conn->inbuf);
sendstr(conn, "\r ");
sendprompt(conn);
sendstr(conn, conn->inbuf);
} else if (c == 0x1b) {
conn->status |= WAITING_ESC_1;
} else if (c == 0xff) {
/* telnet commands */
conn->status |= WAITING_TELNET_1;
/*
unsigned char c1, c2;
recv(conn->fd, &c1, 1, 0);
recv(conn->fd, &c2, 1, 0);
if (c1 == 0xfd && c2 == 0x01) conn->status |= DO_ECHO;
else if (c1 == 0xfd && c2 == 0x03) conn->status |= DO_SUPPRESS;
else if (c1 == 0xfb && c2 == 0x03) conn->status |= WILL_SUPPRESS;
*/
} else if (c == 13 || c == 10) {
char nl[] = {13, 10};
if (conn->status & DO_ECHO)
send(fd, nl, sizeof(nl), 0);
conn->inbuf[conn->pos] = 0;
if (0 && conn->pos == 0) {
strcpy(conn->inbuf, conn->oldbuf[conn->old_put_cnt]);
conn->pos = strlen(conn->inbuf);
sendstr(conn, conn->inbuf);
send(fd, nl, sizeof(nl), 0);
} else if (conn->pos > 0 && strcmp(conn->oldbuf[conn->old_put_cnt], conn->inbuf)) {
conn->old_put_cnt++;
if (conn->old_put_cnt >= NUM_OLD_BUFS)
conn->old_put_cnt = 0;
strcpy(conn->oldbuf[conn->old_put_cnt], conn->inbuf);
}
if (conn->pos) {
parse(conn, 0);
if (run_alias >= 0) {
strcpy(conn->inbuf, alias_table[run_alias].cmd);
run_alias = -1;
parse(conn, 0);
}
} else
sendcrlf(conn);
conn->pos = 0;
conn->inbuf[0] = 0;
conn->old_get_cnt = conn->old_put_cnt;
} else if (c == 8 || c == 127) {
if (conn->pos > 0) {
char bs[] = {8, ' ', 8};
if (conn->status & DO_ECHO)
send(fd, bs, sizeof(bs), 0);
conn->pos--;
conn->inbuf[conn->pos] = 0;
}
} else if (c == '?' || c == '\t') {
parse(conn, c);
} else if (c >= ' ' && c < 127) {
if (conn->pos < (sizeof(conn->inbuf) - 1)) {
conn->inbuf[conn->pos++] = c;
conn->inbuf[conn->pos] = 0;
if (conn->status & DO_ECHO)
send(fd, &c, 1, 0);
}
}
return 0;
}
static void cli_sa_accept(int fd)
{
struct cli_conn *conn;
conn = &connection;
bzero(conn, sizeof(*conn));
conn->fd = fd;
send(fd, telnet_echo_off, sizeof(telnet_echo_off), 0);
OFP_DBG("new sock %d opened\r\n", conn->fd);
}
#define OFP_SERVER_PORT 2345
static int cli_serv_fd = -1, cli_tmp_fd = -1;
/** CLI server thread
*
* @param arg void*
* @return void*
*
*/
static int cli_server(void *arg)
{
int alen;
struct sockaddr_in my_addr, caller;
int reuse = 1;
fd_set read_fd, fds;
char *file_name;
struct ofp_global_config_mem *ofp_global_cfg = NULL;
int select_nfds;
close_cli = 0;
file_name = (char *)arg;
OFP_INFO("CLI server started on core %i\n", odp_cpu_id());
if (ofp_init_local()) {
OFP_ERR("Error: OFP local init failed.\n");
return -1;
}
ofp_global_cfg = ofp_get_global_config();
if (!ofp_global_cfg) {
OFP_ERR("Error: Failed to retrieve global configuration.");
ofp_term_local();
return -1;
}
cli_init_commands();
cli_process_file(file_name);
cli_serv_fd = socket(AF_INET, SOCK_STREAM, 0);
if (cli_serv_fd < 0) {
OFP_ERR("cli serv socket\n");
ofp_term_local();
return -1;
}
if (setsockopt(cli_serv_fd, SOL_SOCKET,
SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0)
OFP_ERR("cli setsockopt (SO_REUSEADDR)\n");
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_port = odp_cpu_to_be_16(OFP_SERVER_PORT);
my_addr.sin_addr.s_addr = odp_cpu_to_be_32(INADDR_ANY);
if (bind(cli_serv_fd, (struct sockaddr *)&my_addr,
sizeof(struct sockaddr)) < 0) {
OFP_ERR("serv bind\n");
ofp_term_local();
return -1;
}
listen(cli_serv_fd, 1);
FD_ZERO(&read_fd);
FD_SET(cli_serv_fd, &read_fd);
while (ofp_global_cfg->is_running) {
struct timeval timeout;
int r;
fds = read_fd;
select_nfds = cli_serv_fd + 1;
if (cli_tmp_fd > 0) {
FD_SET(cli_tmp_fd, &fds);
if (cli_tmp_fd > select_nfds - 1)
select_nfds = cli_tmp_fd + 1;
}
timeout.tv_sec = 1;
timeout.tv_usec = 0;
r = select(select_nfds, &fds, NULL, NULL, &timeout);
if (close_cli) {
if (cli_tmp_fd > 0)
close(cli_tmp_fd);
cli_tmp_fd = -1;
close_cli = 0;
OFP_DBG("CLI connection closed\r\n");
}
if (r < 0)
continue;
if (FD_ISSET(cli_serv_fd, &fds)) {
close_cli = 0;
if (cli_tmp_fd > 0)
close(cli_tmp_fd);
alen = sizeof(caller);
cli_tmp_fd = accept(cli_serv_fd,
(struct sockaddr *)&caller,
(socklen_t *)&alen);
if (cli_tmp_fd < 0) {
OFP_ERR("cli serv accept");
continue;
}
cli_sa_accept(cli_tmp_fd);
cli_send_welcome_banner(cli_tmp_fd);
OFP_DBG("CLI connection established\r\n");
}
if (cli_tmp_fd > 0 && FD_ISSET(cli_tmp_fd, &fds)) {
if (cli_read(cli_tmp_fd)) {
close(cli_tmp_fd);
cli_tmp_fd = -1;
OFP_DBG("CLI connection closed\r\n");
}
}
} /* while () */
if (cli_tmp_fd > 0)
close(cli_tmp_fd);
cli_tmp_fd = -1;
close(cli_serv_fd);
cli_serv_fd = -1;
OFP_DBG("CLI server exiting");
ofp_term_local();
return 0;
}
int ofp_start_cli_thread(odp_instance_t , int core_id, char *cli_file)
{
odp_cpumask_t cpumask;
struct ofp_global_config_mem *ofp_global_cfg;
odph_thread_param_t thr_params;
odph_thread_common_param_t common_param;
ofp_global_cfg = ofp_get_global_config();
if (!ofp_global_cfg) {
OFP_ERR("Error: Failed to retrieve global configuration.");
return -1;
}
if (ofp_global_cfg->cli_thread_is_running) {
OFP_ERR("Error: CLI thread is running.");
return -1;
}
odp_cpumask_zero(&cpumask);
odp_cpumask_set(&cpumask, core_id);
odph_thread_common_param_init(&common_param);
common_param.cpumask = &cpumask;
odph_thread_param_init(&thr_params);
thr_params.start = cli_server;
thr_params.arg = cli_file;
thr_params.thr_type = ODP_THREAD_CONTROL;
if (odph_thread_create(&ofp_global_cfg->cli_thread,
&common_param,
&thr_params,
1) == 0) {
OFP_ERR("Failed to start CLI thread.");
ofp_global_cfg->cli_thread_is_running = 0;
return -1;
}
ofp_global_cfg->cli_thread_is_running = 1;
return 0;
}
int ofp_stop_cli_thread(void)
{
struct ofp_global_config_mem *ofp_global_cfg;
ofp_global_cfg = ofp_get_global_config();
if (!ofp_global_cfg) {
OFP_ERR("Error: Failed to retrieve global configuration.");
return -1;
}
if (ofp_global_cfg->cli_thread_is_running) {
close_connection(NULL);
odph_thread_join(&ofp_global_cfg->cli_thread, 1);
ofp_global_cfg->cli_thread_is_running = 0;
}
return 0;
}
#else
int ofp_start_cli_thread(odp_instance_t instance, int core_id, char *cli_file)
{
(void) instance;
(void) core_id;
(void) cli_file;
return OFP_ENOTSUP;
}
int ofp_stop_cli_thread(void)
{
return OFP_ENOTSUP;
}
#endif
/*end*/
| 18.939012 | 89 | 0.596108 |
1eb807b16ff30173d9e1cd971429d72f8e12a989 | 338 | h | C | source/procedural_objects/translate.h | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 12 | 2019-04-16T17:35:53.000Z | 2020-04-12T14:37:27.000Z | source/procedural_objects/translate.h | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 47 | 2019-05-27T15:24:43.000Z | 2020-04-27T17:54:54.000Z | source/procedural_objects/translate.h | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | null | null | null | #pragma once
#include "procedural_operation.h"
namespace pagoda
{
class Translate : public ProceduralOperation
{
public:
static const std::string s_inputGeometry;
static const std::string s_outputGeometry;
Translate(ProceduralObjectSystemPtr objectSystem);
virtual ~Translate();
void DoWork() override;
};
} // namespace pagoda
| 17.789474 | 51 | 0.781065 |
145263be1ca22ad9836572f1b1fb6c4bbe0bd98f | 3,394 | h | C | include/corolib/auto_reset_event.h | JohanVanslembrouck/corolib | 0ebbabfe368c29901bf96ae1d3b6e989e3ff82c9 | [
"MIT"
] | 1 | 2021-08-19T13:49:01.000Z | 2021-08-19T13:49:01.000Z | include/corolib/auto_reset_event.h | JohanVanslembrouck/corolib | 0ebbabfe368c29901bf96ae1d3b6e989e3ff82c9 | [
"MIT"
] | null | null | null | include/corolib/auto_reset_event.h | JohanVanslembrouck/corolib | 0ebbabfe368c29901bf96ae1d3b6e989e3ff82c9 | [
"MIT"
] | null | null | null | /**
* @file auto_reset_event.h
* @brief
* Defines an event that can be used to resume a waiting coroutine1 from another coroutine, coroutine2.
* Instead of coroutine1 co_awaiting on the awaitable returned by coroutine2,
* coroutine1 can pass an auto_reset_event as argument to coroutine2.
* coroutine1 then co_awaits the resumption of that event from within coroutine2.
* When coroutine1 is resumed, the m_ready flag is reset.
* The behavior is similar to using a semaphore, but this is the "coroutine way".
*
* @author Johan Vanslembrouck (johan.vanslembrouck@altran.com, johan.vanslembrouck@gmail.com)
*/
#ifndef _AUTO_RESET_EVENT_H_
#define _AUTO_RESET_EVENT_H_
#include <experimental/resumable>
#include "print.h"
namespace corolib
{
struct auto_reset_event {
auto_reset_event()
: m_awaiting(nullptr)
, m_ready(false)
{
print(PRI2, "%p: auto_reset_event::auto_reset_event()\n", this);
}
auto_reset_event(const auto_reset_event&) = delete;
auto_reset_event& operator = (const auto_reset_event&) = delete;
auto_reset_event(auto_reset_event&& s) noexcept
: m_awaiting(s.m_awaiting)
, m_ready(s.m_ready)
{
print(PRI2, "%p: auto_reset_event::auto_reset_event(auto_reset_event&& s)\n", this);
s.m_awaiting = nullptr;
s.m_ready = false;
}
auto_reset_event& operator = (auto_reset_event&& s) noexcept
{
print(PRI2, "%p: auto_reset_event::auto_reset_event = (auto_reset_event&& s)\n", this);
m_awaiting = s.m_awaiting;
m_ready = s.m_ready;
s.m_awaiting = nullptr;
s.m_ready = false;
return *this;
}
void resume()
{
print(PRI2, "%p: auto_reset_event::resume(): before m_awaiting.resume();\n", this);
m_ready = true;
if (m_awaiting && !m_awaiting.done())
m_awaiting.resume();
print(PRI2, "%p: auto_reset_event::resume(): after m_awaiting.resume();\n", this);
}
auto operator co_await() noexcept
{
class awaiter
{
public:
awaiter(auto_reset_event& are_)
: m_are(are_)
{
print(PRI2, "%p: auto_reset_event::awaiter(auto_reset_event& ars_)\n", this);
}
bool await_ready()
{
print(PRI2, "%p: auto_reset_event::await_ready(): return false\n", this);
return m_are.m_ready;
}
void await_suspend(std::experimental::coroutine_handle<> awaiting)
{
print(PRI2, "%p: auto_reset_event::await_suspend(std::experimental::coroutine_handle<> awaiting)\n", this);
m_are.m_awaiting = awaiting;
}
void await_resume()
{
print(PRI2, "%p: void auto_reset_event::await_resume()\n", this);
m_are.m_ready = false;
}
private:
auto_reset_event& m_are;
};
return awaiter{ *this };
}
private:
std::experimental::coroutine_handle<> m_awaiting;
bool m_ready;
};
}
#endif
| 32.32381 | 127 | 0.564231 |
88bec014bc9bb763bb3903ef2b50d65d27de853f | 36,917 | c | C | Microchip/TCPIP Stack/WiFi/WFConsoleIwconfig.c | wenyizou/RIC-Segway-Project | 16a61fbc60fb409578e29722f57022f254480c03 | [
"BSD-3-Clause"
] | null | null | null | Microchip/TCPIP Stack/WiFi/WFConsoleIwconfig.c | wenyizou/RIC-Segway-Project | 16a61fbc60fb409578e29722f57022f254480c03 | [
"BSD-3-Clause"
] | null | null | null | Microchip/TCPIP Stack/WiFi/WFConsoleIwconfig.c | wenyizou/RIC-Segway-Project | 16a61fbc60fb409578e29722f57022f254480c03 | [
"BSD-3-Clause"
] | null | null | null | /******************************************************************************
MRF24W Driver iwconfig
Module for Microchip TCP/IP Stack
-Provides access to MRF24W WiFi controller
-Reference: MRF24W Data sheet, IEEE 802.11 Standard
*******************************************************************************
FileName: WFConsoleIwconfig.c
Dependencies: TCP/IP Stack header files
Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32
Compiler: Microchip C32 v1.10b or higher
Microchip C30 v3.22 or higher
Microchip C18 v3.34 or higher
Company: Microchip Technology, Inc.
Software License Agreement
Copyright (C) 2002-2010 Microchip Technology Inc. All rights reserved.
Microchip licenses to you the right to use, modify, copy, and distribute:
(i) the Software when embedded on a Microchip microcontroller or digital
signal controller product ("Device") which is integrated into
Licensee's product; or
(ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h,
ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device used in
conjunction with a Microchip ethernet controller for the sole purpose
of interfacing with the ethernet controller.
You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.
THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR ANY INCIDENTAL,
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST
OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS BY
THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS
FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON
THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR
OTHERWISE.
Author Date Comment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KH 27 Jan 2010 Updated for MRF24W
******************************************************************************/
//============================================================================
// Includes
//============================================================================
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "TCPIP Stack/TCPIP.h"
#include "TCPIP Stack/WFConsole.h"
#if defined( WF_CONSOLE_IFCFGUTIL )
#include "TCPIP Stack/WFConsoleIwconfig.h"
#include "TCPIP Stack/WFConsoleMsgs.h"
#include "TCPIP Stack/WFConsoleMsgHandler.h"
#if defined ( EZ_CONFIG_SCAN )
#include "TCPIP Stack/WFEasyConfig.h"
#endif /* EZ_CONFIG_SCAN */
//============================================================================
// Constants
//============================================================================
//============================================================================
// Globals
//============================================================================
static BOOL iwconfigCbInitialized = FALSE;
tWFIwconfigCb iwconfigCb;
//============================================================================
// Local Function Prototypes
//============================================================================
static void iwconfigDisplayStatus(void);
static BOOL iwconfigSetSsid(void);
static BOOL iwconfigSetMode(void);
static BOOL iwconfigSetChannel(void);
static BOOL iwconfigSetPower(void);
static BOOL iwconfigSetDomain(void);
static BOOL iwconfigSetRTS(void);
static BOOL iwconfigSetTxRate(void);
static BOOL iwconfigSetConnect(void);
#ifdef STACK_USE_CERTIFICATE_DEBUG
static BOOL iwconfigGetMacStats(void);
#endif
tWFHibernate WF_hibernate;
BOOL test_flag;
DWORD test_sec;
int test_count;
char test_buf[80];
/*******************************************************************************
Function:
void do_iwconfig_cmd(void)
Summary:
Responds to the user invoking iwconfig command
Description:
Responds to the user invoking iwconfig command
Precondition:
MACInit must be called first.
Parameters:
None.
Returns:
None.
Remarks:
None.
*****************************************************************************/
void do_iwconfig_cmd(void)
{
if (!WF_hibernate.state && !iwconfigSetCb() )
return;
// if user only typed in iwconfig with no other parameters
if (ARGC == 1u)
{
if (!WF_hibernate.state)
iwconfigDisplayStatus();
else
#if defined(STACK_USE_UART)
WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode - command failed.", TRUE);
#endif
return;
}
if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "wakeup") == 0) )
{
if (!WF_hibernate.wakeup_notice)
{
WF_hibernate.wakeup_notice = TRUE;
}
#if defined(STACK_USE_UART)
WFConsolePrintRomStr("The Wi-Fi module is awake.", TRUE);
#endif
return;
}
if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "hibernate") == 0) )
{
if (!WF_hibernate.state)
{
WF_hibernate.state = WF_HB_ENTER_SLEEP;
WF_hibernate.wakeup_notice = FALSE;
WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode.", TRUE);
}
else
WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode.", TRUE);
return;
}
if (WF_hibernate.state)
{
WFConsolePrintRomStr("The Wi-Fi module is in hibernate mode - command failed.", TRUE);
return;
}
if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "ssid") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetSsid())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "mode") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetMode())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "channel") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetChannel())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "power") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetPower())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "domain") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetDomain())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "rts") == 0) )
{
if (!WF_hibernate.state && !iwconfigSetRTS())
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "txrate") == 0) )
{
// txrate is NOT available. Will always return FALSE
if (!WF_hibernate.state && !iwconfigSetTxRate())
return;
}
#if defined ( EZ_CONFIG_SCAN ) && !defined(__18CXX)
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "scan") == 0))
{
if (!WF_hibernate.state)
{
// WFInitScan();
WFConsolePrintRomStr("Scanning...", TRUE);
if (WFStartScan() == WF_SUCCESS)
{
WFConsolePrintRomStr("Scan completed.", TRUE);
}
else
{
WFConsolePrintRomStr("Scan failed. Already in progress or not allowed", TRUE);
}
}
else
{
WFConsolePrintRomStr("In hibernate mode - scan is not allowed.", TRUE);
}
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "scanresults") == 0) )
{
if (IS_SCAN_IN_PROGRESS(SCANCXT.scanState))
WFConsolePrintRomStr("Scann in process...please wait or try again later", TRUE);
else if (SCANCXT.numScanResults > 0)
{
SCAN_SET_DISPLAY(SCANCXT.scanState);
SCANCXT.displayIdx = 0;
while (IS_SCAN_STATE_DISPLAY(SCANCXT.scanState))
{
WFDisplayScanMgr();
}
}
else
WFConsolePrintRomStr("No scan results to display.", TRUE);
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "starttest") == 0))
{
test_flag = TRUE;
test_count = 0;
return;
}
else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "stoptest") == 0))
{
test_flag = FALSE;
return;
}
#endif /* EZ_CONFIG_SCAN */
else if( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "connect") == 0))
{
iwconfigSetConnect();
return;
}
#ifdef STACK_USE_CERTIFICATE_DEBUG
else if( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "macstats") == 0))
{
iwconfigGetMacStats();
return;
}
#endif
else
{
WFConsolePrintRomStr("Unknown parameter", TRUE);
return;
}
}
/*******************************************************************************
Function:
BOOL iwconfigSetCb(void)
Summary:
Set the iwconfigCb structure
Description:
Set the iwconfigCb structure
Parameters:
None.
Returns:
TRUE or FALSE
Remarks:
None.
*****************************************************************************/
BOOL iwconfigSetCb(void)
{
UINT8 cpId;
if ( !iwconfigCbInitialized ) // first time call of iwconfigSetCb
{
memset(&iwconfigCb, 0, sizeof(iwconfigCb));
iwconfigCbInitialized = TRUE;
}
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_GetPowerSaveState(&iwconfigCb.powerSaveState);
#endif
if (iwconfigCb.powerSaveState == WF_PS_HIBERNATE)
{
WFConsolePrintRomStr("WF device hibernated", TRUE);
return FALSE;
}
WF_CMGetConnectionState(&iwconfigCb.connState, &cpId);
if ( iwconfigCb.cpId == WF_CURRENT_CPID_NONE )
{
if ( cpId == WF_CURRENT_CPID_NONE )
{
iwconfigCb.cpId = 1; // console demo only supports 1 CPID; don't create a new one here
}
else if ( cpId == WF_CURRENT_CPID_LIST )
{
WFConsolePrintRomStr("Connection profile list not supported", TRUE);
return FALSE;
}
else
{
iwconfigCb.cpId = cpId; // use the application-created profile
}
}
else // WF_MIN_NUM_CPID <= iwconfigCb.cpId && iwconfigCb.cpId <= WF_MAX_NUM_CPID
{
if ( cpId == WF_CURRENT_CPID_NONE )
{
// continue to use iwconfigCb.cpId
}
else if ( cpId == WF_CURRENT_CPID_LIST )
{
WFConsolePrintRomStr("Conection profile list not supported", TRUE);
WF_CPDelete(iwconfigCb.cpId);
iwconfigCb.cpId = WF_CURRENT_CPID_NONE;
return FALSE;
}
else if ( cpId != iwconfigCb.cpId )
{
WF_CPDelete(iwconfigCb.cpId);
iwconfigCb.cpId = cpId; // use the application-created profile
}
else // cpId == iwconfigCb.cpId
{
// contine to use iwconfigCb.cpId
}
}
if ((iwconfigCb.connState == WF_CSTATE_NOT_CONNECTED) || (iwconfigCb.connState == WF_CSTATE_CONNECTION_PERMANENTLY_LOST))
{
iwconfigCb.isIdle = TRUE;
}
else
{
iwconfigCb.isIdle = FALSE;
}
return TRUE;
}
#if defined(MRF24WG)
static void OutputMacAddress(void)
{
UINT8 mac[6];
int i;
char buf[4];
WF_GetMacAddress(mac);
for (i = 0; i < 6; ++i)
{
sprintf(buf, "%02X ", mac[i]);
putsUART(buf);
}
putrsUART("\r\n");
}
#endif
extern void WF_OutputConnectionContext(void);
/*******************************************************************************
Function:
void iwconfigDisplayStatus(void)
Summary:
Responds to the user invoking iwconfig with no parameters
Description:
Responds to the user invoking iwconfig with no parameters
Parameters:
None.
Returns:
None
Remarks:
None.
*****************************************************************************/
static void iwconfigDisplayStatus(void)
{
UINT8 *p;
UINT8 tmp;
UINT8 connectionState;
UINT8 cpId;
#if defined(MRF24WG)
char buf[6];
#endif
union
{
struct
{
UINT8 List[WF_CHANNEL_LIST_LENGTH];
UINT8 Num;
} Channel;
UINT8 Domain;
struct
{
UINT8 String[WF_MAX_SSID_LENGTH+1];
UINT8 Len;
} Ssid;
struct
{
UINT8 NetworkType;
} Mode;
struct
{
UINT16 Threshold;
} Rts;
} ws; // workspace
// cpId
{
WFConsolePrintRomStr("\tcpid: ", FALSE);
WFConsolePrintInteger(iwconfigCb.cpId, 'd');
WFConsolePrintRomStr("", TRUE);
}
// channel
{
WF_CAGetChannelList(ws.Channel.List, &ws.Channel.Num);
WFConsolePrintRomStr("\tchannel: ", FALSE);
p = ws.Channel.List;
tmp = ws.Channel.Num;
while ( --tmp > 0u )
{
WFConsolePrintInteger(*p, 'd');
WFConsolePrintRomStr(",", FALSE);
p++;
}
WFConsolePrintInteger(*p, 'd');
WFConsolePrintRomStr("", TRUE);
}
#if defined(MRF24WG)
// domain
{
WF_GetRegionalDomain(&ws.Domain);
WFConsolePrintRomStr("\tdomain: ", FALSE);
if ( ws.Domain == WF_DOMAIN_FCC )
{
WFConsolePrintRomStr("fcc", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_ETSI )
{
WFConsolePrintRomStr("etsi", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_JAPAN )
{
WFConsolePrintRomStr("japan", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_OTHER )
{
WFConsolePrintRomStr("other", TRUE);
}
else
{
WFConsolePrintRomStr("unknown", TRUE);
}
}
#else
// domain
{
WF_GetRegionalDomain(&ws.Domain);
WFConsolePrintRomStr("\tdomain: ", FALSE);
if ( ws.Domain == WF_DOMAIN_FCC )
{
WFConsolePrintRomStr("fcc", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_IC )
{
WFConsolePrintRomStr("ic", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_ETSI )
{
WFConsolePrintRomStr("etsi", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_SPAIN )
{
WFConsolePrintRomStr("spain", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_FRANCE )
{
WFConsolePrintRomStr("france", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_JAPAN_A )
{
WFConsolePrintRomStr("japana", TRUE);
}
else if ( ws.Domain == WF_DOMAIN_JAPAN_B )
{
WFConsolePrintRomStr("japanb", TRUE);
}
else
{
WFConsolePrintRomStr("unknown", TRUE);
}
}
#endif
// rts
{
WF_GetRtsThreshold(&ws.Rts.Threshold);
WFConsolePrintRomStr("\trts: ", FALSE);
WFConsolePrintInteger(ws.Rts.Threshold, 'd');
WFConsolePrintRomStr("", TRUE);
}
// mode
{
WF_CMGetConnectionState(&connectionState, &cpId);
WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType);
WFConsolePrintRomStr("\tmode: ", FALSE);
if (iwconfigCb.isIdle)
{
if (iwconfigCb.connState == WF_CSTATE_NOT_CONNECTED)
{
WFConsolePrintRomStr("idle", TRUE);
}
else if (iwconfigCb.connState == WF_CSTATE_CONNECTION_PERMANENTLY_LOST)
{
WFConsolePrintRomStr("idle (connection permanently lost)", TRUE);
}
else
{
WFConsolePrintRomStr("idle (?)", TRUE);
}
}
else
{
WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType);
if (ws.Mode.NetworkType == WF_INFRASTRUCTURE)
{
if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS)
{
WFConsolePrintRomStr("managed (connection in progress)", TRUE);
}
else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_INFRASTRUCTURE)
{
WFConsolePrintRomStr("managed", TRUE);
}
else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS)
{
WFConsolePrintRomStr("managed (reconnection in progress)", TRUE);
}
else
{
WFConsolePrintRomStr("managed (?)", TRUE);
}
}
else if (ws.Mode.NetworkType == WF_ADHOC)
{
if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS)
{
WFConsolePrintRomStr("adhoc (connection in progress)", TRUE);
}
else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_ADHOC)
{
WFConsolePrintRomStr("adhoc", TRUE);
}
else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS)
{
WFConsolePrintRomStr("adhoc (reconnection in progress)", TRUE);
}
else
{
WFConsolePrintRomStr("adhoc (?)", TRUE);
}
}
else
{
WFConsolePrintRomStr("unknown", TRUE);
}
}
}
// ssid
{
WF_CPGetSsid(iwconfigCb.cpId, ws.Ssid.String, &ws.Ssid.Len);
ws.Ssid.String[ws.Ssid.Len] = '\0';
WFConsolePrintRomStr("\tssid: ", FALSE);
WFConsolePrintRamStr(ws.Ssid.String, TRUE);
}
// power
{
switch (iwconfigCb.powerSaveState)
{
case WF_PS_PS_POLL_DTIM_ENABLED:
WFConsolePrintRomStr("\tpwrsave: enabled", TRUE);
WFConsolePrintRomStr("\tdtim rx: enabled", TRUE);
break;
case WF_PS_PS_POLL_DTIM_DISABLED:
WFConsolePrintRomStr("\tpwrsave: enabled", TRUE);
WFConsolePrintRomStr("\tdtim rx: disabled", TRUE);
break;
case WF_PS_OFF:
WFConsolePrintRomStr("\tpwrsave: disabled", TRUE);
break;
default:
WFConsolePrintRomStr("\tpwrsave: unknown(", FALSE);
WFConsolePrintInteger(iwconfigCb.powerSaveState, 'd');
WFConsolePrintRomStr(")", TRUE);
break;
}
}
#if defined(MRF24WG)
// context
WF_OutputConnectionContext();
// Network Type
putrsUART("\tNetwork: ");
#if defined(EZ_CONFIG_STORE) && !defined(WF_CONSOLE_DEMO) /* if EZConfig demo */
if (AppConfig.networkType == WF_ADHOC)
{
putrsUART("AdHoc\r\n");
}
else
{
putrsUART("Infrastructure\r\n");
}
#else
#if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC)
putrsUART("AdHoc\r\n");
#elif (MY_DEFAULT_NETWORK_TYPE == WF_P2P)
putrsUART("P2P\r\n");
#elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE)
#if (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PUSH_BUTTON)
putrsUART("Infrastructure (using WPS Push Button)\r\n");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PIN)
putrsUART("Infrastructure (using WPS Pin)\r\n");
#else
putrsUART("Infrastructure\r\n");
#endif
#endif
#endif /* EZ_CONFIG_STORE */
// Retry Count
putrsUART("\tRetries ");
#if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC)
sprintf(buf, "%d\r\n", ADHOC_RETRY_COUNT);
putsUART(buf);
#elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE)
#if (INFRASTRUCTURE_RETRY_COUNT == WF_RETRY_FOREVER)
sprintf(buf, "Retry Forever\r\n");
putsUART(buf);
#else
sprintf(buf, "%d\r\n", INFRASTRUCTURE_RETRY_COUNT);
putsUART(buf);
#endif
#endif /* (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC) */
// Security
putrsUART("\tSecurity: ");
#if (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_OPEN)
putrsUART("WF_SECURITY_OPEN");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WEP_40)
putrsUART("WF_SECURITY_WEP_40");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WEP_104)
putrsUART("WF_SECURITY_WEP_104");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_WITH_KEY)
putrsUART("WF_SECURITY_WPA_WITH_KEY");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_WITH_PASS_PHRASE)
putrsUART("WF_SECURITY_WPA_WITH_PASS_PHRASE");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA2_WITH_KEY)
putrsUART("WF_SECURITY_WPA2_WITH_KEY");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA2_WITH_PASS_PHRASE)
putrsUART("WF_SECURITY_WPA2_WITH_PASS_PHRASE");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_AUTO_WITH_KEY)
putrsUART("WF_SECURITY_WPA_AUTO_WITH_KEY");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE)
putrsUART("WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PUSH_BUTTON)
putrsUART("WF_SECURITY_WPS_PUSH_BUTTON");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PIN)
putrsUART("WF_SECURITY_WPS_PIN");
#else
putrsUART("Unknown");
#endif
putrsUART("\r\n");
// scan type
putrsUART("\tScan: ");
#if (MY_DEFAULT_SCAN_TYPE == WF_ACTIVE_SCAN)
putrsUART("Active Scan\r\n");
#else
putrsUART("Passive Scan\r\n");
#endif
// MAC address
putrsUART("\tMAC: ");
OutputMacAddress();
#endif /* MRF24WG */
}
static BOOL iwconfigSetSsid(void)
{
if (ARGC < 3u)
{
WFConsolePrintRomStr("Missing value for last parameter", TRUE);
return FALSE;
}
if (ARGC > 3u)
{
WFConsolePrintRomStr("SSID may not contain space for this demo", TRUE);
return FALSE;
}
WF_CPSetSsid(iwconfigCb.cpId, (UINT8 *)ARGV[2], strlen((char*)ARGV[2]));
return TRUE;
}
/*******************************************************************************
Function:
BOOL iwconfigSetMode(void)
Summary:
Set the mode to idle, managed or adhoc.
Description:
Idle mode - Force MRF24W module to disconnect from any currently connected network
Managed mode - MRF24W module will connect to SSID in infrastructure mode. Ensure all network
parameters are correct before this command is invoked.
Adhoc mode - MRF24W module will connect to SSID in adhoc mode. Ensure all network
parameters are correct before this command is invoked.
Parameters:
Mode - idle / managed /adhoc
Returns:
TRUE or FALSE
Remarks:
None.
*****************************************************************************/
static BOOL iwconfigSetMode(void)
{
UINT8 networkType;
WF_CPGetNetworkType(iwconfigCb.cpId, &networkType);
if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "idle") == 0) )
{
if ( iwconfigCb.isIdle )
{
WFConsolePrintRomStr("Already in the idle mode", TRUE);
}
else
{
if (WF_CMDisconnect() != WF_SUCCESS)
{
#if defined(STACK_USE_UART)
putsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
#endif
}
WF_PsPollDisable();
}
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "managed") == 0) )
{
if ( iwconfigCb.isIdle )
{
WF_CPSetNetworkType(iwconfigCb.cpId, WF_INFRASTRUCTURE);
WF_CMConnect(iwconfigCb.cpId);
}
else
{
WF_CPGetNetworkType(iwconfigCb.cpId, &networkType);
if (networkType == WF_INFRASTRUCTURE)
{
WFConsolePrintRomStr("Already in the managed mode", TRUE);
}
else
{
if (WF_CMDisconnect() != WF_SUCCESS)
{
#if defined(STACK_USE_UART)
putsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
#endif
}
WF_CPSetNetworkType(iwconfigCb.cpId, WF_INFRASTRUCTURE);
WF_CMConnect(iwconfigCb.cpId);
}
}
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "adhoc") == 0) )
{
if ( iwconfigCb.isIdle )
{
WF_CASetListRetryCount(ADHOC_RETRY_COUNT);
WF_CPSetNetworkType(iwconfigCb.cpId, WF_ADHOC);
WF_CPSetAdHocBehavior(iwconfigCb.cpId, WF_ADHOC_CONNECT_THEN_START);
WF_CMConnect(iwconfigCb.cpId);
}
else
{
WF_CPGetNetworkType(iwconfigCb.cpId, &networkType);
if (networkType == WF_ADHOC)
{
WFConsolePrintRomStr("Already in the adhoc mode", TRUE);
}
else
{
if (WF_CMDisconnect() != WF_SUCCESS)
{
#if defined(STACK_USE_UART)
putsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
#endif
}
WF_CPSetNetworkType(iwconfigCb.cpId, WF_ADHOC);
WF_CMConnect(iwconfigCb.cpId);
}
}
}
else
{
WFConsolePrintRomStr("Unknown parameter", TRUE);
return FALSE;
}
return TRUE;
}
static BOOL iwconfigSetChannel(void)
{
UINT8 *p1, *p2;
UINT8 *p_channelList;
UINT8 index = 0;
UINT16 temp;
if (ARGC < 3u)
{
WFConsolePrintRomStr("Missing value for last parameter", TRUE);
return FALSE;
}
if ( !iwconfigCb.isIdle )
{
WFConsolePrintRomStr("Channel can only be set in idle mode", TRUE);
return FALSE;
}
p_channelList = (UINT8*) ARGV[2];
p1 = p2 = p_channelList;
if ( strlen( (char*) p_channelList) == 0u )
return FALSE;
if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "all") == 0) )
{
WF_CASetChannelList(p_channelList, 0); // reset to domain default channel list
return TRUE;
}
do
{
if ( (p2 = (UINT8*) strchr( (const char *) p1, (int) ',')) != NULL )
{
*p2='\0';
p2++;
}
if( !ConvertASCIIUnsignedDecimalToBinary((INT8 *)p1, &temp) )
return FALSE;
p1 = p2;
p_channelList[index] = (UINT8) temp;
index++;
} while ( p2 != NULL );
WF_CASetChannelList(p_channelList, index);
return TRUE;
}
/*******************************************************************************
Function:
BOOL iwconfigSetPower(void)
Summary:
Enables or disables PS Poll mode.
Description:
Enables or disables PS Poll mode.
reenable / all - Enables all power saving features (PS_POLL) of the MRF24W. MRF24W
will wake up to check for all types of traffic (unicast, multicast, and broadcast)
disable - Disables any power savings features.
unicast - MRF24W will be in its deepest sleep state, only waking up at periodic intervals
to check for unicast data. MRF24W will not wake up on the DTIM period for
broadcast or multicast traffic.
Parameters:
reenable / disable / unicast /all
Returns:
TRUE or FALSE
Remarks:
WF_USE_POWER_SAVE_FUNCTIONS must be defined to use PS Poll mode.
*****************************************************************************/
static BOOL iwconfigSetPower(void)
{
if (ARGC < 3u)
{
WFConsolePrintRomStr("Missing value for last parameter", TRUE);
return FALSE;
}
if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "reenable") == 0) )
{ // reenable power saving
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(TRUE);
#endif
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "disable") == 0) )
{ // disable power saving
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollDisable();
#endif
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "unicast") == 0) )
{ // enable power saving but don't poll for DTIM
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(FALSE);
#endif
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "all") == 0) )
{ // enable power saving and poll for DTIM
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(TRUE);
#endif
}
else
{
WFConsolePrintRomStr("Unknown parameter", TRUE);
return FALSE;
}
return TRUE;
}
/*******************************************************************************
Function:
BOOL iwconfigSetDomain(void)
Summary:
Set the domain.
Description:
Set the MRF24W Regional Domain.
For MRF24WG with RF module FW version 0x3107 and future releases, this function
is NOT supported due to changes in FCC requirements, which does not allow programming
of the regional domain.
Parameters:
Domain - fcc / etsi /japan / other
Returns:
TRUE or FALSE
Remarks:
None.
*****************************************************************************/
static BOOL iwconfigSetDomain(void)
{
UINT8 domain;
if (ARGC < 3u)
{
WFConsolePrintRomStr("Missing value for last parameter", TRUE);
return FALSE;
}
if ( !iwconfigCb.isIdle )
{
WFConsolePrintRomStr("Domain can only be set in idle mode", TRUE);
return FALSE;
}
#if defined(MRF24WG)
if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "fcc") == 0) )
{
domain = WF_DOMAIN_FCC;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "etsi") == 0) )
{
domain = WF_DOMAIN_ETSI;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "japan") == 0) )
{
domain = WF_DOMAIN_JAPAN;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "other") == 0) )
{
domain = WF_DOMAIN_OTHER;
}
else
{
WFConsolePrintRomStr("Unknown domain", TRUE);
return FALSE;
}
#else
if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "fcc") == 0) )
{
domain = WF_DOMAIN_FCC;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "ic") == 0) )
{
domain = WF_DOMAIN_IC;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "etsi") == 0) )
{
domain = WF_DOMAIN_ETSI;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "spain") == 0) )
{
domain = WF_DOMAIN_SPAIN;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "france") == 0) )
{
domain = WF_DOMAIN_FRANCE;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "japana") == 0) )
{
domain = WF_DOMAIN_JAPAN_A;
}
else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "japanb") == 0) )
{
domain = WF_DOMAIN_JAPAN_B;
}
else
{
WFConsolePrintRomStr("Unknown domain", TRUE);
return FALSE;
}
#endif
WF_SetRegionalDomain(domain);
WF_CASetChannelList(NULL, 0); // reset to domain default channel list
return TRUE;
}
static BOOL iwconfigSetRTS(void)
{
UINT16 rtsThreshold;
if (ARGC < 3u)
{
WFConsolePrintRomStr("Missing value for last parameter", TRUE);
return FALSE;
}
if( !ConvertASCIIUnsignedDecimalToBinary(ARGV[2], &rtsThreshold) )
return FALSE;
WF_SetRtsThreshold(rtsThreshold);
return TRUE;
}
static BOOL iwconfigSetTxRate(void)
{
return FALSE;
}
static UINT8 SetMode_idle(void)
{
UINT8 networkType;
WF_CPGetNetworkType(iwconfigCb.cpId, &networkType);
if (FALSE == iwconfigCb.isIdle )
{
if (WF_CMDisconnect() != WF_SUCCESS)
{
putsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
}
WF_PsPollDisable();
#ifdef STACK_USE_CERTIFICATE_DEBUG
DelayMs(100);
#endif
}
return networkType;
}
static void SetMode_NotIdle(UINT8 networkType)
{
#ifdef STACK_USE_CERTIFICATE_DEBUG
DelayMs(100);
#endif
if(WF_INFRASTRUCTURE == networkType)
{
WF_CPSetNetworkType(iwconfigCb.cpId, WF_INFRASTRUCTURE);
WF_CMConnect(iwconfigCb.cpId);
}
else if(WF_ADHOC == networkType)
{
WF_CASetListRetryCount(ADHOC_RETRY_COUNT);
WF_CPSetNetworkType(iwconfigCb.cpId, WF_ADHOC);
WF_CPSetAdHocBehavior(iwconfigCb.cpId, WF_ADHOC_CONNECT_THEN_START);
WF_CMConnect(iwconfigCb.cpId);
}
else
{
//To be done
}
}
static BOOL iwconfigSetConnect(void)
{ // IWCONFIG CONNECT [ssid] [channel] [power-mode] //[security-mode] [WEP-key/passphrase] [retry-attempt]
UINT8 networkType;
if(ARGC < 3u)
{
putsUART("Wrong command, correct command is:IWCONFIG CONNECT [ssid] [bssid] [channel] [power-mode]\r\n");
return FALSE;
}
networkType = SetMode_idle();
if(ARGC >= 3u) // ssid
{
WF_CPSetSsid(iwconfigCb.cpId, (UINT8 *)ARGV[2], strlen((char*)ARGV[2]));
}
if(ARGC >= 4u) //channel
{
int int_channel;
sscanf((const char *)ARGV[3], (const char *)"%d",&int_channel);
if((int_channel>=1)&&(int_channel<=14))
{
WF_CASetChannelList((UINT8 *)&int_channel, 1);
}
else
{
WFConsolePrintRomStr("channel err (1~14): Unknown parameter", TRUE);
return FALSE;
}
}if(ARGC >= 5u) //channel
{
int int_channel;
UINT8 channel;
sscanf((const char *)ARGV[4], (const char *)"%d",&int_channel);
if((int_channel>=1)&&(int_channel<=14))
{
channel = int_channel;
//{char buf_t[20];sprintf(buf_t,"channel=%d\r\n",int_channel);putsUART(buf_t);}
WF_CASetChannelList(&channel, 1);
DelayMs(100);
}
else
{
WFConsolePrintRomStr("channel err (1~14): Unknown parameter", TRUE);
return FALSE;
}
}
if(ARGC >= 6u) // power-mode
{
if (strcmppgm2ram((char*)ARGV[5], "reenable") == 0)
{ // reenable power saving
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(TRUE);
#endif
}
else if (strcmppgm2ram((char*)ARGV[5], "disable") == 0)
{ // disable power saving
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollDisable();
#endif
}
else if (strcmppgm2ram((char*)ARGV[5], "unicast") == 0)
{ // enable power saving but don't poll for DTIM
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(FALSE);
#endif
}
else if (strcmppgm2ram((char*)ARGV[5], "all") == 0)
{ // enable power saving and poll for DTIM
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
WF_PsPollEnable(TRUE);
#endif
}
else
{
WFConsolePrintRomStr("Unknown parameter", TRUE);
return FALSE;
}
}
if(ARGC >= 7u) // [security-mode]
{
}
SetMode_NotIdle(networkType);
return TRUE;
}
#if defined(STACK_USE_CERTIFICATE_DEBUG)
BOOL iwconfigGetMacStats(void)
{
tWFMacStats my_WFMacStats;
WF_GetMacStats(&my_WFMacStats);
putsUART("MibRxMICFailureCounts = ");
{char buf_t[16]; sprintf(buf_t,"%u",(unsigned int)(my_WFMacStats.MibRxMICFailureCtr));putsUART(buf_t);}
//putsUART("\r\n");
return TRUE;
}
#endif
#endif /* WF_CONSOLE_IFCFGUTIL */
| 29.114353 | 125 | 0.544654 |
1560199c1efb1a0c21bfbe547e2bfec7df4c9470 | 8,685 | c | C | rock/external/xserver/hw/xwin/winrandr.c | NovasomIndustries/Utils-2019.01 | ab6d48edc03363f3ee4f1e9efc5269fdecfe35a8 | [
"MIT"
] | 2 | 2019-04-20T14:21:56.000Z | 2019-06-14T07:17:22.000Z | rock/external/xserver/hw/xwin/winrandr.c | NovasomIndustries/Utils-2019.07 | 4a41062e0f50c1f97cb37df91457672ce386516d | [
"MIT"
] | null | null | null | rock/external/xserver/hw/xwin/winrandr.c | NovasomIndustries/Utils-2019.07 | 4a41062e0f50c1f97cb37df91457672ce386516d | [
"MIT"
] | 1 | 2021-07-11T14:36:00.000Z | 2021-07-11T14:36:00.000Z | /*
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
*Copyright (C) 2009-2010 Jon TURNEY
*
*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 HAROLD L HUNT II 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.
*
*Except as contained in this notice, the name of the author(s)
*shall not be used in advertising or otherwise to promote the sale, use
*or other dealings in this Software without prior written authorization
*from the author(s)
*
* Authors: Harold L Hunt II
* Jon TURNEY
*/
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
/*
* Answer queries about the RandR features supported.
*/
static Bool
winRandRGetInfo(ScreenPtr pScreen, Rotation * pRotations)
{
rrScrPrivPtr pRRScrPriv;
RROutputPtr output;
pRRScrPriv = rrGetScrPriv(pScreen);
output = pRRScrPriv->outputs[0];
winDebug("winRandRGetInfo ()\n");
/* Don't support rotations */
*pRotations = RR_Rotate_0;
/* Delete previous mode */
if (output->modes[0])
{
RRModeDestroy(output->modes[0]);
RRModeDestroy(output->crtc->mode);
}
/* Register current mode */
{
xRRModeInfo modeInfo;
RRModePtr mode;
char name[100];
memset(&modeInfo, '\0', sizeof(modeInfo));
snprintf(name, sizeof(name), "%dx%d", pScreen->width, pScreen->height);
modeInfo.width = pScreen->width;
modeInfo.height = pScreen->height;
modeInfo.hTotal = pScreen->width;
modeInfo.vTotal = pScreen->height;
modeInfo.dotClock = 0;
modeInfo.nameLength = strlen(name);
mode = RRModeGet(&modeInfo, name);
output->modes[0] = mode;
output->numModes = 1;
mode = RRModeGet(&modeInfo, name);
output->crtc->mode = mode;
}
return TRUE;
}
/*
*/
void
winDoRandRScreenSetSize(ScreenPtr pScreen,
CARD16 width,
CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
WindowPtr pRoot = pScreen->root;
/* Ignore changes which do nothing */
if ((pScreen->width == width) && (pScreen->height == height) &&
(pScreen->mmWidth == mmWidth) && (pScreen->mmHeight == mmHeight))
return;
// Prevent screen updates while we change things around
SetRootClip(pScreen, ROOT_CLIP_NONE);
/* Update the screen size as requested */
pScreenInfo->dwWidth = width;
pScreenInfo->dwHeight = height;
/* Reallocate the framebuffer used by the drawing engine */
(*pScreenPriv->pwinFreeFB) (pScreen);
if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) {
ErrorF("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
}
pScreen->width = width;
pScreen->height = height;
pScreen->mmWidth = mmWidth;
pScreen->mmHeight = mmHeight;
/* Update the screen pixmap to point to the new framebuffer */
winUpdateFBPointer(pScreen, pScreenInfo->pfb);
// pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
// resize the root window
//pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
// does this emit a ConfigureNotify??
// Restore the ability to update screen, now with new dimensions
SetRootClip(pScreen, ROOT_CLIP_FULL);
// and arrange for it to be repainted
pScreen->PaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
/* Indicate that a screen size change took place */
RRScreenSizeNotify(pScreen);
}
/*
* Respond to resize request
*/
static
Bool
winRandRScreenSetSize(ScreenPtr pScreen,
CARD16 width,
CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winDebug("winRandRScreenSetSize ()\n");
/*
It doesn't currently make sense to allow resize in fullscreen mode
(we'd actually have to list the supported resolutions)
*/
if (pScreenInfo->fFullScreen) {
ErrorF
("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
return FALSE;
}
/*
Client resize requests aren't allowed in rootless modes, even if
the X screen is monitor or virtual desktop size, we'd need to
resize the native display size
*/
if (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
|| pScreenInfo->fMWExtWM
#endif
|| pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
|| pScreenInfo->fMultiWindow
#endif
) {
ErrorF
("winRandRScreenSetSize - resize not supported in rootless modes\n");
return FALSE;
}
winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
/* Cause the native window for the screen to resize itself */
{
DWORD dwStyle, dwExStyle;
RECT rcClient;
rcClient.left = 0;
rcClient.top = 0;
rcClient.right = width;
rcClient.bottom = height;
ErrorF("winRandRScreenSetSize new client area w: %d h: %d\n", width,
height);
/* Get the Windows window style and extended style */
dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
/*
* Calculate the window size needed for the given client area
* adjusting for any decorations it will have
*/
AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
ErrorF("winRandRScreenSetSize new window area w: %d h: %d\n",
(int)(rcClient.right - rcClient.left),
(int)(rcClient.bottom - rcClient.top));
SetWindowPos(pScreenPriv->hwndScreen, NULL,
0, 0, rcClient.right - rcClient.left,
rcClient.bottom - rcClient.top, SWP_NOZORDER | SWP_NOMOVE);
}
return TRUE;
}
/*
* Initialize the RandR layer.
*/
Bool
winRandRInit(ScreenPtr pScreen)
{
rrScrPrivPtr pRRScrPriv;
winDebug("winRandRInit ()\n");
if (!RRScreenInit(pScreen)) {
ErrorF("winRandRInit () - RRScreenInit () failed\n");
return FALSE;
}
/* Set some RandR function pointers */
pRRScrPriv = rrGetScrPriv(pScreen);
pRRScrPriv->rrGetInfo = winRandRGetInfo;
pRRScrPriv->rrSetConfig = NULL;
pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
pRRScrPriv->rrCrtcSet = NULL;
pRRScrPriv->rrCrtcSetGamma = NULL;
/* Create a CRTC and an output for the screen, and hook them together */
{
RRCrtcPtr crtc;
RROutputPtr output;
crtc = RRCrtcCreate(pScreen, NULL);
if (!crtc)
return FALSE;
crtc->rotations = RR_Rotate_0;
output = RROutputCreate(pScreen, "default", 7, NULL);
if (!output)
return FALSE;
RROutputSetCrtcs(output, &crtc, 1);
RROutputSetConnection(output, RR_Connected);
RROutputSetSubpixelOrder(output, PictureGetSubpixelOrder(pScreen));
output->crtc = crtc;
/* Set crtc outputs (should use RRCrtcNotify?) */
crtc->outputs = malloc(sizeof(RROutputPtr));
crtc->outputs[0] = output;
crtc->numOutputs = 1;
pRRScrPriv->primaryOutput = output;
/* Ensure we have space for exactly one mode */
output->modes = malloc(sizeof(RRModePtr));
output->modes[0] = NULL;
}
/*
The screen doesn't have to be limited to the actual
monitor size (we can have scrollbars :-), so set the
upper limit to the maximum coordinates X11 can use.
*/
RRScreenSetSizeRange(pScreen, 0, 0, 32768, 32768);
return TRUE;
}
| 30.051903 | 82 | 0.650086 |
4b5e34d3d514d96f3f3ec890fcef194d42e64fcb | 1,234 | h | C | low_level_controller/vehicle_atmega2560_firmware/watchdog.h | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 9 | 2020-06-24T11:22:15.000Z | 2022-01-13T14:14:13.000Z | low_level_controller/vehicle_atmega2560_firmware/watchdog.h | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 1 | 2021-05-10T13:48:04.000Z | 2021-05-10T13:48:04.000Z | low_level_controller/vehicle_atmega2560_firmware/watchdog.h | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 2 | 2021-11-08T11:59:29.000Z | 2022-03-15T13:50:54.000Z | /**
* \file watchdog.h
*
* \date Created: 6/21/2019 13:35:35
* \author: cfrauzem
*
* \brief The watchdog of the low_level_controller, which can be accessed via this module,
* controls the state of the vehicle. If the watchdog is enabled and the
* low_level_controller didn't get up-to-date information of the mid_level_controller
* for too long, the watchdog will provoke the low_level_controller to be set into
* safe-mode.
*
* \ingroup low_level_controller
*/
#ifndef WATCHDOG_H_
#define WATCHDOG_H_
#include "spi_packets.h"
extern volatile uint8_t safe_mode_flag;
/**
* \brief Disable the functionality of the watchdog.
*
* \author cfrauzem
* \ingroup low_level_controller
*/
void watchdog_disable();
/**
* \brief Enable the functionality of the watchdog.
*
* \author cfrauzem
* \ingroup low_level_controller
*/
void watchdog_enable();
/**
* \brief Reset the watchdog to the initial value. Has to be done regularily such that
* the safe-mode is not provoked when low_level_controller and mid_level_controller
* work together in a proper way.
*
* \author cfrauzem
* \ingroup low_level_controller
*/
void watchdog_reset();
#endif /* WATCHDOG_H_ */ | 24.68 | 92 | 0.712318 |
bbb9ed2127680de154e42c5458179989b627fe99 | 689 | h | C | Tutorial/myui/bdui/bdui/views/Input/KFDSTextView.h | Bytedesk/bytedesk-ios | f4ed1bec53ae4841abd27e18d68f0e92fdfabcf4 | [
"MIT"
] | 7 | 2019-05-16T07:40:58.000Z | 2020-12-26T16:16:05.000Z | Tutorial/myui/bdui/bdui/views/Input/KFDSTextView.h | pengjinning/bytedesk-ios | 65f7a949c5d184af467bfc384fc73ca84673cc26 | [
"MIT"
] | 1 | 2019-04-07T06:10:17.000Z | 2019-04-08T02:46:46.000Z | Tutorial/myui/bdui/bdui/views/Input/KFDSTextView.h | pengjinning/bytedesk-ios | 65f7a949c5d184af467bfc384fc73ca84673cc26 | [
"MIT"
] | 3 | 2019-06-09T12:52:54.000Z | 2020-04-10T05:43:28.000Z | //
// CSTextView.h
// feedback
//
// Created by 宁金鹏 on 2017/2/22.
// Copyright © 2017年 宁金鹏. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KFDSTextView : UITextView
/**
* textView最大行数
*/
@property (nonatomic, assign) NSUInteger maxNumberOfLines;
/**
* 文字高度改变block → 文字高度改变会自动调用
* block参数(text) → 文字内容
* block参数(textHeight) → 文字高度
*/
@property (nonatomic, strong) void(^yz_textHeightChangeBlock)(NSString *text,CGFloat textHeight);
/**
* 设置圆角
*/
@property (nonatomic, assign) NSUInteger cornerRadius;
/**
* 占位文字
*/
@property (nonatomic, strong) NSString *placeholder;
/**
* 占位文字颜色
*/
@property (nonatomic, strong) UIColor *placeholderColor;
@end
| 16.404762 | 97 | 0.683599 |
9ddaf355b3cfa93f16a989831c8b8eb618a03bc0 | 12,342 | c | C | mdm-helper/mdm_helper.c | BlissRoms-Devices/device_lge_g4-common | f09460f17786b76981f1c7f5d5a66bbec4a8d511 | [
"FTL"
] | 8 | 2017-11-21T00:59:17.000Z | 2021-01-25T15:26:57.000Z | mdm-helper/mdm_helper.c | LGgFour/android_device_lge_g4-common | 249c05705b0759fe811962475f4bd1d71d248b03 | [
"FTL"
] | 3 | 2017-11-22T07:12:28.000Z | 2021-01-13T10:26:32.000Z | mdm-helper/mdm_helper.c | LGgFour/android_device_lge_g4-common | 249c05705b0759fe811962475f4bd1d71d248b03 | [
"FTL"
] | 20 | 2017-10-03T01:28:21.000Z | 2021-03-21T07:57:02.000Z | /*
*mdm_helper: A module to monitor modem activities on fusion devices
*
*Copyright (C) 2012,2014 Qualcomm Technologies, Inc. All rights reserved.
* Qualcomm Technologies Proprietary/GTDR
*
*All data and information contained in or disclosed by this document is
*confidential and proprietary information of Qualcomm Technologies, Inc. and all
*rights therein are expressly reserved. By accepting this material the
*recipient agrees that this material and the information contained therein
*is held in confidence and in trust and will not be used, copied, reproduced
*in whole or in part, nor its contents revealed in any manner to others
*without the express written permission of Qualcomm Technologies, Inc.
*
*mdm_helper.c : Main implementation of mdm_helper
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <pwd.h>
#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <linux/msm_charm.h>
#include <linux/ioctl.h>
#include <cutils/properties.h>
#include <mdm_detect.h>
#include <mdm_helper_private.h>
#include <dirent.h>
static struct mdm_helper_drv mdm_helper;
/*
* Get the ops structure for a particular esoc.
*/
static int get_soc_ops(char *esoc_dev_node,
struct mdm_helper_ops *ops )
{
char *soc_name = get_soc_name(esoc_dev_node);
if (!soc_name) {
ALOGE("Failed to populate ops structure");
goto error;
}
if (!strncmp(soc_name, "MDM9x25",6) ||
!strncmp(soc_name, "MDM9x35", 6)) {
*ops = mdm9k_ops;
return RET_SUCCESS;
}
ALOGE("Failed to get ops structure for %s", soc_name);
error:
if (soc_name)
free(soc_name);
return RET_FAILED;
}
/*
* Obtain the private data struct(if any) for the esoc.
*/
static int get_soc_private_data(char *esoc_dev_node,
struct mdm_private_data **pdata)
{
char *soc_name = get_soc_name(esoc_dev_node);
char *link_name = get_soc_link(esoc_dev_node);
if (!soc_name || !link_name) {
ALOGE("Failed to populate private data.Invalid name/link");
goto error;
}
if ((!strncmp(soc_name, "MDM9x25",6) &&
!strncmp(link_name, LINK_HSIC, 4)) ||
(!strncmp(soc_name, "MDM9x35",6) &&
!strncmp(link_name, LINK_HSIC, 4))) {
ALOGI("Found private data for %s", soc_name);
*pdata = &private_data_9x25_hsic;
free(soc_name);
free(link_name);
return RET_SUCCESS;
}
ALOGI("No private data structure present for %s over link %s",
soc_name,
link_name);
pdata = NULL;
free(soc_name);
free(link_name);
return RET_SUCCESS;
error:
if (soc_name)
free(soc_name);
if (link_name)
free(link_name);
return RET_FAILED;
}
static int load_configuration_via_esoc()
{
int num_soc = 0;
int count = 0;
int i = 0;
struct mdm_device *dev;
struct dev_info devinfo;
if (get_system_info(&devinfo) != RET_SUCCESS) {
ALOGE("Failed to get device configuration.mdm-helper disabled");
do {
sleep(500000);
}while(1);
}
if (devinfo.num_modems == 0) {
ALOGE("No supported ESOC's found");
goto error;
}
for (count = 0; count < devinfo.num_modems; count++) {
if (devinfo.mdm_list[count].type == MDM_TYPE_EXTERNAL)
num_soc++;
}
ALOGI("%d supported modem(s) found", num_soc);
dev = (struct mdm_device*)malloc(sizeof(struct mdm_device) * num_soc);
if (!dev) {
ALOGE("Failed to allocate mdm_device structure");
goto error;
}
ALOGI("Setting up mdm helper device structure");
mdm_helper.num_modems = num_soc;
mdm_helper.baseband_name = "n/a";
mdm_helper.platform_name = "n/a";
mdm_helper.dev = dev;
count = 0;
for (i = 0; i < devinfo.num_modems; i++) {
if (devinfo.mdm_list[i].type == MDM_TYPE_EXTERNAL) {
strlcpy(dev[count].esoc_node,
devinfo.mdm_list[i].esoc_node,
sizeof(dev[count].esoc_node));
strlcpy(dev[count].mdm_name,
devinfo.mdm_list[i].mdm_name,
sizeof(dev[count].mdm_name));
if (!strcmp(devinfo.mdm_list[i].mdm_link,
LINK_HSIC_PCIE))
strlcpy(dev[count].mdm_link,
LINK_HSIC,
sizeof(dev[count].mdm_link));
else
strlcpy(dev[count].mdm_link,
devinfo.mdm_list[i].mdm_link,
sizeof(dev[count].mdm_link));
strlcpy(dev[count].mdm_port,
devinfo.mdm_list[i].drv_port,
sizeof(dev[count].mdm_port));
dev[count].device_descriptor = 0;
dev[count].required_action = MDM_REQUIRED_ACTION_NONE;
if (strncmp(dev[count].mdm_name, "MDM", 3) == 0)
strlcpy(dev[count].images_path,
MDM9K_IMAGE_PATH,
sizeof(dev[count].images_path));
else
strlcpy(dev[count].images_path,
"N/A",
sizeof(dev->images_path));
strlcpy(dev[count].ram_dump_path,
devinfo.mdm_list[i].ram_dump_path,
sizeof(dev[count].ram_dump_path));
if (get_soc_ops(dev[count].esoc_node,
&(dev->ops)) != RET_SUCCESS) {
ALOGE("Failed to get ops stucture for modem");
goto error;
}
if (get_soc_private_data(dev[count].esoc_node,
(struct mdm_private_data**) \
&dev->private_data)
!= RET_SUCCESS) {
ALOGW("No private data located for %s",
dev[count].mdm_name);
}
ALOGI("ESOC Details:\n\tName:%s\n\tPort:%s\n\tLink:%s",
dev->mdm_name, dev->mdm_port,
dev->mdm_link);
count++;
}
}
return RET_SUCCESS;
error:
return RET_FAILED;
}
int mdm_helper_init()
{
int i, rcode;
if (esoc_framework_supported() != RET_SUCCESS) {
ALOGE("ESOC framework not detected");
return RET_FAILED;
}
rcode = load_configuration_via_esoc();
if (rcode != RET_SUCCESS) {
do {
ALOGE("Failed to load device configuration");
sleep(500);
}while(1);
} else
ALOGI("Device configuration loaded");
for (i = 0; i < mdm_helper.num_modems; i++) {
if (!mdm_helper.dev[i].ops.power_up ||
!mdm_helper.dev[i].ops.post_power_up) {
ALOGE("power_up/post_power_up undefined for %s\n",
mdm_helper.dev[i].mdm_name);
return RET_FAILED;
}
}
return RET_SUCCESS;
}
static void* modem_state_machine(void *arg)
{
struct mdm_device *dev = (struct mdm_device *) arg;
MdmHelperStates state = MDM_HELPER_STATE_POWERUP;
ALOGI("Starting %s",dev->mdm_name);
do {
switch (state) {
case MDM_HELPER_STATE_POWERUP:
ALOGI("%s : switching state to POWERUP", dev->mdm_name);
if (dev->ops.power_up(dev)
!= RET_SUCCESS) {
ALOGE("%s : Powerup failed", dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
if (dev->required_action ==
MDM_REQUIRED_ACTION_RAMDUMPS) {
state = MDM_HELPER_STATE_RAMDUMP;
dev->required_action =
MDM_REQUIRED_ACTION_NONE;
} else
state = MDM_HELPER_STATE_POST_POWERUP;
break;
case MDM_HELPER_STATE_POST_POWERUP:
ALOGI("%s : switching state to POST POWERUP/monitor",
dev->mdm_name);
if (dev->ops.post_power_up(dev) !=
RET_SUCCESS) {
ALOGE("%s : Post power_up failed",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
if (dev->required_action ==
MDM_REQUIRED_ACTION_RAMDUMPS) {
state = MDM_HELPER_STATE_RAMDUMP;
dev->required_action =
MDM_REQUIRED_ACTION_NONE;
break;
} else if (dev->required_action ==
MDM_REQUIRED_ACTION_NORMAL_BOOT) {
state = MDM_HELPER_STATE_POWERUP;
dev->required_action =
MDM_REQUIRED_ACTION_NONE;
break;
} else if (dev->required_action ==
MDM_REQUIRED_ACTION_SHUTDOWN) {
if (dev->ops.shutdown) {
state = MDM_HELPER_STATE_SHUTDOWN;
} else {
ALOGI("%s:No shutdown function present",
dev->mdm_name);
state = MDM_HELPER_STATE_POST_POWERUP;
}
dev->required_action =
MDM_REQUIRED_ACTION_NONE;
break;
}
ALOGE("%s : post pwrup returned unsupported action:%d",
dev->mdm_name,
dev->required_action);
state = MDM_HELPER_STATE_FAIL;
break;
case MDM_HELPER_STATE_RAMDUMP:
ALOGI("%s : Switching state to RAMDUMP",
dev->mdm_name);
if (dev->ops.prep_for_ramdumps) {
if (dev->ops.\
prep_for_ramdumps(dev)
!= RET_SUCCESS) {
ALOGE("%s :prep_for_ramdump failed",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
}
if (dev->ops.collect_ramdumps) {
if (dev->ops.\
collect_ramdumps(dev) !=
RET_SUCCESS){
ALOGE("%s :ramdump collect failed",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
} else {
ALOGE("%s :No collect_ramdump function defined",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
if (dev->ops.post_ramdump_collect) {
if (dev->ops.\
post_ramdump_collect(dev)
!= RET_SUCCESS) {
ALOGE("%s :post ramdump collect failed",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
}
if ((dev->required_action !=
MDM_REQUIRED_ACTION_NORMAL_BOOT) &&
(dev->required_action !=
MDM_REQUIRED_ACTION_NONE) &&
(dev->required_action !=
MDM_REQUIRED_ACTION_SHUTDOWN)) {
ALOGE("%s:Invalid state trans req:state:%d",
dev->mdm_name,
dev->required_action);
}
if (dev->required_action ==
MDM_REQUIRED_ACTION_SHUTDOWN)
state = MDM_HELPER_STATE_SHUTDOWN;
else
state = MDM_HELPER_STATE_POWERUP;
dev->required_action = MDM_REQUIRED_ACTION_NONE;
break;
case MDM_HELPER_STATE_REBOOT:
ALOGI("%s : Normal reboot request", dev->mdm_name);
if (!dev->ops.reboot) {
ALOGE("%s : Reboot function not defined",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
if (dev->ops.reboot(dev) != RET_SUCCESS) {
state = MDM_HELPER_STATE_FAIL;
break;
}
state = MDM_HELPER_STATE_POST_POWERUP;
break;
case MDM_HELPER_STATE_SHUTDOWN:
ALOGI("%s: Handling shutdown request",
dev->mdm_name);
if (!dev->ops.shutdown) {
ALOGE("%s: No shutdown function defined",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
if (dev->ops.shutdown(dev) != RET_SUCCESS) {
ALOGE("%s: Shutdown function failed",
dev->mdm_name);
state = MDM_HELPER_STATE_FAIL;
break;
}
state = MDM_HELPER_STATE_POWERUP;
break;
case MDM_HELPER_STATE_FAIL:
ALOGE("%s : Reached failed state. exiting",
dev->mdm_name);
if (dev->ops.failure_cleanup) {
ALOGI("%s : Calling cleanup function",
dev->mdm_name);
dev->ops.failure_cleanup(dev);
} else
ALOGI("%s : No cleanup function defined",
dev->mdm_name);
return 0;
default:
ALOGE("%s : Reached unknown state %d.exiting",
dev->mdm_name,
state);
state = MDM_HELPER_STATE_FAIL;
break;
}
} while(1);
}
static void* modem_proxy_routine(void *arg)
{
struct mdm_device *dev = (struct mdm_device*)arg;
char powerup_node[MAX_PATH_LEN];
int fd;
snprintf(powerup_node, sizeof(powerup_node),
"/dev/subsys_%s",
dev->esoc_node);
fd = open(powerup_node, O_RDONLY);
if (fd < 0) {
ALOGE("%s: Proxy thread failed to open esoc node: %s",
dev->mdm_name,
powerup_node);
}
do {
sleep(50000);
} while(1);
return NULL;
}
int main(int argc, char *argv[])
{
int i;
int rcode = 0;
int valid_argument = 0;
pthread_t *tid = NULL;
void *(*mdm_routine) (void *);
if (mdm_helper_init()) {
ALOGE("Initializaion failed");
return 0;
}
if (argc > 1) {
ALOGI("Standalone mode");
for (i = 0; i < mdm_helper.num_modems; i++)
{
if (!strncmp(argv[1],mdm_helper.dev[i].mdm_name,
MDM_NAME_LEN)) {
valid_argument = 1;
break;
}
}
if (!valid_argument) {
ALOGE("Unrecognised modem :%s",argv[1]);
return RET_FAILED;
}
if (mdm_helper.dev[i].ops.standalone_mode)
return mdm_helper.dev[i].ops.\
standalone_mode(&mdm_helper.dev[i],
&argv[1]);
else
ALOGE("No standalone function defined");
return RET_FAILED;
}
ALOGI("Starting MDM helper");
tid = (pthread_t*) malloc(mdm_helper.num_modems * sizeof(pthread_t));
if (!tid) {
ALOGE("Failed to create modem threads : %s",strerror(errno));
return RET_FAILED;
}
if (!strcmp(basename(argv[0]), "mdm_helper_proxy"))
mdm_routine = &modem_proxy_routine;
else
mdm_routine = &modem_state_machine;
for (i = 0; i < mdm_helper.num_modems; i++) {
ALOGI("Creating thread for %s",mdm_helper.dev[i].mdm_name);
rcode = pthread_create(&tid[i], NULL,
mdm_routine,
(void*)(&(mdm_helper.dev[i])));
if (rcode) {
ALOGE("Failed to create thread for %s\n",
mdm_helper.dev[i].mdm_name);
return RET_FAILED;
}
}
do {
sleep(250000);
} while(1);
return 0;
}
| 26.484979 | 81 | 0.669989 |
8bb43abd3b7e8fe4f7fa8cd509b5939ec88526c9 | 4,407 | h | C | source/blender/blenlib/BLI_ghash.h | wycivil08/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 30 | 2015-01-29T14:06:05.000Z | 2022-01-10T07:47:29.000Z | source/blender/blenlib/BLI_ghash.h | ttagu99/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 1 | 2017-02-20T20:57:48.000Z | 2018-12-19T23:44:38.000Z | source/blender/blenlib/BLI_ghash.h | ttagu99/blendocv | f6cce83e1f149fef39afa8043aade9c64378f33e | [
"Unlicense"
] | 15 | 2015-04-23T02:38:36.000Z | 2021-03-01T20:09:39.000Z | /*
* $Id: BLI_ghash.h 39316 2011-08-12 02:23:06Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_GHASH_H
#define BLI_GHASH_H
/** \file BLI_ghash.h
* \ingroup bli
* \brief A general (pointer -> pointer) hash table ADT
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "BLI_mempool.h"
#include "BLI_blenlib.h"
typedef unsigned int (*GHashHashFP) (const void *key);
typedef int (*GHashCmpFP) (const void *a, const void *b);
typedef void (*GHashKeyFreeFP) (void *key);
typedef void (*GHashValFreeFP) (void *val);
typedef struct Entry {
struct Entry *next;
void *key, *val;
} Entry;
typedef struct GHash {
GHashHashFP hashfp;
GHashCmpFP cmpfp;
Entry **buckets;
struct BLI_mempool *entrypool;
int nbuckets, nentries, cursize;
} GHash;
typedef struct GHashIterator {
GHash *gh;
int curBucket;
struct Entry *curEntry;
} GHashIterator;
/* *** */
GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info);
void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
void BLI_ghash_insert(GHash *gh, void *key, void *val);
void * BLI_ghash_lookup(GHash *gh, const void *key);
int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
int BLI_ghash_haskey(GHash *gh, void *key);
int BLI_ghash_size (GHash *gh);
/* *** */
/**
* Create a new GHashIterator. The hash table must not be mutated
* while the iterator is in use, and the iterator will step exactly
* BLI_ghash_size(gh) times before becoming done.
*
* @param gh The GHash to iterate over.
* @return Pointer to a new DynStr.
*/
GHashIterator* BLI_ghashIterator_new (GHash *gh);
/**
* Init an already allocated GHashIterator. The hash table must not
* be mutated while the iterator is in use, and the iterator will
* step exactly BLI_ghash_size(gh) times before becoming done.
*
* @param ghi The GHashIterator to initialize.
* @param gh The GHash to iterate over.
*/
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh);
/**
* Free a GHashIterator.
*
* @param ghi The iterator to free.
*/
void BLI_ghashIterator_free (GHashIterator *ghi);
/**
* Retrieve the key from an iterator.
*
* @param ghi The iterator.
* @return The key at the current index, or NULL if the
* iterator is done.
*/
void* BLI_ghashIterator_getKey (GHashIterator *ghi);
/**
* Retrieve the value from an iterator.
*
* @param ghi The iterator.
* @return The value at the current index, or NULL if the
* iterator is done.
*/
void* BLI_ghashIterator_getValue (GHashIterator *ghi);
/**
* Steps the iterator to the next index.
*
* @param ghi The iterator.
*/
void BLI_ghashIterator_step (GHashIterator *ghi);
/**
* Determine if an iterator is done (has reached the end of
* the hash table).
*
* @param ghi The iterator.
* @return True if done, False otherwise.
*/
int BLI_ghashIterator_isDone (GHashIterator *ghi);
/* *** */
unsigned int BLI_ghashutil_ptrhash (const void *key);
int BLI_ghashutil_ptrcmp (const void *a, const void *b);
unsigned int BLI_ghashutil_strhash (const void *key);
int BLI_ghashutil_strcmp (const void *a, const void *b);
unsigned int BLI_ghashutil_inthash (const void *ptr);
int BLI_ghashutil_intcmp (const void *a, const void *b);
#ifdef __cplusplus
}
#endif
#endif /* BLI_GHASH_H */
| 27.716981 | 98 | 0.705015 |
eb6e3cd2d62cd4f86fdbbe7c82958aab9036d001 | 1,491 | c | C | source/gtk/init/init_changtype.c | kassisdion/Raytracer | ef18d5dc84c838f45e6d2a938dbdcd6acb549d8a | [
"MIT"
] | 1 | 2015-02-17T03:26:16.000Z | 2015-02-17T03:26:16.000Z | source/gtk/init/init_changtype.c | kassisdion/raytracer | ef18d5dc84c838f45e6d2a938dbdcd6acb549d8a | [
"MIT"
] | null | null | null | source/gtk/init/init_changtype.c | kassisdion/raytracer | ef18d5dc84c838f45e6d2a938dbdcd6acb549d8a | [
"MIT"
] | null | null | null | /*
** init_changtype.c for init_changtype in /home/caron/git/generaytacer/source/gtk/init
**
** Made by Caron Thomas
** Login <caron_t@epitech.net>
**
** Started on Mon May 20 17:41:04 2013 Caron Thomas
** Last update Tue Jun 4 02:47:59 2013 florian faisant
*/
#include <gtk/gtk.h>
#include "gen.h"
#include "callback.h"
#include "pos.h"
#include "gtk_func.h"
static GtkWidget *init_button(t_wid *wid)
{
int nb_box;
int i;
GtkWidget *box[3];
i = 0;
nb_box = 0;
box[0] = gtk_hbox_new(FALSE, 0);
box[1] = gtk_hbox_new(FALSE, 0);
while (i < 6)
{
wid->surface->objselect[i].type = i + 1;
wid->surface->objselect[i].button =
new_button(NULL, get_image(i + 1), G_CALLBACK(type_obj),
&wid->surface->objselect[i]);
wid->surface->objselect[i].wid = wid;
if (wid->surface->objselect[i].wid != NULL)
gtk_box_pack_start(GTK_BOX(box[nb_box]),
wid->surface->objselect[i++].button,
TRUE, TRUE, 0);
if ((i % 3) == 0)
nb_box++;
}
gtk_widget_show(box[0]);
gtk_widget_show(box[1]);
return (unit_vbox(box, nb_box, FALSE, 0));
}
t_wid *init_changetype(t_wid *wid)
{
wid->surface->win_obj = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(wid->surface->win_obj), "Change Type");
g_signal_connect(G_OBJECT(wid->surface->win_obj), "destroy",
G_CALLBACK(objtype_ok), wid);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wid->surface->win_obj)->vbox),
init_button(wid), TRUE, TRUE, 0);
return (0);
}
| 26.625 | 86 | 0.649229 |
55725d54ad16c56df70a0fc86312909ad19dd376 | 452 | h | C | MISC/APE/include/inttypes.h | aryx/principia-softwarica | 4191ace48c70d7e70ef0002b27324c3a766f7672 | [
"LPL-1.02"
] | null | null | null | MISC/APE/include/inttypes.h | aryx/principia-softwarica | 4191ace48c70d7e70ef0002b27324c3a766f7672 | [
"LPL-1.02"
] | null | null | null | MISC/APE/include/inttypes.h | aryx/principia-softwarica | 4191ace48c70d7e70ef0002b27324c3a766f7672 | [
"LPL-1.02"
] | null | null | null | #ifndef _SUSV2_SOURCE
#error "inttypes.h is SUSV2"
#endif
#ifndef _INTTYPES_H_
#define _INTTYPES_H_ 1
typedef int _intptr_t;
typedef unsigned int _uintptr_t;
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef _intptr_t intptr_t;
typedef _uintptr_t uintptr_t;
#endif
| 18.833333 | 36 | 0.818584 |
1d18fef7d0a4471a061936cad416203affa12a95 | 833 | c | C | globaltime.c | kwasmich/GLES2Playground | 95ec30a7bcd040ebdc4bfabb5d4c76b1844a3cf5 | [
"MIT"
] | 5 | 2015-01-11T11:44:18.000Z | 2019-02-23T03:35:08.000Z | globaltime.c | kwasmich/GLES2Playground | 95ec30a7bcd040ebdc4bfabb5d4c76b1844a3cf5 | [
"MIT"
] | null | null | null | globaltime.c | kwasmich/GLES2Playground | 95ec30a7bcd040ebdc4bfabb5d4c76b1844a3cf5 | [
"MIT"
] | null | null | null | //
// globaltime.c
// GlobalTime
//
// Created by Michael Kwasnicki on 25.01.15.
// Copyright (c) 2015 Michael Kwasnicki. All rights reserved.
//
#include "globaltime.h"
#include <stddef.h>
#include <sys/time.h>
static struct timeval s_relativeZero;
static float s_time = 0;
static float s_timeDelta = 0;
void timeReset() {
gettimeofday(&s_relativeZero, NULL);
s_time = 0;
}
void timeTick() {
struct timeval now, delta;
gettimeofday(&now, NULL);
timersub(&now, &s_relativeZero, &delta);
float before = s_time;
s_time = (float)(delta.tv_sec) + (float)(delta.tv_usec) * 0.000001f;
s_timeDelta = s_time - before;
}
void timeSet(const float in_TIME) {
s_time = in_TIME;
s_timeDelta = 0;
}
float timeGet() {
return s_time;
}
float timeDelta() {
return s_timeDelta;
}
| 15.145455 | 72 | 0.659064 |
b1f14665034057aef80d4e9dfdca555af647c4ee | 2,608 | h | C | ui/message_center/views/notification_header_view.h | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | ui/message_center/views/notification_header_view.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | ui/message_center/views/notification_header_view.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright 2017 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 UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_HEADER_VIEW_H_
#define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_HEADER_VIEW_H_
#include "base/macros.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/views/controls/button/button.h"
namespace views {
class ImageView;
class Label;
}
namespace message_center {
class NotificationControlButtonsView;
class NotificationHeaderView : public views::Button {
public:
NotificationHeaderView(NotificationControlButtonsView* control_buttons_view,
views::ButtonListener* listener);
void SetAppIcon(const gfx::ImageSkia& img);
void SetAppName(const base::string16& name);
void SetProgress(int progress);
void SetOverflowIndicator(int count);
void SetTimestamp(base::Time past);
void SetExpandButtonEnabled(bool enabled);
void SetExpanded(bool expanded);
void SetSettingsButtonEnabled(bool enabled);
void SetCloseButtonEnabled(bool enabled);
void SetControlButtonsVisible(bool visible);
// Set the unified theme color used among the app icon, app name, and expand
// button.
void SetAccentColor(SkColor color);
void ClearAppIcon();
void ClearProgress();
void ClearOverflowIndicator();
void ClearTimestamp();
bool IsExpandButtonEnabled();
void SetSubpixelRenderingEnabled(bool enabled);
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// Button override:
std::unique_ptr<views::InkDrop> CreateInkDrop() override;
views::ImageView* expand_button() { return expand_button_; }
SkColor accent_color_for_testing() { return accent_color_; }
private:
// Update visibility for both |summary_text_view_| and |timestamp_view_|.
void UpdateSummaryTextVisibility();
SkColor accent_color_ = kNotificationDefaultAccentColor;
views::Label* app_name_view_ = nullptr;
views::Label* summary_text_divider_ = nullptr;
views::Label* summary_text_view_ = nullptr;
views::Label* timestamp_divider_ = nullptr;
views::Label* timestamp_view_ = nullptr;
views::ImageView* app_icon_view_ = nullptr;
views::ImageView* expand_button_ = nullptr;
bool settings_button_enabled_ = false;
bool has_progress_ = false;
bool has_overflow_indicator_ = false;
bool has_timestamp_ = false;
bool is_expanded_ = false;
DISALLOW_COPY_AND_ASSIGN(NotificationHeaderView);
};
} // namespace message_center
#endif // UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_HEADER_VIEW_H_
| 32.197531 | 78 | 0.778374 |
df8a2836defc1df42f477a1a7125cfc5115e7c89 | 1,041 | h | C | src/vl53l0x_i2c_platform.h | Vgdn1942/Adafruit_VL53L0X | 1cd7556aeff27eb2af37158196e55b9739cd2f09 | [
"MIT"
] | 114 | 2017-01-11T06:53:43.000Z | 2022-02-23T15:10:37.000Z | src/vl53l0x_i2c_platform.h | Vgdn1942/Adafruit_VL53L0X | 1cd7556aeff27eb2af37158196e55b9739cd2f09 | [
"MIT"
] | 48 | 2016-12-10T10:22:13.000Z | 2022-03-17T14:19:45.000Z | src/vl53l0x_i2c_platform.h | Vgdn1942/Adafruit_VL53L0X | 1cd7556aeff27eb2af37158196e55b9739cd2f09 | [
"MIT"
] | 104 | 2016-12-10T09:34:42.000Z | 2022-03-31T11:04:50.000Z | #include "Arduino.h"
#include "Wire.h"
// initialize I2C
int VL53L0X_i2c_init(TwoWire *i2c);
int VL53L0X_write_multi(uint8_t deviceAddress, uint8_t index, uint8_t *pdata,
uint32_t count, TwoWire *i2c);
int VL53L0X_read_multi(uint8_t deviceAddress, uint8_t index, uint8_t *pdata,
uint32_t count, TwoWire *i2c);
int VL53L0X_write_byte(uint8_t deviceAddress, uint8_t index, uint8_t data,
TwoWire *i2c);
int VL53L0X_write_word(uint8_t deviceAddress, uint8_t index, uint16_t data,
TwoWire *i2c);
int VL53L0X_write_dword(uint8_t deviceAddress, uint8_t index, uint32_t data,
TwoWire *i2c);
int VL53L0X_read_byte(uint8_t deviceAddress, uint8_t index, uint8_t *data,
TwoWire *i2c);
int VL53L0X_read_word(uint8_t deviceAddress, uint8_t index, uint16_t *data,
TwoWire *i2c);
int VL53L0X_read_dword(uint8_t deviceAddress, uint8_t index, uint32_t *data,
TwoWire *i2c);
| 47.318182 | 77 | 0.665706 |
8dae61baea45ba57654bcf4a6331fe60d016bd12 | 835 | h | C | Example/Pods/Headers/Public/ChameleonFramework/ChameleonEnums.h | YuyeQingshan/QSQuickDemoKit | 25f38dcf4d402e57babc2c079f56ff1b961cb290 | [
"MIT"
] | 27 | 2018-11-17T19:19:40.000Z | 2021-12-14T12:47:54.000Z | FoodbLog/Pods/Headers/Private/ChameleonFramework/ChameleonEnums.h | ParkSangGwon/FoodbLog | 1a6518fd62b4f0b6b15293017ca1286a256b24ae | [
"MIT"
] | 2 | 2016-02-15T22:32:19.000Z | 2016-03-01T10:16:08.000Z | FoodbLog/Pods/Headers/Private/ChameleonFramework/ChameleonEnums.h | ParkSangGwon/FoodbLog | 1a6518fd62b4f0b6b15293017ca1286a256b24ae | [
"MIT"
] | 10 | 2016-12-15T10:28:17.000Z | 2021-02-01T13:57:01.000Z | //
// ChameleonEnums.h
// Chameleon
//
// Created by Vicc Alexander on 6/8/15.
// Copyright (c) 2015 Vicc Alexander. All rights reserved.
//
#ifndef Chameleon_ChameleonEnums_h
#define Chameleon_ChameleonEnums_h
/**
* Specifies how text-based UI elements and other content such as switch knobs, should be colored.
*
* @since 2.0
*/
typedef NS_ENUM(NSUInteger, UIContentStyle) {
/**
* Automatically chooses and colors text-based elements with the shade that best contrasts its @c backgroundColor.
*
* @since 2.0
*/
UIContentStyleContrast,
/**
* Colors text-based elements using a light shade.
*
* @since 2.0
*/
UIContentStyleLight,
/**
* Colors text-based elements using a light shade.
*
* @since 2.0
*/
UIContentStyleDark
};
#endif
| 20.875 | 119 | 0.646707 |
a83c0f5b6e056bcc7a0a541e4aa0cd76658d6ff9 | 649 | c | C | 04-12-2022/exercice3.c | zakariaCHOUKRI/cours-prog | 389e5f1f3ec404535afb11aa8385230460c5c651 | [
"CC0-1.0"
] | null | null | null | 04-12-2022/exercice3.c | zakariaCHOUKRI/cours-prog | 389e5f1f3ec404535afb11aa8385230460c5c651 | [
"CC0-1.0"
] | null | null | null | 04-12-2022/exercice3.c | zakariaCHOUKRI/cours-prog | 389e5f1f3ec404535afb11aa8385230460c5c651 | [
"CC0-1.0"
] | null | null | null | #include <stdio.h>
int main()
{
int i, j, decal, taille, temp;
printf("entrer la taille du tableau: ");
scanf("%i", &taille);
int tab[taille];
int *p;
p = tab;
printf("entrer les elements du tableau:\n");
for (i = 0; i < taille; i++) scanf("%i", p+i);
printf("entrer le decalage:\n");
scanf("%i", &decal);
printf("le tableau initial:\n");
for (i = 0; i < taille; i++) printf("%i|", *(p+i));
for (i = 0; i < decal; i++)
{
for (j = 0; j < taille; j++)
{
temp = *p;
*p = *(p+j);
*(p+j) = temp;
}
}
printf("\n\nle tableau apres decalage:\n");
for (i = 0; i < taille; i++) printf("%i|", *(p+i));
return 0;
} | 18.542857 | 52 | 0.513097 |
a85074f2768ee5eae057cd4aff6d95e73d4020d1 | 290 | h | C | JCCategoryKit/JCCategoryKit/Other/AppDelegate.h | JackeyChen1015/JCExtensionKit | 0165444bb962f9cef0661f9fc581f6a0b3ef49bf | [
"Apache-2.0"
] | 1 | 2019-05-01T12:54:47.000Z | 2019-05-01T12:54:47.000Z | JCCategoryKit/JCCategoryKit/Other/AppDelegate.h | JackeyChen1015/JCCategoryKit | 0165444bb962f9cef0661f9fc581f6a0b3ef49bf | [
"Apache-2.0"
] | null | null | null | JCCategoryKit/JCCategoryKit/Other/AppDelegate.h | JackeyChen1015/JCCategoryKit | 0165444bb962f9cef0661f9fc581f6a0b3ef49bf | [
"Apache-2.0"
] | null | null | null | //
// AppDelegate.h
// JCCategoryKit
//
// Created by JackeyChen1015 on 2019/5/1.
// Copyright © 2019 JackeyChen1015. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 16.111111 | 60 | 0.72069 |
6dce38df65142a5b67b4ed3edcbc41b4aa5655c0 | 888 | h | C | src/CANopen/OD/OD.h | DanielMartensson/Easy-CANopen | fccd98dfe59edc61ca87373eb5216374130c6812 | [
"MIT"
] | 7 | 2021-10-16T23:29:52.000Z | 2022-03-11T02:26:09.000Z | src/CANopen/OD/OD.h | DanielMartensson/Easy-CANopen | fccd98dfe59edc61ca87373eb5216374130c6812 | [
"MIT"
] | 1 | 2022-03-15T20:57:31.000Z | 2022-03-15T22:26:29.000Z | src/CANopen/OD/OD.h | DanielMartensson/Easy-CANopen | fccd98dfe59edc61ca87373eb5216374130c6812 | [
"MIT"
] | 8 | 2021-11-03T11:19:25.000Z | 2022-03-31T14:08:32.000Z | /*
* DO.h
*
* Created on: 14 okt. 2021
* Author: Danie Mårtensson
*/
#ifndef CANOPEN_OD_OD_H_
#define CANOPEN_OD_OD_H_
#include "../../Easy_CANopen/Easy_CANopen_Structs.h"
OD_DATA_TYPE CANopen_OD_Get_Data_Type(CANopen *canopen, uint16_t index, uint8_t sub_index);
uint32_t CANopen_OD_Get_Byte_Size(CANopen *canopen, uint16_t index, uint8_t sub_index);
uint8_t *CANopen_OD_Get_Byte_Pointer(CANopen *canopen, uint16_t index, uint8_t sub_index);
uint32_t CANopen_OD_Get_Value(CANopen *canopen, uint16_t index, uint8_t sub_index);
OD_STATUS CANopen_OD_Set_Value(CANopen *canopen, uint16_t index, uint8_t sub_index, uint32_t value);
OD_STATUS CANopen_OD_Bank(CANopen *canopen, uint16_t index, uint8_t sub_index, bool set, uint32_t *value, uint32_t *byte_size, OD_DATA_TYPE *data_type, uint8_t *byte_pointer, OD_ACCESS *access);
#endif /* CANOPEN_OD_OD_H_ */
| 42.285714 | 195 | 0.780405 |
a35cecf73dbce97a548c6745dd39aa6b1458b8c5 | 51,621 | c | C | testsuite/EXP_1/test205.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 34 | 2017-07-04T14:16:12.000Z | 2021-04-22T21:04:43.000Z | testsuite/EXP_1/test205.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 1 | 2017-07-06T03:43:44.000Z | 2017-07-06T03:43:44.000Z | testsuite/EXP_1/test205.c | ishiura-compiler/CF3 | 0718aa176d0303a4ea8a46bd6c794997cbb8fabb | [
"MIT"
] | 6 | 2017-07-04T16:30:42.000Z | 2019-10-16T05:37:29.000Z |
/*
CF3
Copyright (c) 2015 ishiura-lab.
Released under the MIT license.
https://github.com/ishiura-compiler/CF3/MIT-LICENSE.md
*/
#include<stdio.h>
#include<stdint.h>
#include<stdlib.h>
#include"test1.h"
int8_t x2 = INT8_MIN;
uint64_t x3 = 179172782128LLU;
static int8_t x9 = INT8_MIN;
int32_t x14 = INT32_MAX;
static int16_t x29 = INT16_MIN;
static int8_t x30 = 1;
static int16_t x50 = INT16_MIN;
volatile uint64_t x51 = UINT64_MAX;
uint16_t x52 = 0U;
volatile int32_t t9 = -246923481;
int64_t x56 = -1LL;
uint64_t x58 = UINT64_MAX;
static uint32_t x64 = 0U;
volatile int32_t t12 = 88197;
int8_t x68 = INT8_MIN;
static uint8_t x72 = 1U;
volatile int32_t t15 = 8;
int16_t x82 = INT16_MAX;
int32_t x87 = -1;
int64_t x96 = 293262530172LL;
volatile int16_t x98 = -1;
int16_t x100 = 7791;
static volatile int32_t t20 = 360;
uint8_t x125 = 3U;
uint8_t x127 = UINT8_MAX;
int32_t t25 = 281104;
int32_t x137 = INT32_MIN;
volatile int16_t x140 = INT16_MIN;
volatile int32_t t28 = 3756609;
static int32_t x154 = INT32_MIN;
volatile int64_t x155 = -1600LL;
static int64_t x156 = -1LL;
uint64_t x159 = 8047531809873LLU;
int64_t x174 = 2598801032LL;
volatile int32_t x181 = -2;
static volatile int64_t x183 = 3750LL;
int32_t x184 = INT32_MIN;
static int32_t x190 = -1;
int32_t t37 = 0;
int64_t x193 = -1LL;
int8_t x197 = INT8_MIN;
uint32_t x198 = UINT32_MAX;
static uint16_t x200 = UINT16_MAX;
int32_t x203 = -1;
int64_t x210 = INT64_MIN;
volatile int8_t x212 = INT8_MAX;
volatile int32_t t44 = 57675101;
int64_t x221 = -8843117LL;
uint32_t x225 = 679U;
int64_t x233 = -230296545785LL;
volatile int32_t t47 = -186090492;
uint64_t x255 = 3815771406565151429LLU;
int32_t t50 = -1;
int32_t x262 = INT32_MAX;
int64_t x265 = -1LL;
int8_t x270 = -1;
static volatile int16_t x273 = -1;
uint16_t x278 = 8355U;
uint16_t x279 = 118U;
int32_t t56 = 245541309;
int64_t x282 = INT64_MIN;
static int8_t x283 = INT8_MIN;
int8_t x289 = INT8_MIN;
static int16_t x291 = INT16_MAX;
static uint16_t x292 = 2U;
int32_t t59 = 6;
int32_t x296 = -1;
int16_t x297 = INT16_MIN;
int64_t x307 = 44LL;
volatile uint8_t x316 = 10U;
int16_t x317 = -1;
static volatile int32_t t64 = 437490;
int16_t x324 = 22;
int8_t x343 = INT8_MIN;
int16_t x344 = INT16_MIN;
int32_t t70 = 5;
int32_t t71 = -12451;
uint64_t x351 = 128LLU;
int32_t t72 = -448908;
int16_t x353 = -1;
uint64_t x359 = 148LLU;
static volatile int32_t t74 = 167668;
volatile int16_t x364 = -1;
volatile int32_t x371 = -15774;
uint8_t x373 = 2U;
int64_t x380 = -1LL;
int8_t x381 = INT8_MIN;
uint8_t x382 = 55U;
int16_t x385 = INT16_MIN;
static uint64_t x388 = 35017065111245644LLU;
int8_t x393 = 0;
static int32_t t83 = 25869;
uint8_t x397 = 117U;
int16_t x401 = INT16_MIN;
static int16_t x413 = INT16_MAX;
int32_t x414 = 926903;
uint8_t x415 = 118U;
int32_t x418 = INT32_MIN;
volatile uint8_t x420 = UINT8_MAX;
static uint16_t x421 = 3U;
int16_t x424 = -1;
int32_t x439 = 163035;
uint16_t x441 = 3U;
volatile uint16_t x452 = 1U;
int64_t x455 = INT64_MIN;
int8_t x456 = 3;
uint16_t x461 = 1491U;
uint32_t x462 = UINT32_MAX;
int16_t x463 = -1;
static volatile int32_t t99 = 131028;
uint64_t x477 = UINT64_MAX;
volatile int32_t t101 = -1000;
static volatile int32_t t102 = -196547637;
static int8_t x497 = INT8_MIN;
uint64_t x500 = 35530222615LLU;
int64_t x504 = -105412367LL;
volatile int32_t t105 = 26;
int32_t x515 = 94465;
volatile int32_t t110 = 4168290;
int64_t x534 = -29298876396938915LL;
static int8_t x537 = 0;
uint64_t x538 = UINT64_MAX;
static volatile uint8_t x539 = 10U;
uint32_t x547 = UINT32_MAX;
static int16_t x550 = 2829;
int16_t x562 = -159;
int16_t x564 = -1;
volatile int32_t t117 = -128380368;
static volatile int32_t t119 = 94491449;
int8_t x575 = -2;
uint64_t x580 = 2LLU;
int32_t t121 = -115790;
int32_t t123 = 1962618;
int64_t x589 = -2188747920853872138LL;
uint32_t x603 = 21U;
volatile int32_t t126 = 30;
int32_t t127 = 1;
volatile int16_t x612 = 3;
static volatile int64_t x617 = -47133LL;
static uint16_t x619 = UINT16_MAX;
volatile int32_t t130 = -44519;
uint64_t x624 = 643887933263997LLU;
int32_t t131 = -1655;
volatile uint8_t x635 = 9U;
static int32_t x636 = 342215;
int16_t x644 = INT16_MAX;
volatile uint8_t x651 = UINT8_MAX;
uint32_t x658 = 4182U;
int32_t t138 = -224;
int16_t x661 = INT16_MIN;
volatile uint32_t x663 = UINT32_MAX;
int32_t t143 = 467;
static volatile int32_t x692 = INT32_MIN;
int8_t x695 = 3;
static int8_t x696 = INT8_MIN;
int32_t x701 = INT32_MIN;
int8_t x703 = 10;
int8_t x724 = INT8_MIN;
uint64_t x735 = UINT64_MAX;
int16_t x738 = -7;
int32_t x740 = -1;
volatile uint64_t x751 = UINT64_MAX;
uint64_t x754 = 3279611906967167LLU;
int32_t x755 = -149516287;
static int32_t t157 = 1;
int8_t x771 = INT8_MIN;
int32_t t160 = 220;
int32_t t162 = 46656;
static int32_t x794 = INT32_MIN;
static volatile int32_t x795 = -1;
uint32_t x801 = 0U;
int8_t x803 = 2;
volatile int16_t x804 = INT16_MIN;
int32_t t165 = -427274;
uint8_t x806 = UINT8_MAX;
int8_t x812 = 1;
int32_t t167 = 58;
int64_t x818 = -1LL;
int8_t x821 = INT8_MIN;
static volatile int32_t t171 = 157170;
uint32_t x834 = 322795U;
uint8_t x835 = 13U;
int32_t x836 = INT32_MIN;
static uint16_t x839 = 9241U;
int32_t t174 = 36588152;
static uint64_t x842 = 39623196778129660LLU;
static uint32_t x843 = 3042465U;
int32_t x847 = -1;
int32_t t179 = -143;
int16_t x884 = INT16_MAX;
int32_t x890 = INT32_MIN;
int32_t x895 = -28830;
static int16_t x897 = -52;
static int32_t x900 = -33975431;
volatile int16_t x906 = 12;
static int32_t x908 = -1;
uint8_t x916 = UINT8_MAX;
int32_t x919 = INT32_MIN;
int16_t x923 = INT16_MIN;
int32_t x929 = INT32_MIN;
uint16_t x934 = 4144U;
int16_t x938 = -1;
static int8_t x940 = 0;
int32_t t193 = 359038045;
uint64_t x942 = UINT64_MAX;
uint16_t x944 = UINT16_MAX;
uint8_t x947 = 1U;
static uint64_t x960 = UINT64_MAX;
static int64_t x962 = -7626730299LL;
volatile int32_t t199 = 51572693;
void f0(void) {
uint16_t x1 = UINT16_MAX;
volatile int16_t x4 = -265;
static int32_t t0 = -94205;
t0 = (((x1-x2)+x3)>x4);
if (t0 != 0) { NG(); } else { ; }
}
void f1(void) {
uint8_t x10 = 30U;
int16_t x11 = -1;
int16_t x12 = -1;
volatile int32_t t1 = 630485;
t1 = (((x9-x10)+x11)>x12);
if (t1 != 0) { NG(); } else { ; }
}
void f2(void) {
uint64_t x13 = 123120840816LLU;
volatile uint32_t x15 = UINT32_MAX;
int32_t x16 = -105139624;
volatile int32_t t2 = 12843327;
t2 = (((x13-x14)+x15)>x16);
if (t2 != 0) { NG(); } else { ; }
}
void f3(void) {
uint32_t x17 = UINT32_MAX;
static volatile uint32_t x18 = UINT32_MAX;
int8_t x19 = -1;
int16_t x20 = INT16_MIN;
int32_t t3 = 7;
t3 = (((x17-x18)+x19)>x20);
if (t3 != 1) { NG(); } else { ; }
}
void f4(void) {
static int8_t x25 = -1;
volatile int16_t x26 = -1;
int8_t x27 = -1;
uint16_t x28 = UINT16_MAX;
volatile int32_t t4 = 242410694;
t4 = (((x25-x26)+x27)>x28);
if (t4 != 0) { NG(); } else { ; }
}
void f5(void) {
uint32_t x31 = UINT32_MAX;
int32_t x32 = INT32_MIN;
int32_t t5 = 61;
t5 = (((x29-x30)+x31)>x32);
if (t5 != 1) { NG(); } else { ; }
}
void f6(void) {
int16_t x37 = INT16_MIN;
int16_t x38 = INT16_MIN;
static int32_t x39 = INT32_MAX;
volatile uint8_t x40 = 10U;
int32_t t6 = 44067237;
t6 = (((x37-x38)+x39)>x40);
if (t6 != 1) { NG(); } else { ; }
}
void f7(void) {
int16_t x41 = INT16_MAX;
volatile int16_t x42 = INT16_MIN;
volatile uint32_t x43 = 10568U;
uint8_t x44 = UINT8_MAX;
int32_t t7 = -56979179;
t7 = (((x41-x42)+x43)>x44);
if (t7 != 1) { NG(); } else { ; }
}
void f8(void) {
volatile uint16_t x45 = 3U;
static int32_t x46 = -14424;
int32_t x47 = INT32_MIN;
int64_t x48 = INT64_MIN;
volatile int32_t t8 = -123546022;
t8 = (((x45-x46)+x47)>x48);
if (t8 != 1) { NG(); } else { ; }
}
void f9(void) {
int16_t x49 = -1;
t9 = (((x49-x50)+x51)>x52);
if (t9 != 1) { NG(); } else { ; }
}
void f10(void) {
static uint64_t x53 = 1948063LLU;
uint64_t x54 = UINT64_MAX;
uint64_t x55 = 1665LLU;
volatile int32_t t10 = 158519;
t10 = (((x53-x54)+x55)>x56);
if (t10 != 0) { NG(); } else { ; }
}
void f11(void) {
static int8_t x57 = -1;
uint16_t x59 = UINT16_MAX;
int8_t x60 = -3;
int32_t t11 = 819334681;
t11 = (((x57-x58)+x59)>x60);
if (t11 != 0) { NG(); } else { ; }
}
void f12(void) {
uint64_t x61 = 16LLU;
uint64_t x62 = 746499965334222688LLU;
int16_t x63 = 101;
t12 = (((x61-x62)+x63)>x64);
if (t12 != 1) { NG(); } else { ; }
}
void f13(void) {
volatile int64_t x65 = -1LL;
static int64_t x66 = INT64_MIN;
int16_t x67 = INT16_MIN;
volatile int32_t t13 = -7831956;
t13 = (((x65-x66)+x67)>x68);
if (t13 != 1) { NG(); } else { ; }
}
void f14(void) {
volatile int64_t x69 = -6998689350481LL;
volatile uint64_t x70 = 812099987700742LLU;
int16_t x71 = INT16_MIN;
int32_t t14 = -12977;
t14 = (((x69-x70)+x71)>x72);
if (t14 != 1) { NG(); } else { ; }
}
void f15(void) {
volatile int32_t x77 = INT32_MAX;
int64_t x78 = INT64_MAX;
uint32_t x79 = 16U;
static int8_t x80 = INT8_MIN;
t15 = (((x77-x78)+x79)>x80);
if (t15 != 0) { NG(); } else { ; }
}
void f16(void) {
int8_t x81 = -3;
int32_t x83 = -1;
uint32_t x84 = UINT32_MAX;
int32_t t16 = 2;
t16 = (((x81-x82)+x83)>x84);
if (t16 != 0) { NG(); } else { ; }
}
void f17(void) {
int16_t x85 = -228;
volatile int64_t x86 = 490LL;
static volatile int8_t x88 = INT8_MIN;
volatile int32_t t17 = -1052199505;
t17 = (((x85-x86)+x87)>x88);
if (t17 != 0) { NG(); } else { ; }
}
void f18(void) {
static int32_t x93 = INT32_MAX;
static int8_t x94 = INT8_MAX;
uint32_t x95 = 2031896309U;
int32_t t18 = -129909;
t18 = (((x93-x94)+x95)>x96);
if (t18 != 0) { NG(); } else { ; }
}
void f19(void) {
int32_t x97 = -3021627;
static int64_t x99 = INT64_MAX;
static int32_t t19 = -15608959;
t19 = (((x97-x98)+x99)>x100);
if (t19 != 1) { NG(); } else { ; }
}
void f20(void) {
volatile uint32_t x105 = 65104U;
int64_t x106 = -54798983294453213LL;
int64_t x107 = INT64_MIN;
int32_t x108 = INT32_MIN;
t20 = (((x105-x106)+x107)>x108);
if (t20 != 0) { NG(); } else { ; }
}
void f21(void) {
static uint64_t x109 = 1681111084832LLU;
static int16_t x110 = 2287;
int32_t x111 = INT32_MIN;
uint32_t x112 = UINT32_MAX;
static volatile int32_t t21 = -7005;
t21 = (((x109-x110)+x111)>x112);
if (t21 != 1) { NG(); } else { ; }
}
void f22(void) {
uint8_t x113 = UINT8_MAX;
uint32_t x114 = 301U;
int64_t x115 = 263049423088736LL;
static uint64_t x116 = 570LLU;
int32_t t22 = 23;
t22 = (((x113-x114)+x115)>x116);
if (t22 != 1) { NG(); } else { ; }
}
void f23(void) {
static uint16_t x117 = UINT16_MAX;
static uint32_t x118 = 7013U;
static int32_t x119 = INT32_MIN;
static int16_t x120 = 2192;
static volatile int32_t t23 = -478014232;
t23 = (((x117-x118)+x119)>x120);
if (t23 != 1) { NG(); } else { ; }
}
void f24(void) {
int16_t x126 = INT16_MAX;
int8_t x128 = -1;
static volatile int32_t t24 = -1;
t24 = (((x125-x126)+x127)>x128);
if (t24 != 0) { NG(); } else { ; }
}
void f25(void) {
static int64_t x133 = -1LL;
volatile int8_t x134 = INT8_MAX;
volatile int32_t x135 = -1;
int8_t x136 = INT8_MAX;
t25 = (((x133-x134)+x135)>x136);
if (t25 != 0) { NG(); } else { ; }
}
void f26(void) {
static uint32_t x138 = UINT32_MAX;
static int8_t x139 = 27;
volatile int32_t t26 = 29489455;
t26 = (((x137-x138)+x139)>x140);
if (t26 != 0) { NG(); } else { ; }
}
void f27(void) {
static int8_t x141 = -1;
int16_t x142 = INT16_MAX;
int32_t x143 = 210996153;
static int8_t x144 = -61;
int32_t t27 = -1354;
t27 = (((x141-x142)+x143)>x144);
if (t27 != 1) { NG(); } else { ; }
}
void f28(void) {
int32_t x149 = -1;
int16_t x150 = 217;
static int16_t x151 = INT16_MIN;
uint64_t x152 = 43LLU;
t28 = (((x149-x150)+x151)>x152);
if (t28 != 1) { NG(); } else { ; }
}
void f29(void) {
int64_t x153 = -1LL;
static volatile int32_t t29 = -32657716;
t29 = (((x153-x154)+x155)>x156);
if (t29 != 1) { NG(); } else { ; }
}
void f30(void) {
int32_t x157 = INT32_MAX;
uint16_t x158 = 8U;
static int16_t x160 = INT16_MIN;
int32_t t30 = -4056616;
t30 = (((x157-x158)+x159)>x160);
if (t30 != 0) { NG(); } else { ; }
}
void f31(void) {
int32_t x161 = -21983;
int8_t x162 = 2;
uint64_t x163 = UINT64_MAX;
static volatile int16_t x164 = INT16_MAX;
int32_t t31 = 770376151;
t31 = (((x161-x162)+x163)>x164);
if (t31 != 1) { NG(); } else { ; }
}
void f32(void) {
int16_t x165 = 2771;
static int16_t x166 = INT16_MAX;
static uint64_t x167 = 55228643LLU;
int64_t x168 = INT64_MAX;
int32_t t32 = 104859;
t32 = (((x165-x166)+x167)>x168);
if (t32 != 0) { NG(); } else { ; }
}
void f33(void) {
volatile uint16_t x169 = 9U;
uint16_t x170 = 92U;
int8_t x171 = 0;
int16_t x172 = 0;
static int32_t t33 = -5921131;
t33 = (((x169-x170)+x171)>x172);
if (t33 != 0) { NG(); } else { ; }
}
void f34(void) {
uint64_t x173 = 9313178593LLU;
int64_t x175 = 55426136441LL;
int16_t x176 = INT16_MIN;
volatile int32_t t34 = -333608005;
t34 = (((x173-x174)+x175)>x176);
if (t34 != 0) { NG(); } else { ; }
}
void f35(void) {
int8_t x177 = INT8_MAX;
uint8_t x178 = 117U;
volatile int32_t x179 = -424166182;
uint8_t x180 = UINT8_MAX;
int32_t t35 = 9;
t35 = (((x177-x178)+x179)>x180);
if (t35 != 0) { NG(); } else { ; }
}
void f36(void) {
int32_t x182 = 96;
static volatile int32_t t36 = 273;
t36 = (((x181-x182)+x183)>x184);
if (t36 != 1) { NG(); } else { ; }
}
void f37(void) {
int32_t x189 = 9661;
uint32_t x191 = UINT32_MAX;
int64_t x192 = 489064790281171LL;
t37 = (((x189-x190)+x191)>x192);
if (t37 != 0) { NG(); } else { ; }
}
void f38(void) {
volatile uint8_t x194 = UINT8_MAX;
int8_t x195 = INT8_MIN;
static uint16_t x196 = 14999U;
int32_t t38 = 5604677;
t38 = (((x193-x194)+x195)>x196);
if (t38 != 0) { NG(); } else { ; }
}
void f39(void) {
volatile int16_t x199 = INT16_MAX;
int32_t t39 = 790780923;
t39 = (((x197-x198)+x199)>x200);
if (t39 != 0) { NG(); } else { ; }
}
void f40(void) {
int32_t x201 = INT32_MAX;
volatile uint64_t x202 = 29508LLU;
uint32_t x204 = UINT32_MAX;
volatile int32_t t40 = 715795;
t40 = (((x201-x202)+x203)>x204);
if (t40 != 0) { NG(); } else { ; }
}
void f41(void) {
int8_t x205 = -56;
int64_t x206 = INT64_MIN;
static uint8_t x207 = 6U;
uint64_t x208 = 18610436534LLU;
int32_t t41 = 153;
t41 = (((x205-x206)+x207)>x208);
if (t41 != 1) { NG(); } else { ; }
}
void f42(void) {
int32_t x209 = INT32_MIN;
int32_t x211 = -1;
int32_t t42 = 70;
t42 = (((x209-x210)+x211)>x212);
if (t42 != 1) { NG(); } else { ; }
}
void f43(void) {
volatile int8_t x213 = INT8_MAX;
static int64_t x214 = -1LL;
int8_t x215 = INT8_MAX;
uint64_t x216 = 439912612527991LLU;
volatile int32_t t43 = 510;
t43 = (((x213-x214)+x215)>x216);
if (t43 != 0) { NG(); } else { ; }
}
void f44(void) {
static int8_t x217 = INT8_MIN;
int64_t x218 = -1LL;
int16_t x219 = 482;
volatile int64_t x220 = INT64_MAX;
t44 = (((x217-x218)+x219)>x220);
if (t44 != 0) { NG(); } else { ; }
}
void f45(void) {
int32_t x222 = INT32_MIN;
int8_t x223 = 47;
static volatile int8_t x224 = -48;
volatile int32_t t45 = -30;
t45 = (((x221-x222)+x223)>x224);
if (t45 != 1) { NG(); } else { ; }
}
void f46(void) {
int64_t x226 = -3869689LL;
static volatile int16_t x227 = -1;
int16_t x228 = 16277;
volatile int32_t t46 = 186900709;
t46 = (((x225-x226)+x227)>x228);
if (t46 != 1) { NG(); } else { ; }
}
void f47(void) {
volatile uint32_t x234 = 4U;
static int8_t x235 = -1;
uint64_t x236 = 61441197836597377LLU;
t47 = (((x233-x234)+x235)>x236);
if (t47 != 1) { NG(); } else { ; }
}
void f48(void) {
int16_t x241 = INT16_MIN;
int64_t x242 = INT64_MIN;
int16_t x243 = -3871;
int64_t x244 = 483620745974772483LL;
static volatile int32_t t48 = -54377;
t48 = (((x241-x242)+x243)>x244);
if (t48 != 1) { NG(); } else { ; }
}
void f49(void) {
static int16_t x249 = -594;
uint64_t x250 = 4230360806537LLU;
uint32_t x251 = 6U;
int16_t x252 = INT16_MAX;
volatile int32_t t49 = -60908;
t49 = (((x249-x250)+x251)>x252);
if (t49 != 1) { NG(); } else { ; }
}
void f50(void) {
int64_t x253 = -1LL;
volatile uint8_t x254 = 4U;
static uint32_t x256 = UINT32_MAX;
t50 = (((x253-x254)+x255)>x256);
if (t50 != 1) { NG(); } else { ; }
}
void f51(void) {
uint32_t x257 = UINT32_MAX;
static int8_t x258 = -1;
int16_t x259 = -7324;
int16_t x260 = 1;
volatile int32_t t51 = -2155025;
t51 = (((x257-x258)+x259)>x260);
if (t51 != 1) { NG(); } else { ; }
}
void f52(void) {
uint8_t x261 = UINT8_MAX;
uint16_t x263 = UINT16_MAX;
volatile int8_t x264 = INT8_MIN;
static volatile int32_t t52 = 740361849;
t52 = (((x261-x262)+x263)>x264);
if (t52 != 0) { NG(); } else { ; }
}
void f53(void) {
int32_t x266 = -28124225;
static uint64_t x267 = UINT64_MAX;
int64_t x268 = 3781876034LL;
int32_t t53 = 5221794;
t53 = (((x265-x266)+x267)>x268);
if (t53 != 0) { NG(); } else { ; }
}
void f54(void) {
volatile int16_t x269 = INT16_MAX;
static int32_t x271 = -1;
static int16_t x272 = INT16_MIN;
int32_t t54 = -89327076;
t54 = (((x269-x270)+x271)>x272);
if (t54 != 1) { NG(); } else { ; }
}
void f55(void) {
uint16_t x274 = 2374U;
uint32_t x275 = UINT32_MAX;
volatile uint8_t x276 = 120U;
volatile int32_t t55 = -1442275;
t55 = (((x273-x274)+x275)>x276);
if (t55 != 1) { NG(); } else { ; }
}
void f56(void) {
volatile int64_t x277 = -1LL;
int8_t x280 = 1;
t56 = (((x277-x278)+x279)>x280);
if (t56 != 0) { NG(); } else { ; }
}
void f57(void) {
int8_t x281 = INT8_MIN;
int32_t x284 = -1;
static int32_t t57 = -156;
t57 = (((x281-x282)+x283)>x284);
if (t57 != 1) { NG(); } else { ; }
}
void f58(void) {
int8_t x285 = INT8_MIN;
int8_t x286 = -1;
int32_t x287 = 519;
volatile int16_t x288 = INT16_MIN;
volatile int32_t t58 = -352483;
t58 = (((x285-x286)+x287)>x288);
if (t58 != 1) { NG(); } else { ; }
}
void f59(void) {
static uint64_t x290 = 469612LLU;
t59 = (((x289-x290)+x291)>x292);
if (t59 != 1) { NG(); } else { ; }
}
void f60(void) {
int64_t x293 = -1LL;
static uint8_t x294 = UINT8_MAX;
uint64_t x295 = 56682148LLU;
volatile int32_t t60 = -106433;
t60 = (((x293-x294)+x295)>x296);
if (t60 != 0) { NG(); } else { ; }
}
void f61(void) {
static int8_t x298 = -3;
volatile uint8_t x299 = 0U;
int32_t x300 = -1;
volatile int32_t t61 = 18521638;
t61 = (((x297-x298)+x299)>x300);
if (t61 != 0) { NG(); } else { ; }
}
void f62(void) {
volatile int16_t x305 = 735;
static int8_t x306 = -1;
int64_t x308 = 6602488LL;
int32_t t62 = -12;
t62 = (((x305-x306)+x307)>x308);
if (t62 != 0) { NG(); } else { ; }
}
void f63(void) {
int64_t x313 = -1LL;
int8_t x314 = -1;
static uint64_t x315 = UINT64_MAX;
int32_t t63 = -206832833;
t63 = (((x313-x314)+x315)>x316);
if (t63 != 1) { NG(); } else { ; }
}
void f64(void) {
int16_t x318 = INT16_MAX;
int8_t x319 = 10;
static volatile int8_t x320 = INT8_MIN;
t64 = (((x317-x318)+x319)>x320);
if (t64 != 0) { NG(); } else { ; }
}
void f65(void) {
int16_t x321 = -3;
int16_t x322 = INT16_MIN;
static uint8_t x323 = 9U;
int32_t t65 = 42;
t65 = (((x321-x322)+x323)>x324);
if (t65 != 1) { NG(); } else { ; }
}
void f66(void) {
int16_t x325 = -1;
int32_t x326 = 4929;
volatile uint32_t x327 = 32U;
volatile uint64_t x328 = 102908400601275LLU;
int32_t t66 = 4808;
t66 = (((x325-x326)+x327)>x328);
if (t66 != 0) { NG(); } else { ; }
}
void f67(void) {
int64_t x329 = INT64_MAX;
volatile int8_t x330 = 0;
static volatile int16_t x331 = INT16_MIN;
volatile uint64_t x332 = 266771277947967838LLU;
volatile int32_t t67 = -6576;
t67 = (((x329-x330)+x331)>x332);
if (t67 != 1) { NG(); } else { ; }
}
void f68(void) {
int8_t x333 = INT8_MIN;
int8_t x334 = -23;
volatile int64_t x335 = INT64_MAX;
uint64_t x336 = UINT64_MAX;
int32_t t68 = -1869;
t68 = (((x333-x334)+x335)>x336);
if (t68 != 0) { NG(); } else { ; }
}
void f69(void) {
uint16_t x337 = 23U;
volatile int32_t x338 = 1;
volatile int64_t x339 = INT64_MIN;
volatile int64_t x340 = -1LL;
int32_t t69 = 40162937;
t69 = (((x337-x338)+x339)>x340);
if (t69 != 0) { NG(); } else { ; }
}
void f70(void) {
uint32_t x341 = UINT32_MAX;
static volatile uint16_t x342 = 222U;
t70 = (((x341-x342)+x343)>x344);
if (t70 != 1) { NG(); } else { ; }
}
void f71(void) {
uint32_t x345 = 3U;
static uint8_t x346 = UINT8_MAX;
static int64_t x347 = -11465252401738228LL;
volatile int32_t x348 = INT32_MIN;
t71 = (((x345-x346)+x347)>x348);
if (t71 != 0) { NG(); } else { ; }
}
void f72(void) {
static uint32_t x349 = 22949808U;
int32_t x350 = 1369;
volatile uint32_t x352 = UINT32_MAX;
t72 = (((x349-x350)+x351)>x352);
if (t72 != 0) { NG(); } else { ; }
}
void f73(void) {
uint8_t x354 = 3U;
uint32_t x355 = UINT32_MAX;
uint64_t x356 = 0LLU;
int32_t t73 = 14679480;
t73 = (((x353-x354)+x355)>x356);
if (t73 != 1) { NG(); } else { ; }
}
void f74(void) {
volatile int64_t x357 = -1LL;
uint32_t x358 = 4334704U;
uint64_t x360 = UINT64_MAX;
t74 = (((x357-x358)+x359)>x360);
if (t74 != 0) { NG(); } else { ; }
}
void f75(void) {
static volatile int8_t x361 = -6;
uint8_t x362 = UINT8_MAX;
int8_t x363 = INT8_MIN;
static int32_t t75 = -18064198;
t75 = (((x361-x362)+x363)>x364);
if (t75 != 0) { NG(); } else { ; }
}
void f76(void) {
int16_t x365 = INT16_MIN;
int16_t x366 = INT16_MAX;
static int8_t x367 = -1;
volatile int64_t x368 = INT64_MIN;
int32_t t76 = 89545681;
t76 = (((x365-x366)+x367)>x368);
if (t76 != 1) { NG(); } else { ; }
}
void f77(void) {
int32_t x369 = INT32_MIN;
volatile int64_t x370 = INT64_MIN;
static int16_t x372 = INT16_MIN;
static volatile int32_t t77 = -1604;
t77 = (((x369-x370)+x371)>x372);
if (t77 != 1) { NG(); } else { ; }
}
void f78(void) {
uint16_t x374 = 26U;
static int64_t x375 = 14LL;
uint8_t x376 = 18U;
int32_t t78 = 1799498;
t78 = (((x373-x374)+x375)>x376);
if (t78 != 0) { NG(); } else { ; }
}
void f79(void) {
uint32_t x377 = UINT32_MAX;
volatile int32_t x378 = INT32_MIN;
static volatile int16_t x379 = -7;
int32_t t79 = -371304173;
t79 = (((x377-x378)+x379)>x380);
if (t79 != 1) { NG(); } else { ; }
}
void f80(void) {
int16_t x383 = -1;
int16_t x384 = INT16_MIN;
int32_t t80 = -56;
t80 = (((x381-x382)+x383)>x384);
if (t80 != 1) { NG(); } else { ; }
}
void f81(void) {
volatile int8_t x386 = INT8_MAX;
static int16_t x387 = INT16_MAX;
volatile int32_t t81 = -882697212;
t81 = (((x385-x386)+x387)>x388);
if (t81 != 1) { NG(); } else { ; }
}
void f82(void) {
static int8_t x389 = -24;
int64_t x390 = 497737263LL;
uint16_t x391 = UINT16_MAX;
uint8_t x392 = 109U;
int32_t t82 = 0;
t82 = (((x389-x390)+x391)>x392);
if (t82 != 0) { NG(); } else { ; }
}
void f83(void) {
int16_t x394 = -1918;
uint8_t x395 = 13U;
static int64_t x396 = 12LL;
t83 = (((x393-x394)+x395)>x396);
if (t83 != 1) { NG(); } else { ; }
}
void f84(void) {
int64_t x398 = INT64_MAX;
uint32_t x399 = 328U;
int32_t x400 = -35654;
int32_t t84 = -220309539;
t84 = (((x397-x398)+x399)>x400);
if (t84 != 0) { NG(); } else { ; }
}
void f85(void) {
int8_t x402 = -1;
uint64_t x403 = UINT64_MAX;
static int16_t x404 = INT16_MIN;
volatile int32_t t85 = -2105;
t85 = (((x401-x402)+x403)>x404);
if (t85 != 0) { NG(); } else { ; }
}
void f86(void) {
int8_t x409 = INT8_MIN;
static uint32_t x410 = UINT32_MAX;
int32_t x411 = -1;
int8_t x412 = INT8_MAX;
static int32_t t86 = 2239499;
t86 = (((x409-x410)+x411)>x412);
if (t86 != 1) { NG(); } else { ; }
}
void f87(void) {
static int8_t x416 = -1;
int32_t t87 = 23671694;
t87 = (((x413-x414)+x415)>x416);
if (t87 != 0) { NG(); } else { ; }
}
void f88(void) {
int32_t x417 = -1;
int8_t x419 = -7;
volatile int32_t t88 = -6;
t88 = (((x417-x418)+x419)>x420);
if (t88 != 1) { NG(); } else { ; }
}
void f89(void) {
static int16_t x422 = -1;
volatile int8_t x423 = -1;
volatile int32_t t89 = 1143774;
t89 = (((x421-x422)+x423)>x424);
if (t89 != 1) { NG(); } else { ; }
}
void f90(void) {
int32_t x425 = 555;
static int32_t x426 = -1;
int8_t x427 = -1;
uint32_t x428 = UINT32_MAX;
volatile int32_t t90 = 10433;
t90 = (((x425-x426)+x427)>x428);
if (t90 != 0) { NG(); } else { ; }
}
void f91(void) {
int8_t x433 = -1;
static int16_t x434 = 823;
volatile uint16_t x435 = 24736U;
uint32_t x436 = 2338U;
static volatile int32_t t91 = -5030553;
t91 = (((x433-x434)+x435)>x436);
if (t91 != 1) { NG(); } else { ; }
}
void f92(void) {
int16_t x437 = -1;
int16_t x438 = INT16_MIN;
int8_t x440 = 11;
int32_t t92 = -94;
t92 = (((x437-x438)+x439)>x440);
if (t92 != 1) { NG(); } else { ; }
}
void f93(void) {
int32_t x442 = -1;
int16_t x443 = INT16_MAX;
int32_t x444 = -1;
static volatile int32_t t93 = 344;
t93 = (((x441-x442)+x443)>x444);
if (t93 != 1) { NG(); } else { ; }
}
void f94(void) {
volatile int8_t x449 = INT8_MIN;
int64_t x450 = 673LL;
int16_t x451 = 0;
volatile int32_t t94 = 1344732;
t94 = (((x449-x450)+x451)>x452);
if (t94 != 0) { NG(); } else { ; }
}
void f95(void) {
static int32_t x453 = INT32_MIN;
static int64_t x454 = INT64_MIN;
volatile int32_t t95 = 1;
t95 = (((x453-x454)+x455)>x456);
if (t95 != 0) { NG(); } else { ; }
}
void f96(void) {
uint16_t x457 = UINT16_MAX;
uint32_t x458 = UINT32_MAX;
uint64_t x459 = 143668067451287LLU;
int32_t x460 = INT32_MAX;
int32_t t96 = -64;
t96 = (((x457-x458)+x459)>x460);
if (t96 != 1) { NG(); } else { ; }
}
void f97(void) {
static int8_t x464 = INT8_MIN;
volatile int32_t t97 = 833884;
t97 = (((x461-x462)+x463)>x464);
if (t97 != 0) { NG(); } else { ; }
}
void f98(void) {
int64_t x465 = -1LL;
uint64_t x466 = 844217353726057187LLU;
volatile int8_t x467 = -1;
static uint16_t x468 = UINT16_MAX;
volatile int32_t t98 = 0;
t98 = (((x465-x466)+x467)>x468);
if (t98 != 1) { NG(); } else { ; }
}
void f99(void) {
volatile int32_t x469 = -1;
int64_t x470 = INT64_MIN;
volatile int8_t x471 = -1;
static volatile int32_t x472 = 4173527;
t99 = (((x469-x470)+x471)>x472);
if (t99 != 1) { NG(); } else { ; }
}
void f100(void) {
int8_t x478 = INT8_MAX;
uint32_t x479 = 1902808483U;
int8_t x480 = INT8_MIN;
int32_t t100 = 102573;
t100 = (((x477-x478)+x479)>x480);
if (t100 != 0) { NG(); } else { ; }
}
void f101(void) {
int32_t x489 = INT32_MIN;
volatile int32_t x490 = INT32_MIN;
int16_t x491 = 14563;
static int16_t x492 = INT16_MIN;
t101 = (((x489-x490)+x491)>x492);
if (t101 != 1) { NG(); } else { ; }
}
void f102(void) {
uint32_t x493 = UINT32_MAX;
int32_t x494 = 379;
uint16_t x495 = UINT16_MAX;
int32_t x496 = INT32_MAX;
t102 = (((x493-x494)+x495)>x496);
if (t102 != 0) { NG(); } else { ; }
}
void f103(void) {
uint32_t x498 = 15U;
uint16_t x499 = UINT16_MAX;
int32_t t103 = -263212015;
t103 = (((x497-x498)+x499)>x500);
if (t103 != 0) { NG(); } else { ; }
}
void f104(void) {
uint32_t x501 = 21977138U;
volatile int32_t x502 = -13;
uint64_t x503 = UINT64_MAX;
static int32_t t104 = 1;
t104 = (((x501-x502)+x503)>x504);
if (t104 != 0) { NG(); } else { ; }
}
void f105(void) {
int32_t x509 = -171868307;
uint64_t x510 = 65728LLU;
int8_t x511 = INT8_MIN;
static int64_t x512 = -119280441461390LL;
t105 = (((x509-x510)+x511)>x512);
if (t105 != 1) { NG(); } else { ; }
}
void f106(void) {
uint32_t x513 = 3512790U;
int8_t x514 = INT8_MIN;
int8_t x516 = INT8_MIN;
volatile int32_t t106 = -2;
t106 = (((x513-x514)+x515)>x516);
if (t106 != 0) { NG(); } else { ; }
}
void f107(void) {
volatile int16_t x517 = INT16_MIN;
volatile uint32_t x518 = 184340U;
int32_t x519 = INT32_MIN;
int8_t x520 = INT8_MAX;
static int32_t t107 = -28;
t107 = (((x517-x518)+x519)>x520);
if (t107 != 1) { NG(); } else { ; }
}
void f108(void) {
volatile int32_t x521 = INT32_MIN;
int16_t x522 = -171;
int8_t x523 = -1;
static uint64_t x524 = 7210932468236048721LLU;
volatile int32_t t108 = -1101;
t108 = (((x521-x522)+x523)>x524);
if (t108 != 1) { NG(); } else { ; }
}
void f109(void) {
int64_t x525 = 239056204265LL;
uint16_t x526 = UINT16_MAX;
int8_t x527 = INT8_MIN;
static int16_t x528 = INT16_MAX;
volatile int32_t t109 = -11726356;
t109 = (((x525-x526)+x527)>x528);
if (t109 != 1) { NG(); } else { ; }
}
void f110(void) {
uint16_t x529 = UINT16_MAX;
uint8_t x530 = 2U;
int16_t x531 = -1;
static int64_t x532 = 493055015LL;
t110 = (((x529-x530)+x531)>x532);
if (t110 != 0) { NG(); } else { ; }
}
void f111(void) {
static volatile int16_t x533 = INT16_MIN;
int64_t x535 = 38843663LL;
volatile uint16_t x536 = 4018U;
int32_t t111 = 14384588;
t111 = (((x533-x534)+x535)>x536);
if (t111 != 1) { NG(); } else { ; }
}
void f112(void) {
int8_t x540 = -51;
volatile int32_t t112 = -60;
t112 = (((x537-x538)+x539)>x540);
if (t112 != 0) { NG(); } else { ; }
}
void f113(void) {
volatile uint8_t x541 = 118U;
int16_t x542 = 3530;
uint8_t x543 = UINT8_MAX;
static volatile int16_t x544 = 205;
static int32_t t113 = -10605;
t113 = (((x541-x542)+x543)>x544);
if (t113 != 0) { NG(); } else { ; }
}
void f114(void) {
int16_t x545 = INT16_MAX;
int8_t x546 = -1;
int64_t x548 = 4LL;
static volatile int32_t t114 = -2958118;
t114 = (((x545-x546)+x547)>x548);
if (t114 != 1) { NG(); } else { ; }
}
void f115(void) {
int64_t x549 = -1LL;
int32_t x551 = -1;
uint64_t x552 = 382038135LLU;
static int32_t t115 = -2148115;
t115 = (((x549-x550)+x551)>x552);
if (t115 != 1) { NG(); } else { ; }
}
void f116(void) {
static int8_t x557 = 7;
volatile int16_t x558 = -1;
int16_t x559 = INT16_MAX;
uint32_t x560 = UINT32_MAX;
int32_t t116 = -121;
t116 = (((x557-x558)+x559)>x560);
if (t116 != 0) { NG(); } else { ; }
}
void f117(void) {
volatile int64_t x561 = 353843823LL;
uint16_t x563 = 166U;
t117 = (((x561-x562)+x563)>x564);
if (t117 != 1) { NG(); } else { ; }
}
void f118(void) {
int8_t x565 = INT8_MAX;
int64_t x566 = INT64_MAX;
uint64_t x567 = 760338LLU;
int16_t x568 = -1;
static int32_t t118 = 1;
t118 = (((x565-x566)+x567)>x568);
if (t118 != 0) { NG(); } else { ; }
}
void f119(void) {
int16_t x569 = -11;
uint64_t x570 = UINT64_MAX;
volatile int8_t x571 = -6;
int8_t x572 = INT8_MAX;
t119 = (((x569-x570)+x571)>x572);
if (t119 != 1) { NG(); } else { ; }
}
void f120(void) {
int32_t x573 = INT32_MIN;
int64_t x574 = 3733502923545396LL;
uint16_t x576 = 27129U;
int32_t t120 = -1014029;
t120 = (((x573-x574)+x575)>x576);
if (t120 != 0) { NG(); } else { ; }
}
void f121(void) {
uint8_t x577 = UINT8_MAX;
volatile uint16_t x578 = UINT16_MAX;
uint64_t x579 = 20842LLU;
t121 = (((x577-x578)+x579)>x580);
if (t121 != 1) { NG(); } else { ; }
}
void f122(void) {
int8_t x581 = INT8_MIN;
int16_t x582 = -1;
uint8_t x583 = 3U;
static int32_t x584 = INT32_MIN;
static volatile int32_t t122 = 6;
t122 = (((x581-x582)+x583)>x584);
if (t122 != 1) { NG(); } else { ; }
}
void f123(void) {
volatile uint16_t x585 = UINT16_MAX;
volatile uint16_t x586 = 63U;
static int64_t x587 = -1LL;
volatile int8_t x588 = -1;
t123 = (((x585-x586)+x587)>x588);
if (t123 != 1) { NG(); } else { ; }
}
void f124(void) {
uint64_t x590 = UINT64_MAX;
int64_t x591 = -1LL;
volatile uint32_t x592 = 12250574U;
int32_t t124 = -2441417;
t124 = (((x589-x590)+x591)>x592);
if (t124 != 1) { NG(); } else { ; }
}
void f125(void) {
int8_t x597 = -1;
uint8_t x598 = UINT8_MAX;
static int8_t x599 = -1;
static int32_t x600 = INT32_MIN;
volatile int32_t t125 = 3;
t125 = (((x597-x598)+x599)>x600);
if (t125 != 1) { NG(); } else { ; }
}
void f126(void) {
int32_t x601 = -1;
uint16_t x602 = UINT16_MAX;
int64_t x604 = -26560468LL;
t126 = (((x601-x602)+x603)>x604);
if (t126 != 1) { NG(); } else { ; }
}
void f127(void) {
static int64_t x605 = INT64_MIN;
int64_t x606 = INT64_MIN;
uint8_t x607 = 46U;
int8_t x608 = INT8_MIN;
t127 = (((x605-x606)+x607)>x608);
if (t127 != 1) { NG(); } else { ; }
}
void f128(void) {
static volatile int8_t x609 = -1;
static volatile uint64_t x610 = 1101524689142LLU;
static int8_t x611 = 53;
static int32_t t128 = -716477;
t128 = (((x609-x610)+x611)>x612);
if (t128 != 1) { NG(); } else { ; }
}
void f129(void) {
uint64_t x613 = 1079408363118LLU;
volatile int8_t x614 = -32;
uint32_t x615 = UINT32_MAX;
int8_t x616 = 3;
volatile int32_t t129 = -89872265;
t129 = (((x613-x614)+x615)>x616);
if (t129 != 1) { NG(); } else { ; }
}
void f130(void) {
volatile uint16_t x618 = 3420U;
uint32_t x620 = UINT32_MAX;
t130 = (((x617-x618)+x619)>x620);
if (t130 != 0) { NG(); } else { ; }
}
void f131(void) {
int8_t x621 = -4;
int64_t x622 = 488845802741LL;
int32_t x623 = -4308626;
t131 = (((x621-x622)+x623)>x624);
if (t131 != 1) { NG(); } else { ; }
}
void f132(void) {
volatile uint16_t x625 = 272U;
static int16_t x626 = INT16_MIN;
uint8_t x627 = 15U;
int16_t x628 = 3;
volatile int32_t t132 = -1541;
t132 = (((x625-x626)+x627)>x628);
if (t132 != 1) { NG(); } else { ; }
}
void f133(void) {
volatile uint64_t x633 = 3520320835195LLU;
int32_t x634 = INT32_MIN;
volatile int32_t t133 = 7173;
t133 = (((x633-x634)+x635)>x636);
if (t133 != 1) { NG(); } else { ; }
}
void f134(void) {
int8_t x637 = -61;
static int8_t x638 = -1;
uint64_t x639 = UINT64_MAX;
uint32_t x640 = 334577075U;
int32_t t134 = -47;
t134 = (((x637-x638)+x639)>x640);
if (t134 != 1) { NG(); } else { ; }
}
void f135(void) {
int32_t x641 = -26;
uint32_t x642 = 1797961U;
uint16_t x643 = 57U;
int32_t t135 = -876868;
t135 = (((x641-x642)+x643)>x644);
if (t135 != 1) { NG(); } else { ; }
}
void f136(void) {
uint64_t x649 = 2054332337550468LLU;
static int16_t x650 = INT16_MAX;
volatile int16_t x652 = 47;
static int32_t t136 = -1864712;
t136 = (((x649-x650)+x651)>x652);
if (t136 != 1) { NG(); } else { ; }
}
void f137(void) {
volatile int64_t x653 = 30179494LL;
int16_t x654 = INT16_MIN;
int8_t x655 = 26;
uint8_t x656 = UINT8_MAX;
volatile int32_t t137 = 206077;
t137 = (((x653-x654)+x655)>x656);
if (t137 != 1) { NG(); } else { ; }
}
void f138(void) {
int64_t x657 = -1LL;
static int8_t x659 = INT8_MIN;
int32_t x660 = INT32_MIN;
t138 = (((x657-x658)+x659)>x660);
if (t138 != 1) { NG(); } else { ; }
}
void f139(void) {
int16_t x662 = INT16_MIN;
int8_t x664 = INT8_MAX;
volatile int32_t t139 = 16485952;
t139 = (((x661-x662)+x663)>x664);
if (t139 != 1) { NG(); } else { ; }
}
void f140(void) {
int64_t x665 = INT64_MAX;
static int32_t x666 = 89450244;
uint16_t x667 = 21U;
uint16_t x668 = 15918U;
static volatile int32_t t140 = 4116;
t140 = (((x665-x666)+x667)>x668);
if (t140 != 1) { NG(); } else { ; }
}
void f141(void) {
uint16_t x669 = 12080U;
int8_t x670 = INT8_MIN;
int32_t x671 = INT32_MIN;
volatile int16_t x672 = INT16_MIN;
volatile int32_t t141 = 1;
t141 = (((x669-x670)+x671)>x672);
if (t141 != 0) { NG(); } else { ; }
}
void f142(void) {
int32_t x673 = -1;
int32_t x674 = 13670;
int16_t x675 = -1;
static uint16_t x676 = 13979U;
int32_t t142 = -9;
t142 = (((x673-x674)+x675)>x676);
if (t142 != 0) { NG(); } else { ; }
}
void f143(void) {
int16_t x681 = INT16_MIN;
uint16_t x682 = 129U;
static int16_t x683 = INT16_MIN;
int8_t x684 = 43;
t143 = (((x681-x682)+x683)>x684);
if (t143 != 0) { NG(); } else { ; }
}
void f144(void) {
int16_t x685 = INT16_MIN;
int64_t x686 = 22971050LL;
uint8_t x687 = 0U;
static volatile int8_t x688 = INT8_MIN;
volatile int32_t t144 = -63871684;
t144 = (((x685-x686)+x687)>x688);
if (t144 != 0) { NG(); } else { ; }
}
void f145(void) {
uint32_t x689 = 3564U;
static volatile int16_t x690 = INT16_MIN;
int16_t x691 = -88;
volatile int32_t t145 = -58759;
t145 = (((x689-x690)+x691)>x692);
if (t145 != 0) { NG(); } else { ; }
}
void f146(void) {
static int8_t x693 = -1;
uint32_t x694 = 36U;
static int32_t t146 = 2155002;
t146 = (((x693-x694)+x695)>x696);
if (t146 != 1) { NG(); } else { ; }
}
void f147(void) {
int8_t x702 = INT8_MIN;
volatile uint32_t x704 = UINT32_MAX;
volatile int32_t t147 = 1;
t147 = (((x701-x702)+x703)>x704);
if (t147 != 0) { NG(); } else { ; }
}
void f148(void) {
static int8_t x705 = 13;
static int32_t x706 = INT32_MAX;
int32_t x707 = -1;
int32_t x708 = INT32_MIN;
int32_t t148 = 9119643;
t148 = (((x705-x706)+x707)>x708);
if (t148 != 1) { NG(); } else { ; }
}
void f149(void) {
uint32_t x713 = 41597963U;
volatile uint64_t x714 = UINT64_MAX;
static uint8_t x715 = 12U;
int16_t x716 = INT16_MIN;
int32_t t149 = 0;
t149 = (((x713-x714)+x715)>x716);
if (t149 != 0) { NG(); } else { ; }
}
void f150(void) {
int16_t x717 = INT16_MIN;
int8_t x718 = -1;
int32_t x719 = INT32_MAX;
uint16_t x720 = 3U;
int32_t t150 = -586065;
t150 = (((x717-x718)+x719)>x720);
if (t150 != 1) { NG(); } else { ; }
}
void f151(void) {
int32_t x721 = -1;
volatile int64_t x722 = 197805167507LL;
int16_t x723 = 53;
static volatile int32_t t151 = -11722017;
t151 = (((x721-x722)+x723)>x724);
if (t151 != 0) { NG(); } else { ; }
}
void f152(void) {
int8_t x725 = INT8_MAX;
uint32_t x726 = 14110874U;
volatile uint8_t x727 = UINT8_MAX;
uint32_t x728 = UINT32_MAX;
static int32_t t152 = 119970;
t152 = (((x725-x726)+x727)>x728);
if (t152 != 0) { NG(); } else { ; }
}
void f153(void) {
uint16_t x733 = 2186U;
int8_t x734 = INT8_MIN;
static uint64_t x736 = 2018449643668855607LLU;
volatile int32_t t153 = 1;
t153 = (((x733-x734)+x735)>x736);
if (t153 != 0) { NG(); } else { ; }
}
void f154(void) {
int64_t x737 = INT64_MIN;
volatile int64_t x739 = 1LL;
int32_t t154 = -3392493;
t154 = (((x737-x738)+x739)>x740);
if (t154 != 0) { NG(); } else { ; }
}
void f155(void) {
int32_t x745 = -7;
uint64_t x746 = 1223361864883651LLU;
uint32_t x747 = UINT32_MAX;
uint64_t x748 = 3516706LLU;
volatile int32_t t155 = -7669609;
t155 = (((x745-x746)+x747)>x748);
if (t155 != 1) { NG(); } else { ; }
}
void f156(void) {
int16_t x749 = INT16_MAX;
volatile int32_t x750 = -1;
int32_t x752 = INT32_MIN;
int32_t t156 = 3101198;
t156 = (((x749-x750)+x751)>x752);
if (t156 != 0) { NG(); } else { ; }
}
void f157(void) {
static int64_t x753 = -1LL;
static int64_t x756 = -1LL;
t157 = (((x753-x754)+x755)>x756);
if (t157 != 0) { NG(); } else { ; }
}
void f158(void) {
uint16_t x757 = 1U;
uint16_t x758 = UINT16_MAX;
int8_t x759 = -35;
int16_t x760 = INT16_MIN;
int32_t t158 = 60;
t158 = (((x757-x758)+x759)>x760);
if (t158 != 0) { NG(); } else { ; }
}
void f159(void) {
volatile int64_t x769 = -58160LL;
int8_t x770 = 2;
uint8_t x772 = 0U;
static volatile int32_t t159 = -29;
t159 = (((x769-x770)+x771)>x772);
if (t159 != 0) { NG(); } else { ; }
}
void f160(void) {
static int32_t x773 = INT32_MIN;
uint32_t x774 = UINT32_MAX;
static volatile int8_t x775 = INT8_MIN;
int32_t x776 = 5670727;
t160 = (((x773-x774)+x775)>x776);
if (t160 != 1) { NG(); } else { ; }
}
void f161(void) {
uint32_t x781 = 230307990U;
int16_t x782 = INT16_MIN;
volatile int16_t x783 = INT16_MIN;
volatile int32_t x784 = 68;
int32_t t161 = 5929;
t161 = (((x781-x782)+x783)>x784);
if (t161 != 1) { NG(); } else { ; }
}
void f162(void) {
static volatile int32_t x789 = -119498;
volatile int8_t x790 = 15;
int32_t x791 = -20595206;
uint32_t x792 = UINT32_MAX;
t162 = (((x789-x790)+x791)>x792);
if (t162 != 0) { NG(); } else { ; }
}
void f163(void) {
int32_t x793 = INT32_MIN;
static int16_t x796 = -10;
volatile int32_t t163 = -3738675;
t163 = (((x793-x794)+x795)>x796);
if (t163 != 1) { NG(); } else { ; }
}
void f164(void) {
uint32_t x797 = 1680U;
int64_t x798 = 33154584529041162LL;
volatile int32_t x799 = INT32_MIN;
int32_t x800 = -1;
int32_t t164 = -169200681;
t164 = (((x797-x798)+x799)>x800);
if (t164 != 0) { NG(); } else { ; }
}
void f165(void) {
uint32_t x802 = 6U;
t165 = (((x801-x802)+x803)>x804);
if (t165 != 1) { NG(); } else { ; }
}
void f166(void) {
int64_t x805 = 1227191632458673LL;
int64_t x807 = INT64_MIN;
int32_t x808 = INT32_MIN;
int32_t t166 = 6504709;
t166 = (((x805-x806)+x807)>x808);
if (t166 != 0) { NG(); } else { ; }
}
void f167(void) {
static int32_t x809 = 448595;
static volatile uint8_t x810 = 0U;
int8_t x811 = INT8_MIN;
t167 = (((x809-x810)+x811)>x812);
if (t167 != 1) { NG(); } else { ; }
}
void f168(void) {
int32_t x813 = INT32_MIN;
static volatile int64_t x814 = 372521377LL;
static uint64_t x815 = 144624333408765207LLU;
volatile int8_t x816 = -1;
volatile int32_t t168 = 491231;
t168 = (((x813-x814)+x815)>x816);
if (t168 != 0) { NG(); } else { ; }
}
void f169(void) {
uint8_t x817 = UINT8_MAX;
int32_t x819 = -3;
volatile uint64_t x820 = 538706505780928LLU;
int32_t t169 = 14;
t169 = (((x817-x818)+x819)>x820);
if (t169 != 0) { NG(); } else { ; }
}
void f170(void) {
uint16_t x822 = 3525U;
int32_t x823 = -1;
uint16_t x824 = 2016U;
int32_t t170 = 1236;
t170 = (((x821-x822)+x823)>x824);
if (t170 != 0) { NG(); } else { ; }
}
void f171(void) {
uint64_t x825 = 1597446886896224438LLU;
int8_t x826 = -38;
volatile int32_t x827 = -1;
uint64_t x828 = 2029LLU;
t171 = (((x825-x826)+x827)>x828);
if (t171 != 1) { NG(); } else { ; }
}
void f172(void) {
uint16_t x829 = UINT16_MAX;
uint16_t x830 = 1865U;
static int8_t x831 = 1;
int32_t x832 = INT32_MAX;
int32_t t172 = 7;
t172 = (((x829-x830)+x831)>x832);
if (t172 != 0) { NG(); } else { ; }
}
void f173(void) {
int8_t x833 = INT8_MIN;
volatile int32_t t173 = 919;
t173 = (((x833-x834)+x835)>x836);
if (t173 != 1) { NG(); } else { ; }
}
void f174(void) {
int32_t x837 = -1;
int64_t x838 = -1LL;
volatile int8_t x840 = INT8_MAX;
t174 = (((x837-x838)+x839)>x840);
if (t174 != 1) { NG(); } else { ; }
}
void f175(void) {
int32_t x841 = INT32_MIN;
static volatile uint8_t x844 = UINT8_MAX;
volatile int32_t t175 = 30;
t175 = (((x841-x842)+x843)>x844);
if (t175 != 1) { NG(); } else { ; }
}
void f176(void) {
uint16_t x845 = 28U;
uint32_t x846 = 37397583U;
volatile int32_t x848 = -1928;
volatile int32_t t176 = 1;
t176 = (((x845-x846)+x847)>x848);
if (t176 != 0) { NG(); } else { ; }
}
void f177(void) {
volatile uint64_t x861 = UINT64_MAX;
int64_t x862 = INT64_MIN;
int32_t x863 = 1;
int32_t x864 = INT32_MIN;
volatile int32_t t177 = -91;
t177 = (((x861-x862)+x863)>x864);
if (t177 != 0) { NG(); } else { ; }
}
void f178(void) {
volatile int16_t x869 = INT16_MAX;
uint32_t x870 = UINT32_MAX;
int16_t x871 = INT16_MAX;
int8_t x872 = -3;
int32_t t178 = 1048209013;
t178 = (((x869-x870)+x871)>x872);
if (t178 != 0) { NG(); } else { ; }
}
void f179(void) {
uint64_t x873 = 41641LLU;
int8_t x874 = -1;
int16_t x875 = INT16_MIN;
volatile int16_t x876 = INT16_MIN;
t179 = (((x873-x874)+x875)>x876);
if (t179 != 0) { NG(); } else { ; }
}
void f180(void) {
int16_t x877 = INT16_MIN;
static volatile int32_t x878 = INT32_MIN;
int64_t x879 = INT64_MIN;
int16_t x880 = INT16_MIN;
static volatile int32_t t180 = -1232708;
t180 = (((x877-x878)+x879)>x880);
if (t180 != 0) { NG(); } else { ; }
}
void f181(void) {
int16_t x881 = 50;
volatile uint16_t x882 = UINT16_MAX;
volatile int16_t x883 = INT16_MIN;
volatile int32_t t181 = 98;
t181 = (((x881-x882)+x883)>x884);
if (t181 != 0) { NG(); } else { ; }
}
void f182(void) {
int16_t x885 = -1;
int8_t x886 = INT8_MIN;
uint32_t x887 = 1445278614U;
int8_t x888 = INT8_MAX;
int32_t t182 = -3607;
t182 = (((x885-x886)+x887)>x888);
if (t182 != 1) { NG(); } else { ; }
}
void f183(void) {
int8_t x889 = -1;
int64_t x891 = 2129298175681267LL;
volatile uint32_t x892 = UINT32_MAX;
volatile int32_t t183 = -1489;
t183 = (((x889-x890)+x891)>x892);
if (t183 != 1) { NG(); } else { ; }
}
void f184(void) {
static uint32_t x893 = 44103U;
int8_t x894 = INT8_MIN;
int32_t x896 = -1;
volatile int32_t t184 = 0;
t184 = (((x893-x894)+x895)>x896);
if (t184 != 0) { NG(); } else { ; }
}
void f185(void) {
volatile int16_t x898 = -1;
int16_t x899 = INT16_MIN;
static volatile int32_t t185 = 51;
t185 = (((x897-x898)+x899)>x900);
if (t185 != 1) { NG(); } else { ; }
}
void f186(void) {
static uint32_t x905 = UINT32_MAX;
int64_t x907 = -11447LL;
int32_t t186 = 88;
t186 = (((x905-x906)+x907)>x908);
if (t186 != 1) { NG(); } else { ; }
}
void f187(void) {
int64_t x913 = 1419520794331LL;
uint16_t x914 = UINT16_MAX;
int32_t x915 = -1;
volatile int32_t t187 = 32499;
t187 = (((x913-x914)+x915)>x916);
if (t187 != 1) { NG(); } else { ; }
}
void f188(void) {
volatile uint8_t x917 = 23U;
int64_t x918 = 3174628194067536255LL;
volatile int8_t x920 = INT8_MIN;
int32_t t188 = -14859255;
t188 = (((x917-x918)+x919)>x920);
if (t188 != 0) { NG(); } else { ; }
}
void f189(void) {
int16_t x921 = INT16_MIN;
int8_t x922 = INT8_MIN;
volatile int64_t x924 = 27624LL;
static int32_t t189 = 902998204;
t189 = (((x921-x922)+x923)>x924);
if (t189 != 0) { NG(); } else { ; }
}
void f190(void) {
int16_t x925 = INT16_MAX;
volatile int64_t x926 = INT64_MAX;
static volatile uint8_t x927 = UINT8_MAX;
uint64_t x928 = 520400470495394972LLU;
volatile int32_t t190 = -15368;
t190 = (((x925-x926)+x927)>x928);
if (t190 != 1) { NG(); } else { ; }
}
void f191(void) {
uint32_t x930 = UINT32_MAX;
volatile int8_t x931 = 18;
uint16_t x932 = 7250U;
int32_t t191 = 75;
t191 = (((x929-x930)+x931)>x932);
if (t191 != 1) { NG(); } else { ; }
}
void f192(void) {
static int8_t x933 = -1;
static int8_t x935 = INT8_MIN;
static int32_t x936 = 1;
volatile int32_t t192 = -4;
t192 = (((x933-x934)+x935)>x936);
if (t192 != 0) { NG(); } else { ; }
}
void f193(void) {
uint8_t x937 = 1U;
volatile uint64_t x939 = 42780055594559LLU;
t193 = (((x937-x938)+x939)>x940);
if (t193 != 1) { NG(); } else { ; }
}
void f194(void) {
int8_t x941 = -17;
uint32_t x943 = UINT32_MAX;
volatile int32_t t194 = 1;
t194 = (((x941-x942)+x943)>x944);
if (t194 != 1) { NG(); } else { ; }
}
void f195(void) {
volatile int8_t x945 = -5;
int8_t x946 = INT8_MAX;
uint16_t x948 = 41U;
volatile int32_t t195 = -443;
t195 = (((x945-x946)+x947)>x948);
if (t195 != 0) { NG(); } else { ; }
}
void f196(void) {
int16_t x949 = INT16_MAX;
int32_t x950 = -1;
volatile uint64_t x951 = 7507746543LLU;
static int32_t x952 = -12647;
volatile int32_t t196 = -330;
t196 = (((x949-x950)+x951)>x952);
if (t196 != 0) { NG(); } else { ; }
}
void f197(void) {
volatile uint16_t x953 = UINT16_MAX;
int64_t x954 = -52LL;
volatile int8_t x955 = INT8_MIN;
static uint64_t x956 = 220238731858LLU;
static volatile int32_t t197 = 1;
t197 = (((x953-x954)+x955)>x956);
if (t197 != 0) { NG(); } else { ; }
}
void f198(void) {
int32_t x957 = -1;
uint32_t x958 = 6915U;
int8_t x959 = -1;
int32_t t198 = 63370;
t198 = (((x957-x958)+x959)>x960);
if (t198 != 0) { NG(); } else { ; }
}
void f199(void) {
int64_t x961 = INT64_MIN;
uint32_t x963 = 7761274U;
static int16_t x964 = INT16_MIN;
t199 = (((x961-x962)+x963)>x964);
if (t199 != 0) { NG(); } else { ; }
}
int main(void) {
f0();
f1();
f2();
f3();
f4();
f5();
f6();
f7();
f8();
f9();
f10();
f11();
f12();
f13();
f14();
f15();
f16();
f17();
f18();
f19();
f20();
f21();
f22();
f23();
f24();
f25();
f26();
f27();
f28();
f29();
f30();
f31();
f32();
f33();
f34();
f35();
f36();
f37();
f38();
f39();
f40();
f41();
f42();
f43();
f44();
f45();
f46();
f47();
f48();
f49();
f50();
f51();
f52();
f53();
f54();
f55();
f56();
f57();
f58();
f59();
f60();
f61();
f62();
f63();
f64();
f65();
f66();
f67();
f68();
f69();
f70();
f71();
f72();
f73();
f74();
f75();
f76();
f77();
f78();
f79();
f80();
f81();
f82();
f83();
f84();
f85();
f86();
f87();
f88();
f89();
f90();
f91();
f92();
f93();
f94();
f95();
f96();
f97();
f98();
f99();
f100();
f101();
f102();
f103();
f104();
f105();
f106();
f107();
f108();
f109();
f110();
f111();
f112();
f113();
f114();
f115();
f116();
f117();
f118();
f119();
f120();
f121();
f122();
f123();
f124();
f125();
f126();
f127();
f128();
f129();
f130();
f131();
f132();
f133();
f134();
f135();
f136();
f137();
f138();
f139();
f140();
f141();
f142();
f143();
f144();
f145();
f146();
f147();
f148();
f149();
f150();
f151();
f152();
f153();
f154();
f155();
f156();
f157();
f158();
f159();
f160();
f161();
f162();
f163();
f164();
f165();
f166();
f167();
f168();
f169();
f170();
f171();
f172();
f173();
f174();
f175();
f176();
f177();
f178();
f179();
f180();
f181();
f182();
f183();
f184();
f185();
f186();
f187();
f188();
f189();
f190();
f191();
f192();
f193();
f194();
f195();
f196();
f197();
f198();
f199();
return 0;
}
| 18.279391 | 54 | 0.581236 |
33eff6194d75b1b13d4f0d0abdf61b8d3b11a26e | 984 | h | C | RiceCube/src/Application.h | wuguyannian/RiceCube | 01abe52d3e59efb8e48f2b3ce9e4243027687bff | [
"MIT"
] | null | null | null | RiceCube/src/Application.h | wuguyannian/RiceCube | 01abe52d3e59efb8e48f2b3ce9e4243027687bff | [
"MIT"
] | null | null | null | RiceCube/src/Application.h | wuguyannian/RiceCube | 01abe52d3e59efb8e48f2b3ce9e4243027687bff | [
"MIT"
] | null | null | null | #pragma once
#include "window.h"
#include "layer_stack.h"
#include "layer/layer_imgui.h"
#include "event/event_application.h"
#include "render/shader.h"
#include "render/buffer.h"
namespace RiceCube
{
class Application
{
public:
Application();
virtual ~Application();
void run();
void onEvent(Event& event);
void pushLayer(Layer* layer);
void pushOverlay(Layer* layer);
inline Window& getWindow() { return *m_window; }
inline static Application& get() { return *s_instance; }
private:
bool onWindowClose(WindowCloseEvent& event);
bool m_running = true;
std::unique_ptr<Window> m_window;
LayerStack m_layerStack;
LayerImGui* m_layerGui;
uint32_t m_vertexArray = 0;
std::unique_ptr<Shader> m_shader;
std::unique_ptr<VertexBuffer> m_vertexBuffer;
std::unique_ptr<IndexBuffer> m_indexBuffer;
private:
static Application* s_instance;
};
} | 20.081633 | 64 | 0.658537 |
b88fad136595275383a71058048536eaff536d59 | 1,248 | c | C | libvirt/pileus-libvirt-1.2.12/src/interface/interface_driver.c | SIIS-cloud/pileus | de7546845cf03862cdd2b9884fefb2033d8b11ab | [
"Apache-2.0"
] | 3 | 2017-09-22T15:10:01.000Z | 2018-03-30T02:11:54.000Z | libvirt/pileus-libvirt-1.2.12/src/interface/interface_driver.c | SIIS-cloud/Pileus | de7546845cf03862cdd2b9884fefb2033d8b11ab | [
"Apache-2.0"
] | null | null | null | libvirt/pileus-libvirt-1.2.12/src/interface/interface_driver.c | SIIS-cloud/Pileus | de7546845cf03862cdd2b9884fefb2033d8b11ab | [
"Apache-2.0"
] | null | null | null | /*
* interface_driver.c: loads the appropriate backend
*
* Copyright (C) 2014 Red Hat, Inc.
* Copyright (C) 2012 Doug Goldstein <cardoe@cardoe.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "interface_driver.h"
int
interfaceRegister(void)
{
#ifdef WITH_NETCF
/* Attempt to load the netcf based backend first */
if (netcfIfaceRegister() == 0)
return 0;
#endif /* WITH_NETCF */
#if WITH_UDEV
/* If there's no netcf or it failed to load, register the udev backend */
if (udevIfaceRegister() == 0)
return 0;
#endif /* WITH_UDEV */
return -1;
}
| 31.2 | 77 | 0.707532 |
ef78318a39ade471a3e6222488605df701a448e7 | 2,575 | h | C | ai_scripts/global.h | stephenneuendorffer/vyasa | 8dc1c8be2c1fd51e9c68c1b52542c3ba6cc432be | [
"MIT"
] | 7 | 2021-05-04T01:39:19.000Z | 2021-11-16T20:06:47.000Z | ai_scripts/global.h | stephenneuendorffer/vyasa | 8dc1c8be2c1fd51e9c68c1b52542c3ba6cc432be | [
"MIT"
] | null | null | null | ai_scripts/global.h | stephenneuendorffer/vyasa | 8dc1c8be2c1fd51e9c68c1b52542c3ba6cc432be | [
"MIT"
] | null | null | null | // Copyright (c) 2019 Xilinx Inc. All Rights Reserved.
#ifndef _FILTER_2D_H_
#define _FILTER_2D_H_
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#define PARALLEL_FACTOR_32b 8 // Parallelization factor for 32b operations (8x mults)
#define SRS_SHIFT 10 // SRS shift used can be increased if input data likewise adjusted)
int conv7D_naive(int32_t * restrict _b0_buffer, int _b0_buffer_dim0_min, int _b0_buffer_dim0_extent, int _b0_buffer_dim0_stride, int _b0_buffer_dim1_min, int _b0_buffer_dim1_extent, int _b0_buffer_dim1_stride, int _b0_buffer_dim2_min, int _b0_buffer_dim2_extent, int _b0_buffer_dim2_stride, int _b0_buffer_dim3_min, int _b0_buffer_dim3_extent, int _b0_buffer_dim3_stride,
int32_t * restrict _b1_buffer, int _b1_buffer_dim0_min, int _b1_buffer_dim0_extent, int _b1_buffer_dim0_stride, int _b1_buffer_dim1_min, int _b1_buffer_dim1_extent, int _b1_buffer_dim1_stride, int _b1_buffer_dim2_min, int _b1_buffer_dim2_extent, int _b1_buffer_dim2_stride, int _b1_buffer_dim3_min, int _b1_buffer_dim3_extent, int _b1_buffer_dim3_stride,
int32_t * restrict _conv_buffer, int _conv_buffer_dim0_min, int _conv_buffer_dim0_extent, int _conv_buffer_dim0_stride, int _conv_buffer_dim1_min, int _conv_buffer_dim1_extent, int _conv_buffer_dim1_stride, int _conv_buffer_dim2_min, int _conv_buffer_dim2_extent, int _conv_buffer_dim2_stride, int _conv_buffer_dim3_min, int _conv_buffer_dim3_extent, int _conv_buffer_dim3_stride);
int conv(int32_t * restrict _b0_buffer, int _b0_buffer_dim0_min, int _b0_buffer_dim0_extent, int _b0_buffer_dim0_stride, int _b0_buffer_dim1_min, int _b0_buffer_dim1_extent, int _b0_buffer_dim1_stride, int _b0_buffer_dim2_min, int _b0_buffer_dim2_extent, int _b0_buffer_dim2_stride, int _b0_buffer_dim3_min, int _b0_buffer_dim3_extent, int _b0_buffer_dim3_stride,
int32_t * restrict _b1_buffer, int _b1_buffer_dim0_min, int _b1_buffer_dim0_extent, int _b1_buffer_dim0_stride, int _b1_buffer_dim1_min, int _b1_buffer_dim1_extent, int _b1_buffer_dim1_stride, int _b1_buffer_dim2_min, int _b1_buffer_dim2_extent, int _b1_buffer_dim2_stride, int _b1_buffer_dim3_min, int _b1_buffer_dim3_extent, int _b1_buffer_dim3_stride,
int32_t * restrict _conv_buffer, int _conv_buffer_dim0_min, int _conv_buffer_dim0_extent, int _conv_buffer_dim0_stride, int _conv_buffer_dim1_min, int _conv_buffer_dim1_extent, int _conv_buffer_dim1_stride, int _conv_buffer_dim2_min, int _conv_buffer_dim2_extent, int _conv_buffer_dim2_stride, int _conv_buffer_dim3_min, int _conv_buffer_dim3_extent, int _conv_buffer_dim3_stride);
#endif
| 117.045455 | 382 | 0.860583 |
8ecaa9505ef9e78a50ad32461e6a4cbfe6b8c763 | 42 | c | C | okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/gnuc/original/tests/test16.c | CyberQueenMara/baseband-research | e1605537e10c37e161fff1a3416b908c9894f204 | [
"MIT"
] | 77 | 2018-12-31T22:12:09.000Z | 2021-12-31T22:56:13.000Z | okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/gnuc/original/tests/test16.c | CyberQueenMara/baseband-research | e1605537e10c37e161fff1a3416b908c9894f204 | [
"MIT"
] | 4 | 2015-02-09T14:50:21.000Z | 2016-03-25T12:28:37.000Z | okl4_kernel/okl4_2.1.1-patch.9/tools/magpie-parsers/src/magpieparsers/gnuc/original/tests/test16.c | CyberQueenMara/baseband-research | e1605537e10c37e161fff1a3416b908c9894f204 | [
"MIT"
] | 24 | 2019-01-20T15:51:52.000Z | 2021-12-25T18:29:13.000Z | hey() {
int x,y,z;
z= x ? : y;
}
| 7 | 15 | 0.285714 |
3f11869482b3a4c37d64835e593135d91432cba1 | 7,348 | c | C | lab_09/_unit_tests/check_main.c | Pastor/bauman.c.programming.labs | dc7149b853a815da9c4054753b768ecd4a031a67 | [
"MIT"
] | null | null | null | lab_09/_unit_tests/check_main.c | Pastor/bauman.c.programming.labs | dc7149b853a815da9c4054753b768ecd4a031a67 | [
"MIT"
] | null | null | null | lab_09/_unit_tests/check_main.c | Pastor/bauman.c.programming.labs | dc7149b853a815da9c4054753b768ecd4a031a67 | [
"MIT"
] | null | null | null | #include <stdlib.h>
#include <check.h>
#include <main.h>
#define UNIT_MATRIX_FILENAME "unit_fread_struct.txt"
static void destroy_none(void *element) {
}
int compare_long_fn(void *a, void *b, void *userdata) {
if ((long long) a < (long long) b) return -1;
if ((long long) a > (long long) b) return 1;
return 0;
}
void callback_none(const char **fields, void *userdata) {
}
START_TEST(unit_fread_struct)
{
FILE *fd = fopen(UNIT_MATRIX_FILENAME, "w+");
ck_assert_ptr_nonnull(fd);
fprintf(fd, "One\n");
fprintf(fd, "Two\n");
fprintf(fd, "Three");
rewind(fd);
fread_struct(fd, 3, callback_none, 0);
fclose(fd);
remove(UNIT_MATRIX_FILENAME);
}
END_TEST
START_TEST(unit_list_insert)
{
struct List list = {0};
list_insert(&list, 0, (void *) (long long) 0);
list_insert(&list, 0, (void *) (long long) 1);
list_insert(&list, 0, (void *) (long long) 2);
list_insert(&list, 0, (void *) (long long) 3);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
ck_assert_int_eq((long long) list.elements[1], (long long) 2);
ck_assert_int_eq((long long) list.elements[2], (long long) 1);
ck_assert_int_eq((long long) list.elements[3], (long long) 0);
list_destroy(&list, destroy_none);
}
END_TEST
START_TEST(unit_list_append)
{
struct List list = {0};
list_append(&list, (void *) (long long) 0);
list_append(&list, (void *) (long long) 1);
list_append(&list, (void *) (long long) 2);
list_append(&list, (void *) (long long) 3);
ck_assert_int_eq((long long) list.elements[0], (long long) 0);
ck_assert_int_eq((long long) list.elements[1], (long long) 1);
ck_assert_int_eq((long long) list.elements[2], (long long) 2);
ck_assert_int_eq((long long) list.elements[3], (long long) 3);
list_destroy(&list, destroy_none);
}
END_TEST
START_TEST(unit_list_destroy)
{
list_destroy(0, destroy_none);
}
END_TEST
START_TEST(unit_list_append_sort)
{
struct List list = {0};
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
ck_assert_int_eq((long long) list.elements[1], (long long) 2);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
ck_assert_int_eq((long long) list.elements[1], (long long) 2);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 1, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
ck_assert_int_eq((long long) list.elements[1], (long long) 2);
ck_assert_int_eq((long long) list.elements[2], (long long) 1);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 1, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 3);
ck_assert_int_eq((long long) list.elements[1], (long long) 2);
ck_assert_int_eq((long long) list.elements[2], (long long) 1);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 1, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 8, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 8);
ck_assert_int_eq((long long) list.elements[1], (long long) 3);
ck_assert_int_eq((long long) list.elements[2], (long long) 2);
ck_assert_int_eq((long long) list.elements[3], (long long) 1);
list_destroy(&list, destroy_none);
list_append_sort(&list, (void *) (long long) 3, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 2, compare_long_fn, 0);
list_append_sort(&list, (void *) (long long) 8, compare_long_fn, 0);
ck_assert_int_eq((long long) list.elements[0], (long long) 8);
ck_assert_int_eq((long long) list.elements[1], (long long) 3);
ck_assert_int_eq((long long) list.elements[2], (long long) 2);
list_destroy(&list, destroy_none);
}
END_TEST
START_TEST(unit_binary_search)
{
struct List list = {0};
ssize_t i;
enum BinarySearchSide side = NOT_FOUND;
list_append(&list, (void *) (long long) 3);
list_append(&list, (void *) (long long) 2);
list_append(&list, (void *) (long long) 1);
list_append(&list, (void *) (long long) 0);
i = binary_search(&list, 0, list.size - 1, (void *) (long long) 1, &side, compare_long_fn, 0);
ck_assert_int_eq(i, 2);
ck_assert(side == FOUND);
list_destroy(&list, destroy_none);
list_append(&list, (void *) (long long) 3);
list_append(&list, (void *) (long long) 2);
list_append(&list, (void *) (long long) 1);
i = binary_search(&list, 0, list.size - 1, (void *) (long long) 2, &side, compare_long_fn, 0);
ck_assert_int_eq(i, 1);
ck_assert(side == FOUND);
list_destroy(&list, destroy_none);
list_append(&list, (void *) (long long) 30);
list_append(&list, (void *) (long long) 20);
list_append(&list, (void *) (long long) 10);
i = binary_search(&list, 0, list.size - 1, (void *) (long long) 1, &side, compare_long_fn, 0);
ck_assert(side == RIGHT);
ck_assert(i > 0);
list_destroy(&list, destroy_none);
}
END_TEST
Suite *main_suite() {
Suite *suite;
TCase *core_case;
suite = suite_create("Main");
core_case = tcase_create("unit_list");
tcase_add_test(core_case, unit_list_insert);
tcase_add_test(core_case, unit_list_append);
tcase_add_test(core_case, unit_list_destroy);
tcase_add_test(core_case, unit_list_append_sort);
tcase_add_test(core_case, unit_binary_search);
suite_add_tcase(suite, core_case);
core_case = tcase_create("unit_file");
tcase_add_test(core_case, unit_fread_struct);
suite_add_tcase(suite, core_case);
return suite;
}
int main() {
Suite *suite;
SRunner *runner;
int failed;
suite = main_suite();
runner = srunner_create(suite);
srunner_run_all(runner, CK_NORMAL);
failed = srunner_ntests_failed(runner);
srunner_free(runner);
return failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
| 36.557214 | 102 | 0.626837 |
8baa214136f28b41a1fd8a2118bf2e0f62f085a9 | 2,072 | h | C | QMC5883/QMC5883.h | MartinD-CZ/HAL-drivers | 1e07e52624665e8a96ec1e6a01661af8152b0297 | [
"MIT"
] | 1 | 2022-03-26T14:57:34.000Z | 2022-03-26T14:57:34.000Z | QMC5883/QMC5883.h | MartinD-CZ/HAL-drivers | 1e07e52624665e8a96ec1e6a01661af8152b0297 | [
"MIT"
] | null | null | null | QMC5883/QMC5883.h | MartinD-CZ/HAL-drivers | 1e07e52624665e8a96ec1e6a01661af8152b0297 | [
"MIT"
] | null | null | null | #ifndef QMC5883_H_
#define QMC5883_H_
#include "hal_include.h"
#ifdef CONFIG_FILE
#include "config.h"
#endif
#ifndef QMC_I2C_TIMEOUT
#define QMC_I2C_TIMEOUT 100 //timeout for SPI in polling mode; in ms
#endif
#ifndef QMC5883_I2C_ADDR
#define QMC5883_I2C_ADDR (0x0D << 1)
#endif
#define QMC5883_CHIPID 0xFF
#define QMC_STATUS_DRDY_FLAG 0b00000001 //data ready flag
#define QMC_STATUS_OVL_FLAG 0b00000010 //data overflow flag (increase range)
#define QMC_STATUS_DOR_FLAG 0b00000100 //data read skipped
#define QMC_READ_NO_DATA 0
#define QMC_READ_I2C_NACK 1
#define QMC_READ_OVERFLOW 2
#define QMC_READ_OK 3
enum osr_e
{
OSR_64x = 0b11000000,
OSR_128x = 0b10000000,
OSR_256x = 0b01000000,
OSR_512x = 0b00000000
};
enum rng_e
{
RNG_2GAUSS = 0b000000,
RNG_8GAUSS = 0b010000
};
enum odr_e
{
ODR_10HZ = 0b0000,
ODR_50HZ = 0b0100,
ODR_100HZ = 0b1000,
ODR_200HZ = 0b1100
};
enum mode_e
{
MODE_STANDBY = 0b00,
MODE_CONTINUOUS = 0b01
};
enum drdy_e
{
DRDY_ENABLED = 0b00,
DRDY_DISABLED = 0b01
};
enum rol_e
{
ROL_PTN_NORMAL = 0b00000000,
ROL_PTN_ENABLED = 0b01000000
};
class QMC5883
{
public:
QMC5883(I2C_HandleTypeDef* I2C):
_I2C(I2C), _drdy_port(nullptr), _drdy_pin(0xFFFF) {};
QMC5883(I2C_HandleTypeDef* I2C, GPIO_TypeDef* drdy_port, const uint16_t drdy_pin):
_I2C(I2C), _drdy_port(drdy_port), _drdy_pin(drdy_pin) {};
bool init(void);
void setConfig(osr_e osr, rng_e rng, odr_e odr, mode_e mode, rol_e rol = ROL_PTN_NORMAL);
void reset(void);
uint8_t readChipID(void);
bool dataAvailable(void);
uint8_t readStatusRegister(void);
uint8_t readData(int16_t* xout = nullptr, int16_t* yout = nullptr, int16_t* zout = nullptr, int16_t* tout = nullptr);
int16_t getX(void) const {return _x;};
int16_t getY(void) const {return _y;};
int16_t getZ(void) const {return _z;};
int16_t getTemperature(void) const {return _t;};
int16_t getHeading() const;
private:
I2C_HandleTypeDef* const _I2C;
GPIO_TypeDef* const _drdy_port;
const uint16_t _drdy_pin;
int16_t _x, _y, _z, _t;
};
#endif /* QMC5883_H_ */
| 19.923077 | 118 | 0.742278 |
2724adc4b114a6927ba89e925008dbd86aea9050 | 2,372 | h | C | Qlink/Vender/QLC/QLCFramework.framework/Headers/QLCWalletManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 8 | 2018-07-11T12:31:20.000Z | 2019-08-14T03:38:45.000Z | Qlink/Vender/QLC/QLCFramework.framework/Headers/QLCWalletManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 65 | 2020-03-29T08:17:07.000Z | 2021-01-14T22:41:10.000Z | Qlink/Vender/QLC/QLCFramework.framework/Headers/QLCWalletManage.h | QlcChainOrg/winq-ios | 21dc93068e2f4bfe14b1fa65a398a049782894c5 | [
"MIT"
] | 9 | 2018-07-11T10:37:19.000Z | 2019-08-03T10:33:14.000Z | //
// QLCWalletManage.h
// Qlink
//
// Created by Jelly Foo on 2019/5/23.
// Copyright © 2019 pan. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
extern NSString * _Nonnull const QLC_AccountPending_Done_Noti;
@interface QLCWalletManage : NSObject
@property (nonatomic, strong) NSString *qlcMainAddress;
+ (instancetype)shareInstance;
- (BOOL)createWallet;
- (BOOL)importWalletWithSeed:(NSString *)seed;
- (BOOL)importWalletWithMnemonic:(NSString *)mnemonic;
- (BOOL)walletSeedIsValid:(NSString *)seed;
- (BOOL)walletMnemonicIsValid:(NSString *)mnemonic;
- (NSString *)exportMnemonicWithSeed:(NSString *)seed;
- (NSString *)walletAddress;
- (NSString *)walletPrivateKeyStr;
- (NSString *)walletPublicKeyStr;
- (NSString *)walletSeed;
- (BOOL)walletAddressIsValid:(NSString *)address;
- (BOOL)switchWalletWithSeed:(NSString *)seed;
- (void)sendAssetWithTokenName:(NSString *)tokenName to:(NSString *)to amount:(NSUInteger)amount sender:(nullable NSString *)sender receiver:(nullable NSString *)receiver message:(nullable NSString *)message data:(nullable NSString *)data baseUrl:(NSString *)baseUrl workInLocal:(BOOL)workInLocal successHandler:(void(^_Nonnull)(NSString * _Nullable responseObj))successHandler failureHandler:(void(^_Nonnull)(NSError * _Nullable error, NSString *_Nullable message))failureHandler;
// send
- (void)sendAssetWithTokenName:(NSString *)tokenName from:(NSString *)from to:(NSString *)to amount:(NSUInteger)amount privateKey:(NSString *)privateKey sender:(nullable NSString *)sender receiver:(nullable NSString *)receiver message:(nullable NSString *)message data:(nullable NSString *)data baseUrl:(NSString *)baseUrl workInLocal:(BOOL)workInLocal successHandler:(void(^_Nonnull)(NSString * _Nullable responseObj))successHandler failureHandler:(void(^_Nonnull)(NSError * _Nullable error, NSString *_Nullable message))failureHandler;
// receive
- (void)receive_accountsPending:(NSString *)address baseUrl:(NSString *)baseUrl privateKey:(NSString *)privateKey toastView:(UIView *)toastView;
+ (void)signAndWork:(NSDictionary *)dic publicKey:(NSString *)publicKey privateKey:(NSString *)privateKey resultHandler:(void(^_Nonnull)(NSDictionary * _Nullable responseDic))resultHandler;
+ (NSString *)qlcSign:(NSString *)messageHex publicKey:(NSString *)publicKey privateKey:(NSString *)privateKey;
@end
| 52.711111 | 537 | 0.783727 |
2743d80dc7d388299ac6fec93d43e254ab1b0a2b | 727 | h | C | ProjectArchitecture/Tools/ZMMJRefreshTools/NSObject+ZMAddMJRefresh.h | lucking/ProjectArchitecture | 49765919a0a4eb9092ff64a82d437ba7f4a36fd1 | [
"Apache-2.0"
] | 10 | 2017-08-08T15:24:18.000Z | 2019-05-05T01:51:04.000Z | ProjectArchitecture/Tools/ZMMJRefreshTools/NSObject+ZMAddMJRefresh.h | lucking/ProjectArchitecture | 49765919a0a4eb9092ff64a82d437ba7f4a36fd1 | [
"Apache-2.0"
] | null | null | null | ProjectArchitecture/Tools/ZMMJRefreshTools/NSObject+ZMAddMJRefresh.h | lucking/ProjectArchitecture | 49765919a0a4eb9092ff64a82d437ba7f4a36fd1 | [
"Apache-2.0"
] | null | null | null | //
// NSObject+ZMAddMJRefresh.h
// ProjectArchitecture
//
// Created by ZM on 2017/5/8.
// Copyright © 2017年 ZM. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSObject (ZMAddMJRefresh)
/**
结束刷新:UIScrollView
@param scrollView 结束刷新的视图
@param isHeader 是否是头部:下拉刷新
*/
- (void)endRefreshScrollView:(UIScrollView *)scrollView isHeader:(BOOL)isHeader;
/**
结束刷新:UITableView
@param tableView 结束刷新的视图
@param isHeader 是否是头部:下拉刷新
*/
- (void)endRefreshTableView:(UITableView *)tableView isHeader:(BOOL)isHeader;
/**
结束刷新:UICollectionView
@param collectionView 结束刷新的视图
@param isHeader 是否是头部:下拉刷新
*/
- (void)endRefreshCollectionView:(UICollectionView *)collectionView isHeader:(BOOL)isHeader;
@end
| 20.771429 | 92 | 0.753783 |
6a1a1b3c082759bfee9fca707fcf885d324464b6 | 473 | h | C | tools/perf/arch/x86/include/arch-tests.h | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | tools/perf/arch/x86/include/arch-tests.h | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 1 | 2022-03-29T02:30:28.000Z | 2022-03-30T03:40:46.000Z | tools/perf/arch/x86/include/arch-tests.h | Sunrisepeak/Linux2.6-Reading | c25102a494a37f9f30a27ca2cd4a1a412bffc80f | [
"MIT"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | /* SPDX-License-Identifier: GPL-2.0 */
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H
struct test_suite;
/* Tests */
int test__rdpmc(struct test_suite *test, int subtest);
int test__insn_x86(struct test_suite *test, int subtest);
int test__intel_pt_pkt_decoder(struct test_suite *test, int subtest);
int test__bp_modify(struct test_suite *test, int subtest);
int test__x86_sample_parsing(struct test_suite *test, int subtest);
extern struct test_suite *arch_tests[];
#endif
| 27.823529 | 69 | 0.792812 |
3a49d240b173d02c5e087e9a172bed7cf0f0861b | 3,478 | h | C | sun_ray/feature/intersection_state.h | fuersten/sun_ray | b882d67cd9747f61b50def4c1414e7552ba917c0 | [
"BSD-3-Clause"
] | 2 | 2021-03-28T21:36:36.000Z | 2021-08-10T14:44:04.000Z | sun_ray/feature/intersection_state.h | fuersten/sun_ray | b882d67cd9747f61b50def4c1414e7552ba917c0 | [
"BSD-3-Clause"
] | null | null | null | sun_ray/feature/intersection_state.h | fuersten/sun_ray | b882d67cd9747f61b50def4c1414e7552ba917c0 | [
"BSD-3-Clause"
] | null | null | null | //
// intersection_state.h
// sun_ray
//
// Created by Lars-Christian Fürstenberg on 18.01.20.
// Copyright © 2020 Lars-Christian Fürstenberg. All rights reserved.
//
#pragma once
#include <sun_ray/feature/object.h>
namespace sunray
{
class IntersectionState
{
public:
IntersectionState(Intersection intersection, const Ray& ray, const Intersections& intersections)
: intersection_{std::move(intersection)}
{
point_ = ray.position(intersection_.time());
eye_ = -ray.direction();
normal_ = intersection_.object()->normal_at(point_);
if (normal_.scalarProduct(eye_) < 0) {
inside_ = true;
normal_ = normal_.negate();
}
over_point_ = point_ + normal_ * epsilon;
under_point_ = point_ - normal_ * epsilon;
reflect_ = ray.direction().reflect(normal_);
calculate_refraction_indices(intersections);
}
~IntersectionState() = default;
IntersectionState(const IntersectionState&) = delete;
IntersectionState(IntersectionState&&) = delete;
IntersectionState& operator=(const IntersectionState&) = delete;
IntersectionState& operator=(IntersectionState&&) = delete;
const Intersection& intersection() const
{
return intersection_;
}
inline const Point& point() const
{
return point_;
}
inline const Point& over_point() const
{
return over_point_;
}
inline const Point& under_point() const
{
return under_point_;
}
inline const Vector& eye() const
{
return eye_;
}
inline const Vector& normal() const
{
return normal_;
}
inline const Vector& reflect() const
{
return reflect_;
}
inline bool is_inside() const
{
return inside_;
}
inline float n1() const
{
return n1_;
}
inline float n2() const
{
return n2_;
}
float schlick() const
{
auto cos = eye_.scalarProduct(normal_);
if (n1_ > n2_) {
const auto n = n1_ / n2_;
const auto sin2_t = n * n * (1.0 - cos * cos);
if (sin2_t > 1.0) {
return 1.0;
}
cos = sqrt(1.0 - sin2_t);
}
const auto r0 = pow<2>((n1_ - n2_) / (n1_ + n2_));
return static_cast<float>(r0 + (1.0 - r0) * pow<5>(1.0 - cos));
}
private:
void calculate_refraction_indices(const Intersections& intersections)
{
std::vector<const Object*> objects;
objects.reserve(20);
for (const auto& intersection : intersections.intersections()) {
if (intersection == intersection_) {
if (objects.empty()) {
n1_ = 1.0f;
} else {
n1_ = objects.back()->material().refractive_index();
}
}
auto it = std::find(objects.begin(), objects.end(), intersection.object());
if (it != objects.end()) {
objects.erase(it);
} else {
objects.emplace_back(intersection.object());
}
if (intersection == intersection_) {
if (objects.empty()) {
n2_ = 1.0;
} else {
n2_ = objects.back()->material().refractive_index();
}
break;
}
}
}
Intersection intersection_;
Point point_;
Point over_point_;
Point under_point_;
Vector eye_;
Vector normal_;
Vector reflect_;
bool inside_{false};
float n1_{1.0};
float n2_{1.0};
};
}
| 22.152866 | 100 | 0.579643 |
5c8017e7af15c3ba491845ef1cfcd068afa1aa78 | 1,740 | h | C | macOS/10.13/AppKit.framework/NSTouchBarCustomizationPreviewDeletionLabel.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.13/AppKit.framework/NSTouchBarCustomizationPreviewDeletionLabel.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.13/AppKit.framework/NSTouchBarCustomizationPreviewDeletionLabel.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/AppKit.framework/Versions/C/AppKit
*/
@interface NSTouchBarCustomizationPreviewDeletionLabel : NSView <NSCollectionViewElement> {
NSTextField * _labelField;
struct CGAffineTransform {
double a;
double b;
double c;
double d;
double tx;
double ty;
} _labelTransform;
CALayer * _maskLayer;
}
@property (atomic, readonly, copy) NSString *debugDescription;
@property (atomic, readonly, copy) NSString *description;
@property (atomic, readonly) unsigned long long hash;
@property (atomic, readwrite, copy) NSString *identifier;
@property (atomic, readwrite, copy) NSString *label;
@property (atomic, readwrite) struct CGAffineTransform { double x1; double x2; double x3; double x4; double x5; double x6; } labelTransform;
@property (atomic, readonly) Class superclass;
// Image: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
- (BOOL)_shouldDoLayerPerformanceUpdates;
- (void)dealloc;
// Image: /Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib
- (void)applyLayoutAttributes:(id)arg1;
- (id)hitTest:(struct CGPoint { double x1; double x2; })arg1;
- (id)initWithFrame:(struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })arg1;
- (id)label;
- (struct CGAffineTransform { double x1; double x2; double x3; double x4; double x5; double x6; })labelTransform;
- (void)setLabel:(id)arg1;
- (void)setLabelTransform:(struct CGAffineTransform { double x1; double x2; double x3; double x4; double x5; double x6; })arg1;
- (void)updateLayer;
- (BOOL)wantsLayer;
- (BOOL)wantsUpdateLayer;
@end
| 38.666667 | 153 | 0.731609 |
364c099aa4855e12ede1957cafdf8432d973ba1c | 221 | h | C | Examples/Controllers/Posts/View/PostTextLabel.h | geolives/XLDataLoader | 3798c76d541fa9c04b27b2f6cb2f5c065742a31d | [
"MIT"
] | null | null | null | Examples/Controllers/Posts/View/PostTextLabel.h | geolives/XLDataLoader | 3798c76d541fa9c04b27b2f6cb2f5c065742a31d | [
"MIT"
] | null | null | null | Examples/Controllers/Posts/View/PostTextLabel.h | geolives/XLDataLoader | 3798c76d541fa9c04b27b2f6cb2f5c065742a31d | [
"MIT"
] | 1 | 2020-01-09T12:09:21.000Z | 2020-01-09T12:09:21.000Z | //
// PostTextLabel.h
// XLTableViewControllerTest
//
// Created by Gaston Borba on 4/16/14.
// Copyright (c) 2014 XmartLabs. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PostTextLabel : UILabel
@end
| 15.785714 | 54 | 0.701357 |
0e7bfbc2b2df414fa16d486d0e819b483c5367ae | 3,145 | h | C | contrib/gitian-builder/inputs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSArchiver.h | Phikzel2/haroldcoin-main-MacOS | 15c949c8f722d424fd9603fab3c49ec4b2b720eb | [
"MIT"
] | null | null | null | contrib/gitian-builder/inputs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSArchiver.h | Phikzel2/haroldcoin-main-MacOS | 15c949c8f722d424fd9603fab3c49ec4b2b720eb | [
"MIT"
] | null | null | null | contrib/gitian-builder/inputs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSArchiver.h | Phikzel2/haroldcoin-main-MacOS | 15c949c8f722d424fd9603fab3c49ec4b2b720eb | [
"MIT"
] | 1 | 2021-08-13T21:12:07.000Z | 2021-08-13T21:12:07.000Z | /* NSArchiver.h
Copyright (c) 1994-2018, Apple Inc. All rights reserved.
*/
#import <Foundation/NSCoder.h>
#import <Foundation/NSException.h>
@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
NS_ASSUME_NONNULL_BEGIN
/************ Archiving: Writing ****************/
API_DEPRECATED("Use NSKeyedArchiver instead", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0))
@interface NSArchiver : NSCoder {
@private
void *mdata;
void *pointerTable;
void *stringTable;
void *ids;
void *map;
void *replacementTable;
void *reserved;
}
- (instancetype)initForWritingWithMutableData:(NSMutableData *)mdata NS_DESIGNATED_INITIALIZER;
@property (readonly, retain) NSMutableData *archiverData;
- (void)encodeRootObject:(id)rootObject;
- (void)encodeConditionalObject:(nullable id)object;
+ (NSData *)archivedDataWithRootObject:(id)rootObject;
+ (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path;
- (void)encodeClassName:(NSString *)trueName intoClassName:(NSString *)inArchiveName;
- (nullable NSString *)classNameEncodedForTrueClassName:(NSString *)trueName;
- (void)replaceObject:(id)object withObject:(id)newObject;
@end
/************ Archiving: Reading ****************/
API_DEPRECATED("Use NSKeyedUnarchiver instead", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0))
@interface NSUnarchiver : NSCoder {
@private
void * datax;
NSUInteger cursor;
NSZone *objectZone;
NSUInteger systemVersion;
signed char streamerVersion;
char swap;
char unused1;
char unused2;
void *pointerTable;
void *stringTable;
id classVersions;
NSInteger lastLabel;
void *map;
void *allUnarchivedObjects;
id reserved;
}
- (nullable instancetype)initForReadingWithData:(NSData *)data NS_DESIGNATED_INITIALIZER;
- (void)setObjectZone:(nullable NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- (nullable NSZone *)objectZone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
@property (getter=isAtEnd, readonly) BOOL atEnd;
@property (readonly) unsigned int systemVersion;
+ (nullable id)unarchiveObjectWithData:(NSData *)data;
+ (nullable id)unarchiveObjectWithFile:(NSString *)path;
+ (void)decodeClassName:(NSString *)inArchiveName asClassName:(NSString *)trueName;
- (void)decodeClassName:(NSString *)inArchiveName asClassName:(NSString *)trueName;
+ (NSString *)classNameDecodedForArchiveClassName:(NSString *)inArchiveName;
- (NSString *)classNameDecodedForArchiveClassName:(NSString *)inArchiveName;
- (void)replaceObject:(id)object withObject:(id)newObject;
@end
/************ Exceptions ****************/
FOUNDATION_EXPORT NSExceptionName const NSInconsistentArchiveException;
/************ Object call back ****************/
@interface NSObject (NSArchiverCallback)
@property (nullable, readonly) Class classForArchiver;
- (nullable id)replacementObjectForArchiver:(NSArchiver *)archiver API_DEPRECATED_WITH_REPLACEMENT("replacementObjectForCoder:", macos(10.0,10.13), ios(2.0,11.0), watchos(2.0,4.0), tvos(9.0,11.0));
@end
NS_ASSUME_NONNULL_END
| 30.240385 | 197 | 0.722734 |
3d8c5c922f98cc44f417134cdc044c12309253dd | 1,628 | c | C | src/util/qsort.c | mortzdk/heavy-hitters | 61d90af9b281d903107064fac5dd993563d6f98c | [
"MIT"
] | 12 | 2016-11-03T09:31:55.000Z | 2022-01-11T05:40:00.000Z | src/util/qsort.c | mortzdk/heavy-hitters | 61d90af9b281d903107064fac5dd993563d6f98c | [
"MIT"
] | null | null | null | src/util/qsort.c | mortzdk/heavy-hitters | 61d90af9b281d903107064fac5dd993563d6f98c | [
"MIT"
] | 5 | 2016-06-30T01:31:46.000Z | 2020-07-20T22:14:57.000Z | // Borrowed from: http://www.cs.princeton.edu/~rs/Algs3.c1-4/code.txt
#include <stdint.h>
#include "qsort.h"
void quicksort_map(uint32_t *a, int64_t l, int64_t r, uint32_t *map) {
int64_t i, j, k, p, q;
uint32_t v;
if (r <= l) {
return;
}
v = a[r];
i = l-1;
j = r;
p = l-1;
q = r;
while (1) {
while (less_map(a[++i], v));
while (less_map(v, a[--j])) {
if (j == l) {
break;
}
}
if (i >= j) {
break;
}
exch_map(a[i], a[j]);
exch_map(map[i], map[j]);
if (eq(a[i], v)) {
p++;
exch_map(a[p], a[i]);
exch_map(map[p], map[i]);
}
if (eq(v, a[j])) {
q--;
exch_map(a[q], a[j]);
exch_map(map[q], map[j]);
}
}
exch_map(a[i], a[r]);
exch_map(map[i], map[r]);
j = i-1;
i = i+1;
for (k = l ; k < p; k++, j--) {
exch_map(a[k], a[j]);
exch_map(map[k], map[j]);
}
for (k = r-1; k > q; k--, i++) {
exch_map(a[k], a[i]);
exch_map(map[k], map[i]);
}
quicksort_map(a, l, j, map);
quicksort_map(a, i, r, map);
}
void quicksort(Item a[], int64_t l, int64_t r) {
int64_t i, j, k, p, q;
Item v;
if (r <= l) {
return;
}
v = a[r];
i = l-1;
j = r;
p = l-1;
q = r;
while (1) {
while (less(a[++i], v));
while (less(v, a[--j])) {
if (j == l) {
break;
}
}
if (i >= j) {
break;
}
exch(a[i], a[j]);
if (eq(a[i], v)) {
p++;
exch(a[p], a[i]);
}
if (eq(v, a[j])) {
q--;
exch(a[q], a[j]);
}
}
exch(a[i], a[r]);
j = i-1;
i = i+1;
for (k = l ; k < p; k++, j--) {
exch(a[k], a[j]);
}
for (k = r-1; k > q; k--, i++) {
exch(a[k], a[i]);
}
quicksort(a, l, j);
quicksort(a, i, r);
}
| 13.344262 | 71 | 0.437346 |
cdf6635f5dbb8c34d03f49a79ce527d8de151d5a | 4,525 | h | C | platform/mcu/xr872/drivers/include/cedarx/libcore/playback/include/soundControl.h | HelloAllen8893/AliOS-Things | f3a2904860c3bf87b64d634e6900d980931fac88 | [
"Apache-2.0"
] | 2 | 2018-08-20T08:33:55.000Z | 2018-11-28T03:19:22.000Z | platform/mcu/xr872/drivers/include/cedarx/libcore/playback/include/soundControl.h | HelloAllen8893/AliOS-Things | f3a2904860c3bf87b64d634e6900d980931fac88 | [
"Apache-2.0"
] | null | null | null | platform/mcu/xr872/drivers/include/cedarx/libcore/playback/include/soundControl.h | HelloAllen8893/AliOS-Things | f3a2904860c3bf87b64d634e6900d980931fac88 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2008-2016 Allwinner Technology Co. Ltd.
* All rights reserved.
*
* File : soundControl.h
* Description : soundControl
* History :
*
*/
#ifndef SOUND_CONTROL_H
#define SOUND_CONTROL_H
#include "cdx_log.h"
#include "adecoder.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum XAudioTimestretchStretchMode {
AUDIO_TIMESTRETCH_STRETCH_DEFAULT = 0,
AUDIO_TIMESTRETCH_STRETCH_SPEECH = 1,
} XAudioTimestretchStretchMode;
typedef enum XAudioTimestretchFallbackMode {
XAUDIO_TIMESTRETCH_FALLBACK_CUT_REPEAT = -1,
XAUDIO_TIMESTRETCH_FALLBACK_DEFAULT = 0,
XAUDIO_TIMESTRETCH_FALLBACK_MUTE = 1,
XAUDIO_TIMESTRETCH_FALLBACK_FAIL = 2,
} XAudioTimestretchFallbackMode;
typedef struct XAudioPlaybackRate {
float mSpeed;
float mPitch;
enum XAudioTimestretchStretchMode mStretchMode;
enum XAudioTimestretchFallbackMode mFallbackMode;
}XAudioPlaybackRate;
typedef struct SoundCtrl SoundCtrl;
typedef struct SoundControlOpsS SoundControlOpsT;
struct SoundControlOpsS
{
void (*cdxDestroy)(SoundCtrl* s);
void (*cdxSetFormat)(SoundCtrl* s, CdxPlaybkCfg* cfg);
int (*cdxStart)(SoundCtrl* s);
int (*cdxStop)(SoundCtrl* s);
int (*cdxPause)(SoundCtrl* s);
int (*cdxFlush)(SoundCtrl* s, void *block);
int (*cdxWrite)(SoundCtrl* s, void* pData, int nDataSize);
int (*cdxReset)(SoundCtrl* s);
int (*cdxGetCachedTime)(SoundCtrl* s);
int (*cdxGetFrameCount)(SoundCtrl* s);
int (*cdxSetPlaybackRate)(SoundCtrl* s,const XAudioPlaybackRate *rate);
int (*cdxControl)(SoundCtrl* s, int cmd, void* para);
};
struct SoundCtrl
{
const struct SoundControlOpsS* ops;
};
typedef enum _SoundCtrlCmd
{
/*
Set para area...
*/
SOUND_CONTROL_SET_OPTION_START = 100,
SOUND_CONTROL_SET_CLBK_EOS,
/*
Get para area...
*/
SOUND_CONTROL_GET_OPTION_START = 200,
/*
Query area...
*/
SOUND_CONTROL_QUERY_OPTION_START = 300,
SOUND_CONTROL_QUERY_IF_GAPLESS_PLAY,
/*
Sound Stream Control area...
*/
SOUND_CONTROL_SET_OUTPUT_CONFIG = 400,
SOUND_CONTROL_ADD_OUTPUT_CONFIG,
SOUND_CONTROL_CLEAR_OUTPUT_CONFIG,
SOUND_CONTROL_SET_EQ_MODE,
SOUND_CONTROL_CLEAR_EQ_MODE,
}SoundCtrlCmd;
static inline void SoundDeviceDestroy(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxDestroy);
return s->ops->cdxDestroy(s);
}
static inline void SoundDeviceSetFormat(SoundCtrl* s, CdxPlaybkCfg* cfg)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxSetFormat);
return s->ops->cdxSetFormat(s, cfg);
}
static inline int SoundDeviceStart(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxStart);
return s->ops->cdxStart(s);
}
static inline int SoundDeviceStop(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxStop);
return s->ops->cdxStop(s);
}
static inline int SoundDevicePause(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxPause);
return s->ops->cdxPause(s);
}
static inline int SoundDeviceFlush(SoundCtrl* s, void* block)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxFlush);
return s->ops->cdxFlush(s, block);
}
static inline int SoundDeviceWrite(SoundCtrl* s, void* pData, int nDataSize)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxWrite);
return s->ops->cdxWrite(s, pData, nDataSize);
}
static inline int SoundDeviceReset(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxReset);
return s->ops->cdxReset(s);
}
static inline int SoundDeviceGetCachedTime(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxGetCachedTime);
return s->ops->cdxGetCachedTime(s);
}
static inline int SoundDeviceGetFrameCount(SoundCtrl* s)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxGetFrameCount);
return s->ops->cdxGetFrameCount(s);
}
static inline int SoundDeviceSetPlaybackRate(SoundCtrl* s,const XAudioPlaybackRate *rate)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxSetPlaybackRate);
return s->ops->cdxSetPlaybackRate(s,rate);
}
static inline int SoundDeviceControl(SoundCtrl* s, int cmd, void* para)
{
CDX_CHECK(s);
CDX_CHECK(s->ops);
CDX_CHECK(s->ops->cdxControl);
return s->ops->cdxControl(s, cmd, para);
}
SoundCtrl* SoundDeviceCreate();
#ifdef __cplusplus
}
#endif
#endif
| 22.073171 | 89 | 0.695912 |
e0648fbbc94176e326cf8e798e36a959cc4b345d | 3,331 | c | C | gempak/source/programs/gd/gdgrib2/gdsetsect5.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 42 | 2015-06-03T15:26:21.000Z | 2022-02-28T22:36:03.000Z | gempak/source/programs/gd/gdgrib2/gdsetsect5.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 60 | 2015-05-11T21:36:08.000Z | 2022-03-29T16:22:42.000Z | gempak/source/programs/gd/gdgrib2/gdsetsect5.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 27 | 2016-06-06T21:55:14.000Z | 2022-03-18T18:23:28.000Z | #include "gdgrib2.h"
#define MAXTMPL 200
void gdsetsect5 ( GDG2_input *input, int *idrtnum, int *idrtmpl, int *iret )
/************************************************************************
* gdsetsect5 *
* *
* This routine sets up an array containing information to encode *
* GRIB2 Sections 5 and 7. The required info is obtained from user *
* parameter G2DRT. *
* *
* Usage: *
* gdsetsect5( input, idrtnum, idrtmpl, iret ); *
* *
* Input Arguments: *
* *input GDG2_input input structure for GDGRIB2 *
* *
* Output Arguments: *
* *idrtnum int Data Representation Template *
* number. *
* *idrtmpl int Data Representation Template *
* values. *
* *iret int Error return code. *
* 0 = Normal *
** *
* Log: *
* S. Gilbert/NCEP 8/2005 Orig *
***********************************************************************/
{
const int ng2drt=6;
int ret, num, j;
int g2drt[ng2drt], g2drt_defs[6]={0,0,0,1,0,255};
*iret = 0;
/*
* parse user input for parameter G2DRT
*/
cst_ilst( input->g2drt, '|', IMISSD, ng2drt, g2drt, &num, &ret);
/*
* set default values, if necessary
*/
for ( j=0; j < ng2drt; j++ ) {
if ( g2drt[j] == IMISSD ) g2drt[j] = g2drt_defs[j];
}
/*
* Assign values to Data Representaion Template array
*/
*idrtnum = g2drt[0];
for (j=0;j<MAXTMPL;j++) idrtmpl[j]=0; /* initialize to zero */
idrtmpl[1]=g2drt[2]; /* binary scale factor */
idrtmpl[2]=g2drt[1]; /* decimal scale factor */
/*
* Set the Order of Differencing. if using DRT 5.3
*/
if ( *idrtnum == 3 ) idrtmpl[16]=g2drt[3];
/*
* Set the Missing Value Management. if using DRT 5.2 or 5.3
*/
if ( *idrtnum == 2 || *idrtnum == 3)
idrtmpl[6]=g2drt[4];
/*
* Set the lossless/lossy flag/ratio. if using DRT 5.40
*/
if ( *idrtnum == 40 ) {
if ( g2drt[5] == 255 ) { /* lossless compression */
idrtmpl[5]=0;
idrtmpl[6]=g2drt[5];
}
else { /* lossy compression */
idrtmpl[5]=1;
idrtmpl[6]=g2drt[5];
}
}
}
| 39.654762 | 76 | 0.332933 |
6dc9b5c59dcdbbda161617c526f56d18d54c1e58 | 2,485 | h | C | include/jjwu_debug_config.h | goodwater/jjwu_debug | ce3ca2ba777940cb98e97ceaf212e3f99053042a | [
"MIT"
] | 2 | 2016-06-29T15:32:27.000Z | 2016-06-29T15:32:28.000Z | include/jjwu_debug_config.h | goodwater/jjwu_debug | ce3ca2ba777940cb98e97ceaf212e3f99053042a | [
"MIT"
] | null | null | null | include/jjwu_debug_config.h | goodwater/jjwu_debug | ce3ca2ba777940cb98e97ceaf212e3f99053042a | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2016 WU, JHENG-JHONG <goodwater.wu@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef __JJWU_DEBUG_CONFIG_H__
#define __JJWU_DEBUG_CONFIG_H__
/* The follow definition can change according to your need */
#define KERNEL_SPACE 0
#define PRINT_TIMESTAMP 1
#define PRINT_FILE_NAME 1
#define PRINT_FILE_LINE 1
#define PRINT_FUNCTION_NAME 1
#define PRINT_RESERVE_0 0
#define PRINT_RESERVE_1 0
#define PRINT_RESERVE_2 0
#define PRINT_RESERVE_3 0
#define DEBUG_LEVEL 7
/* The following definition should not change manually. */
#define LEVEL_EMERG 0
#define LEVEL_ALERT 1
#define LEVEL_CRIT 2
#define LEVEL_ERR 3
#define LEVEL_WARNING 4
#define LEVEL_NOTICE 5
#define LEVEL_INFO 6
#define LEVEL_DEBUG 7
#define EMERG "EMERG"
#define ALERT "ALERT"
#define CRIT "CRIT"
#define ERR "ERR"
#define WARNING "WARNING"
#define NOTICE "NOTICE"
#define INFO "INFO"
#define DEBUG "DEBUG"
#define PRINT_TIMESTAMP_SHIFT 0
#define PRINT_FILE_NAME_SHIFT 1
#define PRINT_FILE_LINE_SHIFT 2
#define PRINT_FUNCTION_NAME_SHIFT 3
#define PRINT_RESERVE_0_SHIFT 4
#define PRINT_RESERVE_1_SHIFT 5
#define PRINT_RESERVE_2_SHIFT 6
#define PRINT_RESERVE_3_SHIFT 7
#define PRINT_TIMESTAMP_MASK 0x1
#define PRINT_FILE_NAME_MASK 0x2
#define PRINT_FILE_LINE_MASK 0x4
#define PRINT_FUNCTION_NAME_MASK 0x8
#define PRINT_RESERVE_0_MASK 0x10
#define PRINT_RESERVE_1_MASK 0x20
#define PRINT_RESERVE_2_MASK 0x40
#define PRINT_RESERVE_3_MASK 0x80
#endif
| 32.697368 | 117 | 0.796781 |
6df31757421f9ad5a7b2b6c4c1f6a019b491210a | 5,461 | c | C | src/dda_bc.c | evanlev/bart | 68f8bbc6fd1335fb9d200f998e25051dcce1091b | [
"BSD-3-Clause"
] | null | null | null | src/dda_bc.c | evanlev/bart | 68f8bbc6fd1335fb9d200f998e25051dcce1091b | [
"BSD-3-Clause"
] | null | null | null | src/dda_bc.c | evanlev/bart | 68f8bbc6fd1335fb9d200f998e25051dcce1091b | [
"BSD-3-Clause"
] | null | null | null | #include <getopt.h>
#include <stdio.h>
#include <complex.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <math.h>
#include "num/multind.h"
#include "num/flpmath.h"
#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/debug.h"
#include "misc/mmio.h"
#include "misc/opts.h"
#include "dda_tools/dda_utils.h"
static const char* usage_str = "Generate a sampling pattern for sensitivity maps. Map dims are xres,yres,zres,coils,maps,time,maps2,\n"
"where the image is formed as DF{ sum_{k,l} sns_maps(:,:,:,:,k,:,l) m(:,:,:,1,k,1,l)}. It is sometimes \n"
"convenient to use both k and l (maps and maps2) indices (dimensions). Best candidate sampling is used, \n"
"and can be made faster with -T or -K options.";
static void int2cfl(const long N, complex float *dst, const int *src){
for( long i = 0 ; i < N ; ++i )
dst[i] = (complex float) src[i];
}
int main_dda_bc(int argc, char* argv[])
{
int maxST = 0;
int totSamps = 0;
bool exact = false;
float T = 0;
int K = 0;
const char* pat_file = NULL;
const char* maps_file = NULL;
struct arg_s args[] = {
ARG_INFILE(true, &maps_file, "sensitivity maps"),
ARG_OUTFILE(true, &pat_file, "pattern"),
};
const struct opt_s opts[] = {
OPT_INT('d', &debug_level, "level", "debug level"),
OPT_INT('t', &maxST, "maxST", "max samples per frame"),
OPT_INT('M', &totSamps, "tot", "max total samples (optional)"),
OPT_SET('e', &exact, "Exact BC sampling"),
OPT_INT('K', &K, "K", "Limit the size of the support set of w to this"),
OPT_FLOAT('T', &T, "T", "Set w(Delta k, t, t') < T to 0"),
};
cmdline(&argc, argv, ARRAY_SIZE(args), args, usage_str, ARRAY_SIZE(opts), opts);
// Check options: see setup later
if( (K != 0 || T != 0) && exact ){
debug_printf(DP_ERROR, "For exact BC sampling, do not provide thresholding parameters -T or -K\n");
exit(0);
}
if( K && T > 0 ){
debug_printf(DP_ERROR, "Provide only -K or -T\n");
exit(0);
}
if( maxST == 0 && totSamps == 0){
debug_printf(DP_ERROR, "Need to specify either total samples (-M) or max samples per frame (-t)\n");
exit(0);
}
if(totSamps){
debug_printf(DP_INFO, "Total samples: %d\n", totSamps);
}
if(maxST){
debug_printf(DP_INFO, "Max samples per phase: %d\n", maxST);
}
// Read in sensitivity maps
long sns_dims[DIMS];
complex float *sns_maps = load_cfl(argv[1], DIMS, sns_dims);
check_sns_dims(sns_dims);
long nt = sns_dims[TE_DIM];
// Convert sensitivity maps to w
debug_printf(DP_INFO, "Compute w from sensitivity maps...\n");
long w_dims[DIMS];
get_w_dims(w_dims, sns_dims);
double *w = md_alloc(DIMS, w_dims, sizeof(double));
buildW(w, sns_dims, sns_maps);
// Free sensitivty maps
unmap_cfl(DIMS, sns_dims, sns_maps);
// Allocate sampling pattern
long pat_dims[DIMS];
md_singleton_dims(DIMS, pat_dims);
pat_dims[0] = sns_dims[1];
pat_dims[1] = sns_dims[2];
pat_dims[2] = nt;
long pat_size = md_calc_size(DIMS, pat_dims);
int *pat_int = xmalloc(pat_size*sizeof(int));
// Allocate deltaJ = change in cost associated with sampling (ky,kz,t)
double cost;
debug_printf(DP_INFO, "Allocating Delta J, size %d\n", pat_size);
double *deltaJ = xmalloc(pat_size * sizeof(double));
// Set up constraints on sampling from options
if(maxST == 0){
maxST = totSamps; // totSamps = no constraint
}else if(totSamps == 0){
totSamps = maxST * nt;
}
// Max samples per frame: same for all frames
long maxSampsPerFrame[nt];
for( long t = 0 ; t < nt ; t++ ){
maxSampsPerFrame[t] = maxST;
}
// Generate the sampling pattern
if( !exact ){
// Set up wsp a thresholded version of w
SparseW wsp;
if( K ){
sparsify_w_to_k(KSP_DIMS, w_dims, &wsp, w, (long) K);
}else{
sparsify_w(KSP_DIMS, w_dims, &wsp, w, T);
}
// Generate it
approxBestCandidate(KSP_DIMS, &cost, deltaJ, pat_int, &wsp,
maxSampsPerFrame, totSamps);
/*
*/
}else{
// Set up array with list of samples acquired
long *samples[nt];
for( long t = 0 ; t < nt ; t++ ){
if( maxSampsPerFrame[t] > 0 ){
samples[t] = xmalloc(KSP_DIMS * maxSampsPerFrame[t] * sizeof(long));
}
}
// Generate it
exactBestCandidate(KSP_DIMS, w_dims, &cost, deltaJ, pat_int, w, samples,
maxSampsPerFrame, totSamps);
// Free array with list of samples acquired
for( long t = 0 ; t < nt ; t++ ){
if( maxSampsPerFrame[t] > 0 ){
free(samples[t]);
}
}
}
// Convert output for complex
debug_printf(DP_DEBUG3, "Converting output pattern\n");
complex float *pat_cfl = create_cfl(pat_file, DIMS, pat_dims);
int2cfl(pat_size, pat_cfl, pat_int);
// cleanup
debug_printf(DP_DEBUG3, "Clean up ...\n");
unmap_cfl(DIMS, pat_dims, pat_cfl);
md_free(w);
free(deltaJ);
free(pat_int);
debug_printf(DP_DEBUG3, "Done.\n");
return 0;
}
| 31.028409 | 139 | 0.575719 |
a33d5aeb76157169b8fedfccfb82d7ee2563d65b | 3,196 | h | C | src/World/World.h | olesgedz/Cube | 12f0b48cc89a8fbb381e3e47e482bb6f3fcf04d6 | [
"Apache-2.0"
] | null | null | null | src/World/World.h | olesgedz/Cube | 12f0b48cc89a8fbb381e3e47e482bb6f3fcf04d6 | [
"Apache-2.0"
] | null | null | null | src/World/World.h | olesgedz/Cube | 12f0b48cc89a8fbb381e3e47e482bb6f3fcf04d6 | [
"Apache-2.0"
] | null | null | null | //
// Created by Jeromy Black on 1/7/21.
//
#ifndef FT_VOX_WORLD_H
#define FT_VOX_WORLD_H
#include <unordered_map>
#include <memory>
#define GLM_ENABLE_EXPERIMENTAL
#include "glm/glm.hpp"
#include "glm/gtx/hash.hpp"
#include "Chunk.h"
#include "camera.h"
class World
{
public:
int radius = 7;
int octaves = 0;
float scale1 = 0.2f;
float scale2 = 0.267f;
float scale3 = 0.130f;
int seed = 1337;
bool need_render = true;
std::unordered_map<vec3, shared_ptr<Chunk>> world;
Camera * player_cam;
glm::vec3 last_player_position = vec3(0,0,0);
Shader * shader;
World(World const&) = delete;
World& operator=(World const&) = delete;
static std::shared_ptr<World> instance()
{
static std::shared_ptr<World> s{new World};
return s;
}
bool NeedRender()
{
return(need_render);
}
void UpdateWorld()
{
// vec3 pos = vec3(int(player_cam->Position.x), int(player_cam->Position.y), int(player_cam->Position.z));
// last_player_position = pos;
// int r_c = radius * 16;
// std::cout << pos.x << " " << pos.y << " " << pos.z << std::endl;
// vec3 pos_start = vec3(pos.x - r_c, pos.y, pos.z - r_c);
// vec3 pos_finish = vec3(pos.x + r_c, pos.y, pos.z + r_c);
// for (;pos_start.x < pos_finish.x; )
// {
// pos_start.z = pos.z - r_c;
// for ( ;pos_start.z < pos_finish.z; ) // Z
// {
// world.insert(std::pair<vec3, std::shared_ptr<Chunk>>(pos_start, new Chunk(vec3(pos_start.x, 0, pos_start.z))));
// shared_ptr<Chunk> c = world[pos_start];
// c->generate();
// c->model.meshes[0].bind_shader(shader);
// c->model.meshes[0].shader->use();
//
//
//
// //c->model.meshes[0].load_texture("resources/textures/spritesheet.png");//("resources/textures/Test.png");
//// c->model.meshes[0].bind_texture();
// c->model.meshes[0].texture = texture;
// c->model.meshes[0].upload();
// pos_start.z+=16;
// }
// pos_start.x+=16;
// }
}
private:
World() {
// shader = new Shader("../shaders/SimpleVertex.glsl", "../shaders/SimpleFragment.glsl");
// shader->use();
// glGenTextures(1, &this->texture);
// glBindTexture(GL_TEXTURE_2D, this->texture);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // set texture wrapping to GL_REPEAT (default wrapping method)
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// // set texture filtering parameters
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//// int width, height, nrChannels;
// string s;
// s.append("./");
// s.append(filename);
// stbi_set_flip_vertically_on_load(true);
// cout <<filename <<endl;
// data = stbi_load(s.c_str(), &width, &height, &nrChannels, 0);
// if (data)
// {
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
// glGenerateMipmap(GL_TEXTURE_2D);
// }
// else
// {
// std::cout << "Failed to load texture" << std::endl;
// }
//stbi_image_free(data);
}
GLuint texture;
string filename = "../resources/textures/spritesheet.png";
int width, height, nrChannels;
unsigned char *data ;
};
#endif //FT_VOX_WORLD_H
| 28.535714 | 128 | 0.649562 |
a349edc4314eac9cd622af3c481cab24585344e2 | 34,574 | h | C | scripts/dp88_customAI.h | mpforums/RenSharp | 5b3fb8bff2a1772a82a4148bcf3e1265a11aa097 | [
"Apache-2.0"
] | 1 | 2021-10-04T02:34:33.000Z | 2021-10-04T02:34:33.000Z | scripts/dp88_customAI.h | mpforums/RenSharp | 5b3fb8bff2a1772a82a4148bcf3e1265a11aa097 | [
"Apache-2.0"
] | 9 | 2019-07-03T19:19:59.000Z | 2020-03-02T22:00:21.000Z | scripts/dp88_customAI.h | mpforums/RenSharp | 5b3fb8bff2a1772a82a4148bcf3e1265a11aa097 | [
"Apache-2.0"
] | 2 | 2019-08-14T08:37:36.000Z | 2020-09-29T06:44:26.000Z | /* Renegade Scripts.dll
Copyright 2013 Tiberian Technologies
This file is part of the Renegade scripts.dll
The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version. See the file COPYING for more details.
In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
Only the source code to the module(s) containing the licenced code has to be released.
*/
#pragma once
#include "LoopedAnimationController.h"
#include "ObserverImpClass.h"
// Forward declaration
class dp88_AI_Objective;
class dp88_AI_ChargedTurret_AnimationObserver;
/*------------------------
Base class for custom AI's
--------------------------*/
/*!
* \brief danpaul88's Custom AI Core
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* This class contains the core logic used in custom AI scripts, such as the target prioritisation
* mechanism. It is not an actual script in it's own right and cannot be used in LevelEdit directly.
*
* \note
* AI scripts derived from this class support being disabled and enabled on the fly by sending the
* following custom messages to the object the script is attached to.<br/>
* <table>
* <tr> <th>Custom Message</th> <th>Effect</th></tr>
* <tr> <td>-637140989</td> <td>Disable the AI</td></tr>
* <tr> <td>-637140988</td> <td>Enable the AI</td></tr>
* </table>
*/
class dp88_customAI : public ScriptImpClass
{
public:
/* -----
Constructor / Destructor (cleanup debug file if applicable
----- */
dp88_customAI() { debugFile = NULL; };
~dp88_customAI() { if ( debugFile != NULL ) { fclose(debugFile); } };
/* -----
Variables
----- */
// Priority and weapon choice for each target type
float priority_infantry; bool primary_infantry;
float priority_lightVehicle; bool primary_lightVehicle;
float priority_heavyVehicle; bool primary_heavyVehicle;
float priority_VTOL; bool primary_VTOL;
float priority_building; bool primary_building;
// Priority modifiers
float modifier_distance, modifier_target_damage, modifier_target_value;
// Attack ranges
int primary_minRange, primary_maxRange;
int secondary_minRange, secondary_maxRange;
// Current target state
int targetID;
int targetLastSeen;
float targetPriority;
bool m_bTargetPrimaryFire;
// Other settings
bool m_bAiEnabled;
bool m_bCanDetectStealth;
// Debug state
bool debug;
FILE* debugFile;
/* -----
Events
----- */
virtual void Created( GameObject *obj );
virtual void Timer_Expired(GameObject *obj, int number);
virtual void Custom ( GameObject* pObj, int message, int param, GameObject* pSender );
virtual void Action_Complete( GameObject *obj, int action_id, ActionCompleteReason complete_reason );
//virtual void Enemy_Seen ( GameObject *obj, GameObject *enemy );
//virtual void Timer_Expired( GameObject *obj, int number );
/* ----
Functions
----- */
virtual void Init( GameObject *obj );
virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings );
virtual void AIStateChanged( GameObject* pObj, bool bEnabled );
/*!
* Called by derived classes to cancel all ongoing actions, can be overridden in a derived class
* to reset variable states as necessary
*/
virtual void ResetAllActions(GameObject* obj);
static float getDistance ( GameObject *obj1, GameObject *obj2 );
virtual float getBasePriority(GameObject *target );
virtual float getPriority( GameObject *obj, GameObject *target );
virtual float getPriority( GameObject *obj, int target_id );
bool getPrimary ( GameObject *target );
/* Utility functions for both priority calculations and AI scripts to utilise */
virtual bool IsVehicleEmpty( VehicleGameObj* vobj );
virtual bool IsVehicleAIEnabled( VehicleGameObj* vobj );
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief danpaul88's Custom AI Heavy Vehicle Marker
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* This is a dummy script with no functionality which can be attached to an object to indicate all of
* my custom AI scripts should treat this as a heavy vehicle. Any vehicle without this script will be
* considered to be a light vehicle.
*/
class dp88_AI_heavyVehicleMarker : public ScriptImpClass{};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Unit AI Base Class
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* The base class for unit AI classes, this defines some common functions and logic but leaves
* the specific implementation up to the derived classes
*/
class dp88_AI_Unit : public dp88_customAI
{
public:
// Game Events
void Created(GameObject *obj);
void Timer_Expired(GameObject *obj, int number);
void Action_Complete(GameObject *obj, int action_id, ActionCompleteReason reason);
// Custom AI initialisation script overloads
virtual void Init(GameObject *obj);
virtual void loadSettings(GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings);
protected:
static const int ACTION_ID_MOVE_TO_OBJECTIVE = 7850001;
static const int ACTION_ID_ATTACK_TARGET = 7850002;
// Action reset handler
void ResetAllActions(GameObject* obj);
// Go to the location of the current objective
virtual void GoToObjective(GameObject *obj);
// Attack the specified target
virtual void AttackTarget(GameObject *obj, GameObject *target);
/*!
* Used by AttackTarget to decide if the unit should give chase to the target (or, if already
* within preferred range, hold position) or whether it should continue with its existing
* pathfinding operation (or, if none, hold position).
*
* The default implementation will return true if the target base priority is >= 0 or there is
* no current objective to complete, otherwise it will return false
*/
virtual bool ShouldPursueTarget(GameObject *obj, GameObject *target);
/*!
* Get the preferred attack range for the specified target
*/
virtual int GetPreferredAttackRange(GameObject* obj, GameObject *target) = 0;
/*!
* Check if the specified object is a valid target at this time
*/
virtual bool IsValidTarget(GameObject* obj, GameObject *target) = 0;
/*!
* Select a new objective
*/
virtual dp88_AI_Objective* ChooseNewObjective(GameObject* obj) = 0;
// -----------------------------------------------------------------------------------------------
// Member variables
/*! True if moving towards an objective */
bool m_bMovingToObjective;
/*! True if moving towards an attack target */
bool m_bMovingToTarget;
// Current objective
dp88_AI_Objective* m_pCurrentObjective;
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Offensive Tank AI
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* This is a somewhat experimental AI for vehicles which can track targets over a predefined distance
* and attack them. This script is not yet suitable for use in maps or mods and is subject to change.
*/
class dp88_AI_Tank_Offensive : public dp88_AI_Unit
{
public:
// Game Events
void Created(GameObject *obj);
void Enemy_Seen(GameObject *obj, GameObject *enemy);
// Custom AI initialisation script overloads
virtual void Init(GameObject *obj);
virtual void loadSettings(GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings);
protected:
/*!
* Get the preferred attack range for the specified target
*/
virtual int GetPreferredAttackRange(GameObject* obj, GameObject *target);
/*!
* Check if the specified object is a valid target at this time
*/
virtual bool IsValidTarget(GameObject* obj, GameObject *target);
/*!
* Select a new objective
*/
virtual dp88_AI_Objective* ChooseNewObjective(GameObject* obj);
/*! \name Cached Script Parameters */
/*! @{ */
int m_primary_prefRange, m_secondary_prefRange;
int retreatDamageAmount;
/*! @} */
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Turret AI
* \author Daniel Paul (danpaul88@yahoo.co.uk)
* \ingroup scripts_basedefences
*
* A custom designed turret AI code designed to allow maximum flexibility in implementation without
* needing multiple versions of effectively the same code to target different enemies (ie: VTOL vs.
* non-VTOL).
*
* The turret AI uses a priority based system to 'intelligently' pick targets based upon a range of
* criteria such as the type of target, how far away it is, if it's already taken damage and how
* valuable it is. All of these criteria can be fine tuned in the script parameters to give you a
* high degree of control over which of several targets a turret will choose to shoot at. This also
* has the effect of making multiple, closely placed, turrets with the same targetting parameters
* concentrate their fire on a single target for maximum impact.
*
* \param Priority_Infantry
* Base targetting priority for infantry targets, or 0 to ignore infantry
* \param Weapon_Infantry
* Weapon to use against infantry targets: 1 for primary fire, 2 for secondary fire
* \param Splash_Infantry
* Determines if we should try to damage infantry with splash instead of hitting them directly.
* This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
* \param Priority_Light_Vehicle
* Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
* \param Weapon_Light_Vehicle
* Weapon to use against light vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_Heavy_Vehicle
* Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
* \param Weapon_Heavy_Vehicle
* Weapon to use against heavy vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_VTOL
* Base targetting priority for flying targets, or 0 to ignore flying targets
* \param Weapon_VTOL
* Weapon to use against flying targets: 1 for primary fire, 2 for secondary fire
* \param Min_Attack_Range
* Minimum distance at which the turret can engage enemies when using primary fire
* \param Max_Attack_Range
* Maximum distance at which the turret can engage enemies when using primary fire
* \param Min_Attack_Range_Secondary
* Minimum distance at which the turret can engage enemies when using secondary fire
* \param Max_Attack_Range_Secondary
* Maximum distance at which the turret can engage enemies when using secondary fire
* \param Modifier_Distance
* Priority modification to apply based on distance to target. Higher values will favour targets
* which are closer to the turret, good for less accurate weapons
* \param Modifier_Target_Damage
* Priority modification to apply based on damage a target has already sustained. Higher values
* will favour targets which have already been damaged in combat, picking them off first
* \param Modifier_Target_Value
* Priority modification to apply based on the value of the target. Higher values will favour
* targets with a higher purchase cost, good for hard hitting weapons
* \param Requires_Power
* Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
* \param Debug
* Specify whether to produce a debug logfile about the turrets targetting decisions, this is
* useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable
* \param Detects_Stealth
* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable
*
* \note
* Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
* script attached to them<br/>
* <br/>
* The turret can be disabled using custom messages, see the note about this in dp88_customAI
*
* \warning
* Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
* machines with useless text files everywhere... people usually don't like that :D
*/
class dp88_AI_Turret : public dp88_customAI
{
public:
// Events
virtual void Enemy_Seen ( GameObject *obj, GameObject *enemy );
virtual void Timer_Expired( GameObject *obj, int number );
virtual void Damaged(GameObject *obj, GameObject *damager, float amount);
// Custom AI initialisation script overrides
virtual void Init( GameObject *obj );
virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings );
// Custom AI event overrides
virtual void AIStateChanged( GameObject* pObj, bool bEnabled );
protected:
bool requiresPower, splashInfantry;
// These can be overloaded from their default functionality as required, allowing the default
// enemy seen procedure to be reused even when the behaviour of these checks has been altered
virtual bool checkTeam ( GameObject* obj, GameObject* target );
virtual bool checkRange ( GameObject* obj, GameObject* target, bool primary );
virtual bool checkPowerState( GameObject* obj );
/* These functions are used to initiate and control the AI actions and can be overloaded from
their defaults if required to provide custom functionality, such as delaying an attack whilst
waiting for a chargeup / popup animation to occur. */
// These is called when a valid target has been identified and selected as the highest priority
// target, the turret should begin attacking in this function. Note that this may be called
// while another attack is already in progress, either normal or splash.
virtual void attackTarget ( GameObject* obj, GameObject* target, bool primary );
// This is called instead of attackTarget when we are set to splash infantry instead of shooting
// at them directly. Whilst we are attacking an infantry unit with splash this will be called
// regularly on a timer to update the location of the target. Note that this may be called
// while another attack is already in progress, either normal or splash.
virtual void attackLocation ( GameObject* obj, Vector3 location, bool primary );
// This is called when the target is no longer valid and the turret should stop attacking, this
// is called to stop both attackTarget and splashLocation attacks.
virtual void stopAttacking ( GameObject* obj );
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Popup Turret AI
* \author Daniel Paul (danpaul88@yahoo.co.uk)
* \ingroup scripts_basedefences
*
* An overloaded version of my custom turret AI incorporating popup/deploy logic. This script requires
* two LevelEdit presets to work correctly, which are as follows;
*
* <b>Turret Preset</b>
* As with any turret preset, this has all the weapons, health, armour, etc etc and should have an
* instance of this script attached to it with the relevant parameters configured (see below).
*
* <b>Spotter Preset</b>
* This is a dummy preset used to 'see' enemies whilst the real turret is undeployed. This should be
* setup as a turret but only the sight range parameter needs to be configured properly. It's model
* can be set to any valid model (or possibly left blank?) and it should NOT have ANY scripts. Note
* this preset can be shared by multiple turret presets as long as the sight range is appropriate.
*
* \param Priority_Infantry
* Base targetting priority for infantry targets, or 0 to ignore infantry
* \param Weapon_Infantry
* Weapon to use against infantry targets: 1 for primary fire, 2 for secondary fire
* \param Splash_Infantry
* Determines if we should try to damage infantry with splash instead of hitting them directly.
* This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
* \param Priority_Light_Vehicle
* Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
* \param Weapon_Light_Vehicle
* Weapon to use against light vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_Heavy_Vehicle
* Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
* \param Weapon_Heavy_Vehicle
* Weapon to use against heavy vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_VTOL
* Base targetting priority for flying targets, or 0 to ignore flying targets
* \param Weapon_VTOL
* Weapon to use against flying targets: 1 for primary fire, 2 for secondary fire
* \param Min_Attack_Range
* Minimum distance at which the turret can engage enemies when using primary fire
* \param Max_Attack_Range
* Maximum distance at which the turret can engage enemies when using primary fire
* \param Min_Attack_Range_Secondary
* Minimum distance at which the turret can engage enemies when using secondary fire
* \param Max_Attack_Range_Secondary
* Maximum distance at which the turret can engage enemies when using secondary fire
* \param Deploy_Animation
* Name of the animation to play when the turret deploys - this is played in reverse for undeploy
* \param Deploy_Animation_Frames
* Number of animation frames in the deployment animation, which should start at frame 0
* \param Deploy_Sound
* An optional sound effect to be played whilst the deployment occurs
* \param Deploy_Timeout
* Time the turret will wait after it last saw an enemy before it undeploys, in seconds
* \param Spotter_Preset
* Name of your Spotter Preset in LevelEdit
* \param Modifier_Distance
* Priority modification to apply based on distance to target. Higher values will favour targets
* which are closer to the turret, good for less accurate weapons
* \param Modifier_Target_Damage
* Priority modification to apply based on damage a target has already sustained. Higher values
* will favour targets which have already been damaged in combat, picking them off first
* \param Modifier_Target_Value
* Priority modification to apply based on the value of the target. Higher values will favour
* targets with a higher purchase cost, good for hard hitting weapons
* \param Requires_Power
* Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
* \param Debug
* Specify whether to produce a debug logfile about the turrets targetting decisions, this is
* useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable
* \param Detects_Stealth
* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable
*
* \note
* Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
* script attached to them<br/>
* <br/>
* The turret can be disabled using custom messages, see the note about this in dp88_customAI
*
* \warning
* Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
* machines with useless text files everywhere... people usually don't like that :D
*/
class dp88_AI_PopupTurret : public dp88_AI_Turret
{
public:
// Game events
virtual void Created ( GameObject* pSelf );
virtual void Timer_Expired ( GameObject* pSelf, int number );
virtual void Custom ( GameObject* pSelf, int type, int param, GameObject* pSender );
virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name );
virtual void Destroyed( GameObject* pSelf );
protected:
static const unsigned char STATE_UNDEPLOYED = 0x00;
static const unsigned char STATE_DEPLOYING = 0x01;
static const unsigned char STATE_DEPLOYED = 0x02;
static const unsigned char STATE_UNDEPLOYING = 0x03;
/*! Current deployment state */
unsigned char m_deploymentState;
/*! Time at which we will undeploy unless we see a target in the meantime */
time_t m_undeployTime;
/*! ID of the spotter turret we have created for ourselves */
int m_spotterId;
/*! Overloaded form of dp88_AI_Turret::attackTarget to check deployment state prior to initiating attack */
virtual void attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary );
/*! Overloaded form of dp88_AI_Turret::attackLocation to check deployment state prior to initiating attack */
virtual void attackLocation ( GameObject* pSelf, Vector3 location, bool primary );
/*! Function to initiate the deployment sequence if it is not already in process, this is called
when we want to start shooting things */
virtual void Deploy ( GameObject* pSelf );
/*! Function to initiate the undeployment sequence if it is not already in process, this is called
when we are bored because we haven't had anything to shoot at for a while...*/
virtual void Undeploy ( GameObject* pSelf );
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Popup Turret Spotter
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* A simple companion script for dp88_AI_PopupTurret which is attached to an invisible clone of the
* turret to allow it to 'see' enemies when whilst the muzzle is underground. Simply fires off a
* custom event to the parent turret each time it sees an enemy with the ID of that enemy.
*/
class dp88_AI_PopupTurret_Spotter : public ScriptImpClass
{
void Enemy_Seen ( GameObject* pSelf, GameObject* pEnemy );
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief Charged Turret AI
* \author Daniel Paul (danpaul88@yahoo.co.uk)
* \ingroup scripts_basedefences
*
* An overloaded version of my custom turret AI incorporating charge up logic, which causes an
* animation sequence to be played prior to each clip fired by the turret. For maximum flexibility
* the animation can be played on either the turrets own model or on a seperate preset which is
* attached by this script to a specified bone on the turret model. This allows damage and charge
* up animations to be used on a turret simultaneously.
*
* One notable feature is the ability to fire more than one shot each time the turret charges up,
* allowing for greater flexibility in usage. When the turret is fully charged it will fire at the
* enemy until it runs out of bullets and needs to reload, at which point it will restart the charge
* up animation.
*
* \note
* The weapon reload time <b>must</b> be less than the duration of the charging animation
*
* \warning
* Currently there is a design limitation in the script which requires that the weapon reload time
* must be at least 1.1 seconds in duration to ensure correct detection of the discharged state. If
* this is problematic in future the limitation can be removed. If your reload time is less than 1
* second the turret could empty two or more complete clips of ammo before charging again.
*
* \param Priority_Infantry
* Base targetting priority for infantry targets, or 0 to ignore infantry
* \param Weapon_Infantry
* Weapon to use against infantry targets: 1 for primary fire, 2 for secondary fire
* \param Splash_Infantry
* Determines if we should try to damage infantry with splash instead of hitting them directly.
* This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
* \param Priority_Light_Vehicle
* Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
* \param Weapon_Light_Vehicle
* Weapon to use against light vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_Heavy_Vehicle
* Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
* \param Weapon_Heavy_Vehicle
* Weapon to use against heavy vehicle targets: 1 for primary fire, 2 for secondary fire
* \param Priority_VTOL
* Base targetting priority for flying targets, or 0 to ignore flying targets
* \param Weapon_VTOL
* Weapon to use against flying targets: 1 for primary fire, 2 for secondary fire
* \param Min_Attack_Range
* Minimum distance at which the turret can engage enemies when using primary fire
* \param Max_Attack_Range
* Maximum distance at which the turret can engage enemies when using primary fire
* \param Min_Attack_Range_Secondary
* Minimum distance at which the turret can engage enemies when using secondary fire
* \param Max_Attack_Range_Secondary
* Maximum distance at which the turret can engage enemies when using secondary fire
* \param Animation_Model
* Optional name of a W3D model file to spawn and attach to the turret upon which the charge
* animations defined in this script will be applied. This allows the turret itself to be running
* a different set of animations, such as damage states via dp88_damageAnimation
* \param Animation_Model_Bone
* If you specify an Animation_Model above then you must also specify the a bone on the parent
* to which that model should be attached. This allows the animation model to be moved by the
* animation set executing on the turret.
* \param Animation
* Name of the animation which contains the frames for the various charge states
* \param Animation_Idle_Start_Frame
* First frame number for the idle animation, which will loop continually whilst the turret is
* powered and not currently attacking a target
* \param Animation_Idle_End_Frame
* Final frame number for the idle animation
* \param Animation_Unpowered_Start_Frame
* First frame number for the unpowered animation, which will loop continually whilst the turret
* is in the unpowered state. This is not used if Requires_Power is disabled (see below).
* \param Animation_Unpowered_End_Frame
* Final frame number for the unpowered animation
* \param Animation_Charge_Start_Frame
* First frame number for the charging animation, which will be played once each time the turret
* reloads its weapon. Once this animation completes the turret will fire again, therefore the
* length of this animation must be greater than the weapon reload time.
* \param Animation_Charge_End_Frame
* Final frame number for the charging animation
* \param Charge_Sound
* Optional sound effect to be played each time the turret starts charging up
* \param Modifier_Distance
* Priority modification to apply based on distance to target. Higher values will favour targets
* which are closer to the turret, good for less accurate weapons
* \param Modifier_Target_Damage
* Priority modification to apply based on damage a target has already sustained. Higher values
* will favour targets which have already been damaged in combat, picking them off first
* \param Modifier_Target_Value
* Priority modification to apply based on the value of the target. Higher values will favour
* targets with a higher purchase cost, good for hard hitting weapons
* \param Requires_Power
* Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
* \param Debug
* Specify whether to produce a debug logfile about the turrets targetting decisions, this is
* useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable
* \param Detects_Stealth
* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable
*
* \note
* Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
* script attached to them<br/>
* <br/>
* The turret can be disabled using custom messages, see the note about this in dp88_customAI
*
* \warning
* Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
* machines with useless text files everywhere... people usually don't like that :D
*/
class dp88_AI_ChargedTurret : public dp88_AI_Turret
{
public:
// Game events
virtual void Timer_Expired ( GameObject* pSelf, int number );
virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name );
virtual void Destroyed( GameObject* pSelf );
// Custom AI initialisation script overloads
virtual void Init( GameObject* pSelf );
virtual void loadSettings( GameObject* pSelf, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings );
protected:
unsigned int m_myObjId; //!< My own GameObject ID, used by the observer callbacks
/*! Are we currently charging ready for an attack? */
bool m_bIsCharging;
/*! Are we currently discharging (ie: attacking an enemy)? */
bool m_bIsDischarging;
/*! This is true if the turret is reloading AND the remaining reload duration exceeds the
* charge up time. Prevents the charge animation starting prematurely and then hanging around
* waiting for the reload to be finished before firing */
bool m_bIsPreReloading;
/*! ID of the charge animation object we have created for ourselves */
int m_chargeAnimObjId;
/*! Power state last time it was checked - if this changes we need to update our animation */
bool m_bPowerState;
/*! A looped animation controller for the idle and low power state animations */
LoopedAnimationController* m_pLoopedAnimCtrl;
/*! An animation observer for the object identified by m_chargeAnimObjId, if used */
dp88_AI_ChargedTurret_AnimationObserver* m_pAnimationObserver;
/*! Overloaded form of dp88_AI_Turret::attackTarget which initiates turret charging (if it is not
* currently in progress) rather than actually attacking anything */
virtual void attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary );
/*! Overloaded form of dp88_AI_Turret::attackLocation which initiates turret charging (if it is
* not currently in progress) rather than actually attacking anything */
virtual void attackLocation ( GameObject* pSelf, Vector3 location, bool primary );
/*! This function is called to initiate the charge up process, if it is not already in progress */
virtual void StartCharging ( GameObject* pSelf );
/*! This function is called when the turret is fully charged and is ready to fire at something */
virtual void StartDischarging ( GameObject* pSelf );
/*! Internal utility function to get a pointer to the object upon which the charge animation will
* be applied - this will either be the turret itself or the seperate charge animation object if
* one was specified in the script parameters */
virtual GameObject* GetAnimationObject ( GameObject* pSelf );
/*! Called when the turret is idle or unpowered to apply the correct animation frames */
virtual void ApplyIdleAnimation ( GameObject* pSelf );
};
/*!
* \brief Chargeup Animation Observer
* \author Daniel Paul (danpaul88@yahoo.co.uk)
*
* An observer to detect animations if the "separate object" feature is used
*/
class dp88_AI_ChargedTurret_AnimationObserver : public ObserverImpClass
{
public:
dp88_AI_ChargedTurret_AnimationObserver(dp88_AI_ChargedTurret* pParent);
// Game events
virtual void Animation_Complete(GameObject* pSelf, const char* animation_name);
private:
dp88_AI_ChargedTurret* m_pParent;
};
// -------------------------------------------------------------------------------------------------
/*!
* \brief AI Objective
* \author Daniel Paul (danpaul88@yahoo.co.uk)
* \ingroup scripts_ai
*
* This script should be attached to any object which offensive AI scripts should treat as a mission
* objective, for example a building. Compatible scripts include dp88_AI_Tank_Offensive. Note that
* the objective is used as a go-to location rather than a target to shoot at, so the behaviour of
* the unit when it arrives at an objective depends upon the script being used and its configuration.
*
* \param Team
* Which team this objective applies to. 0 for Nod/Soviets, 1 for GDI/Allies and 2 for both
* \param Type
* What type of objective this is, valid values are 1 (Offensive), 2 (Defensive) or 3 (Engineering)
* \param Range
* The target distance from this objective the unit will try to achieve. Be careful not to set this
* too low or the AI might be unable to calculate a successful route. Upon arrival units will roam
* within this area until the objective is accomplished or a new objective takes priority
* \param Priority_Soldier
* Objective priority for soldiers, or 0 is this objective is not suitable for soldiers
* \param Priority_Light_Vehicle
* Objective priority for light vehicles, or 0 is this objective is not suitable for light vehicles
* \param Priority_Heavy_Vehicle
* Objective priority for heavy vehicles, or 0 is this objective is not suitable for heavy vehicles
* \param Priority_Aircraft
* Objective priority for aircraft, or 0 is this objective is not suitable for aircraft
*/
class dp88_AI_Objective : public ScriptImpClass
{
public:
void Created ( GameObject* obj );
void Detach ( GameObject* obj );
GameObject* GetGameObject();
unsigned char GetType() { return m_type; }
int GetTeam() { return m_team; }
int GetRange() { return m_range; }
/*! Get the priority of this objective for the specified AI unit */
float GetPriority(GameObject* obj, float distance_modifier);
/*!
* Finds the most suitable objective of a given type for the specified unit, based on the distance
* to the objective and their distance modifier
*/
static dp88_AI_Objective* GetBestObjective ( GameObject* obj, unsigned char objective_type, float distance_modifier );
/*! Checks if the specified objective is still valid */
static bool IsValidObjective ( dp88_AI_Objective* pObjective );
/*! \name Objective types */
/*! @{ */
const static unsigned char TYPE_OFFENSIVE = 1;
const static unsigned char TYPE_DEFENSIVE = 2;
const static unsigned char TYPE_ENGINEERING = 3;
/*! @} */
protected:
/*! \name Unit types */
/*! @{ */
const static unsigned char UNITTYPE_SOLDIER = 0;
const static unsigned char UNITTYPE_LVEHICLE = 1;
const static unsigned char UNITTYPE_HVEHICLE = 2;
const static unsigned char UNITTYPE_AIRCRAFT = 3;
const static unsigned char UNITTYPE_MAX = UNITTYPE_AIRCRAFT;
const static unsigned char UNITTYPE_UNKNOWN = UCHAR_MAX;
/*! @} */
/*! Get the unit type of the specified unit */
unsigned char GetUnitType(GameObject* obj);
int m_objID;;
/*! \name Cached Script Parameters */
/*! @{ */
unsigned char m_type;
int m_priority[UNITTYPE_MAX + 1];
int m_range;
int m_team;
/*! @} */
static DynamicVectorClass<dp88_AI_Objective *> Objectives;
};
| 43.325815 | 164 | 0.741106 |
8981a609c7612b0501e7cd1583b490a64eb55215 | 114 | h | C | Spec/Support/ArgumentReleaser.h | sgravrock/cedar | 176a091e663ccbe4b7a3139e188b55b0a2d329d0 | [
"MIT"
] | 357 | 2015-01-02T01:16:19.000Z | 2017-10-26T13:30:36.000Z | Spec/Support/ArgumentReleaser.h | sgravrock/cedar | 176a091e663ccbe4b7a3139e188b55b0a2d329d0 | [
"MIT"
] | 93 | 2015-01-16T15:11:04.000Z | 2017-02-22T22:29:02.000Z | Spec/Support/ArgumentReleaser.h | sgravrock/cedar | 176a091e663ccbe4b7a3139e188b55b0a2d329d0 | [
"MIT"
] | 54 | 2015-01-17T16:54:34.000Z | 2017-09-30T16:21:32.000Z | #import <Foundation/Foundation.h>
@interface ArgumentReleaser : NSObject
- (void)releaseArgument:(id)arg;
@end
| 14.25 | 38 | 0.763158 |
edd80663f8d44831e1b045d0290dcaedf55abbd5 | 694 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HiChatService-Protocol.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HiChatService-Protocol.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/HiChatService-Protocol.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import "DTService-Protocol.h"
@class APLinkCardItem, NSString;
@protocol HiChatService <DTService>
- (void)cleanCachedData;
- (void)autoCheckClipboardLink;
- (void)queryLinkCardWithLink:(NSString *)arg1 jsLinkCardItem:(APLinkCardItem *)arg2 detectLink:(_Bool)arg3 bizType:(NSString *)arg4 owner:(id)arg5 callback:(void (^)(APLinkCardItem *))arg6;
- (void)queryLinkCardWithLink:(NSString *)arg1 detectLink:(_Bool)arg2 bizType:(NSString *)arg3 owner:(id)arg4 callback:(void (^)(APLinkCardItem *))arg5;
@end
| 38.555556 | 190 | 0.739193 |
070b0f59cd7eddee10ce8e9910de10ef97b9a91a | 415 | h | C | Src/Main.h | TobiasBriones/example.math.numerical.cpp.differential-equations | 5415dfed6369a3664091edfc1bbd34207b03f031 | [
"MIT"
] | null | null | null | Src/Main.h | TobiasBriones/example.math.numerical.cpp.differential-equations | 5415dfed6369a3664091edfc1bbd34207b03f031 | [
"MIT"
] | null | null | null | Src/Main.h | TobiasBriones/example.math.numerical.cpp.differential-equations | 5415dfed6369a3664091edfc1bbd34207b03f031 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2020 Tobias Briones. All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* This file is part of Example Project: Numerical Differential Equations.
*
* This source code is licensed under the MIT License found in the
* LICENSE file in the root directory of this source tree or at
* https://opensource.org/licenses/MIT.
*/
#pragma once
const char APP_VERSION[] = "1.0";
int main();
| 23.055556 | 74 | 0.715663 |
882a3b0e830e40144af44d196e84c66ca895ebbf | 396 | c | C | examples/google-code-jam/tatuyan/D_Fractile_small.c | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | examples/google-code-jam/tatuyan/D_Fractile_small.c | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | examples/google-code-jam/tatuyan/D_Fractile_small.c | rbenic-fer/progauthfp | d0fd96c31ab0aab1a9acdcb7c75f2b430f51c675 | [
"MIT"
] | null | null | null | #include<stdio.h>
void solve(void);
int main(void){
int t,i;
scanf("%d",&t);
for(i=0;i<t;i++){
printf("Case #%d: ",i+1);
solve();
}
return 0;
}
void solve(void){
int i,j;
int K,C,S;
scanf("%d%d%d",&K,&C,&S);
if(C==1){
for(i=0;i<S;i++) printf("%d%c",i+1,i==S-1?'\n':' ');
}else{
for(i=0;i<S;i++){
printf("%d%c",i+1+(i*K),i==S-1?'\n':' ');
}
}
}
| 14.142857 | 56 | 0.431818 |
885453f34f1308dcc3e1d972ebf66c3c628a569f | 313 | h | C | Ankit/ali_core.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | Ankit/ali_core.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | Ankit/ali_core.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | #ifndef __ALI_H__
#define __ALI_H__
#include <stdint.h>
#include <stddef.h>
typedef uint8_t data_t;
typedef struct
{
data_t *data;
size_t size;
uint8_t sign;
} alint;
void alint_free (alint * integer);
alint* alint_init (size_t starting_size);
void alint_resize (alint* integer, size_t new_size);
#endif
| 16.473684 | 52 | 0.747604 |
fc9d60ab68b0e819c7b4d205496ef24d07bb05ab | 1,047 | h | C | GedlekPawel-lab10/zad1/cluster.h | Codetype/Operating-Systems | 3946a5406de90fbb7281ed2d33320bc79ad7b602 | [
"MIT"
] | null | null | null | GedlekPawel-lab10/zad1/cluster.h | Codetype/Operating-Systems | 3946a5406de90fbb7281ed2d33320bc79ad7b602 | [
"MIT"
] | null | null | null | GedlekPawel-lab10/zad1/cluster.h | Codetype/Operating-Systems | 3946a5406de90fbb7281ed2d33320bc79ad7b602 | [
"MIT"
] | null | null | null | #ifndef _CLUSTER_SERVER
#define _CLUSTER_SERVER
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <pthread.h>
#include <sys/un.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <signal.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <fcntl.h>
#define UNIX_PATH_MAX 108
#define MAX_MSG 100
#define SERVER_ACCT (char)0
#define SERVER_REJC (char)1
#define SERVER_PING (char)2
#define SERVER_CALC (char)3
#define CLIENT_REGS (char)4
#define CLIENT_PONG (char)5
#define CLIENT_ANSW (char)6
#define CLIENT_ERRO (char)7
#define CLIENT_UNRG (char)8
typedef char msg_t;
typedef struct {
msg_t msg_type;
int msg_length;
int c_count;
} packet_t;
struct client_node {
int fd;
char* name;
int ping;
struct client_node* next;
} client_node;
typedef struct {
int size;
int counter;
struct client_node* first;
} client_list;
#endif
| 19.388889 | 31 | 0.687679 |
50c0a012fe2c934737eaad413168f0c47c0f6982 | 3,736 | h | C | src/plugins/wireguard/wireguard_peer.h | hanqianxun/vpp | a8ebb518445a3ee82e7d18858ea6d2f24c780abc | [
"Apache-2.0"
] | 1 | 2019-12-05T03:21:21.000Z | 2019-12-05T03:21:21.000Z | src/plugins/wireguard/wireguard_peer.h | hanqianxun/vpp | a8ebb518445a3ee82e7d18858ea6d2f24c780abc | [
"Apache-2.0"
] | null | null | null | src/plugins/wireguard/wireguard_peer.h | hanqianxun/vpp | a8ebb518445a3ee82e7d18858ea6d2f24c780abc | [
"Apache-2.0"
] | 1 | 2019-09-07T13:08:01.000Z | 2019-09-07T13:08:01.000Z | /*
* Copyright (c) 2020 Doc.ai and/or its affiliates.
* Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __included_wg_peer_h__
#define __included_wg_peer_h__
#include <vnet/ip/ip.h>
#include <wireguard/wireguard_cookie.h>
#include <wireguard/wireguard_timer.h>
#include <wireguard/wireguard_key.h>
#include <wireguard/wireguard_messages.h>
#include <wireguard/wireguard_if.h>
typedef struct ip4_udp_header_t_
{
ip4_header_t ip4;
udp_header_t udp;
} __clib_packed ip4_udp_header_t;
u8 *format_ip4_udp_header (u8 * s, va_list * va);
typedef struct wg_peer_allowed_ip_t_
{
fib_prefix_t prefix;
fib_node_index_t fib_entry_index;
} wg_peer_allowed_ip_t;
typedef struct wg_peer_endpoint_t_
{
ip46_address_t addr;
u16 port;
} wg_peer_endpoint_t;
typedef struct wg_peer
{
noise_remote_t remote;
cookie_maker_t cookie_maker;
u32 input_thread_index;
u32 output_thread_index;
/* Peer addresses */
wg_peer_endpoint_t dst;
wg_peer_endpoint_t src;
u32 table_id;
adj_index_t adj_index;
/* rewrite built from address information */
u8 *rewrite;
/* Vector of allowed-ips */
wg_peer_allowed_ip_t *allowed_ips;
/* The WG interface this peer is attached to */
u32 wg_sw_if_index;
/* Timers */
tw_timer_wheel_16t_2w_512sl_t *timer_wheel;
u32 timers[WG_N_TIMERS];
u32 timer_handshake_attempts;
u16 persistent_keepalive_interval;
/* Timestamps */
f64 last_sent_handshake;
f64 last_sent_packet;
f64 last_received_packet;
f64 session_derived;
f64 rehandshake_started;
/* Variable intervals */
u32 new_handshake_interval_tick;
u32 rehandshake_interval_tick;
bool timer_need_another_keepalive;
bool is_dead;
} wg_peer_t;
typedef struct wg_peer_table_bind_ctx_t_
{
ip_address_family_t af;
u32 new_fib_index;
u32 old_fib_index;
} wg_peer_table_bind_ctx_t;
int wg_peer_add (u32 tun_sw_if_index,
const u8 public_key_64[NOISE_PUBLIC_KEY_LEN],
u32 table_id,
const ip46_address_t * endpoint,
const fib_prefix_t * allowed_ips,
u16 port, u16 persistent_keepalive, index_t * peer_index);
int wg_peer_remove (u32 peer_index);
typedef walk_rc_t (*wg_peer_walk_cb_t) (index_t peeri, void *arg);
index_t wg_peer_walk (wg_peer_walk_cb_t fn, void *data);
u8 *format_wg_peer (u8 * s, va_list * va);
walk_rc_t wg_peer_if_admin_state_change (wg_if_t * wgi, index_t peeri,
void *data);
walk_rc_t wg_peer_if_table_change (wg_if_t * wgi, index_t peeri, void *data);
/*
* Expoed for the data-plane
*/
extern index_t *wg_peer_by_adj_index;
extern wg_peer_t *wg_peer_pool;
static inline wg_peer_t *
wg_peer_get (index_t peeri)
{
return (pool_elt_at_index (wg_peer_pool, peeri));
}
static inline index_t
wg_peer_get_by_adj_index (index_t ai)
{
return (wg_peer_by_adj_index[ai]);
}
/*
* Makes choice for thread_id should be assigned.
*/
static inline u32
wg_peer_assign_thread (u32 thread_id)
{
return ((thread_id) ? thread_id
: (vlib_num_workers ()?
((unix_time_now_nsec () % vlib_num_workers ()) +
1) : thread_id));
}
#endif // __included_wg_peer_h__
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
| 23.948718 | 77 | 0.755621 |
0a38d497735a4ecb8d030560b58116fbdef9a4b4 | 1,946 | h | C | Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_matlab_filewrite.h | jcfr/ITK | 6632b7f968c3827e8a3bcc9812e05b4e2064676e | [
"Apache-2.0"
] | null | null | null | Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_matlab_filewrite.h | jcfr/ITK | 6632b7f968c3827e8a3bcc9812e05b4e2064676e | [
"Apache-2.0"
] | null | null | null | Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_matlab_filewrite.h | jcfr/ITK | 6632b7f968c3827e8a3bcc9812e05b4e2064676e | [
"Apache-2.0"
] | null | null | null | // This is core/vnl/vnl_matlab_filewrite.h
#ifndef vnl_matlab_filewrite_h_
#define vnl_matlab_filewrite_h_
#ifdef VCL_NEEDS_PRAGMA_INTERFACE
#pragma interface
#endif
//:
// \file
// \author David Capel, Oxford RRG
// \date 17 August 1998
//
// \verbatim
// Modifications
// LSB (Manchester) 23/3/01 Tidied documentation
// Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
// \endverbatim
#include <vcl_string.h>
#include <vcl_fstream.h>
#include <vcl_complex.h>
#include <vnl/vnl_vector.h>
#include <vnl/vnl_matrix.h>
//: Code to perform MATLAB binary file operations
// vnl_matlab_filewrite is a collection of I/O functions for reading/writing
// matrices in the compact MATLAB binary format (.mat)
class vnl_matlab_filewrite
{
public:
vnl_matlab_filewrite (char const* file_name, char const *basename = VXL_NULLPTR);
//: Add scalar/vector/matrix variable to the MAT file using specified variable name.
// If no name is given, variables will be generated by
// appending 0,1,2 etc to the given basename.
void write(double v, char const* variable_name = VXL_NULLPTR);
void write(vnl_vector<double> const & v, char const* variable_name = VXL_NULLPTR);
void write(vnl_vector<vcl_complex<double> > const & v, char const* variable_name = VXL_NULLPTR);
void write(vnl_matrix<float> const & M, char const* variable_name = VXL_NULLPTR);
void write(vnl_matrix<double> const & M, char const* variable_name = VXL_NULLPTR);
void write(vnl_matrix<vcl_complex<float> > const & M, char const* variable_name = VXL_NULLPTR);
void write(vnl_matrix<vcl_complex<double> > const & M, char const* variable_name = VXL_NULLPTR);
void write(double const * const *M, int rows, int cols, char const* variable_name = VXL_NULLPTR);
protected:
vcl_string basename_;
int variable_int_;
vcl_fstream out_;
vcl_string make_var_name(char const* variable_name);
};
#endif // vnl_matlab_filewrite_h_
| 33.551724 | 99 | 0.751285 |
1c00c016f0f574b990e6f69b54ec875a5c9696a4 | 724 | h | C | challenge/leet.gcc/q1130/q1130.h | odys-z/hello | 39ca67cae34eb4bc4cbd848a06b3c0d65a995954 | [
"MIT"
] | null | null | null | challenge/leet.gcc/q1130/q1130.h | odys-z/hello | 39ca67cae34eb4bc4cbd848a06b3c0d65a995954 | [
"MIT"
] | 3 | 2021-04-17T18:36:24.000Z | 2022-03-04T20:30:09.000Z | challenge/leet.gcc/q1130/q1130.h | odys-z/hello | 39ca67cae34eb4bc4cbd848a06b3c0d65a995954 | [
"MIT"
] | null | null | null | #ifndef Q1130_H
#define Q1130_H
#include <vector>
#include <limits.h>
using namespace std;
class Solution {
public:
int mctFromLeafValues(vector<int>& arr) {
int res = 0;
while (arr.size() >= 2) {
int min = INT_MAX;
int mnx = -1;
int replace = 0;
for (int i = 1; i < arr.size(); i++) {
if (min > arr[i] * arr[i-1]) {
min = arr[i] * arr[i-1];
mnx = i;
replace = max(arr[i], arr[i-1]);
}
}
res += min;
arr[mnx - 1] = replace;
arr.erase(arr.begin() + mnx);
}
return res;
}
};
#endif // Q1130_H
| 21.294118 | 52 | 0.411602 |
5ae8e9f8c9564d52f4d0bf861ee46a87f2447ada | 1,426 | c | C | test/test_encode_regex.c | postmodern/libBERT | 970eec51bb7b41be21ffbea758290b6e20483e3e | [
"MIT"
] | 9 | 2015-05-23T20:02:25.000Z | 2019-12-14T23:42:29.000Z | test/test_encode_regex.c | postmodern/libBERT | 970eec51bb7b41be21ffbea758290b6e20483e3e | [
"MIT"
] | 4 | 2016-12-15T12:49:34.000Z | 2021-03-17T06:50:05.000Z | test/test_encode_regex.c | postmodern/libBERT | 970eec51bb7b41be21ffbea758290b6e20483e3e | [
"MIT"
] | 5 | 2016-07-09T19:09:59.000Z | 2019-06-23T14:58:32.000Z | #include <bert/encoder.h>
#include <bert/magic.h>
#include <bert/errno.h>
#include "test.h"
#include <string.h>
#define EXPECTED_LENGTH 13
#define EXPECTED "hello\\s*world"
#define OUTPUT_SIZE (1 + TEST_COMPLEX_HEADER_SIZE + 5 + 1 + 4 + EXPECTED_LENGTH + 1 + 4)
unsigned char output[OUTPUT_SIZE];
void test_output()
{
if (output[0] != BERT_MAGIC)
{
test_fail("bert_encoder_push did not add the magic byte");
}
const unsigned char *data = test_complex_header(output+1,"regex");
if (data[0] != BERT_BIN)
{
test_fail("bert_encoder_push did not encode the BIN magic byte");
}
if (data[4] != EXPECTED_LENGTH)
{
test_fail("bert_encoder_push encoded %u as the source length, expected %u",data[4],EXPECTED_LENGTH);
}
test_strings((const char *)(data+5),EXPECTED,EXPECTED_LENGTH);
if (data[5+EXPECTED_LENGTH] != BERT_LIST)
{
test_fail("bert_encoder_push did not encode the LIST magic byte, for the regex options");
}
if (data[5+EXPECTED_LENGTH+3] != 0)
{
test_fail("bert_encoder_push encoded %u as the regex option list length, expected %u",data[5+EXPECTED_LENGTH+3],0);
}
}
int main()
{
bert_encoder_t *encoder = test_encoder(output,OUTPUT_SIZE);
bert_data_t *data;
if (!(data = bert_data_create_regex(EXPECTED,EXPECTED_LENGTH,0)))
{
test_fail("malloc failed");
}
test_encoder_push(encoder,data);
bert_data_destroy(data);
bert_encoder_destroy(encoder);
test_output();
return 0;
}
| 22.28125 | 117 | 0.720196 |
e35d22558aafb63c15a183dbb33a9fd0f3c8cb28 | 415 | h | C | LRZLocalCache/Model/ViewModel.h | alertross/LRZCache | 8ddf6804ecb1031352c059c03f994204c2ea16ce | [
"MIT"
] | 2 | 2018-05-31T10:35:10.000Z | 2018-05-31T10:42:21.000Z | LRZLocalCache/Model/ViewModel.h | alertross/LRZCache | 8ddf6804ecb1031352c059c03f994204c2ea16ce | [
"MIT"
] | null | null | null | LRZLocalCache/Model/ViewModel.h | alertross/LRZCache | 8ddf6804ecb1031352c059c03f994204c2ea16ce | [
"MIT"
] | null | null | null | //
// ViewModel.h
// LRZLocalCache
//
// Created by 刘强 on 2018/5/31.
// Copyright © 2018年 LightReason. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "NSObject+LRZCoding.h"
@interface ViewModel : NSObject
@property (nonatomic,copy) NSString *name;
@property (nonatomic,copy) NSString *location;
@property (nonatomic,copy) NSString *sex;
@property (nonatomic,copy) NSString *headUrl;
@end
| 20.75 | 55 | 0.73012 |
7c6ea770fd714fdf71e161f008265330a2502ec3 | 129 | h | C | Challenges/C_CPP/0009_power_mod/func.h | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | 5 | 2021-03-26T08:19:43.000Z | 2021-12-18T18:04:04.000Z | Challenges/C_CPP/0009_power_mod/func.h | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | null | null | null | Challenges/C_CPP/0009_power_mod/func.h | saucec0de/sifu | 7924844e1737c7634016c677237bccd7e7651818 | [
"MIT"
] | null | null | null | #ifndef FUNC_H
#define FUNC_H
#include <stdint.h>
int32_t get_power_mod(int32_t a, int32_t p, int32_t n);
#endif /* FUNC_H */
| 14.333333 | 55 | 0.72093 |
f6fbc5d26a951baff99b6c1894aa00ae0d6f6a71 | 5,963 | h | C | sys/src/cmd/tex/mp/site.h | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | null | null | null | sys/src/cmd/tex/mp/site.h | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | null | null | null | sys/src/cmd/tex/mp/site.h | henesy/plan9-1e | 47575dc4a4638a1ee0d9eed78d88a9f1720a4430 | [
"MIT"
] | null | null | null | /* Master configuration file for WEB to C. Almost all the definitions
are wrapped with #ifndef's, so that you can override them from the
command line, if you want to. */
#ifndef __WEB2C_SITE_H
#define __WEB2C_SITE_H
/* Define if you're running under 4.2 or 4.3 BSD. */
#ifndef BSD
#undef BSD
#endif
/* Define if you're running under System V. */
#ifndef SYSV
#undef SYSV
#endif
/* Define if you're running under MS-DOS with Microsoft C. */
#ifndef MS_DOS
#undef MS_DOS
#endif
/* Define if you're running under a POSIX conforming OS */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
/* Define this if the system will be compiled with an ANSI C compiler,
and never with a non-ANSI compiler. It changes web2c so that it
produces ANSI C as its output. This is a good idea, but you don't
necessarily gain anything in the production programs by doing it. */
#ifndef ANSI
#define ANSI
#endif
/* Define these according to your local setup. */
#define TEXINPUTS ".:/usr/lib/tex/macros"
#define TEXFONTS ".:/usr/lib/tex/fonts/tfm"
#define TEXFORMATS ".:/usr/lib/tex/macros"
#define TEXPOOL ".:/usr/lib/tex"
#define MFBASES ".:/usr/lib/mf"
#define MFINPUTS ".:/usr/lib/mf"
#define MFPOOL ".:/usr/lib/mf"
/* BibTeX search path for .bib files. TEXINPUTS is used by BibTeX to
search for .bst files. */
#define BIBINPUTS ".:/usr/lib/tex/macros"
/* Metafont window support: More than one may be defined, as long as you
don't try to have both X10 and X11 support (because there are
conflicting routine names in the libraries). After you've defined
these, make sure to update the top-level Makefile accordingly. Also,
if you want X11 support, see the `Online output from Metafont'
section in ./README before compiling. */
#undef SUNWIN /* SunWindows support. */
#undef X10WIN /* X Version 10 support. */
#undef X11WIN /* X Version 11 support. */
#undef HP2627WIN /* HP 2627 support. */
#undef TEKTRONIXWIN /* Tektronix 4014 support. */
#if defined(X10WIN) && defined(X11WIN)
sorry
#endif
/* Define to be the return type of your signal handlers. POSIX says it
should be `void', but some older systems want `int'. Check your
<signal.h> include file if you're not sure. */
#ifndef SIGNAL_HANDLER_RETURN_TYPE
#define SIGNAL_HANDLER_RETURN_TYPE void
#endif
/* The type `glueratio' should be a floating point type which won't
unnecessarily increase the size of the memoryword structure. This is
the basic requirement. On most machines, if you're building a
normal-sized TeX, then glueratio must probably meet the following
restriction: sizeof(glueratio) <= sizeof(integer). Usually, then,
glueratio must be `float'. But if you build a big TeX, you can (on
most machines) and should make it `double' to avoid loss of precision
and conversions to and from double during calculations. (All this
also goes for Metafont.) Furthermore, if you have enough memory, it
won't hurt to have this defined for running the trip/trap tests. */
typedef double glueratio;
/* Define this if you want TeX to be compiled with local variables
declared as `register'. On SunOS 3.2 and 3.4 (at least), compiling
with cc, this will cause problems. If you're using gcc or the SunOS
4.x compiler, and compiling with -O, register declarations are
ignored, so there is no point in defining this. */
#ifndef REGFIX
#undef REGFIX
#endif
/* If the type `int' is at least 32 bits (including a sign bit), this
symbol should be #undef'd; otherwise, it should be #define'd. If
your compiler uses 16-bit int's, arrays larger than 32K may give you
problems, especially if indices are automatically cast to int's. */
#ifndef SIXTEENBIT
#undef SIXTEENBIT
#endif
/* Our character set is 8-bit ASCII unless NONASCII is defined. For
other character sets, make sure that first_text_char and
last_text_char are defined correctly (they're 0 and 255,
respectively, by default). In the *.defines files, change the
indicated range of type `char' to be the same as
first_text_char..last_text_char, `#define NONASCII', and retangle and
recompile everything. */
#ifndef NONASCII
#undef NONASCII
#endif
/* Default editor command string: %d expands to the line number where
TeX or Metafont found an error and %s expands to the name of the
file. The environment variables TEXEDIT and MFEDIT override this. */
#define EDITOR "/bin/ed %s"
/* The type `schar' should be defined here to be the smallest signed
type available. ANSI C compilers may need to use `signed char'. If
you don't have signed characters, then define schar to be the type
`short'. */
typedef signed char schar;
/* The type `integer' must be a signed integer capable of holding at
least the range of numbers (-2^31)..(2^32-1). The ANSI C
standard says that `long' meets this requirement, but if you don't
have an ANSI C compiler, you might have to change this definition. */
typedef long integer;
/* Define MAXPATHLENGTH to be the maximum number of characters in a
search path. This is used to size the buffers for the environment
variables. It is good to be quite generous here. */
#ifndef MAXPATHLENGTH
#define MAXPATHLENGTH 5000
#endif
/*******************************************************************
The following definitions are for MetaPost support
*******************************************************************/
/* MetaPost search paths (MetaPost also uses TEXFONTS and MFINPUTS) */
#define MPINPUTS ".:/usr/lib/mp"
#define MPMEMS ".:/usr/lib/mp"
#define MPPOOL ".:/usr/lib/mp"
/* Where dvitomp looks for virtual fonts */
#define VFPATH "/usr/lib/tex/fonts/psvf"
/*
* Command for translating MetaPost input to an mpx file
* (Can be overridden by an environment variable)
*/
#define MPXCOMMAND "/usr/lib/mp/makempx"
/************ End of MetaPost stuff *******************************/
#include "defaults.h"
#endif /* __WEB2C_H */
| 36.808642 | 73 | 0.705182 |
91a346bbf41125ee65eecf921d0e5e060d624076 | 343 | c | C | src/c-lib/music.c | oprochazka/spiderAgonyRpg | 8c4f7ed9255ea381d6b802f090b56f642d176dd2 | [
"Apache-2.0"
] | null | null | null | src/c-lib/music.c | oprochazka/spiderAgonyRpg | 8c4f7ed9255ea381d6b802f090b56f642d176dd2 | [
"Apache-2.0"
] | null | null | null | src/c-lib/music.c | oprochazka/spiderAgonyRpg | 8c4f7ed9255ea381d6b802f090b56f642d176dd2 | [
"Apache-2.0"
] | 1 | 2021-06-21T23:08:30.000Z | 2021-06-21T23:08:30.000Z | #include<stdio.h>
#include<stdlib.h>
#include<lua5.2/lua.h>
#include<lua5.2/lauxlib.h>
#include<lua5.2/lualib.h>
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
#include<SDL2/SDL2_gfxPrimitives.h>
#include<SDL2/SDL_mixer.h>
#include"main.h"
#include"basic_shapes.h"
#include"lua_func.h"
#include"list.h"
#include"window.h"
#include"audio.h"
| 19.055556 | 35 | 0.746356 |
91bda28886122d1e557f20c7c5a3fb0317d5cecf | 558 | h | C | System/Library/PrivateFrameworks/VideosUI.framework/VideosUI.CollectionHeaderViewLayout.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | 2 | 2020-07-26T20:30:54.000Z | 2020-08-10T04:26:23.000Z | System/Library/PrivateFrameworks/VideosUI.framework/VideosUI.CollectionHeaderViewLayout.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | 1 | 2020-07-26T20:45:31.000Z | 2020-08-09T09:30:46.000Z | System/Library/PrivateFrameworks/VideosUI.framework/VideosUI.CollectionHeaderViewLayout.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, June 7, 2020 at 11:46:23 AM Mountain Standard Time
* Operating System: Version 13.4.5 (Build 17L562)
* Image Source: /System/Library/PrivateFrameworks/VideosUI.framework/VideosUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@interface VideosUI.CollectionHeaderViewLayout : _UKNOWN_SUPERCLASS_ {
$__lazy_storage_$_titleViewLayout;
$__lazy_storage_$_subtitleViewLayout;
$__lazy_storage_$_imageViewLayout;
}
-(id)copyWithZone:(void*)arg1 ;
@end
| 27.9 | 81 | 0.77957 |
ea02c378eec371f0d44e7edf79980ca66e861ebc | 976 | h | C | src/yars/configuration/data/DataRecording.h | kzahedi/YARS | 48d9fe4178d699fba38114d3b299a228da41293d | [
"MIT"
] | 4 | 2017-08-05T03:33:21.000Z | 2021-11-08T09:15:42.000Z | src/yars/configuration/data/DataRecording.h | kzahedi/YARS | 48d9fe4178d699fba38114d3b299a228da41293d | [
"MIT"
] | null | null | null | src/yars/configuration/data/DataRecording.h | kzahedi/YARS | 48d9fe4178d699fba38114d3b299a228da41293d | [
"MIT"
] | 1 | 2019-03-24T08:35:25.000Z | 2019-03-24T08:35:25.000Z | #ifndef __DATA_RECORDING_H__
#define __DATA_RECORDING_H__
# define YARS_STRING_RECORDING (char*)"recording"
# define YARS_STRING_RECORDING_DEFINITION (char*)"recording_definition"
#include <yars/configuration/data/DataNode.h>
#include <yars/configuration/data/DataParameter.h>
#include <yars/configuration/data/DataActuator.h>
#include <yars/types/Matrix.h>
#include <yars/types/Domain.h>
#include <map>
#include <vector>
#include <string>
typedef __Domain<unsigned long> RecordingInterval;
using namespace std;
class DataRecording : public DataNode, public std::vector<RecordingInterval>
{
public:
DataRecording(DataNode *parent);
virtual ~DataRecording() { };
static void createXsd(XsdSpecification *spec);
void add(DataParseElement *element);
void resetTo(const DataRecording*);
DataRecording* copy();
// returns true if current time step is within a recoding interval
bool record();
};
#endif // __DATA_RECORDING_H__
| 25.684211 | 76 | 0.755123 |
87dc7df25a904ffff26b754d169d644833b5845c | 2,469 | h | C | Subspace/subspace/SubspaceChat.h | automaton82/pspace | 34c3aaaf4dadb63df3183d39535aae0ac0560599 | [
"BSD-3-Clause"
] | null | null | null | Subspace/subspace/SubspaceChat.h | automaton82/pspace | 34c3aaaf4dadb63df3183d39535aae0ac0560599 | [
"BSD-3-Clause"
] | null | null | null | Subspace/subspace/SubspaceChat.h | automaton82/pspace | 34c3aaaf4dadb63df3183d39535aae0ac0560599 | [
"BSD-3-Clause"
] | null | null | null | #ifndef _SUBSPACECHAT_H_
#define _SUBSPACECHAT_H_
#include <list>
#include <map>
#include <string>
using std::list;
using std::map;
using std::string;
#include "DataTypes.h"
#include "TextureFont.h"
//#include "CommandGenerator.h"
#include "ChatMessage.h"
class SubspacePlayer;
//#include "SubspaceChatCommandReceiver.h"
// Chat container object, holds all messages and the like - not responsible for chat routing
class SubspaceChat
//public SubspaceChatCommandReceiver,
//public CommandGenerator<SubspaceChatCommandReceiver>
{
private:
typedef vector<ChatMessage> MessageList;
typedef map<Uint, SubspacePlayer*> SubspacePlayerMap;
public:
SubspaceChat();
~SubspaceChat();
// Accessors
Uint countLines() const; //TODO: cache this?
double getDisplayHeight() const;
const TextureFont& getFont() const;
Uint getHeaderWidth() const;
Uint getLinesDisplayed() const;
Uint getLineWidth() const;
Uint size() const; //number of messages
// Mutators
void setFont(const TextureFont& font);
void setHeaderWidth(Uint width); //TODO: add cache for header and line width for currentLine?
void setLineWidth(Uint width); //line width in characters - implied word wrap
void setLinesDisplayed(Uint height);
void setLineOffset(Uint offset);
// void setPlayers(const SubspacePlayerMap* map);
/////////////
void addMessage(const ChatMessage& msg);
void clear();
// virtual void doChat(Uint16 playerID, const string& message, Uint8 chatType, Uint8 soundByte);
// void doChatOutbound(Uint16 playerID, const string& message, Uint8 chatType, Uint8 soundByte);
void writeMessage(const string& sender, const string& text, ChatType chatType = CHAT_Public);
// Game functionality
void draw() const;
void update(double time);
private:
Uint countMessageLines(const ChatMessage& msg) const; // implicit word wrap
void findLine(Uint lineNum, Uint& msgNum, Uint& msgLineOffset) const; // TODO: cache this?
Uint drawMessage(const ChatMessage& msg, Uint lineOffset, Uint maxMsgLines) const; // returns message lines displayed
static const int defaultLineWidth_ = 100;
static const int defaultHeaderWidth_ = 10;
static const string defaultHeaderSeparator_;
static const string defaultName_;
private:
TextureFont font_;
Uint headerWidth_;
string headerSeparator_;
Uint lineWidth_;
Uint linesDisplayed_; // number of lines drawn
Uint linesDisplayOffset_;
MessageList messages_;
//const SubspacePlayerMap* players_;
};
#endif | 26.836957 | 118 | 0.762657 |
564f9db93dda0ada25b8c8605503bc5f65a521ad | 1,271 | h | C | src/MIT_alice/AUISlotPool.h | midasitdev/aliceui | 3693018021892bcccbc66f29b931d9736db6f9dc | [
"MIT"
] | 10 | 2019-02-21T13:07:06.000Z | 2019-09-21T02:56:37.000Z | src/AliceUI/AUISlotPool.h | DevHwan/aliceui | 9ee7d9424c06d4e063e55b486e9a78dfcebf8f86 | [
"MIT"
] | 5 | 2019-02-28T03:11:50.000Z | 2019-03-08T00:16:17.000Z | src/AliceUI/AUISlotPool.h | DevHwan/aliceui | 9ee7d9424c06d4e063e55b486e9a78dfcebf8f86 | [
"MIT"
] | 5 | 2019-02-25T00:53:08.000Z | 2019-07-05T01:50:34.000Z | #pragma once
#include "AUISlot.h"
#include <vector>
class ALICEUI_API AUISlotPool
{
public:
AUISlotPool();
virtual ~AUISlotPool();
//////////////////////////////////////////////////////////////////////////
// Copy / Move
public:
AUISlotPool(const AUISlotPool& cp);
AUISlotPool& operator=(const AUISlotPool& cp);
AUISlotPool(AUISlotPool&&) noexcept = default;
AUISlotPool& operator=(AUISlotPool&&) noexcept = default;
//////////////////////////////////////////////////////////////////////////
// Slot control
public:
void SetSignalOpen(bool state);
bool IsSignalOpen() const noexcept {
return m_bSignalOpen;
}
private:
bool m_bSignalOpen = true;
//////////////////////////////////////////////////////////////////////////
// Connection to signal & generate slot
public:
void DisconnectAll(bool wait = false);
template<typename _Signal, typename... _Arg>
inline AUISlot Connect(_Signal& s, _Arg... ars)
{
auto c = s.Bind(std::forward<_Arg>(ars)...);
_AddSlot(c);
return c;
}
//////////////////////////////////////////////////////////////////////////
// Slot pool
private:
void _AddSlot(AUISlot& c);
std::vector<AUISlot> m_SlotPool;
};
| 25.938776 | 78 | 0.488592 |
568835e8634fe9968a0b44c24bfb8dc248874397 | 2,801 | h | C | third_party/rpg_common/include/rpg_common/eigen_type.h | debugCVML/rpg_information_field | 56f9ffba83aaee796502116e1cf651c5bc405bf6 | [
"MIT"
] | 149 | 2020-06-23T12:08:47.000Z | 2022-03-31T08:18:52.000Z | third_party/rpg_common/include/rpg_common/eigen_type.h | debugCVML/rpg_information_field | 56f9ffba83aaee796502116e1cf651c5bc405bf6 | [
"MIT"
] | 4 | 2020-08-28T07:51:15.000Z | 2021-04-09T13:18:49.000Z | third_party/rpg_common/include/rpg_common/eigen_type.h | debugCVML/rpg_information_field | 56f9ffba83aaee796502116e1cf651c5bc405bf6 | [
"MIT"
] | 34 | 2020-06-26T14:50:34.000Z | 2022-03-04T06:45:55.000Z | // handy typedefs of Eigen matrices and vectors, adapted from
// https://github.com/zurich-eye/ze_oss/blob/master/ze_common/include/ze/common/types.hpp
// You can now use
// rpg::Matrix66 for a 6x6 matrix
// rpg::Matrix72 for a 7x2 matrix
// Valid for arbitrary combinations from 1-9.
#pragma once
#include <Eigen/Core>
namespace rpg_common
{
#define ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(SIZE, SUFFIX) \
using Matrix##SUFFIX = Eigen::Matrix<double, SIZE, SIZE>; \
using Matrix1##SUFFIX = Eigen::Matrix<double, 1, SIZE>; \
using Matrix2##SUFFIX = Eigen::Matrix<double, 2, SIZE>; \
using Matrix3##SUFFIX = Eigen::Matrix<double, 3, SIZE>; \
using Matrix4##SUFFIX = Eigen::Matrix<double, 4, SIZE>; \
using Matrix5##SUFFIX = Eigen::Matrix<double, 5, SIZE>; \
using Matrix6##SUFFIX = Eigen::Matrix<double, 6, SIZE>; \
using Matrix7##SUFFIX = Eigen::Matrix<double, 7, SIZE>; \
using Matrix8##SUFFIX = Eigen::Matrix<double, 8, SIZE>; \
using Matrix9##SUFFIX = Eigen::Matrix<double, 9, SIZE>; \
using Matrix##SUFFIX##X = Eigen::Matrix<double, SIZE, Eigen::Dynamic>; \
using MatrixX##SUFFIX = Eigen::Matrix<double, Eigen::Dynamic, SIZE>; \
static const Eigen::MatrixBase<Matrix##SUFFIX>::IdentityReturnType \
I_##SUFFIX##x##SUFFIX = Matrix##SUFFIX::Identity(); \
static const Eigen::MatrixBase<Matrix##SUFFIX>::ConstantReturnType \
Z_##SUFFIX##x##SUFFIX = Matrix##SUFFIX::Zero()
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(1, 1);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(2, 2);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(3, 3);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(4, 4);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(5, 5);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(6, 6);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(7, 7);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(8, 8);
ZE_MAKE_EIGEN_MATRIX_TYPEDEFS(9, 9);
#undef ZE_MAKE_EIGEN_MATRIX_TYPEDEFS
// Typedef arbitary length vector and arbitrary sized matrix.
using VectorX = Eigen::Matrix<double, Eigen::Dynamic, 1>;
using MatrixX = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>;
using VectorXi = Eigen::VectorXi;
// Commonly used fixed size vectors.
using Vector1 = Eigen::Matrix<double, 1, 1>;
using Vector2 = Eigen::Matrix<double, 2, 1>;
using Vector3 = Eigen::Matrix<double, 3, 1>;
using Vector4 = Eigen::Matrix<double, 4, 1>;
using Vector5 = Eigen::Matrix<double, 5, 1>;
using Vector6 = Eigen::Matrix<double, 6, 1>;
using Vector7 = Eigen::Matrix<double, 7, 1>;
using Vector8 = Eigen::Matrix<double, 8, 1>;
using Vector9 = Eigen::Matrix<double, 9, 1>;
using Vector2i = Eigen::Vector2i;
}
namespace rpg = rpg_common;
| 44.460317 | 89 | 0.65191 |
730dca4316a9d5fc949fd3ca8d76178858e050e1 | 36,883 | c | C | calcEnergy.c | yixiangLuo/Liquid_Crystal | 165d41aff4e23837539b928a4181ac3b3e4ce471 | [
"MIT"
] | 1 | 2018-03-22T23:20:32.000Z | 2018-03-22T23:20:32.000Z | calcEnergy.c | yixiangLuo/Liquid_Crystal | 165d41aff4e23837539b928a4181ac3b3e4ce471 | [
"MIT"
] | null | null | null | calcEnergy.c | yixiangLuo/Liquid_Crystal | 165d41aff4e23837539b928a4181ac3b3e4ce471 | [
"MIT"
] | null | null | null | #include "calcEnergy.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "header.h"
#include "bingham.h"
#include "initEnergySpace.h"
extern energySpace* energyDataPointer;
extern binghamDataSpace* binghamDataPointer;
extern mpi_comm_data* mpi_comm_space;
extern clock_t comm_start, comm_end, comm_time;
mpi_comm_data* mpi_init_space(){
mpi_comm_data* mpi_comm_space = (mpi_comm_data*) malloc(sizeof(mpi_comm_data));
mpi_comm_space->mpi_comm_groups = (MPI_Comm*) malloc(3*sizeof(MPI_Comm));
mpi_comm_space->local_total_num = PointTotalNum/(RadiusSlice*ThetaSlice*PhiSlice);
mpi_comm_space->mpi_msg_send = linearSpace_MPI(5*mpi_comm_space->local_total_num, mpi_comm_space);
mpi_comm_space->mpi_msg_rec = linearSpace_MPI(max3(RadiusSlice,ThetaSlice,PhiSlice)*5*mpi_comm_space->local_total_num, mpi_comm_space);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
int color_radius = rank%(ThetaSlice*PhiSlice);
int color_theta = rank/(ThetaSlice*PhiSlice)*size+rank%PhiSlice;
int color_phi = rank/(ThetaSlice*PhiSlice)*size+rank%(ThetaSlice*PhiSlice)/PhiSlice;
MPI_Comm_split(MPI_COMM_WORLD, color_radius, rank, &mpi_comm_space->mpi_comm_groups[0]);
MPI_Comm_split(MPI_COMM_WORLD, color_theta, rank, &mpi_comm_space->mpi_comm_groups[1]);
MPI_Comm_split(MPI_COMM_WORLD, color_phi, rank, &mpi_comm_space->mpi_comm_groups[2]);
return mpi_comm_space;
}
void mpi_free_space(mpi_comm_data* mpi_comm_space){
if(!mpi_comm_space) return;
MPI_Comm_free(&mpi_comm_space->mpi_comm_groups[0]);
MPI_Comm_free(&mpi_comm_space->mpi_comm_groups[1]);
MPI_Comm_free(&mpi_comm_space->mpi_comm_groups[2]);
free((void*) mpi_comm_space->mpi_comm_groups);
free((void*) mpi_comm_space->mpi_msg_send);
free((void*) mpi_comm_space->mpi_msg_rec);
free((void *)mpi_comm_space);
}
double* linearSpace_MPI(int size, mpi_comm_data* mpi_comm_space){
double* dataSpace = (double*) malloc(size*sizeof(double));
if(dataSpace==NULL){
mpi_free_space(mpi_comm_space);
printf("fail to allocate temp space: menmory not enough!\n");
exit(1);
}
return dataSpace;
}
void exchange_vals(int rank, double** src, double** des, mpi_comm_data* mpi_comm_space, int same){
int i, n, m, l, q_index, n_index, m_index, l_index, block_index;
int radius_l = Radius_Low(rank);
int radius_u = Radius_Up(rank);
int theta_l = Theta_Low(rank);
int theta_u = Theta_Up(rank);
int phi_l = Phi_Low(rank);
int phi_u = Phi_Up(rank);
int local_total_num = mpi_comm_space->local_total_num;
double* dEnergy_dQdr_msg = (double*) malloc(5*local_total_num*sizeof(double));
double* dEnergy_dQdr_rev = (double*) malloc(RadiusSlice*5*local_total_num*sizeof(double));
for(i=0;i<3;i++){
if(same==0 || (same==1 && i==0))
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
mpi_comm_space->mpi_msg_send[n_index+m_index+l_index+q_index*local_total_num] = src[i][Point_index(n,m,l)+q_index*PointTotalNum];
}
}
}
}
comm_start = clock();
MPI_Allgather(mpi_comm_space->mpi_msg_send, 5*local_total_num, MPI_DOUBLE, mpi_comm_space->mpi_msg_rec, 5*local_total_num, MPI_DOUBLE, mpi_comm_space->mpi_comm_groups[i]);
comm_end = clock();
comm_time += comm_end-comm_start;
for(n=(i==0?0:radius_l); n<(i==0?PointNumInRadius:radius_u); n++){
n_index = n%(radius_u-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
if(i==0) block_index = n/(radius_u-radius_l);
for(m=(i==1?0:theta_l); m<(i==1?PointNumInTheta:theta_u); m++){
m_index = m%(theta_u-theta_l)*(phi_u-phi_l);
if(i==1) block_index = m/(theta_u-theta_l);
for(l=(i==2?0:phi_l); l<(i==2?PointNumInPhi:phi_u); l++){
l_index = l%(phi_u-phi_l);
if(i==2) block_index = l/(phi_u-phi_l);
for(q_index=0; q_index<5; q_index++){
des[i][Point_index(n,m,l)+q_index*PointTotalNum] = mpi_comm_space->mpi_msg_rec[block_index*5*local_total_num+n_index+m_index+l_index+q_index*local_total_num];
}
}
}
}
}
}
/*void makeB(){
int i, j, k, q_index;
int indexBasis_B, indexBasis_Var;
//径向对称
/ *for(i=0; i<PointNumInRadius; i++){
for(q_index=0; q_index<2; q_index++){
for(j=0; j<PointNumInTheta; j++){
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis_B+k]=energyDataPointer->freeVars[i];
}
}
}
}* /
//旋转对称
for(i=0; i<PointNumInRadius; i++){
for(q_index=0; q_index<4; q_index++){
indexBasis_Var=i*PointNumInTheta+q_index*FreeVarsUnitNum;
for(j=0; j<PointNumInTheta; j++){
//if(fabs(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j]))<SplitCorePoint) continue; //split core 初次求解,限定中部横向,配合初值使用
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis_B+k]=energyDataPointer->freeVars[indexBasis_Var+j];
}
}
}
//q_index=4
indexBasis_Var=i*PointNumInTheta+4*FreeVarsUnitNum;
for(j=0; j<PointNumInTheta; j++){
//if(fabs(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j]))<SplitCorePoint) continue; //split core 初次求解,限定中部横向,配合初值使用
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+4*PointTotalNum;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis_B+k]=energyDataPointer->freeVars[indexBasis_Var+j]-energyDataPointer->pointInPhi[k];
}
}
}
}*/
/*void makeFreeVars(){
int i, j, k, q_index;
int indexBasis_B, indexBasis_Var;
//径向对称
/ *for(i=0; i<PointNumInRadius; i++){
energyDataPointer->freeVars[i]=energyDataPointer->Bdiag_Angle_Elements[i*PointNumInTheta*PointNumInPhi];
}* /
//旋转对称
for(i=0; i<PointNumInRadius; i++){
for(q_index=0; q_index<4; q_index++){
indexBasis_Var=i*PointNumInTheta+q_index*FreeVarsUnitNum;
for(j=0; j<PointNumInTheta; j++){
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
energyDataPointer->freeVars[indexBasis_Var+j]=energyDataPointer->Bdiag_Angle_Elements[indexBasis_B];
}
}
//q_index=4
indexBasis_Var=i*PointNumInTheta+4*FreeVarsUnitNum;
for(j=0; j<PointNumInTheta; j++){
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+4*PointTotalNum;
energyDataPointer->freeVars[indexBasis_Var+j]=energyDataPointer->Bdiag_Angle_Elements[indexBasis_B]+energyDataPointer->pointInPhi[0];
}
}
}*/
/*void transVarsBack(){
int i, j, k, q_index;
int indexBasis_B, indexBasis_Var;
for(i=0; i<FreeVarsTotalNum; i++){
energyDataPointer->dEnergy_freeVars[i]=0;
}
//径向对称
/ *for(i=0; i<PointNumInRadius; i++){
for(q_index=0; q_index<2; q_index++){
for(j=0; j<PointNumInTheta; j++){
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->dEnergy_freeVars[i]+=energyDataPointer->dEnergy_dB[indexBasis_B+k];
}
}
}
}* /
//旋转对称
for(i=0; i<PointNumInRadius; i++){
for(q_index=0; q_index<5; q_index++){
indexBasis_Var=i*PointNumInTheta+q_index*FreeVarsUnitNum;
for(j=0; j<PointNumInTheta; j++){
//if(fabs(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j]))<SplitCorePoint) continue; //split core 初次求解,限定中部横向,配合初值使用
indexBasis_B=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->dEnergy_freeVars[indexBasis_Var+j]+=energyDataPointer->dEnergy_dB[indexBasis_B+k];
}
}
}
}
}*/
double eval_energy(){
int rank;
double energy=0;
double *Q_elem[3];
Q_elem[0]=energyDataPointer->Q_elements;
Q_elem[1]=energyDataPointer->Q_elements;
Q_elem[2]=energyDataPointer->Q_elements;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
preCalculate(rank);
exchange_vals(rank, Q_elem, Q_elem, mpi_comm_space, 1);
calc_Fbulk(rank);
calc_Felas(rank);
calc_Fpena(rank);
comm_start = clock();
MPI_Allreduce(&energyDataPointer->energy, &energy, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
comm_end = clock();
comm_time += comm_end-comm_start;
return energy;
}
void preCalculate(int rank){
int i;
int n, m, l, q_index;
int radius_l = Radius_Low(rank);
int radius_u = Radius_Up(rank);
int theta_l = Theta_Low(rank);
int theta_u = Theta_Up(rank);
int phi_l = Phi_Low(rank);
int phi_u = Phi_Up(rank);
Moments M;
double bingham_B[3]={0};
//计算Q的特征值、Z以及它们关于B的特征值的偏导数
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
bingham_B[0]=energyDataPointer->Bdiag_Angle_Elements[i];
bingham_B[1]=energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i];
bingham_B[2]=-energyDataPointer->Bdiag_Angle_Elements[i]-energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i];
M = bingham(bingham_B, binghamDataPointer);
energyDataPointer->Z_elements[i]=M.Z;
energyDataPointer->dZ_dBdiag[0][i]=2*M.Z_x12+M.Z_x22-M.Z;
energyDataPointer->dZ_dBdiag[1][i]=M.Z_x12+2*M.Z_x22-M.Z;
energyDataPointer->Qdiag_elements[i]=M.Q_x12-1.0/3;
energyDataPointer->Qdiag_elements[PointTotalNum+i]=M.Q_x22-1.0/3;
energyDataPointer->dQdiag_dBdiag[0][i]=2*M.Q_x14+M.Q_x12x22-(2*M.Q_x12+M.Q_x22)*M.Q_x12; //dQ1_dB1
energyDataPointer->dQdiag_dBdiag[1][i]=M.Q_x14+2*M.Q_x12x22-(M.Q_x12+2*M.Q_x22)*M.Q_x12; //dQ1_dB2
energyDataPointer->dQdiag_dBdiag[2][i]=2*M.Q_x12x22+M.Q_x24-(2*M.Q_x12+M.Q_x22)*M.Q_x22; //dQ2_dB1
energyDataPointer->dQdiag_dBdiag[3][i]=M.Q_x12x22+2*M.Q_x24-(M.Q_x12+2*M.Q_x22)*M.Q_x22; //dQ2_dB2
calc_Q_dQdB(i);
}
}
}
energyDataPointer->energy=0;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
for(q_index=0; q_index<5; q_index++){
energyDataPointer->dEnergy_dB[i+q_index*PointTotalNum]=0;
}
}
}
}
}
//通过B旋转矩阵的值和Q的特征值,计算Q的值及Q关于自变量B的偏导数的值
void calc_Q_dQdB(int i){
double alpha=energyDataPointer->Bdiag_Angle_Elements[2*PointTotalNum+i];
double beta=energyDataPointer->Bdiag_Angle_Elements[3*PointTotalNum+i];
double gamma=energyDataPointer->Bdiag_Angle_Elements[4*PointTotalNum+i];
double Q_diag[3]={energyDataPointer->Qdiag_elements[i], energyDataPointer->Qdiag_elements[PointTotalNum+i], -energyDataPointer->Qdiag_elements[i]-energyDataPointer->Qdiag_elements[PointTotalNum+i]};
double dQdiag_dB[2][3]={{energyDataPointer->dQdiag_dBdiag[0][i], energyDataPointer->dQdiag_dBdiag[2][i], -energyDataPointer->dQdiag_dBdiag[0][i]-energyDataPointer->dQdiag_dBdiag[2][i]}, {energyDataPointer->dQdiag_dBdiag[1][i], energyDataPointer->dQdiag_dBdiag[3][i], -energyDataPointer->dQdiag_dBdiag[1][i]-energyDataPointer->dQdiag_dBdiag[3][i]}};
double sin_alpha=sin(alpha), cos_alpha=cos(alpha);
double sin_beta=sin(beta), cos_beta=cos(beta);
double sin_gamma=sin(gamma), cos_gamma=cos(gamma);
double euler[3][3]={
{cos_alpha*cos_gamma - cos_beta*sin_alpha*sin_gamma, cos_gamma*sin_alpha + cos_alpha*cos_beta*sin_gamma, sin_beta*sin_gamma},
{-(cos_beta*cos_gamma*sin_alpha) - cos_alpha*sin_gamma, cos_alpha*cos_beta*cos_gamma - sin_alpha*sin_gamma, cos_gamma*sin_beta},
{sin_alpha*sin_beta, -(cos_alpha*sin_beta), cos_beta}};
double euler_dAlpha[3][3]={
{-(cos_gamma*sin_alpha) - cos_alpha*cos_beta*sin_gamma,cos_alpha*cos_gamma - cos_beta*sin_alpha*sin_gamma,0},
{-(cos_alpha*cos_beta*cos_gamma) + sin_alpha*sin_gamma,-(cos_beta*cos_gamma*sin_alpha) - cos_alpha*sin_gamma,0},
{cos_alpha*sin_beta,sin_alpha*sin_beta,0}};
double euler_dBeta[3][3]={
{sin_alpha*sin_beta*sin_gamma,-(cos_alpha*sin_beta*sin_gamma),cos_beta*sin_gamma},
{cos_gamma*sin_alpha*sin_beta,-(cos_alpha*cos_gamma*sin_beta),cos_beta*cos_gamma},
{cos_beta*sin_alpha,-(cos_alpha*cos_beta),-sin_beta}};
double euler_dGamma[3][3]={
{-(cos_beta*cos_gamma*sin_alpha) - cos_alpha*sin_gamma,cos_alpha*cos_beta*cos_gamma - sin_alpha*sin_gamma,cos_gamma*sin_beta},
{-(cos_alpha*cos_gamma) + cos_beta*sin_alpha*sin_gamma,-(cos_gamma*sin_alpha) - cos_alpha*cos_beta*sin_gamma,-(sin_beta*sin_gamma)},
{0,0,0}};
int indexTans[2][5]={{0, 0, 0, 1, 1}, {0, 1, 2, 1, 2}};
int k, j;
double val, val1, val2, val3;
for(k=0; k<5; k++){
val1=0; val2=0; val3=0;
for(j=0; j<3; j++){
val=euler[indexTans[0][k]][j]*euler[indexTans[1][k]][j];
val1+=val*Q_diag[j];
val2+=val*dQdiag_dB[0][j];
val3+=val*dQdiag_dB[1][j];
}
energyDataPointer->Q_elements[k*PointTotalNum+i]=val1;
energyDataPointer->dQ_dBdiagAngle[i][k]=val2;
energyDataPointer->dQ_dBdiagAngle[i][5+k]=val3;
}
for(k=0; k<5; k++){
val1=0; val2=0; val3=0;
for(j=0; j<3; j++){
val1+=euler[indexTans[0][k]][j]*Q_diag[j]*euler_dAlpha[indexTans[1][k]][j]+euler[indexTans[1][k]][j]*Q_diag[j]*euler_dAlpha[indexTans[0][k]][j];
val2+=euler[indexTans[0][k]][j]*Q_diag[j]*euler_dBeta[indexTans[1][k]][j]+euler[indexTans[1][k]][j]*Q_diag[j]*euler_dBeta[indexTans[0][k]][j];
val3+=euler[indexTans[0][k]][j]*Q_diag[j]*euler_dGamma[indexTans[1][k]][j]+euler[indexTans[1][k]][j]*Q_diag[j]*euler_dGamma[indexTans[0][k]][j];
}
energyDataPointer->dQ_dBdiagAngle[i][2*5+k]=val1;
energyDataPointer->dQ_dBdiagAngle[i][3*5+k]=val2;
energyDataPointer->dQ_dBdiagAngle[i][4*5+k]=val3;
}
}
void calc_Fbulk(int rank){
int i;
int n, m, l;
int radius_l = Radius_Low(rank);
int radius_u = Radius_Up(rank);
int theta_l = Theta_Low(rank);
int theta_u = Theta_Up(rank);
int phi_l = Phi_Low(rank);
int phi_u = Phi_Up(rank);
double energy=0;
//Int[Q:B - Ln(Z)] = b1*q1 + b2*q2 + (b1 + b2)*(q1 + q2) - ln(Z)
//泛函值
energy=0;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
energy += energyDataPointer->ballInteCor[i]*(energyDataPointer->Bdiag_Angle_Elements[i]*energyDataPointer->Qdiag_elements[i] + energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i]*energyDataPointer->Qdiag_elements[PointTotalNum+i] + (energyDataPointer->Bdiag_Angle_Elements[i] + energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i]) * (energyDataPointer->Qdiag_elements[i] + energyDataPointer->Qdiag_elements[PointTotalNum+i]) - log(energyDataPointer->Z_elements[i]));
}
}
}
energyDataPointer->energy += energy;
//对自变量的导数
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
//dEnergy_dB1
energyDataPointer->dEnergy_dB[i] += energyDataPointer->ballInteCor[i]*( 2*energyDataPointer->Qdiag_elements[i] + energyDataPointer->Qdiag_elements[PointTotalNum+i] + (2*energyDataPointer->Bdiag_Angle_Elements[i] + energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i])*energyDataPointer->dQdiag_dBdiag[0][i] + (energyDataPointer->Bdiag_Angle_Elements[i] + 2*energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i])*energyDataPointer->dQdiag_dBdiag[2][i] - energyDataPointer->dZ_dBdiag[0][i]/energyDataPointer->Z_elements[i]);
//dEnergy_dB2
energyDataPointer->dEnergy_dB[PointTotalNum+i] += energyDataPointer->ballInteCor[i]*( energyDataPointer->Qdiag_elements[i] + 2*energyDataPointer->Qdiag_elements[PointTotalNum+i] + (2*energyDataPointer->Bdiag_Angle_Elements[i] + energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i])*energyDataPointer->dQdiag_dBdiag[1][i] + (energyDataPointer->Bdiag_Angle_Elements[i] + 2*energyDataPointer->Bdiag_Angle_Elements[PointTotalNum+i])*energyDataPointer->dQdiag_dBdiag[3][i] - energyDataPointer->dZ_dBdiag[1][i]/energyDataPointer->Z_elements[i]);
//其他为0
}
}
}
//Int[|Q|^2] = q1^2 + q2^2 + (q1 + q2)^2
//泛函值
energy=0;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
energy += energyDataPointer->ballInteCor[i]*2*(energyDataPointer->Qdiag_elements[i]*energyDataPointer->Qdiag_elements[i] + energyDataPointer->Qdiag_elements[i]*energyDataPointer->Qdiag_elements[PointTotalNum+i] + energyDataPointer->Qdiag_elements[PointTotalNum+i]*energyDataPointer->Qdiag_elements[PointTotalNum+i]);
}
}
}
energyDataPointer->energy += -Alpha1*0.5 * energy;
//对自变量的导数
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
//dEnergy_dB1
energyDataPointer->dEnergy_dB[i] += -Alpha1*0.5 * energyDataPointer->ballInteCor[i]*2*(energyDataPointer->Qdiag_elements[i]*(2*energyDataPointer->dQdiag_dBdiag[0][i] + energyDataPointer->dQdiag_dBdiag[2][i]) + energyDataPointer->Qdiag_elements[PointTotalNum+i]*(energyDataPointer->dQdiag_dBdiag[0][i] + 2*energyDataPointer->dQdiag_dBdiag[2][i]));
//dEnergy_dB2
energyDataPointer->dEnergy_dB[PointTotalNum+i] += -Alpha1*0.5 * energyDataPointer->ballInteCor[i]*2*(energyDataPointer->Qdiag_elements[i]*(2*energyDataPointer->dQdiag_dBdiag[1][i] + energyDataPointer->dQdiag_dBdiag[3][i]) + energyDataPointer->Qdiag_elements[PointTotalNum+i]*(energyDataPointer->dQdiag_dBdiag[1][i] + 2*energyDataPointer->dQdiag_dBdiag[3][i]));
//其他为0
}
}
}
}
void calc_Felas(int rank){
int i, j, k, n, m, l, q_index;
int indexBasis;
int radius_l = Radius_Low(rank);
int radius_u = Radius_Up(rank);
int theta_l = Theta_Low(rank);
int theta_u = Theta_Up(rank);
int phi_l = Phi_Low(rank);
int phi_u = Phi_Up(rank);
double count=0, energy=0;
for(q_index=0; q_index<5; q_index++){
for(j=theta_l; j<theta_u; j++){
for(k=phi_l; k<phi_u; k++){
indexBasis=j*PointNumInPhi+k+q_index*PointTotalNum;
for(l=radius_l; l<radius_u; l++){
count=0;
for(i=0; i<PointNumInRadius; i++){
count+=energyDataPointer->gradMatrix_radius[l][i] * energyDataPointer->Q_elements[i*PointNumInTheta*PointNumInPhi+indexBasis];
}
energyDataPointer->dQ_drtp[0][l*PointNumInTheta*PointNumInPhi+indexBasis]=count;
}
}
}
for(i=radius_l; i<radius_u; i++){
for(k=phi_l; k<phi_u; k++){
indexBasis=i*PointNumInTheta*PointNumInPhi+k+q_index*PointTotalNum;
for(l=theta_l; l<theta_u; l++){
count=0;
for(j=0; j<PointNumInTheta; j++){
count+=energyDataPointer->gradMatrix_theta[l][j] * energyDataPointer->Q_elements[j*PointNumInPhi+indexBasis];
}
energyDataPointer->dQ_drtp[1][l*PointNumInPhi+indexBasis]=count;
}
}
}
for(i=radius_l; i<radius_u; i++){
for(j=theta_l; j<theta_u; j++){
indexBasis=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi+q_index*PointTotalNum;
for(l=phi_l; l<phi_u; l++){
count=0;
for(k=0; k<PointNumInPhi; k++){
count+=energyDataPointer->gradMatrix_phi[l][k] * energyDataPointer->Q_elements[k+indexBasis];
}
energyDataPointer->dQ_drtp[2][l+indexBasis]=count;
}
}
}
}
double dQ_dxyz[3][5]={0}; //行dx,dy,dz, 列q1,q2,...,q5
double x, y, z;
double norm, norm_2, semiNorm, semiNorm_2;
double cordTrans[3][3];
energy=0;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
//将“对rtp的导数”转化为“对xyz的导数”的准备
x=energyDataPointer->pointsInBall[0][i];
y=energyDataPointer->pointsInBall[1][i];
z=energyDataPointer->pointsInBall[2][i];
semiNorm_2=x*x+y*y;
semiNorm=sqrt(semiNorm_2);
norm_2=semiNorm_2+z*z;
norm=sqrt(norm_2);
cordTrans[0][0]=x/norm; cordTrans[0][1]=x*z/semiNorm/norm_2; cordTrans[0][2]=-y/semiNorm_2;
cordTrans[1][0]=y/norm; cordTrans[1][1]=y*z/semiNorm/norm_2; cordTrans[1][2]=x/semiNorm_2;
cordTrans[2][0]=z/norm; cordTrans[2][1]=-semiNorm/norm_2; cordTrans[2][2]=0;
//算出i点处q1-q5的对xyz的偏导数值
for(q_index=0; q_index<5; q_index++){
for(j=0; j<3; j++){
dQ_dxyz[j][q_index]=cordTrans[j][0]*energyDataPointer->dQ_drtp[0][i+q_index*PointTotalNum] + cordTrans[j][1]*energyDataPointer->dQ_drtp[1][i+q_index*PointTotalNum] + cordTrans[j][2]*energyDataPointer->dQ_drtp[2][i+q_index*PointTotalNum];
}
}
//计算泛函值
count=0;
for(q_index=0; q_index<5; q_index++){
count+=dQ_dxyz[0][q_index]*dQ_dxyz[0][q_index]+dQ_dxyz[1][q_index]*dQ_dxyz[1][q_index]+dQ_dxyz[2][q_index]*dQ_dxyz[2][q_index];
}
energy += energyDataPointer->ballInteCor[i]*(count + dQ_dxyz[0][0]*dQ_dxyz[0][3]+dQ_dxyz[1][0]*dQ_dxyz[1][3]+dQ_dxyz[2][0]*dQ_dxyz[2][3]);
//计算dEnergy_dQdrtp
for(q_index=1; q_index<5; q_index++){ //q2, q3, q5
if(q_index==3) continue;
for(j=0; j<3; j++){
energyDataPointer->dEnergy_dQdrtp[j][i+q_index*PointTotalNum]=Alpha2*energyDataPointer->ballInteCor[i]*2*(cordTrans[0][j]*dQ_dxyz[0][q_index] + cordTrans[1][j]*dQ_dxyz[1][q_index] + cordTrans[2][j]*dQ_dxyz[2][q_index]);
}
}
for(j=0; j<3; j++){ //q1
energyDataPointer->dEnergy_dQdrtp[j][i]=Alpha2*energyDataPointer->ballInteCor[i]*(cordTrans[0][j]*(2*dQ_dxyz[0][0]+dQ_dxyz[0][3]) + cordTrans[1][j]*(2*dQ_dxyz[1][0]+dQ_dxyz[1][3]) + cordTrans[2][j]*(2*dQ_dxyz[2][0]+dQ_dxyz[2][3]));
}
for(j=0; j<3; j++){ //q4
energyDataPointer->dEnergy_dQdrtp[j][i+3*PointTotalNum]=Alpha2*energyDataPointer->ballInteCor[i]*(cordTrans[0][j]*(2*dQ_dxyz[0][3]+dQ_dxyz[0][0]) + cordTrans[1][j]*(2*dQ_dxyz[1][3]+dQ_dxyz[1][0]) + cordTrans[2][j]*(2*dQ_dxyz[2][3]+dQ_dxyz[2][0]));
}
}
}
}
energyDataPointer->energy += Alpha2*energy;
// mpi传输dEnergy_dQdrtp
exchange_vals(rank, energyDataPointer->dEnergy_dQdrtp, energyDataPointer->dEnergy_dQdrtp, mpi_comm_space, 0);
/*
int n_index, m_index, l_index, block_index;
int local_total_num = (radius_u-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
//radius组
double* dEnergy_dQdr_msg = (double*) malloc(5*local_total_num*sizeof(double));
double* dEnergy_dQdr_rev = (double*) malloc(RadiusSlice*5*local_total_num*sizeof(double));
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
dEnergy_dQdr_msg[n_index+m_index+l_index+q_index*local_total_num] = energyDataPointer->dEnergy_dQdrtp[0][Point_index(n,m,l)+q_index*PointTotalNum];
}
}
}
}
MPI_Allgather(dEnergy_dQdr_msg, 5*local_total_num, MPI_DOUBLE, dEnergy_dQdr_rev, 5*local_total_num, MPI_DOUBLE, mpi_radius_group);
for(n=0; n<PointNumInRadius; n++){
n_index = n%(radius_u-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
block_index = n/(radius_u-radius_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
energyDataPointer->dEnergy_dQdrtp[0][Point_index(n,m,l)+q_index*PointTotalNum] = dEnergy_dQdr_rev[block_index*5*local_total_num+n_index+m_index+l_index+q_index*local_total_num];
}
}
}
}
free((void *)dEnergy_dQdr_msg);
free((void *)dEnergy_dQdr_rev);
//theta组
double* dEnergy_dQdt_msg = (double*) malloc(5*local_total_num*sizeof(double));
double* dEnergy_dQdt_rev = (double*) malloc(ThetaSlice*5*local_total_num*sizeof(double));
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
dEnergy_dQdt_msg[n_index+m_index+l_index+q_index*local_total_num] = energyDataPointer->dEnergy_dQdrtp[1][Point_index(n,m,l)+q_index*PointTotalNum];
}
}
}
}
MPI_Allgather(dEnergy_dQdt_msg, 5*local_total_num, MPI_DOUBLE, dEnergy_dQdt_rev, 5*local_total_num, MPI_DOUBLE, mpi_theta_group);
for(m=0; m<PointNumInTheta; m++){
m_index = m%(theta_u-theta_l)*(phi_u-phi_l);
block_index = m/(theta_u-theta_l);
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
energyDataPointer->dEnergy_dQdrtp[1][Point_index(n,m,l)+q_index*PointTotalNum] = dEnergy_dQdt_rev[block_index*5*local_total_num+n_index+m_index+l_index+q_index*local_total_num];
}
}
}
}
free((void *)dEnergy_dQdt_msg);
free((void *)dEnergy_dQdt_rev);
//phi组
double* dEnergy_dQdp_msg = (double*) malloc(5*local_total_num*sizeof(double));
double* dEnergy_dQdp_rev = (double*) malloc(PhiSlice*5*local_total_num*sizeof(double));
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(l=phi_l; l<phi_u; l++){
l_index = l-phi_l;
for(q_index=0; q_index<5; q_index++){
dEnergy_dQdp_msg[n_index+m_index+l_index+q_index*local_total_num] = energyDataPointer->dEnergy_dQdrtp[2][Point_index(n,m,l)+q_index*PointTotalNum];
}
}
}
}
MPI_Allgather(dEnergy_dQdp_msg, 5*local_total_num, MPI_DOUBLE, dEnergy_dQdp_rev, 5*local_total_num, MPI_DOUBLE, mpi_phi_group);
for(l=0; l<PointNumInPhi; l++){
l_index = l%(phi_u-phi_l);
block_index = l/(phi_u-phi_l);
for(n=radius_l; n<radius_u; n++){
n_index = (n-radius_l)*(theta_u-theta_l)*(phi_u-phi_l);
for(m=theta_l; m<theta_u; m++){
m_index = (m-theta_l)*(phi_u-phi_l);
for(q_index=0; q_index<5; q_index++){
energyDataPointer->dEnergy_dQdrtp[2][Point_index(n,m,l)+q_index*PointTotalNum] = dEnergy_dQdp_rev[block_index*5*local_total_num+n_index+m_index+l_index+q_index*local_total_num];
}
}
}
}
free((void *)dEnergy_dQdp_msg);
free((void *)dEnergy_dQdp_rev);
*/
//继续计算偏导数
for(q_index=0; q_index<5; q_index++){
for(i=radius_l; i<radius_u; i++){
for(j=theta_l; j<theta_u; j++){
for(k=phi_l; k<phi_u; k++){
count=0;
for(l=0; l<PointNumInRadius; l++){
count+=energyDataPointer->gradMatrix_radius[l][i] * energyDataPointer->dEnergy_dQdrtp[0][Point_index(l,j,k)+q_index*PointTotalNum];
}
for(l=0; l<PointNumInTheta; l++){
count+=energyDataPointer->gradMatrix_theta[l][j] * energyDataPointer->dEnergy_dQdrtp[1][Point_index(i,l,k)+q_index*PointTotalNum];
}
for(l=0; l<PointNumInPhi; l++){
count+=energyDataPointer->gradMatrix_phi[l][k] * energyDataPointer->dEnergy_dQdrtp[2][Point_index(i,j,l)+q_index*PointTotalNum];
}
energyDataPointer->dEnergy_dQ[Point_index(i,j,k)][q_index]=count;
}
}
}
}
double* pointer1;
double* pointer2;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
pointer1=energyDataPointer->dQ_dBdiagAngle[i];
for(j=0; j<5; j++){
pointer2=energyDataPointer->dEnergy_dQ[i];
count=0;
for(k=0; k<5; k++){
count+=(*pointer1)*(*pointer2);
pointer1++;
pointer2++;
}
energyDataPointer->dEnergy_dB[j*PointTotalNum+i]+=count;
}
}
}
}
pointer1=NULL;
pointer2=NULL;
}
void calc_Fpena(int rank){
int i, j, k, n, m, l, q_index;
int radius_l = Radius_Low(rank);
int radius_u = Radius_Up(rank);
int theta_l = Theta_Low(rank);
int theta_u = Theta_Up(rank);
int phi_l = Phi_Low(rank);
int phi_u = Phi_Up(rank);
int indexBasis, index;
double row1, row2, row3;
double x, y, z;
double q[5]={0};
double q_std[5]={0};
double p[4]={0};
double dFpena_dq[5]={0};
double count=0, energy=0;
energy=0;
for(j=theta_l; j<theta_u; j++){
for(k=phi_l; k<phi_u; k++){
//计算球面上某点处的函数值(q1-q5)
for(q_index=0; q_index<5; q_index++){
indexBasis=j*PointNumInPhi+k+q_index*PointTotalNum;
count=0;
for(i=0; i<PointNumInRadius; i++){
count+=energyDataPointer->sideValVector[i] * energyDataPointer->Q_elements[i*PointNumInTheta*PointNumInPhi+indexBasis];
}
q[q_index]=count;
}
//松弛锚定边界条件
//计算泛函值
index=j*PointNumInPhi+k;
x=energyDataPointer->pointsInSphere[0][index];
y=energyDataPointer->pointsInSphere[1][index];
z=energyDataPointer->pointsInSphere[2][index];
p[0]=q[0]*x*y-q[1]*(x*x-1.0/3);
p[1]=q[1]*z-q[2]*y;
p[2]=q[3]*x*y-q[1]*(y*y-1.0/3);
p[3]=q[1]*z-q[4]*x;
if(radius_u==PointNumInRadius){
count=0;
for(i=0; i<4; i++){
count+=p[i]*p[i];
}
energy += energyDataPointer->sphereInteCor[index]*count;
}
//计算偏导数值
dFpena_dq[0]=Eta*energyDataPointer->sphereInteCor[index]*2*(p[0]*x*y);
dFpena_dq[1]=Eta*energyDataPointer->sphereInteCor[index]*2*(-p[0]*(x*x-1.0/3)+p[1]*z-p[2]*(y*y-1.0/3)+p[3]*z);
dFpena_dq[2]=Eta*energyDataPointer->sphereInteCor[index]*2*(-p[1]*y);
dFpena_dq[3]=Eta*energyDataPointer->sphereInteCor[index]*2*(p[2]*x*y);
dFpena_dq[4]=Eta*energyDataPointer->sphereInteCor[index]*2*(-p[3]*x);
for(q_index=0; q_index<5; q_index++){
for(i=radius_l; i<radius_u; i++){
energyDataPointer->dEnergy_dQ[i*PointNumInTheta*PointNumInPhi+index][q_index]=energyDataPointer->sideValVector[i] * dFpena_dq[q_index];
}
}
/*//强锚定边界条件 罚项 |Q-Q'|^2
//计算泛函值
index=j*PointNumInPhi+k;
x=energyDataPointer->pointsInSphere[0][index];
y=energyDataPointer->pointsInSphere[1][index];
z=energyDataPointer->pointsInSphere[2][index];
q_std[0]=S*(x*x-1.0/3);
q_std[1]=S*x*y;
q_std[2]=S*x*z;
q_std[3]=S*(y*y-1.0/3);
q_std[4]=S*y*z;
if(radius_u==PointNumInRadius){
count=0;
for(i=0; i<5; i++){
count+=(q[i]-q_std[i])*(q[i]-q_std[i]);
}
energy += energyDataPointer->sphereInteCor[index]*count;
}
//计算偏导数值
for(i=0; i<5; i++){
dFpena_dq[i]=Eta*energyDataPointer->sphereInteCor[index]*2*(q[i]-q_std[i]);
}
for(q_index=0; q_index<5; q_index++){
for(i=radius_l; i<radius_u; i++){
energyDataPointer->dEnergy_dQ[i*PointNumInTheta*PointNumInPhi+index][q_index]=energyDataPointer->sideValVector[i] * dFpena_dq[q_index];
}
}
*/
/*//罚项 |Q*x|^2
//计算泛函值
index=j*PointNumInPhi+k;
x=energyDataPointer->pointsInSphere[0][index];
y=energyDataPointer->pointsInSphere[1][index];
z=energyDataPointer->pointsInSphere[2][index];
row1=q[0]*x + q[1]*y + q[2]*z;
row2=q[1]*x + q[3]*y + q[4]*z;
row3=q[2]*x + q[4]*y - (q[0]+q[3])*z;
if(radius_u==PointNumInRadius) energy += energyDataPointer->sphereInteCor[index]*(row1*row1 + row2*row2 + row3*row3);
//计算偏导数值
dFpena_dq[0]=Eta*energyDataPointer->sphereInteCor[index]*2*(row1*x - row3*z);
dFpena_dq[1]=Eta*energyDataPointer->sphereInteCor[index]*2*(row1*y + row2*x);
dFpena_dq[2]=Eta*energyDataPointer->sphereInteCor[index]*2*(row1*z + row3*x);
dFpena_dq[3]=Eta*energyDataPointer->sphereInteCor[index]*2*(row2*y - row3*z);
dFpena_dq[4]=Eta*energyDataPointer->sphereInteCor[index]*2*(row2*z + row3*y);
for(q_index=0; q_index<5; q_index++){
for(i=radius_l; i<radius_u; i++){
energyDataPointer->dEnergy_dQ[i*PointNumInTheta*PointNumInPhi+index][q_index]=energyDataPointer->sideValVector[i] * dFpena_dq[q_index];
}
}
*/
}
}
if(radius_u==PointNumInRadius){
energyDataPointer->energy += Eta*energy;
}
double* pointer1;
double* pointer2;
for(n=radius_l; n<radius_u; n++){
for(m=theta_l; m<theta_u; m++){
for(l=phi_l; l<phi_u; l++){
i=Point_index(n,m,l);
pointer1=energyDataPointer->dQ_dBdiagAngle[i];
for(j=0; j<5; j++){
pointer2=energyDataPointer->dEnergy_dQ[i];
count=0;
for(k=0; k<5; k++){
count+=(*pointer1)*(*pointer2);
pointer1++;
pointer2++;
}
energyDataPointer->dEnergy_dB[j*PointTotalNum+i]+=count;
}
}
}
}
pointer1=NULL;
pointer2=NULL;
}
void setInitValue(){
int i, j, k;
//无序初值
/* for(i=0; i<5*FreeVarsUnitNum; i++){
energyDataPointer->freeVars[i]=0;
} */
//随机初值
/*srand((unsigned)time(NULL));
for(i=0;i<5*PointTotalNum;i++){
energyDataPointer->Bdiag_Angle_Elements[i] = 0*(2.0*rand()/RAND_MAX - 1);
}*/
//随机初值
/*srand((unsigned)time(NULL));
for(i=0;i<FreeVarsTotalNum;i++){
energyDataPointer->freeVars[i] = 2*(2.0*rand()/RAND_MAX - 1);
}*/
//hedgehog初值
/*int indexBasis;
for(i=0; i<PointNumInRadius; i++){
energyDataPointer->freeVars[i]=-2.375*energyDataPointer->pointInRadius[i];
for(j=0; j<PointNumInTheta; j++){
indexBasis=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=energyDataPointer->pointInTheta[j];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=PI/2-energyDataPointer->pointInPhi[k];
}
}
}*/
//hedgehog初值,ring初值
int indexBasis;
for(i=0; i<PointNumInRadius; i++){
for(j=0; j<PointNumInTheta; j++){
indexBasis=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=-2.375*energyDataPointer->pointInRadius[i];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=-2.375*energyDataPointer->pointInRadius[i];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=energyDataPointer->pointInTheta[j];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=PI/2-energyDataPointer->pointInPhi[k];
}
}
}
//makeFreeVars();
//sphereRing解
/*int indexBasis;
for(i=0; i<PointNumInRadius; i++){
for(j=0; j<PointNumInTheta; j++){
indexBasis=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi;
for(k=0; k<PointNumInPhi; k++){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=-2;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=-2;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=0;
}
}
}
//makeFreeVars();*/
//split core初值
/*int indexBasis;
for(i=0; i<PointNumInRadius; i++){
for(j=0; j<PointNumInTheta; j++){
indexBasis=i*PointNumInTheta*PointNumInPhi+j*PointNumInPhi;
for(k=0; k<PointNumInPhi; k++){
/*if(fabs(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j]))<SplitCorePoint){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=-1*energyDataPointer->pointInRadius[i]-0.5;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=-1*energyDataPointer->pointInRadius[i]-0.5;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=PI/2;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=PI/2-energyDataPointer->pointInPhi[k];
}
else{
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=-2*(energyDataPointer->pointInRadius[i]-SplitCorePoint);
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=-2*(energyDataPointer->pointInRadius[i]-SplitCorePoint);
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
if(energyDataPointer->pointInTheta[j]<PI/2){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=atan(energyDataPointer->pointInRadius[i]*sin(energyDataPointer->pointInTheta[j])/(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j])-SplitCorePoint));
}
else{
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=atan(energyDataPointer->pointInRadius[i]*sin(energyDataPointer->pointInTheta[j])/(energyDataPointer->pointInRadius[i]*cos(energyDataPointer->pointInTheta[j])+SplitCorePoint))+PI;
}
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=PI/2-energyDataPointer->pointInPhi[k];
}*
if(energyDataPointer->pointInRadius[i]<0.9){
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=5;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=5;
}
else{
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+0*PointTotalNum]=-2*energyDataPointer->pointInRadius[i];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+1*PointTotalNum]=-2*energyDataPointer->pointInRadius[i];
}
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+2*PointTotalNum]=0;
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+3*PointTotalNum]=energyDataPointer->pointInTheta[j];
energyDataPointer->Bdiag_Angle_Elements[indexBasis+k+4*PointTotalNum]=PI/2-energyDataPointer->pointInPhi[k];
}
}
}
//makeFreeVars();*/
//读取已有结果
/*FILE* fp;
if((fp=fopen("result/B.txt","r"))==NULL) exit(1);
for(i=0; i<5*PointTotalNum; i++){
fscanf(fp, "%lf ", &energyDataPointer->Bdiag_Angle_Elements[i]);
}
fclose(fp);
//makeFreeVars();*/
}
| 38.54023 | 547 | 0.70805 |
4cffb7af37cb8a7148234f64929680aab57aa756 | 29 | h | C | common/config/custom.h | lk565434471/legend | 046731a0ae4e28d4a57689f203c4936cb6e8877a | [
"MIT"
] | null | null | null | common/config/custom.h | lk565434471/legend | 046731a0ae4e28d4a57689f203c4936cb6e8877a | [
"MIT"
] | null | null | null | common/config/custom.h | lk565434471/legend | 046731a0ae4e28d4a57689f203c4936cb6e8877a | [
"MIT"
] | null | null | null |
// #define LEGEND_NAMESPACE | 9.666667 | 27 | 0.758621 |
21a30330ccd2db87714a44a0f2360ae09fd38326 | 1,654 | c | C | Exercise-2/d.XOR_value_of_Two_Varaibles.c | itsMadesh/C-programs | fab74dda093d86b46331d38414d39b924f134b63 | [
"MIT"
] | 1 | 2022-01-19T09:39:24.000Z | 2022-01-19T09:39:24.000Z | Exercise-2/d.XOR_value_of_Two_Varaibles.c | itsMadesh/C-programs | fab74dda093d86b46331d38414d39b924f134b63 | [
"MIT"
] | null | null | null | Exercise-2/d.XOR_value_of_Two_Varaibles.c | itsMadesh/C-programs | fab74dda093d86b46331d38414d39b924f134b63 | [
"MIT"
] | null | null | null | #include <stdio.h>
int bin(int c, int d)
{
int s, r, temp = 1, value = 0;
while (c != 0 || d != 0)
{
r = c % 2;
s = d % 2;
if (r != s)
{
value = value + temp;
}
temp = temp * 2;
c = c / 2;
d = d / 2;
}
return value;
}
int main()
{
int a, b;
printf("Enter value of a and b:");
scanf("%d%d", &a, &b);
printf("%d^%d=%d", a, b,bin(a, b));
}
/*#include <stdio.h>
int neg_binaryvalue(int a)
{
int s = 0, dum = 1;
while (a != 0)
{
int d = a % 2;
if (d == 0)
{
s += dum;
}
dum = dum * 10;
a = a / 2;
}
return s | 1;
}
int pos_binaryvalue(int a)
{
int s = 0, dum = 1;
while (a != 0)
{
int d = a % 2;
s += dum * d;
dum = dum * 10;
a = a / 2;
}
return s;
}
int xorvalue(int c, int d)
{
int s, r, temp = 1, value = 0;
while (c != 0 || d != 0)
{
r = c % 10;
s = d % 10;
if (r != s)
{
value = value + temp;
}
temp = temp * 2;
c = c / 10;
d = d / 10;
}
return value;
}
int getBinaryValue(int v)
{
return v >= 0 ? pos_binaryvalue(v) : neg_binaryvalue(v);
}
int main()
{
printf("%d", !5);
int a, b, c, d, s = 0, dum = 1;
printf("Enter value of a and b:");
scanf("%d%d", &a, &b);
c = getBinaryValue(a);
d = getBinaryValue(b);
printf("%d and %d\n", c, d);
int ans = xorvalue(c, d);
printf("xor : %d\n", (a ^ b));
printf("%d^%d=%d", a, b, (a < 0 || b < 0) ? -ans : ans);
}*/ | 17.229167 | 60 | 0.379686 |
51bc594636e4e0186597ff32832c4a8299a2c63c | 608 | h | C | interface/ttbarReco.h | cms-ttbarAC/cheetah | 76457d3cb3936dac5c78957b66b3b8aa213ca2b7 | [
"MIT"
] | null | null | null | interface/ttbarReco.h | cms-ttbarAC/cheetah | 76457d3cb3936dac5c78957b66b3b8aa213ca2b7 | [
"MIT"
] | 1 | 2018-08-29T19:28:24.000Z | 2018-10-04T18:21:35.000Z | interface/ttbarReco.h | cms-ttbarAC/cheetah | 76457d3cb3936dac5c78957b66b3b8aa213ca2b7 | [
"MIT"
] | null | null | null | #ifndef TTBARRECO_H
#define TTBARRECO_H
#include <string>
#include <map>
#include <vector>
#include "Analysis/cheetah/interface/physicsObjects.h"
#include "Analysis/cheetah/interface/tools.h"
#include "Analysis/cheetah/interface/configuration.h"
class ttbarReco {
public:
ttbarReco( configuration& cmaConfig );
~ttbarReco();
Ttbar1L ttbar1L() {return m_ttbar1L;}
// single lepton
void execute(std::vector<Lepton>& leptons, std::vector<Neutrino>& nu, std::vector<Jet>& jets, std::vector<Ljet>& ljets);
protected:
configuration *m_config;
Ttbar1L m_ttbar1L;
};
#endif
| 19.612903 | 124 | 0.717105 |
99ac170b8165299b5f10c5ec9aea16b41434bac9 | 29,026 | h | C | include/envs/classic_control/rendering.h | dougkiely/cppgym | 03663e40ec1207d0e048a443f8479f71bbc95fa0 | [
"MIT"
] | 1 | 2022-01-24T23:59:52.000Z | 2022-01-24T23:59:52.000Z | include/envs/classic_control/rendering.h | dougkiely/cppgym | 03663e40ec1207d0e048a443f8479f71bbc95fa0 | [
"MIT"
] | null | null | null | include/envs/classic_control/rendering.h | dougkiely/cppgym | 03663e40ec1207d0e048a443f8479f71bbc95fa0 | [
"MIT"
] | 1 | 2022-01-25T03:32:19.000Z | 2022-01-25T03:32:19.000Z | #pragma once
#include <algorithm>
#include <cmath>
#include <concepts>
#include <functional>
#include <iostream> // debug
#include <memory>
#include <numbers>
#include <vector>
#include <GL/gl.h>
#include <GL/freeglut.h>
namespace gym::envs::classic_control {
// TODO: check for GL errors by calling glGetError() after each gl*() call
// TODO: check for GLUT errors after each glut*() call
// TODO: check for const-correctness in this code, although it's likely only a few members functions code in here is const (it's all mutable data and function calls)
// TODO: add any appropriate noexcept clauses
/*display_type get_display(spec_type& spec) {
return display_type {spec};
}
window_type get_window(uint64_t width, uint64_t height, display_type display, char** args) {
return window_type {width, height, display, args};
}*/
template<typename T>
concept attr_concept = requires(T t) {
t.enable(); // TODO: should enable() be changed to show()? Probably not.
t.disable();// TODO: should disable() be changed to hide()? Probably not.
{ t.to_string() } -> std::convertible_to<std::string>;
};
template<typename T>
concept point_2d_concept = std::default_initializable<T> && std::constructible_from<T, typename T::value_type, typename T::value_type> && requires(T t) {
{ t.x } -> std::convertible_to<typename T::value_type>;
{ t.y } -> std::convertible_to<typename T::value_type>;
};
template<typename T>
concept point_3d_concept = std::default_initializable<T> && std::constructible_from<T, typename T::value_type, typename T::value_type, typename T::value_type> && requires(T t) {
{ t.x } -> std::convertible_to<typename T::value_type>;
{ t.y } -> std::convertible_to<typename T::value_type>;
{ t.z } -> std::convertible_to<typename T::value_type>;
};
template<typename T>
class point_2d {
public:
using value_type = T;
T x;
T y;
point_2d()=default;
point_2d(T x_, T y_) : x(x_), y(y_) {}
point_2d(const point_2d& other)=default;
point_2d& operator=(const point_2d& other)=default;
point_2d(point_2d& other)=default;
point_2d& operator=(point_2d& other)=default;
};
template<typename T>
class point_3d {
public:
using value_type = T;
T x;
T y;
T z;
point_3d()=default;
point_3d(T x_, T y_, T z_) : x(std::move(x_)), y(std::move(y_)), z(std::move(z_)) {}
point_3d(const point_3d& other)=default;
point_3d& operator=(const point_3d& other)=default;
point_3d(point_3d& other)=default;
point_3d& operator=(point_3d& other)=default;
};
/*template<std::floating_point T>
concept scale_concept = requires {
public:
scale_type(T x_, T y_, T z_) : x(x_), y(y_), z(z_) {}
T x{};
T y{};
T z{};
};*/
class Attr {
public:
virtual void enable()=0;
virtual void disable() {}
virtual std::string to_string() const=0;
virtual ~Attr()=default;
};
class Color : public Attr {
public:
using value_type = GLfloat;
Color(value_type red, value_type green, value_type blue)
: red_(red), green_(green), blue_(blue), alpha_(1.0f) {}
Color(value_type red, value_type green, value_type blue, value_type alpha)
: red_(red), green_(green), blue_(blue), alpha_(alpha) {}
auto get_color() -> std::tuple<value_type, value_type, value_type> {
return {red_, green_, blue_};
}
void set_color(value_type red, value_type green, value_type blue) {
red_ = red; green_ = green; blue_ = blue;
}
void set_color(value_type red, value_type green, value_type blue, value_type alpha) {
red_ = red; green_ = green; blue_ = blue; alpha_ = alpha;
}
void enable() override {
glColor4f(red_, green_, blue_, alpha_);
}
std::string to_string() const override {
return "Color: red=" + std::to_string(red_) + ", green=" + std::to_string(green_) + ", blue=" + std::to_string(blue_) + ", alpha=" + std::to_string(alpha_);
}
private:
value_type red_{};
value_type green_{};
value_type blue_{};
value_type alpha_{};
};
class Transform : public Attr {
public:
using translation_type = point_2d<GLfloat>;
using rotation_type = GLfloat;
using scale_type = point_2d<GLfloat>;
Transform()=default;
Transform(translation_type translation) : translation_(translation) {}
Transform(translation_type translation, std::floating_point auto rotation, scale_type scale) : translation_(translation), rotation_(rotation), scale_(scale) {}
void enable() override {
glPushMatrix();
glTranslatef(translation_.x, translation_.y, 0.0f);
glRotatef(RAD2DEG * rotation_, 0.0f, 0.0f, 1.0f);
glScalef(scale_.x, scale_.y, 1.0f);
}
void disable() override {
glPopMatrix();
}
void set_translation(const point_2d_concept auto& pt_2d) {
//std::cout << "calling Transform::set_translation...\n"; // TODO: add as debug info?
//translation_ = std::move(pt_2d); // crash occurred, don't std::move() from here
translation_.x = pt_2d.x;
translation_.y = pt_2d.y;
//std::cout << "done calling Transform::set_translation\n"; // TODO: add as debug info?
}
void set_rotation(const std::floating_point auto rot) {
//std::cout << "calling Transform::set_rotation...\n"; // TODO: add as debug info?
rotation_ = rot;
//std::cout << "done calling Transform::set_rotation\n"; // TODO: add as debug info?
}
void set_scale(const point_2d_concept auto& pt_2d) {
//std::cout << "calling Transform::set_scale...\n"; // TODO: add as debug info?
//scale_ = std::move(pt_2d);
scale_.x = pt_2d.x;
scale_.y = pt_2d.y;
//std::cout << "done calling Transform::set_scale\n"; // TODO: add as debug info?
}
std::string to_string() const override {
return "Transform: translation.x=" + std::to_string(translation_.x) + ", translation.y=" + std::to_string(translation_.y) + ", rotation=" + std::to_string(rotation_) + ", scale.x=" + std::to_string(scale_.x) + ", scale.y=" + std::to_string(scale_.y);
}
private:
const rotation_type RAD2DEG{57.29577951308232f};
translation_type translation_{0.0f, 0.0f};
rotation_type rotation_{0.0f};
scale_type scale_{1.0f, 1.0f};
};
class LineStyle : public Attr {
public:
using factor_type = GLint;
using pattern_type = GLushort;
LineStyle(pattern_type pattern) : LineStyle(1.0f, pattern) {}
LineStyle(factor_type factor, pattern_type pattern) : factor_(factor), pattern_(pattern) {}
void enable() override {
glEnable(GL_LINE_STIPPLE);
glLineStipple(factor_, pattern_);
}
void disable() {
glDisable(GL_LINE_STIPPLE);
}
std::string to_string() const override {
return "LineStyle: factor=" + std::to_string(factor_) + ", pattern=" + std::to_string(pattern_);
}
private:
factor_type factor_{};
pattern_type pattern_{};
};
class LineWidth : public Attr {
public:
using value_type = GLfloat;
LineWidth(value_type width) : width_(width) {}
void set_width(value_type width) {
width_ = width;
}
void enable() override {
glLineWidth(width_);
}
std::string to_string() const override {
return "LineWidth: width=" + std::to_string(width_);
}
private:
value_type width_{};
};
template<typename T>
concept geom_concept = requires(T t, Color::value_type color) {
t.render();
//t.add_attr(attr_concept auto... attrs);
t.set_color(color, color, color);
};
class Geom {
public:
Geom(bool add_default_attrs=true) {
if (add_default_attrs)
attrs_.push_back(&color_);
}
void render() {
/*std::for_each(std::rbegin(attrs_), std::rend(attrs_), [](Attr& attr){
for (auto& attr : attrs_)
attr.get().enable();
});*/
std::for_each(std::rbegin(attrs_), std::rend(attrs_), [](Attr* attr){
attr->enable();
});
render1();
/*std::for_each(std::begin(attrs_), std::end(attrs_), [](Attr& attr){
for (auto& attr : attrs_)
attr.get().disable();
});*/
std::for_each(std::begin(attrs_), std::end(attrs_), [](Attr* attr){
attr->disable();
});
}
/*template<attr_concept Attribute, typename... Args>
void add_attr(Args&&... args) {
attrs_.push_back(std::move(std::make_unique<Attribute>(std::forward<Args>(args)...)));
}*/
//void add_attr(attr_concept auto& attr) {
/*void add_attr(Attr& attr) {
attrs_.push_back(std::ref(attr));
}*/
void add_attr(Attr& attr) {
attrs_.push_back(&attr);
}
/*void add_attr(Attr&& attr) {
attrs_.push_back();
}*/
/*template<typename T>
void remove_attr() {
std::erase_if(attrs_, [](auto& x) { return typeid(*x) == typeid(T); });
}*/
void set_color(Color::value_type red, Color::value_type green, Color::value_type blue) {
color_.set_color(red, green, blue);
}
virtual std::string to_string() const {
std::string s{"Geom:\n"};
for (const auto& attr : attrs_)
s += attr->to_string() + '\n';
return s;
}
protected:
virtual void render1()=0;
private:
Color color_{0.0f, 0.0f, 0.0f, 1.0f};
//std::vector<std::reference_wrapper<Attr>> attrs_;
std::vector<Attr*> attrs_;
};
class Compound : public Geom {
public:
using value_type = std::vector<Geom>;
//Compound(std::initializer_list<Geom> geoms) : Compound(std::move(static_cast<std::vector<Geom>>(geoms))) {}
//Compound(std::initializer_list<Geom> geoms) {
// geoms_.insert(std::end(geoms_), std::begin(geoms), std::end(geoms));
//}
Compound(std::vector<Geom> geoms) : geoms_(std::move(geoms)) {}
protected:
void render1() override {
for (auto& g : geoms_)
g.render();
}
private:
std::vector<Geom> geoms_;
};
class Image : public Geom {
public:
using value_type = GLfloat;
Image(std::string_view fname, value_type width, value_type height) : width_(width), height_(height) {
set_color(1.0, 0.5, 0.5); //1.0, 1.0, 1.0
std::cout << "loading image: " << fname << '\n';
//img_ = image.load(fname);
}
protected:
void render1() override {
//img_.blit(-width/2, -height/2, width, height); //glBlitFrameBuffer
}
private:
const value_type width_; //uint64_t width_{};
const value_type height_; //uint64_t height_{};
//??? img_;
//bool flip_{false};
};
class PolyLine : public Geom {
public:
using value_type = point_2d<GLfloat>;
PolyLine()=default;
PolyLine(const bool close) : close_(close) {}
//PolyLine& operator=(const PolyLine&)=default;
//PolyLine& operator=(PolyLine&&)=default;
PolyLine(std::initializer_list<value_type> vertices) : PolyLine(std::move(vertices), false) {}
PolyLine(std::initializer_list<value_type> vertices, const bool close, const LineWidth::value_type width=1) : close_(close) {
vertices_.insert(std::end(vertices_), std::begin(vertices), std::end(vertices));
line_width_.set_width(width);
add_attr(line_width_);
}
PolyLine(std::vector<value_type> vertices) : PolyLine(std::move(vertices), false) {}
PolyLine(std::vector<value_type> vertices, const bool close, const LineWidth::value_type width=1) : vertices_(std::move(vertices)), close_(close) {
line_width_.set_width(width);
add_attr(line_width_);
}
void set_vertices(std::initializer_list<value_type> vertices) {
vertices_.clear();
vertices_.insert(std::end(vertices_), std::begin(vertices), std::end(vertices));
}
void set_vertices(std::vector<value_type> vertices) {
vertices_ = std::move(vertices);
}
void set_width(LineWidth::value_type width) {
line_width_.set_width(width);
}
std::string to_string() const override {
std::string s("PolyLine: {\n");
for (const auto& vertex : vertices_)
s += "vertex.x=" + std::to_string(vertex.x) + ", vertex.y=" + std::to_string(vertex.y) + "\n";
s += "close=" + std::string(close_ ? "true" : "false") + "\n";
s += "line_width=" + line_width_.to_string() + "\n";
s += "}";
return s;
}
protected:
void render1() override {
glBegin(close_ ? GL_LINE_LOOP : GL_LINE_STRIP);
// note: don't call glGetError() between glBegin() and glEnd()
for (const auto& vertex : vertices_) {
glVertex3f(vertex.x, vertex.y, 0.0f);
// note: don't call glGetError() between glBegin() and glEnd()
}
glEnd();
GLenum error{GL_NO_ERROR};
do {
error = glGetError();
if (error != GL_NO_ERROR)
std::cout << "PolyLine::render1: glEnd: error=" << error << '\n';
} while (error != GL_NO_ERROR);
}
private:
std::vector<value_type> vertices_;
bool close_{false};
LineWidth line_width_{1};
};
class Line : public Geom {
public:
using value_type = point_2d<GLfloat>;
Line() : Line({0.0f, 0.0f}, {0.0f, 0.0f}) {}
Line(value_type start, value_type end) : start_(start), end_(end) {
add_attr(line_width_);
}
void set_width(LineWidth::value_type width) {
line_width_.set_width(width);
}
void set_points(value_type start, value_type end) {
start_ = std::move(start);
end_ = std::move(end);
}
std::string to_string() const override {
return "Line: start.x=" + std::to_string(start_.x) + ", start.y=" + std::to_string(start_.y) + ", end.x=" + std::to_string(end_.x) + ", end.y=" + std::to_string(end_.y) + "\n inherits from: {\n" + Geom::to_string() + '}';
}
protected:
void render1() override {
glBegin(GL_LINES);
glVertex2f(start_.x, start_.y);
glVertex2f(end_.x, end_.y);
glEnd();
}
private:
value_type start_{0.0f, 0.0f};
value_type end_{0.0f, 0.0f};
LineWidth line_width_{1};
};
class Point : public Geom {
protected:
void render1() override {
glBegin(GL_POINTS);
glVertex3f(0.0f, 0.0f, 0.0f);
glEnd();
}
};
class FilledPolygon : public Geom {
public:
using value_type = point_2d<GLfloat>;
FilledPolygon()=default;
FilledPolygon(std::initializer_list<value_type> vertices) {
vertices_.insert(std::end(vertices_), std::begin(vertices), std::end(vertices));
}
FilledPolygon(std::vector<value_type> vertices) : vertices_(std::move(vertices)) {}
void set_vertices(std::initializer_list<value_type> vertices) {
vertices_.clear();
vertices_.insert(std::end(vertices_), std::begin(vertices), std::end(vertices));
}
void set_vertices(std::vector<value_type> vertices) {
vertices_ = std::move(vertices);
}
std::string to_string() const override {
std::string s("FilledPolygon: {\n");
for (const auto& vertex : vertices_)
s += "vertex.x=" + std::to_string(vertex.x) + ", vertex.y=" + std::to_string(vertex.y) + "\n";
s += "}";
return s;
}
protected:
void render1() override {
GLenum mode{GL_POLYGON};
if (vertices_.size() == 4)
mode = GL_QUADS;
else if (vertices_.size() < 4)
mode = GL_TRIANGLES;
glBegin(mode);
for (const auto& vertex : vertices_)
glVertex3f(vertex.x, vertex.y, 0.0f);
glEnd();
}
private:
std::vector<value_type> vertices_;
};
//template<std::floating_point T=GLfloat>
//typedef vertices_2d = std::vector<point_2d<T>>;
typedef std::vector<point_2d<GLfloat>> vertices_2d;
PolyLine make_polyline(vertices_2d vertices) {
return PolyLine(vertices, false);
}
template<typename T=FilledPolygon>
T make_polygon(vertices_2d vertices)
requires requires {
std::same_as<T, FilledPolygon> || std::same_as<T, PolyLine>;
}
{
if constexpr (std::same_as<T, FilledPolygon>)
return FilledPolygon(vertices);
else
return PolyLine(vertices, true);
}
//template<geom_concept auto T>
template<typename T=FilledPolygon>
T make_circle(const GLfloat radius=10.0f, const uint64_t resolution=30)
requires requires {
std::same_as<T, FilledPolygon> || std::same_as<T, PolyLine>; } {
//std::unique_ptr<Geom> make_circle(const GLfloat radius=10.0f, const uint64_t resolution=30, const bool filled=true) {
//std::unique_ptr<Geom> make_circle(std::floating_point auto const radius=10.0f, std::unsigned_integral auto const resolution=30, const bool filled=true) {
vertices_2d vertices;
for (uint64_t i=0; i < resolution; ++i) {
auto angle = 2 * std::numbers::pi_v<GLfloat> * static_cast<GLfloat>(i) / static_cast<GLfloat>(resolution);
vertices.emplace_back(std::cos(angle) * radius, std::sin(angle) * radius);
}
return make_polygon<T>(std::move(vertices));
}
class Capsule : public Geom {
public:
using value_type = GLfloat;
Capsule(const value_type length, const value_type width) : length_(length), width_(width) {
circ1_.add_attr(tf_);
}
void set_color(Color::value_type red, Color::value_type green, Color::value_type blue) {
box_.set_color(red, green, blue);
circ0_.set_color(red, green, blue);
circ1_.set_color(red, green, blue);
}
protected:
void render1() override {
box_.render();
circ0_.render();
circ1_.render();
}
private:
const value_type length_;
const value_type width_;
const value_type l_{0.0};
const value_type r_{length_};
const value_type t_{width_/2};
const value_type b_{-width_/2};
FilledPolygon box_{{l_, b_}, {l_, t_}, {r_, t_}, {r_, b_}};
FilledPolygon circ0_{make_circle(t_)};
FilledPolygon circ1_{make_circle(t_)};
Transform tf_{{length_, 0.0}};
};
/*Compound make_capsule(const GLfloat length, const GLfloat width) {
const GLfloat l{0.0}, r{length}, t{width/2}, b{-width/2};
auto box{make_polygon(std::move(vertices_2d{{l, b}, {l, t}, {r, t}, {r, b}}))};
auto circ0{make_circle(width/2)};
auto circ1{make_circle(width/2)};
Transform tf{{length, 0.0}};
circ1.add_attr(tf);
return Compound(std::move(std::vector<Geom>{std::move(box), std::move(circ0), std::move(circ1)}));
}*/
Capsule make_capsule(const GLfloat length, const GLfloat width) {
return Capsule(length, width);
}
static void init_display(int argc, char** argv, const std::unsigned_integral auto width, const std::unsigned_integral auto height, const std::integral auto x, const std::integral auto y);
static void init_display(int argc, char** argv, const std::unsigned_integral auto width, const std::unsigned_integral auto height) {
init_display(argc, argv, width, height, -1, -1);
}
class Display {
friend void init_display(int, char**, const std::unsigned_integral auto, const std::unsigned_integral auto, const std::integral auto, const std::integral auto);
protected:
Display(int argc, char** argv, const std::unsigned_integral auto width, const std::unsigned_integral auto height, const std::integral auto x, const std::integral auto y) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
glutInitWindowSize(width, height);
glutInitWindowPosition(x, y);
}
};
static void init_display(int argc, char** argv, const std::unsigned_integral auto width, const std::unsigned_integral auto height, const std::integral auto x, const std::integral auto y) {
static Display display(argc, argv, width, height, x, y);
}
/*extern "C" {
static void close_func(void) {
std::cout << "WINDOW CLOSED CALLBACK!\n";
}
}*/
class Window {
public:
Window(std::string_view title, const std::unsigned_integral auto width, const std::unsigned_integral auto height) : Window(title, width, height, -1, -1) {}
Window(std::string_view title, const std::unsigned_integral auto width, const std::unsigned_integral auto height, const std::integral auto x, const std::integral auto y) {
glutInitWindowSize(width, height);
glutInitWindowPosition(x, y);
window_handle_ = glutCreateWindow(title.data());
glClearColor(0.20f, 0.0f, 0.15f, 1.0f);
glutSetWindow(window_handle_); // TODO: is this call needed?
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, width - 1, 0, height - 1, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
//glViewport(x, y, width, height);
//std::cout << "glViewport: error=" << glGetError() << "\n";
std::function<void()> close_func = [&]() { window_is_open_ = false; };
//glutCloseFunc(close_func); // TODO: implement c-style callback, unfortunately this doesn't work though since there's no context in the call to close_func()
}
~Window() {
if (window_is_open_) {
std::cout << "window::~window: destroying window...\n";
//glutDestroyWindow(window_handle_); // TODO: implement close callback,
// TODO: or just call glutDestroyWindow() and disregard returned error? probably disregard, doesn't seem to cause any problems to just disregard returned error
}
std::cout << "window::~window: destructor finalized\n";
}
void clear() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
void switch_to() {
glutSetWindow(window_handle_);
}
bool has_focus() {
return glutGetWindow() == window_handle_;
}
void dispatch_events() {
glutMainLoopEvent();
}
void swap() {
glutSwapBuffers();
}
void resize(const std::unsigned_integral auto width, const std::unsigned_integral auto height) {
glutReshapeWindow(width, height);
}
void move(const std::integral auto x, const std::integral auto y) {
glutPositionWindow(x, y);
}
void fullscreen(const bool enabled=true) {
if (enabled)
glutFullScreen();
else
glutLeaveFullScreen();
}
bool is_open() { return window_is_open_; }
private:
int window_handle_{0};
bool window_is_open_{true};
};
template<std::unsigned_integral T=unsigned int>
class Viewer {
public:
Viewer(std::string_view title, const std::unsigned_integral auto width, const std::unsigned_integral auto height) : width_(width), height_(height), window_(Window(title, width, height)) {
//display_ = get_display();
//window_ = get_window(width, height, display_);
//window_.on_close = window_close_by_user; // TODO: implement
//window_is_open_ = true;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
////void set_bounds(const std::unsigned_integral auto left, const std::unsigned_integral auto right, const std::unsigned_integral auto bottom, const std::unsigned_integral auto top) {
//void set_bounds(const std::integral auto left, const std::integral auto right, const std::integral auto bottom, const std::integral auto top) {
void set_bounds(const std::floating_point auto left, const std::floating_point auto right, const std::floating_point auto bottom, const std::floating_point auto top) {
//assert(right > left && top > bottom); // TODO: assert
auto scale_x = width_ / (right - left);
auto scale_y = height_ / (top - bottom);
transform_.set_translation(point_2d{-left * scale_x, -bottom * scale_y});
transform_.set_scale(point_2d{scale_x, scale_y});
}
/*void add_geom(geom_concept auto geom) {
geoms_.push_back(std::move(geom));
}*/
void add_geom(geom_concept auto& geom) {
geoms_.push_back(geom);
}
/*void add_onetime(geom_concept auto geom) {
onetime_geoms_.push_back(std::move(geom));
}*/
void add_onetime(geom_concept auto& geom) {
onetime_geoms_.push_back(geom);
}
template<bool return_rgb_array=false>
auto render() {
//std::cout << "begin: viewer.render\n"; // TODO: add as debug info?
glClearColor(0.15f, 0.0f, 0.1f, 1.0f);
window_.switch_to();
window_.clear(); // TODO: glut standard says call switch_to() before clear()
window_.dispatch_events();
transform_.enable();
for (auto& geom : geoms_) {
////std::cout << " begin: viewer.render: geom=" << geom.get().to_string() << "\n";
geom.get().render();
////std::cout << " end: viewer.render: geom=" << geom.get().to_string() << "\n";
}
for (auto& onetime_geom : onetime_geoms_) {
////std::cout << "onetime_geom: " << onetime_geom.get().to_string() << '\n';
onetime_geom.get().render();
}
transform_.disable();
onetime_geoms_.clear();
//std::cout << "end: viewer.render\n"; // TODO: add as debug info?
if constexpr (return_rgb_array) { // TODO: test saving returned rgb array to file
std::vector<uint8_t> buffer(width_ * height_ * 4);
glReadBuffer(GL_BACK);
glReadPixels(0, 0, width_, height_, GL_BGRA, GL_UNSIGNED_BYTE, &buffer[0]);
window_.swap();
return buffer;
} else {
window_.swap();
return window_.is_open(); //window_is_open_;
}
}
/*template<typename T=FilledPolygon>
T draw_polygon(vertices_2d vertices, const Color& color) {
auto geom = make_polygon<T>(std::move(vertices));
const auto& [red, green, blue] = color.get_color();
geom.set_color(red, green, blue);
add_onetime();
}*/
/*virtual ~Viewer() {
//window_.close();
//window_is_open_ = false;
}*/
protected:
struct display_initializer {
explicit display_initializer(int argc, char** argv,
std::unsigned_integral auto width,
std::unsigned_integral auto height,
std::integral auto x, std::integral auto y)
{
init_display(argc, argv, width, height, x, y);
}
};
/*uint64_t get_display() {
return 7;
}*/
/*uint64_t get_window(T width, T height, uint64_t display) {
return 9;
}*/
/*void window_closed_by_user() {
window_is_open_ = false;
}*/
private:
T width_{};
T height_{};
//uint64_t display_;
display_initializer display_initializer_{0, nullptr, width_, height_, 0, 0};
Window window_;
//bool window_is_open_{false};
std::vector<std::reference_wrapper<Geom>> geoms_;
std::vector<std::reference_wrapper<Geom>> onetime_geoms_;
Transform transform_;
};
}
| 34.188457 | 262 | 0.585889 |
06759016670675358a506c03f3d70cfc23f12582 | 604 | h | C | exe/src/control/game/moveuprightcmd.h | jonpetri/CollectGame | 251beb560f8246468479f04461bfc0b1298a7e70 | [
"MIT"
] | null | null | null | exe/src/control/game/moveuprightcmd.h | jonpetri/CollectGame | 251beb560f8246468479f04461bfc0b1298a7e70 | [
"MIT"
] | null | null | null | exe/src/control/game/moveuprightcmd.h | jonpetri/CollectGame | 251beb560f8246468479f04461bfc0b1298a7e70 | [
"MIT"
] | null | null | null | /*----------------------------------------------------------------*/
/* PROJECT: Collect Game */
/*----------------------------------------------------------------*/
/**
* CLASS: MoveUpRightCmd
* Command class: Move the player UpRight
*/
#ifndef MOVEUPRIGHTCMD_H
#define MOVEUPRIGHTCMD_H
// Includes:
#include "consolecommand.h"
class CollectGame;
class MoveUpRightCmd : public ConsoleCommand<CollectGame>
{
public:
MoveUpRightCmd();
~MoveUpRightCmd() override;
// Methods:
virtual void execute() override;
};
#endif // MOVEUPRIGHTCMD_H
| 21.571429 | 68 | 0.504967 |
069fa5836725a21049098137f8494daadcf71f7f | 449 | h | C | DynamicTableGenerator/DynamicTableView.h | TheoBrown/DynamicTableGenerator-iOS | 54571ad73656dc783625c410556a3a71039a49d7 | [
"MIT"
] | 16 | 2015-02-17T21:34:27.000Z | 2020-01-09T17:12:36.000Z | DynamicTableGenerator/DynamicTableView.h | TheoBrown/DynamicTableGenerator-iOS | 54571ad73656dc783625c410556a3a71039a49d7 | [
"MIT"
] | 1 | 2015-03-18T04:43:40.000Z | 2015-03-18T04:43:40.000Z | DynamicTableGenerator/DynamicTableView.h | TheoBrown/DynamicTableGenerator-iOS | 54571ad73656dc783625c410556a3a71039a49d7 | [
"MIT"
] | 3 | 2015-02-23T18:34:58.000Z | 2020-01-09T17:12:12.000Z | //
// DynamicTableView.h
// DynamicTableGenerator
//
// Created by tpb on 12/18/14.
// Copyright (c) 2014 Theodore Brown. All rights reserved.
//
#ifndef DynamicTableGenerator_DynamicTableView_h
#define DynamicTableGenerator_DynamicTableView_h
#endif
#import "DynamicTableViewCellManager.h"
#import "DynamicTableViewObjectParser.h"
#import "DynamicTableViewController.h"
#import "DynamicTableViewCells.h"
#import "DynamicTableVIewConstants.h" | 24.944444 | 59 | 0.804009 |
b2f216682b4c7bd615c2c51417c61be300126542 | 556 | h | C | include/il2cpp/AkAmbientLargeModePositioner.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | 1 | 2022-01-15T20:20:27.000Z | 2022-01-15T20:20:27.000Z | include/il2cpp/AkAmbientLargeModePositioner.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | include/il2cpp/AkAmbientLargeModePositioner.h | martmists-gh/BDSP | d6326c5d3ad9697ea65269ed47aa0b63abac2a0a | [
"MIT"
] | null | null | null | #pragma once
#include "il2cpp.h"
UnityEngine_Vector3_o AkAmbientLargeModePositioner__get_Position (AkAmbientLargeModePositioner_o* __this, const MethodInfo* method_info);
UnityEngine_Vector3_o AkAmbientLargeModePositioner__get_Forward (AkAmbientLargeModePositioner_o* __this, const MethodInfo* method_info);
UnityEngine_Vector3_o AkAmbientLargeModePositioner__get_Up (AkAmbientLargeModePositioner_o* __this, const MethodInfo* method_info);
void AkAmbientLargeModePositioner___ctor (AkAmbientLargeModePositioner_o* __this, const MethodInfo* method_info);
| 61.777778 | 137 | 0.886691 |
b2fd53996f84e91a1a3d8ce7853fbb3bc60728f6 | 1,128 | h | C | PS_Fgen_FW/Spi/spi.h | M1S2/PowerSupplySigGen | f2d352d9c24db985327d0286db58c6938da2507e | [
"MIT"
] | null | null | null | PS_Fgen_FW/Spi/spi.h | M1S2/PowerSupplySigGen | f2d352d9c24db985327d0286db58c6938da2507e | [
"MIT"
] | 24 | 2020-11-10T13:03:05.000Z | 2021-05-12T16:26:02.000Z | PS_Fgen_FW/Spi/spi.h | M1S2/PowerSupplySigGen | f2d352d9c24db985327d0286db58c6938da2507e | [
"MIT"
] | 1 | 2021-06-25T12:26:36.000Z | 2021-06-25T12:26:36.000Z | /**
* @file spi.h
* @date 14.08.2020 19:24:17
* @author Markus Scheich
* @brief Containing defines and functions for basic SPI initialization and handling.
* @see https://github.com/0xD34D/ATmega/blob/master/include/spi.h
*/
#ifndef SPI_H_
#define SPI_H_
#include "../Pins/Pins.h"
#define spi_wait() while (!(SPSR & (1 << SPIF))); /**< Loop until any current SPI transmissions have completed */
/**
* Initialize the SPI subsystem as master.
*/
void SPI_Init();
/**
* Transfer a byte of data to the slave.
* @param data Data byte to transfer via SPI.
* @return Byte received from the slave.
*/
inline uint8_t SPI_SendByte(uint8_t data)
{
SPDR = data; // Start transmission
spi_wait(); // Wait for the transmission to complete
return SPDR; // return the byte received from the slave
}
/**
* Read a byte of data from the slave by sending a dummy byte.
* @return Byte received form the slave.
*/
inline uint8_t SPI_ReadByte()
{
SPDR = 0xFF; // Start transmission
spi_wait(); // Wait for the transmission to complete
return SPDR; // return the byte received from the slave
}
#endif /* SPI_H_ */ | 25.636364 | 114 | 0.693262 |
9faa907e19d54a7063d599c6213ae5defec11cf1 | 1,222 | h | C | src/models/classifier.h | hieuhoang/marian-dev | f2347a827fcfd7eebaaa552e2b3c2461f8ea45c2 | [
"MIT"
] | 829 | 2017-06-05T12:14:34.000Z | 2022-03-29T17:24:03.000Z | src/models/classifier.h | hieuhoang/marian-dev | f2347a827fcfd7eebaaa552e2b3c2461f8ea45c2 | [
"MIT"
] | 732 | 2017-07-21T15:32:27.000Z | 2022-03-22T10:26:09.000Z | src/models/classifier.h | hieuhoang/marian-dev | f2347a827fcfd7eebaaa552e2b3c2461f8ea45c2 | [
"MIT"
] | 192 | 2017-06-27T10:17:26.000Z | 2022-03-28T05:33:11.000Z | #pragma once
#include "marian.h"
#include "models/states.h"
#include "layers/constructors.h"
#include "layers/factory.h"
namespace marian {
/**
* Simple base class for Classifiers to be used in EncoderClassifier framework
* Currently only implementations are in bert.h
*/
class ClassifierBase :public LayerBase {
using LayerBase::LayerBase;
protected:
Ptr<Options> options_;
const std::string prefix_{"classifier"};
const bool inference_{false};
const size_t batchIndex_{0};
public:
ClassifierBase(Ptr<ExpressionGraph> graph, Ptr<Options> options)
: LayerBase(graph, options),
prefix_(options->get<std::string>("prefix", "classifier")),
inference_(options->get<bool>("inference", false)),
batchIndex_(options->get<size_t>("index", 1)) {} // assume that training input has batch index 0 and labels has 1
virtual ~ClassifierBase() {}
virtual Ptr<ClassifierState> apply(Ptr<ExpressionGraph>, Ptr<data::CorpusBatch>, const std::vector<Ptr<EncoderState>>&) = 0;
template <typename T>
T opt(const std::string& key) const {
return options_->get<T>(key);
}
// Should be used to clear any batch-wise temporary objects if present
virtual void clear() = 0;
};
} | 29.095238 | 126 | 0.711129 |
c399d91229da4afa7bc4e40535f1070e5830659c | 2,296 | h | C | src/chrono_sensor/filters/ChFilterPCfromDepth.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 1,383 | 2015-02-04T14:17:40.000Z | 2022-03-30T04:58:16.000Z | src/chrono_sensor/filters/ChFilterPCfromDepth.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 245 | 2015-01-11T15:30:51.000Z | 2022-03-30T21:28:54.000Z | src/chrono_sensor/filters/ChFilterPCfromDepth.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 351 | 2015-02-04T14:17:47.000Z | 2022-03-30T04:42:52.000Z | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2019 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Eric Brandt, Asher Elmquist
// =============================================================================
//
// =============================================================================
#ifndef CHFILTERPCFROMDEPTH_H
#define CHFILTERPCFROMDEPTH_H
#include "chrono_sensor/filters/ChFilter.h"
#include <cuda.h>
namespace chrono {
namespace sensor {
// forward declaration
class ChSensor;
/// @addtogroup sensor_filters
/// @{
/// A filter that, when applied to a sensor, generates point cloud data from depth values
class CH_SENSOR_API ChFilterPCfromDepth : public ChFilter {
public:
/// Class constructor
/// @param name String name of the filter
ChFilterPCfromDepth(std::string name = {});
/// Apply function. Converts data from depth/intensity to point cloud data
virtual void Apply();
/// Initializes all data needed by the filter access apply function.
/// @param pSensor A pointer to the sensor on which the filter is attached.
/// @param bufferInOut A buffer that is passed into the filter.
virtual void Initialize(std::shared_ptr<ChSensor> pSensor, std::shared_ptr<SensorBuffer>& bufferInOut);
private:
float m_hFOV; ///< field of view of the parent lidar
float m_min_vert_angle; ///< mimimum vertical angle of parent lidar
float m_max_vert_angle; ///< maximum vetical angle of parent lidar
CUstream m_cuda_stream; ///< reference to the cuda stream
std::shared_ptr<SensorDeviceDIBuffer> m_buffer_in; ///< holder of the input buffer
std::shared_ptr<SensorDeviceXYZIBuffer> m_buffer_out; ///< holder of the output buffer
};
/// @}
} // namespace sensor
} // namespace chrono
#endif
| 37.032258 | 107 | 0.581882 |
240f486bc8d4fb1d6a51338506ee620eee08732b | 146 | h | C | 12_SofaBed/Sofabed.h | Aaron-labo/Cpp_StudyNotes | afff37736468b26dad87e9b5cda90f1e5f1efb06 | [
"Unlicense"
] | 1 | 2021-06-17T11:37:42.000Z | 2021-06-17T11:37:42.000Z | 12_SofaBed/Sofabed.h | Aaron-labo/Cpp_StudyNotes | afff37736468b26dad87e9b5cda90f1e5f1efb06 | [
"Unlicense"
] | null | null | null | 12_SofaBed/Sofabed.h | Aaron-labo/Cpp_StudyNotes | afff37736468b26dad87e9b5cda90f1e5f1efb06 | [
"Unlicense"
] | null | null | null | #pragma once
#include "Sofa.h"
#include "Bed.h"
class Sofabed :
public Sofa, public Bed
{
public:
Sofabed(float l, float w, float h);
};
| 13.272727 | 39 | 0.650685 |
ba040004b1e202ba6fd22f7ec06098bae8049f54 | 467 | h | C | InstrumentSampler/InstrumentSingleSampler.h | LovelyA72/ScoreDraft | dd344a49a5eec2670110cc43d672936cd1c27844 | [
"MIT"
] | 1 | 2020-03-26T15:48:49.000Z | 2020-03-26T15:48:49.000Z | InstrumentSampler/InstrumentSingleSampler.h | LovelyA72/ScoreDraft | dd344a49a5eec2670110cc43d672936cd1c27844 | [
"MIT"
] | null | null | null | InstrumentSampler/InstrumentSingleSampler.h | LovelyA72/ScoreDraft | dd344a49a5eec2670110cc43d672936cd1c27844 | [
"MIT"
] | null | null | null | #ifndef _InstrumentSingleSampler_h
#define _InstrumentSingleSampler_h
#include "PyScoreDraft.h"
class InstrumentSample;
class InstrumentSingleSampler : public Instrument
{
public:
InstrumentSingleSampler();
~InstrumentSingleSampler();
void SetSample(InstrumentSample* sample)
{
m_sample = sample;
}
protected:
virtual void GenerateNoteWave(float fNumOfSamples, float sampleFreq, NoteBuffer* noteBuf);
private:
InstrumentSample *m_sample;
};
#endif
| 16.103448 | 91 | 0.796574 |
7071baa135f75f5c6e5901234593233e4d50f1c0 | 2,582 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/BeeKeyboardTracker.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/BeeKeyboardTracker.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/BeeKeyboardTracker.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <UIKit/UIView.h>
#import "UIScrollViewDelegate-Protocol.h"
#import "UITextViewDelegate-Protocol.h"
@class NSString, UILabel, UITextView;
@protocol BeeKeyboardTrackerDelegate;
@interface BeeKeyboardTracker : UIView <UITextViewDelegate, UIScrollViewDelegate>
{
_Bool _statusTextView;
NSString *_placeholderText;
double _textHeight;
UITextView *_textView;
UILabel *_placeholderLabel_ap;
NSString *_sendBtnType;
UIView *_topLineView;
UIView *_bottomLineView;
long long _maxLength;
id <BeeKeyboardTrackerDelegate> _delegate;
}
@property(nonatomic) __weak id <BeeKeyboardTrackerDelegate> delegate; // @synthesize delegate=_delegate;
@property(nonatomic) long long maxLength; // @synthesize maxLength=_maxLength;
@property(retain, nonatomic) UIView *bottomLineView; // @synthesize bottomLineView=_bottomLineView;
@property(retain, nonatomic) UIView *topLineView; // @synthesize topLineView=_topLineView;
@property(retain, nonatomic) NSString *sendBtnType; // @synthesize sendBtnType=_sendBtnType;
@property(retain, nonatomic) UILabel *placeholderLabel_ap; // @synthesize placeholderLabel_ap=_placeholderLabel_ap;
@property(retain, nonatomic) UITextView *textView; // @synthesize textView=_textView;
@property(nonatomic) double textHeight; // @synthesize textHeight=_textHeight;
@property(nonatomic) _Bool statusTextView; // @synthesize statusTextView=_statusTextView;
@property(retain, nonatomic) NSString *placeholderText; // @synthesize placeholderText=_placeholderText;
- (void).cxx_destruct;
- (void)updateTextViewKeytype:(id)arg1;
- (_Bool)canResignFirstResponder;
- (_Bool)canBecomeFirstResponder;
- (void)scrollViewDidScroll:(id)arg1;
- (_Bool)textView:(id)arg1 shouldChangeTextInRange:(struct _NSRange)arg2 replacementText:(id)arg3;
- (void)textViewDidChange:(id)arg1;
- (void)checkTextValid:(id)arg1;
- (void)textViewDidEndEditing:(id)arg1;
- (_Bool)textViewShouldEndEditing:(id)arg1;
- (_Bool)textViewShouldBeginEditing:(id)arg1;
- (void)createUI;
- (void)keyboardWillHide:(id)arg1;
- (void)keyboardWillShow:(id)arg1;
- (void)dealloc;
- (void)createSubView:(id)arg1;
- (id)initWithsendBtnType:(id)arg1 placeholder:(id)arg2;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 39.723077 | 115 | 0.780015 |
3bbebcf60f112b6ba6f7b95fce481af97e0ae564 | 4,371 | c | C | tests/vb20_rsa_padding_tests.c | DennissimOS/platform_external_vboot_reference | 3007a4c680f6122ee2f0e361778007dc19221589 | [
"BSD-3-Clause"
] | 14 | 2016-05-01T23:54:57.000Z | 2021-11-19T16:17:52.000Z | tests/vb20_rsa_padding_tests.c | DennissimOS/platform_external_vboot_reference | 3007a4c680f6122ee2f0e361778007dc19221589 | [
"BSD-3-Clause"
] | null | null | null | tests/vb20_rsa_padding_tests.c | DennissimOS/platform_external_vboot_reference | 3007a4c680f6122ee2f0e361778007dc19221589 | [
"BSD-3-Clause"
] | 7 | 2017-01-03T17:05:39.000Z | 2019-12-12T00:18:39.000Z | /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <stdint.h>
#include <stdio.h>
#include "cryptolib.h"
#include "file_keys.h"
#include "rsa_padding_test.h"
#include "test_common.h"
#include "utility.h"
#include "2sysincludes.h"
#include "2rsa.h"
#include "vb2_common.h"
/**
* Convert an old-style RSA public key struct to a new one.
*
* The new one does not allocate memory, so you must keep the old one around
* until you're done with the new one.
*
* @param k2 Destination new key
* @param key Source old key
*/
void vb2_public_key_to_vb2(struct vb2_public_key *k2,
const struct RSAPublicKey *key)
{
k2->arrsize = key->len;
k2->n0inv = key->n0inv;
k2->n = key->n;
k2->rr = key->rr;
k2->sig_alg = vb2_crypto_to_signature(key->algorithm);
k2->hash_alg = vb2_crypto_to_hash(key->algorithm);
}
/**
* Test valid and invalid signatures.
*/
static void test_signatures(const struct vb2_public_key *key)
{
uint8_t workbuf[VB2_VERIFY_DIGEST_WORKBUF_BYTES]
__attribute__ ((aligned (VB2_WORKBUF_ALIGN)));
uint8_t sig[RSA1024NUMBYTES];
struct vb2_workbuf wb;
int unexpected_success;
int i;
vb2_workbuf_init(&wb, workbuf, sizeof(workbuf));
/* The first test signature is valid. */
Memcpy(sig, signatures[0], sizeof(sig));
TEST_SUCC(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
"RSA Padding Test valid sig");
/* All other signatures should fail verification. */
unexpected_success = 0;
for (i = 1; i < sizeof(signatures) / sizeof(signatures[0]); i++) {
Memcpy(sig, signatures[i], sizeof(sig));
if (!vb2_rsa_verify_digest(key, sig,
test_message_sha1_hash, &wb)) {
fprintf(stderr,
"RSA Padding Test vector %d FAILED!\n", i);
unexpected_success++;
}
}
TEST_EQ(unexpected_success, 0, "RSA Padding Test invalid sigs");
}
/**
* Test other error conditions in vb2_rsa_verify_digest().
*/
static void test_verify_digest(struct vb2_public_key *key) {
uint8_t workbuf[VB2_VERIFY_DIGEST_WORKBUF_BYTES]
__attribute__ ((aligned (VB2_WORKBUF_ALIGN)));
uint8_t sig[RSA1024NUMBYTES];
struct vb2_workbuf wb;
enum vb2_signature_algorithm orig_key_alg = key->sig_alg;
vb2_workbuf_init(&wb, workbuf, sizeof(workbuf));
Memcpy(sig, signatures[0], sizeof(sig));
TEST_SUCC(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
"vb2_rsa_verify_digest() good");
Memcpy(sig, signatures[0], sizeof(sig));
vb2_workbuf_init(&wb, workbuf, sizeof(sig) * 3 - 1);
TEST_EQ(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
VB2_ERROR_RSA_VERIFY_WORKBUF,
"vb2_rsa_verify_digest() small workbuf");
vb2_workbuf_init(&wb, workbuf, sizeof(workbuf));
key->sig_alg = VB2_SIG_INVALID;
Memcpy(sig, signatures[0], sizeof(sig));
TEST_EQ(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
VB2_ERROR_RSA_VERIFY_ALGORITHM,
"vb2_rsa_verify_digest() bad key alg");
key->sig_alg = orig_key_alg;
key->arrsize *= 2;
Memcpy(sig, signatures[0], sizeof(sig));
TEST_EQ(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
VB2_ERROR_RSA_VERIFY_SIG_LEN,
"vb2_rsa_verify_digest() bad sig len");
key->arrsize /= 2;
/* Corrupt the signature near start and end */
Memcpy(sig, signatures[0], sizeof(sig));
sig[3] ^= 0x42;
TEST_EQ(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
VB2_ERROR_RSA_PADDING, "vb2_rsa_verify_digest() bad sig");
Memcpy(sig, signatures[0], sizeof(sig));
sig[RSA1024NUMBYTES - 3] ^= 0x56;
TEST_EQ(vb2_rsa_verify_digest(key, sig, test_message_sha1_hash, &wb),
VB2_ERROR_RSA_PADDING, "vb2_rsa_verify_digest() bad sig end");
}
int main(int argc, char *argv[])
{
int error = 0;
RSAPublicKey *key;
struct vb2_public_key k2;
/* Read test key */
if (argc != 2) {
fprintf(stderr, "Usage: %s <test public key>\n", argv[0]);
return 1;
}
key = RSAPublicKeyFromFile(argv[1]);
if (!key) {
fprintf(stderr, "Couldn't read RSA public key for the test.\n");
return 1;
}
// TODO: why is test key algorithm wrong?
key->algorithm = 0;
/* Convert test key to Vb2 format */
vb2_public_key_to_vb2(&k2, key);
/* Run tests */
test_signatures(&k2);
test_verify_digest(&k2);
/* Clean up and exit */
RSAPublicKeyFree(key);
if (!gTestSuccess)
error = 255;
return error;
}
| 27.490566 | 76 | 0.719286 |
830a23446b503b98f99429035bd11004d10aac6e | 1,515 | h | C | gvrsample/src/main/cpp/engine/Engine.h | nb7123/OpenGLSample | 7ac778d7877cb5f71e225ee3952eedae090549e5 | [
"Apache-2.0"
] | null | null | null | gvrsample/src/main/cpp/engine/Engine.h | nb7123/OpenGLSample | 7ac778d7877cb5f71e225ee3952eedae090549e5 | [
"Apache-2.0"
] | null | null | null | gvrsample/src/main/cpp/engine/Engine.h | nb7123/OpenGLSample | 7ac778d7877cb5f71e225ee3952eedae090549e5 | [
"Apache-2.0"
] | null | null | null | //
// Created by michael on 17-11-28.
//
#ifndef OPENGLSAMPLE_ENGINE_H
#define OPENGLSAMPLE_ENGINE_H
#include <EGL/egl.h>
#include <android/sensor.h>
#include <vr/gvr/capi/include/gvr.h>
#include <vr/gvr/capi/include/gvr_types.h>
#include "../util/Log.h"
#include "../objects/shape/triangle/Triangle.h"
#include "../objects/shape/square/Square.h"
static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000;
class Engine {
private:
static const char *LOG_TAG;
ASensorManager *sensorMgr;
const ASensor *accelerometerSensor;
ASensorEventQueue *sensorEventQueue;
// Objects
std::unique_ptr<Triangle> triangle;
std::unique_ptr<Square> square;
std::unique_ptr<gvr::GvrApi> gvrApi;
/**
* 交换链,用于交换帧缓冲区交换
*/
std::unique_ptr<gvr::SwapChain> swapChain;
/**
* 二级缓冲区
*/
gvr::BufferViewport scratchVP;
/**
* 视口缓冲区列表
*/
std::unique_ptr<gvr::BufferViewportList> vpList;
/**
* gl 初始化
* 必须在渲染线程调用
*/
void initializeGL();
void initObjects();
// vr mode
void drawEye(const gvr::Rectf &sourceUv, const gvr::Mat4f &eyeMat);
public:
/**
* 构造函数
* @param jgvrCtx java google vr context
*/
Engine(jlong jGvrCtx);
/**
* 引擎初始化
*/
void init();
/**
* 绘制
*/
void draw();
/**
* 处理加速传感器事件
*/
void pullAccelerometerEvent();
/**
* 手动释放资源
*/
void release();
~Engine();
};
#endif //OPENGLSAMPLE_ENGINE_H
| 16.833333 | 71 | 0.609901 |
7d8f19e04d632497072c2cccef1fa40ca21fd73a | 78 | c | C | testdata/step_14/foo_x_y.c | gky360/mycc | 3fe20c40e9be473578d1a6a5ba14bc460af2cf2a | [
"MIT"
] | 2 | 2019-05-27T23:45:12.000Z | 2019-06-20T14:02:11.000Z | testdata/step_14/foo_x_y.c | gky360/mycc | 3fe20c40e9be473578d1a6a5ba14bc460af2cf2a | [
"MIT"
] | 1 | 2019-06-07T17:23:31.000Z | 2019-06-07T17:23:31.000Z | testdata/step_14/foo_x_y.c | gky360/mycc | 3fe20c40e9be473578d1a6a5ba14bc460af2cf2a | [
"MIT"
] | null | null | null | #include<stdio.h>
int foo(int x, int y) {
printf("OK: %d, %d\n", x, y);
} | 15.6 | 33 | 0.512821 |
fe79424ddf00d9f6c3171c8cddfa1d8c3bfa59e1 | 467 | h | C | Classes/GTOdbObject.h | ohdarling/objective-git | 9bdd08648fdf0ff05fe5bfd15146422da3fa4e50 | [
"MIT"
] | 1 | 2015-01-04T19:39:07.000Z | 2015-01-04T19:39:07.000Z | Classes/GTOdbObject.h | ohdarling/objective-git | 9bdd08648fdf0ff05fe5bfd15146422da3fa4e50 | [
"MIT"
] | null | null | null | Classes/GTOdbObject.h | ohdarling/objective-git | 9bdd08648fdf0ff05fe5bfd15146422da3fa4e50 | [
"MIT"
] | null | null | null | //
// GTOdbObject.h
// ObjectiveGitFramework
//
// Created by Timothy Clem on 3/23/11.
// Copyright 2011 GitHub, Inc. All rights reserved.
//
#import "GTObject.h"
@interface GTOdbObject : NSObject {}
@property (nonatomic, assign, readonly) git_odb_object *git_odb_object;
- (id)initWithOdbObj:(git_odb_object *)object;
+ (id)objectWithOdbObj:(git_odb_object *)object;
- (NSString *)shaHash;
- (GTObjectType)type;
- (size_t)length;
- (NSData *)data;
@end
| 17.961538 | 71 | 0.708779 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.