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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bf649b63b90b2600c5e72f714b273a2374a750cc | 5,917 | h | C | lib/vm/disruptions/disruption.h | rroessler/nucleus | f1b9b9823b88e109ddfc87acb1beef9ca13bca4c | [
"MIT"
] | null | null | null | lib/vm/disruptions/disruption.h | rroessler/nucleus | f1b9b9823b88e109ddfc87acb1beef9ca13bca4c | [
"MIT"
] | null | null | null | lib/vm/disruptions/disruption.h | rroessler/nucleus | f1b9b9823b88e109ddfc87acb1beef9ca13bca4c | [
"MIT"
] | null | null | null | #ifndef NUC_DISRUPTION_H
#define NUC_DISRUPTION_H
// C Standard Library
#include <stdarg.h>
#include <stdio.h>
// Nucleus Headers
#include "../../common.h"
#include "../../utils/macros.h"
#include "../core/core.h"
#include "../core/flags.h"
#include "../global.h"
#include "immediate.h"
#include "model.h"
/*******************
* HELPER MACROS *
*******************/
// init variable args
#define NUC_INIT_VA_ARGS \
va_list args; \
va_start(args, format)
// prints a variable format string
#define NUC_VA_FPRINT \
vfprintf(stderr, format, args); \
fputc('\n', stderr)
// set a buffer length
#define NUC_ERROR_BUFFER_LEN 512
// define a suitable frame trace length
#define NUC_ERROR_LOOKBACK_FRAMES 8
// allows calling an item as unimplemented
#define NUC_UNIMP(msg, ...) atomizer_runtimeError(NUC_EXIT_UNIMP, msg NUC_VA_ARGS(__VA_ARGS__))
// allows calling an item as unimplemented and returning false
#define NUC_UNIMP_RETURN(msg, ...) \
atomizer_runtimeError(NUC_EXIT_UNIMP, msg NUC_VA_ARGS(__VA_ARGS__)); \
return false
/************************
* DISRUPTION METHODS *
************************/
/**
* Patches requests between `atomizer_catchableError` and `atomizer_runtimeError`.
* @param code Error code.
* @param format Format string for error.
* @param args Variadic format string args.
*/
static inline void __atomizer_errorDisplay(uint8_t code, const char* format, va_list args) {
nuc_printErrorCode(code); // display the error code
NUC_VA_FPRINT; // and print the args
}
// helper macro to allow `runtime` and `catchable` to both print variable args
#define atomizer_errorDisplay(code, format, ...) \
fputc('\n', stderr); \
__atomizer_errorDisplay(code, format, __VA_ARGS__); \
va_end(args)
/**
* Chucks a runtime error as suitable.
* @param code Error code.
* @param format Error format string.
*/
static void atomizer_runtimeError(uint8_t code, const char* format, ...) {
if (format[0] != '\0') { // only display if not empty
NUC_INIT_VA_ARGS;
atomizer_errorDisplay(code, format, args);
}
// determine a suitable frame trace
int endFrame = atomizer.frameCount > NUC_ERROR_LOOKBACK_FRAMES
? (atomizer.frameCount - NUC_ERROR_LOOKBACK_FRAMES)
: 0;
// and iterate over the final frames for a call trace
for (int i = atomizer.frameCount - 1; i >= endFrame; i--) {
nuc_CallFrame* frame = &atomizer.frames[i];
nuc_ObjReaction* reaction = frame->closure->reaction;
size_t inst = frame->ip - reaction->chunk.code - 1;
// retrieve some items for displaying the called line
size_t line = reaction->chunk.lines[inst];
const char* source = lexer_getLine(line);
fprintf(stderr, "[\x1b[2mline\x1b[0m \x1b[33m%lu\x1b[0m] ", line);
if (reaction->name == NULL) {
fprintf(stderr, "in \x1b[32mscript\x1b[0m.");
} else {
fprintf(stderr, "at \x1b[3;31m\"%s()\"\x1b[0m.", reaction->name->chars);
}
// and now printing a TRIMMED source
fprintf(stderr, "\n[\x1b[2;36msource\x1b[0m] \x1b[36m`");
char* ptr = NULL;
while (isspace((unsigned)*source)) source++; // chomp at start of source
ptr = (char*)source + strlen(source) - 1; // jump to the last char of source
while (isspace((unsigned)*ptr)) ptr--; // trim the end of the string
while (source <= ptr) fputc(*source++, stderr); // and
fprintf(stderr, "`\x1b[0m\n");
}
fputc('\n', stderr);
// clean the atomizer stack
atomizer_resetStack();
NUC_SET_AFLAG(NUC_AFLAG_DISRUPTED); // note as disrupted
atomizer.exitCode = code; // and save the exit code
}
/**
* If the atomizer is in a catchable state, then errors can be caught and notified.
* @param code Error code.
* @param format Error format string.
*/
static void atomizer_catchableError(uint8_t code, const char* format, ...) {
NUC_INIT_VA_ARGS;
// if the atomizer is not in a catchable state, then disrupt
if (!NUC_CHECK_AFLAG(NUC_AFLAG_DISRUPTION_CATCHABLE)) {
atomizer_errorDisplay(code, format, args);
atomizer_runtimeError(code, "");
return;
}
// read the format string to a buffer
char buffer[NUC_ERROR_BUFFER_LEN];
vsnprintf(buffer, NUC_ERROR_BUFFER_LEN, format, args);
va_end(args);
// and reallocate the buffer to an appropriate size
size_t length = strlen(buffer);
// now can play with the error as needed
NUC_SET_AFLAG(NUC_AFLAG_DISRUPTED); // set as disrupted regardless
atomizer.exitCode = code;
atomizer_buildDisruptionModel(buffer, length, code);
}
/**
* Handles throwing a disruption model instance.
* @param disruption Disruption to throw (as catchable).
*/
static void atomizer_thrownDisruption(nuc_ObjInstance* disruption) {
// preemptively get the code (needed for BOTH)
nuc_Particle codeValue;
nuc_ObjString* codeAccessor = objString_copy("code", 4);
table_get(&disruption->fields, codeAccessor, &codeValue);
// if not in a catchable state
if (!NUC_CHECK_AFLAG(NUC_AFLAG_DISRUPTION_CATCHABLE)) {
nuc_Particle msgValue;
nuc_ObjString* msgAccessor = objString_copy("message", 7);
table_get(&disruption->fields, msgAccessor, &msgValue);
atomizer_runtimeError((uint8_t)AS_NUMBER(codeValue), AS_CSTRING(msgValue));
return;
}
// otherwise throw as usual
NUC_SET_AFLAG(NUC_AFLAG_DISRUPTED);
atomizer.exitCode = AS_NUMBER(codeValue);
PUSH(NUC_OBJ(disruption));
}
#endif | 34.805882 | 95 | 0.630894 |
c75108b6a91694b380e25ea4a0f3f809b3ec5d11 | 4,001 | h | C | EnableMultiFactorAuthModalBP_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | null | null | null | EnableMultiFactorAuthModalBP_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | null | null | null | EnableMultiFactorAuthModalBP_classes.h | NotDiscordOfficial/Fortnite_SDK | 58f8da148256f99cb35518003306fffee33c4a21 | [
"MIT"
] | 1 | 2021-07-22T00:31:44.000Z | 2021-07-22T00:31:44.000Z | // WidgetBlueprintGeneratedClass EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C
// Size: 0x578 (Inherited: 0x500)
struct UEnableMultiFactorAuthModalBP_C : UEnableMultiFactorModal {
struct FPointerToUberGraphFrame UberGraphFrame; // 0x500(0x08)
struct UWidgetAnimation* Intro_V2; // 0x508(0x08)
struct UWidgetAnimation* ArrowPulse; // 0x510(0x08)
struct UWidgetAnimation* Intro; // 0x518(0x08)
struct UCommonTextBlock* ConsoleTextBlock; // 0x520(0x08)
struct UCommonTextBlock* CT_LimitedTimeHeader; // 0x528(0x08)
struct UCommonTextBlock* CT_TakenToWebsite; // 0x530(0x08)
struct UWidgetSwitcher* EnableButtonSwitcher; // 0x538(0x08)
struct UImage* Image_GoToWebsite; // 0x540(0x08)
struct UItemInfoWidget_C* ItemInfoWidget_FromSocialImport; // 0x548(0x08)
struct UFortLazyImage* lazyImage; // 0x550(0x08)
struct USafeZone* SafeZone; // 0x558(0x08)
struct UScaleBox* ScaleBox_TitleHeader; // 0x560(0x08)
float HeartbeatDelayIntroAnimation; // 0x568(0x04)
bool bHasReward; // 0x56c(0x01)
char pad_56D[0x3]; // 0x56d(0x03)
struct UCommonTextStyle* MobileLimitedTimeHeaderStyle; // 0x570(0x08)
void ScaleTitleForCulture(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.ScaleTitleForCulture // (Public|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void AnimationFullyCompleteBP(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.AnimationFullyCompleteBP // (Public|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void HandleSetScreenMode(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.HandleSetScreenMode // (Public|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void NavUp(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.NavUp // (Public|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void NavRight(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.NavRight // (Public|BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void BP_OnActivated(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.BP_OnActivated // (Event|Protected|BlueprintEvent) // @ game+0xda7c34
void PreConstruct(bool IsDesignTime); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.PreConstruct // (BlueprintCosmetic|Event|Public|BlueprintEvent) // @ game+0xda7c34
void HandleHeaderText(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.HandleHeaderText // (BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void OnIncentivizedSet(bool bIncentivized); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.OnIncentivizedSet // (BlueprintCallable|BlueprintEvent) // @ game+0xda7c34
void OnSetExitButtonText(struct FText NewButtonText); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.OnSetExitButtonText // (Event|Protected|HasOutParms|BlueprintEvent) // @ game+0xda7c34
void OnConsoleDisplayURLProvided(struct FText UniquePlayerURLText); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.OnConsoleDisplayURLProvided // (Event|Protected|HasOutParms|BlueprintEvent) // @ game+0xda7c34
void OnSetScreenConfiguration(bool bIsConsole); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.OnSetScreenConfiguration // (Event|Protected|BlueprintEvent) // @ game+0xda7c34
void Construct(); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.Construct // (BlueprintCosmetic|Event|Public|BlueprintEvent) // @ game+0xda7c34
void OnInputModeChanged(bool bUsingGamepad); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.OnInputModeChanged // (Event|Protected|BlueprintEvent) // @ game+0xda7c34
void ExecuteUbergraph_EnableMultiFactorAuthModalBP(int32_t EntryPoint); // Function EnableMultiFactorAuthModalBP.EnableMultiFactorAuthModalBP_C.ExecuteUbergraph_EnableMultiFactorAuthModalBP // (Final|UbergraphFunction|HasDefaults) // @ game+0xda7c34
};
| 102.589744 | 250 | 0.835291 |
0fde2a73671afcbba0ddf8dc8baea09bc3cc4df4 | 286 | h | C | PhysicalGameObject.h | Akmulla/SimpleEngine-v0.2 | 25b8f4bbe3c9d9b11eafe094b014ddd3766eca5b | [
"MIT"
] | null | null | null | PhysicalGameObject.h | Akmulla/SimpleEngine-v0.2 | 25b8f4bbe3c9d9b11eafe094b014ddd3766eca5b | [
"MIT"
] | null | null | null | PhysicalGameObject.h | Akmulla/SimpleEngine-v0.2 | 25b8f4bbe3c9d9b11eafe094b014ddd3766eca5b | [
"MIT"
] | null | null | null | #pragma once
#include "GameObject.h"
#include "Rigidbody.h"
class PhysicalGameObject : public GameObject
{
protected:
virtual void OnCollision(CollisionData);
Rigidbody* m_rb;
public:
Rigidbody* GetRigidbody();
void UpdateAABB();
PhysicalGameObject();
~PhysicalGameObject();
}; | 16.823529 | 44 | 0.762238 |
84e9d8a5f191eec3871cb29c57fad263cdebbbac | 1,024 | c | C | ZT/rain.c | xuehuachunsheng/HongxiuTeamCode | 8bec8ca44aae7c6ab7162af2f5a60d1374c6a5f0 | [
"Apache-2.0"
] | 1 | 2021-11-27T06:02:52.000Z | 2021-11-27T06:02:52.000Z | ZT/rain.c | DEAiFISH/HongxiuTeamCode | f18762c4480d3d8e0a70234e052528b2459d5ddf | [
"Apache-2.0"
] | null | null | null | ZT/rain.c | DEAiFISH/HongxiuTeamCode | f18762c4480d3d8e0a70234e052528b2459d5ddf | [
"Apache-2.0"
] | 1 | 2021-11-01T04:40:08.000Z | 2021-11-01T04:40:08.000Z | #include<stdio.h>
#define MONTHS 12
#define YEARS 5
int main(void)
{
const float rain[YEARS][MONTHS]=
{
{4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6},
{8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3},
{9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4},
{7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.7,4.3,6.2},
{7.6,5.6,3.8,2.8,3.8,0.2,0.0,0.0,0.0,1.3,2.6,5.2}
};
int year,month;
float subtot,total;
printf("YEAR RAINFALL (inches)\n");
for(year=0,total=0;year<YEARS;year++)
{
for(month=0,subtot=0;month<MONTHS;month++)
subtot+=rain[year][month];
printf("%5d %15.1f\n",2010+year,subtot);
total+=subtot;
}
printf("\n The yearly average is %.1f inches.\n\n",total/YEARS);
printf("MONTHLY AVERAGES:\n\n");
printf("Jan Feb Mar Apr MAY Jun Jul Aug Sep Oct");
printf(" Nov Dec\n");
for(month=0;month<MONTHS;month++)
{
for(year=0,subtot=0;year<YEARS;year++)
subtot+=rain[year][month];
printf("%4.1f",subtot/YEARS);
}
printf("\n");
return 0;
}
| 26.947368 | 66 | 0.573242 |
576d34226a4cb75696c42b576772ad6dde59a12c | 449 | h | C | src/ecs/Forward.h | raptoravis/two | 4366fcf8b3072d0233eb8e1e91ac1105194f60f5 | [
"Zlib"
] | 578 | 2019-05-04T09:09:42.000Z | 2022-03-27T23:02:21.000Z | src/ecs/Forward.h | raptoravis/two | 4366fcf8b3072d0233eb8e1e91ac1105194f60f5 | [
"Zlib"
] | 14 | 2019-05-11T14:34:56.000Z | 2021-02-02T07:06:46.000Z | src/ecs/Forward.h | raptoravis/two | 4366fcf8b3072d0233eb8e1e91ac1105194f60f5 | [
"Zlib"
] | 42 | 2019-05-11T16:04:19.000Z | 2022-01-24T02:21:43.000Z | #pragma once
#include <infra/Config.h>
#include <infra/Forward.h>
#include <type/Forward.h>
#ifndef TWO_ECS_EXPORT
#define TWO_ECS_EXPORT TWO_IMPORT
#endif
namespace two
{
template <class T> struct ComponentHandle;
template <class T> struct EntityHandle;
class Prototype;
struct Entity;
struct Entt;
class OEntt;
class ECS;
class GridECS;
class Complex;
}
#ifdef TWO_META_GENERATOR
#include <stl/vector.h>
namespace stl
{
}
#endif
| 14.03125 | 43 | 0.750557 |
cb34ff7bd76b831a31a47e4926b3cfd2d4159f3f | 215 | h | C | NewsTwo/News/CycleCVController.h | hetefe/news | 8f97e1367effbf3f4deaa2b6278c513c374143cf | [
"Apache-2.0"
] | null | null | null | NewsTwo/News/CycleCVController.h | hetefe/news | 8f97e1367effbf3f4deaa2b6278c513c374143cf | [
"Apache-2.0"
] | null | null | null | NewsTwo/News/CycleCVController.h | hetefe/news | 8f97e1367effbf3f4deaa2b6278c513c374143cf | [
"Apache-2.0"
] | null | null | null | //
// CycleCVController.h
// News
//
// Created by 赫腾飞 on 15/11/26.
// Copyright © 2015年 hetefe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CycleCVController : UICollectionViewController
@end
| 15.357143 | 57 | 0.702326 |
3bba05aa3c5f636149f8a84f4f82a222caaa06e3 | 5,976 | h | C | device/peripheral/wifi/rs9113/include/rsi_bt_common_apis.h | ParkerMactavish/embarc_osp | 9e69440a31d6a4268ef166972aa71a7a19156431 | [
"BSD-3-Clause"
] | 55 | 2017-04-16T01:14:45.000Z | 2022-02-18T09:30:45.000Z | device/peripheral/wifi/rs9113/include/rsi_bt_common_apis.h | ParkerMactavish/embarc_osp | 9e69440a31d6a4268ef166972aa71a7a19156431 | [
"BSD-3-Clause"
] | 121 | 2017-06-30T09:43:01.000Z | 2021-11-23T16:26:35.000Z | device/peripheral/wifi/rs9113/include/rsi_bt_common_apis.h | ParkerMactavish/embarc_osp | 9e69440a31d6a4268ef166972aa71a7a19156431 | [
"BSD-3-Clause"
] | 85 | 2017-04-16T01:46:20.000Z | 2021-09-23T09:26:53.000Z | /**
* @file rsi_bt_common_apis.h
* @version 0.1
* @date 01 Oct 2015
*
* Copyright(C) Redpine Signals 2015
* All rights reserved by Redpine Signals.
*
* @section License
* This program should be used on your own responsibility.
* Redpine Signals assumes no responsibility for any losses
* incurred by customers or third parties arising from the use of this file.
*
* @brief : This file contain definitions and declarations of BT common APIs.
*
* @section Description This file contains definitions and declarations of common
* functions required to configure both BLE and BT Classic modules.
*
*/
#ifndef RSI_BT_COMMON_APIS_H
#define RSI_BT_COMMON_APIS_H
#include<rsi_data_types.h>
#include<rsi_utils.h>
/******************************************************
* * Macros
* ******************************************************/
//! success return value
#define RSI_SUCCESS 0
//! failure return value
#define RSI_FAILURE -1
/******************************************************
* * Constants
* ******************************************************/
/******************************************************
* * Enumerations
* ******************************************************/
/******************************************************
* * Type Definitions
* ******************************************************/
/******************************************************
* * Structures
* ******************************************************/
/******************************************************
* * Global Variables
* ******************************************************/
/******************************************************
* * BT Common API's Declarations
* ******************************************************/
/*==============================================*/
/**
* @fn rsi_bt_set_local_name
* @brief sets the local BT/BLE device name
* @param[in] local_name, name to be set to the local BT/BLE device
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function sets the given name to the local BT/BLE device
*/
int32_t rsi_bt_set_local_name(int8_t *local_name);
/*==============================================*/
/**
* @fn rsi_bt_get_local_name
* @brief requests the local BT/BLE device name
* @param[out] resp, response buffer to hold the response of this API
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used know the name of the local BT/BLE device
*/
int32_t rsi_bt_get_local_name(rsi_bt_resp_get_local_name_t *bt_resp_get_local_name);
/*==============================================*/
/**
* @fn rsi_bt_get_rssi
* @brief request the RSSI of the connected BT/BLE device
* @param[out] resp, response buffer to hold the response of this API
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used know the RSSI of the connected BT/BLE device
*/
int32_t rsi_bt_get_rssi(int8_t *remote_dev_addr, uint8_t *resp);
/*==============================================*/
/**
* @fn rsi_bt_get_local_device_address
* @brief request the local BT/BLE device address
* @param[out] resp, response buffer to hold the response of this API
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used to know the local BT/BLE device address
*/
int32_t rsi_bt_get_local_device_address(uint8_t *resp);
/*==============================================*/
/**
* @fn rsi_bt_init
* @brief Initializes the BT/BLE device
* @param[in] void
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used to initialise the BT/BLE device.
* Its recommended to use this API after rsi_bt_deinit API
*/
int32_t rsi_bt_init(void);
/*==============================================*/
/**
* @fn rsi_bt_deinit
* @brief de-initializes/stops the BT/BLE device
* @param[in] void
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used to de-initialize the BT/BLE device.
* rsi_bt_init API shall be used after rsi_bt_deinit API
*/
int32_t rsi_bt_deinit(void);
/*==============================================*/
/**
* @fn rsi_bt_set_antenna
* @brief sets the antenna of the local BT/BLE device
* @param[in] antenna_value, either internal/external antenna
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used to select either internal/external antenna of the
* BT/BLE device
*/
int32_t rsi_bt_set_antenna(uint8_t antenna_value);
/*==============================================*/
/**
* @fn rsi_bt_set_feature_bitmap
* @brief set or enable the BT or BLE features at firmware
* @param[in] feature_bit_map, features bit map list
* @return int32_t
* 0 = success
* !0 = failure
* @section description
* This function is used to set or select the features bit map
*/
int32_t rsi_bt_set_feature_bitmap(uint32_t feature_bit_map);
/*==============================================*/
/**
* @fn rsi_bt_set_antenna_tx_power_level
* @brief sets the antenna transmit power of the local BT/BLE device
* @param[in] protocol_mode, BT or LE
* power_level,
* @return int32_t
* 0 = success
* !0 = failure
* @section description
*/
int32_t rsi_bt_set_antenna_tx_power_level(uint8_t protocol_mode, int8_t tx_power);
#endif
| 32.835165 | 84 | 0.502343 |
22ede711f3270f22f8e61d0cb01a08346f4d25b8 | 113 | h | C | code/include/mrcuda.h | yangtze1006/PCN_Windows | f89d53ebf5d0e6bcc2971e92b4c4ece4b799b728 | [
"BSD-2-Clause"
] | null | null | null | code/include/mrcuda.h | yangtze1006/PCN_Windows | f89d53ebf5d0e6bcc2971e92b4c4ece4b799b728 | [
"BSD-2-Clause"
] | null | null | null | code/include/mrcuda.h | yangtze1006/PCN_Windows | f89d53ebf5d0e6bcc2971e92b4c4ece4b799b728 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#pragma comment(lib,"cudart.lib") | 28.25 | 38 | 0.769912 |
7053092c692ac8ff499ebe57bb78471fa054c9da | 4,349 | h | C | Dependencies/Build/mac/share/faust/sam/samFaustDSP.h | SKyzZz/test | 9b03adce666adb85e5ae2d8af5262e0acb4b91e1 | [
"Zlib"
] | 2 | 2020-10-25T09:03:03.000Z | 2021-06-24T13:20:01.000Z | Dependencies/Build/mac/share/faust/sam/samFaustDSP.h | SKyzZz/test | 9b03adce666adb85e5ae2d8af5262e0acb4b91e1 | [
"Zlib"
] | null | null | null | Dependencies/Build/mac/share/faust/sam/samFaustDSP.h | SKyzZz/test | 9b03adce666adb85e5ae2d8af5262e0acb4b91e1 | [
"Zlib"
] | null | null | null | /************************************************************************
SHARC Audio Module Faust Architecture File
Copyright (c) 2018 Analog Devices, Inc. All rights reserved.
---------------------------------------------------------------------
This Architecture section is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; If not, see <http://www.gnu.org/licenses/>.
EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************/
#ifndef __sam_faust_dsp__
#define __sam_faust_dsp__
//==========================================
#define SAM_SAMPLERATE AUDIO_SAMPLE_RATE
class FaustPolyEngine;
class MidiUI;
class samAudio;
class mydsp;
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
class samFaustDSP
{
private:
// the polyphonic engine
FaustPolyEngine* fPolyEngine;
// the audio driver
samAudio* fAudioDriver;
public:
//--------------`samFaustDSP()`----------------
// Default constructor, the audio driver will set
// the sampleRate and buffer size
//----
samFaustDSP(int sampleRate, int bufferSize, int numInputs, int numOutputs);
// destructor
~samFaustDSP();
// setup the the hardware buffer pointers.
void setDSP_ChannelBuffers(FAUSTFLOAT* AudioChannelA_0_Left,
FAUSTFLOAT* AudioChannelA_0_Right,
FAUSTFLOAT* AudioChannelA_1_Left,
FAUSTFLOAT* AudioChannelA_1_Right,
FAUSTFLOAT* AudioChannelA_2_Left,
FAUSTFLOAT* AudioChannelA_2_Right,
FAUSTFLOAT* AudioChannelA_3_Left,
FAUSTFLOAT* AudioChannelA_3_Right,
FAUSTFLOAT* AudioChannelB_0_Left,
FAUSTFLOAT* AudioChannelB_0_Right,
FAUSTFLOAT* AudioChannelB_1_Left,
FAUSTFLOAT* AudioChannelB_1_Right,
FAUSTFLOAT* AudioChannelB_2_Left,
FAUSTFLOAT* AudioChannelB_2_Right,
FAUSTFLOAT* AudioChannelB_3_Left,
FAUSTFLOAT* AudioChannelB_3_Right);
//-----------------`void stop()`--------------------------
// Callback to render a buffer.
//--------------------------------------------------------
void processAudioCallback();
//-------`void propagateMidi(int count, double time, int type, int channel, int data1, int data2)`--------
// Take a raw MIDI message and propagate it to the Faust
// DSP object. This method can be used concurrently with
// [`keyOn`](#keyOn) and [`keyOff`](#keyOff).
//
// `propagateMidi` can
// only be used if the `[style:poly]` metadata is used in
// the Faust code or if `-nvoices` flag has been
// provided before compilation.
//
// #### Arguments
//
// * `count`: size of the message (1-3)
// * `time`: time stamp
// * `type`: message type (byte)
// * `channel`: channel number
// * `data1`: first data byte (should be `null` if `count<2`)
// * `data2`: second data byte (should be `null` if `count<3`)
//--------------------------------------------------------
void propagateMidi(int, double, int, int, int, int);
};
#endif
| 40.268519 | 114 | 0.531387 |
467b0c6a1c727ab0d2460e88a7f03ee2c72179e6 | 1,396 | h | C | src/header/AudioEditor.h | vfarjood/Neuro-Load-Reduction | da454fa963984dfa10daf1ab7ccf38f4b30c9247 | [
"MIT"
] | null | null | null | src/header/AudioEditor.h | vfarjood/Neuro-Load-Reduction | da454fa963984dfa10daf1ab7ccf38f4b30c9247 | [
"MIT"
] | null | null | null | src/header/AudioEditor.h | vfarjood/Neuro-Load-Reduction | da454fa963984dfa10daf1ab7ccf38f4b30c9247 | [
"MIT"
] | null | null | null | //***************************************************************************//
// //
// @File Name: AudioEditor.h //
// @Author: Vahid Farjood Chafi //
// @Version: 0.0.1 //
// @Date: 13th December 2021 //
// @Description: This file is used to control and manage audios files //
// specially for playing back. //
// //
//***************************************************************************//
#pragma once
#define __STDC_CONSTANT_MACROS
extern "C"
{
#include "libavutil/avutil.h"
#include "libavutil/audio_fifo.h"
}
#include "../../lib/miniaudio/miniaudio.h"
class AudioEditor
{
private:
ma_device_config deviceConfig;
ma_device device;
public:
double wait;
private:
static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
public:
AudioEditor();
~AudioEditor();
void initDevice(const AVAudioFifo* const fifo, int const& channels, int const& sample_rate, double const& duration);
void play();
void close();
};
| 31.022222 | 117 | 0.419054 |
0be6de59c881f8dd4c5b58409e589d9839f3a0c5 | 1,601 | h | C | PrivateFrameworks/AVConference/VCMediaNegotiatorAudioConfiguration.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/AVConference/VCMediaNegotiatorAudioConfiguration.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/AVConference/VCMediaNegotiatorAudioConfiguration.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "NSCopying.h"
@class NSMutableSet, NSSet;
__attribute__((visibility("hidden")))
@interface VCMediaNegotiatorAudioConfiguration : NSObject <NSCopying>
{
unsigned int _ssrc;
BOOL _allowAudioSwitching;
BOOL _allowAudioRecording;
BOOL _useSBR;
unsigned int _audioUnitNumber;
NSMutableSet *_audioPayloads;
NSMutableSet *_secondaryPayloads;
}
@property(readonly, nonatomic) NSSet *audioPayloads; // @synthesize audioPayloads=_audioPayloads;
@property(nonatomic) unsigned int audioUnitNumber; // @synthesize audioUnitNumber=_audioUnitNumber;
@property(nonatomic) BOOL useSBR; // @synthesize useSBR=_useSBR;
@property(nonatomic) BOOL allowAudioRecording; // @synthesize allowAudioRecording=_allowAudioRecording;
@property(nonatomic) BOOL allowAudioSwitching; // @synthesize allowAudioSwitching=_allowAudioSwitching;
@property(nonatomic) unsigned int ssrc; // @synthesize ssrc=_ssrc;
- (BOOL)isEqual:(id)arg1;
- (id)copyWithZone:(struct _NSZone *)arg1;
- (BOOL)isSecondaryPayload:(int)arg1;
- (void)addAudioPayload:(int)arg1 isSecondary:(BOOL)arg2;
- (void)dealloc;
- (id)initWithAllowAudioSwitching:(BOOL)arg1 allowAudioRecording:(BOOL)arg2 useSBR:(BOOL)arg3 ssrc:(unsigned int)arg4 audioUnitNumber:(unsigned int)arg5 audioRuleCollection:(id)arg6;
- (id)initWithAllowAudioSwitching:(BOOL)arg1 allowAudioRecording:(BOOL)arg2 useSBR:(BOOL)arg3 ssrc:(unsigned int)arg4 audioUnitNumber:(unsigned int)arg5;
@end
| 39.04878 | 182 | 0.777014 |
600018070610e6a41dcfbb2411cfbc1d7a6c9a81 | 431 | h | C | util.h | graphitemaster/xcpumemperf | f2f9bb20677c64964c56513edabee151120c46cf | [
"MIT"
] | 3 | 2017-11-15T21:26:14.000Z | 2021-05-07T00:51:42.000Z | util.h | graphitemaster/xcpumemperf | f2f9bb20677c64964c56513edabee151120c46cf | [
"MIT"
] | 1 | 2017-11-16T06:27:19.000Z | 2017-11-16T06:27:19.000Z | util.h | graphitemaster/xcpumemperf | f2f9bb20677c64964c56513edabee151120c46cf | [
"MIT"
] | 5 | 2017-11-16T02:16:01.000Z | 2017-11-16T14:38:09.000Z | #ifndef UTIL_HDR
#define UTIL_HDR
/* High resolution timer wall time in seconds */
double util_gettime(void);
/* Human readable size metric from size */
const char* util_humansize(char* buffer, size_t bufsize, size_t size);
struct cpuinfo
{
struct { int cpu, core; } entries[128];
int physical;
int threads;
int logical;
char name[1024];
};
int util_getcpuinfo(struct cpuinfo *info);
int util_enumeratecpus(void);
#endif
| 18.73913 | 70 | 0.742459 |
00c30b7a5bef6b572651785957db2247b5847199 | 1,171 | h | C | glibc/sysdeps/unix/sysv/linux/m68k/mmap_internal.h | chyidl/mirror-glibc | 3b17633afc85a9fb8cba0edc365d19403158c5a0 | [
"BSD-3-Clause"
] | null | null | null | glibc/sysdeps/unix/sysv/linux/m68k/mmap_internal.h | chyidl/mirror-glibc | 3b17633afc85a9fb8cba0edc365d19403158c5a0 | [
"BSD-3-Clause"
] | null | null | null | glibc/sysdeps/unix/sysv/linux/m68k/mmap_internal.h | chyidl/mirror-glibc | 3b17633afc85a9fb8cba0edc365d19403158c5a0 | [
"BSD-3-Clause"
] | null | null | null | /* Common mmap definition for Linux implementation. Linux/m68k version.
Copyright (C) 2017-2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef MMAP_M68K_INTERNAL_LINUX_H
#define MMAP_M68K_INTERNAL_LINUX_H
/* ColdFire and Sun 3 kernels have PAGE_SHIFT set to 13 and expect
mmap2 offset to be provided in 8K pages. Determine the shift
dynamically with getpagesize. */
#define MMAP2_PAGE_UNIT -1
#include_next <mmap_internal.h>
#endif
| 39.033333 | 72 | 0.760034 |
44a7546f3335875b7f5deaf07dd17f94b1f99ace | 2,768 | h | C | config.h | z7059652/FreeRDP | 1c738ec0be5a1b461244b4292c5f50d5fa6fb4de | [
"Apache-2.0"
] | null | null | null | config.h | z7059652/FreeRDP | 1c738ec0be5a1b461244b4292c5f50d5fa6fb4de | [
"Apache-2.0"
] | null | null | null | config.h | z7059652/FreeRDP | 1c738ec0be5a1b461244b4292c5f50d5fa6fb4de | [
"Apache-2.0"
] | null | null | null | #ifndef __CONFIG_H
#define __CONFIG_H
#define FREERDP_DATA_PATH "C:/Program Files/FreeRDP/share/freerdp"
#define FREERDP_KEYMAP_PATH ""
#define FREERDP_PLUGIN_PATH "lib/freerdp"
#define FREERDP_INSTALL_PREFIX "C:/Program Files/FreeRDP"
#define FREERDP_LIBRARY_PATH "lib"
#define FREERDP_ADDIN_PATH "lib/freerdp"
#define CMAKE_SHARED_LIBRARY_SUFFIX ".dll"
#define CMAKE_SHARED_LIBRARY_PREFIX ""
#define FREERDP_VENDOR_STRING "FreeRDP"
#define FREERDP_PRODUCT_STRING "FreeRDP"
/* Include files */
#define HAVE_FCNTL_H
/* #undef HAVE_UNISTD_H */
#define HAVE_STDINT_H
#define HAVE_INTTYPES_H
/* #undef HAVE_SYS_MODEM_H */
/* #undef HAVE_SYS_FILIO_H */
/* #undef HAVE_SYS_SELECT_H */
/* #undef HAVE_SYS_SOCKIO_H */
/* #undef HAVE_SYS_STRTIO_H */
/* #undef HAVE_EVENTFD_H */
/* #undef HAVE_TIMERFD_H */
/* #undef HAVE_TM_GMTOFF */
/* #undef HAVE_AIO_H */
/* #undef HAVE_POLL_H */
/* #undef HAVE_PTHREAD_MUTEX_TIMEDLOCK */
/* #undef HAVE_VALGRIND_MEMCHECK_H */
/* #undef HAVE_EXECINFO_H */
/* Features */
/* #undef HAVE_ALIGNED_REQUIRED */
/* Options */
/* #undef WITH_PROFILER */
/* #undef WITH_GPROF */
#define WITH_SSE2
/* #undef WITH_NEON */
/* #undef WITH_IPP */
#define WITH_NATIVE_SSPI
/* #undef WITH_JPEG */
/* #undef WITH_WIN8 */
/* #undef WITH_RDPSND_DSOUND */
/* #undef WITH_EVENTFD_READ_WRITE */
/* #undef HAVE_MATH_C99_LONG_DOUBLE */
/* #undef WITH_FFMPEG */
/* #undef WITH_GSTREAMER_1_0 */
/* #undef WITH_GSTREAMER_0_10 */
#define WITH_WINMM
/* #undef WITH_MACAUDIO */
/* #undef WITH_OSS */
/* #undef WITH_ALSA */
/* #undef WITH_PULSE */
/* #undef WITH_IOSAUDIO */
/* #undef WITH_OPENSLES */
/* #undef WITH_GSM */
#define WITH_MEDIA_FOUNDATION
/* Plugins */
#define STATIC_CHANNELS
/* #undef WITH_RDPDR */
/* Debug */
/* #undef WITH_DEBUG_CERTIFICATE */
/* #undef WITH_DEBUG_CAPABILITIES */
/* #undef WITH_DEBUG_CHANNELS */
/* #undef WITH_DEBUG_CLIPRDR */
/* #undef WITH_DEBUG_DVC */
/* #undef WITH_DEBUG_TSMF */
/* #undef WITH_DEBUG_GDI */
/* #undef WITH_DEBUG_KBD */
/* #undef WITH_DEBUG_LICENSE */
/* #undef WITH_DEBUG_NEGO */
/* #undef WITH_DEBUG_NLA */
/* #undef WITH_DEBUG_NTLM */
/* #undef WITH_DEBUG_TSG */
/* #undef WITH_DEBUG_ORDERS */
/* #undef WITH_DEBUG_RAIL */
/* #undef WITH_DEBUG_RDP */
/* #undef WITH_DEBUG_REDIR */
/* #undef WITH_DEBUG_RFX */
/* #undef WITH_DEBUG_SCARD */
/* #undef WITH_DEBUG_SND */
/* #undef WITH_DEBUG_SVC */
/* #undef WITH_DEBUG_RDPEI */
/* #undef WITH_DEBUG_TIMEZONE */
/* #undef WITH_DEBUG_THREADS */
/* #undef WITH_DEBUG_MUTEX */
/* #undef WITH_DEBUG_TRANSPORT */
/* #undef WITH_DEBUG_WND */
/* #undef WITH_DEBUG_X11 */
/* #undef WITH_DEBUG_X11_CLIPRDR */
/* #undef WITH_DEBUG_X11_LOCAL_MOVESIZE */
/* #undef WITH_DEBUG_XV */
/* #undef WITH_DEBUG_ANDROID_JNI */
/* #undef WITH_DEBUG_RINGBUFFER */
#endif
| 25.62963 | 66 | 0.722905 |
93bac339e3988ccc71f64b6d065da1a091957fa0 | 608 | h | C | include/ChessCore/AppleUtil.h | trojanfoe/ChessCore | be1022a37bc12fb6c545d258eaf4b99f57049995 | [
"MIT",
"Unlicense"
] | 3 | 2016-02-02T23:00:22.000Z | 2018-08-03T12:51:34.000Z | include/ChessCore/AppleUtil.h | trojanfoe/ChessCore | be1022a37bc12fb6c545d258eaf4b99f57049995 | [
"MIT",
"Unlicense"
] | 1 | 2015-01-01T12:15:56.000Z | 2015-01-04T19:44:01.000Z | include/ChessCore/AppleUtil.h | trojanfoe/ChessCore | be1022a37bc12fb6c545d258eaf4b99f57049995 | [
"MIT",
"Unlicense"
] | null | null | null | //
// ChessCore (c)2008-2013 Andy Duplain <andy@trojanfoe.com>
//
// AppleUtil.h: Apple-specific utility functions.
//
#pragma once
#include <ChessCore/ChessCore.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Get the app's temporary directory into the specified buffer.
*
* @param buffer Where to store the temporary directory.
* @param buflen The size of the buffer pointed to by 'buffer'.
*
* @return TRUE if the temporary directory was successfully retrieved, else FALSE.
*/
extern int CHESSCORE_EXPORT appleTempDir(char *buffer, unsigned buflen);
#ifdef __cplusplus
} // extern "C"
#endif
| 21.714286 | 82 | 0.728618 |
7851bea12d0694071b3bc5be7f04cb58002138cc | 1,426 | h | C | Source/Samples/54_P2PMultiplayerExtended/Peer.h | ArnisLielturks/Urho3D-P2P-Multiplayer | f986ca7fdfcbe46a7883cc48db8a23e876330602 | [
"MIT"
] | 2 | 2019-02-19T09:00:13.000Z | 2022-01-11T17:05:23.000Z | Source/Samples/54_P2PMultiplayerExtended/Peer.h | ArnisLielturks/Urho3D-P2P-Multiplayer | f986ca7fdfcbe46a7883cc48db8a23e876330602 | [
"MIT"
] | null | null | null | Source/Samples/54_P2PMultiplayerExtended/Peer.h | ArnisLielturks/Urho3D-P2P-Multiplayer | f986ca7fdfcbe46a7883cc48db8a23e876330602 | [
"MIT"
] | 1 | 2019-11-25T10:33:35.000Z | 2019-11-25T10:33:35.000Z | //
// Created by arnislielturks on 18.6.11.
//
#pragma once
#include <Urho3D/Input/Controls.h>
#include <Urho3D/Scene/LogicComponent.h>
#include <Urho3D/Network/Connection.h>
#include <Urho3D/Core/Context.h>
#include <Urho3D/Scene/Scene.h>
using namespace Urho3D;
// Control bits we define
static const unsigned CTRL_FORWARD = 1;
static const unsigned CTRL_BACK = 2;
static const unsigned CTRL_LEFT = 4;
static const unsigned CTRL_RIGHT = 8;
static const unsigned CTRL_JUMP = 16;
class Peer: public Object {
URHO3D_OBJECT(Peer, Object);
public:
/// Construct.
explicit Peer(Context* context);
~Peer();
/// Register object factory and attributes.
static void RegisterObject(Context* context);
/// Handle physics world update. Called by LogicComponent base class.
void HandlePhysicsPrestep(StringHash eventType, VariantMap& eventData);
void Create(Connection* connection);
void SetScene(Scene* scene);
void SetConnection(Connection* connection);
const WeakPtr<Connection> GetConnection() const { return connection_; }
void SetNode(Node* node);
const Node* GetNode() const { return node_; };
void DestroyNode();
private:
/// Movement controls. Assigned by the main program each physics update step.
Controls controls_;
SharedPtr<Node> node_;
WeakPtr<Connection> connection_;
WeakPtr<Scene> scene_;
Timer updateTimer_;
};
| 21.606061 | 81 | 0.718794 |
2b024bb9faf7a7519073b4672a63e11151060baa | 5,176 | c | C | lib/mdb/mdb.c | UWNetworksLab/arrakis | a6964987bb718e3d84e4fbf44f5d1d1b5e7f64a7 | [
"MIT"
] | 81 | 2015-01-02T23:53:38.000Z | 2021-12-26T23:04:47.000Z | lib/mdb/mdb.c | salivarick/barrelfish | 252246b89117b0a23f6caa48a8b166c7bf12f885 | [
"MIT"
] | 1 | 2016-09-21T06:27:06.000Z | 2016-10-05T07:16:28.000Z | lib/mdb/mdb.c | salivarick/barrelfish | 252246b89117b0a23f6caa48a8b166c7bf12f885 | [
"MIT"
] | 7 | 2015-03-11T14:27:15.000Z | 2017-11-08T23:03:45.000Z | /**
* \file
* \brief
*/
/*
* Copyright (c) 2007, 2008, 2010, 2011, ETH Zurich.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
*/
#include <stdio.h>
#include <string.h>
#include <errors/errno.h>
#include <barrelfish/types.h>
#include <barrelfish_kpi/syscalls.h>
#include <capabilities.h>
#include <cap_predicates.h>
#include <mdb/mdb.h>
#include <mdb/mdb_tree.h>
void set_cap_remote(struct cte *cte, bool is_remote)
{
assert(cte != NULL);
cte->mdbnode.remote_relations = is_remote; // set is_remote on this cte
struct cte *next = mdb_successor(cte);
// find all relations and set is_remote on them
while (next) {
if (is_copy(&next->cap, &cte->cap) || is_ancestor(&next->cap, &cte->cap)
|| is_ancestor(&cte->cap, &next->cap)) {
next->mdbnode.remote_relations = is_remote;
} else {
break;
}
next = mdb_successor(next);
}
struct cte *prev = mdb_predecessor(cte);
while (prev) {
if (is_copy(&prev->cap, &cte->cap) || is_ancestor(&prev->cap, &cte->cap)
|| is_ancestor(&cte->cap, &prev->cap)) {
prev->mdbnode.remote_relations = is_remote;
} else {
break;
}
prev = mdb_predecessor(prev);
}
}
bool is_cap_remote(struct cte *cte)
{
return cte->mdbnode.remote_relations;
}
/// Check if #cte has any descendants
bool has_descendants(struct cte *cte)
{
assert(cte != NULL);
struct cte *next = mdb_find_greater(&cte->cap, false);
return next
&& get_type_root(next->cap.type) == get_type_root(cte->cap.type)
&& get_address(&next->cap) < get_address(&cte->cap) + get_size(&cte->cap);
}
/// Check if #cte has any ancestors
bool has_ancestors(struct cte *cte)
{
assert(cte != NULL);
// XXX: this check should have its own predicate
if (!get_address(&cte->cap) && !get_size(&cte->cap)) {
return false;
}
struct cte *prev = mdb_find_less(&cte->cap, false);
if (prev
&& get_type_root(prev->cap.type) == get_type_root(cte->cap.type)
&& get_address(&prev->cap) + get_size(&prev->cap)
>= get_address(&cte->cap) + get_size(&cte->cap))
{
return true;
}
// cte is preceded in the ordering by a non-ancestor. This imples one of
// two situations:
// 1) cte has no ancestors
// 2) cte has ancestors but also has siblings earlier in the
// ordering, thus the ancestor cannot have the same base
// address as cte.
// If we query for the zero-length memory region at cte's start
// address, we will not get cte itself back as the end of our query
// is at cte's start address.
// Similarly, we cannot get a sibling of cte that ends where cte
// starts, as the beginning of our query is not in that sibling's
// region.
// Thus we must get its ancestor if present, or no cap at all.
int find_result;
mdb_find_range(get_type_root(cte->cap.type),
get_address(&cte->cap), 0,
MDB_RANGE_FOUND_SURROUNDING,
&prev, &find_result);
if (find_result != MDB_RANGE_NOT_FOUND) {
assert(find_result == MDB_RANGE_FOUND_SURROUNDING);
assert(prev);
assert(get_address(&prev->cap) <= get_address(&cte->cap));
assert(get_address(&prev->cap) + get_size(&prev->cap)
>= get_address(&cte->cap) + get_size(&cte->cap));
}
return find_result != MDB_RANGE_NOT_FOUND;
}
/// Checks if #cte has any copies
bool has_copies(struct cte *cte)
{
assert(cte != NULL);
struct cte *next = mdb_successor(cte);
if (next && is_copy(&next->cap, &cte->cap)) {
return true;
}
struct cte *prev = mdb_predecessor(cte);
if (prev && is_copy(&prev->cap, &cte->cap)) {
return true;
}
return false;
}
/**
* \brief Returns a copy of the #cap
*/
errval_t mdb_get_copy(struct capability *cap, struct capability **ret)
{
assert(cap != NULL);
assert(ret != NULL);
struct cte *cte = mdb_find_equal(cap);
if (cte) {
*ret = &cte->cap;
return SYS_ERR_OK;
}
else {
return SYS_ERR_NO_LOCAL_COPIES;
}
}
bool mdb_is_sane(void)
{
if (mdb_check_invariants() != 0) {
return false;
}
// TODO: check following conditon on each element of mdb
//if ((lvaddr_t)walk < BASE_PAGE_SIZE || walk->cap.type == ObjType_Null) {
// return false;
//}
return true;
}
/**
* Place #dest_start in the mapping database in the appropriate location.
*
* Look for its relations: copies and descendants and place in accordance.
* If no relations found, place at the top and set map_head to point to it.
*/
void set_init_mapping(struct cte *dest_start, size_t num)
{
for (size_t i = 0; i < num; i++) {
mdb_insert(&dest_start[i]);
}
}
/// Remove one cap from the mapping database
void remove_mapping(struct cte *cte)
{
mdb_remove(cte);
}
| 27.531915 | 82 | 0.618238 |
ff94e352a1a7cc39fc00d5c321fba7906311ec55 | 723 | h | C | Chaos/src/Chaos.h | dohnala/Chaos | 384a85082860310344b3509c429d4e680fe14e8d | [
"Apache-2.0"
] | null | null | null | Chaos/src/Chaos.h | dohnala/Chaos | 384a85082860310344b3509c429d4e680fe14e8d | [
"Apache-2.0"
] | null | null | null | Chaos/src/Chaos.h | dohnala/Chaos | 384a85082860310344b3509c429d4e680fe14e8d | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "Chaos/Core/Base.h"
#include "Chaos/Core/Application.h"
#include "Chaos/Core/Layer.h"
#include "Chaos/Core/Log.h"
#include "Chaos/Core/Assert.h"
#include "Chaos/Core/Timestep.h"
#include "Chaos/Core/Random.h"
#include "Chaos/Core/Input.h"
#include "Chaos/Core/KeyCodes.h"
#include "Chaos/Core/MouseCodes.h"
#include "Chaos/Math/Math.h"
#include "Chaos/Events/Event.h"
#include "Chaos/Renderer/Renderer.h"
#include "Chaos/Renderer/Buffer.h"
#include "Chaos/Renderer/VertexArray.h"
#include "Chaos/Renderer/Shader.h"
#include "Chaos/Renderer/Camera.h"
#include "Chaos/Renderer/OrthographicCamera.h"
#include "Chaos/Other/ParticleSystem.h"
#include "Chaos/ECS/World.h"
#include "Chaos/ECS/Entity.h" | 25.821429 | 46 | 0.75657 |
2c985ca868a6e32f72b133475cd8a9bda966d753 | 2,912 | h | C | third_party/chromium/base/trace_event/auto_open_close_event.h | dendisuhubdy/CXTPL | 586b146c6a68b79a310ba20d133a0ca6211f22cc | [
"MIT"
] | 128 | 2019-10-07T14:03:15.000Z | 2022-02-25T10:25:57.000Z | third_party/chromium/base/trace_event/auto_open_close_event.h | dendisuhubdy/CXTPL | 586b146c6a68b79a310ba20d133a0ca6211f22cc | [
"MIT"
] | 65 | 2019-09-20T07:25:22.000Z | 2020-10-14T14:31:52.000Z | third_party/chromium/base/trace_event/auto_open_close_event.h | dendisuhubdy/CXTPL | 586b146c6a68b79a310ba20d133a0ca6211f22cc | [
"MIT"
] | 90 | 2019-10-16T06:13:14.000Z | 2022-03-02T10:29:19.000Z | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_TRACE_EVENT_AUTO_OPEN_CLOSE_EVENT_H_
#define BASE_TRACE_EVENT_AUTO_OPEN_CLOSE_EVENT_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
namespace base {
namespace trace_event {
// Class for tracing events that support "auto-opening" and "auto-closing".
// "auto-opening" = if the trace event is started (call Begin() before
// tracing is started,the trace event will be opened, with the start time
// being the time that the trace event was actually started.
// "auto-closing" = if the trace event is started but not ended by the time
// tracing ends, then the trace event will be automatically closed at the
// end of tracing.
// |category| must be known at compile-time in order to be used in trace macros.
// Hence, it's passed as a class templace argument.
template <const char* category>
class AutoOpenCloseEvent : public TraceLog::AsyncEnabledStateObserver {
public:
enum Type {
ASYNC
};
// As in the rest of the tracing macros, the const char* arguments here
// must be pointers to indefinitely lived strings (e.g. hard-coded string
// literals are okay, but not strings created by c_str())
AutoOpenCloseEvent(Type type, const char* event_name)
: event_name_(event_name), weak_factory_(this) {
base::trace_event::TraceLog::GetInstance()->AddAsyncEnabledStateObserver(
weak_factory_.GetWeakPtr());
}
~AutoOpenCloseEvent() override {
DCHECK(thread_checker_.CalledOnValidThread());
base::trace_event::TraceLog::GetInstance()->RemoveAsyncEnabledStateObserver(
this);
}
void Begin() {
DCHECK(thread_checker_.CalledOnValidThread());
start_time_ = TRACE_TIME_TICKS_NOW();
TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
category, event_name_, static_cast<void*>(this), start_time_);
}
void End() {
DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT_ASYNC_END0(category, event_name_, static_cast<void*>(this));
start_time_ = base::TimeTicks();
}
// AsyncEnabledStateObserver implementation
void OnTraceLogEnabled() override {
DCHECK(thread_checker_.CalledOnValidThread());
if (!start_time_.is_null()) {
TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
category, event_name_, static_cast<void*>(this), start_time_);
}
}
void OnTraceLogDisabled() override {}
private:
const char* const event_name_;
base::TimeTicks start_time_;
base::ThreadChecker thread_checker_;
WeakPtrFactory<AutoOpenCloseEvent> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AutoOpenCloseEvent);
};
} // namespace trace_event
} // namespace base
#endif // BASE_TRACE_EVENT_AUTO_OPEN_CLOSE_EVENT_H_
| 35.512195 | 80 | 0.748626 |
d285fe312ea0b236974de0234e1d3755300cbd6d | 203 | h | C | ch_4/p4-5/p4-5.h | bg2d/accelerated_cpp | a558d90090ceadeedd83e4726f6e7497219e9626 | [
"MIT"
] | null | null | null | ch_4/p4-5/p4-5.h | bg2d/accelerated_cpp | a558d90090ceadeedd83e4726f6e7497219e9626 | [
"MIT"
] | null | null | null | ch_4/p4-5/p4-5.h | bg2d/accelerated_cpp | a558d90090ceadeedd83e4726f6e7497219e9626 | [
"MIT"
] | null | null | null | #ifndef GUARD_P4_5_h
#define GUARD_P4_5_h
#include <string>
#include <vector>
struct input_word {
std::string word;
int occ;
};
int get_input(std::istream&, std::vector<input_word>&);
#endif
| 13.533333 | 55 | 0.704433 |
302087fe6b36a3c4993317b61b357af8dcddff27 | 1,860 | h | C | components/service/ucloud/live/include/alibabacloud/live/model/DescribeCasterVideoResourcesResult.h | wanguojian/AliOS-Things | 47fce29d4dd39d124f0bfead27998ad7beea8441 | [
"Apache-2.0"
] | 3 | 2020-01-06T08:23:14.000Z | 2022-01-22T04:41:35.000Z | components/service/ucloud/live/include/alibabacloud/live/model/DescribeCasterVideoResourcesResult.h | wanguojian/AliOS-Things | 47fce29d4dd39d124f0bfead27998ad7beea8441 | [
"Apache-2.0"
] | null | null | null | components/service/ucloud/live/include/alibabacloud/live/model/DescribeCasterVideoResourcesResult.h | wanguojian/AliOS-Things | 47fce29d4dd39d124f0bfead27998ad7beea8441 | [
"Apache-2.0"
] | 1 | 2021-06-20T06:43:12.000Z | 2021-06-20T06:43:12.000Z | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_LIVE_MODEL_DESCRIBECASTERVIDEORESOURCESRESULT_H_
#define ALIBABACLOUD_LIVE_MODEL_DESCRIBECASTERVIDEORESOURCESRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/live/LiveExport.h>
namespace AlibabaCloud
{
namespace Live
{
namespace Model
{
class ALIBABACLOUD_LIVE_EXPORT DescribeCasterVideoResourcesResult : public ServiceResult
{
public:
struct VideoResource
{
int endOffset;
int beginOffset;
std::string materialId;
std::string resourceId;
std::string resourceName;
std::string locationId;
int repeatNum;
std::string liveStreamUrl;
int ptsCallbackInterval;
std::string vodUrl;
};
DescribeCasterVideoResourcesResult();
explicit DescribeCasterVideoResourcesResult(const std::string &payload);
~DescribeCasterVideoResourcesResult();
int getTotal()const;
std::vector<VideoResource> getVideoResources()const;
protected:
void parse(const std::string &payload);
private:
int total_;
std::vector<VideoResource> videoResources_;
};
}
}
}
#endif // !ALIBABACLOUD_LIVE_MODEL_DESCRIBECASTERVIDEORESOURCESRESULT_H_ | 28.181818 | 91 | 0.745161 |
b9bf53210c7d883656b7b85210ab0ad01f8c8264 | 309 | h | C | base/noncopyable.h | 761417898/WebServer | 8a519c226d2aec5d9fc6d6ca9d18858678cbae92 | [
"MIT"
] | 1 | 2019-03-18T09:57:21.000Z | 2019-03-18T09:57:21.000Z | base/noncopyable.h | 761417898/WebServer | 8a519c226d2aec5d9fc6d6ca9d18858678cbae92 | [
"MIT"
] | null | null | null | base/noncopyable.h | 761417898/WebServer | 8a519c226d2aec5d9fc6d6ca9d18858678cbae92 | [
"MIT"
] | null | null | null | #ifndef BASE_NONCOPYABLE_H
#define BASE_NONCOPYABLE_H
namespace GaoServer {
class noncopyable {
public:
noncopyable(const noncopyable&) = delete;
void operator=(const noncopyable&) = delete;
protected:
noncopyable() = default;
~noncopyable() = default;
};
}
#endif // BASE_NONCOPYABLE_H
| 15.45 | 48 | 0.721683 |
27fae32e235434e060d061ced5fa5e2f7fa895a8 | 519 | h | C | OneBusAway/ui/bookmarks/OBABookmarksViewController.h | ualch9/onebusaway-iphone | de4c8827c8ab221d24c98e0958220ec5c0947116 | [
"Apache-2.0"
] | 166 | 2015-01-30T03:26:42.000Z | 2022-02-09T20:06:24.000Z | OneBusAway/ui/bookmarks/OBABookmarksViewController.h | ualch9/onebusaway-iphone | de4c8827c8ab221d24c98e0958220ec5c0947116 | [
"Apache-2.0"
] | 720 | 2015-01-01T03:06:30.000Z | 2021-08-06T18:44:14.000Z | OneBusAway/ui/bookmarks/OBABookmarksViewController.h | ualch9/onebusaway-iphone | de4c8827c8ab221d24c98e0958220ec5c0947116 | [
"Apache-2.0"
] | 118 | 2015-01-05T16:03:09.000Z | 2022-03-11T05:04:02.000Z | //
// OBABookmarksViewController.h
// org.onebusaway.iphone
//
// Created by Aaron Brethorst on 3/9/16.
// Copyright © 2016 OneBusAway. All rights reserved.
//
@import OBAKit;
@interface OBABookmarksViewController : OBAStaticTableViewController<OBANavigationTargetAware>
@property(nonatomic,strong) OBAApplication *application;
@property(nonatomic,strong) OBAModelDAO *modelDAO;
@property(nonatomic,strong) PromisedModelService *modelService;
@property(nonatomic,strong) OBALocationManager *locationManager;
@end
| 30.529412 | 94 | 0.805395 |
7df3a08aef587525a99f798db366e4822dc2bdb2 | 874 | h | C | RtLibrary/include/Xuzumi/Platform/Console.h | lymuc-studio/Xuzumi | 6377b07ba991d3c4f7cfa92c25fd35cc8a136f81 | [
"MIT"
] | null | null | null | RtLibrary/include/Xuzumi/Platform/Console.h | lymuc-studio/Xuzumi | 6377b07ba991d3c4f7cfa92c25fd35cc8a136f81 | [
"MIT"
] | null | null | null | RtLibrary/include/Xuzumi/Platform/Console.h | lymuc-studio/Xuzumi | 6377b07ba991d3c4f7cfa92c25fd35cc8a136f81 | [
"MIT"
] | null | null | null | #pragma once
#include "Xuzumi/Core/Types.h"
namespace Xuzumi
{
enum class ConsoleColor
{
White,
Black,
Blue,
Red,
Green,
Yello,
DarkWhite,
DarkBlue,
DarkRed,
DarkGreen,
DarkYello,
};
class Console
{
public:
static bool Allocate();
static void Free();
static bool Valid();
static void NewLine();
static void WriteLine(String fmt, ...);
static void WriteLine(Int32 value);
static void WriteLine(UInt32 value);
static void WriteLine(float value);
static char Read();
static void SetBackgroundColor(ConsoleColor color);
static void SetForegroundColor(ConsoleColor color);
protected:
virtual ~Console() = default;
virtual bool Valid_() const = 0;
virtual void SetBackgroundColor_(ConsoleColor color) = 0;
virtual void SetForegroundColor_(ConsoleColor color) = 0;
private:
static Console* s_instance;
};
}
| 16.490566 | 59 | 0.708238 |
fe6d79eee104cf75f165b14b0595ee1ece2acc4e | 61 | c | C | 3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/SourceWrappers/umfpack_dl_get_determinant.o.c | luoyongheng/dtslam | d3c2230d45db14c811eff6fd43e119ac39af1352 | [
"BSD-3-Clause"
] | 370 | 2015-01-30T01:04:37.000Z | 2022-03-26T18:48:39.000Z | 3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/SourceWrappers/umfpack_dl_get_determinant.o.c | luoyongheng/dtslam | d3c2230d45db14c811eff6fd43e119ac39af1352 | [
"BSD-3-Clause"
] | 85 | 2015-02-03T22:57:35.000Z | 2021-12-17T12:39:55.000Z | 3rdparty/suitesparse-metis-for-windows-1.2.1/SuiteSparse/UMFPACK/SourceWrappers/umfpack_dl_get_determinant.o.c | luoyongheng/dtslam | d3c2230d45db14c811eff6fd43e119ac39af1352 | [
"BSD-3-Clause"
] | 234 | 2015-01-14T15:09:09.000Z | 2022-03-26T18:48:41.000Z | #define DLONG
#include <../Source/umfpack_get_determinant.c>
| 20.333333 | 46 | 0.786885 |
7d73a7d466caed3d6d0c4f6c1a204a4ef5a31395 | 196 | c | C | C_Prac/Modoo/func/func_5.c | googoles/C_algorithms | 649b46d004913d3baeb92d4a3003944f3fd5bc7b | [
"MIT"
] | null | null | null | C_Prac/Modoo/func/func_5.c | googoles/C_algorithms | 649b46d004913d3baeb92d4a3003944f3fd5bc7b | [
"MIT"
] | null | null | null | C_Prac/Modoo/func/func_5.c | googoles/C_algorithms | 649b46d004913d3baeb92d4a3003944f3fd5bc7b | [
"MIT"
] | null | null | null | #include <stdio.h>
int factorize(int n)
{
int i;
for(i = 2; i <= n; i++)
{
if (n % i == 0) {
n /= i;
printf("%d X ", i);
i = 1;
}
}
}
int main(){
} | 8.909091 | 27 | 0.336735 |
04634159ab83bba5aaa2a5749897d19ce6eb11f9 | 806 | c | C | Exercises/Listas de Nivelamento/Lista04/aeroporto.c | whoiswelliton/Algorithms_and_Data_Structures | 8aded4a427c68f6c89135fd8c0094dc361bd1538 | [
"MIT"
] | null | null | null | Exercises/Listas de Nivelamento/Lista04/aeroporto.c | whoiswelliton/Algorithms_and_Data_Structures | 8aded4a427c68f6c89135fd8c0094dc361bd1538 | [
"MIT"
] | null | null | null | Exercises/Listas de Nivelamento/Lista04/aeroporto.c | whoiswelliton/Algorithms_and_Data_Structures | 8aded4a427c68f6c89135fd8c0094dc361bd1538 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
int main(){
int a; //numero de aeroportos
int v; //numero de voos
int i;
int x,y;
int teste=1;
while (scanf (" %d %d", &a, &v) && a!=0 && v!=0){
/*vet contém a frequência de aeroportos, assim, o aeroporto
"i" tem uma frequência de vet[i]*/
int vet[a+1];
memset(vet, 0, sizeof(int)*(a+1));
for (i=0; i<v; i++){
scanf (" %d %d", &x, &y);
vet[x]++; vet[y]++;
}
/*procura o aeroporto com mais tráfego*/
int maiorfrequencia = 1;
for (i=2; i< a+1; i++){
if (vet[i] > vet[maiorfrequencia])
maiorfrequencia = i;
}
/*imprime a lista de aeroportos com maior frequencia*/
printf ("Teste %d\n", teste++);
for (i=1; i<a+1; i++)
if (vet[i] == vet[maiorfrequencia])
printf ("%d ", i);
printf ("\n\n");
}
return 0;
} | 19.190476 | 61 | 0.555831 |
a8df1abee2adff9dfcb9b30a4ac044220dfc26f3 | 830 | h | C | ESwap/arithmetic_execution.h | kzoacn/ESwap | 120ef93ff823ec91760e35dd3f37bc4ed931c73e | [
"MIT"
] | null | null | null | ESwap/arithmetic_execution.h | kzoacn/ESwap | 120ef93ff823ec91760e35dd3f37bc4ed931c73e | [
"MIT"
] | null | null | null | ESwap/arithmetic_execution.h | kzoacn/ESwap | 120ef93ff823ec91760e35dd3f37bc4ed931c73e | [
"MIT"
] | null | null | null | #ifndef ARITHMETIC_EXECUTION_H__
#define ARITHMETIC_EXECUTION_H__
#include "emp-tool/emp-tool.h"
namespace emp {
class Number;
class ArithmeticExecution: virtual public CircuitExecution {
public:
static __thread ArithmeticExecution * ari_exec;
static block _;
virtual void add_gate(Number &c,const Number &a,const Number &b)=0;
virtual void sub_gate(Number &c,const Number &a,const Number &b)=0;
virtual void sel_gate(Number &z,const Bit &b,const Number &x,const Number &y)=0;
virtual void sels_gate(int length,Number *c,const Bit *bits,const Number *a,const Number *b)=0;
virtual Number b2a_gate(const Integer &x)=0;
virtual Integer a2b_gate(int length,const Number &val)=0;
virtual bool eq(const Number &a,const Number &b)=0;
virtual bool is_true(const Bit &bit)=0;
virtual ~ArithmeticExecution (){ }
};
}
#endif | 37.727273 | 96 | 0.761446 |
a8e608291379eb0e5ec2e278a375e5e1db75e197 | 573 | h | C | BugCoverageSwiftInit/BugCoverageSwiftInit.h | paulz/XcodeBugInTestCoverageForSwiftInit | ce5c4a49be9bf3ac82a018c9ecff3f312ea226b9 | [
"MIT"
] | 1 | 2019-01-12T08:04:17.000Z | 2019-01-12T08:04:17.000Z | BugCoverageSwiftInit/BugCoverageSwiftInit.h | paulz/XcodeBugInTestCoverageForSwiftInit | ce5c4a49be9bf3ac82a018c9ecff3f312ea226b9 | [
"MIT"
] | null | null | null | BugCoverageSwiftInit/BugCoverageSwiftInit.h | paulz/XcodeBugInTestCoverageForSwiftInit | ce5c4a49be9bf3ac82a018c9ecff3f312ea226b9 | [
"MIT"
] | null | null | null | //
// BugCoverageSwiftInit.h
// BugCoverageSwiftInit
//
// Created by Paul Zabelin on 6/1/18.
// Copyright © 2018 Paul Zabelin. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for BugCoverageSwiftInit.
FOUNDATION_EXPORT double BugCoverageSwiftInitVersionNumber;
//! Project version string for BugCoverageSwiftInit.
FOUNDATION_EXPORT const unsigned char BugCoverageSwiftInitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <BugCoverageSwiftInit/PublicHeader.h>
| 28.65 | 145 | 0.790576 |
2898cb52e33177f9df2e969a70ad30fc4badaafd | 1,488 | h | C | include/flamegpu/pop/AgentStateMemory.h | Robadob/FLAMEGPU2_dev | 3e4106078f754ee90957519fa196a863fd257d1c | [
"MIT"
] | null | null | null | include/flamegpu/pop/AgentStateMemory.h | Robadob/FLAMEGPU2_dev | 3e4106078f754ee90957519fa196a863fd257d1c | [
"MIT"
] | null | null | null | include/flamegpu/pop/AgentStateMemory.h | Robadob/FLAMEGPU2_dev | 3e4106078f754ee90957519fa196a863fd257d1c | [
"MIT"
] | null | null | null | /**
* @file AgentStateMemory.h
* @authors Paul
* @date 5 Mar 2014
* @brief
*
* @see
* @warning
*/
#ifndef INCLUDE_FLAMEGPU_POP_AGENTSTATEMEMORY_H_
#define INCLUDE_FLAMEGPU_POP_AGENTSTATEMEMORY_H_
#include <string>
#include <vector>
#include <map>
#include <typeinfo>
// include generic memory vectors
#include "flamegpu/pop/MemoryVector.h"
class AgentPopulation;
class AgentDescription;
class AgentStateMemory { // agent_list
public:
explicit AgentStateMemory(const AgentPopulation &population, unsigned int initial_capacity = 0);
virtual ~AgentStateMemory() {}
unsigned int incrementSize();
GenericMemoryVector& getMemoryVector(const std::string variable_name);
const GenericMemoryVector& getReadOnlyMemoryVector(const std::string variable_name) const;
const std::type_info& getVariableType(std::string variable_name); // const
bool isSameDescription(const AgentDescription& description) const;
void resizeMemoryVectors(unsigned int size);
// the maximum number of possible agents in this population (same for all state lists)
unsigned int getPopulationCapacity() const;
// the actual number of agents in this state
unsigned int getStateListSize() const;
void overrideStateListSize(unsigned int size);
protected:
const AgentPopulation &population;
const std::string agent_state;
StateMemoryMap state_memory;
unsigned int current_size;
};
#endif // INCLUDE_FLAMEGPU_POP_AGENTSTATEMEMORY_H_
| 25.655172 | 100 | 0.760081 |
7acefa971450d93532366916c523dcdba8fafec7 | 91,322 | c | C | wireshark-2.0.13/epan/dissectors/packet-quic.c | mahrukhfida/mi | 7187765aa225e71983969ef5285771ac77c8309a | [
"Apache-2.0"
] | null | null | null | wireshark-2.0.13/epan/dissectors/packet-quic.c | mahrukhfida/mi | 7187765aa225e71983969ef5285771ac77c8309a | [
"Apache-2.0"
] | null | null | null | wireshark-2.0.13/epan/dissectors/packet-quic.c | mahrukhfida/mi | 7187765aa225e71983969ef5285771ac77c8309a | [
"Apache-2.0"
] | null | null | null | /* packet-quic.c
* Routines for Quick UDP Internet Connections dissection
* Copyright 2013, Alexis La Goutte <alexis.lagoutte at gmail dot com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* 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.
*/
/*
QUIC Wire Layout Specification : https://docs.google.com/document/d/1WJvyZflAO2pq77yOLbp9NsGjC1CHetAXV8I0fQe-B_U/
QUIC Crypto : https://docs.google.com/document/d/1g5nIXAIkN_Y-7XJW5K45IblHd_L2f5LTaDUDwvZ5L6g/
QUIC source code in Chromium : https://code.google.com/p/chromium/codesearch#chromium/src/net/quic/quic_utils.h&sq=package:chromium
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
void proto_register_quic(void);
void proto_reg_handoff_quic(void);
static int proto_quic = -1;
static int hf_quic_puflags = -1;
static int hf_quic_puflags_vrsn = -1;
static int hf_quic_puflags_rst = -1;
static int hf_quic_puflags_cid = -1;
static int hf_quic_puflags_seq = -1;
static int hf_quic_puflags_rsv = -1;
static int hf_quic_cid = -1;
static int hf_quic_version = -1;
static int hf_quic_sequence = -1;
static int hf_quic_prflags = -1;
static int hf_quic_prflags_entropy = -1;
static int hf_quic_prflags_fecg = -1;
static int hf_quic_prflags_fec = -1;
static int hf_quic_prflags_rsv = -1;
static int hf_quic_message_authentication_hash = -1;
static int hf_quic_frame = -1;
static int hf_quic_frame_type = -1;
static int hf_quic_frame_type_padding_length = -1;
static int hf_quic_frame_type_padding = -1;
static int hf_quic_frame_type_rsts_stream_id = -1;
static int hf_quic_frame_type_rsts_byte_offset = -1;
static int hf_quic_frame_type_rsts_error_code = -1;
static int hf_quic_frame_type_cc_error_code = -1;
static int hf_quic_frame_type_cc_reason_phrase_length = -1;
static int hf_quic_frame_type_cc_reason_phrase = -1;
static int hf_quic_frame_type_goaway_error_code = -1;
static int hf_quic_frame_type_goaway_last_good_stream_id = -1;
static int hf_quic_frame_type_goaway_reason_phrase_length = -1;
static int hf_quic_frame_type_goaway_reason_phrase = -1;
static int hf_quic_frame_type_wu_stream_id = -1;
static int hf_quic_frame_type_wu_byte_offset = -1;
static int hf_quic_frame_type_blocked_stream_id = -1;
static int hf_quic_frame_type_sw_send_entropy = -1;
static int hf_quic_frame_type_sw_least_unacked_delta = -1;
static int hf_quic_frame_type_stream = -1;
static int hf_quic_frame_type_stream_f = -1;
static int hf_quic_frame_type_stream_d = -1;
static int hf_quic_frame_type_stream_ooo = -1;
static int hf_quic_frame_type_stream_ss = -1;
static int hf_quic_frame_type_ack = -1;
static int hf_quic_frame_type_ack_n = -1;
static int hf_quic_frame_type_ack_t = -1;
static int hf_quic_frame_type_ack_ll = -1;
static int hf_quic_frame_type_ack_mm = -1;
static int hf_quic_frame_type_ack_received_entropy = -1;
static int hf_quic_frame_type_ack_largest_observed = -1;
static int hf_quic_frame_type_ack_largest_observed_delta_time = -1;
static int hf_quic_frame_type_ack_num_timestamp = -1;
static int hf_quic_frame_type_ack_delta_largest_observed = -1;
static int hf_quic_frame_type_ack_time_since_largest_observed = -1;
static int hf_quic_frame_type_ack_time_since_previous_timestamp = -1;
static int hf_quic_frame_type_ack_num_ranges = -1;
static int hf_quic_frame_type_ack_missing_packet = -1;
static int hf_quic_frame_type_ack_range_length = -1;
static int hf_quic_frame_type_ack_num_revived = -1;
static int hf_quic_frame_type_ack_revived_packet = -1;
static int hf_quic_stream_id = -1;
static int hf_quic_offset_len = -1;
static int hf_quic_data_len = -1;
static int hf_quic_tag = -1;
static int hf_quic_tags = -1;
static int hf_quic_tag_number = -1;
static int hf_quic_tag_value = -1;
static int hf_quic_tag_type = -1;
static int hf_quic_tag_offset_end = -1;
static int hf_quic_tag_length = -1;
static int hf_quic_tag_sni = -1;
static int hf_quic_tag_pad = -1;
static int hf_quic_tag_ver = -1;
static int hf_quic_tag_ccs = -1;
static int hf_quic_tag_pdmd = -1;
static int hf_quic_tag_uaid = -1;
static int hf_quic_tag_stk = -1;
static int hf_quic_tag_sno = -1;
static int hf_quic_tag_prof = -1;
static int hf_quic_tag_scfg = -1;
static int hf_quic_tag_scfg_number = -1;
static int hf_quic_tag_rrej = -1;
static int hf_quic_tag_crt = -1;
static int hf_quic_tag_aead = -1;
static int hf_quic_tag_scid = -1;
static int hf_quic_tag_pubs = -1;
static int hf_quic_tag_kexs = -1;
static int hf_quic_tag_obit = -1;
static int hf_quic_tag_expy = -1;
static int hf_quic_tag_nonc = -1;
static int hf_quic_tag_mspc = -1;
static int hf_quic_tag_tcid = -1;
static int hf_quic_tag_srbf = -1;
static int hf_quic_tag_icsl = -1;
static int hf_quic_tag_scls = -1;
static int hf_quic_tag_copt = -1;
static int hf_quic_tag_ccrt = -1;
static int hf_quic_tag_irtt = -1;
static int hf_quic_tag_cfcw = -1;
static int hf_quic_tag_sfcw = -1;
static int hf_quic_tag_cetv = -1;
static int hf_quic_tag_unknown = -1;
static int hf_quic_padding = -1;
static int hf_quic_payload = -1;
static guint g_quic_port = 80;
static guint g_quics_port = 443;
static gint ett_quic = -1;
static gint ett_quic_puflags = -1;
static gint ett_quic_prflags = -1;
static gint ett_quic_ft = -1;
static gint ett_quic_ftflags = -1;
static gint ett_quic_tag_value = -1;
static expert_field ei_quic_tag_undecoded = EI_INIT;
static expert_field ei_quic_tag_length = EI_INIT;
static expert_field ei_quic_tag_unknown = EI_INIT;
#define QUIC_MIN_LENGTH 3
/**************************************************************************/
/* Public Flags */
/**************************************************************************/
#define PUFLAGS_VRSN 0x01
#define PUFLAGS_RST 0x02
#define PUFLAGS_CID 0x0C
#define PUFLAGS_SEQ 0x30
#define PUFLAGS_RSV 0xC0
static const value_string puflags_cid_vals[] = {
{ 0, "0 Byte" },
{ 1, "1 Bytes" },
{ 2, "4 Bytes" },
{ 3, "8 Bytes" },
{ 0, NULL }
};
static const value_string puflags_seq_vals[] = {
{ 0, "1 Byte" },
{ 1, "2 Bytes" },
{ 2, "4 Bytes" },
{ 3, "6 Bytes" },
{ 0, NULL }
};
/**************************************************************************/
/* Private Flags */
/**************************************************************************/
#define PRFLAGS_ENTROPY 0x01
#define PRFLAGS_FECG 0x02
#define PRFLAGS_FEC 0x04
#define PRFLAGS_RSV 0xF8
/**************************************************************************/
/* Frame Type Regular */
/**************************************************************************/
#define FT_PADDING 0x00
#define FT_RST_STREAM 0x01
#define FT_CONNECTION_CLOSE 0x02
#define FT_GOAWAY 0x03
#define FT_WINDOW_UPDATE 0x04
#define FT_BLOCKED 0x05
#define FT_STOP_WAITING 0x06
#define FT_PING 0x07
/**************************************************************************/
/* Frame Type Special */
/**************************************************************************/
#define FTFLAGS_SPECIAL 0xE0
#define FTFLAGS_STREAM 0x80
#define FTFLAGS_STREAM_F 0x40
#define FTFLAGS_STREAM_D 0x20
#define FTFLAGS_STREAM_OOO 0x1C
#define FTFLAGS_STREAM_SS 0x03
#define FTFLAGS_ACK 0x40
#define FTFLAGS_ACK_N 0x20
#define FTFLAGS_ACK_T 0x10
#define FTFLAGS_ACK_LL 0x0C
#define FTFLAGS_ACK_MM 0x03
static const range_string frame_type_vals[] = {
{ 0,0, "PADDING" },
{ 1,1, "RST_STREAM" },
{ 2,2, "CONNECTION_CLOSE" },
{ 3,3, "GOAWAY" },
{ 4,4, "WINDOW_UPDATE" },
{ 5,5, "BLOCKED" },
{ 6,6, "STOP_WAITING" },
{ 7,7, "PING" },
{ 8,31, "Unknown" },
{ 32,63, "CONGESTION_FEEDBACK (Special Frame Type)" },
{ 64,127, "ACK (Special Frame Type)" },
{ 128,256, "STREAM (Special Frame Type)" },
{ 0,0, NULL }
};
static const value_string len_offset_vals[] = {
{ 0, "0 Byte" },
{ 1, "2 Bytes" },
{ 2, "3 Bytes" },
{ 3, "4 Bytes" },
{ 4, "5 Bytes" },
{ 5, "6 Bytes" },
{ 6, "7 Bytes" },
{ 7, "8 Bytes" },
{ 0, NULL }
};
static const value_string len_stream_vals[] = {
{ 0, "1 Byte" },
{ 1, "2 Bytes" },
{ 2, "3 Bytes" },
{ 3, "4 Bytes" },
{ 0, NULL }
};
static const true_false_string len_data_vals = {
"2 Bytes",
"0 Byte"
};
static const value_string len_largest_observed_vals[] = {
{ 0, "1 Byte" },
{ 1, "2 Bytes" },
{ 2, "4 Bytes" },
{ 3, "6 Bytes" },
{ 0, NULL }
};
static const value_string len_missing_packet_vals[] = {
{ 0, "1 Byte" },
{ 1, "2 Bytes" },
{ 2, "4 Bytes" },
{ 3, "6 Bytes" },
{ 0, NULL }
};
/**************************************************************************/
/* Message tag */
/**************************************************************************/
#define MTAG_CHLO 0x43484C4F
#define MTAG_SHLO 0x53484C4F
#define MTAG_REJ 0X52454A00
static const value_string message_tag_vals[] = {
{ MTAG_CHLO, "Client Hello" },
{ MTAG_SHLO, "Server Hello" },
{ MTAG_REJ, "Rejection" },
{ 0, NULL }
};
/**************************************************************************/
/* Tag */
/**************************************************************************/
/* See https://chromium.googlesource.com/chromium/src.git/+/master/net/quic/crypto/crypto_protocol.h */
#define TAG_PAD 0x50414400
#define TAG_SNI 0x534E4900
#define TAG_VER 0x56455200
#define TAG_CCS 0x43435300
#define TAG_UAID 0x55414944
#define TAG_PDMD 0x50444d44
#define TAG_STK 0x53544b00
#define TAG_SNO 0x534E4F00
#define TAG_PROF 0x50524F46
#define TAG_SCFG 0x53434647
#define TAG_RREJ 0x5252454A
#define TAG_CRT 0x435254FF
#define TAG_AEAD 0x41454144
#define TAG_SCID 0x53434944
#define TAG_PUBS 0x50554253
#define TAG_KEXS 0x4B455853
#define TAG_OBIT 0x4F424954
#define TAG_EXPY 0x45585059
#define TAG_NONC 0x4E4F4E43
#define TAG_MSPC 0x4D535043
#define TAG_TCID 0x54434944
#define TAG_SRBF 0x53524246
#define TAG_ICSL 0x4943534C
#define TAG_SCLS 0x53434C53
#define TAG_COPT 0x434F5054
#define TAG_CCRT 0x43435254
#define TAG_IRTT 0x49525454
#define TAG_CFCW 0x43464357
#define TAG_SFCW 0x53464357
#define TAG_CETV 0x43455456
static const value_string tag_vals[] = {
{ TAG_PAD, "Padding" },
{ TAG_SNI, "Server Name Indication" },
{ TAG_VER, "Version" },
{ TAG_CCS, "Common Certificate Sets" },
{ TAG_UAID, "Client's User Agent ID" },
{ TAG_PDMD, "Proof Demand" },
{ TAG_STK, "Source Address Token" },
{ TAG_SNO, "Server nonce" },
{ TAG_PROF, "Proof (Signature)" },
{ TAG_SCFG, "Server Config" },
{ TAG_RREJ, "Reasons for server sending" },
{ TAG_CRT, "Certificate chain" },
{ TAG_AEAD, "Authenticated encryption algorithms" },
{ TAG_SCID, "Server config ID" },
{ TAG_PUBS, "Public value" },
{ TAG_KEXS, "Key exchange algorithms" },
{ TAG_OBIT, "Server Orbit" },
{ TAG_EXPY, "Expiry" },
{ TAG_NONC, "Client Nonce" },
{ TAG_MSPC, "Max streams per connection" },
{ TAG_TCID, "Connection ID truncation" },
{ TAG_SRBF, "Socket receive buffer" },
{ TAG_ICSL, "Idle connection state" },
{ TAG_SCLS, "Silently close on timeout" },
{ TAG_COPT, "Connection options" },
{ TAG_CCRT, "Cached certificates" },
{ TAG_IRTT, "Estimated initial RTT" },
{ TAG_CFCW, "Initial session/connection" },
{ TAG_SFCW, "Initial stream flow control" },
{ TAG_CETV, "Client encrypted tag-value" },
{ 0, NULL }
};
/**************************************************************************/
/* AEAD Tag */
/**************************************************************************/
#define AEAD_AESG 0x41455347
#define AEAD_S20P 0x53323050
#define AEAD_CC12 0x43433132
static const value_string tag_aead_vals[] = {
{ AEAD_AESG, "AES-GCM with a 12-byte tag and IV" },
{ AEAD_S20P, "Salsa20 with Poly1305" },
{ AEAD_CC12, "Salsa20 with Poly1305" },
{ 0, NULL }
};
/**************************************************************************/
/* KEXS Tag */
/**************************************************************************/
#define KEXS_C255 0x43323535
#define KEXS_P256 0x50323536
static const value_string tag_kexs_vals[] = {
{ KEXS_C255, "Curve25519" },
{ KEXS_P256, "P-256" },
{ 0, NULL }
};
/**************************************************************************/
/* Error Code */
/* See src/net/quic/quic_protocol.h from Chromium Source */
/**************************************************************************/
enum QuicErrorCode {
QUIC_NO_ERROR = 0,
/* Connection has reached an invalid state. */
QUIC_INTERNAL_ERROR = 1,
/* There were data frames after the a fin or reset. */
QUIC_STREAM_DATA_AFTER_TERMINATION = 2,
/* Control frame is malformed. */
QUIC_INVALID_PACKET_HEADER = 3,
/* Frame data is malformed. */
QUIC_INVALID_FRAME_DATA = 4,
/* The packet contained no payload. */
QUIC_MISSING_PAYLOAD = 48,
/* FEC data is malformed. */
QUIC_INVALID_FEC_DATA = 5,
/* STREAM frame data is malformed. */
QUIC_INVALID_STREAM_DATA = 46,
/* STREAM frame data is not encrypted. */
QUIC_UNENCRYPTED_STREAM_DATA = 61,
/* RST_STREAM frame data is malformed. */
QUIC_INVALID_RST_STREAM_DATA = 6,
/* CONNECTION_CLOSE frame data is malformed. */
QUIC_INVALID_CONNECTION_CLOSE_DATA = 7,
/* GOAWAY frame data is malformed. */
QUIC_INVALID_GOAWAY_DATA = 8,
/* WINDOW_UPDATE frame data is malformed. */
QUIC_INVALID_WINDOW_UPDATE_DATA = 57,
/* BLOCKED frame data is malformed. */
QUIC_INVALID_BLOCKED_DATA = 58,
/* STOP_WAITING frame data is malformed. */
QUIC_INVALID_STOP_WAITING_DATA = 60,
/* ACK frame data is malformed. */
QUIC_INVALID_ACK_DATA = 9,
/* deprecated: */
QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47,
/* Version negotiation packet is malformed. */
QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10,
/* Public RST packet is malformed. */
QUIC_INVALID_PUBLIC_RST_PACKET = 11,
/* There was an error decrypting. */
QUIC_DECRYPTION_FAILURE = 12,
/* There was an error encrypting. */
QUIC_ENCRYPTION_FAILURE = 13,
/* The packet exceeded kMaxPacketSize. */
QUIC_PACKET_TOO_LARGE = 14,
/* Data was sent for a stream which did not exist. */
QUIC_PACKET_FOR_NONEXISTENT_STREAM = 15,
/* The peer is going away. May be a client or server. */
QUIC_PEER_GOING_AWAY = 16,
/* A stream ID was invalid. */
QUIC_INVALID_STREAM_ID = 17,
/* A priority was invalid. */
QUIC_INVALID_PRIORITY = 49,
/* Too many streams already open. */
QUIC_TOO_MANY_OPEN_STREAMS = 18,
/* The peer must send a FIN/RST for each stream, and has not been doing so. */
QUIC_TOO_MANY_UNFINISHED_STREAMS = 66,
/* Received public reset for this connection. */
QUIC_PUBLIC_RESET = 19,
/* Invalid protocol version. */
QUIC_INVALID_VERSION = 20,
/* deprecated: */
QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED = 21,
/* The Header ID for a stream was too far from the previous. */
QUIC_INVALID_HEADER_ID = 22,
/* Negotiable parameter received during handshake had invalid value. */
QUIC_INVALID_NEGOTIATED_VALUE = 23,
/* There was an error decompressing data. */
QUIC_DECOMPRESSION_FAILURE = 24,
/* We hit our prenegotiated (or default) timeout */
QUIC_CONNECTION_TIMED_OUT = 25,
/* We hit our overall connection timeout */
QUIC_CONNECTION_OVERALL_TIMED_OUT = 67,
/* There was an error encountered migrating addresses */
QUIC_ERROR_MIGRATING_ADDRESS = 26,
/* There was an error while writing to the socket. */
QUIC_PACKET_WRITE_ERROR = 27,
/* There was an error while reading from the socket. */
QUIC_PACKET_READ_ERROR = 51,
/* We received a STREAM_FRAME with no data and no fin flag set. */
QUIC_INVALID_STREAM_FRAME = 50,
/* We received invalid data on the headers stream. */
QUIC_INVALID_HEADERS_STREAM_DATA = 56,
/* The peer received too much data, violating flow control. */
QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA = 59,
/* The peer sent too much data, violating flow control. */
QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63,
/* The peer received an invalid flow control window. */
QUIC_FLOW_CONTROL_INVALID_WINDOW = 64,
/* The connection has been IP pooled into an existing connection. */
QUIC_CONNECTION_IP_POOLED = 62,
/* The connection has too many outstanding sent packets. */
QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS = 68,
/* The connection has too many outstanding received packets. */
QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS = 69,
/* The quic connection job to load server config is cancelled. */
QUIC_CONNECTION_CANCELLED = 70,
/* Disabled QUIC because of high packet loss rate. */
QUIC_BAD_PACKET_LOSS_RATE = 71,
/* Disabled QUIC because of too many PUBLIC_RESETs post handshake. */
QUIC_PUBLIC_RESETS_POST_HANDSHAKE = 73,
/* Disabled QUIC because of too many timeouts with streams open. */
QUIC_TIMEOUTS_WITH_OPEN_STREAMS = 74,
/* Closed because we failed to serialize a packet. */
QUIC_FAILED_TO_SERIALIZE_PACKET = 75,
/* Crypto errors. */
/* Hanshake failed. */
QUIC_HANDSHAKE_FAILED = 28,
/* Handshake message contained out of order tags. */
QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29,
/* Handshake message contained too many entries. */
QUIC_CRYPTO_TOO_MANY_ENTRIES = 30,
/* Handshake message contained an invalid value length. */
QUIC_CRYPTO_INVALID_VALUE_LENGTH = 31,
/* A crypto message was received after the handshake was complete. */
QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE = 32,
/* A crypto message was received with an illegal message tag. */
QUIC_INVALID_CRYPTO_MESSAGE_TYPE = 33,
/* A crypto message was received with an illegal parameter. */
QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER = 34,
/* An invalid channel id signature was supplied. */
QUIC_INVALID_CHANNEL_ID_SIGNATURE = 52,
/* A crypto message was received with a mandatory parameter missing. */
QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND = 35,
/* A crypto message was received with a parameter that has no overlap
with the local parameter. */
QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP = 36,
/* A crypto message was received that contained a parameter with too few
values. */
QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND = 37,
/* An internal error occured in crypto processing. */
QUIC_CRYPTO_INTERNAL_ERROR = 38,
/* A crypto handshake message specified an unsupported version. */
QUIC_CRYPTO_VERSION_NOT_SUPPORTED = 39,
/* A crypto handshake message resulted in a stateless reject. */
QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT = 72,
/* There was no intersection between the crypto primitives supported by the
peer and ourselves. */
QUIC_CRYPTO_NO_SUPPORT = 40,
/* The server rejected our client hello messages too many times. */
QUIC_CRYPTO_TOO_MANY_REJECTS = 41,
/* The client rejected the server's certificate chain or signature. */
QUIC_PROOF_INVALID = 42,
/* A crypto message was received with a duplicate tag. */
QUIC_CRYPTO_DUPLICATE_TAG = 43,
/* A crypto message was received with the wrong encryption level (i.e. it
should have been encrypted but was not. ) */
QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT = 44,
/* The server config for a server has expired. */
QUIC_CRYPTO_SERVER_CONFIG_EXPIRED = 45,
/* We failed to setup the symmetric keys for a connection. */
QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53,
/* A handshake message arrived, but we are still validating the
previous handshake message. */
QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54,
/* A server config update arrived before the handshake is complete. */
QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65,
/* This connection involved a version negotiation which appears to have been
tampered with. */
QUIC_VERSION_NEGOTIATION_MISMATCH = 55,
/* No error. Used as bound while iterating. */
QUIC_LAST_ERROR = 76
};
static const value_string error_code_vals[] = {
{ QUIC_NO_ERROR, "There was no error" },
{ QUIC_INTERNAL_ERROR, "Connection has reached an invalid state" },
{ QUIC_STREAM_DATA_AFTER_TERMINATION, "There were data frames after the a fin or reset" },
{ QUIC_INVALID_PACKET_HEADER, "Control frame is malformed" },
{ QUIC_INVALID_FRAME_DATA, "Frame data is malformed" },
{ QUIC_INVALID_FEC_DATA, "FEC data is malformed" },
{ QUIC_INVALID_RST_STREAM_DATA, "RST_STREAM frame data is malformed" },
{ QUIC_INVALID_CONNECTION_CLOSE_DATA, "CONNECTION_CLOSE frame data is malformed" },
{ QUIC_INVALID_GOAWAY_DATA, "GOAWAY frame data is malformed" },
{ QUIC_INVALID_ACK_DATA, "ACK frame data is malformed" },
{ QUIC_INVALID_VERSION_NEGOTIATION_PACKET, "Version negotiation packet is malformed" },
{ QUIC_INVALID_PUBLIC_RST_PACKET, "Public RST packet is malformed" },
{ QUIC_DECRYPTION_FAILURE, "There was an error decrypting" },
{ QUIC_ENCRYPTION_FAILURE, "There was an error encrypting" },
{ QUIC_PACKET_TOO_LARGE, "The packet exceeded kMaxPacketSize" },
{ QUIC_PACKET_FOR_NONEXISTENT_STREAM, "Data was sent for a stream which did not exist" },
{ QUIC_PEER_GOING_AWAY, "The peer is going away. May be a client or server" },
{ QUIC_INVALID_STREAM_ID, "A stream ID was invalid" },
{ QUIC_TOO_MANY_OPEN_STREAMS, "Too many streams already open" },
{ QUIC_PUBLIC_RESET, "Received public reset for this connection" },
{ QUIC_INVALID_VERSION, "Invalid protocol version" },
{ QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED, "Stream RST before Headers decompressed (Deprecated)" },
{ QUIC_INVALID_HEADER_ID, "The Header ID for a stream was too far from the previous" },
{ QUIC_INVALID_NEGOTIATED_VALUE, "Negotiable parameter received during handshake had invalid value" },
{ QUIC_DECOMPRESSION_FAILURE, "There was an error decompressing data" },
{ QUIC_CONNECTION_TIMED_OUT, "We hit our prenegotiated (or default) timeout" },
{ QUIC_ERROR_MIGRATING_ADDRESS, "There was an error encountered migrating addresses" },
{ QUIC_PACKET_WRITE_ERROR, "There was an error while writing to the socket" },
{ QUIC_HANDSHAKE_FAILED, "Hanshake failed" },
{ QUIC_CRYPTO_TAGS_OUT_OF_ORDER, "Handshake message contained out of order tags" },
{ QUIC_CRYPTO_TOO_MANY_ENTRIES, "Handshake message contained too many entries" },
{ QUIC_CRYPTO_INVALID_VALUE_LENGTH, "Handshake message contained an invalid value length" },
{ QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, "A crypto message was received after the handshake was complete" },
{ QUIC_INVALID_CRYPTO_MESSAGE_TYPE, "A crypto message was received with an illegal message tag" },
{ QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, "A crypto message was received with an illegal parameter" },
{ QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, "A crypto message was received with a mandatory parameter missing" },
{ QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, "A crypto message was received with a parameter that has no overlap with the local parameter" },
{ QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND, "A crypto message was received that contained a parameter with too few values" },
{ QUIC_CRYPTO_INTERNAL_ERROR, "An internal error occured in crypto processing" },
{ QUIC_CRYPTO_VERSION_NOT_SUPPORTED, "A crypto handshake message specified an unsupported version" },
{ QUIC_CRYPTO_NO_SUPPORT, "There was no intersection between the crypto primitives supported by the peer and ourselves" },
{ QUIC_CRYPTO_TOO_MANY_REJECTS, "The server rejected our client hello messages too many times" },
{ QUIC_PROOF_INVALID, "The client rejected the server's certificate chain or signature" },
{ QUIC_CRYPTO_DUPLICATE_TAG, "A crypto message was received with a duplicate tag" },
{ QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, "A crypto message was received with the wrong encryption level (i.e. it should have been encrypted but was not" },
{ QUIC_CRYPTO_SERVER_CONFIG_EXPIRED, "The server config for a server has expired" },
{ QUIC_INVALID_STREAM_DATA, "STREAM frame data is malformed" },
{ QUIC_INVALID_CONGESTION_FEEDBACK_DATA, "Invalid congestion Feedback data (Deprecated)" },
{ QUIC_MISSING_PAYLOAD, "The packet contained no payload" },
{ QUIC_INVALID_PRIORITY, "A priority was invalid" },
{ QUIC_INVALID_STREAM_FRAME, "We received a STREAM_FRAME with no data and no fin flag set" },
{ QUIC_PACKET_READ_ERROR, "There was an error while reading from the socket" },
{ QUIC_INVALID_CHANNEL_ID_SIGNATURE, "An invalid channel id signature was supplied" },
{ QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED, "We failed to setup the symmetric keys for a connection" },
{ QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, "A handshake message arrived, but we are still validating the previous handshake message" },
{ QUIC_VERSION_NEGOTIATION_MISMATCH, "This connection involved a version negotiation which appears to have been tampered with" },
{ QUIC_INVALID_HEADERS_STREAM_DATA, "We received invalid data on the headers stream" },
{ QUIC_INVALID_WINDOW_UPDATE_DATA, "WINDOW_UPDATE frame data is malformed" },
{ QUIC_INVALID_BLOCKED_DATA, "BLOCKED frame data is malformed" },
{ QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, "The peer received too much data, violating flow control" },
{ QUIC_INVALID_STOP_WAITING_DATA, "STOP_WAITING frame data is malformed" },
{ QUIC_UNENCRYPTED_STREAM_DATA, "STREAM frame data is not encrypted" },
{ QUIC_CONNECTION_IP_POOLED, "The connection has been IP pooled into an existing connection" },
{ QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, "The peer sent too much data, violating flow control" },
{ QUIC_FLOW_CONTROL_INVALID_WINDOW, "The peer received an invalid flow control window" },
{ QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, "A server config update arrived before the handshake is complete" },
{ QUIC_TOO_MANY_UNFINISHED_STREAMS, "The peer must send a FIN/RST for each stream, and has not been doing so" },
{ QUIC_CONNECTION_OVERALL_TIMED_OUT, "We hit our overall connection timeout" },
{ QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, "The connection has too many outstanding sent packets" },
{ QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, "The connection has too many outstanding received packets" },
{ QUIC_CONNECTION_CANCELLED, "The quic connection job to load server config is cancelled" },
{ QUIC_BAD_PACKET_LOSS_RATE, "Disabled QUIC because of high packet loss rate" },
{ QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, "A crypto handshake message resulted in a stateless reject" },
{ QUIC_PUBLIC_RESETS_POST_HANDSHAKE, "Disabled QUIC because of too many PUBLIC_RESETs post handshake" },
{ QUIC_TIMEOUTS_WITH_OPEN_STREAMS, "Disabled QUIC because of too many timeouts with streams open" },
{ QUIC_FAILED_TO_SERIALIZE_PACKET, "Closed because we failed to serialize a packet" },
{ QUIC_LAST_ERROR, "No error. Used as bound while iterating" },
{ 0, NULL }
};
static value_string_ext error_code_vals_ext = VALUE_STRING_EXT_INIT(error_code_vals);
static guint32 get_len_offset(guint8 frame_type){
guint32 len;
switch((frame_type & FTFLAGS_STREAM_OOO) >> 2){
case 0:
len = 0;
break;
case 1:
len = 2;
break;
case 2:
len = 3;
break;
case 3:
len = 4;
break;
case 4:
len = 5;
break;
case 5:
len = 6;
break;
case 6:
len = 7;
break;
case 7:
len = 8;
break;
default: /* No possible but always return value... */
len = 0;
break;
}
return len;
}
static guint32 get_len_stream(guint8 frame_type){
guint32 len;
switch(frame_type & FTFLAGS_STREAM_SS){
case 0:
len = 1;
break;
case 1:
len = 2;
break;
case 2:
len = 3;
break;
case 3:
len = 4;
break;
default: /* No possible but always return value... */
len = 1;
break;
}
return len;
}
static guint32 get_len_largest_observed(guint8 frame_type){
guint32 len;
switch((frame_type & FTFLAGS_ACK_LL) >> 2){
case 0:
len = 1;
break;
case 1:
len = 2;
break;
case 2:
len = 4;
break;
case 3:
len = 6;
break;
default: /* No possible but always return value... */
len = 1;
break;
}
return len;
}
static guint32 get_len_missing_packet(guint8 frame_type){
guint32 len;
switch(frame_type & FTFLAGS_ACK_MM){
case 0:
len = 1;
break;
case 1:
len = 2;
break;
case 2:
len = 4;
break;
case 3:
len = 6;
break;
default: /* No possible but always return value... */
len = 1;
break;
}
return len;
}
static gboolean is_quic_handshake(tvbuff_t *tvb, guint offset, guint16 len_seq){
guint8 frame_type;
guint8 num_ranges, num_revived, num_timestamp;
guint32 len_stream = 0, len_offset = 0, len_data = 0, len_largest_observed = 1, len_missing_packet = 1;
guint32 message_tag;
if(tvb_captured_length_remaining(tvb, offset) <= 13){
return FALSE;
}
/* Message Authentication Hash */
offset += 12;
/* Private Flags */
offset += 1;
while(tvb_reported_length_remaining(tvb, offset) > 0){
if (tvb_captured_length_remaining(tvb, offset) <= 1){
return FALSE;
}
/* Frame type */
frame_type = tvb_get_guint8(tvb, offset);
if((frame_type & FTFLAGS_SPECIAL) == 0){
offset += 1;
switch(frame_type){
case FT_PADDING:
return FALSE; /* Pad on rest of packet.. */
break;
case FT_RST_STREAM:
/* Stream ID */
offset += 4;
/* Byte Offset */
offset += 8;
/* Error Code */
offset += 4;
break;
case FT_CONNECTION_CLOSE:{
guint16 len_reason;
/* Error Code */
offset += 4;
/* Reason Phrase Length */
if (tvb_captured_length_remaining(tvb, offset) <= 2){
return FALSE;
}
len_reason = tvb_get_ntohs(tvb, offset);
offset += 2;
/* Reason Phrase */
offset += len_reason;
}
break;
case FT_GOAWAY:{
guint16 len_reason;
/* Error Code */
offset += 4;
/* Last Good Stream ID */
offset += 4;
/* Reason Phrase Length */
if (tvb_captured_length_remaining(tvb, offset) <= 2){
return FALSE;
}
len_reason = tvb_get_ntohs(tvb, offset);
offset += 2;
/* Reason Phrase */
offset += len_reason;
}
break;
case FT_WINDOW_UPDATE:
/* Stream ID */
offset += 4;
/* Byte Offset */
offset += 8;
break;
case FT_BLOCKED:
/* Stream ID */
offset += 4;
break;
case FT_STOP_WAITING:
/* Send Entropy */
offset += 1;
/* Least Unacked Delta */
offset += len_seq;
break;
case FT_PING: /* No Payload */
default: /* No default */
break;
}
} else {
/* Special Frame Type */
if(frame_type & FTFLAGS_STREAM){ /* Stream */
if(frame_type & FTFLAGS_STREAM_D){
len_data = 2;
}
len_offset = get_len_offset(frame_type);
len_stream = get_len_stream(frame_type);
/* Frame Type */
offset += 1;
/* Stream */
offset += len_stream;
/* Offset */
offset += len_offset;
/* Data length */
offset += len_data;
if (tvb_captured_length_remaining(tvb, offset) <= 4){
return FALSE;
}
/* Check if the Message Tag is CHLO (Client Hello) or SHLO (Server Hello) or REJ (Rejection) */
message_tag = tvb_get_ntohl(tvb, offset);
if (message_tag == MTAG_CHLO|| message_tag == MTAG_SHLO || message_tag == MTAG_REJ) {
return TRUE;
}
} else if (frame_type & FTFLAGS_ACK) {
/* ACK Flags */
len_largest_observed = get_len_largest_observed(frame_type);
len_missing_packet = get_len_missing_packet(frame_type);
/* Frame Type */
offset += 1;
/* Received Entropy */
offset += 1;
/* Largest Observed */
offset += len_largest_observed;
/* Largest Observed Delta Time */
offset += 2;
/* Num Timestamp */
if (tvb_captured_length_remaining(tvb, offset) <= 1){
return FALSE;
}
num_timestamp = tvb_get_guint8(tvb, offset);
offset += 1;
if(num_timestamp > 0){
/* Delta Largest Observed */
offset += 1;
/* Time Since Previous Timestamp */
offset += 4;
/* Num Timestamp (-1)x (Delta Largest Observed + Time Since Largest Observed) */
offset += (num_timestamp - 1)*(1+2);
}
if(frame_type & FTFLAGS_ACK_N){
/* Num Ranges */
if (tvb_captured_length_remaining(tvb, offset) <= 1){
return FALSE;
}
num_ranges = tvb_get_guint8(tvb, offset);
offset += 1;
/* Num Range x (Missing Packet + Range Length) */
offset += num_ranges*(len_missing_packet+1);
/* Num Revived */
if (tvb_captured_length_remaining(tvb, offset) <= 1){
return FALSE;
}
num_revived = tvb_get_guint8(tvb, offset);
offset += 1;
/* Num Revived x Length Largest Observed */
offset += num_revived*len_largest_observed;
}
} else { /* Other Special Frame type */
offset += 1;
}
}
}
return FALSE;
}
static guint32
dissect_quic_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint offset, guint32 tag_number){
guint32 tag_offset_start = offset + tag_number*4*2;
guint32 tag_offset = 0, total_tag_len = 0;
gint32 tag_len;
while(tag_number){
proto_tree *tag_tree, *ti_len, *ti_tag, *ti_type;
guint32 offset_end, tag;
ti_tag = proto_tree_add_item(quic_tree, hf_quic_tags, tvb, offset, 8, ENC_NA);
tag_tree = proto_item_add_subtree(ti_tag, ett_quic_tag_value);
ti_type = proto_tree_add_item(tag_tree, hf_quic_tag_type, tvb, offset, 4, ENC_ASCII|ENC_NA);
tag = tvb_get_ntohl(tvb, offset);
proto_item_append_text(ti_type, " (%s)", val_to_str(tag, tag_vals, "Unknown"));
proto_item_append_text(ti_tag, ": %s (%s)", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII|ENC_NA), val_to_str(tag, tag_vals, "Unknown"));
offset += 4;
proto_tree_add_item(tag_tree, hf_quic_tag_offset_end, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset_end = tvb_get_letohl(tvb, offset);
tag_len = offset_end - tag_offset;
total_tag_len += tag_len;
ti_len = proto_tree_add_uint(tag_tree, hf_quic_tag_length, tvb, offset, 4, tag_len);
proto_item_append_text(ti_tag, " (l=%u)", tag_len);
PROTO_ITEM_SET_GENERATED(ti_len);
offset += 4;
/* Fix issue with CRT.. (Fragmentation ?) */
if( tag_len >= tvb_reported_length_remaining(tvb, tag_offset_start + tag_offset)){
tag_len = tvb_reported_length_remaining(tvb, tag_offset_start + tag_offset);
expert_add_info(pinfo, ti_len, &ei_quic_tag_length);
}
proto_tree_add_item(tag_tree, hf_quic_tag_value, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
switch(tag){
case TAG_PAD:
proto_tree_add_item(tag_tree, hf_quic_tag_pad, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_SNI:
proto_tree_add_item(tag_tree, hf_quic_tag_sni, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA));
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_VER:
proto_tree_add_item(tag_tree, hf_quic_tag_ver, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_tag, " %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_CCS:
while(tag_len > 0){
proto_tree_add_item(tag_tree, hf_quic_tag_ccs, tvb, tag_offset_start + tag_offset, 8, ENC_NA);
tag_offset += 8;
tag_len -= 8;
}
break;
case TAG_PDMD:
proto_tree_add_item(tag_tree, hf_quic_tag_pdmd, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA));
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_UAID:
proto_tree_add_item(tag_tree, hf_quic_tag_uaid, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA));
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_STK:
proto_tree_add_item(tag_tree, hf_quic_tag_stk, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_SNO:
proto_tree_add_item(tag_tree, hf_quic_tag_sno, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_PROF:
proto_tree_add_item(tag_tree, hf_quic_tag_prof, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_SCFG:{
guint32 scfg_tag_number;
proto_tree_add_item(tag_tree, hf_quic_tag_scfg, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA);
tag_offset += 4;
tag_len -= 4;
proto_tree_add_item(tag_tree, hf_quic_tag_scfg_number, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
scfg_tag_number = tvb_get_letohl(tvb, tag_offset_start + tag_offset);
tag_offset += 4;
tag_len -= 4;
dissect_quic_tag(tvb, pinfo, tag_tree, tag_offset_start + tag_offset, scfg_tag_number);
tag_offset += tag_len;
tag_len -= tag_len;
}
break;
case TAG_RREJ:
proto_tree_add_item(tag_tree, hf_quic_tag_rrej, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
proto_item_append_text(ti_tag, ": Code %u", tvb_get_letohl(tvb, tag_offset_start + tag_offset));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_CRT:
proto_tree_add_item(tag_tree, hf_quic_tag_crt, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_AEAD:
while(tag_len > 0){
proto_tree *ti_aead;
ti_aead = proto_tree_add_item(tag_tree, hf_quic_tag_aead, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_aead, " (%s)", val_to_str(tvb_get_ntohl(tvb, tag_offset_start + tag_offset), tag_aead_vals, "Unknown"));
proto_item_append_text(ti_tag, ", %s", val_to_str(tvb_get_ntohl(tvb, tag_offset_start + tag_offset), tag_aead_vals, "Unknown"));
tag_offset += 4;
tag_len -= 4;
}
break;
case TAG_SCID:
proto_tree_add_item(tag_tree, hf_quic_tag_scid, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_PUBS:
/*TODO FIX: 24 Length + Pubs key?.. ! */
proto_tree_add_item(tag_tree, hf_quic_tag_pubs, tvb, tag_offset_start + tag_offset, 2, ENC_LITTLE_ENDIAN);
tag_offset +=2;
tag_len -= 2;
while(tag_len > 0){
proto_tree_add_item(tag_tree, hf_quic_tag_pubs, tvb, tag_offset_start + tag_offset, 3, ENC_LITTLE_ENDIAN);
tag_offset += 3;
tag_len -= 3;
}
break;
case TAG_KEXS:
while(tag_len > 0){
proto_tree *ti_kexs;
ti_kexs = proto_tree_add_item(tag_tree, hf_quic_tag_kexs, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA);
proto_item_append_text(ti_kexs, " (%s)", val_to_str(tvb_get_ntohl(tvb, tag_offset_start + tag_offset), tag_kexs_vals, "Unknown"));
proto_item_append_text(ti_tag, ", %s", val_to_str(tvb_get_ntohl(tvb, tag_offset_start + tag_offset), tag_kexs_vals, "Unknown"));
tag_offset += 4;
tag_len -= 4;
}
break;
case TAG_OBIT:
proto_tree_add_item(tag_tree, hf_quic_tag_obit, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_EXPY:
proto_tree_add_item(tag_tree, hf_quic_tag_expy, tvb, tag_offset_start + tag_offset, 8, ENC_LITTLE_ENDIAN);
tag_offset += 8;
tag_len -= 8;
break;
case TAG_NONC:
/*TODO: Enhance display: 32 bytes consisting of 4 bytes of timestamp (big-endian, UNIX epoch seconds), 8 bytes of server orbit and 20 bytes of random data. */
proto_tree_add_item(tag_tree, hf_quic_tag_nonc, tvb, tag_offset_start + tag_offset, 32, ENC_NA);
tag_offset += 32;
tag_len -= 32;
break;
case TAG_MSPC:
proto_tree_add_item(tag_tree, hf_quic_tag_mspc, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
proto_item_append_text(ti_tag, ": %u", tvb_get_letohl(tvb, tag_offset_start + tag_offset));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_TCID:
proto_tree_add_item(tag_tree, hf_quic_tag_tcid, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
tag_offset += 4;
tag_len -= 4;
break;
case TAG_SRBF:
proto_tree_add_item(tag_tree, hf_quic_tag_srbf, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
tag_offset += 4;
tag_len -= 4;
break;
case TAG_ICSL:
proto_tree_add_item(tag_tree, hf_quic_tag_icsl, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
tag_offset += 4;
tag_len -= 4;
break;
case TAG_SCLS:
proto_tree_add_item(tag_tree, hf_quic_tag_scls, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
tag_offset += 4;
tag_len -= 4;
break;
case TAG_COPT:
if(tag_len){
proto_tree_add_item(tag_tree, hf_quic_tag_copt, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
tag_offset += 4;
tag_len -= 4;
}
break;
case TAG_CCRT:
proto_tree_add_item(tag_tree, hf_quic_tag_ccrt, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
case TAG_IRTT:
proto_tree_add_item(tag_tree, hf_quic_tag_irtt, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
proto_item_append_text(ti_tag, ": %u", tvb_get_letohl(tvb, tag_offset_start + tag_offset));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_CFCW:
proto_tree_add_item(tag_tree, hf_quic_tag_cfcw, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
proto_item_append_text(ti_tag, ": %u", tvb_get_letohl(tvb, tag_offset_start + tag_offset));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_SFCW:
proto_tree_add_item(tag_tree, hf_quic_tag_sfcw, tvb, tag_offset_start + tag_offset, 4, ENC_LITTLE_ENDIAN);
proto_item_append_text(ti_tag, ": %u", tvb_get_letohl(tvb, tag_offset_start + tag_offset));
tag_offset += 4;
tag_len -= 4;
break;
case TAG_CETV:
proto_tree_add_item(tag_tree, hf_quic_tag_cetv, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
tag_offset += tag_len;
tag_len -= tag_len;
break;
default:
proto_tree_add_item(tag_tree, hf_quic_tag_unknown, tvb, tag_offset_start + tag_offset, tag_len, ENC_NA);
expert_add_info_format(pinfo, ti_tag, &ei_quic_tag_undecoded,
"Dissector for QUIC Tag"
" %s (%s) code not implemented, Contact"
" Wireshark developers if you want this supported", tvb_get_string_enc(wmem_packet_scope(), tvb, offset-8, 4, ENC_ASCII|ENC_NA), val_to_str(tag, tag_vals, "Unknown"));
tag_offset += tag_len;
tag_len -= tag_len;
break;
}
if(tag_len){
/* Wrong Tag len... */
proto_tree_add_expert(tag_tree, pinfo, &ei_quic_tag_unknown, tvb, tag_offset_start + tag_offset, tag_len);
tag_offset += tag_len;
tag_len -= tag_len;
}
tag_number--;
}
return offset + total_tag_len;
}
static int
dissect_quic_frame_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint offset, guint8 len_seq){
proto_item *ti, *ti_ft, *ti_ftflags /*, *expert_ti*/;
proto_tree *ft_tree, *ftflags_tree;
guint8 frame_type;
guint8 num_ranges, num_revived, num_timestamp;
guint32 tag_number;
guint32 len_stream = 0, len_offset = 0, len_data = 0, len_largest_observed = 1, len_missing_packet = 1;
ti_ft = proto_tree_add_item(quic_tree, hf_quic_frame, tvb, offset, 1, ENC_NA);
ft_tree = proto_item_add_subtree(ti_ft, ett_quic_ft);
/* Frame type */
ti_ftflags = proto_tree_add_item(ft_tree, hf_quic_frame_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
frame_type = tvb_get_guint8(tvb, offset);
proto_item_set_text(ti_ft, "%s", rval_to_str(frame_type, frame_type_vals, "Unknown"));
if((frame_type & FTFLAGS_SPECIAL) == 0){ /* Regular Stream Flags */
offset += 1;
switch(frame_type){
case FT_PADDING:{
proto_item *ti_pad_len;
guint32 pad_len = tvb_reported_length_remaining(tvb, offset);
ti_pad_len = proto_tree_add_uint(ft_tree, hf_quic_frame_type_padding_length, tvb, offset, 0, pad_len);
PROTO_ITEM_SET_GENERATED(ti_pad_len);
proto_item_append_text(ti_ft, " Length: %u", pad_len);
proto_tree_add_item(ft_tree, hf_quic_frame_type_padding, tvb, offset, -1, ENC_NA);
offset += pad_len;
}
break;
case FT_RST_STREAM:{
guint32 stream_id, error_code;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_rsts_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN, &stream_id);
offset += 4;
proto_tree_add_item(ft_tree, hf_quic_frame_type_rsts_byte_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_rsts_error_code, tvb, offset, 4, ENC_LITTLE_ENDIAN, &error_code);
offset += 4;
proto_item_append_text(ti_ft, " Stream ID: %u, Error code: %s", stream_id, val_to_str_ext(error_code, &error_code_vals_ext, "Unknown (%d)"));
}
break;
case FT_CONNECTION_CLOSE:{
guint16 len_reason;
guint32 error_code;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_cc_error_code, tvb, offset, 4, ENC_LITTLE_ENDIAN, &error_code);
offset += 4;
proto_tree_add_item(ft_tree, hf_quic_frame_type_cc_reason_phrase_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
len_reason = tvb_get_ntohs(tvb, offset);
offset += 2;
proto_tree_add_item(ft_tree, hf_quic_frame_type_cc_reason_phrase, tvb, offset, len_reason, ENC_ASCII|ENC_NA);
offset += len_reason;
proto_item_append_text(ti_ft, " Error code: %s", val_to_str_ext(error_code, &error_code_vals_ext, "Unknown (%d)"));
}
break;
case FT_GOAWAY:{
guint16 len_reason;
guint32 error_code, last_good_stream_id;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_goaway_error_code, tvb, offset, 4, ENC_LITTLE_ENDIAN, &error_code);
offset += 4;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_goaway_last_good_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN, &last_good_stream_id);
offset += 4;
proto_tree_add_item(ft_tree, hf_quic_frame_type_goaway_reason_phrase_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
len_reason = tvb_get_ntohs(tvb, offset);
offset += 2;
proto_tree_add_item(ft_tree, hf_quic_frame_type_goaway_reason_phrase, tvb, offset, len_reason, ENC_ASCII|ENC_NA);
offset += len_reason;
proto_item_append_text(ti_ft, " Stream ID: %u, Error code: %s", last_good_stream_id, val_to_str_ext(error_code, &error_code_vals_ext, "Unknown (%d)"));
}
break;
case FT_WINDOW_UPDATE:{
guint32 stream_id;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_wu_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN, &stream_id);
offset += 4;
proto_tree_add_item(ft_tree, hf_quic_frame_type_wu_byte_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN);
offset += 8;
proto_item_append_text(ti_ft, " Stream ID: %u", stream_id);
}
break;
case FT_BLOCKED:{
guint32 stream_id;
proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_blocked_stream_id, tvb, offset, 4, ENC_LITTLE_ENDIAN, &stream_id);
offset += 4;
proto_item_append_text(ti_ft, " Stream ID: %u", stream_id);
}
break;
case FT_STOP_WAITING:{
guint8 send_entropy;
proto_tree_add_item(ft_tree, hf_quic_frame_type_sw_send_entropy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
send_entropy = tvb_get_guint8(tvb, offset);
offset += 1;
proto_tree_add_item(ft_tree, hf_quic_frame_type_sw_least_unacked_delta, tvb, offset, len_seq, ENC_LITTLE_ENDIAN);
offset += len_seq;
proto_item_append_text(ti_ft, " Send Entropy: %u", send_entropy);
}
break;
case FT_PING: /* No Payload */
default: /* No default */
break;
}
}
else { /* Special Frame Types */
guint32 stream_id = 0, message_tag;
ftflags_tree = proto_item_add_subtree(ti_ftflags, ett_quic_ftflags);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream , tvb, offset, 1, ENC_LITTLE_ENDIAN);
if(frame_type & FTFLAGS_STREAM){ /* Stream Flags */
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream_f, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream_d, tvb, offset, 1, ENC_LITTLE_ENDIAN);
if(frame_type & FTFLAGS_STREAM_D){
len_data = 2;
}
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream_ooo, tvb, offset, 1, ENC_LITTLE_ENDIAN);
len_offset = get_len_offset(frame_type);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream_ss, tvb, offset, 1, ENC_LITTLE_ENDIAN);
len_stream = get_len_stream(frame_type);
offset += 1;
if(len_stream) {
proto_tree_add_item_ret_uint(ft_tree, hf_quic_stream_id, tvb, offset, len_stream, ENC_LITTLE_ENDIAN, &stream_id);
offset += len_stream;
}
if(len_offset) {
proto_tree_add_item(ft_tree, hf_quic_offset_len, tvb, offset, len_offset, ENC_LITTLE_ENDIAN);
offset += len_offset;
}
if(len_data) {
proto_tree_add_item(ft_tree, hf_quic_data_len, tvb, offset, len_data, ENC_LITTLE_ENDIAN);
offset += len_data;
}
ti = proto_tree_add_item(ft_tree, hf_quic_tag, tvb, offset, 4, ENC_ASCII|ENC_NA);
message_tag = tvb_get_ntohl(tvb, offset);
proto_item_append_text(ti, " (%s)", val_to_str(message_tag, message_tag_vals, "Unknown Tag"));
proto_item_append_text(ti_ft, " Stream ID:%u, Type: %s (%s)", stream_id, tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII|ENC_NA), val_to_str(message_tag, message_tag_vals, "Unknown Tag"));
col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(message_tag, message_tag_vals, "Unknown"));
offset += 4;
proto_tree_add_item(ft_tree, hf_quic_tag_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
tag_number = tvb_get_letohs(tvb, offset);
offset += 2;
proto_tree_add_item(ft_tree, hf_quic_padding, tvb, offset, 2, ENC_NA);
offset += 2;
offset = dissect_quic_tag(tvb, pinfo, ft_tree, offset, tag_number);
} else if (frame_type & FTFLAGS_ACK) { /* ACK Flags */
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_ack, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_ack_n, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_ack_t, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_ack_ll, tvb, offset, 1, ENC_LITTLE_ENDIAN);
len_largest_observed = get_len_largest_observed(frame_type);
proto_tree_add_item(ftflags_tree, hf_quic_frame_type_ack_mm, tvb, offset, 1, ENC_LITTLE_ENDIAN);
len_missing_packet = get_len_missing_packet(frame_type);
offset += 1;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_received_entropy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_largest_observed, tvb, offset, len_largest_observed, ENC_LITTLE_ENDIAN);
offset += len_largest_observed;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_largest_observed_delta_time, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_num_timestamp, tvb, offset, 1, ENC_LITTLE_ENDIAN);
num_timestamp = tvb_get_guint8(tvb, offset);
offset += 1;
/* Delta Largest Observed */
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_delta_largest_observed, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
/* Time Since Previous Timestamp */
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_time_since_largest_observed, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
num_timestamp -= 1;
/* Num Timestamp (-1) x (Delta Largest Observed + Time Since Largest Observed) */
while(num_timestamp){
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_delta_largest_observed, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_time_since_previous_timestamp, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
num_timestamp--;
}
if(frame_type & FTFLAGS_ACK_N){
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_num_ranges, tvb, offset, 1, ENC_LITTLE_ENDIAN);
num_ranges = tvb_get_guint8(tvb, offset);
offset += 1;
while(num_ranges){
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_missing_packet, tvb, offset, len_missing_packet, ENC_LITTLE_ENDIAN);
offset += len_missing_packet;
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_range_length, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 1;
num_ranges--;
}
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_num_revived, tvb, offset, 1, ENC_LITTLE_ENDIAN);
num_revived = tvb_get_guint8(tvb, offset);
offset += 1;
while(num_revived){
proto_tree_add_item(ft_tree, hf_quic_frame_type_ack_revived_packet, tvb, offset, len_largest_observed, ENC_LITTLE_ENDIAN);
offset += len_largest_observed;
num_revived--;
}
}
} else { /* Other ...*/
offset += 1;
}
}
return offset;
}
static int
dissect_quic_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint offset, guint8 len_seq){
proto_item *ti_prflags;
proto_tree *prflags_tree;
/* Message Authentication Hash */
proto_tree_add_item(quic_tree, hf_quic_message_authentication_hash, tvb, offset, 12, ENC_NA);
offset += 12;
/* Private Flags */
ti_prflags = proto_tree_add_item(quic_tree, hf_quic_prflags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
prflags_tree = proto_item_add_subtree(ti_prflags, ett_quic_prflags);
proto_tree_add_item(prflags_tree, hf_quic_prflags_entropy, tvb, offset, 1, ENC_NA);
proto_tree_add_item(prflags_tree, hf_quic_prflags_fecg, tvb, offset, 1, ENC_NA);
proto_tree_add_item(prflags_tree, hf_quic_prflags_fec, tvb, offset, 1, ENC_NA);
proto_tree_add_item(prflags_tree, hf_quic_prflags_rsv, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset +=1;
while(tvb_reported_length_remaining(tvb, offset) > 0){
offset = dissect_quic_frame_type(tvb, pinfo, quic_tree, offset, len_seq);
}
return offset;
}
static int
dissect_quic_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
proto_item *ti, *ti_puflags; /*, *expert_ti*/
proto_tree *quic_tree, *puflags_tree;
guint offset = 0;
guint8 puflags, len_cid, len_seq;
guint64 cid, seq;
if (tvb_captured_length(tvb) < QUIC_MIN_LENGTH)
return 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "QUIC");
ti = proto_tree_add_item(tree, proto_quic, tvb, 0, -1, ENC_NA);
quic_tree = proto_item_add_subtree(ti, ett_quic);
/* Public Flags */
ti_puflags = proto_tree_add_item(quic_tree, hf_quic_puflags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
puflags_tree = proto_item_add_subtree(ti_puflags, ett_quic_puflags);
proto_tree_add_item(puflags_tree, hf_quic_puflags_vrsn, tvb, offset, 1, ENC_NA);
proto_tree_add_item(puflags_tree, hf_quic_puflags_rst, tvb, offset, 1, ENC_NA);
proto_tree_add_item(puflags_tree, hf_quic_puflags_cid, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(puflags_tree, hf_quic_puflags_seq, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(puflags_tree, hf_quic_puflags_rsv, tvb, offset, 1, ENC_LITTLE_ENDIAN);
puflags = tvb_get_guint8(tvb, offset);
offset += 1;
/* CID */
/* Get len of CID (and CID), may be a more easy function to get the length... */
switch((puflags & PUFLAGS_CID) >> 2){
case 0:
len_cid = 0;
cid = 0;
break;
case 1:
len_cid = 1;
cid = tvb_get_guint8(tvb, offset);
break;
case 2:
len_cid = 4;
cid = tvb_get_letohl(tvb, offset);
break;
case 3:
len_cid = 8;
cid = tvb_get_letoh64(tvb, offset);
break;
default: /* It is only between 0..3 but Clang(Analyser) i don't like this... ;-) */
len_cid = 8;
cid = tvb_get_letoh64(tvb, offset);
break;
}
if (len_cid) {
proto_tree_add_item(quic_tree, hf_quic_cid, tvb, offset, len_cid, ENC_LITTLE_ENDIAN);
offset += len_cid;
}
/* Version */
if(puflags & PUFLAGS_VRSN){
proto_tree_add_item(quic_tree, hf_quic_version, tvb, offset, 4, ENC_ASCII|ENC_NA);
offset += 4;
}
/* Sequence */
/* Get len of sequence (and sequence), may be a more easy function to get the length... */
switch((puflags & PUFLAGS_SEQ) >> 4){
case 0:
len_seq = 1;
seq = tvb_get_guint8(tvb, offset);
break;
case 1:
len_seq = 2;
seq = tvb_get_letohs(tvb, offset);
break;
case 2:
len_seq = 4;
seq = tvb_get_letohl(tvb, offset);
break;
case 3:
len_seq = 6;
seq = tvb_get_letoh48(tvb, offset);
break;
default: /* It is only between 0..3 but Clang(Analyser) i don't like this... ;-) */
len_seq = 6;
seq = tvb_get_letoh48(tvb, offset);
break;
}
proto_tree_add_item(quic_tree, hf_quic_sequence, tvb, offset, len_seq, ENC_LITTLE_ENDIAN);
offset += len_seq;
/* Handshake Message */
if (is_quic_handshake(tvb, offset, len_seq)){
offset = dissect_quic_handshake(tvb, pinfo, quic_tree, offset, len_seq);
}else { /* Payload... (encrypted... TODO FIX !) */
col_add_str(pinfo->cinfo, COL_INFO, "Payload (Encrypted)");
proto_tree_add_item(quic_tree, hf_quic_payload, tvb, offset, -1, ENC_NA);
}
if(cid){
col_append_fstr(pinfo->cinfo, COL_INFO, ", CID: %" G_GINT64_MODIFIER "u", cid);
}
col_append_fstr(pinfo->cinfo, COL_INFO, ", Seq: %" G_GINT64_MODIFIER "u", seq);
return offset;
}
static int
dissect_quic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *data _U_)
{
return dissect_quic_common(tvb, pinfo, tree, NULL);
}
void
proto_register_quic(void)
{
module_t *quic_module;
static hf_register_info hf[] = {
{ &hf_quic_puflags,
{ "Public Flags", "quic.puflags",
FT_UINT8, BASE_HEX, NULL, 0x0,
"Specifying per-packet public flags", HFILL }
},
{ &hf_quic_puflags_vrsn,
{ "Version", "quic.puflags.version",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), PUFLAGS_VRSN,
"Signifies that this packet also contains the version of the QUIC protocol", HFILL }
},
{ &hf_quic_puflags_rst,
{ "Reset", "quic.puflags.reset",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), PUFLAGS_RST,
"Signifies that this packet is a public reset packet", HFILL }
},
{ &hf_quic_puflags_cid,
{ "CID Length", "quic.puflags.cid",
FT_UINT8, BASE_HEX, VALS(puflags_cid_vals), PUFLAGS_CID,
"Signifies the Length of CID", HFILL }
},
{ &hf_quic_puflags_seq,
{ "Sequence Length", "quic.puflags.seq",
FT_UINT8, BASE_HEX, VALS(puflags_seq_vals), PUFLAGS_SEQ,
"Signifies the Length of Sequence", HFILL }
},
{ &hf_quic_puflags_rsv,
{ "Reserved", "quic.puflags.rsv",
FT_UINT8, BASE_HEX, NULL, PUFLAGS_RSV,
"Must be Zero", HFILL }
},
{ &hf_quic_cid,
{ "CID", "quic.cid",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Connection ID 64 bit pseudo random number", HFILL }
},
{ &hf_quic_version,
{ "Version", "quic.version",
FT_STRING, BASE_NONE, NULL, 0x0,
"32 bit opaque tag that represents the version of the QUIC", HFILL }
},
{ &hf_quic_sequence,
{ "Sequence", "quic.sequence",
FT_UINT64, BASE_DEC, NULL, 0x0,
"The lower 8, 16, 32, or 48 bits of the sequence number", HFILL }
},
{ &hf_quic_prflags,
{ "Private Flags", "quic.prflags",
FT_UINT8, BASE_HEX, NULL, 0x0,
"Specifying per-packet Private flags", HFILL }
},
{ &hf_quic_prflags_entropy,
{ "Entropy", "quic.prflags.entropy",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), PRFLAGS_ENTROPY,
"For data packets, signifies that this packet contains the 1 bit of entropy, for fec packets, contains the xor of the entropy of protected packets", HFILL }
},
{ &hf_quic_prflags_fecg,
{ "FEC Group", "quic.prflags.fecg",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), PRFLAGS_FECG,
"Indicates whether the fec byte is present.", HFILL }
},
{ &hf_quic_prflags_fec,
{ "FEC", "quic.prflags.fec",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), PRFLAGS_FEC,
"Signifies that this packet represents an FEC packet", HFILL }
},
{ &hf_quic_prflags_rsv,
{ "Reserved", "quic.prflags.rsv",
FT_UINT8, BASE_HEX, NULL, PRFLAGS_RSV,
"Must be Zero", HFILL }
},
{ &hf_quic_message_authentication_hash,
{ "Message Authentication Hash", "quic.message_authentication_hash",
FT_BYTES, BASE_NONE, NULL, 0x0,
"The hash is an FNV1a-128 hash, serialized in little endian order", HFILL }
},
{ &hf_quic_frame,
{ "Frame", "quic.frame_type",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_frame_type,
{ "Frame Type", "quic.frame_type",
FT_UINT8 ,BASE_RANGE_STRING | BASE_HEX, RVALS(frame_type_vals), 0x0,
NULL, HFILL }
},
{ &hf_quic_frame_type_padding_length,
{ "Padding Length", "quic.frame_type.padding.length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_frame_type_padding,
{ "Padding", "quic.frame_type.padding",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Must be zero", HFILL }
},
{ &hf_quic_frame_type_rsts_stream_id,
{ "Stream ID", "quic.frame_type.rsts.stream_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Stream ID of the stream being terminated", HFILL }
},
{ &hf_quic_frame_type_rsts_byte_offset,
{ "Byte offset", "quic.frame_type.rsts.byte_offset",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Indicating the absolute byte offset of the end of data for this stream", HFILL }
},
{ &hf_quic_frame_type_rsts_error_code,
{ "Error code", "quic.frame_type.rsts.error_code",
FT_UINT32, BASE_DEC|BASE_EXT_STRING, &error_code_vals_ext, 0x0,
"Indicates why the stream is being closed", HFILL }
},
{ &hf_quic_frame_type_cc_error_code,
{ "Error code", "quic.frame_type.cc.error_code",
FT_UINT32, BASE_DEC|BASE_EXT_STRING, &error_code_vals_ext, 0x0,
"Stream ID of the stream being terminated", HFILL }
},
{ &hf_quic_frame_type_cc_reason_phrase_length,
{ "Reason phrase Length", "quic.frame_type.cc.reason_phrase.length",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Specifying the length of the reason phrase", HFILL }
},
{ &hf_quic_frame_type_cc_reason_phrase,
{ "Reason phrase", "quic.frame_type.cc.reason_phrase",
FT_STRING, BASE_NONE, NULL, 0x0,
"An optional human-readable explanation for why the connection was closed", HFILL }
},
{ &hf_quic_frame_type_goaway_error_code,
{ "Error code", "quic.frame_type.goaway.error_code",
FT_UINT32, BASE_DEC|BASE_EXT_STRING, &error_code_vals_ext, 0x0,
"Stream ID of the stream being terminated", HFILL }
},
{ &hf_quic_frame_type_goaway_last_good_stream_id,
{ "Error code", "quic.frame_type.goaway.error_code",
FT_UINT32, BASE_DEC|BASE_EXT_STRING, &error_code_vals_ext, 0x0,
"Stream ID of the stream being terminated", HFILL }
},
{ &hf_quic_frame_type_goaway_reason_phrase_length,
{ "Reason phrase Length", "quic.frame_type.goaway.reason_phrase.length",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Specifying the length of the reason phrase", HFILL }
},
{ &hf_quic_frame_type_goaway_reason_phrase,
{ "Reason phrase", "quic.frame_type.goaway.reason_phrase",
FT_STRING, BASE_NONE, NULL, 0x0,
"An optional human-readable explanation for why the connection was closed", HFILL }
},
{ &hf_quic_frame_type_wu_stream_id,
{ "Stream ID", "quic.frame_type.wu.stream_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
"ID of the stream whose flow control windows is begin updated, or 0 to specify the connection-level flow control window", HFILL }
},
{ &hf_quic_frame_type_wu_byte_offset,
{ "Byte offset", "quic.frame_type.wu.byte_offset",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Indicating the absolute byte offset of data which can be sent on the given stream", HFILL }
},
{ &hf_quic_frame_type_blocked_stream_id,
{ "Stream ID", "quic.frame_type.blocked.stream_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Indicating the stream which is flow control blocked", HFILL }
},
{ &hf_quic_frame_type_sw_send_entropy,
{ "Send Entropy", "quic.frame_type.sw.send_entropy",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying the cumulative hash of entropy in all sent packets up to the packet with sequence number one less than the least unacked packet", HFILL }
},
{ &hf_quic_frame_type_sw_least_unacked_delta,
{ "Least unacked delta", "quic.frame_type.sw.least_unacked_delta",
FT_UINT64, BASE_DEC, NULL, 0x0,
"A variable length sequence number delta withthe same length as the packet header's sequence number", HFILL }
},
{ &hf_quic_frame_type_stream,
{ "Stream", "quic.frame_type.stream",
FT_BOOLEAN, 8, NULL, FTFLAGS_STREAM,
NULL, HFILL }
},
{ &hf_quic_frame_type_stream_f,
{ "FIN", "quic.frame_type.stream.f",
FT_BOOLEAN, 8, NULL, FTFLAGS_STREAM_F,
NULL, HFILL }
},
{ &hf_quic_frame_type_stream_d,
{ "Data Length", "quic.frame_type.stream.d",
FT_BOOLEAN, 8, TFS(&len_data_vals), FTFLAGS_STREAM_D,
NULL, HFILL }
},
{ &hf_quic_frame_type_stream_ooo,
{ "Offset Length", "quic.frame_type.stream.ooo",
FT_UINT8, BASE_DEC, VALS(len_offset_vals), FTFLAGS_STREAM_OOO,
NULL, HFILL }
},
{ &hf_quic_frame_type_stream_ss,
{ "Stream Length", "quic.frame_type.stream.ss",
FT_UINT8, BASE_DEC, VALS(len_stream_vals), FTFLAGS_STREAM_SS,
NULL, HFILL }
},
{ &hf_quic_frame_type_ack,
{ "ACK", "quic.frame_type.ack",
FT_BOOLEAN, 8, NULL, FTFLAGS_ACK,
NULL, HFILL }
},
{ &hf_quic_frame_type_ack_n,
{ "NACK", "quic.frame_type.ack.n",
FT_BOOLEAN, 8, NULL, FTFLAGS_ACK_N,
NULL, HFILL }
},
{ &hf_quic_frame_type_ack_t,
{ "Truncated", "quic.frame_type.ack.t",
FT_BOOLEAN, 8, NULL, FTFLAGS_ACK_T,
NULL, HFILL }
},
{ &hf_quic_frame_type_ack_ll,
{ "Largest Observed Length", "quic.frame_type.ack.ll",
FT_UINT8, BASE_DEC, VALS(len_largest_observed_vals), FTFLAGS_ACK_LL,
"Length of the Largest Observed field as 1, 2, 4, or 6 bytes long", HFILL }
},
{ &hf_quic_frame_type_ack_mm,
{ "Missing Packet Length", "quic.frame_type.ack.mm",
FT_UINT8, BASE_DEC, VALS(len_missing_packet_vals), FTFLAGS_ACK_MM,
"Length of the Missing Packet Sequence Number Delta field as 1, 2, 4, or 6 bytes long", HFILL }
},
{ &hf_quic_frame_type_ack_received_entropy,
{ "Received Entropy", "quic.frame_type.ack.received_entropy",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying the cumulative hash of entropy in all received packets up to the largest observed packet", HFILL }
},
{ &hf_quic_frame_type_ack_largest_observed,
{ "Largest Observed", "quic.frame_type.ack.largest_observed",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Representing the largest sequence number the peer has observed", HFILL }
},
{ &hf_quic_frame_type_ack_largest_observed_delta_time,
{ "Largest Observed Delta time", "quic.frame_type.ack.largest_observed_delta_time",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Specifying the time elapsed in microseconds from when largest observed was received until this Ack frame was sent", HFILL }
},
{ &hf_quic_frame_type_ack_num_timestamp,
{ "Num Timestamp", "quic.frame_type.ack.num_timestamp",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying the number of TCP timestamps that are included in this frame", HFILL }
},
{ &hf_quic_frame_type_ack_delta_largest_observed,
{ "Delta Largest Observed", "quic.frame_type.ack.delta_largest_observed",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Specifying the sequence number delta from the first timestamp to the largest observed", HFILL }
},
{ &hf_quic_frame_type_ack_time_since_largest_observed,
{ "Time since Largest Observed", "quic.frame_type.ack.time_since_largest_observed",
FT_UINT32, BASE_DEC, NULL, 0x0,
"This is the time delta in microseconds from the time the receiver's packet framer was created", HFILL }
},
{ &hf_quic_frame_type_ack_time_since_previous_timestamp,
{ "Time since Previous timestamp", "quic.frame_type.ack.time_since_previous_timestamp",
FT_UINT16, BASE_DEC, NULL, 0x0,
"This is the time delta from the previous timestamp", HFILL }
},
{ &hf_quic_frame_type_ack_num_ranges,
{ "Num Ranges", "quic.frame_type.ack.num_ranges",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying the number of missing packet ranges between largest observed and least unacked", HFILL }
},
{ &hf_quic_frame_type_ack_missing_packet,
{ "Missing Packet Sequence Number Delta", "quic.frame_type.ack.missing_packet",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_frame_type_ack_range_length,
{ "Range Length", "quic.frame_type.ack.range_length",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying one less than the number of sequential nacks in the range", HFILL }
},
{ &hf_quic_frame_type_ack_num_revived,
{ "Num Revived", "quic.frame_type.ack.num_revived",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Specifying the number of revived packets, recovered via FEC", HFILL }
},
{ &hf_quic_frame_type_ack_revived_packet,
{ "Revived Packet Sequence Number", "quic.frame_type.ack.revived_packet",
FT_UINT64, BASE_DEC, NULL, 0x0,
"Representing a packet the peer has revived via FEC", HFILL }
},
{ &hf_quic_stream_id,
{ "Stream ID", "quic.stream_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_offset_len,
{ "Offset Length", "quic.offset_len",
FT_UINT64, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_data_len,
{ "Data Length", "quic.offset_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag,
{ "Tag", "quic.tag",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_number,
{ "Tag Number", "quic.tag_number",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tags,
{ "Tag/value", "quic.tags",
FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_type,
{ "Tag Type", "quic.tag_type",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_offset_end,
{ "Tag offset end", "quic.tag_offset_end",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_length,
{ "Tag length", "quic.tag_offset_length",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_value,
{ "Tag/value", "quic.tag_value",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_sni,
{ "Server Name Indication", "quic.tag.sni",
FT_STRING, BASE_NONE, NULL, 0x0,
"The fully qualified DNS name of the server, canonicalised to lowercase with no trailing period", HFILL }
},
{ &hf_quic_tag_pad,
{ "Padding", "quic.tag.pad",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Pad.....", HFILL }
},
{ &hf_quic_tag_ver,
{ "Version", "quic.tag.version",
FT_STRING, BASE_NONE, NULL, 0x0,
"Version of QUIC supported", HFILL }
},
{ &hf_quic_tag_pdmd,
{ "Proof demand", "quic.tag.pdmd",
FT_STRING, BASE_NONE, NULL, 0x0,
"a list of tags describing the types of proof acceptable to the client, in preference order", HFILL }
},
{ &hf_quic_tag_ccs,
{ "Common certificate sets", "quic.tag.ccs",
FT_UINT64, BASE_HEX, NULL, 0x0,
"A series of 64-bit, FNV-1a hashes of sets of common certificates that the client possesses", HFILL }
},
{ &hf_quic_tag_uaid,
{ "Client's User Agent ID", "quic.tag.uaid",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_stk,
{ "Source-address token", "quic.tag.stk",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_sno,
{ "Server nonce", "quic.tag.sno",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_prof,
{ "Proof (Signature)", "quic.tag.prof",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_scfg,
{ "Server Config Tag", "quic.tag.scfg",
FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_scfg_number,
{ "Number Server Config Tag", "quic.tag.scfg.number",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_rrej,
{ "Reasons for server sending", "quic.tag.rrej",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_crt,
{ "Certificate chain", "quic.tag.crt",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_aead,
{ "Authenticated encryption algorithms", "quic.tag.aead",
FT_STRING, BASE_NONE, NULL, 0x0,
"A list of tags, in preference order, specifying the AEAD primitives supported by the server", HFILL }
},
{ &hf_quic_tag_scid,
{ "Server Config ID", "quic.tag.scid",
FT_BYTES, BASE_NONE, NULL, 0x0,
"An opaque, 16-byte identifier for this server config", HFILL }
},
{ &hf_quic_tag_pubs,
{ "Public value", "quic.tag.pubs",
FT_UINT24, BASE_DEC_HEX, NULL, 0x0,
"A list of public values, 24-bit, little-endian length prefixed", HFILL }
},
{ &hf_quic_tag_kexs,
{ "Key exchange algorithms", "quic.tag.kexs",
FT_STRING, BASE_NONE, NULL, 0x0,
"A list of tags, in preference order, specifying the key exchange algorithms that the server supports", HFILL }
},
{ &hf_quic_tag_obit,
{ "Server orbit", "quic.tag.obit",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_expy,
{ "Expiry", "quic.tag.expy",
FT_UINT64, BASE_DEC, NULL, 0x0,
"a 64-bit expiry time for the server config in UNIX epoch seconds", HFILL }
},
{ &hf_quic_tag_nonc,
{ "Client nonce", "quic.tag.nonc",
FT_BYTES, BASE_NONE, NULL, 0x0,
"32 bytes consisting of 4 bytes of timestamp (big-endian, UNIX epoch seconds), 8 bytes of server orbit and 20 bytes of random data", HFILL }
},
{ &hf_quic_tag_mspc,
{ "Max streams per connection", "quic.tag.mspc",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_tcid,
{ "Connection ID truncation", "quic.tag.tcid",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_srbf,
{ "Socket receive buffer", "quic.tag.srbf",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_icsl,
{ "Idle connection state", "quic.tag.icsl",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_scls,
{ "Silently close on timeout", "quic.tag.scls",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_copt,
{ "Connection options", "quic.tag.copt",
FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_ccrt,
{ "Cached certificates", "quic.tag.ccrt",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_irtt,
{ "Estimated initial RTT", "quic.tag.irtt",
FT_UINT32, BASE_DEC, NULL, 0x0,
"in us", HFILL }
},
{ &hf_quic_tag_cfcw,
{ "Initial session/connection", "quic.tag.cfcw",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_sfcw,
{ "Initial stream flow control", "quic.tag.sfcw",
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_cetv,
{ "Client encrypted tag-value", "quic.tag.cetv",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_tag_unknown,
{ "Unknown tag", "quic.tag.unknown",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_padding,
{ "Padding", "quic.padding",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_quic_payload,
{ "Payload", "quic.payload",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Quic Payload..", HFILL }
},
};
static gint *ett[] = {
&ett_quic,
&ett_quic_puflags,
&ett_quic_prflags,
&ett_quic_ft,
&ett_quic_ftflags,
&ett_quic_tag_value
};
static ei_register_info ei[] = {
{ &ei_quic_tag_undecoded, { "quic.tag.undecoded", PI_UNDECODED, PI_NOTE, "Dissector for QUIC Tag code not implemented, Contact Wireshark developers if you want this supported", EXPFILL }},
{ &ei_quic_tag_length, { "quic.tag.length.truncated", PI_MALFORMED, PI_NOTE, "Truncated Tag Length...", EXPFILL }},
{ &ei_quic_tag_unknown, { "quic.tag.unknown", PI_UNDECODED, PI_NOTE, "Unknown Data", EXPFILL }}
};
expert_module_t *expert_quic;
proto_quic = proto_register_protocol("QUIC (Quick UDP Internet Connections)",
"QUIC", "quic");
proto_register_field_array(proto_quic, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
quic_module = prefs_register_protocol(proto_quic, proto_reg_handoff_quic);
prefs_register_uint_preference(quic_module, "udp.quic.port", "QUIC UDP Port",
"QUIC UDP port if other than the default",
10, &g_quic_port);
prefs_register_uint_preference(quic_module, "udp.quics.port", "QUICS UDP Port",
"QUICS (Secure) UDP port if other than the default",
10, &g_quics_port);
expert_quic = expert_register_protocol(proto_quic);
expert_register_field_array(expert_quic, ei, array_length(ei));
}
void
proto_reg_handoff_quic(void)
{
static gboolean initialized = FALSE;
static dissector_handle_t quic_handle;
static int current_quic_port;
static int current_quics_port;
if (!initialized) {
quic_handle = new_create_dissector_handle(dissect_quic,
proto_quic);
initialized = TRUE;
} else {
dissector_delete_uint("udp.port", current_quic_port, quic_handle);
dissector_delete_uint("udp.port", current_quics_port, quic_handle);
}
current_quic_port = g_quic_port;
current_quics_port = g_quics_port;
dissector_add_uint("udp.port", current_quic_port, quic_handle);
dissector_add_uint("udp.port", current_quics_port, quic_handle);
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
| 42.083871 | 218 | 0.602407 |
d88cf74fc58044a154d659a59ca8903423bcf0e8 | 631 | h | C | Core/Inc/oled_font.h | imengyu/ControlSwitch | 785c11c8851e187a6f697600808e0529f85f9afc | [
"MIT"
] | 8 | 2021-01-22T07:43:28.000Z | 2022-03-26T14:02:43.000Z | Core/Inc/oled_font.h | imengyu/ControlSwitch | 785c11c8851e187a6f697600808e0529f85f9afc | [
"MIT"
] | null | null | null | Core/Inc/oled_font.h | imengyu/ControlSwitch | 785c11c8851e187a6f697600808e0529f85f9afc | [
"MIT"
] | null | null | null | /**
******************************************************************************
* @file : oled_font.h
* @brief : LED字符点阵
******************************************************************************
*/
#ifndef __OLED_FONT_H
#define __OLED_FONT_H
#define GB162_F16_COUNT 9 //汉字个数
//汉字用的结构体
typedef struct FONT_GB162
{
unsigned char Msk[32];
unsigned char Index[2];
unsigned char num;
}FONT_GB162;
extern const unsigned char ASCII_F6X8[][6];
extern const unsigned char ASCII_F8X16[];
extern const struct FONT_GB162 GB162_F16[];
extern const unsigned char INTRO_BMP[];
#endif
| 23.37037 | 80 | 0.508716 |
1a7cd36fd31afefad4c966bb0730a6b9e19587ed | 495 | h | C | Drawboard/Drawboard/Drawboard.h | www16852/Drawboard_swift | 146282ff970c35c206680a2aeacf7bda29961503 | [
"Apache-2.0"
] | null | null | null | Drawboard/Drawboard/Drawboard.h | www16852/Drawboard_swift | 146282ff970c35c206680a2aeacf7bda29961503 | [
"Apache-2.0"
] | null | null | null | Drawboard/Drawboard/Drawboard.h | www16852/Drawboard_swift | 146282ff970c35c206680a2aeacf7bda29961503 | [
"Apache-2.0"
] | null | null | null | //
// Drawboard.h
// Drawboard
//
// Created by waltoncob on 2016/11/15.
// Copyright © 2016年 waltoncob. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Drawboard.
FOUNDATION_EXPORT double DrawboardVersionNumber;
//! Project version string for Drawboard.
FOUNDATION_EXPORT const unsigned char DrawboardVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Drawboard/PublicHeader.h>
| 24.75 | 134 | 0.761616 |
7fb667ef88886f1bea037ad428f2397278919c26 | 16,844 | c | C | opal/mca/pmix/pmix112/pmix_pmix1.c | ICLDisco/SCON_Prototype | 69841e27f0079b21d1f930655678a6183af3282f | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | opal/mca/pmix/pmix112/pmix_pmix1.c | ICLDisco/SCON_Prototype | 69841e27f0079b21d1f930655678a6183af3282f | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | opal/mca/pmix/pmix112/pmix_pmix1.c | ICLDisco/SCON_Prototype | 69841e27f0079b21d1f930655678a6183af3282f | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/types.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "opal/dss/dss.h"
#include "opal/mca/event/event.h"
#include "opal/mca/hwloc/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/runtime/opal_progress_threads.h"
#include "opal/util/argv.h"
#include "opal/util/error.h"
#include "opal/util/output.h"
#include "opal/util/proc.h"
#include "opal/util/show_help.h"
#include "pmix1.h"
#include "opal/mca/pmix/base/base.h"
#include "opal/mca/pmix/pmix_types.h"
#include "opal/mca/pmix/pmix112/pmix/include/pmix/pmix_common.h"
/**** C.O.M.M.O.N I.N.T.E.R.F.A.C.E.S ****/
/* These are functions used by both client and server to
* access common functions in the embedded PMIx library */
static const char *pmix1_get_nspace(opal_jobid_t jobid);
static void pmix1_register_jobid(opal_jobid_t jobid, const char *nspace);
const opal_pmix_base_module_t opal_pmix_pmix112_module = {
/* client APIs */
.init = pmix1_client_init,
.finalize = pmix1_client_finalize,
.initialized = pmix1_initialized,
.abort = pmix1_abort,
.commit = pmix1_commit,
.fence = pmix1_fence,
.fence_nb = pmix1_fencenb,
.put = pmix1_put,
.get = pmix1_get,
.get_nb = pmix1_getnb,
.publish = pmix1_publish,
.publish_nb = pmix1_publishnb,
.lookup = pmix1_lookup,
.lookup_nb = pmix1_lookupnb,
.unpublish = pmix1_unpublish,
.unpublish_nb = pmix1_unpublishnb,
.spawn = pmix1_spawn,
.spawn_nb = pmix1_spawnnb,
.connect = pmix1_connect,
.connect_nb = pmix1_connectnb,
.disconnect = pmix1_disconnect,
.disconnect_nb = pmix1_disconnectnb,
.resolve_peers = pmix1_resolve_peers,
.resolve_nodes = pmix1_resolve_nodes,
/* server APIs */
.server_init = pmix1_server_init,
.server_finalize = pmix1_server_finalize,
.generate_regex = pmix1_server_gen_regex,
.generate_ppn = pmix1_server_gen_ppn,
.server_register_nspace = pmix1_server_register_nspace,
.server_deregister_nspace = pmix1_server_deregister_nspace,
.server_register_client = pmix1_server_register_client,
.server_deregister_client = pmix1_server_deregister_client,
.server_setup_fork = pmix1_server_setup_fork,
.server_dmodex_request = pmix1_server_dmodex,
.server_notify_error = pmix1_server_notify_error,
/* utility APIs */
.get_version = PMIx_Get_version,
.register_errhandler = opal_pmix_base_register_handler,
.deregister_errhandler = opal_pmix_base_deregister_handler,
.store_local = pmix1_store_local,
.get_nspace = pmix1_get_nspace,
.register_jobid = pmix1_register_jobid
};
static const char *pmix1_get_nspace(opal_jobid_t jobid)
{
opal_pmix1_jobid_trkr_t *jptr;
OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix112_component.jobids, opal_pmix1_jobid_trkr_t) {
if (jptr->jobid == jobid) {
return jptr->nspace;
}
}
return NULL;
}
static void pmix1_register_jobid(opal_jobid_t jobid, const char *nspace)
{
opal_pmix1_jobid_trkr_t *jptr;
/* if we don't already have it, add this to our jobid tracker */
OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix112_component.jobids, opal_pmix1_jobid_trkr_t) {
if (jptr->jobid == jobid) {
return;
}
}
jptr = OBJ_NEW(opal_pmix1_jobid_trkr_t);
(void)strncpy(jptr->nspace, nspace, PMIX_MAX_NSLEN);
jptr->jobid = jobid;
opal_list_append(&mca_pmix_pmix112_component.jobids, &jptr->super);
}
pmix_status_t pmix1_convert_opalrc(int rc)
{
switch (rc) {
case OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER:
return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
case OPAL_ERR_COMM_FAILURE:
return PMIX_ERR_COMM_FAILURE;
case OPAL_ERR_NOT_IMPLEMENTED:
return PMIX_ERR_NOT_IMPLEMENTED;
case OPAL_ERR_NOT_SUPPORTED:
return PMIX_ERR_NOT_SUPPORTED;
case OPAL_ERR_NOT_FOUND:
return PMIX_ERR_NOT_FOUND;
case OPAL_ERR_SERVER_NOT_AVAIL:
return PMIX_ERR_SERVER_NOT_AVAIL;
case OPAL_ERR_BAD_PARAM:
return PMIX_ERR_BAD_PARAM;
case OPAL_ERR_OUT_OF_RESOURCE:
return PMIX_ERR_NOMEM;
case OPAL_ERR_DATA_VALUE_NOT_FOUND:
return PMIX_ERR_DATA_VALUE_NOT_FOUND;
case OPAL_ERR_IN_ERRNO:
return PMIX_ERR_IN_ERRNO;
case OPAL_ERR_UNREACH:
return PMIX_ERR_UNREACH;
case OPAL_ERR_TIMEOUT:
return PMIX_ERR_TIMEOUT;
case OPAL_ERR_PERM:
return PMIX_ERR_NO_PERMISSIONS;
case OPAL_ERR_PACK_MISMATCH:
return PMIX_ERR_PACK_MISMATCH;
case OPAL_ERR_PACK_FAILURE:
return PMIX_ERR_PACK_FAILURE;
case OPAL_ERR_UNPACK_FAILURE:
return PMIX_ERR_UNPACK_FAILURE;
case OPAL_ERR_UNPACK_INADEQUATE_SPACE:
return PMIX_ERR_UNPACK_INADEQUATE_SPACE;
case OPAL_ERR_TYPE_MISMATCH:
return PMIX_ERR_TYPE_MISMATCH;
case OPAL_ERR_PROC_ENTRY_NOT_FOUND:
return PMIX_ERR_PROC_ENTRY_NOT_FOUND;
case OPAL_ERR_UNKNOWN_DATA_TYPE:
return PMIX_ERR_UNKNOWN_DATA_TYPE;
case OPAL_ERR_WOULD_BLOCK:
return PMIX_ERR_WOULD_BLOCK;
case OPAL_EXISTS:
return PMIX_EXISTS;
case OPAL_ERR_SILENT:
return PMIX_ERR_SILENT;
case OPAL_ERROR:
return PMIX_ERROR;
case OPAL_SUCCESS:
return PMIX_SUCCESS;
default:
return PMIX_ERROR;
}
}
int pmix1_convert_rc(pmix_status_t rc)
{
switch (rc) {
case PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER:
return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
case PMIX_ERR_COMM_FAILURE:
return OPAL_ERR_COMM_FAILURE;
case PMIX_ERR_NOT_IMPLEMENTED:
return OPAL_ERR_NOT_IMPLEMENTED;
case PMIX_ERR_NOT_SUPPORTED:
return OPAL_ERR_NOT_SUPPORTED;
case PMIX_ERR_NOT_FOUND:
return OPAL_ERR_NOT_FOUND;
case PMIX_ERR_SERVER_NOT_AVAIL:
return OPAL_ERR_SERVER_NOT_AVAIL;
case PMIX_ERR_INVALID_NAMESPACE:
case PMIX_ERR_INVALID_SIZE:
case PMIX_ERR_INVALID_KEYVALP:
case PMIX_ERR_INVALID_NUM_PARSED:
case PMIX_ERR_INVALID_ARGS:
case PMIX_ERR_INVALID_NUM_ARGS:
case PMIX_ERR_INVALID_LENGTH:
case PMIX_ERR_INVALID_VAL_LENGTH:
case PMIX_ERR_INVALID_VAL:
case PMIX_ERR_INVALID_KEY_LENGTH:
case PMIX_ERR_INVALID_KEY:
case PMIX_ERR_INVALID_ARG:
return OPAL_ERR_BAD_PARAM;
case PMIX_ERR_NOMEM:
return OPAL_ERR_OUT_OF_RESOURCE;
case PMIX_ERR_INIT:
return OPAL_ERROR;
case PMIX_ERR_DATA_VALUE_NOT_FOUND:
return OPAL_ERR_DATA_VALUE_NOT_FOUND;
case PMIX_ERR_OUT_OF_RESOURCE:
return OPAL_ERR_OUT_OF_RESOURCE;
case PMIX_ERR_RESOURCE_BUSY:
return OPAL_ERR_TEMP_OUT_OF_RESOURCE;
case PMIX_ERR_BAD_PARAM:
return OPAL_ERR_BAD_PARAM;
case PMIX_ERR_IN_ERRNO:
return OPAL_ERR_IN_ERRNO;
case PMIX_ERR_UNREACH:
return OPAL_ERR_UNREACH;
case PMIX_ERR_TIMEOUT:
return OPAL_ERR_TIMEOUT;
case PMIX_ERR_NO_PERMISSIONS:
return OPAL_ERR_PERM;
case PMIX_ERR_PACK_MISMATCH:
return OPAL_ERR_PACK_MISMATCH;
case PMIX_ERR_PACK_FAILURE:
return OPAL_ERR_PACK_FAILURE;
case PMIX_ERR_UNPACK_FAILURE:
return OPAL_ERR_UNPACK_FAILURE;
case PMIX_ERR_UNPACK_INADEQUATE_SPACE:
return OPAL_ERR_UNPACK_INADEQUATE_SPACE;
case PMIX_ERR_TYPE_MISMATCH:
return OPAL_ERR_TYPE_MISMATCH;
case PMIX_ERR_PROC_ENTRY_NOT_FOUND:
return OPAL_ERR_PROC_ENTRY_NOT_FOUND;
case PMIX_ERR_UNKNOWN_DATA_TYPE:
return OPAL_ERR_UNKNOWN_DATA_TYPE;
case PMIX_ERR_WOULD_BLOCK:
return OPAL_ERR_WOULD_BLOCK;
case PMIX_ERR_READY_FOR_HANDSHAKE:
case PMIX_ERR_HANDSHAKE_FAILED:
case PMIX_ERR_INVALID_CRED:
return OPAL_ERR_COMM_FAILURE;
case PMIX_EXISTS:
return OPAL_EXISTS;
case PMIX_ERR_SILENT:
return OPAL_ERR_SILENT;
case PMIX_ERROR:
return OPAL_ERROR;
case PMIX_SUCCESS:
return OPAL_SUCCESS;
default:
return OPAL_ERROR;
}
}
pmix_scope_t pmix1_convert_opalscope(opal_pmix_scope_t scope) {
switch(scope) {
case OPAL_PMIX_LOCAL:
return PMIX_LOCAL;
case OPAL_PMIX_REMOTE:
return PMIX_REMOTE;
case OPAL_PMIX_GLOBAL:
return PMIX_GLOBAL;
default:
return PMIX_SCOPE_UNDEF;
}
}
void pmix1_value_load(pmix_value_t *v,
opal_value_t *kv)
{
switch(kv->type) {
case OPAL_UNDEF:
v->type = PMIX_UNDEF;
opal_output(0, "TYPE WAS UNDEF");
break;
case OPAL_BOOL:
v->type = PMIX_BOOL;
memcpy(&(v->data.flag), &kv->data.flag, 1);
break;
case OPAL_BYTE:
v->type = PMIX_BYTE;
memcpy(&(v->data.byte), &kv->data.byte, 1);
break;
case OPAL_STRING:
v->type = PMIX_STRING;
if (NULL != kv->data.string) {
v->data.string = strdup(kv->data.string);
} else {
v->data.string = NULL;
}
break;
case OPAL_SIZE:
v->type = PMIX_SIZE;
v->data.size = (size_t)kv->data.size;
break;
case OPAL_PID:
v->type = PMIX_PID;
memcpy(&(v->data.pid), &kv->data.pid, sizeof(pid_t));
break;
case OPAL_INT:
v->type = PMIX_INT;
memcpy(&(v->data.integer), &kv->data.integer, sizeof(int));
break;
case OPAL_INT8:
v->type = PMIX_INT8;
memcpy(&(v->data.int8), &kv->data.int8, 1);
break;
case OPAL_INT16:
v->type = PMIX_INT16;
memcpy(&(v->data.int16), &kv->data.int16, 2);
break;
case OPAL_INT32:
v->type = PMIX_INT32;
memcpy(&(v->data.int32), &kv->data.int32, 4);
break;
case OPAL_INT64:
v->type = PMIX_INT64;
memcpy(&(v->data.int64), &kv->data.int64, 8);
break;
case OPAL_UINT:
v->type = PMIX_UINT;
memcpy(&(v->data.uint), &kv->data.uint, sizeof(int));
break;
case OPAL_UINT8:
v->type = PMIX_UINT8;
memcpy(&(v->data.uint8), &kv->data.uint8, 1);
break;
case OPAL_UINT16:
v->type = PMIX_UINT16;
memcpy(&(v->data.uint16), &kv->data.uint16, 2);
break;
case OPAL_UINT32:
v->type = PMIX_UINT32;
memcpy(&(v->data.uint32), &kv->data.uint32, 4);
break;
case OPAL_UINT64:
v->type = PMIX_UINT64;
memcpy(&(v->data.uint64), &kv->data.uint64, 8);
break;
case OPAL_FLOAT:
v->type = PMIX_FLOAT;
memcpy(&(v->data.fval), &kv->data.fval, sizeof(float));
break;
case OPAL_DOUBLE:
v->type = PMIX_DOUBLE;
memcpy(&(v->data.dval), &kv->data.dval, sizeof(double));
break;
case OPAL_TIMEVAL:
v->type = PMIX_TIMEVAL;
memcpy(&(v->data.tv), &kv->data.tv, sizeof(struct timeval));
break;
case OPAL_BYTE_OBJECT:
v->type = PMIX_BYTE_OBJECT;
if (NULL != kv->data.bo.bytes) {
v->data.bo.bytes = (char*)malloc(kv->data.bo.size);
memcpy(v->data.bo.bytes, kv->data.bo.bytes, kv->data.bo.size);
v->data.bo.size = (size_t)kv->data.bo.size;
} else {
v->data.bo.bytes = NULL;
v->data.bo.size = 0;
}
break;
default:
/* silence warnings */
break;
}
}
int pmix1_value_unload(opal_value_t *kv,
const pmix_value_t *v)
{
int rc=OPAL_SUCCESS;
switch(v->type) {
case PMIX_UNDEF:
rc = OPAL_ERR_UNKNOWN_DATA_TYPE;
break;
case PMIX_BOOL:
kv->type = OPAL_BOOL;
memcpy(&kv->data.flag, &(v->data.flag), 1);
break;
case PMIX_BYTE:
kv->type = OPAL_BYTE;
memcpy(&kv->data.byte, &(v->data.byte), 1);
break;
case PMIX_STRING:
kv->type = OPAL_STRING;
if (NULL != v->data.string) {
kv->data.string = strdup(v->data.string);
}
break;
case PMIX_SIZE:
kv->type = OPAL_SIZE;
kv->data.size = (int)v->data.size;
break;
case PMIX_PID:
kv->type = OPAL_PID;
memcpy(&kv->data.pid, &(v->data.pid), sizeof(pid_t));
break;
case PMIX_INT:
kv->type = OPAL_INT;
memcpy(&kv->data.integer, &(v->data.integer), sizeof(int));
break;
case PMIX_INT8:
kv->type = OPAL_INT8;
memcpy(&kv->data.int8, &(v->data.int8), 1);
break;
case PMIX_INT16:
kv->type = OPAL_INT16;
memcpy(&kv->data.int16, &(v->data.int16), 2);
break;
case PMIX_INT32:
kv->type = OPAL_INT32;
memcpy(&kv->data.int32, &(v->data.int32), 4);
break;
case PMIX_INT64:
kv->type = OPAL_INT64;
memcpy(&kv->data, &(v->data.int64), 8);
break;
case PMIX_UINT:
kv->type = OPAL_UINT;
memcpy(&kv->data, &(v->data.uint), sizeof(int));
break;
case PMIX_UINT8:
kv->type = OPAL_UINT8;
memcpy(&kv->data, &(v->data.uint8), 1);
break;
case PMIX_UINT16:
kv->type = OPAL_UINT16;
memcpy(&kv->data, &(v->data.uint16), 2);
break;
case PMIX_UINT32:
kv->type = OPAL_UINT32;
memcpy(&kv->data, &(v->data.uint32), 4);
break;
case PMIX_UINT64:
kv->type = OPAL_UINT64;
memcpy(&kv->data, &(v->data.uint64), 8);
break;
case PMIX_FLOAT:
kv->type = OPAL_FLOAT;
memcpy(&kv->data, &(v->data.fval), sizeof(float));
break;
case PMIX_DOUBLE:
kv->type = OPAL_DOUBLE;
memcpy(&kv->data, &(v->data.dval), sizeof(double));
break;
case PMIX_TIMEVAL:
kv->type = OPAL_TIMEVAL;
memcpy(&kv->data, &(v->data.tv), sizeof(struct timeval));
break;
case PMIX_BYTE_OBJECT:
kv->type = OPAL_BYTE_OBJECT;
if (NULL != v->data.bo.bytes && 0 < v->data.bo.size) {
kv->data.bo.bytes = (uint8_t*)malloc(v->data.bo.size);
memcpy(kv->data.bo.bytes, v->data.bo.bytes, v->data.bo.size);
kv->data.bo.size = (int)v->data.bo.size;
} else {
kv->data.bo.bytes = NULL;
kv->data.bo.size = 0;
}
break;
default:
/* silence warnings */
rc = OPAL_ERROR;
break;
}
return rc;
}
/**** INSTANTIATE INTERNAL CLASSES ****/
OBJ_CLASS_INSTANCE(opal_pmix1_jobid_trkr_t,
opal_list_item_t,
NULL, NULL);
static void opcon(pmix1_opcaddy_t *p)
{
memset(&p->p, 0, sizeof(pmix_proc_t));
p->procs = NULL;
p->nprocs = 0;
p->error_procs = NULL;
p->nerror_procs = 0;
p->info = NULL;
p->ninfo = 0;
p->apps = NULL;
p->sz = 0;
p->opcbfunc = NULL;
p->mdxcbfunc = NULL;
p->valcbfunc = NULL;
p->lkcbfunc = NULL;
p->spcbfunc = NULL;
p->cbdata = NULL;
}
static void opdes(pmix1_opcaddy_t *p)
{
if (NULL != p->procs) {
PMIX_PROC_FREE(p->procs, p->nprocs);
}
if (NULL != p->error_procs) {
PMIX_PROC_FREE(p->error_procs, p->nerror_procs);
}
if (NULL != p->info) {
PMIX_INFO_FREE(p->info, p->sz);
}
if (NULL != p->apps) {
PMIX_APP_FREE(p->apps, p->sz);
}
}
OBJ_CLASS_INSTANCE(pmix1_opcaddy_t,
opal_object_t,
opcon, opdes);
static void ocadcon(pmix1_opalcaddy_t *p)
{
OBJ_CONSTRUCT(&p->procs, opal_list_t);
OBJ_CONSTRUCT(&p->info, opal_list_t);
OBJ_CONSTRUCT(&p->apps, opal_list_t);
p->opcbfunc = NULL;
p->dmdxfunc = NULL;
p->mdxcbfunc = NULL;
p->lkupcbfunc = NULL;
p->spwncbfunc = NULL;
p->cbdata = NULL;
p->odmdxfunc = NULL;
p->ocbdata = NULL;
}
static void ocaddes(pmix1_opalcaddy_t *p)
{
OPAL_LIST_DESTRUCT(&p->procs);
OPAL_LIST_DESTRUCT(&p->info);
OPAL_LIST_DESTRUCT(&p->apps);
}
OBJ_CLASS_INSTANCE(pmix1_opalcaddy_t,
opal_object_t,
ocadcon, ocaddes);
| 30.294964 | 90 | 0.620043 |
cfa5d8df0e8e1ee221424b4657db77b61ba12d83 | 25,678 | c | C | bsp/efm32/Libraries/CMSIS/DSP_Lib/Source/TransformFunctions/arm_cfft_radix4_q31.c | Davidfind/rt-thread | 56f1a8af4f9e8bad0a0fdc5cea7112767267b243 | [
"Apache-2.0"
] | 275 | 2018-06-15T14:34:36.000Z | 2022-03-26T17:09:40.000Z | bsp/efm32/Libraries/CMSIS/DSP_Lib/Source/TransformFunctions/arm_cfft_radix4_q31.c | zlzerg/rt-thread | c0a400ccbee720fc0e9ee904298f09bd07a21382 | [
"Apache-2.0"
] | 5 | 2019-02-28T10:07:03.000Z | 2019-03-11T10:40:20.000Z | bsp/efm32/Libraries/CMSIS/DSP_Lib/Source/TransformFunctions/arm_cfft_radix4_q31.c | zlzerg/rt-thread | c0a400ccbee720fc0e9ee904298f09bd07a21382 | [
"Apache-2.0"
] | 164 | 2018-06-15T14:47:47.000Z | 2022-03-25T09:54:53.000Z | /* ----------------------------------------------------------------------
* Copyright (C) 2010 ARM Limited. All rights reserved.
*
* $Date: 15. February 2012
* $Revision: V1.1.0
*
* Project: CMSIS DSP Library
* Title: arm_cfft_radix4_q31.c
*
* Description: This file has function definition of Radix-4 FFT & IFFT function and
* In-place bit reversal using bit reversal table
*
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
*
* Version 1.1.0 2012/02/15
* Updated with more optimizations, bug fixes and minor API changes.
*
* Version 1.0.10 2011/7/15
* Big Endian support added and Merged M0 and M3/M4 Source code.
*
* Version 1.0.3 2010/11/29
* Re-organized the CMSIS folders and updated documentation.
*
* Version 1.0.2 2010/11/11
* Documentation updated.
*
* Version 1.0.1 2010/10/05
* Production release and review comments incorporated.
*
* Version 1.0.0 2010/09/20
* Production release and review comments incorporated.
*
* Version 0.0.5 2010/04/26
* incorporated review comments and updated with latest CMSIS layer
*
* Version 0.0.3 2010/03/10
* Initial version
* -------------------------------------------------------------------- */
#include "arm_math.h"
/**
* @ingroup groupTransforms
*/
/**
* @addtogroup Radix4_CFFT_CIFFT
* @{
*/
/**
* @details
* @brief Processing function for the Q31 CFFT/CIFFT.
* @param[in] *S points to an instance of the Q31 CFFT/CIFFT structure.
* @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place.
* @return none.
*
* \par Input and output formats:
* \par
* Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
* Hence the output format is different for different FFT sizes.
* The input and output formats for different FFT sizes and number of bits to upscale are mentioned in the tables below for CFFT and CIFFT:
* \par
* \image html CFFTQ31.gif "Input and Output Formats for Q31 CFFT"
* \image html CIFFTQ31.gif "Input and Output Formats for Q31 CIFFT"
*
*/
void arm_cfft_radix4_q31(
const arm_cfft_radix4_instance_q31 * S,
q31_t * pSrc)
{
if(S->ifftFlag == 1u)
{
/* Complex IFFT radix-4 */
arm_radix4_butterfly_inverse_q31(pSrc, S->fftLen, S->pTwiddle,
S->twidCoefModifier);
}
else
{
/* Complex FFT radix-4 */
arm_radix4_butterfly_q31(pSrc, S->fftLen, S->pTwiddle,
S->twidCoefModifier);
}
if(S->bitReverseFlag == 1u)
{
/* Bit Reversal */
arm_bitreversal_q31(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable);
}
}
/**
* @} end of Radix4_CFFT_CIFFT group
*/
/*
* Radix-4 FFT algorithm used is :
*
* Input real and imaginary data:
* x(n) = xa + j * ya
* x(n+N/4 ) = xb + j * yb
* x(n+N/2 ) = xc + j * yc
* x(n+3N 4) = xd + j * yd
*
*
* Output real and imaginary data:
* x(4r) = xa'+ j * ya'
* x(4r+1) = xb'+ j * yb'
* x(4r+2) = xc'+ j * yc'
* x(4r+3) = xd'+ j * yd'
*
*
* Twiddle factors for radix-4 FFT:
* Wn = co1 + j * (- si1)
* W2n = co2 + j * (- si2)
* W3n = co3 + j * (- si3)
*
* Butterfly implementation:
* xa' = xa + xb + xc + xd
* ya' = ya + yb + yc + yd
* xb' = (xa+yb-xc-yd)* co1 + (ya-xb-yc+xd)* (si1)
* yb' = (ya-xb-yc+xd)* co1 - (xa+yb-xc-yd)* (si1)
* xc' = (xa-xb+xc-xd)* co2 + (ya-yb+yc-yd)* (si2)
* yc' = (ya-yb+yc-yd)* co2 - (xa-xb+xc-xd)* (si2)
* xd' = (xa-yb-xc+yd)* co3 + (ya+xb-yc-xd)* (si3)
* yd' = (ya+xb-yc-xd)* co3 - (xa-yb-xc+yd)* (si3)
*
*/
/**
* @brief Core function for the Q31 CFFT butterfly process.
* @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
* @param[in] fftLen length of the FFT.
* @param[in] *pCoef points to twiddle coefficient buffer.
* @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
* @return none.
*/
void arm_radix4_butterfly_q31(
q31_t * pSrc,
uint32_t fftLen,
q31_t * pCoef,
uint32_t twidCoefModifier)
{
uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k;
q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3;
q31_t xa, xb, xc, xd;
q31_t ya, yb, yc, yd;
q31_t xa_out, xb_out, xc_out, xd_out;
q31_t ya_out, yb_out, yc_out, yd_out;
q31_t *ptr1;
q63_t xaya, xbyb, xcyc, xdyd;
/* Total process is divided into three stages */
/* process first stage, middle stages, & last stage */
/* start of first stage process */
/* Initializations for the first stage */
n2 = fftLen;
n1 = n2;
/* n2 = fftLen/4 */
n2 >>= 2u;
i0 = 0u;
ia1 = 0u;
j = n2;
/* Calculation of first stage */
do
{
/* index calculation for the input as, */
/* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2u], pSrc[i0 + 3fftLen/4] */
i1 = i0 + n2;
i2 = i1 + n2;
i3 = i2 + n2;
/* input is in 1.31(q31) format and provide 4 guard bits for the input */
/* Butterfly implementation */
/* xa + xc */
r1 = (pSrc[(2u * i0)] >> 4u) + (pSrc[(2u * i2)] >> 4u);
/* xa - xc */
r2 = (pSrc[2u * i0] >> 4u) - (pSrc[2u * i2] >> 4u);
/* xb + xd */
t1 = (pSrc[2u * i1] >> 4u) + (pSrc[2u * i3] >> 4u);
/* ya + yc */
s1 = (pSrc[(2u * i0) + 1u] >> 4u) + (pSrc[(2u * i2) + 1u] >> 4u);
/* ya - yc */
s2 = (pSrc[(2u * i0) + 1u] >> 4u) - (pSrc[(2u * i2) + 1u] >> 4u);
/* xa' = xa + xb + xc + xd */
pSrc[2u * i0] = (r1 + t1);
/* (xa + xc) - (xb + xd) */
r1 = r1 - t1;
/* yb + yd */
t2 = (pSrc[(2u * i1) + 1u] >> 4u) + (pSrc[(2u * i3) + 1u] >> 4u);
/* ya' = ya + yb + yc + yd */
pSrc[(2u * i0) + 1u] = (s1 + t2);
/* (ya + yc) - (yb + yd) */
s1 = s1 - t2;
/* yb - yd */
t1 = (pSrc[(2u * i1) + 1u] >> 4u) - (pSrc[(2u * i3) + 1u] >> 4u);
/* xb - xd */
t2 = (pSrc[2u * i1] >> 4u) - (pSrc[2u * i3] >> 4u);
/* index calculation for the coefficients */
ia2 = 2u * ia1;
co2 = pCoef[ia2 * 2u];
si2 = pCoef[(ia2 * 2u) + 1u];
/* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */
pSrc[2u * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) +
((int32_t) (((q63_t) s1 * si2) >> 32))) << 1u;
/* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */
pSrc[(2u * i1) + 1u] = (((int32_t) (((q63_t) s1 * co2) >> 32)) -
((int32_t) (((q63_t) r1 * si2) >> 32))) << 1u;
/* (xa - xc) + (yb - yd) */
r1 = r2 + t1;
/* (xa - xc) - (yb - yd) */
r2 = r2 - t1;
/* (ya - yc) - (xb - xd) */
s1 = s2 - t2;
/* (ya - yc) + (xb - xd) */
s2 = s2 + t2;
co1 = pCoef[ia1 * 2u];
si1 = pCoef[(ia1 * 2u) + 1u];
/* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */
pSrc[2u * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) +
((int32_t) (((q63_t) s1 * si1) >> 32))) << 1u;
/* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */
pSrc[(2u * i2) + 1u] = (((int32_t) (((q63_t) s1 * co1) >> 32)) -
((int32_t) (((q63_t) r1 * si1) >> 32))) << 1u;
/* index calculation for the coefficients */
ia3 = 3u * ia1;
co3 = pCoef[ia3 * 2u];
si3 = pCoef[(ia3 * 2u) + 1u];
/* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */
pSrc[2u * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) +
((int32_t) (((q63_t) s2 * si3) >> 32))) << 1u;
/* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */
pSrc[(2u * i3) + 1u] = (((int32_t) (((q63_t) s2 * co3) >> 32)) -
((int32_t) (((q63_t) r2 * si3) >> 32))) << 1u;
/* Twiddle coefficients index modifier */
ia1 = ia1 + twidCoefModifier;
/* Updating input index */
i0 = i0 + 1u;
} while(--j);
/* end of first stage process */
/* data is in 5.27(q27) format */
/* start of Middle stages process */
/* each stage in middle stages provides two down scaling of the input */
twidCoefModifier <<= 2u;
for (k = fftLen / 4u; k > 4u; k >>= 2u)
{
/* Initializations for the first stage */
n1 = n2;
n2 >>= 2u;
ia1 = 0u;
/* Calculation of first stage */
for (j = 0u; j <= (n2 - 1u); j++)
{
/* index calculation for the coefficients */
ia2 = ia1 + ia1;
ia3 = ia2 + ia1;
co1 = pCoef[ia1 * 2u];
si1 = pCoef[(ia1 * 2u) + 1u];
co2 = pCoef[ia2 * 2u];
si2 = pCoef[(ia2 * 2u) + 1u];
co3 = pCoef[ia3 * 2u];
si3 = pCoef[(ia3 * 2u) + 1u];
/* Twiddle coefficients index modifier */
ia1 = ia1 + twidCoefModifier;
for (i0 = j; i0 < fftLen; i0 += n1)
{
/* index calculation for the input as, */
/* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2u], pSrc[i0 + 3fftLen/4] */
i1 = i0 + n2;
i2 = i1 + n2;
i3 = i2 + n2;
/* Butterfly implementation */
/* xa + xc */
r1 = pSrc[2u * i0] + pSrc[2u * i2];
/* xa - xc */
r2 = pSrc[2u * i0] - pSrc[2u * i2];
/* ya + yc */
s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u];
/* ya - yc */
s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u];
/* xb + xd */
t1 = pSrc[2u * i1] + pSrc[2u * i3];
/* xa' = xa + xb + xc + xd */
pSrc[2u * i0] = (r1 + t1) >> 2u;
/* xa + xc -(xb + xd) */
r1 = r1 - t1;
/* yb + yd */
t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u];
/* ya' = ya + yb + yc + yd */
pSrc[(2u * i0) + 1u] = (s1 + t2) >> 2u;
/* (ya + yc) - (yb + yd) */
s1 = s1 - t2;
/* (yb - yd) */
t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u];
/* (xb - xd) */
t2 = pSrc[2u * i1] - pSrc[2u * i3];
/* xc' = (xa-xb+xc-xd)co2 + (ya-yb+yc-yd)(si2) */
pSrc[2u * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) +
((int32_t) (((q63_t) s1 * si2) >> 32))) >> 1u;
/* yc' = (ya-yb+yc-yd)co2 - (xa-xb+xc-xd)(si2) */
pSrc[(2u * i1) + 1u] = (((int32_t) (((q63_t) s1 * co2) >> 32)) -
((int32_t) (((q63_t) r1 * si2) >> 32))) >> 1u;
/* (xa - xc) + (yb - yd) */
r1 = r2 + t1;
/* (xa - xc) - (yb - yd) */
r2 = r2 - t1;
/* (ya - yc) - (xb - xd) */
s1 = s2 - t2;
/* (ya - yc) + (xb - xd) */
s2 = s2 + t2;
/* xb' = (xa+yb-xc-yd)co1 + (ya-xb-yc+xd)(si1) */
pSrc[2u * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) +
((int32_t) (((q63_t) s1 * si1) >> 32))) >> 1u;
/* yb' = (ya-xb-yc+xd)co1 - (xa+yb-xc-yd)(si1) */
pSrc[(2u * i2) + 1u] = (((int32_t) (((q63_t) s1 * co1) >> 32)) -
((int32_t) (((q63_t) r1 * si1) >> 32))) >> 1u;
/* xd' = (xa-yb-xc+yd)co3 + (ya+xb-yc-xd)(si3) */
pSrc[2u * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) +
((int32_t) (((q63_t) s2 * si3) >> 32))) >> 1u;
/* yd' = (ya+xb-yc-xd)co3 - (xa-yb-xc+yd)(si3) */
pSrc[(2u * i3) + 1u] = (((int32_t) (((q63_t) s2 * co3) >> 32)) -
((int32_t) (((q63_t) r2 * si3) >> 32))) >> 1u;
}
}
twidCoefModifier <<= 2u;
}
/* End of Middle stages process */
/* data is in 11.21(q21) format for the 1024 point as there are 3 middle stages */
/* data is in 9.23(q23) format for the 256 point as there are 2 middle stages */
/* data is in 7.25(q25) format for the 64 point as there are 1 middle stage */
/* data is in 5.27(q27) format for the 16 point as there are no middle stages */
/* start of Last stage process */
/* Initializations for the last stage */
j = fftLen >> 2;
ptr1 = &pSrc[0];
/* Calculations of last stage */
do
{
#ifndef ARM_MATH_BIG_ENDIAN
/* Read xa (real), ya(imag) input */
xaya = *__SIMD64(ptr1)++;
xa = (q31_t) xaya;
ya = (q31_t) (xaya >> 32);
/* Read xb (real), yb(imag) input */
xbyb = *__SIMD64(ptr1)++;
xb = (q31_t) xbyb;
yb = (q31_t) (xbyb >> 32);
/* Read xc (real), yc(imag) input */
xcyc = *__SIMD64(ptr1)++;
xc = (q31_t) xcyc;
yc = (q31_t) (xcyc >> 32);
/* Read xc (real), yc(imag) input */
xdyd = *__SIMD64(ptr1)++;
xd = (q31_t) xdyd;
yd = (q31_t) (xdyd >> 32);
#else
/* Read xa (real), ya(imag) input */
xaya = *__SIMD64(ptr1)++;
ya = (q31_t) xaya;
xa = (q31_t) (xaya >> 32);
/* Read xb (real), yb(imag) input */
xbyb = *__SIMD64(ptr1)++;
yb = (q31_t) xbyb;
xb = (q31_t) (xbyb >> 32);
/* Read xc (real), yc(imag) input */
xcyc = *__SIMD64(ptr1)++;
yc = (q31_t) xcyc;
xc = (q31_t) (xcyc >> 32);
/* Read xc (real), yc(imag) input */
xdyd = *__SIMD64(ptr1)++;
yd = (q31_t) xdyd;
xd = (q31_t) (xdyd >> 32);
#endif
/* xa' = xa + xb + xc + xd */
xa_out = xa + xb + xc + xd;
/* ya' = ya + yb + yc + yd */
ya_out = ya + yb + yc + yd;
/* pointer updation for writing */
ptr1 = ptr1 - 8u;
/* writing xa' and ya' */
*ptr1++ = xa_out;
*ptr1++ = ya_out;
xc_out = (xa - xb + xc - xd);
yc_out = (ya - yb + yc - yd);
/* writing xc' and yc' */
*ptr1++ = xc_out;
*ptr1++ = yc_out;
xb_out = (xa + yb - xc - yd);
yb_out = (ya - xb - yc + xd);
/* writing xb' and yb' */
*ptr1++ = xb_out;
*ptr1++ = yb_out;
xd_out = (xa - yb - xc + yd);
yd_out = (ya + xb - yc - xd);
/* writing xd' and yd' */
*ptr1++ = xd_out;
*ptr1++ = yd_out;
} while(--j);
/* output is in 11.21(q21) format for the 1024 point */
/* output is in 9.23(q23) format for the 256 point */
/* output is in 7.25(q25) format for the 64 point */
/* output is in 5.27(q27) format for the 16 point */
/* End of last stage process */
}
/**
* @brief Core function for the Q31 CIFFT butterfly process.
* @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
* @param[in] fftLen length of the FFT.
* @param[in] *pCoef points to twiddle coefficient buffer.
* @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
* @return none.
*/
/*
* Radix-4 IFFT algorithm used is :
*
* CIFFT uses same twiddle coefficients as CFFT Function
* x[k] = x[n] + (j)k * x[n + fftLen/4] + (-1)k * x[n+fftLen/2] + (-j)k * x[n+3*fftLen/4]
*
*
* IFFT is implemented with following changes in equations from FFT
*
* Input real and imaginary data:
* x(n) = xa + j * ya
* x(n+N/4 ) = xb + j * yb
* x(n+N/2 ) = xc + j * yc
* x(n+3N 4) = xd + j * yd
*
*
* Output real and imaginary data:
* x(4r) = xa'+ j * ya'
* x(4r+1) = xb'+ j * yb'
* x(4r+2) = xc'+ j * yc'
* x(4r+3) = xd'+ j * yd'
*
*
* Twiddle factors for radix-4 IFFT:
* Wn = co1 + j * (si1)
* W2n = co2 + j * (si2)
* W3n = co3 + j * (si3)
* The real and imaginary output values for the radix-4 butterfly are
* xa' = xa + xb + xc + xd
* ya' = ya + yb + yc + yd
* xb' = (xa-yb-xc+yd)* co1 - (ya+xb-yc-xd)* (si1)
* yb' = (ya+xb-yc-xd)* co1 + (xa-yb-xc+yd)* (si1)
* xc' = (xa-xb+xc-xd)* co2 - (ya-yb+yc-yd)* (si2)
* yc' = (ya-yb+yc-yd)* co2 + (xa-xb+xc-xd)* (si2)
* xd' = (xa+yb-xc-yd)* co3 - (ya-xb-yc+xd)* (si3)
* yd' = (ya-xb-yc+xd)* co3 + (xa+yb-xc-yd)* (si3)
*
*/
void arm_radix4_butterfly_inverse_q31(
q31_t * pSrc,
uint32_t fftLen,
q31_t * pCoef,
uint32_t twidCoefModifier)
{
uint32_t n1, n2, ia1, ia2, ia3, i0, i1, i2, i3, j, k;
q31_t t1, t2, r1, r2, s1, s2, co1, co2, co3, si1, si2, si3;
q31_t xa, xb, xc, xd;
q31_t ya, yb, yc, yd;
q31_t xa_out, xb_out, xc_out, xd_out;
q31_t ya_out, yb_out, yc_out, yd_out;
q31_t *ptr1;
q63_t xaya, xbyb, xcyc, xdyd;
/* input is be 1.31(q31) format for all FFT sizes */
/* Total process is divided into three stages */
/* process first stage, middle stages, & last stage */
/* Start of first stage process */
/* Initializations for the first stage */
n2 = fftLen;
n1 = n2;
/* n2 = fftLen/4 */
n2 >>= 2u;
i0 = 0u;
ia1 = 0u;
j = n2;
do
{
/* input is in 1.31(q31) format and provide 4 guard bits for the input */
/* index calculation for the input as, */
/* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2u], pSrc[i0 + 3fftLen/4] */
i1 = i0 + n2;
i2 = i1 + n2;
i3 = i2 + n2;
/* Butterfly implementation */
/* xa + xc */
r1 = (pSrc[2u * i0] >> 4u) + (pSrc[2u * i2] >> 4u);
/* xa - xc */
r2 = (pSrc[2u * i0] >> 4u) - (pSrc[2u * i2] >> 4u);
/* xb + xd */
t1 = (pSrc[2u * i1] >> 4u) + (pSrc[2u * i3] >> 4u);
/* ya + yc */
s1 = (pSrc[(2u * i0) + 1u] >> 4u) + (pSrc[(2u * i2) + 1u] >> 4u);
/* ya - yc */
s2 = (pSrc[(2u * i0) + 1u] >> 4u) - (pSrc[(2u * i2) + 1u] >> 4u);
/* xa' = xa + xb + xc + xd */
pSrc[2u * i0] = (r1 + t1);
/* (xa + xc) - (xb + xd) */
r1 = r1 - t1;
/* yb + yd */
t2 = (pSrc[(2u * i1) + 1u] >> 4u) + (pSrc[(2u * i3) + 1u] >> 4u);
/* ya' = ya + yb + yc + yd */
pSrc[(2u * i0) + 1u] = (s1 + t2);
/* (ya + yc) - (yb + yd) */
s1 = s1 - t2;
/* yb - yd */
t1 = (pSrc[(2u * i1) + 1u] >> 4u) - (pSrc[(2u * i3) + 1u] >> 4u);
/* xb - xd */
t2 = (pSrc[2u * i1] >> 4u) - (pSrc[2u * i3] >> 4u);
/* index calculation for the coefficients */
ia2 = 2u * ia1;
co2 = pCoef[ia2 * 2u];
si2 = pCoef[(ia2 * 2u) + 1u];
/* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
pSrc[2u * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32)) -
((int32_t) (((q63_t) s1 * si2) >> 32))) << 1u;
/* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
pSrc[2u * i1 + 1u] = (((int32_t) (((q63_t) s1 * co2) >> 32)) +
((int32_t) (((q63_t) r1 * si2) >> 32))) << 1u;
/* (xa - xc) - (yb - yd) */
r1 = r2 - t1;
/* (xa - xc) + (yb - yd) */
r2 = r2 + t1;
/* (ya - yc) + (xb - xd) */
s1 = s2 + t2;
/* (ya - yc) - (xb - xd) */
s2 = s2 - t2;
co1 = pCoef[ia1 * 2u];
si1 = pCoef[(ia1 * 2u) + 1u];
/* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
pSrc[2u * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) -
((int32_t) (((q63_t) s1 * si1) >> 32))) << 1u;
/* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
pSrc[(2u * i2) + 1u] = (((int32_t) (((q63_t) s1 * co1) >> 32)) +
((int32_t) (((q63_t) r1 * si1) >> 32))) << 1u;
/* index calculation for the coefficients */
ia3 = 3u * ia1;
co3 = pCoef[ia3 * 2u];
si3 = pCoef[(ia3 * 2u) + 1u];
/* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
pSrc[2u * i3] = (((int32_t) (((q63_t) r2 * co3) >> 32)) -
((int32_t) (((q63_t) s2 * si3) >> 32))) << 1u;
/* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
pSrc[(2u * i3) + 1u] = (((int32_t) (((q63_t) s2 * co3) >> 32)) +
((int32_t) (((q63_t) r2 * si3) >> 32))) << 1u;
/* Twiddle coefficients index modifier */
ia1 = ia1 + twidCoefModifier;
/* Updating input index */
i0 = i0 + 1u;
} while(--j);
/* data is in 5.27(q27) format */
/* each stage provides two down scaling of the input */
/* Start of Middle stages process */
twidCoefModifier <<= 2u;
/* Calculation of second stage to excluding last stage */
for (k = fftLen / 4u; k > 4u; k >>= 2u)
{
/* Initializations for the first stage */
n1 = n2;
n2 >>= 2u;
ia1 = 0u;
for (j = 0; j <= (n2 - 1u); j++)
{
/* index calculation for the coefficients */
ia2 = ia1 + ia1;
ia3 = ia2 + ia1;
co1 = pCoef[ia1 * 2u];
si1 = pCoef[(ia1 * 2u) + 1u];
co2 = pCoef[ia2 * 2u];
si2 = pCoef[(ia2 * 2u) + 1u];
co3 = pCoef[ia3 * 2u];
si3 = pCoef[(ia3 * 2u) + 1u];
/* Twiddle coefficients index modifier */
ia1 = ia1 + twidCoefModifier;
for (i0 = j; i0 < fftLen; i0 += n1)
{
/* index calculation for the input as, */
/* pSrc[i0 + 0], pSrc[i0 + fftLen/4], pSrc[i0 + fftLen/2u], pSrc[i0 + 3fftLen/4] */
i1 = i0 + n2;
i2 = i1 + n2;
i3 = i2 + n2;
/* Butterfly implementation */
/* xa + xc */
r1 = pSrc[2u * i0] + pSrc[2u * i2];
/* xa - xc */
r2 = pSrc[2u * i0] - pSrc[2u * i2];
/* ya + yc */
s1 = pSrc[(2u * i0) + 1u] + pSrc[(2u * i2) + 1u];
/* ya - yc */
s2 = pSrc[(2u * i0) + 1u] - pSrc[(2u * i2) + 1u];
/* xb + xd */
t1 = pSrc[2u * i1] + pSrc[2u * i3];
/* xa' = xa + xb + xc + xd */
pSrc[2u * i0] = (r1 + t1) >> 2u;
/* xa + xc -(xb + xd) */
r1 = r1 - t1;
/* yb + yd */
t2 = pSrc[(2u * i1) + 1u] + pSrc[(2u * i3) + 1u];
/* ya' = ya + yb + yc + yd */
pSrc[(2u * i0) + 1u] = (s1 + t2) >> 2u;
/* (ya + yc) - (yb + yd) */
s1 = s1 - t2;
/* (yb - yd) */
t1 = pSrc[(2u * i1) + 1u] - pSrc[(2u * i3) + 1u];
/* (xb - xd) */
t2 = pSrc[2u * i1] - pSrc[2u * i3];
/* xc' = (xa-xb+xc-xd)co2 - (ya-yb+yc-yd)(si2) */
pSrc[2u * i1] = (((int32_t) (((q63_t) r1 * co2) >> 32u)) -
((int32_t) (((q63_t) s1 * si2) >> 32u))) >> 1u;
/* yc' = (ya-yb+yc-yd)co2 + (xa-xb+xc-xd)(si2) */
pSrc[(2u * i1) + 1u] =
(((int32_t) (((q63_t) s1 * co2) >> 32u)) +
((int32_t) (((q63_t) r1 * si2) >> 32u))) >> 1u;
/* (xa - xc) - (yb - yd) */
r1 = r2 - t1;
/* (xa - xc) + (yb - yd) */
r2 = r2 + t1;
/* (ya - yc) + (xb - xd) */
s1 = s2 + t2;
/* (ya - yc) - (xb - xd) */
s2 = s2 - t2;
/* xb' = (xa+yb-xc-yd)co1 - (ya-xb-yc+xd)(si1) */
pSrc[2u * i2] = (((int32_t) (((q63_t) r1 * co1) >> 32)) -
((int32_t) (((q63_t) s1 * si1) >> 32))) >> 1u;
/* yb' = (ya-xb-yc+xd)co1 + (xa+yb-xc-yd)(si1) */
pSrc[(2u * i2) + 1u] = (((int32_t) (((q63_t) s1 * co1) >> 32)) +
((int32_t) (((q63_t) r1 * si1) >> 32))) >> 1u;
/* xd' = (xa-yb-xc+yd)co3 - (ya+xb-yc-xd)(si3) */
pSrc[(2u * i3)] = (((int32_t) (((q63_t) r2 * co3) >> 32)) -
((int32_t) (((q63_t) s2 * si3) >> 32))) >> 1u;
/* yd' = (ya+xb-yc-xd)co3 + (xa-yb-xc+yd)(si3) */
pSrc[(2u * i3) + 1u] = (((int32_t) (((q63_t) s2 * co3) >> 32)) +
((int32_t) (((q63_t) r2 * si3) >> 32))) >> 1u;
}
}
twidCoefModifier <<= 2u;
}
/* End of Middle stages process */
/* data is in 11.21(q21) format for the 1024 point as there are 3 middle stages */
/* data is in 9.23(q23) format for the 256 point as there are 2 middle stages */
/* data is in 7.25(q25) format for the 64 point as there are 1 middle stage */
/* data is in 5.27(q27) format for the 16 point as there are no middle stages */
/* Start of last stage process */
/* Initializations for the last stage */
j = fftLen >> 2;
ptr1 = &pSrc[0];
/* Calculations of last stage */
do
{
#ifndef ARM_MATH_BIG_ENDIAN
/* Read xa (real), ya(imag) input */
xaya = *__SIMD64(ptr1)++;
xa = (q31_t) xaya;
ya = (q31_t) (xaya >> 32);
/* Read xb (real), yb(imag) input */
xbyb = *__SIMD64(ptr1)++;
xb = (q31_t) xbyb;
yb = (q31_t) (xbyb >> 32);
/* Read xc (real), yc(imag) input */
xcyc = *__SIMD64(ptr1)++;
xc = (q31_t) xcyc;
yc = (q31_t) (xcyc >> 32);
/* Read xc (real), yc(imag) input */
xdyd = *__SIMD64(ptr1)++;
xd = (q31_t) xdyd;
yd = (q31_t) (xdyd >> 32);
#else
/* Read xa (real), ya(imag) input */
xaya = *__SIMD64(ptr1)++;
ya = (q31_t) xaya;
xa = (q31_t) (xaya >> 32);
/* Read xb (real), yb(imag) input */
xbyb = *__SIMD64(ptr1)++;
yb = (q31_t) xbyb;
xb = (q31_t) (xbyb >> 32);
/* Read xc (real), yc(imag) input */
xcyc = *__SIMD64(ptr1)++;
yc = (q31_t) xcyc;
xc = (q31_t) (xcyc >> 32);
/* Read xc (real), yc(imag) input */
xdyd = *__SIMD64(ptr1)++;
yd = (q31_t) xdyd;
xd = (q31_t) (xdyd >> 32);
#endif
/* xa' = xa + xb + xc + xd */
xa_out = xa + xb + xc + xd;
/* ya' = ya + yb + yc + yd */
ya_out = ya + yb + yc + yd;
/* pointer updation for writing */
ptr1 = ptr1 - 8u;
/* writing xa' and ya' */
*ptr1++ = xa_out;
*ptr1++ = ya_out;
xc_out = (xa - xb + xc - xd);
yc_out = (ya - yb + yc - yd);
/* writing xc' and yc' */
*ptr1++ = xc_out;
*ptr1++ = yc_out;
xb_out = (xa - yb - xc + yd);
yb_out = (ya + xb - yc - xd);
/* writing xb' and yb' */
*ptr1++ = xb_out;
*ptr1++ = yb_out;
xd_out = (xa + yb - xc - yd);
yd_out = (ya - xb - yc + xd);
/* writing xd' and yd' */
*ptr1++ = xd_out;
*ptr1++ = yd_out;
} while(--j);
/* output is in 11.21(q21) format for the 1024 point */
/* output is in 9.23(q23) format for the 256 point */
/* output is in 7.25(q25) format for the 64 point */
/* output is in 5.27(q27) format for the 16 point */
/* End of last stage process */
}
| 28.786996 | 142 | 0.466586 |
82d6e5383685bd0623e7a20de51c8ad5491475ed | 8,894 | c | C | sdk-6.5.16/src/soc/esw/tomahawk2/flexport/tomahawk2_mmu_port_resequence.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.16/src/soc/esw/tomahawk2/flexport/tomahawk2_mmu_port_resequence.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.16/src/soc/esw/tomahawk2/flexport/tomahawk2_mmu_port_resequence.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2019 Broadcom Inc. All rights reserved.
*
* $File: tomahawk2_mmu_port_resequence.c
*/
#include <shared/bsl.h>
#include <soc/drv.h>
#include <soc/defs.h>
#include <soc/mem.h>
#include <soc/esw/port.h>
#include <soc/tdm/core/tdm_top.h>
#if defined(BCM_TOMAHAWK2_SUPPORT)
#include <soc/tomahawk2.h>
#include <soc/tomahawk.h>
#include <soc/tomahawk2_tdm.h>
/*! @file tomahawk2_mmu_port_resequence.c
* @brief
*/
#include <soc/flexport/tomahawk2_flexport.h>
/*! @fn int soc_tomahawk2_mmu_set_mmu_to_phy_port_mapping(int unit,
* soc_port_resource_t *port_resource_t)
* @param unit Device number
* @param *port_resource_t Port Resource Struct
* @brief API to update the mmu port to physical port mapping during port
* up and port down operations in flexport.
*/
int
soc_tomahawk2_mmu_set_mmu_to_phy_port_mapping(
int unit,soc_port_resource_t *port_resource_t)
{
int mmu_port;
uint64 phy_port_new, dev_port_new;
soc_reg_t reg;
uint64 rval;
int inst;
COMPILER_64_SET(phy_port_new, 0, 0);
COMPILER_64_SET(dev_port_new, 0, 0);
mmu_port = port_resource_t->mmu_port;
inst = mmu_port;
/* When a physical port goes down, the port resource struct phy port number
* becomes -1. That time, we need to invalidate the phy port to 'hff When
* a port is coming back up, the struct is populated correctly.
*/
if (port_resource_t->physical_port == -1) {
COMPILER_64_SET(phy_port_new, 0, TH2_INVALID_PHY_PORT_NUMBER); /* All 1's */
}
else {
COMPILER_64_SET(phy_port_new, 0, port_resource_t->physical_port);
COMPILER_64_SET(dev_port_new, 0, port_resource_t->logical_port);
}
reg= MMU_PORT_TO_PHY_PORT_MAPPINGr;
COMPILER_64_ZERO(rval);
soc_reg64_field_set(unit, reg, &rval, PHY_PORTf, phy_port_new);
/* BT:IPORT, AT: SINGLE, Block ID: MMU_GLOBAL */
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, reg, inst, 0, rval));
if (port_resource_t->physical_port != -1) {
reg= MMU_PORT_TO_DEVICE_PORT_MAPPINGr;
COMPILER_64_ZERO(rval);
soc_reg64_field_set(unit, reg, &rval, DEVICE_PORTf, dev_port_new);
/* BT:IPORT, AT: SINGLE, Block ID: MMU_GLOBAL */
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, reg, inst, 0, rval));
}
return SOC_E_NONE;
}
/*! @fn int soc_tomahawk2_mmu_vbs_port_flush(int unit,
* soc_port_resource_t *port_resource_t, int set_val)
* @param unit Device number
* @param *port_resource_t Port Resource Struct
* @param set_val Value to be set to the port flush register
* @brief API to Set the Port Flush register
*/
int
soc_tomahawk2_mmu_vbs_port_flush(int unit,soc_port_resource_t *port_resource_t,
uint64 set_val)
{
soc_reg_t reg;
uint64 rval;
uint64 enable_val;
int mmu_port, lcl_mmu_port;
int pipe_number, inst;
reg = Q_SCHED_PORT_FLUSHr;
pipe_number = port_resource_t->pipe;
mmu_port = port_resource_t->mmu_port;
lcl_mmu_port = mmu_port % TH2_MMU_PORT_PIPE_OFFSET;
/* READ MODIFY WRITE IN SW ... Hence get Register
Value and Then Write ... */
COMPILER_64_ZERO(rval);
inst = pipe_number;
SOC_IF_ERROR_RETURN(soc_reg_rawport_get(unit, reg,
inst, 0, &rval));
enable_val = soc_reg64_field_get(unit, reg,
rval, ENABLEf);
if (COMPILER_64_IS_ZERO(set_val) == 1) {
COMPILER_64_BITCLR(enable_val, lcl_mmu_port);
}
else {
COMPILER_64_BITSET(enable_val, lcl_mmu_port);
}
soc_reg64_field_set(unit, reg, &rval, ENABLEf, enable_val);
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, reg, inst, 0, rval));
return SOC_E_NONE;
}
/*! @fn int soc_tomahawk2_mmu_rqe_port_flush(int unit,
* soc_port_resource_t *port_resource_t, int phy_port, int set_val)
* @param unit Device number
* @param *port_resource_t Port Resource Struct
* @param set_val Value to be set to the snapshot register
* @param phy_port Only valid for port disabling case. Physical port number of the port to be down
* @brief API to Set the RQE Snapshot register to Flush out packets in the
* RQE Replication FIFO
*/
int
soc_tomahawk2_mmu_rqe_port_flush(int unit,soc_port_resource_t *port_resource_t,
int phy_port, uint64 set_val)
{
soc_reg_t reg;
uint64 rval;
uint64 enable_val;
int count=0, count1=0;
uint64 rd_val;
int pipe_number, inst;
uint64 rval64, fldval64;
uint32 entry[SOC_MAX_MEM_WORDS];
uint32 cell_requests;
reg = Q_SCHED_RQE_SNAPSHOTr;
pipe_number = port_resource_t->pipe;
inst = pipe_number;
enable_val = set_val;
COMPILER_64_ZERO(rval);
soc_reg64_field_set(unit, reg, &rval, INITIATEf, enable_val);
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, reg, inst, 0, rval));
while (1) {
SOC_IF_ERROR_RETURN(soc_reg_rawport_get(unit, reg,
inst, 0, &rval));
rd_val = soc_reg64_field_get(unit, reg,
rval, INITIATEf);
if (COMPILER_64_IS_ZERO(rd_val)) {
break;
}
sal_usleep(1 + (SAL_BOOT_QUICKTURN ? 1 : 0) * EMULATION_FACTOR);
count++;
if (count > 10000) {
count1++;
SOC_IF_ERROR_RETURN
(soc_mem_read(unit, EGR_PORT_REQUESTSm,
MEM_BLOCK_ANY, phy_port, entry));
cell_requests = soc_mem_field32_get(unit, EGR_PORT_REQUESTSm, entry,
OUTSTANDING_PORT_REQUESTSf);
if ((count1 == 1) && (cell_requests == 0)) {
/* Hold MAC in reset state */
SOC_IF_ERROR_RETURN
(soc_reg_rawport_get(unit, CLMAC_CTRLr, phy_port,0,
&rval64));
COMPILER_64_SET(fldval64, 0, 1);
soc_reg64_field_set(unit, CLMAC_CTRLr, &rval64, SOFT_RESETf,
fldval64);
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, CLMAC_CTRLr,
phy_port, 0, rval64));
/* Remove MAC reset */
SOC_IF_ERROR_RETURN(soc_reg_rawport_get(unit, CLMAC_CTRLr,
phy_port, 0, &rval64));
COMPILER_64_ZERO(fldval64);
soc_reg64_field_set(unit, CLMAC_CTRLr, &rval64, SOFT_RESETf,
fldval64);
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, CLMAC_CTRLr,
phy_port,0, rval64));
count=0;
continue;
}
LOG_ERROR(BSL_LS_SOC_COMMON,
(BSL_META_U(unit,
"Initiate isn't reset even after 1000 "
"iterations")));
return SOC_E_FAIL;
}
}
return SOC_E_NONE;
}
/*! @fn int soc_tomahawk2_mmu_mtro_port_flush(int unit,
* soc_port_resource_t *port_resource_t, int set_val)
* @param unit Device number
* @param *port_resource_t Port Resource Struct
* @param set_val Value to be set to the snapshot register
* @brief This function is used to set the MTRO Port Flush register to
* ignore shaper information on a port during flexport operation
*/
int
soc_tomahawk2_mmu_mtro_port_flush(int unit,soc_port_resource_t *port_resource_t,
uint64 set_val)
{
soc_reg_t reg;
uint64 rval;
int mmu_port, lcl_mmu_port;
int pipe_number, inst;
uint64 enable_val;
reg = MTRO_PORT_ENTITY_DISABLEr;
pipe_number = port_resource_t->pipe;
mmu_port = port_resource_t->mmu_port;
lcl_mmu_port = mmu_port % TH2_MMU_PORT_PIPE_OFFSET;
/* READ MODIFY WRITE IN SW ... Hence get
Register Value and Then Write .. */
inst = pipe_number;
SOC_IF_ERROR_RETURN(soc_reg_rawport_get(unit, reg,
inst, 0, &rval));
enable_val = soc_reg64_field_get(unit, reg,
rval, METERING_DISABLEf);
if (COMPILER_64_IS_ZERO(set_val) == 1) {
COMPILER_64_BITCLR(enable_val, lcl_mmu_port);
}
else {
COMPILER_64_BITSET(enable_val, lcl_mmu_port);
}
COMPILER_64_ZERO(rval);
soc_reg64_field_set(unit, reg, &rval, METERING_DISABLEf, enable_val);
SOC_IF_ERROR_RETURN(soc_reg_rawport_set(unit, reg, inst, 0, rval));
return SOC_E_NONE;
}
#endif /* BCM_TOMAHAWK2_SUPPORT */
| 32.698529 | 133 | 0.626265 |
89d5fc283aed3cd86cc1ea1a8dcb6ef6a71532f2 | 2,372 | h | C | src/isolate/inspector.h | vugluskr86/isolated-vm | 6a204868374dd794e3f2170cc2bff938eaf6db96 | [
"0BSD"
] | null | null | null | src/isolate/inspector.h | vugluskr86/isolated-vm | 6a204868374dd794e3f2170cc2bff938eaf6db96 | [
"0BSD"
] | null | null | null | src/isolate/inspector.h | vugluskr86/isolated-vm | 6a204868374dd794e3f2170cc2bff938eaf6db96 | [
"0BSD"
] | null | null | null | #pragma once
#include <v8.h>
#include "./v8_inspector_wrapper.h"
#include <condition_variable>
#include <memory>
#include <mutex>
#include <unordered_set>
namespace ivm {
class IsolateEnvironment;
class InspectorSession;
/**
* This handles communication to the v8 backend. There is only one of these per isolate, but many
* sessions may connect to this agent.
*
* This class combines the role of both V8Inspector and V8InspectorClient into a single class.
*/
class InspectorAgent : public v8_inspector::V8InspectorClient {
friend class InspectorSession;
private:
IsolateEnvironment& isolate;
std::unique_ptr<v8_inspector::V8Inspector> inspector;
std::condition_variable cv;
std::mutex mutex;
struct {
std::mutex mutex;
std::unordered_set<InspectorSession*> active;
} sessions;
bool running = false;
std::unique_ptr<v8_inspector::V8InspectorSession> ConnectSession(InspectorSession& session);
void SessionDisconnected(InspectorSession& session);
void SendInterrupt(std::unique_ptr<class Runnable> task);
public:
explicit InspectorAgent(IsolateEnvironment& isolate);
~InspectorAgent() override;
InspectorAgent(const InspectorAgent&) = delete;
InspectorAgent& operator= (const InspectorAgent&) = delete;
void runMessageLoopOnPause(int context_group_id) final;
void quitMessageLoopOnPause() final;
void ContextCreated(v8::Local<v8::Context> context, const std::string& name);
void ContextDestroyed(v8::Local<v8::Context> context);
bool WaitForLoop();
};
/**
* Individual session to the v8 inspector agent. This probably relays messages from a websocket to
* the v8 backend. To use the class you need to implement the abstract methods defined in Channel.
*
* This class combines the role of both V8Inspector::Channel and V8InspectorSession into a single
* class.
*/
class InspectorSession : public v8_inspector::V8Inspector::Channel {
friend class InspectorAgent;
private:
InspectorAgent& agent;
std::shared_ptr<v8_inspector::V8InspectorSession> session;
std::mutex mutex;
public:
explicit InspectorSession(IsolateEnvironment& isolate);
~InspectorSession() override;
InspectorSession(const InspectorSession&) = delete;
InspectorSession& operator= (const InspectorSession&) = delete;
void Disconnect();
void DispatchBackendProtocolMessage(std::vector<uint16_t> message);
};
} // namespace ivm
| 33.408451 | 98 | 0.772344 |
683dbd4a22ee9d2fb58c8bbb6589c777c00af61c | 1,210 | h | C | util.h | kzwkt/foot | 94f0b7283a4fba57788c753380afe1fc752351de | [
"MIT"
] | null | null | null | util.h | kzwkt/foot | 94f0b7283a4fba57788c753380afe1fc752351de | [
"MIT"
] | null | null | null | util.h | kzwkt/foot | 94f0b7283a4fba57788c753380afe1fc752351de | [
"MIT"
] | null | null | null | #pragma once
#include <stdint.h>
#include <threads.h>
#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
static inline const char *
thrd_err_as_string(int thrd_err)
{
switch (thrd_err) {
case thrd_success: return "success";
case thrd_busy: return "busy";
case thrd_nomem: return "no memory";
case thrd_timedout: return "timedout";
case thrd_error:
default: return "unknown error";
}
return "unknown error";
}
static inline uint64_t
sdbm_hash(const char *s)
{
uint64_t hash = 0;
for (; *s != '\0'; s++) {
int c = *s;
hash = c + (hash << 6) + (hash << 16) - hash;
}
return hash;
}
enum {
HEX_DIGIT_INVALID = 16
};
static inline uint8_t
hex2nibble(char c)
{
switch (c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return c - '0';
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
return c - 'a' + 10;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
return c - 'A' + 10;
}
return HEX_DIGIT_INVALID;
}
| 20.166667 | 63 | 0.533058 |
d05281c2eb04cee14573222e03f1b9affbcd22bc | 1,538 | c | C | benchmarks/rdoc/ruby_trunk/ext/openssl/ossl_bio.c | acangiano/ruby-benchmark-suite | 314ae79f97110a6ee1248dcdf2c4ac2ee4778dec | [
"MIT"
] | 19 | 2015-01-23T03:27:08.000Z | 2021-03-19T00:42:42.000Z | benchmarks/rdoc/ruby_trunk/ext/openssl/ossl_bio.c | tmtm/ruby-benchmark-suite | 314ae79f97110a6ee1248dcdf2c4ac2ee4778dec | [
"MIT"
] | null | null | null | benchmarks/rdoc/ruby_trunk/ext/openssl/ossl_bio.c | tmtm/ruby-benchmark-suite | 314ae79f97110a6ee1248dcdf2c4ac2ee4778dec | [
"MIT"
] | 4 | 2015-03-09T03:57:29.000Z | 2019-09-14T03:34:08.000Z | /*
* $Id: ossl_bio.c 25189 2009-10-02 12:04:37Z akr $
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
*/
/*
* This program is licenced under the same licence as Ruby.
* (See the file 'LICENCE'.)
*/
#include "ossl.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
BIO *
ossl_obj2bio(VALUE obj)
{
BIO *bio;
if (TYPE(obj) == T_FILE) {
rb_io_t *fptr;
FILE *fp;
int fd;
GetOpenFile(obj, fptr);
rb_io_check_readable(fptr);
if ((fd = dup(FPTR_TO_FD(fptr))) < 0){
rb_sys_fail(0);
}
if (!(fp = fdopen(fd, "r"))){
close(fd);
rb_sys_fail(0);
}
if (!(bio = BIO_new_fp(fp, BIO_CLOSE))){
fclose(fp);
ossl_raise(eOSSLError, NULL);
}
}
else {
StringValue(obj);
bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LEN(obj));
if (!bio) ossl_raise(eOSSLError, NULL);
}
return bio;
}
BIO *
ossl_protect_obj2bio(VALUE obj, int *status)
{
BIO *ret = NULL;
ret = (BIO*)rb_protect((VALUE(*)_((VALUE)))ossl_obj2bio, obj, status);
return ret;
}
VALUE
ossl_membio2str0(BIO *bio)
{
VALUE ret;
BUF_MEM *buf;
BIO_get_mem_ptr(bio, &buf);
ret = rb_str_new(buf->data, buf->length);
return ret;
}
VALUE
ossl_protect_membio2str(BIO *bio, int *status)
{
return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str0, (VALUE)bio, status);
}
VALUE
ossl_membio2str(BIO *bio)
{
VALUE ret;
int status = 0;
ret = ossl_protect_membio2str(bio, &status);
BIO_free(bio);
if(status) rb_jump_tag(status);
return ret;
}
| 17.678161 | 80 | 0.631339 |
a9bd62057c600c9dbdf82fe8b525500e8210c86f | 150 | h | C | cpp-state-machine-framework/actions/ByDefault.h | tucher/cpp-state-machine-framework | 0919bad5dfb22004a84c1bdc442882b221bcf7f0 | [
"MIT"
] | 37 | 2019-12-28T20:50:20.000Z | 2021-12-27T16:50:47.000Z | cpp-state-machine-framework/actions/ByDefault.h | tucher/cpp-state-machine-framework | 0919bad5dfb22004a84c1bdc442882b221bcf7f0 | [
"MIT"
] | null | null | null | cpp-state-machine-framework/actions/ByDefault.h | tucher/cpp-state-machine-framework | 0919bad5dfb22004a84c1bdc442882b221bcf7f0 | [
"MIT"
] | 7 | 2020-07-28T11:34:32.000Z | 2021-11-17T04:21:59.000Z | #pragma once
template <typename Action>
struct ByDefault
{
template <typename Event>
Action handle(const Event&) const
{
return Action{};
}
};
| 12.5 | 34 | 0.713333 |
b79ed38d610c570f1684151cc36422ad7bef7eb3 | 4,531 | h | C | openbsd/sys/arch/mvmeppc/include/powerpc.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 91 | 2015-01-05T15:18:31.000Z | 2022-03-11T16:43:28.000Z | openbsd/sys/arch/mvmeppc/include/powerpc.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 1 | 2016-02-25T15:57:55.000Z | 2016-02-25T16:01:02.000Z | openbsd/sys/arch/mvmeppc/include/powerpc.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 21 | 2015-02-07T08:23:07.000Z | 2021-12-14T06:01:49.000Z | /* $OpenBSD: powerpc.h,v 1.1 2001/06/26 21:57:47 smurph Exp $ */
/* $NetBSD: powerpc.h,v 1.1 1996/09/30 16:34:30 ws Exp $ */
/*
* Copyright (C) 1996 Wolfgang Solfrank.
* Copyright (C) 1996 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MACHINE_POWERPC_H_
#define _MACHINE_POWERPC_H_
struct mem_region {
vm_offset_t start;
vm_size_t size;
};
void mem_regions __P((struct mem_region **, struct mem_region **));
/*
* These two functions get used solely in boot() in machdep.c.
*
* Not sure whether boot itself should be implementation dependent instead. XXX
*/
typedef void (exit_f) __P((void)) /*__attribute__((__noreturn__))*/ ;
typedef void (boot_f) __P((char *bootspec)) /* __attribute__((__noreturn__))*/ ;
typedef void (vmon_f) __P((void));
typedef unsigned char (nvram_rd_f) __P((unsigned long offset));
typedef void (nvram_wr_f) __P((unsigned long offset, unsigned char val));
typedef unsigned long (tps_f) __P((void));
typedef void (mem_regions_f) __P((struct mem_region **memp,
struct mem_region **availp));
typedef int (clock_read_f) __P((int *sec, int *min, int *hour, int *day,
int *mon, int *yr));
typedef int (clock_write_f) __P((int sec, int min, int hour, int day,
int mon, int yr));
typedef int (time_read_f) __P((u_long *sec));
typedef int (time_write_f) __P((u_long sec));
/* firmware interface.
* regardless of type of firmware used several items
* are need from firmware to boot up.
* these include:
* memory information
* vmsetup for firmware calls.
* default character print mechanism ???
* firmware exit (return)
* firmware boot (reset)
* vmon - tell firmware the bsd vm is active.
*/
struct firmware {
mem_regions_f *mem_regions;
exit_f *exit;
boot_f *boot;
vmon_f *vmon;
nvram_rd_f *nvram_rd;
nvram_wr_f *nvram_wr;
tps_f *tps;
clock_read_f *clock_read;
clock_write_f *clock_write;
time_read_f *time_read;
time_write_f *time_write;
#ifdef FW_HAS_PUTC
boot_f *putc;
#endif
};
extern struct firmware *fw;
#define ppc_exit() if (fw->exit != NULL) (fw->exit)()
#define ppc_boot(x) if (fw->boot != NULL) (fw->boot)(x)
#define ppc_vmon() if (fw->vmon != NULL) (fw->vmon)()
#define ppc_nvram_rd(a) ({unsigned char val; \
if (fw->nvram_rd !=NULL) \
val = (fw->nvram_rd)(a); \
else \
val = 0; \
val;})
#define ppc_nvram_wr(a, v) if (fw->nvram_wr !=NULL) (fw->nvram_wr)(a, v)
#define ppc_tps() ({unsigned long val; \
if (fw->tps != NULL) \
val = (fw->tps)(); \
else \
val = 0; \
val;})
#define SPR_XER "1"
#define SPR_LR "8"
#define SPR_CTR "9"
#define SPR_DSISR "18"
#define SPR_DAR "19"
#define SPR_DEC "22"
#define SPR_SDR1 "25"
#define SPR_SRR0 "26"
#define SPR_SRR1 "27"
#define ppc_get_spr(reg) ({u_int32_t val; \
__asm__ volatile("mfspr %0," reg : "=r"(val)); \
val;})
#define ppc_set_spr(reg, val) ({ \
__asm__ volatile("mtspr " reg ",%0" :: "r"(val));})
#endif /* _MACHINE_POWERPC_H_ */
| 34.067669 | 80 | 0.705804 |
a10d1f5c1a367ab55fe7fcfa828f44e77abbef1d | 2,895 | c | C | proj/PN532_PICC_Emulate/main.c | ZeeLivermorium/PN532_TM4C123GXL | acaa025814bec68977b373dba47176413fe811e8 | [
"MIT"
] | 1 | 2017-12-22T16:54:48.000Z | 2017-12-22T16:54:48.000Z | proj/PN532_PICC_Emulate/main.c | ZeeLivermorium/PN532_TM4C123GXL | acaa025814bec68977b373dba47176413fe811e8 | [
"MIT"
] | null | null | null | proj/PN532_PICC_Emulate/main.c | ZeeLivermorium/PN532_TM4C123GXL | acaa025814bec68977b373dba47176413fe811e8 | [
"MIT"
] | null | null | null | /*!
* @file main.c
* @brief emulate PN532 as NDEF tag.
* ----------
* Adapted code from Seeed Studio PN532 driver for Arduino.
* You can find the Seeed Studio PN532 driver here: https://github.com/Seeed-Studio/PN532
* ----------
* NXP PN532 Data Sheet: https://www.nxp.com/docs/en/nxp/data-sheets/PN532_C1.pdf
* NXP PN532 User Manual: https://www.nxp.com/docs/en/user-guide/141520.pdf
* ----------
* For future development and updates, please follow this repository: https://github.com/ZeeLivermorium/PN532_TM4C123
* ----------
* If you find any bug or problem, please create new issue or a pull request with a fix in the repository.
* Or you can simply email me about the problem or bug at zeelivermorium@gmail.com
* Much Appreciated!
* ----------
* @author Zee Livermorium
* @date Nov 13, 2018
*/
#include <stdint.h>
#include <string.h>
#include "PLL.h"
#include "Serial.h"
#include "PN532.h"
#include "PN532_cardEmulation.h"
#include "NDEF_Message.h"
uint8_t ndef_data_buffer[120];
uint16_t ndef_data_length;
uint8_t uid[3] = { 0x12, 0x34, 0x56 };
int main (void) {
/*-- TM4C123 Init --*/
// bus clock at 80 MHz
PLL_Init(Bus80MHz);
// serial init for output anything to console
Serial_Init();
// NDEF Message struct to hold the NDEF records to be encoded and sent
NDEF_Message ndef_message;
// uri to be added
char* uri = "zeelivermorium.com";
// size of payload buffer = prefix byte (1) + size of uri + string termination byte (1)
char payload_buffer[ 1 + strlen(uri) + 1 ];
// append a new uri record to the ndef message
add_uri_record (&ndef_message, NDEF_URIPREFIX_HTTP_WWWDOT, uri, payload_buffer);
// get the size of encoded NDEF message
uint32_t ndef_message_size = NDEF_Message_getEncodedSize(ndef_message);
// encode ndef message and save the result to a buffer
NDEF_Message_encode(ndef_message, ndef_data_buffer);
// set the ndef file from the encoded message
emulation_setNDEFFile(ndef_data_buffer, ndef_message_size);
// set uid to be sent
emulation_setUid(uid);
/*-- PN532 Init --*/
// init communication and wake up PN532
PN532_Init();
uint32_t firmwareVersion = PN532_getFirmwareVersion();
// if not able to read version number, quit
if (!firmwareVersion) {
Serial_println("Did not find PN532 board :(");
// exit
return 0;
}
/* output firmware info */
Serial_println("");
Serial_println("Found PN5%x", (firmwareVersion >> 24) & 0xFF);
Serial_println("Firmware Version %u.%u", (firmwareVersion >> 16) & 0xFF, (firmwareVersion >> 8) & 0xFF);
Serial_println("-------------------------------");
PN532_SAMConfiguration();
/*-- loop --*/
while(1) {
emulate_card(0);
}
}
| 35.304878 | 118 | 0.641451 |
4e4d8c2b25e4598644297542b393af09a1c58467 | 6,133 | c | C | xpa-2.1.14/xpaset.c | odysseus9672/pysao | 883bf6fc8fa86ae8777d3ae31c8b466fde25c94a | [
"MIT"
] | 3 | 2015-03-20T03:52:34.000Z | 2021-08-18T12:55:22.000Z | xpa-2.1.14/xpaset.c | odysseus9672/pysao | 883bf6fc8fa86ae8777d3ae31c8b466fde25c94a | [
"MIT"
] | 3 | 2019-06-26T18:26:10.000Z | 2021-08-17T03:19:15.000Z | xpa-2.1.14/xpaset.c | odysseus9672/pysao | 883bf6fc8fa86ae8777d3ae31c8b466fde25c94a | [
"MIT"
] | 5 | 2017-05-04T15:57:00.000Z | 2021-05-03T13:26:36.000Z | /*
* Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
*/
#include <xpap.h>
extern char *optarg;
extern int optind;
#ifdef ANSI_FUNC
void
usage (char *s)
#else
void usage(s)
char *s;
#endif
{
fprintf(stderr, "\n");
fprintf(stderr, "usage:\n");
fprintf(stderr, " <data> | %s [-h] [-i nsinet] [-m method] [-n] [-p] [-s] [-t sval,lval] [-u users] <tmpl|host:port> [paramlist]\n", s);
fprintf(stderr, "\n");
fprintf(stderr, "switches:\n");
fprintf(stderr, "\t-h\tprint this message\n");
fprintf(stderr, "\t-i\toverride XPA_NSINET environment variable\n");
fprintf(stderr, "\t-m\toverride XPA_METHOD environment variable\n");
fprintf(stderr, "\t-n\tdon't wait for message after server completes\n");
fprintf(stderr, "\t-p\tdon't read (or send) buf data from stdin\n");
fprintf(stderr, "\t-s\tserver mode\n");
fprintf(stderr, "\t-t \toverride XPA_[SHORT,LONG]_TIMEOUT environment variables\n");
fprintf(stderr, "\t-u\toverride XPA_NSUSERS environment variable\n");
fprintf(stderr, "\t-v\tverify message to stdout\n");
fprintf(stderr, "\t--version display version and exit\n");
fprintf(stderr, "\n");
fprintf(stderr, "Data will be sent to access points matching the template or host:port.\n");
fprintf(stderr, "Templates are of the form [class:]name. Wildcards *,?,[] are accepted.\n");
fprintf(stderr, "A set of qualifying parameters can be appended.\n");
fprintf(stderr, "\n");
fprintf(stderr, "examples:\n");
fprintf(stderr, "\tcsh> xpaset ds9 fits foo.fits < foo.fits\n");
fprintf(stderr, "\tcsh> echo \"stop\" | xpaset bynars:28571\n");
fprintf(stderr, "\n(version: %s)\n", XPA_VERSION);
exit(1);
}
#ifdef ANSI_FUNC
int
main (int argc, char **argv)
#else
int
main(argc, argv)
int argc;
char **argv;
#endif
{
int i;
int c;
int got;
int lp;
int errcode=0;
int server=0;
int hmax=XPA_MAXHOSTS;
char *paramlist=NULL;
char *xtemplate=NULL;
char lbuf[SZ_LINE];
char tbuf[SZ_LINE];
char mode[SZ_LINE];
char cmd[SZ_LINE];
char *s;
char **errs=NULL;
char **names=NULL;
int fd;
XPA xpa=NULL;
/* display version and exit, if necessary */
if( (argc == 2) && !strcmp(argv[1], "--version") ){
fprintf(stderr, "%s\n", XPA_VERSION);
exit(0);
}
/* make sure we have enough arguments */
if( argc < 2 )
usage(argv[0]);
/* start with no mode flag */
*mode = '\0';
/* read from stdin */
fd = fileno(stdin);
/* we want the args in the same order in which they arrived, and
gnu getopt sometimes changes things without this */
putenv("POSIXLY_CORRECT=true");
/* process switch arguments */
while ((c = getopt(argc, argv, "hi:m:npst:u:vwW")) != -1){
switch(c){
case 'h':
usage(argv[0]);
case 'i':
snprintf(cmd, SZ_LINE, "XPA_NSINET=%s", optarg);
putenv(xstrdup(cmd));
break;
case 'm':
snprintf(cmd, SZ_LINE, "XPA_METHOD=%s", optarg);
putenv(xstrdup(cmd));
break;
case 'n':
if( *mode != '\0' )
strcat(mode, ",");
strcat(mode, "ack=false");
break;
case 'p':
fd = -1;
break;
case 's':
server = 1;
if( xpa == NULL )
xpa = XPAOpen(NULL);
break;
case 't':
{
int xip=0;
char xbuf[SZ_LINE];
newdtable(",;");
if( word(optarg, xbuf, &xip) && *xbuf && (*xbuf != '*') ){
snprintf(cmd, SZ_LINE, "XPA_SHORT_TIMEOUT=%s", xbuf);
putenv(xstrdup(cmd));
}
if( word(optarg, xbuf, &xip) && *xbuf && (*xbuf != '*') ){
snprintf(cmd, SZ_LINE, "XPA_LONG_TIMEOUT=%s", xbuf);
putenv(xstrdup(cmd));
}
freedtable();
}
break;
case 'u':
snprintf(cmd, SZ_LINE, "XPA_NSUSERS=%s", optarg);
putenv(xstrdup(cmd));
break;
case 'v':
if( *mode != '\0' )
strcat(mode, ",");
strcat(mode, "verify=true");
break;
/* for backward compatibility with 1.0 */
case 'w':
case 'W':
break;
}
}
/* no explicit host:port specified, so we should have a name */
if( optind >= argc ){
/* in server mode, we can skip the host on the command line */
if( !server )
usage(argv[0]);
}
else{
xtemplate = xstrdup(argv[optind]);
optind++;
}
/* make the paramlist */
paramlist = XPAArgvParamlist(argc, argv, optind);
/* init variables for names and ports */
if( (s=(char *)getenv("XPA_MAXHOSTS")) != NULL )
hmax = atoi(s);
names = (char **)xcalloc(hmax, sizeof(char *));
errs = (char **)xcalloc(hmax, sizeof(char *));
again:
/* if we are in server mode, we might have to read a line from stdin
to grab the template and paramlist */
if( server && (xtemplate==NULL) ){
/* read description of template and paramlist */
if( fgets(lbuf, SZ_LINE, stdin) == NULL )
exit(errcode);
if( (*lbuf == '#') || (*lbuf == '\n') )
goto again;
lp = 0;
if( word(lbuf, tbuf, &lp) && !strcmp(tbuf, "xpaset") &&
word(lbuf, tbuf, &lp) ){
xtemplate = xstrdup(tbuf);
paramlist = xstrdup(&(lbuf[lp]));
nowhite(paramlist, paramlist);
}
else{
fprintf(stderr, "XPA$ERROR invalid command: %s", lbuf);
exit(++errcode);
}
}
/* process xpa requests */
got = XPASetFd(xpa, xtemplate, paramlist, mode, fd, names, errs, hmax);
/* process errors */
if( got == 0 ){
fprintf(stderr, "XPA$ERROR no 'xpaset' access points match template: %s\n",
xtemplate);
errcode++;
}
else{
/* display errors and free up strings */
for(i=0; i<got; i++){
if( errs[i] != NULL ){
fprintf(stderr, "%s", errs[i]);
xfree(errs[i]);
errcode++;
}
if( names[i] != NULL )
xfree(names[i]);
}
}
/* free the paramlist */
if( paramlist!= NULL ){
xfree(paramlist);
paramlist = NULL;
}
/* and the template */
if( xtemplate != NULL ){
xfree(xtemplate);
xtemplate = NULL;
}
/* if we are in server mode, go back for more */
if( server )
goto again;
/* else exit */
else{
/* clean up */
if( errs ) xfree(errs);
if( names ) xfree(names);
XPACleanup();
exit(errcode);
}
return(0);
}
| 25.554167 | 141 | 0.585032 |
ec850e42be32f171f8230f8266c694f101bf11f6 | 2,025 | c | C | sdl/window.c | dsoageofheroes/soloscuro | 37ec77aeeebc0edaf687c4df36914416a10ec157 | [
"MIT"
] | 3 | 2021-02-20T00:09:48.000Z | 2022-02-08T23:33:21.000Z | sdl/window.c | dsoageofheroes/soloscuro | 37ec77aeeebc0edaf687c4df36914416a10ec157 | [
"MIT"
] | 1 | 2021-02-20T03:13:45.000Z | 2021-02-20T03:13:45.000Z | sdl/window.c | dsoageofheroes/soloscuro | 37ec77aeeebc0edaf687c4df36914416a10ec157 | [
"MIT"
] | 3 | 2021-02-20T00:02:55.000Z | 2021-03-17T23:42:49.000Z | /* This is a debug program for testing the various available windows. */
#include <SDL2/SDL.h>
#include <stdio.h>
#include "window-manager.h"
#include "add-load-save.h"
#include "game-menu.h"
#include "inventory.h"
#include "interact.h"
#include "narrate.h"
#include "window-main.h"
#include "view-character.h"
#include "popup.h"
#include "new-character.h"
#include "combat-status.h"
#include "gpl.h"
#include "gameloop.h"
#include "region.h"
#include "sprite.h"
static SDL_Renderer *renderer = NULL;
static SDL_Surface *surface = NULL;
void load_window(const char *arg) {
if (!strcmp(arg, "main")) {
sol_window_push(&main_window, 10, 10);
}
if (!strcmp(arg, "view")) {
sol_window_push(&view_character_window, 0, 10);
narrate_init(0, 0); // to setup print_line
}
if (!strcmp(arg, "new")) {
sol_window_push(&new_character_window, 0, 0);
}
if (!strcmp(arg, "popup")) {
narrate_init(0, 0); // to setup print_line
sol_window_push(&popup_window, 10, 10);
sol_popup_set_message("Exit game?");
sol_popup_set_option(0, "Save");
sol_popup_set_option(1, "Load");
sol_popup_set_option(2, "Exit");
}
if (!strcmp(arg, "als")) {
sol_window_push(&als_window, 0, 0);
}
if (!strcmp(arg, "inv")) {
sol_window_push(&inventory_window, 0, 0);
}
if (!strcmp(arg, "menu")) {
sol_window_push(&game_menu_window, 0, 0);
}
if (!strcmp(arg, "interact")) {
sol_window_push(&interact_window, 0, 0);
}
if (!strcmp(arg, "combat")) {
combat_status_t* cs = sol_combat_status_get();
strcpy(cs->name, "Tex");
cs->current_hp = 10;
cs->max_hp = 20;
cs->status = 1;
cs->move = 12;
sol_window_push(&combat_status_window, 295, 5);
}
}
void window_debug_init(SDL_Surface *sur, SDL_Renderer *rend, const char *arg) {
surface = sur;
renderer = rend;
sprite_init();
sol_window_init();
load_window(arg);
}
| 27.364865 | 79 | 0.614321 |
ecc17889254af706b4e49b1cb7fdf4275866812e | 455 | h | C | include/ppr/cmd/benchmark/benchmark.h | zieglerdo/ppr | 3ba2d675ee80a723a4e83b0e9249bb546e2a1489 | [
"MIT"
] | 1 | 2020-08-05T08:37:43.000Z | 2020-08-05T08:37:43.000Z | include/ppr/cmd/benchmark/benchmark.h | zieglerdo/ppr | 3ba2d675ee80a723a4e83b0e9249bb546e2a1489 | [
"MIT"
] | null | null | null | include/ppr/cmd/benchmark/benchmark.h | zieglerdo/ppr | 3ba2d675ee80a723a4e83b0e9249bb546e2a1489 | [
"MIT"
] | 1 | 2022-03-31T06:14:04.000Z | 2022-03-31T06:14:04.000Z | #pragma once
#include "ppr/cmd/benchmark/bench_spec.h"
#include "ppr/cmd/benchmark/bounds.h"
#include "ppr/cmd/benchmark/prog_options.h"
#include "ppr/cmd/benchmark/stations.h"
#include "ppr/common/routing_graph.h"
#include "ppr/routing/search_profile.h"
namespace ppr::benchmark {
void run_benchmark(routing_graph const& rg, prog_options const& opt,
stations& st, bounds& a, bench_spec const& spec);
} // namespace ppr::benchmark
| 28.4375 | 68 | 0.736264 |
08a6184524db3d10d99de56a65ed2ab9e4036496 | 297 | h | C | src/sha.h | skawamoto0/FFFTP-Classic | 99e2fa670145735e0f81c69202d1f46c6ff6a7bd | [
"BSD-3-Clause"
] | null | null | null | src/sha.h | skawamoto0/FFFTP-Classic | 99e2fa670145735e0f81c69202d1f46c6ff6a7bd | [
"BSD-3-Clause"
] | null | null | null | src/sha.h | skawamoto0/FFFTP-Classic | 99e2fa670145735e0f81c69202d1f46c6ff6a7bd | [
"BSD-3-Clause"
] | null | null | null | #define MSDOS
#define LITTLE_ENDIAN
typedef int int32;
typedef unsigned int uint32;
//typedef unsigned int UINT4;
typedef unsigned short int UINT2;
/*
* just enough declarations for otp_hash to deal.
*/
void sha_memory (char *, uint32, uint32 *);
| 18.5625 | 50 | 0.636364 |
311eb6ad1f97306a201985edd1cbaac730bf7de3 | 1,595 | h | C | AK/Tests/TestHelpers.h | dcimino/serenity | 752d297321c47ff93df4b0d8ccadb39db6ccce3f | [
"BSD-2-Clause"
] | 1 | 2019-07-13T01:30:44.000Z | 2019-07-13T01:30:44.000Z | AK/Tests/TestHelpers.h | urantialife/serenity | 6e671f78a82bc3d9785bd35307cec72a84b6dcda | [
"BSD-2-Clause"
] | null | null | null | AK/Tests/TestHelpers.h | urantialife/serenity | 6e671f78a82bc3d9785bd35307cec72a84b6dcda | [
"BSD-2-Clause"
] | 1 | 2019-11-17T10:42:52.000Z | 2019-11-17T10:42:52.000Z | #pragma once
#include <stdio.h>
#include <AK/AKString.h>
#define LOG_FAIL(cond) \
fprintf(stderr, "\033[31;1mFAIL\033[0m: " #cond "\n")
#define LOG_PASS(cond) \
fprintf(stderr, "\033[32;1mPASS\033[0m: " #cond "\n")
#define LOG_FAIL_EQ(cond, expected_value, actual_value) \
fprintf(stderr, "\033[31;1mFAIL\033[0m: " #cond " should be " #expected_value ", got "); \
stringify_for_test(actual_value); \
fprintf(stderr, "\n")
#define LOG_PASS_EQ(cond, expected_value) \
fprintf(stderr, "\033[32;1mPASS\033[0m: " #cond " should be " #expected_value " and it is\n")
#define EXPECT_EQ(expr, expected_value) \
do { \
auto result = (expr); \
if (!(result == expected_value)) { \
LOG_FAIL_EQ(expr, expected_value, result); \
} else { \
LOG_PASS_EQ(expr, expected_value); \
} \
} while(0)
#define EXPECT(cond) \
do { \
if (!(cond)) { \
LOG_FAIL(cond); \
} else { \
LOG_PASS(cond); \
} \
} while(0)
inline void stringify_for_test(int value)
{
fprintf(stderr, "%d", value);
}
inline void stringify_for_test(unsigned value)
{
fprintf(stderr, "%u", value);
}
inline void stringify_for_test(const char* value)
{
fprintf(stderr, "%s", value);
}
inline void stringify_for_test(char value)
{
fprintf(stderr, "%c", value);
}
inline void stringify_for_test(const AK::String& string)
{
stringify_for_test(string.characters());
}
inline void stringify_for_test(const AK::StringImpl& string)
{
stringify_for_test(string.characters());
}
| 23.115942 | 97 | 0.622571 |
d6e8bd4f4f325b17b357a2074ae8a58d35b547f5 | 477 | c | C | test/testinfo.c | jlowintermute/log | e1e2892270d46140ede74181fc8245ac0ccc863b | [
"0BSD"
] | null | null | null | test/testinfo.c | jlowintermute/log | e1e2892270d46140ede74181fc8245ac0ccc863b | [
"0BSD"
] | null | null | null | test/testinfo.c | jlowintermute/log | e1e2892270d46140ede74181fc8245ac0ccc863b | [
"0BSD"
] | null | null | null | #include <log/log.h>
int
main()
{
LOG_INIT(LOG_INFO);
LOG(LOG_DEBUG, "This is the debug text: %s", "with a substring");
LOG(LOG_INFO, "This is the info text: %s", "with a substring2");
LOG(LOG_NOTICE, "This is the notice text: %s", "with a substring2");
LOG(LOG_WARNING, "This is the warning text: %s", "with a substring3");
LOG(LOG_ERROR, "This is the error text: %s", "with a substring4");
LOG(LOG_FATAL, "This is the fatal text: %s", "with a substring5");
}
| 31.8 | 72 | 0.662474 |
d900aa67722e570f62f9df9177c19d905295a45d | 2,663 | h | C | AMOS/Libs/Libs_Source/PTPlayLibrary/Sources/LibHeader.h | fatman2021/AMOSProfessional | e4b00e561c4af708d1f1006ec833d5cc9aef91df | [
"MIT"
] | 2 | 2020-01-23T17:33:10.000Z | 2020-11-01T20:19:42.000Z | AMOS/Libs/Libs_Source/PTPlayLibrary/Sources/LibHeader.h | fatman2021/AMOSProfessional | e4b00e561c4af708d1f1006ec833d5cc9aef91df | [
"MIT"
] | null | null | null | AMOS/Libs/Libs_Source/PTPlayLibrary/Sources/LibHeader.h | fatman2021/AMOSProfessional | e4b00e561c4af708d1f1006ec833d5cc9aef91df | [
"MIT"
] | 1 | 2020-08-23T17:06:59.000Z | 2020-08-23T17:06:59.000Z | #ifndef PTPLAY_LIBHEADER_H
#define PTPLAY_LIBHEADER_H
#ifndef DOS_DOS_H
#include <dos/dos.h>
#endif
#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif
#ifndef __DECLGATE_H__
#include "declgate.h"
#endif
#ifndef UTILITY_UTILITY_H
#include <utility/utility.h>
#endif
#ifndef RTF_PPC
#define RTF_PPC 0
#endif
#ifndef RTF_EXTENDED
#define RTF_EXTENDED 0
#endif
#ifdef __MORPHOS__
#define REG(reg,arg) arg
#else
#define REG(reg,arg) MREG(reg,arg)
#endif
#ifndef __GNUC__
#define __attribute__(x)
#endif
#include "ptplay_priv.h"
/*********************************************************************
* @Structures *
********************************************************************/
struct MyInitData
{
UBYTE ln_Type_Init[4];
UBYTE ln_Pri_Init[4];
UBYTE ln_Name_Init[2];
ULONG __attribute__((aligned(2))) ln_Name_Content;
UBYTE lib_Flags_Init[4];
UBYTE lib_Version_Init[2]; UWORD lib_Version_Content;
UBYTE lib_Revision_Init[2]; UWORD lib_Revision_Content;
UBYTE lib_IdString_Init[2];
ULONG __attribute__((aligned(2))) lib_IdString_Content;
UWORD EndMark;
} __attribute__((packed));
struct PtPlayLibrary
{
struct Library Library;
UWORD Pad;
BPTR SegList;
struct ExecBase *MySysBase;
struct UtilityBase *MyUtilBase;
};
/*********************************************************************
* @Prototypes *
********************************************************************/
ULONG LibReserved(void);
struct Library * LibInit(struct PtPlayLibrary *LibBase, BPTR LibSegList, struct ExecBase *MySysBase);
BPTR NATDECLFUNC_1(LibExpunge, a6, struct PtPlayLibrary *, LibBase);
BPTR NATDECLFUNC_1(LibClose, a6, struct PtPlayLibrary *, LibBase);
struct Library * NATDECLFUNC_1(LibOpen, a6, struct PtPlayLibrary *, LibBase);
pt_mod_s * NATDECLFUNC_5(Init, a1, UBYTE *, buf, d0, LONG, bufsize, d1, LONG, freq, d2, ULONG, modtype, a6, struct PtPlayLibrary *, LibBase);
VOID NATDECLFUNC_8(PtRender, a0, pt_mod_s *, mod, a1, BYTE *, buf, a2, BYTE *, buf2, d0, LONG, bufmodulo, d1, LONG, numsmp, d2, LONG, scale, d3, LONG, depth, d4, LONG, channels);
ULONG NATDECLFUNC_3(PtTest, a0, STRPTR, filename, a1, UBYTE *, buf, d0, LONG, bufsize);
VOID NATDECLFUNC_2(PtCleanup, a0, pt_mod_s *, mod, a6, struct PtPlayLibrary *, LibBase);
VOID NATDECLFUNC_3(PtSetAttrs, a0, pt_mod_s *, mod, a1, struct TagItem *, taglist, a6, struct PtPlayLibrary *, LibBase);
ULONG NATDECLFUNC_3(PtGetAttr, a0, pt_mod_s *, mod, d0, ULONG, tagitem, a1, ULONG *, StoragePtr);
ULONG NATDECLFUNC_2(PtSeek, a0, pt_mod_s *, mod, d0, ULONG, time);
#endif /* PTPLAY_LIBHEADER_H */
| 30.965116 | 182 | 0.648517 |
d8002cb6de9072e6a0e51637e1477edf7fe41091 | 1,137 | h | C | include/refinement/EpsRefine.h | sav-project/covenant | 19dca6cb80be9094ed16c07bfd55d380ced83f9d | [
"MIT"
] | 7 | 2015-07-22T16:01:01.000Z | 2020-10-06T20:17:32.000Z | include/refinement/EpsRefine.h | sav-project/covenant | 19dca6cb80be9094ed16c07bfd55d380ced83f9d | [
"MIT"
] | 1 | 2015-04-24T13:45:07.000Z | 2015-04-25T18:29:31.000Z | include/refinement/EpsRefine.h | sav-tools/covenant | 19dca6cb80be9094ed16c07bfd55d380ced83f9d | [
"MIT"
] | null | null | null | #ifndef __CFG_EPS_REFINE_H__
#define __CFG_EPS_REFINE_H__
#include <refinement/CondEpsGen.h>
namespace covenant {
using namespace std;
enum GeneralizationMethod { GREEDY, MAX_GEN };
std::istream& operator>>(std::istream& in, GeneralizationMethod& gen)
{
std::string token;
in >> token;
if (token == "greedy")
gen = GREEDY;
else if (token == "max-gen")
gen = MAX_GEN;
else
throw error("Invalid generalization method");
return in;
}
std::ostream& operator<<(std::ostream& o, GeneralizationMethod gen)
{
if (gen == GREEDY)
o << "greedy";
else if (gen == MAX_GEN)
o << "max-gen";
else
throw error("invalid generalization method");
return o;
}
template<typename EdgeSym>
class EpsRefine
{
public:
virtual ~EpsRefine() { }
// Refine a language with respect to a witness, following the chosen
// generalization strategy.
//
// Return a generalized witness that by construction not in the
// language of the CFG.
virtual DFA<EdgeSym> refine(CondEpsGen<EdgeSym>& gen) = 0;
};
} // end namespace covenant
#endif /*__CFG_REFINE_H__*/
| 20.672727 | 70 | 0.66051 |
26d75194ceabce0f3592cd46b166c30bcbaef861 | 7,814 | c | C | 00_graph_bench/src/structures/arrayQueue.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | 6 | 2019-12-15T02:37:57.000Z | 2021-02-02T05:10:01.000Z | 00_graph_bench/src/structures/arrayQueue.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | null | null | null | 00_graph_bench/src/structures/arrayQueue.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | 1 | 2020-12-16T05:52:50.000Z | 2020-12-16T05:52:50.000Z | // -----------------------------------------------------------------------------
//
// "00_AccelGraph"
//
// -----------------------------------------------------------------------------
// Copyright (c) 2014-2019 All rights reserved
// -----------------------------------------------------------------------------
// Author : Abdullah Mughrabi
// Email : atmughra@ncsu.edu||atmughrabi@gmail.com
// File : arrayQueue.c
// Create : 2019-06-21 17:15:17
// Revise : 2019-09-28 15:36:13
// Editor : Abdullah Mughrabi
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <omp.h>
#include "myMalloc.h"
#include "arrayQueue.h"
#include "bitmap.h"
struct ArrayQueue *newArrayQueue(uint32_t size)
{
struct ArrayQueue *arrayQueue = (struct ArrayQueue *) my_malloc( sizeof(struct ArrayQueue));
arrayQueue->head = 0;
arrayQueue->tail = 0;
arrayQueue->tail_next = 0;
arrayQueue->size = size;
arrayQueue->queue = (uint32_t *) my_malloc(size * sizeof(uint32_t));
arrayQueue->q_bitmap = newBitmap(size);
arrayQueue->q_bitmap_next = newBitmap(size);
return arrayQueue;
}
void softResetArrayQueue(struct ArrayQueue *q)
{
q->head = 0;
q->tail = 0;
q->tail_next = 0;
// clearBitmap(q->q_bitmap);
// clearBitmap(q->q_bitmap_next);
}
void resetArrayQueue(struct ArrayQueue *q)
{
q->head = 0;
q->tail = 0;
q->tail_next = 0;
clearBitmap(q->q_bitmap);
// clearBitmap(q->q_bitmap_next);
}
void freeArrayQueue(struct ArrayQueue *q)
{
if(q)
{
if(q->q_bitmap_next)
freeBitmap(q->q_bitmap_next);
if(q->q_bitmap)
freeBitmap(q->q_bitmap);
if(q->queue)
free(q->queue);
free(q);
}
}
void enArrayQueue (struct ArrayQueue *q, uint32_t k)
{
q->queue[q->tail] = k;
q->tail = (q->tail + 1) % q->size;
q->tail_next = q->tail;
}
void enArrayQueueWithBitmap (struct ArrayQueue *q, uint32_t k)
{
q->queue[q->tail] = k;
setBit(q->q_bitmap, k);
q->tail = q->tail_next;
q->tail++;
q->tail_next++;
}
void enArrayQueueAtomic (struct ArrayQueue *q, uint32_t k)
{
uint32_t local_q_tail = __sync_fetch_and_add(&q->tail, 1);
q->queue[local_q_tail] = k;
}
void enArrayQueueWithBitmapAtomic (struct ArrayQueue *q, uint32_t k)
{
uint32_t local_q_tail = __sync_fetch_and_add(&q->tail, 1);
q->queue[local_q_tail] = k;
setBitAtomic(q->q_bitmap, k);
}
void enArrayQueueDelayed (struct ArrayQueue *q, uint32_t k)
{
q->queue[q->tail_next] = k;
q->tail_next++;
}
void enArrayQueueDelayedWithBitmap (struct ArrayQueue *q, uint32_t k)
{
q->queue[q->tail_next] = k;
setBit(q->q_bitmap_next, k);
q->tail_next++;
}
void enArrayQueueDelayedWithBitmapAtomic (struct ArrayQueue *q, uint32_t k)
{
uint32_t local_q_tail_next = __sync_fetch_and_add(&q->tail_next, 1);
setBitAtomic(q->q_bitmap, k);
q->queue[local_q_tail_next] = k;
}
void slideWindowArrayQueue (struct ArrayQueue *q)
{
q->head = q->tail;
q->tail = q->tail_next;
}
void slideWindowArrayQueueBitmap (struct ArrayQueue *q)
{
q->head = q->tail;
q->tail = q->tail_next;
swapBitmaps(&q->q_bitmap, &q->q_bitmap_next);
clearBitmap(q->q_bitmap_next);
}
uint32_t deArrayQueue(struct ArrayQueue *q)
{
uint32_t k = q->queue[q->head];
clearBit(q->q_bitmap, k);
q->head = (q->head + 1) % q->size;
return k;
}
uint32_t frontArrayQueue (struct ArrayQueue *q)
{
uint32_t k = q->queue[q->head];
return k;
}
uint8_t isEmptyArrayQueueCurr (struct ArrayQueue *q)
{
if((q->tail > q->head))
return 0;
else
return 1;
}
uint8_t isEmptyArrayQueue (struct ArrayQueue *q)
{
if(!isEmptyArrayQueueCurr(q) || !isEmptyArrayQueueNext(q))
return 0;
else
return 1;
}
uint8_t isEmptyArrayQueueNext (struct ArrayQueue *q)
{
if((q->tail_next > q->head))
return 0;
else
return 1;
}
uint8_t isEnArrayQueued (struct ArrayQueue *q, uint32_t k)
{
return getBit(q->q_bitmap, k);
}
uint8_t isEnArrayQueuedNext (struct ArrayQueue *q, uint32_t k)
{
return getBit(q->q_bitmap_next, k);
}
uint32_t sizeArrayQueueCurr(struct ArrayQueue *q)
{
return q->tail - q->head;
}
uint32_t sizeArrayQueueNext(struct ArrayQueue *q)
{
return q->tail_next - q->tail;
}
uint32_t sizeArrayQueue(struct ArrayQueue *q)
{
return q->tail_next - q->head;
}
void flushArrayQueueToShared(struct ArrayQueue *local_q, struct ArrayQueue *shared_q)
{
uint32_t shared_q_tail_next = __sync_fetch_and_add(&shared_q->tail_next, local_q->tail);
uint32_t local_q_size = local_q->tail - local_q->head;
memcpy(&shared_q->queue[shared_q_tail_next], &local_q->queue[local_q->head], local_q_size * (sizeof(uint32_t)));
local_q->head = 0;
local_q->tail = 0;
local_q->tail_next = 0;
}
void arrayQueueGenerateBitmap(struct ArrayQueue *q)
{
uint32_t v;
uint32_t i;
#pragma omp parallel for
for(i = q->head ; i < q->tail; i++)
{
v = q->queue[i];
setBitAtomic(q->q_bitmap, v);
}
}
void arrayQueueToBitmap(struct ArrayQueue *q, struct Bitmap *b)
{
uint32_t v;
uint32_t i;
#pragma omp parallel for default(none) shared(q,b) private(v,i)
for(i = q->head ; i < q->tail; i++)
{
v = q->queue[i];
setBitAtomic(b, v);
}
// b->numSetBits = q->q_bitmap->numSetBits;
q->head = q->tail;
q->tail_next = q->tail;
}
void bitmapToArrayQueue(struct Bitmap *b, struct ArrayQueue *q, struct ArrayQueue **localFrontierQueues)
{
#pragma omp parallel default(none) shared(b,localFrontierQueues,q)
{
uint32_t i;
uint32_t t_id = omp_get_thread_num();
struct ArrayQueue *localFrontierQueue = localFrontierQueues[t_id];
#pragma omp for
for(i = 0 ; i < (b->size); i++)
{
if(getBit(b, i))
{
localFrontierQueue->queue[localFrontierQueue->tail] = i;
localFrontierQueue->tail++;
}
}
flushArrayQueueToShared(localFrontierQueue, q);
}
slideWindowArrayQueue(q);
}
void arrayQueueToBitmapDualOrder(struct ArrayQueue *q, struct Bitmap *b, uint32_t *labels)
{
uint32_t v;
uint32_t i;
uint32_t inv_u;
uint32_t num_threads_max = omp_get_max_threads();
#pragma omp parallel for default(none) shared(q,b,labels) private(v,i,inv_u) num_threads(num_threads_max)
for(i = q->head ; i < q->tail; i++)
{
v = q->queue[i];
inv_u = labels[v];
setBitAtomic(b, inv_u);
}
// b->numSetBits = q->q_bitmap->numSetBits;
q->head = q->tail;
q->tail_next = q->tail;
}
void bitmapToArrayQueueDualOrder(struct Bitmap *b, struct ArrayQueue *q, struct ArrayQueue **localFrontierQueues, uint32_t *labels)
{
#pragma omp parallel default(none) shared(b,localFrontierQueues,q,labels)
{
uint32_t i;
uint32_t inv_v;
uint32_t t_id = omp_get_thread_num();
struct ArrayQueue *localFrontierQueue = localFrontierQueues[t_id];
#pragma omp for
for(i = 0 ; i < (b->size); i++)
{
if(getBit(b, i))
{
inv_v = labels[i];
// uint32_t shared_q_tail_next = __sync_fetch_and_add(&localFrontierQueue->tail, 1);
localFrontierQueue->queue[localFrontierQueue->tail] = inv_v;
// #pragma omp atomic
localFrontierQueue->tail++;
}
}
flushArrayQueueToShared(localFrontierQueue, q);
}
slideWindowArrayQueue(q);
}
| 19.732323 | 131 | 0.598797 |
144d5f47c7b8ea7dc4bff40f5e288ed586fc74b5 | 877 | h | C | EchoServer.h | 13015517713/MyMuduo | eb864450e8827a1ed46c642b16e808b7a9d4f50f | [
"MIT"
] | null | null | null | EchoServer.h | 13015517713/MyMuduo | eb864450e8827a1ed46c642b16e808b7a9d4f50f | [
"MIT"
] | 1 | 2020-12-26T15:05:30.000Z | 2020-12-26T15:05:30.000Z | EchoServer.h | 13015517713/MyMuduo | eb864450e8827a1ed46c642b16e808b7a9d4f50f | [
"MIT"
] | null | null | null | #ifndef _ECHO_SERVER_H
#define _ECHO_SERVER_H
#include <muduo/net/EventLoop.h>
#include <muduo/net/InetAddress.h>
#include <muduo/net/TcpServer.h>
#include <iostream>
#include <functional>
using namespace muduo;
using namespace muduo::net;
using namespace std::placeholders;
class EchoServer{
public:
EchoServer(EventLoop *loop,const InetAddress &addr,const string &name):
_tcpServer(loop,addr,name),
_loop(loop) {
_tcpServer.setConnectionCallback(std::bind(&EchoServer::onConCall,this,_1)); // bind为了和function契合
_tcpServer.setMessageCallback(std::bind(&EchoServer::onMsgCall,this,_1,_2,_3));
}
void run();
private:
void onConCall(const TcpConnectionPtr&);
void onMsgCall(const TcpConnectionPtr&, Buffer*, Timestamp);
EventLoop *_loop;
TcpServer _tcpServer;
};
#endif | 30.241379 | 106 | 0.693273 |
e7a909968114a925548112e7c3d9d44aa7c0602c | 6,486 | c | C | vbox/src/VBox/Devices/PC/BIOS/bios.c | Nurzamal/rest_api_docker | a9cc01dfc235467d490d9663755b33ef6990bdd8 | [
"MIT"
] | null | null | null | vbox/src/VBox/Devices/PC/BIOS/bios.c | Nurzamal/rest_api_docker | a9cc01dfc235467d490d9663755b33ef6990bdd8 | [
"MIT"
] | null | null | null | vbox/src/VBox/Devices/PC/BIOS/bios.c | Nurzamal/rest_api_docker | a9cc01dfc235467d490d9663755b33ef6990bdd8 | [
"MIT"
] | null | null | null | /* $Id: bios.c 69501 2017-10-28 16:12:47Z vboxsync $ */
/** @file
* PC BIOS - ???
*/
/*
* Copyright (C) 2006-2017 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
* ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
*
* Copyright (C) 2002 MandrakeSoft S.A.
*
* MandrakeSoft S.A.
* 43, rue d'Aboukir
* 75002 Paris - France
* http://www.linux-mandrake.com/
* http://www.mandrakesoft.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 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include <stdint.h>
#include "inlines.h"
#include "biosint.h"
#ifndef VBOX_VERSION_STRING
#include <VBox/version.h>
#endif
static const char bios_cvs_version_string[] = "VirtualBox " VBOX_VERSION_STRING;
uint8_t read_byte(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint8_t *)offset) );
}
void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
{
*(seg:>(uint8_t *)offset) = data;
}
uint16_t read_word(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint16_t *)offset) );
}
void write_word(uint16_t seg, uint16_t offset, uint16_t data)
{
*(seg:>(uint16_t *)offset) = data;
}
uint32_t read_dword(uint16_t seg, uint16_t offset)
{
return( *(seg:>(uint32_t *)offset) );
}
void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
{
*(seg:>(uint32_t *)offset) = data;
}
uint8_t inb_cmos(uint8_t cmos_reg)
{
uint8_t cmos_port = 0x70;
if (cmos_reg >= 0x80)
cmos_port += 2;
outb(cmos_port, cmos_reg);
return inb(cmos_port + 1);
}
void outb_cmos(uint8_t cmos_reg, uint8_t val)
{
uint8_t cmos_port = 0x70;
if (cmos_reg >= 0x80)
cmos_port += 2;
outb(cmos_port, cmos_reg);
outb(cmos_port + 1, val);
}
void BIOSCALL dummy_isr_function(pusha_regs_t regs, uint16_t es,
uint16_t ds, iret_addr_t iret_addr)
{
// Interrupt handler for unexpected hardware interrupts. We have to clear
// the PIC because if we don't, the next EOI will clear the wrong interrupt
// and all hell will break loose! This routine also masks the unexpected
// interrupt so it will generally be called only once for each unexpected
// interrupt level.
uint8_t isrA, isrB, imr, last_int = 0xFF;
outb(PIC_MASTER, PIC_CMD_RD_ISR); // Read master ISR
isrA = inb(PIC_MASTER);
if (isrA) {
outb(PIC_SLAVE, PIC_CMD_RD_ISR); // Read slave ISR
isrB = inb(PIC_SLAVE);
if (isrB) {
imr = inb(PIC_SLAVE_MASK);
outb(PIC_SLAVE_MASK, imr | isrB ); // Mask this interrupt
outb(PIC_SLAVE, PIC_CMD_EOI); // Send EOI on slave PIC
} else {
imr = inb(PIC_MASTER_MASK);
isrA &= 0xFB; // Never mask the cascade interrupt
outb(PIC_MASTER_MASK, imr | isrA); // Mask this interrupt
}
outb(PIC_MASTER, PIC_CMD_EOI); // Send EOI on master PIC
last_int = isrA;
}
write_byte(0x40, 0x6B, last_int); // Write INTR_FLAG
}
void BIOSCALL nmi_handler_msg(void)
{
BX_PANIC("NMI Handler called\n");
}
void BIOSCALL int18_panic_msg(void)
{
BX_PANIC("INT18: BOOT FAILURE\n");
}
void BIOSCALL log_bios_start(void)
{
#if BX_DEBUG_SERIAL
outb(BX_DEBUG_PORT+UART_LCR, 0x03); /* setup for serial logging: 8N1 */
#endif
BX_INFO("%s\n", bios_cvs_version_string);
}
/* Set video mode. */
void set_mode(uint8_t mode);
#pragma aux set_mode = \
"mov ah, 0" \
"int 10h" \
parm [al] modify [ax];
/// @todo restore
//#undef VBOX
#define BX_PCIBIOS 1
#define BX_APPNAME "VirtualBox"
#define BIOS_BUILD_DATE __DATE__
//--------------------------------------------------------------------------
// print_bios_banner
// displays a the bios version
//--------------------------------------------------------------------------
void BIOSCALL print_bios_banner(void)
{
#ifdef VBOX
// Skip the logo if a warm boot is requested.
uint16_t warm_boot = read_word(0x0040,0x0072);
write_word(0x0040,0x0072, 0);
if (warm_boot == 0x1234)
{
/* Only set text mode. */
set_mode(3);
return;
}
/* show graphical logo */
show_logo();
#else /* !VBOX */
char *bios_conf;
/* Avoid using preprocessing directives within macro arguments. */
bios_conf =
#ifdef __WATCOMC__
"watcom "
#endif
#if BX_APM
"apmbios "
#endif
#if BX_PCIBIOS
"pcibios "
#endif
#if BX_ELTORITO_BOOT
"eltorito "
#endif
#if BX_ROMBIOS32
"rombios32 "
#endif
"\n\n";
printf(BX_APPNAME" BIOS - build: %s\n%s\nOptions: ",
BIOS_BUILD_DATE, bios_cvs_version_string);
printf(bios_conf, 0);
#endif /* VBOX */
}
| 29.216216 | 93 | 0.63984 |
88e558e177dc4cc00a5e0220abd1022e61e30a27 | 1,878 | c | C | dsalgo/01-linear-lists/p0204.c | zw267/coding-practice | b9d81dac1397d84e5df9f19ea4701ca5f4be7043 | [
"MIT"
] | null | null | null | dsalgo/01-linear-lists/p0204.c | zw267/coding-practice | b9d81dac1397d84e5df9f19ea4701ca5f4be7043 | [
"MIT"
] | null | null | null | dsalgo/01-linear-lists/p0204.c | zw267/coding-practice | b9d81dac1397d84e5df9f19ea4701ca5f4be7043 | [
"MIT"
] | null | null | null | /* P0204: Perid in prefixes/
* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define MAX_STR_LEN 1000000
// use a global variable storing in the stack to reduce time complexity.
char str[MAX_STR_LEN];
// r[0] is kept a sentinel
int r[MAX_STR_LEN];
/* notes:
* 1. the longth of A is at most MAX_STR_LEN / 2.
* 2. recursive? find_period();
* 3. DP might be a better choice, we could solve and record solutions of
* substr, and construct the solutions with the solved ones directly.
* */
int solve(int len);
void init(int len);
int cmp(int period, int k);
int main() {
int n;
int len;
int count = 1;
int i;
while (1) {
scanf("%d", &n);
if (n == 0) break;
scanf("%s", str);
len = strlen(str);
init(len);
printf("Test case #%d\n", count++);
for (i = 2; i <= len; i++) {
int res = solve(i);
if (res > 0)
printf("%d %d\n", i, res);
}
printf("\n");
}
exit(0);
}
void init(int len) {
int i;
for (i = 0; i <= len; i++)
r[i] = INT_MIN;
//if (str[0] == str[1]) r[1] = 2;
return;
}
int solve(int len) {
int max = INT_MIN;
//printf("len: %d ", len);
// the length of A: [1, len / 2]
int i;
for (i = len / 2; i >= 1; i--) {
//for (i = 1; i <= len; i++) {
if (len % i != 0) continue;
// the possible number of repeations
int j = len / i;
//printf("i: %d, j: %d ", i, j);
int tmp = cmp(i, j);
//printf("%d ", tmp);
if (tmp > 0) {
if (r[i - 1] > 0) return j * r[i - 1];
if (tmp > max) {
max = tmp;
r[len - 1] = max;
}
}
}
return max;
}
int cmp(int period, int k) {
int i;
for (i = 1; i < k; i++) {
int next = i * period;
int j;
for (j = 0; j < period; j++) {
if (str[j] != str[next + j])
return INT_MIN;
}
}
return k;
}
| 17.716981 | 73 | 0.504792 |
7636e3a5a46a7288187a81cd5e675465243993c4 | 870 | h | C | JKPasswordView/PasswordView.h | tangzhentao/JKPasswordView | fa67c063fe15e8ba7b888d0d5fe57e549fa8e9ed | [
"Apache-2.0"
] | null | null | null | JKPasswordView/PasswordView.h | tangzhentao/JKPasswordView | fa67c063fe15e8ba7b888d0d5fe57e549fa8e9ed | [
"Apache-2.0"
] | null | null | null | JKPasswordView/PasswordView.h | tangzhentao/JKPasswordView | fa67c063fe15e8ba7b888d0d5fe57e549fa8e9ed | [
"Apache-2.0"
] | null | null | null | //
// PasswordView.h
// JKPasswordView
//
// Created by itang on 2020/4/4.
// Copyright © 2020 learn. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class PasswordView;
@protocol PasswordViewDelegate<NSObject>
-(void)passWordDidChange:(PasswordView *)password;
-(void)passWordCompleteInput:(PasswordView *)password;
-(void)passWordBeginInput:(PasswordView *)password;
-(void)deleteWhenEmpty:(PasswordView *)password;
@end
@interface PasswordView : UIView<UIKeyInput>
@property (nonatomic) NSInteger passWordNum;//密码的位数
@property (nonatomic) CGFloat pointRadius;//黑点半径
@property (nonatomic) UIColor *pointColor;//黑点颜色
@property (nonatomic) UIColor *rectColor;//边框颜色
@property (nonatomic) id<PasswordViewDelegate> delegate;//
@property (nonatomic,readonly,strong) NSMutableString *textStore;//保存密码的字符串
@end
NS_ASSUME_NONNULL_END
| 22.307692 | 75 | 0.774713 |
6feb932cde25f7c814693ece5ea01934c62da4a6 | 300 | h | C | ObjC/AutomaticHeightTagTableViewCell/AppDelegate.h | mihir815/automatic-height-tagcells | ae2a5248aa7eae073390fd783b07627f38602be7 | [
"MIT"
] | 248 | 2016-07-25T21:19:02.000Z | 2021-10-30T23:10:30.000Z | ObjC/AutomaticHeightTagTableViewCell/AppDelegate.h | mihir815/automatic-height-tagcells | ae2a5248aa7eae073390fd783b07627f38602be7 | [
"MIT"
] | 14 | 2016-09-16T09:34:16.000Z | 2019-05-13T08:49:30.000Z | ObjC/AutomaticHeightTagTableViewCell/AppDelegate.h | weijentu/automatic-height-tagcells | d41790980d20fd096a065c230babdca8624554f1 | [
"MIT"
] | 41 | 2016-07-26T21:08:03.000Z | 2020-07-29T13:23:26.000Z | //
// AppDelegate.h
// AutomaticHeightTagTableViewCell
//
// Created by WEI-JEN TU on 2016-07-16.
// Copyright © 2016 Cold Yam. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 16.666667 | 60 | 0.72 |
8b3876f2a30a2702347d8036fa669b0d13aea41e | 8,943 | c | C | omp_kmeans.c | PatrickHarvey/AlgParalelos2017 | d13838859b6a0f722095290ff7d73598a4635cb2 | [
"MIT"
] | null | null | null | omp_kmeans.c | PatrickHarvey/AlgParalelos2017 | d13838859b6a0f722095290ff7d73598a4635cb2 | [
"MIT"
] | null | null | null | omp_kmeans.c | PatrickHarvey/AlgParalelos2017 | d13838859b6a0f722095290ff7d73598a4635cb2 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include "kmeans.h"
// distancia euclideana
__inline static
float euclid_dist_2(int numdims, /* num_dimensiones */
float *coord1, /* [num_dimensiones] */
float *coord2) /* [num_dimensiones] */
{
int i;
float ans=0.0;
for (i=0; i<numdims; i++)
ans += (coord1[i]-coord2[i]) * (coord1[i]-coord2[i]);
return(ans);
}
// encontrar el cluster mas cercano
__inline static
int find_nearest_cluster(int numClusters, /* num de clusters */
int numCoords, /* num de coordenadas */
float *object, /* [num de coordenadas] */
float **clusters) /* [num_clusters][num_coordenadas] */
{
int index, i;
float dist, min_dist;
// encontrar el id del cluster mas cercano al objeto
index = 0;
min_dist = euclid_dist_2(numCoords, object, clusters[0]);
for (i=1; i<numClusters; i++) {
dist = euclid_dist_2(numCoords, object, clusters[i]);
if (dist < min_dist) {
min_dist = dist;
index = i;
}
}
return(index);
}
/* retorna un arreglo de centros de los clusters de tamaño [num_clusters][num_coordenadas] */
float** omp_kmeans(int is_perform_atomic,
float **objects, /* entrada: [num_objetos][num_coordenadas] */
int numCoords, /* num_coordenadas */
int numObjs, /* num_objetos */
int numClusters, /* num_clusters */
float threshold,
int *membership) /* salidas: [num__objetos] */
{
int i, j, k, index, loop=0;
int *newClusterSize; /* [numClusters]: no. objects assigned in each
new cluster */
float delta; /* % of objects change their clusters */
float **clusters; /* out: [numClusters][numCoords] */
float **newClusters; /* [numClusters][numCoords] */
double timing;
int nthreads; /* no. threads */
int **local_newClusterSize; /* [nthreads][numClusters] */
float ***local_newClusters; /* [nthreads][numClusters][numCoords] */
nthreads = omp_get_max_threads();
/* allocate a 2D space for returning variable clusters[] (coordinates
of cluster centers) */
clusters = (float**) malloc(numClusters * sizeof(float*));
assert(clusters != NULL);
clusters[0] = (float*) malloc(numClusters * numCoords * sizeof(float));
assert(clusters[0] != NULL);
for (i=1; i<numClusters; i++)
clusters[i] = clusters[i-1] + numCoords;
/* pick first numClusters elements of objects[] as initial cluster centers*/
for (i=0; i<numClusters; i++)
for (j=0; j<numCoords; j++)
clusters[i][j] = objects[i][j];
/* initialize membership[] */
for (i=0; i<numObjs; i++) membership[i] = -1;
/* need to initialize newClusterSize and newClusters[0] to all 0 */
newClusterSize = (int*) calloc(numClusters, sizeof(int));
assert(newClusterSize != NULL);
newClusters = (float**) malloc(numClusters * sizeof(float*));
assert(newClusters != NULL);
newClusters[0] = (float*) calloc(numClusters * numCoords, sizeof(float));
assert(newClusters[0] != NULL);
for (i=1; i<numClusters; i++)
newClusters[i] = newClusters[i-1] + numCoords;
if (!is_perform_atomic) {
/* each thread calculates new centers using a private space,
then thread 0 does an array reduction on them. This approach
should be faster */
local_newClusterSize = (int**) malloc(nthreads * sizeof(int*));
assert(local_newClusterSize != NULL);
local_newClusterSize[0] = (int*) calloc(nthreads*numClusters,
sizeof(int));
assert(local_newClusterSize[0] != NULL);
for (i=1; i<nthreads; i++)
local_newClusterSize[i] = local_newClusterSize[i-1]+numClusters;
/* local_newClusters is a 3D array */
local_newClusters =(float***)malloc(nthreads * sizeof(float**));
assert(local_newClusters != NULL);
local_newClusters[0] =(float**) malloc(nthreads * numClusters *
sizeof(float*));
assert(local_newClusters[0] != NULL);
for (i=1; i<nthreads; i++)
local_newClusters[i] = local_newClusters[i-1] + numClusters;
for (i=0; i<nthreads; i++) {
for (j=0; j<numClusters; j++) {
local_newClusters[i][j] = (float*)calloc(numCoords,
sizeof(float));
assert(local_newClusters[i][j] != NULL);
}
}
}
if (_debug) timing = omp_get_wtime();
do {
delta = 0.0;
if (is_perform_atomic) {
#pragma omp parallel for \
private(i,j,index) \
firstprivate(numObjs,numClusters,numCoords) \
shared(objects,clusters,membership,newClusters,newClusterSize) \
schedule(static) \
reduction(+:delta)
for (i=0; i<numObjs; i++) {
/* encuentra el indice al cluster más cercano */
index = find_nearest_cluster(numClusters, numCoords, objects[i],
clusters);
/* incrementa delta */
if (membership[i] != index) delta += 1.0;
/* asigna el id del cluster al objeto-i */
membership[i] = index;
/*actualizar los nuevos centros : suma de todos los objetos en la misma región */
#pragma omp atomic
newClusterSize[index]++;
for (j=0; j<numCoords; j++)
#pragma omp atomic
newClusters[index][j] += objects[i][j];
}
}
else {
#pragma omp parallel \
shared(objects,clusters,membership,local_newClusters,local_newClusterSize)
{
int tid = omp_get_thread_num();
#pragma omp for \
private(i,j,index) \
firstprivate(numObjs,numClusters,numCoords) \
schedule(static) \
reduction(+:delta)
for (i=0; i<numObjs; i++) {
/* encuentra el indice al cluster más cercano */
index = find_nearest_cluster(numClusters, numCoords,
objects[i], clusters);
/* incrementa delta */
if (membership[i] != index) delta += 1.0;
/* asigna el id del cluster al objeto-i*/
membership[i] = index;
/* actualizar los nuevos centros : suma de todos los objetos en la misma región*/
local_newClusterSize[tid][index]++;
for (j=0; j<numCoords; j++)
local_newClusters[tid][index][j] += objects[i][j];
}
} /* fin #pragma omp parallel */
/* permite al hilo principal realizar la reduccion del array */
for (i=0; i<numClusters; i++) {
for (j=0; j<nthreads; j++) {
newClusterSize[i] += local_newClusterSize[j][i];
local_newClusterSize[j][i] = 0.0;
for (k=0; k<numCoords; k++) {
newClusters[i][k] += local_newClusters[j][i][k];
local_newClusters[j][i][k] = 0.0;
}
}
}
}
/* promedio de la suma y se reemplaza los centros antiguos con los nuevos */
for (i=0; i<numClusters; i++) {
for (j=0; j<numCoords; j++) {
if (newClusterSize[i] > 1)
clusters[i][j] = newClusters[i][j] / newClusterSize[i];
newClusters[i][j] = 0.0;
}
newClusterSize[i] = 0;
}
delta /= numObjs;
} while (delta > threshold && loop++ < 500);
if (_debug) {
timing = omp_get_wtime() - timing;
printf("nloops = %2d (T = %7.4f)",loop,timing);
}
if (!is_perform_atomic) {
free(local_newClusterSize[0]);
free(local_newClusterSize);
for (i=0; i<nthreads; i++)
for (j=0; j<numClusters; j++)
free(local_newClusters[i][j]);
free(local_newClusters[0]);
free(local_newClusters);
}
free(newClusters[0]);
free(newClusters);
free(newClusterSize);
return clusters;
}
| 37.894068 | 101 | 0.509337 |
5b16ef34d8f46fac5de94e68321ef18e874a4fa4 | 2,651 | h | C | keyboards/numatreus/config.h | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/numatreus/config.h | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | keyboards/numatreus/config.h | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | /*
Copyright 2019 yohei <yohewi@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xE80A
#define DEVICE_VER 0x0001
#define MANUFACTURER yohewi
#define PRODUCT NumAtreus
#define DESCRIPTION QMK keyboard firmware for NumAtreus
/* key matrix size */
#define MATRIX_ROWS 4
#define MATRIX_COLS 11
// wiring of each half
#define MATRIX_ROW_PINS { C6, D7, E6, B4 }
#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2, D2, D1, D0, D4 }
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION ROW2COL
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
/* number of backlight levels */
//#define BACKLIGHT_LEVELS 3
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
/* ws2812 RGB LED */
#define RGB_DI_PIN D3
// keyboard RGB LED support
//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no
// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes
#define RGBLED_NUM 6
#define RGBLIGHT_LIMIT_VAL 200
#define RGBLIGHT_VAL_STEP 17
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#if defined(RGBLIGHT_ENABLE)
// USB_MAX_POWER_CONSUMPTION value for stonehenge30 keyboard
// 120 RGBoff, OLEDoff
// 120 OLED
// 330 RGB 6
// 300 RGB 32
// 310 OLED & RGB 32
#define USB_MAX_POWER_CONSUMPTION 400
#else
// fix iPhone and iPad power adapter issue
// iOS device need lessthan 100
#define USB_MAX_POWER_CONSUMPTION 100
#endif
/*
* Feature disable options
* These options are also useful to firmware size reduction.
*/
/* disable debug print */
//#define NO_DEBUG
/* disable print */
//#define NO_PRINT
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
| 26.247525 | 83 | 0.751415 |
85ebf9d2499cf573eb6b1caf46cd183c5b9725e4 | 16,090 | h | C | plugins/protein_cuda/src/MoleculeCudaSESRenderer.h | masrice/megamol | d48fc4889f500528609053a5445202a9c0f6e5fb | [
"BSD-3-Clause"
] | 49 | 2017-08-23T13:24:24.000Z | 2022-03-16T09:10:58.000Z | plugins/protein_cuda/src/MoleculeCudaSESRenderer.h | masrice/megamol | d48fc4889f500528609053a5445202a9c0f6e5fb | [
"BSD-3-Clause"
] | 200 | 2018-07-20T15:18:26.000Z | 2022-03-31T11:01:44.000Z | plugins/protein_cuda/src/MoleculeCudaSESRenderer.h | masrice/megamol | d48fc4889f500528609053a5445202a9c0f6e5fb | [
"BSD-3-Clause"
] | 31 | 2017-07-31T16:19:29.000Z | 2022-02-14T23:41:03.000Z | /*
* MoleculeCudaSESRenderer.h
*
* Copyright (C) 2009 by Universitaet Stuttgart (VIS). Alle Rechte vorbehalten.
*/
#ifndef MEGAMOL_MOLRENCUDASES_H_INCLUDED
#define MEGAMOL_MOLRENCUDASES_H_INCLUDED
#if (_MSC_VER > 1000)
#pragma once
#endif /* (_MSC_VER > 1000) */
#include "mmcore/CallerSlot.h"
#include "mmcore/param/ParamSlot.h"
#include "mmcore/view/CallRender3D.h"
#include "mmcore/view/Renderer3DModule.h"
#include "protein_calls/MolecularDataCall.h"
#include "vislib/graphics/gl/FramebufferObject.h"
#include "vislib/graphics/gl/GLSLGeometryShader.h"
#include "vislib/graphics/gl/GLSLShader.h"
#include "vislib/graphics/gl/IncludeAllGL.h"
#include <GL/glu.h>
#include "cuda_runtime_api.h"
#include "particles_kernel.cuh"
#include "vector_functions.h"
//#include "cudpp/cudpp.h"
#define CHECK_FOR_OGL_ERROR() \
do { \
GLenum err; \
err = glGetError(); \
if (err != GL_NO_ERROR) { \
fprintf(stderr, "%s(%d) glError: %s\n", __FILE__, __LINE__, gluErrorString(err)); \
} \
} while (0)
namespace megamol {
namespace protein_cuda {
/**
* Molecular Surface Renderer class.
* Computes and renders the Solvent Excluded Surface on the GPU.
*/
class MoleculeCudaSESRenderer : public megamol::core::view::Renderer3DModule {
public:
/**
* Answer the name of this module.
*
* @return The name of this module.
*/
static const char* ClassName(void) {
return "MoleculeCudaSESRenderer";
}
/**
* Answer a human readable description of this module.
*
* @return A human readable description of this module.
*/
static const char* Description(void) {
return "Offers molecular surface renderings.";
}
/**
* Answers whether this module is available on the current system.
*
* @return 'true' if the module is available, 'false' otherwise.
*/
static bool IsAvailable(void) {
//return true;
return vislib::graphics::gl::GLSLShader::AreExtensionsAvailable();
}
/** ctor */
MoleculeCudaSESRenderer(void);
/** dtor */
virtual ~MoleculeCudaSESRenderer(void);
protected:
/**
* Implementation of 'Create'.
*
* @return 'true' on success, 'false' otherwise.
*/
virtual bool create(void);
/**
* Implementation of 'release'.
*/
virtual void release(void);
/**
* Creates a FBO for visibility tests with the given size.
* @param size The maximum size for the FBO textures.
* @param width Out parameter: texture width.
* @param height Out parameter: texture height.
*/
void createVisibilityFBO(unsigned int size, unsigned int& width, unsigned int& height);
/**
* Renders all atoms using GPU ray casting and write atom ID to red color channel.
* @param protein The protein call.
*/
void RenderAtomIdGPU(megamol::protein_calls::MolecularDataCall* protein);
/**
* Create the FBO for visibility test.
* @param maxSize The maximum dimension for width/height.
*/
void CreateVisibilityFBO(unsigned int maxSize);
/**
* Create the FBO for visible atoms.
* @param atomCount The number of protein atoms.
*/
void CreateVisibleAtomsFBO(unsigned int atomCount);
/**
* Find all visible atoms
* @param protein The protein call.
*/
void FindVisibleAtoms(megamol::protein_calls::MolecularDataCall* protein);
/**
* Find for each visible atom all atoms that are in the proximity.
* @param protein The protein call.
*/
void ComputeVisibleAtomsVicinityTable(megamol::protein_calls::MolecularDataCall* protein);
/**
* Use CUDA to find for each visible atom all atoms that are in the neighborhood.
* @param protein The protein call.
*/
void ComputeVicinityTableCUDA(megamol::protein_calls::MolecularDataCall* protein);
/**
* Compute the Reduced Surface using the Fragment Shader.
* @param protein The protein call.
*/
void ComputeRSFragShader(megamol::protein_calls::MolecularDataCall* protein);
/**
* Creates the FBO for reduced surface triangle generation.
* @param atomCount The total number of atoms.
* @param vicinityCount The maximum number of vicinity atoms.
*/
void CreateTriangleFBO(unsigned int atomCount, unsigned int vicinityCount);
/**
* Creates the FBO for visible reduced surface triangles.
*/
void CreateVisibleTriangleFBO(unsigned int atomCount, unsigned int vicinityCount);
/**
* Render all potential RS-faces as triangles using a vertex shader.
* @param protein The protein call.
*/
void RenderTriangles(megamol::protein_calls::MolecularDataCall* protein);
/**
* Find all visible triangles (i.e. visible RS-faces).
* @param protein The protein call.
*/
void FindVisibleTriangles(megamol::protein_calls::MolecularDataCall* protein);
/**
* Create fbo for adjacent triangles of visible triangles
* @param atomCount The total number of atoms.
* @param vicinityCount The maximum number of vicinity atoms.
*/
void CreateAdjacentTriangleFBO(unsigned int atomCount, unsigned int vicinityCount);
/**
* Find the adjacent triangles to all visible triangles.
* @param protein The protein call.
*/
void FindAdjacentTriangles(megamol::protein_calls::MolecularDataCall* protein);
/**
* Find the adjacent triangles to all visible triangles.
* @param mol The molecular data call.
*/
void FindAdjacentTrianglesCUDA(megamol::protein_calls::MolecularDataCall* mol);
/**
* Create the VBO for transform feedback.
*/
void CreateTransformFeedbackVBO(megamol::protein_calls::MolecularDataCall* mol);
/**
* Find all intersecting probes for each probe and create the singularity texture.
* @param mol The molecular data call.
* @param numProbes The number of RS-faces (i.e. probes in fixed positions).
*/
void CreateSingularityTextureCuda(megamol::protein_calls::MolecularDataCall* mol, unsigned int numProbes);
/**
* Render the SES using GPU ray casting.
* @param mol The molecular data call.
* @param primitiveCount The number of primitives.
*/
void RenderSESCuda(megamol::protein_calls::MolecularDataCall* mol, unsigned int primitiveCount);
/**
* Render all visible atoms using GPU ray casting.
* @param protein The protein call.
*/
void RenderVisibleAtomsGPU(megamol::protein_calls::MolecularDataCall* protein);
/**
* Mark all atoms which are vertices of adjacent triangles as visible
*/
void MarkAdjacentAtoms(megamol::protein_calls::MolecularDataCall* protein);
/**
* Mark all atoms which are vertices of adjacent triangles as visible
*
* @param mol The molecular data call.
*/
void MarkAdjacentAtomsCUDA(megamol::protein_calls::MolecularDataCall* mol);
/**
* Initialize CUDA
* @param protein The molecular data call.
* @param gridDim The grid dimension.
* @param cr3d Pointer to the render call.
* @return 'true' if initialization was successful, otherwise 'false'
*/
bool initCuda(megamol::protein_calls::MolecularDataCall* protein, uint gridDim, core::view::CallRender3D* cr3d);
/**
* Write atom positions and radii to an array for processing in CUDA
*/
void writeAtomPositions(megamol::protein_calls::MolecularDataCall* protein);
private:
/**
* The get extents callback. The module should set the members of
* 'call' to tell the caller the extents of its data (bounding boxes
* and times).
*
* @param call The calling call.
*
* @return The return value of the function.
*/
virtual bool GetExtents(megamol::core::Call& call);
/**
* Open GL Render call.
*
* @param call The calling call.
* @return The return value of the function.
*/
virtual bool Render(megamol::core::Call& call);
/**
* Deinitialises this renderer. This is only called if there was a
* successful call to "initialise" before.
*/
virtual void deinitialise(void);
/**
* Compute the Reduced Surface using CUDA.
*
* @param mol The molecular data call.
*/
void ComputeRSCuda(megamol::protein_calls::MolecularDataCall* mol);
/**
* Find all visible triangles (i.e. visible RS-faces).
* @param mol The molecular call.
*/
void FindVisibleTrianglesCuda(megamol::protein_calls::MolecularDataCall* mol);
/**
* Render all potential RS-faces as triangles.
* @param mol The protein call.
*/
void RenderTrianglesCuda(megamol::protein_calls::MolecularDataCall* mol);
/**
* Render all potential RS-faces as triangles.
* @param mol The protein call.
*/
void RenderTrianglesCuda2(megamol::protein_calls::MolecularDataCall* mol);
/**
* Render all visible RS-faces as triangles.
* @param mol The protein call.
*/
void RenderVisibleTrianglesCuda(megamol::protein_calls::MolecularDataCall* mol);
/**
* Create geometric primitives for ray casting.
* @param mol The molecular data call.
* @return The number of primitives which were read back.
*/
unsigned int CreateGeometricPrimitivesCuda(megamol::protein_calls::MolecularDataCall* mol);
/**********************************************************************
* variables
**********************************************************************/
// caller slot
megamol::core::CallerSlot protDataCallerSlot;
/** parameter slot for positional interpolation */
megamol::core::param::ParamSlot interpolParam;
/** parameter slot for debugging */
megamol::core::param::ParamSlot debugParam;
/** parameter slot for probe radius */
megamol::core::param::ParamSlot probeRadiusParam;
// shaders
vislib::graphics::gl::GLSLShader writeSphereIdShader;
vislib::graphics::gl::GLSLShader drawPointShader;
vislib::graphics::gl::GLSLShader sphereShader;
vislib::graphics::gl::GLSLShader reducedSurfaceShader;
vislib::graphics::gl::GLSLShader drawTriangleShader;
vislib::graphics::gl::GLSLGeometryShader drawVisibleTriangleShader;
vislib::graphics::gl::GLSLShader sphericalTriangleShader;
vislib::graphics::gl::GLSLShader torusShader;
vislib::graphics::gl::GLSLShader adjacentTriangleShader;
vislib::graphics::gl::GLSLShader adjacentAtomsShader;
vislib::graphics::gl::GLSLShader drawCUDATriangleShader;
vislib::graphics::gl::GLSLGeometryShader visibleTriangleIdxShader;
// camera information
vislib::SmartPtr<vislib::graphics::CameraParameters> cameraInfo;
// the bounding box of the protein
vislib::math::Cuboid<float> bBox;
// current width and height of camera view
unsigned int width, height;
// interpolated atom positions
float* posInter;
// the GL clear color
float clearCol[4];
// start value for fogging
float fogStart;
// transparency value
float transparency;
// the radius of the probe defining the SES
float probeRadius;
// ----- variables for atom visibility test -----
// the ID array (contains IDs from 0 .. n)
float* proteinAtomId;
unsigned int proteinAtomCount;
// visibility FBO, textures and parameters
GLuint visibilityFBO;
GLuint visibilityColor;
GLuint visibilityDepth;
unsigned int visibilityTexWidth, visibilityTexHeight;
// variables for drawing visibility texture as vertices (data + VBO)
float* visibilityVertex;
GLuint visibilityVertexVBO;
// FBO, textures and parameters for visible atoms
GLuint visibleAtomsFBO;
GLuint visibleAtomsColor;
GLuint visibleAtomsDepth;
// array for visible atoms maks
float* visibleAtomMask;
// ----- vicinity table for visible atoms -----
float* vicinityTable;
unsigned int voxelLength;
unsigned int* voxelMap;
unsigned int voxelMapSize;
unsigned int numAtomsPerVoxel;
GLuint vicinityTableTex;
float* visibleAtomsList;
unsigned int* visibleAtomsIdList;
unsigned int visibleAtomCount;
GLuint visibleAtomsTex;
GLuint visibleAtomsIdTex;
// vertex and color arrays for geometry shader implementation
float* atomPosRSGS;
float* atomColRSGS;
// ----- FBO and textures for triangle (i.e. potential RS-faces) computation
GLuint triangleFBO;
GLuint triangleColor0;
GLuint triangleColor1;
GLuint triangleColor2;
GLuint triangleNormal;
GLuint triangleDepth;
// VBO and data arrays for triangle drawing
GLuint triangleVBO;
float* triangleVertex;
// ----- FBO and textures for visible triangles (i.e. visible RS-faces)
GLuint visibleTriangleFBO;
GLuint visibleTriangleColor;
GLuint visibleTriangleDepth;
// ----- render to VBO -----
GLuint visibilityTexVBO;
// ----- FBO and textures for finding adjacent triangles -----
GLuint adjacentTriangleFBO;
GLuint adjacentTriangleColor;
GLuint adjacentTriangleDepth;
float* adjacentTriangleVertex;
GLuint adjacentTriangleVBO;
GLuint adjacentTriangleTexVBO;
// ----- vicinity table for probes -----
unsigned int* probeVoxelMap;
// ----- singularity handling -----
float* singTexData;
float* singTexCoords;
GLuint singTex;
// VBO for spherical triangle center transform feedback
GLuint sphericalTriaVBO;
// query for transform feedback
GLuint query;
float delta;
bool first;
// CUDA Radix sort
//CUDPPHandle sortHandle;
//CUDPPHandle sortHandleProbe;
// params
bool cudaInitalized;
uint numAtoms;
SimParams params;
uint3 gridSize;
uint numGridCells;
// CPU data
float* m_hPos; // particle positions
uint* m_hNeighborCount; // atom neighbor count
uint* m_hNeighbors; // atom neighbor count
uint* m_hParticleIndex;
// GPU data
float* m_dPos;
float* m_dSortedPos;
uint* m_dNeighborCount;
uint* m_dNeighbors;
// grid data for sorting method
uint* m_dGridParticleHash; // grid hash value for each particle
uint* m_dGridParticleIndex; // particle index for each particle
uint* m_dCellStart; // index of start of each cell in sorted list
uint* m_dCellEnd; // index of end of cell
uint gridSortBits;
// additional parameters for the reduced surface
RSParams rsParams;
// arrays for reduced surface computation
uint* m_dPoint1;
float* m_dPoint2;
float* m_dPoint3;
float* m_dProbePosTable;
float* m_dVisibleAtoms;
uint* m_dVisibleAtomsId;
struct cudaGraphicsResource* cudaVboResource;
struct cudaGraphicsResource* cudaTexResource;
uint* pointIdx;
// vertex array for fast drawing of texture coordinates (visible triangle testing)
float* visTriaTestVerts;
struct cudaGraphicsResource* cudaVisTriaVboResource;
struct cudaGraphicsResource* cudaTorusVboResource;
GLuint torusVbo;
struct cudaGraphicsResource* cudaSTriaVboResource;
GLuint sTriaVbo;
// GPU data for probes
float* m_dProbePos;
float* m_dSortedProbePos;
uint* m_dProbeNeighborCount;
uint* m_dProbeNeighbors;
uint* m_dGridProbeHash;
uint* m_dGridProbeIndex;
struct cudaGraphicsResource* cudaSTriaResource;
GLuint singPbo;
GLuint singCoordsPbo;
GLuint visibilityPbo;
};
} /* end namespace protein_cuda */
} /* end namespace megamol */
#endif /* MEGAMOL_MOLRENCUDASES_H_INCLUDED */
| 32.505051 | 116 | 0.662337 |
3fbb3d226c376eddf883b85e1ef45bc165d8fd8a | 311 | h | C | ZBWUIKit/CustomViews/ZBWCustomViews.h | HangZhouShuChengKeJi/ZBWUIKit | 33304b5f7c18d69671372259fe279da6e3cbe0d2 | [
"BSD-2-Clause"
] | null | null | null | ZBWUIKit/CustomViews/ZBWCustomViews.h | HangZhouShuChengKeJi/ZBWUIKit | 33304b5f7c18d69671372259fe279da6e3cbe0d2 | [
"BSD-2-Clause"
] | null | null | null | ZBWUIKit/CustomViews/ZBWCustomViews.h | HangZhouShuChengKeJi/ZBWUIKit | 33304b5f7c18d69671372259fe279da6e3cbe0d2 | [
"BSD-2-Clause"
] | null | null | null | //
// ZBWCustomViews.h
// ZBWUIKit
//
// Created by 朱博文 on 16/12/23.
// Copyright © 2016年 朱博文. All rights reserved.
//
#ifndef ZBWCustomViews_h
#define ZBWCustomViews_h
#import "ZBWSegmentView.h"
#import "ZBWGridView.h"
#import "ZBWGridCell.h"
#import "ZBWGridCellButton.h"
#endif /* ZBWCustomViews_h */
| 17.277778 | 47 | 0.717042 |
87f9451bbdc477eea3e226880e217846f9b1db8d | 16,208 | h | C | include/vlog/edb.h | karmaresearch/glog | c908c527640c6ae8f23c03ccd7dfb17184989e22 | [
"Apache-2.0"
] | 3 | 2021-03-01T07:13:18.000Z | 2021-12-11T08:28:20.000Z | include/vlog/edb.h | karmaresearch/glog | c908c527640c6ae8f23c03ccd7dfb17184989e22 | [
"Apache-2.0"
] | null | null | null | include/vlog/edb.h | karmaresearch/glog | c908c527640c6ae8f23c03ccd7dfb17184989e22 | [
"Apache-2.0"
] | null | null | null | #ifndef EDB_LAYER_H
#define EDB_LAYER_H
#include <vlog/consts.h>
#include <vlog/concepts.h>
#include <vlog/qsqquery.h>
#include <vlog/support.h>
#include <vlog/idxtupletable.h>
#include <vlog/edbtable.h>
#include <vlog/edbiterator.h>
#include <vlog/edbconf.h>
#include <vlog/incremental/removal.h>
#include <kognac/factory.h>
#include <vector>
#include <map>
//Datatype is set in the most significant three bits
#define IS_NUMBER(x) ((x) >> 61)
#define IS_UINT(x) ((x >> 61) == 1)
#define IS_FLOAT32(x) ((x >> 61) == 2)
#define GET_UINT(x) (x & 0x2000000000000000ul)
#define GET_FLOAT32(x) (*(float*)&x)
#define FLOAT32_MASK(x) ( *((uint32_t*)&x) | 0x4000000000000000ul)
class Column;
class SemiNaiver; // Why cannot I break the software hierarchy? RFHH
class EDBFCInternalTable;
class TGSegment;
class GBGraph;
using RemoveLiteralOf = std::unordered_map<PredId_t, const EDBRemoveLiterals *>;
using NamedSemiNaiver = std::unordered_map<std::string,
std::shared_ptr<SemiNaiver>>;
class EDBMemIterator : public EDBIterator {
private:
uint8_t nfields = 0;
bool isFirst = false, hasFirst = false;
bool equalFields = false, isNextCheck = false, isNext = false;
bool ignoreSecondColumn = false;
bool isIgnoreAllowed = true;
PredId_t predid;
std::vector<Term_t>::iterator oneColumn;
std::vector<Term_t>::iterator endOneColumn;
std::vector<std::pair<Term_t, Term_t>>::iterator pointerEqualFieldsNext;
std::vector<std::pair<Term_t, Term_t>>::iterator twoColumns;
std::vector<std::pair<Term_t, Term_t>>::iterator endTwoColumns;
public:
EDBMemIterator() {}
void init1(PredId_t id, std::vector<Term_t>*, const bool c1,
const Term_t vc1);
void init2(PredId_t id, const bool defaultSorting,
std::vector<std::pair<Term_t, Term_t>>*, const bool c1,
const Term_t vc1, const bool c2, const Term_t vc2,
const bool equalFields);
VLIBEXP void skipDuplicatedFirstColumn();
VLIBEXP bool hasNext();
VLIBEXP void next();
PredId_t getPredicateID() {
return predid;
}
void reset();
void mark();
void moveTo(const uint8_t fieldId, const Term_t t) {}
VLIBEXP Term_t getElementAt(const uint8_t p);
void clear() {}
~EDBMemIterator() {}
};
class EmptyEDBIterator final : public EDBIterator {
PredId_t predid;
public:
EmptyEDBIterator(PredId_t id) {
predid = id;
}
VLIBEXP void init1(PredId_t id, std::vector<Term_t>*, const bool c1,
const Term_t vc1) {
predid = id;
}
VLIBEXP void init2(PredId_t id, const bool defaultSorting,
std::vector<std::pair<Term_t, Term_t>>*, const bool c1,
const Term_t vc1, const bool c2, const Term_t vc2,
const bool equalFields) {
predid = id;
}
VLIBEXP void skipDuplicatedFirstColumn() { }
VLIBEXP bool hasNext() {
return false;
}
VLIBEXP void next() {
throw 10;
}
PredId_t getPredicateID() {
return predid;
}
void moveTo(const uint8_t fieldId, const Term_t t) {}
VLIBEXP Term_t getElementAt(const uint8_t p) {
throw 10;
}
void clear() {}
~EmptyEDBIterator() {}
};
class EDBLayer {
private:
struct EDBInfoTable {
PredId_t id;
uint8_t arity;
std::string type;
std::shared_ptr<EDBTable> manager;
};
const EDBConf &conf;
const bool multithreaded;
const std::string edbconfpath;
bool loadAllData;
GBGraph *context_gbGraph;
size_t context_step;
std::shared_ptr<Dictionary> predDictionary; //std::string, Term_t
std::map<PredId_t, EDBInfoTable> dbPredicates;
Factory<EDBMemIterator> memItrFactory;
std::vector<IndexedTupleTable *>tmpRelations;
std::vector<std::shared_ptr<EDBTable>> edbTablesWithDict;
std::shared_ptr<Dictionary> termsDictionary;//std::string, Term_t
std::string rootPath;
VLIBEXP void addTridentTable(const EDBConf::Table &tableConf,
bool multithreaded);
void addCliqueTable(const EDBConf::Table &tableConf,
PredId_t predId = 0,
bool usePredId = false);
void addTopKTable(const EDBConf::Table &tableConf);
void addEmbTable(const EDBConf::Table &tableConf);
void addElasticTable(const EDBConf::Table &tableConf);
void addStringTable(bool isUnary, const EDBConf::Table &tableConf);
#ifdef MYSQL
void addMySQLTable(const EDBConf::Table &tableConf);
#endif
#ifdef ODBC
void addODBCTable(const EDBConf::Table &tableConf);
#endif
#ifdef MAPI
void addMAPITable(const EDBConf::Table &tableConf);
#endif
#ifdef MDLITE
void addMDLiteTable(const EDBConf::Table &tableConf);
#endif
VLIBEXP void addInmemoryTable(const EDBConf::Table &tableConf,
std::string edbconfpath);
VLIBEXP void addSparqlTable(const EDBConf::Table &tableConf);
VLIBEXP void addEDBonIDBTable(const EDBConf::Table &tableConf);
VLIBEXP void addEDBimporter(const EDBConf::Table &tableConf);
// literals to be removed during iteration
RemoveLiteralOf removals;
// For incremental reasoning: EDBonIDB must know which SemiNaiver(s) to
// query
NamedSemiNaiver prevSemiNaiver;
// need to import the mapping predid -> Predicate from prevSemiNaiver
void handlePrevSemiNaiver();
std::string name;
void addTable(const EDBConf::Table &table, bool multithreaded,
std::string edbconfpath, PredId_t predId = 0,
bool usePredId = false);
public:
EDBLayer(EDBLayer &db, bool copyTables = false);
EDBLayer(const EDBConf &conf, bool multithreaded,
const NamedSemiNaiver &prevSemiNaiver,
bool loadAllData = true) :
conf(conf), prevSemiNaiver(prevSemiNaiver),
loadAllData(loadAllData), multithreaded(multithreaded),
edbconfpath(conf.getConfigFilePath()), context_gbGraph(NULL),
context_step(0)
{
const std::vector<EDBConf::Table> tables = conf.getTables();
rootPath = conf.getRootPath();
std::string edbconfpath = conf.getConfigFilePath();
predDictionary = std::shared_ptr<Dictionary>(new Dictionary());
if (prevSemiNaiver.size() != 0) {
handlePrevSemiNaiver();
}
for (const auto &table : tables) {
addTable(table, multithreaded, edbconfpath);
}
}
EDBLayer(const EDBConf &conf, bool multithreaded,
bool loadAllData = true) :
EDBLayer(conf, multithreaded, NamedSemiNaiver(), loadAllData)
{
}
std::vector<PredId_t> getAllEDBPredicates();
std::vector<PredId_t> getAllPredicateIDs() const;
std::string getPredType(PredId_t id) const;
VLIBEXP uint64_t getPredSize(PredId_t id) const;
std::string getPredName(PredId_t id) const;
uint8_t getPredArity(PredId_t id) const;
PredId_t getPredID(const std::string &name) const;
void setPredArity(PredId_t id, uint8_t arity);
void addTmpRelation(Predicate &pred, IndexedTupleTable *table);
void addEDBPredicate(std::string name,
std::string type,
std::vector<std::string> args,
PredId_t id);
PredId_t addEDBPredicate(std::string predName);
bool isTmpRelationEmpty(Predicate &pred) {
if (pred.getId() >= tmpRelations.size()) {
return false;
}
return tmpRelations[pred.getId()] == NULL ||
tmpRelations[pred.getId()]->getNTuples() == 0;
}
const Dictionary &getPredDictionary() {
assert(predDictionary.get() != NULL);
return *(predDictionary.get());
}
std::unordered_map<PredId_t, uint8_t> getPredicateCardUnorderedMap () {
std::unordered_map< PredId_t, uint8_t> ret;
for (auto item : dbPredicates)
ret.insert(std::make_pair(item.first, item.second.arity));
return ret;
}
VLIBEXP bool doesPredExists(PredId_t id) const;
PredId_t getFirstEDBPredicate() {
if (!dbPredicates.empty()) {
auto p = dbPredicates.begin();
return p->first;
} else {
LOG(ERRORL) << "There is no EDB Predicate!";
throw 10;
}
}
bool checkValueInTmpRelation(const uint8_t relId,
const uint8_t posInRelation,
const Term_t value) const;
size_t getSizeTmpRelation(Predicate &pred) {
if (pred.getId() >= tmpRelations.size()) {
return 0;
}
return tmpRelations[pred.getId()]->getNTuples();
}
bool supportsCheckIn(const Literal &l);
void join(std::vector<Term_t> &out, const Literal &l1,
std::vector<uint8_t> &posInL1, const uint8_t joinLeftVarPos,
const Literal &l2, const uint8_t posInL2,
const uint8_t copyVarPosLeft);
void join(std::vector<std::pair<Term_t,Term_t>> &out,
const Literal &l1, std::vector<uint8_t> &posInL1,
const uint8_t joinLeftVarPos,
const Literal &l2, const uint8_t posInL2,
const uint8_t copyVarPosLeft1,
const uint8_t copyVarPosLeft2);
std::vector<std::shared_ptr<Column>> checkNewIn(const Literal &l1,
std::vector<uint8_t> &posInL1,
const Literal &l2,
std::vector<uint8_t> &posInL2,
bool stopAfterFirst = false);
// Note: posInL2 contains positions in the literal.
std::vector<std::shared_ptr<Column>> checkNewIn(
std::vector <
std::shared_ptr<Column >> &checkValues,
const Literal &l2,
std::vector<uint8_t> &posInL2);
std::vector<Term_t> checkNewIn(
std::shared_ptr<const TGSegment> newSeg,
int posNew,
const Literal &l2,
int posInL2);
std::vector<Term_t> checkNewIn(
const Literal &l1,
int posInL1,
std::shared_ptr<const TGSegment> oldSeg);
std::vector<std::pair<Term_t, Term_t>> checkNewIn(const Literal &l1,
std::vector<uint8_t> &posInL1,
const std::vector<std::pair<Term_t, Term_t>> &existing);
std::vector<std::pair<Term_t,Term_t>> checkNewIn(
std::shared_ptr<const TGSegment> newSeg,
int posNew1,
int posNew2,
const Literal &l2,
int posInL2_1,
int posInL2_2);
std::vector<std::pair<Term_t,Term_t>> checkNewIn(
const std::vector<std::pair<Term_t, Term_t>> &terms,
const Literal &l2,
int posInL2_1,
int posInL2_2);
std::shared_ptr<Column> checkIn(
const std::vector<Term_t> &values,
const Literal &l2,
uint8_t posInL2,
size_t &sizeOutput);
VLIBEXP void query(QSQQuery *query, TupleTable *outputTable,
std::vector<uint8_t> *posToFilter,
std::vector<Term_t> *valuesToFilter);
EDBIterator *getIterator(const Literal &query);
// Note: fields only counts variables in the query.
EDBIterator *getSortedIterator(const Literal &query,
const std::vector<uint8_t> &fields);
// Note: posToFilter contains positions in the literal.
bool isEmpty(const Literal &query, std::vector<uint8_t> *posToFilter,
std::vector<Term_t> *valuesToFilter);
size_t estimateCardinality(const Literal &query);
size_t getCardinality(const Literal &query);
// Note: posColumn contains a position in the literal.
size_t getCardinalityColumn(const Literal &query,
uint8_t posColumn);
VLIBEXP bool getDictNumber(const char *text,
const size_t sizeText, uint64_t &id) const;
VLIBEXP bool getOrAddDictNumber(const char *text,
const size_t sizeText, uint64_t &id);
VLIBEXP bool getDictText(const uint64_t id, char *text) const;
VLIBEXP std::string getDictText(const uint64_t id) const;
Predicate getDBPredicate(int idx) const;
std::shared_ptr<EDBTable> getEDBTable(PredId_t id) const {
if (dbPredicates.count(id)) {
return dbPredicates.find(id)->second.manager;
} else {
return std::shared_ptr<EDBTable>();
}
}
std::string getTypeEDBPredicate(PredId_t id) const {
if (dbPredicates.count(id)) {
return dbPredicates.find(id)->second.type;
} else {
return "";
}
}
VLIBEXP uint64_t getNTerms() const;
bool expensiveEDBPredicate(PredId_t id) {
if (dbPredicates.count(id)) {
return dbPredicates.find(id)->second.manager->expensiveLayer();
}
return false;
}
void releaseIterator(EDBIterator *itr);
VLIBEXP void addRemoveLiterals(const RemoveLiteralOf &rm) {
removals.insert(rm.begin(), rm.end());
}
VLIBEXP bool hasRemoveLiterals(PredId_t pred) const {
if (removals.empty()) {
return false;
}
if (removals.find(pred) == removals.end()) {
return false;
}
if (removals.at(pred)->size() == 0) {
return false;
}
return true;
}
VLIBEXP void replaceFactsInmemoryTable(std::string predicate,
std::vector<std::vector<std::string>> &rows);
// For JNI interface ...
VLIBEXP void addInmemoryTable(std::string predicate,
std::vector<std::vector<std::string>> &rows);
VLIBEXP void addInmemoryTable(std::string predicate,
PredId_t id, std::vector<std::vector<std::string>> &rows);
//For RMFA check
VLIBEXP void addInmemoryTable(PredId_t predicate,
uint8_t arity,
std::vector<uint64_t> &rows);
VLIBEXP void addEDBTable(PredId_t predId,
std::string tableType,
std::shared_ptr<EDBTable> table);
const EDBConf &getConf() const {
return conf;
}
void setName(const std::string &name) {
this->name = name;
}
const std::string &getName() const {
return name;
}
//This method specifies whether the EDB source can change *during* reasoning
//Most sources cannot, thus this method normally returns false
bool canChange(PredId_t predId);
//Some EDB sources do not allow variables (or constants) in some positions.
//In this case, we cannot do a merge join but must apply sideway information
//passing and other types of joins.
bool isQueryAllowed(const Literal &query);
//Some EDB sources require that the literal has no variable. For instance,
//some string functions. In this case, we do not do any join
bool acceptQueriesWithFreeVariables(const Literal &query);
BuiltinFunction getBuiltinFunction(const Literal &query);
void setContext(GBGraph *g, size_t step);
void clearContext();
~EDBLayer() {
for (int i = 0; i < tmpRelations.size(); ++i) {
if (tmpRelations[i] != NULL) {
delete tmpRelations[i];
}
}
}
};
#endif
| 31.471845 | 84 | 0.593287 |
8facdcc2d1dc15699869e0d8536eb8906259b659 | 394 | h | C | game/ui/base/aliencontainmentscreen.h | trevortomesh/OpenApoc | 53cd163889fbfd21a9c128183427dad4255ac1a3 | [
"MIT"
] | 1 | 2019-11-19T11:41:36.000Z | 2019-11-19T11:41:36.000Z | game/ui/base/aliencontainmentscreen.h | trevortomesh/OpenApoc | 53cd163889fbfd21a9c128183427dad4255ac1a3 | [
"MIT"
] | null | null | null | game/ui/base/aliencontainmentscreen.h | trevortomesh/OpenApoc | 53cd163889fbfd21a9c128183427dad4255ac1a3 | [
"MIT"
] | null | null | null | #pragma once
#include "game/ui/base/transactionscreen.h"
#include "library/sp.h"
namespace OpenApoc
{
class AlienContainmentScreen : public TransactionScreen
{
private:
void closeScreen() override;
void executeOrders() override;
public:
AlienContainmentScreen(sp<GameState> state, bool forceLimits = false);
~AlienContainmentScreen() override = default;
};
}; // namespace OpenApoc
| 19.7 | 71 | 0.766497 |
b1d188d9de782fa0f85c706e802ee45b05c1c8d1 | 748 | h | C | src/AsmvarBaseStat/BamInsert.h | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 17 | 2015-12-25T10:58:03.000Z | 2021-05-06T01:56:40.000Z | src/AsmvarBaseStat/BamInsert.h | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 3 | 2017-07-20T22:12:16.000Z | 2021-04-19T14:37:14.000Z | src/AsmvarBaseStat/BamInsert.h | bioinformatics-centre/AsmVar | 5abd91a47feedfbd39b89ec3e2d6d20c02fe5a5e | [
"MIT"
] | 3 | 2018-01-26T02:03:04.000Z | 2020-08-07T08:01:20.000Z | /*
* Author : Shujia Huang & Siyang Liu
* Date : 2013-11-22 14:37:13
*
* Caculate insertsize by different @RG
*
*/
#ifndef BAMINSERT_H
#define BAMINSERT_H
#include <iostream>
#include <fstream>
#include <utility> // std::pair
#include <map>
#include <math.h> /* sqrt */
#include "api/BamMultiReader.h"
#include "api/BamReader.h"
using namespace std;
using namespace BamTools;
// insert size calculate and return a inner average fragment coverage depth
bool GetInsersizeFromBam ( string bamInfile, map< string, pair<int, int> >& is, uint32_t n=200000 ); // RG => pair<int, int>. 'first' is mean, 'second' is SD
pair<int, int> MeanAndStddev ( vector<int> & v ); // pair.first = mean, pair.second = standard deviation
#endif
| 24.933333 | 157 | 0.68984 |
38bf896ac496e1931a0640b3e5b3644d63a70680 | 9,447 | h | C | ccc/ccc.h | doesthisusername/ccc | 572670290f6136be6a249f0089ee6af21de4eb5a | [
"MIT"
] | null | null | null | ccc/ccc.h | doesthisusername/ccc | 572670290f6136be6a249f0089ee6af21de4eb5a | [
"MIT"
] | null | null | null | ccc/ccc.h | doesthisusername/ccc | 572670290f6136be6a249f0089ee6af21de4eb5a | [
"MIT"
] | null | null | null | #pragma once
#include <map>
#include <set>
#include <vector>
#include <cstdio>
#include <memory>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <filesystem>
#include <inttypes.h>
// *****************************************************************************
// util.cpp
// *****************************************************************************
namespace fs = std::filesystem;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using s8 = int8_t;
using s16 = int16_t;
using s32 = int32_t;
using s64 = int64_t;
using buffer = std::vector<u8>;
// Like assert, but for user errors.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-security"
template <typename... Args>
void verify_impl(const char* file, int line, bool condition, const char* error_message, Args... args) {
if(!condition) {
fprintf(stderr, "[%s:%d] ", file, line);
fprintf(stderr, error_message, args...);
exit(1);
}
}
#define verify(condition, ...) \
verify_impl(__FILE__, __LINE__, condition, __VA_ARGS__)
template <typename... Args>
[[noreturn]] void verify_not_reached_impl(const char* file, int line, const char* error_message, Args... args) {
fprintf(stderr, "[%s:%d] ", file, line);
fprintf(stderr, error_message, args...);
exit(1);
}
#define verify_not_reached(...) \
verify_not_reached_impl(__FILE__, __LINE__, __VA_ARGS__)
#pragma GCC diagnostic pop
#ifdef _MSC_VER
#define packed_struct(name, ...) \
__pragma(pack(push, 1)) struct name { __VA_ARGS__ } __pragma(pack(pop));
#else
#define packed_struct(name, ...) \
struct __attribute__((__packed__)) name { __VA_ARGS__ };
#endif
template <typename T>
const T& get_packed(const std::vector<u8>& bytes, u64 offset, const char* subject) {
verify(bytes.size() >= offset + sizeof(T), "error: Failed to read %s.\n", subject);
return *(const T*) &bytes[offset];
}
buffer read_file_bin(fs::path const& filepath);
std::string read_string(const buffer& bytes, u64 offset);
struct Range {
s32 low;
s32 high;
};
#define BEGIN_END(x) (x).begin(), (x).end()
// *****************************************************************************
// Core data structures
// *****************************************************************************
struct ProgramImage {
std::vector<u8> bytes;
};
// This is like a simplified ElfSectionType.
enum class ProgramSectionType {
MIPS_DEBUG,
OTHER
};
struct ProgramSection {
u64 image;
u64 file_offset;
u64 size;
ProgramSectionType type;
};
enum class SymbolType : u32 {
NIL = 0,
GLOBAL = 1,
STATIC = 2,
PARAM = 3,
LOCAL = 4,
LABEL = 5,
PROC = 6,
BLOCK = 7,
END = 8,
MEMBER = 9,
TYPEDEF = 10,
FILE_SYMBOL = 11,
STATICPROC = 14,
CONSTANT = 15
};
enum class SymbolClass : u32 {
COMPILER_VERSION_INFO = 11
};
struct Symbol {
std::string string;
u32 value;
SymbolType storage_type;
SymbolClass storage_class;
u32 index;
};
struct SymFileDescriptor {
std::string name;
Range procedures;
std::vector<Symbol> symbols;
};
struct SymProcedureDescriptor {
std::string name;
};
struct SymbolTable {
std::vector<SymProcedureDescriptor> procedures;
std::vector<SymFileDescriptor> files;
u64 procedure_descriptor_table_offset;
u64 local_symbol_table_offset;
u64 file_descriptor_table_offset;
};
struct Program {
std::vector<ProgramImage> images;
std::vector<ProgramSection> sections;
};
// *****************************************************************************
// elf.cpp
// *****************************************************************************
ProgramImage read_program_image(fs::path path);
void parse_elf_file(Program& program, u64 image_index);
// *****************************************************************************
// mdebug.cpp
// *****************************************************************************
SymbolTable parse_symbol_table(const ProgramImage& image, const ProgramSection& section);
const char* symbol_type(SymbolType type);
const char* symbol_class(SymbolClass symbol_class);
// *****************************************************************************
// stabs.cpp
// *****************************************************************************
enum class StabsSymbolDescriptor : s8 {
LOCAL_VARIABLE = '\0',
A = 'a',
LOCAL_FUNCTION = 'f',
GLOBAL_FUNCTION = 'F',
GLOBAL_VARIABLE = 'G',
REGISTER_PARAMETER = 'P',
VALUE_PARAMETER = 'p',
REGISTER_VARIABLE = 'r',
STATIC_GLOBAL_VARIABLE = 's',
TYPE_NAME = 't',
ENUM_STRUCT_OR_TYPE_TAG = 'T',
STATIC_LOCAL_VARIABLE = 'V'
};
enum class StabsTypeDescriptor : s8 {
TYPE_REFERENCE = '\0',
ARRAY = 'a',
ENUM = 'e',
FUNCTION = 'f',
RANGE = 'r',
STRUCT = 's',
UNION = 'u',
CROSS_REFERENCE = 'x',
METHOD = '#',
REFERENCE = '&',
POINTER = '*',
SLASH = '/',
MEMBER = '@'
};
struct StabsBaseClass;
struct StabsField;
struct StabsMemberFunction;
// e.g. for "123=*456" 123 would be the type_number, the type descriptor would
// be of type POINTER and reference_or_pointer.value_type would point to a type
// with type_number = 456 and has_body = false.
struct StabsType {
// The name field is only populated for root types and cross references.
std::optional<std::string> name;
bool anonymous;
s32 type_number;
bool has_body;
// If !has_body, everything below isn't filled in.
StabsTypeDescriptor descriptor;
// Tagged "union" based on the value of the type descriptor.
struct {
std::unique_ptr<StabsType> type;
} type_reference;
struct {
std::unique_ptr<StabsType> index_type;
std::unique_ptr<StabsType> element_type;
} array_type;
struct {
std::vector<std::pair<s32, std::string>> fields;
} enum_type;
struct {
std::unique_ptr<StabsType> type;
} function_type;
struct {
std::unique_ptr<StabsType> type;
s64 low;
s64 high;
} range_type;
struct {
s64 size;
std::vector<StabsBaseClass> base_classes;
std::vector<StabsField> fields;
std::vector<StabsMemberFunction> member_functions;
} struct_or_union;
struct {
char type;
std::string identifier;
} cross_reference;
struct {
std::unique_ptr<StabsType> return_type;
std::unique_ptr<StabsType> class_type;
std::vector<StabsType> parameter_types;
} method;
struct {
std::unique_ptr<StabsType> value_type;
} reference_or_pointer;
};
enum class StabsFieldVisibility : s8 {
NONE = '\0',
PRIVATE = '0',
PROTECTED = '1',
PUBLIC = '2',
IGNORE = '9'
};
struct StabsBaseClass {
s8 visibility;
s32 offset;
StabsType type;
};
struct StabsField {
std::string name;
StabsFieldVisibility visibility = StabsFieldVisibility::NONE;
StabsType type;
bool is_static = false;
s32 offset = 0;
s32 size = 0;
std::string type_name;
};
struct StabsMemberFunctionField {
StabsType type;
StabsFieldVisibility visibility;
bool is_const;
bool is_volatile;
};
struct StabsMemberFunction {
std::string name;
std::vector<StabsMemberFunctionField> fields;
};
struct StabsSymbol {
std::string raw;
std::string name;
StabsSymbolDescriptor descriptor;
StabsType type;
Symbol mdebug_symbol;
};
std::vector<StabsSymbol> parse_stabs_symbols(const std::vector<Symbol>& input);
StabsSymbol parse_stabs_symbol(const char* input);
void print_stabs_type(const StabsType& type);
std::map<s32, const StabsType*> enumerate_numbered_types(const std::vector<StabsSymbol>& symbols);
// *****************************************************************************
// ast.cpp
// *****************************************************************************
struct TypeName {
std::string first_part;
std::vector<s32> array_indices;
};
enum class AstNodeDescriptor {
LEAF, ENUM, STRUCT, UNION, TYPEDEF
};
using EnumFields = std::vector<std::pair<s32, std::string>>;
struct AstBaseClass {
s8 visibility;
s32 offset;
std::string type_name;
};
struct AstNode {
bool is_static = false;
s32 offset;
s32 size;
std::string name;
AstNodeDescriptor descriptor;
std::vector<s32> array_indices;
bool top_level = false;
struct {
std::string type_name;
} leaf;
struct {
EnumFields fields;
} enum_type;
struct {
std::vector<AstBaseClass> base_classes;
std::vector<AstNode> fields;
} struct_or_union;
struct {
std::string type_name;
} typedef_type;
const StabsSymbol* symbol = nullptr;
// Fields below populated by deduplicate_type.
std::set<std::string> source_files;
bool conflicting_types = false; // Are there other differing types with the same name?
};
std::map<s32, TypeName> resolve_c_type_names(const std::map<s32, const StabsType*>& types);
struct FieldInfo {
bool is_static = false;
s32 offset;
s32 size;
const StabsType& type;
const std::string& name;
};
std::optional<AstNode> stabs_symbol_to_ast(const StabsSymbol& symbol, const std::map<s32, TypeName>& type_names);
std::vector<AstNode> deduplicate_ast(const std::vector<std::pair<std::string, std::vector<AstNode>>>& per_file_ast);
// *****************************************************************************
// print.cpp
// *****************************************************************************
enum class OutputLanguage {
CPP, JSON
};
void print_ast(FILE* output, const std::vector<AstNode>& ast_nodes, OutputLanguage language, bool verbose);
void print_c_ast_begin(FILE* output);
void print_c_forward_declarations(FILE* output, const std::vector<AstNode>& ast_nodes);
void print_c_ast_node(FILE* output, const AstNode& node, s32 depth, s32 absolute_parent_offset);
| 25.125 | 116 | 0.639251 |
751890c885db9c205e9ef6774a28fefb3a90d59a | 282 | h | C | FNLApp/FLFAboutViewController.h | woudini/fnlmobileexperience | 6058e66a98b1e046286c0f94312771dc3fc46827 | [
"MIT"
] | null | null | null | FNLApp/FLFAboutViewController.h | woudini/fnlmobileexperience | 6058e66a98b1e046286c0f94312771dc3fc46827 | [
"MIT"
] | null | null | null | FNLApp/FLFAboutViewController.h | woudini/fnlmobileexperience | 6058e66a98b1e046286c0f94312771dc3fc46827 | [
"MIT"
] | null | null | null | //
// FLFAboutViewController.h
// FNLApp
//
// Created by Woudini on 4/17/15.
// Copyright (c) 2015 Hi Range. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FLFAboutViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *textView;
@end
| 18.8 | 58 | 0.723404 |
ced8fea7f041bcc943a32eb79727eadad4a193c0 | 3,340 | h | C | sys/dev/ic/malo.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | 1 | 2019-02-16T13:29:23.000Z | 2019-02-16T13:29:23.000Z | sys/dev/ic/malo.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | 1 | 2018-08-21T03:56:33.000Z | 2018-08-21T03:56:33.000Z | sys/dev/ic/malo.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | null | null | null | /* $OpenBSD: malo.h,v 1.12 2013/12/06 21:03:03 deraadt Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2006 Marcus Glocker <mglocker@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
struct malo_rx_desc;
struct malo_rx_data;
struct malo_rx_ring {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_addr_t physaddr;
struct malo_rx_desc *desc;
struct malo_rx_data *data;
int count;
int cur;
int next;
};
struct malo_tx_desc;
struct malo_tx_data;
struct malo_tx_ring {
bus_dmamap_t map;
bus_dma_segment_t seg;
bus_addr_t physaddr;
struct malo_tx_desc *desc;
struct malo_tx_data *data;
int count;
int queued;
int cur;
int next;
int stat;
};
#define MALO_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_RSSI))
struct malo_rx_radiotap_hdr {
struct ieee80211_radiotap_header wr_ihdr;
uint8_t wr_flags;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
uint8_t wr_rssi;
uint8_t wr_max_rssi;
} __packed;
#define MALO_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct malo_tx_radiotap_hdr {
struct ieee80211_radiotap_header wt_ihdr;
uint8_t wt_flags;
uint8_t wt_rate;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
} __packed;
struct malo_softc {
struct device sc_dev;
struct ieee80211com sc_ic;
struct malo_rx_ring sc_rxring;
struct malo_tx_ring sc_txring;
bus_dma_tag_t sc_dmat;
bus_space_tag_t sc_mem1_bt;
bus_space_tag_t sc_mem2_bt;
bus_space_handle_t sc_mem1_bh;
bus_space_handle_t sc_mem2_bh;
bus_dmamap_t sc_cmd_dmam;
bus_dma_segment_t sc_cmd_dmas;
void *sc_cmd_mem;
bus_addr_t sc_cmd_dmaaddr;
uint32_t *sc_cookie;
bus_addr_t sc_cookie_dmaaddr;
uint32_t sc_RxPdWrPtr;
uint32_t sc_RxPdRdPtr;
int (*sc_newstate)
(struct ieee80211com *,
enum ieee80211_state, int);
int (*sc_enable)(struct malo_softc *);
void (*sc_disable)(struct malo_softc *);
struct timeout sc_scan_to;
int sc_tx_timer;
int sc_last_txrate;
#if NBPFILTER > 0
caddr_t sc_drvbpf;
union {
struct malo_rx_radiotap_hdr th;
uint8_t pad[64];
} sc_rxtapu;
#define sc_rxtap sc_rxtapu.th
int sc_rxtap_len;
union {
struct malo_tx_radiotap_hdr th;
uint8_t pad[64];
} sc_txtapu;
#define sc_txtap sc_txtapu.th
int sc_txtap_len;
#endif
};
int malo_intr(void *arg);
int malo_attach(struct malo_softc *sc);
int malo_detach(void *arg);
int malo_init(struct ifnet *);
void malo_stop(struct malo_softc *);
| 24.925373 | 75 | 0.74521 |
e074d032d052f2a90273ee77913032ac2abb78d1 | 2,814 | c | C | src/drivers/serial.c | tcr/jiauliyan-os | cf49c76c3e3c2568e6bd66c1c053ace7caba81b6 | [
"MIT"
] | 3 | 2015-02-20T19:05:42.000Z | 2021-01-17T05:54:43.000Z | src/drivers/serial.c | tcr/jiauliyan-os | cf49c76c3e3c2568e6bd66c1c053ace7caba81b6 | [
"MIT"
] | null | null | null | src/drivers/serial.c | tcr/jiauliyan-os | cf49c76c3e3c2568e6bd66c1c053ace7caba81b6 | [
"MIT"
] | null | null | null | /*
* Jiauliyan OS - Released under the MIT License
* Copyright (C) 2011 Paul Booth, Jialiya Huang, Tim Ryan
* https://github.com/timcameronryan/jiauliyan
*
* Based on code from the OSDev wiki
* http://wiki.osdev.org/Serial_ports
*/
#include <system.h>
#include <stream.h>
#include <string.h>
#include <common.h>
#define PORT 0x3f8 /* COM1 */
#define SERIAL_BUF_SIZE 1024*128
/*
* serial port
*/
// flag if serial data has been received
int serial_received()
{
return inportb(PORT + 5) & 1;
}
// flag if transit is clear to send data
int serial_transit_empty()
{
return inportb(PORT + 5) & 0x20;
}
unsigned char serial_get()
{
while (serial_received() == 0);
return inportb(PORT);
}
void serial_put(unsigned char a)
{
while (serial_transit_empty() == 0);
outportb(PORT, a);
}
/*
* interrupt/buffer
*/
unsigned char serial_buf[SERIAL_BUF_SIZE];
int serial_buf_len = 0;
void (*serial_handler)(unsigned char *buf, long int size) = NULL;
void serial_set_handler(void (*callback)(unsigned char *buf, long int size))
{
serial_handler = callback;
}
void serial_flush()
{
if (serial_buf_len > 0) {
disable_interrupts();
if (serial_handler != NULL)
serial_handler(serial_buf, serial_buf_len);
serial_buf_len = 0;
enable_interrupts();
}
}
void serial_interrupt(struct regs *r)
{
UNUSED(r);
if (serial_received()) {
serial_buf[serial_buf_len++] = serial_get();
if (serial_buf_len == SERIAL_BUF_SIZE)
serial_flush();
}
}
/*
* serial in implementation
*/
int serialin_get(stream_s *stream)
{
UNUSED(stream);
// read from serial buffer
if (serial_buf_len == 0)
return EOF;
unsigned char c = serial_buf[0];
memcpy(serial_buf, serial_buf + 1, --serial_buf_len);
return c;
}
long int serialin_avail(stream_s *stream)
{
UNUSED(stream);
return serial_buf_len;
}
int serialout_put(stream_s *stream, unsigned char c)
{
UNUSED(stream);
serial_put((char) c);
return (int) c;
}
stream_s *serialout;
stream_s *serialin;
/*
* install
*/
void serial_install()
{
outportb(PORT + 1, 0x01); // enable Received Data Available interrupt
outportb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor)
outportb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud
outportb(PORT + 1, 0x00); // (hi byte) * 3
outportb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit
outportb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
outportb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
/* Installs 'serial_handler' to IRQ4 */
irq_install_handler(4, serial_interrupt);
// create streams
serialout = stream_create(stream_no_get, serialout_put, stream_no_avail, stream_no_seek, NULL);
serialin = stream_create(serialin_get, stream_no_put, serialin_avail, stream_no_seek, NULL);
}
| 21.157895 | 96 | 0.691898 |
6d87420b7bc7ab7e995d050829961567bfcd85ab | 985 | c | C | src/des/or_exclusif_2.c | fbonhomm/ft_ssl_md5--ft_ssl_des | 345c6279e54c2482977d6af54e8bc1f93c9c0031 | [
"MIT"
] | null | null | null | src/des/or_exclusif_2.c | fbonhomm/ft_ssl_md5--ft_ssl_des | 345c6279e54c2482977d6af54e8bc1f93c9c0031 | [
"MIT"
] | null | null | null | src/des/or_exclusif_2.c | fbonhomm/ft_ssl_md5--ft_ssl_des | 345c6279e54c2482977d6af54e8bc1f93c9c0031 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* or_exclusif_2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fbonhomm <fbonhomm@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/17 22:50:50 by fbonhomm #+# #+# */
/* Updated: 2018/11/17 22:51:15 by fbonhomm ### ########.fr */
/* */
/* ************************************************************************** */
#include <ft_ssl.h>
void or_exclusif_2(uint32_t left, uint32_t *right)
{
*right ^= left;
}
| 51.842105 | 80 | 0.174619 |
d497c9e73b7483c9a1391fe7bd805996ef6e15b9 | 151 | h | C | shmem.h | RyanFisk2/GWU_OS_FINAL | 6511b4a9d847ced79458151bc5035650bf54fbe2 | [
"MIT-0"
] | 1 | 2021-01-05T18:13:01.000Z | 2021-01-05T18:13:01.000Z | shmem.h | RyanFisk2/GWU_OS_FINAL | 6511b4a9d847ced79458151bc5035650bf54fbe2 | [
"MIT-0"
] | null | null | null | shmem.h | RyanFisk2/GWU_OS_FINAL | 6511b4a9d847ced79458151bc5035650bf54fbe2 | [
"MIT-0"
] | null | null | null | #include "types.h"
struct shared_mem{
char name[16];
uint pa;
uint refcount;
uint in_use;
int container_id;
}; | 16.777778 | 25 | 0.543046 |
edaf04adfed91aeaf882b40a6abdb8e51ebeb749 | 4,752 | h | C | EzmaxApi/Model/EZEzsigntemplateformfieldgroupResponseCompound.h | ezmaxinc/eZmax-SDK-objc | 2d36884daef77a08c359216daf38e2d5f8108da9 | [
"MIT"
] | null | null | null | EzmaxApi/Model/EZEzsigntemplateformfieldgroupResponseCompound.h | ezmaxinc/eZmax-SDK-objc | 2d36884daef77a08c359216daf38e2d5f8108da9 | [
"MIT"
] | null | null | null | EzmaxApi/Model/EZEzsigntemplateformfieldgroupResponseCompound.h | ezmaxinc/eZmax-SDK-objc | 2d36884daef77a08c359216daf38e2d5f8108da9 | [
"MIT"
] | null | null | null | #import <Foundation/Foundation.h>
#import "EZObject.h"
/**
* eZmax API Definition (Full)
* This API expose all the functionnalities for the eZmax and eZsign applications.
*
* The version of the OpenAPI document: 1.1.7
* Contact: support-api@ezmax.ca
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#import "EZCustomDropdownElementResponseCompound.h"
#import "EZEzsigntemplateformfieldResponseCompound.h"
#import "EZEzsigntemplateformfieldgroupResponse.h"
#import "EZEzsigntemplateformfieldgroupResponseCompoundAllOf.h"
#import "EZEzsigntemplateformfieldgroupsignerResponseCompound.h"
#import "EZFieldEEzsigntemplateformfieldgroupSignerrequirement.h"
#import "EZFieldEEzsigntemplateformfieldgroupTooltipposition.h"
#import "EZFieldEEzsigntemplateformfieldgroupType.h"
@protocol EZCustomDropdownElementResponseCompound;
@class EZCustomDropdownElementResponseCompound;
@protocol EZEzsigntemplateformfieldResponseCompound;
@class EZEzsigntemplateformfieldResponseCompound;
@protocol EZEzsigntemplateformfieldgroupResponse;
@class EZEzsigntemplateformfieldgroupResponse;
@protocol EZEzsigntemplateformfieldgroupResponseCompoundAllOf;
@class EZEzsigntemplateformfieldgroupResponseCompoundAllOf;
@protocol EZEzsigntemplateformfieldgroupsignerResponseCompound;
@class EZEzsigntemplateformfieldgroupsignerResponseCompound;
@protocol EZFieldEEzsigntemplateformfieldgroupSignerrequirement;
@class EZFieldEEzsigntemplateformfieldgroupSignerrequirement;
@protocol EZFieldEEzsigntemplateformfieldgroupTooltipposition;
@class EZFieldEEzsigntemplateformfieldgroupTooltipposition;
@protocol EZFieldEEzsigntemplateformfieldgroupType;
@class EZFieldEEzsigntemplateformfieldgroupType;
@protocol EZEzsigntemplateformfieldgroupResponseCompound
@end
@interface EZEzsigntemplateformfieldgroupResponseCompound : EZObject
/* The unique ID of the Ezsigntemplateformfieldgroup
*/
@property(nonatomic) NSNumber* pkiEzsigntemplateformfieldgroupID;
/* The unique ID of the Ezsigntemplatedocument
*/
@property(nonatomic) NSNumber* fkiEzsigntemplatedocumentID;
@property(nonatomic) EZFieldEEzsigntemplateformfieldgroupType* eEzsigntemplateformfieldgroupType;
@property(nonatomic) EZFieldEEzsigntemplateformfieldgroupSignerrequirement* eEzsigntemplateformfieldgroupSignerrequirement;
/* The Label for the Ezsigntemplateformfieldgroup
*/
@property(nonatomic) NSString* sEzsigntemplateformfieldgroupLabel;
/* The step when the Ezsigntemplatesigner will be invited to fill the form fields
*/
@property(nonatomic) NSNumber* iEzsigntemplateformfieldgroupStep;
/* The default value for the Ezsigntemplateformfieldgroup
*/
@property(nonatomic) NSString* sEzsigntemplateformfieldgroupDefaultvalue;
/* The minimum number of Ezsigntemplateformfield that must be filled in the Ezsigntemplateformfieldgroup
*/
@property(nonatomic) NSNumber* iEzsigntemplateformfieldgroupFilledmin;
/* The maximum number of Ezsigntemplateformfield that must be filled in the Ezsigntemplateformfieldgroup
*/
@property(nonatomic) NSNumber* iEzsigntemplateformfieldgroupFilledmax;
/* Whether the Ezsigntemplateformfieldgroup is read only or not.
*/
@property(nonatomic) NSNumber* bEzsigntemplateformfieldgroupReadonly;
/* The maximum length for the value in the Ezsigntemplateformfieldgroup This can only be set if eEzsigntemplateformfieldgroupType is **Text** or **Textarea** [optional]
*/
@property(nonatomic) NSNumber* iEzsigntemplateformfieldgroupMaxlength;
/* Whether the Ezsigntemplateformfieldgroup is encrypted in the database or not. Encrypted values are not displayed on the Ezsigndocument. This can only be set if eEzsigntemplateformfieldgroupType is **Text** or **Textarea** [optional]
*/
@property(nonatomic) NSNumber* bEzsigntemplateformfieldgroupEncrypted;
/* A regular expression to indicate what values are acceptable for the Ezsigntemplateformfieldgroup. This can only be set if eEzsigntemplateformfieldgroupType is **Text** or **Textarea** [optional]
*/
@property(nonatomic) NSString* sEzsigntemplateformfieldgroupRegexp;
/* A tooltip that will be presented to Ezsigntemplatesigner about the Ezsigntemplateformfieldgroup [optional]
*/
@property(nonatomic) NSString* tEzsigntemplateformfieldgroupTooltip;
@property(nonatomic) EZFieldEEzsigntemplateformfieldgroupTooltipposition* eEzsigntemplateformfieldgroupTooltipposition;
@property(nonatomic) NSArray<EZEzsigntemplateformfieldgroupsignerResponseCompound>* aObjEzsigntemplateformfieldgroupsigner;
@property(nonatomic) NSArray<EZCustomDropdownElementResponseCompound>* aObjDropdownElement;
@property(nonatomic) NSArray<EZEzsigntemplateformfieldResponseCompound>* aObjEzsigntemplateformfield;
@end
| 48 | 235 | 0.856902 |
72664fefb17c1f3acc6daba25b66e580216a80f4 | 1,432 | h | C | NJKCategory/NJK_Category/Chain/UITextView+NJKChain.h | jiangkuoniu/NJKDemo | 046502f00e65f7f8bc5fe72236bce2c16e5e8496 | [
"MIT"
] | null | null | null | NJKCategory/NJK_Category/Chain/UITextView+NJKChain.h | jiangkuoniu/NJKDemo | 046502f00e65f7f8bc5fe72236bce2c16e5e8496 | [
"MIT"
] | null | null | null | NJKCategory/NJK_Category/Chain/UITextView+NJKChain.h | jiangkuoniu/NJKDemo | 046502f00e65f7f8bc5fe72236bce2c16e5e8496 | [
"MIT"
] | null | null | null | //
// UITextView+NJKChain.h
// NJK-Kit
//
// Created by njk on 2020/8/19.
// Copyright © 2020 NJK. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UITextView (NJKChain)
- (UITextView *(^)(NSString *text))njk_text;
- (UITextView *(^)(UIFont *font))njk_font;
- (UITextView *(^)(UIColor *textColor))njk_textColor;
- (UITextView *(^)(NSTextAlignment textAlignment))njk_textAlignment;
- (UITextView *(^)(NSRange selectedRange))njk_selectedRange;
- (UITextView *(^)(BOOL selectedRange))njk_editable;
- (UITextView *(^)(BOOL selectable))njk_selectable;
- (UITextView *(^)(UIDataDetectorTypes dataDetectorTypes))njk_dataDetectorTypes;
- (UITextView *(^)(BOOL allowsEditingTextAttributes))njk_allowsEditingTextAttributes;
- (UITextView *(^)(NSAttributedString *attributedText))njk_attributedText;
- (UITextView *(^)(NSDictionary<NSAttributedStringKey, id> *typingAttributes))njk_typingAttributes;
- (UITextView *(^)(UIView *inputView))njk_inputView;
- (UITextView *(^)(UIView *inputAccessoryView))njk_inputAccessoryView;
- (UITextView *(^)(BOOL clearsOnInsertion))njk_clearsOnInsertion;
- (UITextView *(^)(UIEdgeInsets textContainerInset))njk_textContainerInset;
- (UITextView *(^)(NSDictionary<NSAttributedStringKey,id> *linkTextAttributes))njk_linkTextAttributes;
- (UITextView *(^)(BOOL usesStandardTextScaling))njk_usesStandardTextScaling API_AVAILABLE(ios(13.0));
@end
NS_ASSUME_NONNULL_END
| 39.777778 | 102 | 0.769553 |
c255815f3c5dc9f990a9a642d555b106998666e6 | 2,352 | h | C | src/Network/TCPServer.h | dmalysiak/Lazarus | 925d92843e311d2cd5afd437766563d0d5ab9052 | [
"Apache-2.0"
] | 1 | 2019-04-29T05:31:32.000Z | 2019-04-29T05:31:32.000Z | src/Network/TCPServer.h | dmalysiak/Lazarus | 925d92843e311d2cd5afd437766563d0d5ab9052 | [
"Apache-2.0"
] | null | null | null | src/Network/TCPServer.h | dmalysiak/Lazarus | 925d92843e311d2cd5afd437766563d0d5ab9052 | [
"Apache-2.0"
] | null | null | null | /*
* TCPServer.h
*
* Created on: 28.02.2013
* Author: Darius Malysiak
*/
#ifndef TCPSERVER_H_
#define TCPSERVER_H_
#include "TCPSocket.h"
#include "../Threading/Thread.h"
#include "TCPServerWorkerThread.h"
#include "CommunicationFacility.h"
#include <sys/epoll.h>
#include <stdio.h>
#include <string>
namespace Lazarus
{
class TCPServer: public Lazarus::Thread {
public:
TCPServer(std::string local_address, unsigned int local_port, unsigned int max_connections,
unsigned int worker_threads);
virtual ~TCPServer();
void startServer();
/*
* This is equivalent with calling 'shutdown()' of the 'Thread' class, i.e. this method will only call 'shutdown()',
* nothing more than that!
*/
void stopServer();
/*
* This method should handle all incoming connection >requests<,
* it is the only method which will be executed by the thread
*/
virtual void listener_method() = 0;
virtual void createWorkerThreads() = 0;
virtual void run();
virtual void preFlag();
static const int LISTENER_QUEUE_SIZE = 20;
static const int SHUTDOWN_DELAY_MS = 1000;
static const int MAX_EPOLL_EVENTS = 64;
/**
* Returns the servers current IP address.
* */
std::string getAddress();
/**
* Returns the servers current port.
* */
unsigned int getPort();
void setConnectCallback(ConnectCallback* connect_callback);
void setDisconnectCallback(DisconnectCallback* disconnect_callback);
protected:
std::string m_local_address;
unsigned int m_local_port;
TCPSocket* mp_socket;
unsigned int m_current_connections;
unsigned int m_max_connections;
TCPServerWorkerThread** mp_worker_threads;
unsigned int m_worker_thread_count;
//********************* epoll system
int m_epoll_in_fd;
struct epoll_event* mp_active_in_events;
int m_epoll_read_poker;//poker for the listener
unsigned int m_run_count;
/**
* The communication facility will be used to enable all threads to communicate among each other.
* It will be forwarded up to the frame handler!
* Ownership will never be forwarded!! I.e. this class will destroy it! (even if a far child class created it!)
*/
CommunicationFacility* mp_cn_node_facility;
//callback object for disconnect
DisconnectCallback* mp_disconnect_callback;
//callback object for disconnect
ConnectCallback* mp_connect_callback;
};
}
#endif /* TCPSERVER_H_ */
| 22.4 | 117 | 0.740646 |
b035c68d0af76692b8e9850de06c8cb63f3203cb | 8,270 | h | C | EntitiesMP/EnvironmentParticlesHolder_tables.h | openlastchaos/lastchaos-source-client | 3d88594dba7347b1bb45378136605e31f73a8555 | [
"Apache-2.0"
] | 1 | 2022-02-14T15:46:44.000Z | 2022-02-14T15:46:44.000Z | EntitiesMP/EnvironmentParticlesHolder_tables.h | openlastchaos/lastchaos-source-client | 3d88594dba7347b1bb45378136605e31f73a8555 | [
"Apache-2.0"
] | null | null | null | EntitiesMP/EnvironmentParticlesHolder_tables.h | openlastchaos/lastchaos-source-client | 3d88594dba7347b1bb45378136605e31f73a8555 | [
"Apache-2.0"
] | 2 | 2022-01-10T22:17:06.000Z | 2022-01-17T09:34:08.000Z | /*
* This file is generated by Entity Class Compiler, (c) CroTeam 1997-98
*/
EP_ENUMBEG(EnvironmentParticlesHolderType)
EP_ENUMVALUE(EPTH_NONE, "None"),
EP_ENUMVALUE(EPTH_GROWTH, "Growth"),
EP_ENUMVALUE(EPTH_RAIN, "Rain"),
EP_ENUMVALUE(EPTH_SNOW, "Snow"),
EP_ENUMEND(EnvironmentParticlesHolderType);
CEntityEvent *EWeatherStart_New(void) { return new EWeatherStart; };
CDLLEntityEvent DLLEvent_EWeatherStart = {
0x00ed0000, &EWeatherStart_New
};
CEntityEvent *EWeatherStop_New(void) { return new EWeatherStop; };
CDLLEntityEvent DLLEvent_EWeatherStop = {
0x00ed0001, &EWeatherStop_New
};
CDLLEntityEvent *CEnvironmentParticlesHolder_events[] = {
&DLLEvent_EWeatherStop,
&DLLEvent_EWeatherStart,
};
#define CEnvironmentParticlesHolder_eventsct ARRAYCOUNT(CEnvironmentParticlesHolder_events)
#define ENTITYCLASS CEnvironmentParticlesHolder
CEntityProperty CEnvironmentParticlesHolder_properties[] = {
CEntityProperty(CEntityProperty::EPT_STRING, NULL, (0x000000ed<<8)+1, offsetof(CEnvironmentParticlesHolder, m_strName), "Name", 'N', 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_STRING, NULL, (0x000000ed<<8)+6, offsetof(CEnvironmentParticlesHolder, m_strDescription), "", 0, 0, 0),
CEntityProperty(CEntityProperty::EPT_FILENAME, NULL, (0x000000ed<<8)+2, offsetof(CEnvironmentParticlesHolder, m_fnHeightMap), "Height map", 'R', 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOATAABBOX3D, NULL, (0x000000ed<<8)+3, offsetof(CEnvironmentParticlesHolder, m_boxHeightMap), "Height map box", 'B', 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_ENUM, &EnvironmentParticlesHolderType_enum, (0x000000ed<<8)+4, offsetof(CEnvironmentParticlesHolder, m_eptType), "Type", 'Y', 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_ENTITYPTR, NULL, (0x000000ed<<8)+5, offsetof(CEnvironmentParticlesHolder, m_penNextHolder), "Next env. particles holder", 'T', 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+10, offsetof(CEnvironmentParticlesHolder, m_tmRainStart), "", 0, 0, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+11, offsetof(CEnvironmentParticlesHolder, m_tmRainEnd), "", 0, 0, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+12, offsetof(CEnvironmentParticlesHolder, m_tmSnowStart), "", 0, 0, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+13, offsetof(CEnvironmentParticlesHolder, m_tmSnowEnd), "", 0, 0, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_MODELOBJECT, NULL, (0x000000ed<<8)+20, offsetof(CEnvironmentParticlesHolder, m_moHeightMapHolder), "", 0, 0, 0),
CEntityProperty(CEntityProperty::EPT_MODELOBJECT, NULL, (0x000000ed<<8)+22, offsetof(CEnvironmentParticlesHolder, m_moParticleTextureHolder), "", 0, 0, 0),
CEntityProperty(CEntityProperty::EPT_FILENAME, NULL, (0x000000ed<<8)+40, offsetof(CEnvironmentParticlesHolder, m_fnTexture), "Particle Texture", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+50, offsetof(CEnvironmentParticlesHolder, m_fGrowthRenderingStep), "Growth frequency", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+51, offsetof(CEnvironmentParticlesHolder, m_fGrowthRenderingRadius), "Growth radius", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+52, offsetof(CEnvironmentParticlesHolder, m_fGrowthRenderingRadiusFade), "Growth fade radius", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_BOOL, NULL, (0x000000ed<<8)+53, offsetof(CEnvironmentParticlesHolder, m_bGrowthHighresMap), "Growth high res map", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_INDEX, NULL, (0x000000ed<<8)+54, offsetof(CEnvironmentParticlesHolder, m_iGrowthMapX), "Growth map tiles X", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_INDEX, NULL, (0x000000ed<<8)+55, offsetof(CEnvironmentParticlesHolder, m_iGrowthMapY), "Growth map tiles Y", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+56, offsetof(CEnvironmentParticlesHolder, m_fGrowthMinSize), "Growth min. size", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+57, offsetof(CEnvironmentParticlesHolder, m_fGrowthMaxSize), "Growth max. size", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+58, offsetof(CEnvironmentParticlesHolder, m_fParticlesSinkFactor), "Growth sink factor", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+70, offsetof(CEnvironmentParticlesHolder, m_fRainAppearLen), "Rain start duration", 0, 0x7F0000FFUL, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+71, offsetof(CEnvironmentParticlesHolder, m_fSnowAppearLen), "Snow start duration", 0, 0x7F0000FFUL, EPROPF_NETSEND ),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+72, offsetof(CEnvironmentParticlesHolder, m_fParticleSize), "Particle Size Scale", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_INDEX, NULL, (0x000000ed<<8)+73, offsetof(CEnvironmentParticlesHolder, m_iParticleCount), "Particle Count", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+74, offsetof(CEnvironmentParticlesHolder, m_vWindX), "Wind Direction X", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+75, offsetof(CEnvironmentParticlesHolder, m_vWindZ), "Wind Direction Z", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_FLOAT, NULL, (0x000000ed<<8)+76, offsetof(CEnvironmentParticlesHolder, m_vDropSpeed), "Drop Speed Scale", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_COLOR, NULL, (0x000000ed<<8)+77, offsetof(CEnvironmentParticlesHolder, m_colParticle), "Particle Color", 0, 0x7F0000FFUL, 0),
CEntityProperty(CEntityProperty::EPT_BOOL, NULL, (0x000000ed<<8)+80, offsetof(CEnvironmentParticlesHolder, m_bRenderOutsideBox), "Render outside box", 0, 0x7F0000FFUL, EPROPF_NETSEND ),
};
#define CEnvironmentParticlesHolder_propertiesct ARRAYCOUNT(CEnvironmentParticlesHolder_properties)
CEntityComponent CEnvironmentParticlesHolder_components[] = {
#define MODEL_ENVIRONMENT_PARTICLES_HOLDER ((0x000000ed<<8)+1)
CEntityComponent(ECT_MODEL, MODEL_ENVIRONMENT_PARTICLES_HOLDER, 2, "EFNM" "Data\\ModelsMP\\Editor\\EnvironmentParticlesHolder.mdl"),
#define TEXTURE_ENVIRONMENT_PARTICLES_HOLDER ((0x000000ed<<8)+2)
CEntityComponent(ECT_TEXTURE, TEXTURE_ENVIRONMENT_PARTICLES_HOLDER, 2, "EFNM" "Data\\ModelsMP\\Editor\\EnvironmentParticlesHolder.tex"),
};
#define CEnvironmentParticlesHolder_componentsct ARRAYCOUNT(CEnvironmentParticlesHolder_components)
CEventHandlerEntry CEnvironmentParticlesHolder_handlers[] = {
{1, -1, CEntity::pEventHandler(&CEnvironmentParticlesHolder::
#line 167 "C:/Users/pwesty/Desktop/SD-Source/nov-source/Reco_Csrc/EntitiesMP/EnvironmentParticlesHolder.es"
Main),DEBUGSTRING("CEnvironmentParticlesHolder::Main")},
{0x00ed0002, -1, CEntity::pEventHandler(&CEnvironmentParticlesHolder::H0x00ed0002_Main_01), DEBUGSTRING("CEnvironmentParticlesHolder::H0x00ed0002_Main_01")},
{0x00ed0003, -1, CEntity::pEventHandler(&CEnvironmentParticlesHolder::H0x00ed0003_Main_02), DEBUGSTRING("CEnvironmentParticlesHolder::H0x00ed0003_Main_02")},
};
#define CEnvironmentParticlesHolder_handlersct ARRAYCOUNT(CEnvironmentParticlesHolder_handlers)
CEntity *CEnvironmentParticlesHolder_New(void) { return new CEnvironmentParticlesHolder; };
void CEnvironmentParticlesHolder_OnInitClass(void) {};
void CEnvironmentParticlesHolder_OnEndClass(void) {};
void CEnvironmentParticlesHolder_OnPrecache(CDLLEntityClass *pdec, INDEX iUser) {};
void CEnvironmentParticlesHolder_OnWorldEnd(CWorld *pwo) {};
void CEnvironmentParticlesHolder_OnWorldInit(CWorld *pwo) {};
void CEnvironmentParticlesHolder_OnWorldTick(CWorld *pwo) {};
void CEnvironmentParticlesHolder_OnWorldRender(CWorld *pwo) {};
ENTITY_CLASSDEFINITION(CEnvironmentParticlesHolder, CRationalEntity, "EnvironmentParticlesHolder", "Thumbnails\\EnvironmentParticlesHolder.tbn", 0x000000ed);
DECLARE_CTFILENAME(_fnmCEnvironmentParticlesHolder_tbn, "Thumbnails\\EnvironmentParticlesHolder.tbn");
| 92.921348 | 186 | 0.813785 |
e6e58ed8084a7168a7f680044db33bfd21fec81d | 670 | h | C | src/grib_nearest_class.h | bbakernoaa/eccodes | 61eb6daac46f6f2b9959b506df5565fb9e763c40 | [
"Apache-2.0"
] | 103 | 2018-12-11T09:10:19.000Z | 2022-03-15T11:30:26.000Z | src/grib_nearest_class.h | bbakernoaa/eccodes | 61eb6daac46f6f2b9959b506df5565fb9e763c40 | [
"Apache-2.0"
] | 45 | 2019-01-02T18:52:32.000Z | 2022-02-11T13:15:03.000Z | src/grib_nearest_class.h | bbakernoaa/eccodes | 61eb6daac46f6f2b9959b506df5565fb9e763c40 | [
"Apache-2.0"
] | 60 | 2018-12-27T00:03:25.000Z | 2022-02-09T13:34:47.000Z | /* This file is automatically generated by ./make_class.pl, do not edit */
extern grib_nearest_class* grib_nearest_class_gen;
extern grib_nearest_class* grib_nearest_class_lambert_azimuthal_equal_area;
extern grib_nearest_class* grib_nearest_class_lambert_conformal;
extern grib_nearest_class* grib_nearest_class_latlon_reduced;
extern grib_nearest_class* grib_nearest_class_mercator;
extern grib_nearest_class* grib_nearest_class_polar_stereographic;
extern grib_nearest_class* grib_nearest_class_reduced;
extern grib_nearest_class* grib_nearest_class_regular;
extern grib_nearest_class* grib_nearest_class_sh;
extern grib_nearest_class* grib_nearest_class_space_view;
| 55.833333 | 75 | 0.895522 |
da486f54a6723158d87c79c4d95010bd6b4dfe15 | 311 | c | C | File/simple_write.c | Becavalier/Linux-Library | b6d391f9b3f546bfc9e6f9404774765fc6b52937 | [
"MIT"
] | 1 | 2016-10-09T01:13:25.000Z | 2016-10-09T01:13:25.000Z | File/simple_write.c | Becavalier/Linux-Library | b6d391f9b3f546bfc9e6f9404774765fc6b52937 | [
"MIT"
] | null | null | null | File/simple_write.c | Becavalier/Linux-Library | b6d391f9b3f546bfc9e6f9404774765fc6b52937 | [
"MIT"
] | null | null | null | #include <unistd.h>
#include <stdlib.h>
int main() {
/**
* fildes: 0(标准输入), 1(标准输出), 2(错误输出)
* prototype: size_t write(int fildes, const void *buf, size_t nbytes);
*/
if (write(1, "Here is some data\n", 18) != 18) {
write(2, "A wirte error has occurred on file descriptor 1\n", 46);
}
exit(0);
} | 19.4375 | 72 | 0.607717 |
92c642decfe7b97c4bbbaa0322d71670e074f3b8 | 2,708 | h | C | include/smp/components/model_checkers/mu_calculus.h | reobaird/srl_global_planner | e2a4b3ea60a0b870aba0ca3e96ea07899c411bd2 | [
"BSD-3-Clause"
] | 120 | 2016-09-01T07:06:43.000Z | 2022-03-08T23:07:50.000Z | include/smp/components/model_checkers/mu_calculus.h | dz306271098/srl_global_planner | e2a4b3ea60a0b870aba0ca3e96ea07899c411bd2 | [
"BSD-3-Clause"
] | 7 | 2015-08-26T05:24:46.000Z | 2021-03-17T06:57:28.000Z | include/smp/components/model_checkers/mu_calculus.h | dz306271098/srl_global_planner | e2a4b3ea60a0b870aba0ca3e96ea07899c411bd2 | [
"BSD-3-Clause"
] | 56 | 2015-08-07T07:54:06.000Z | 2021-11-12T01:14:57.000Z | /*! \file components/model_checkers/mu_calculus.h
\brief The mu-calculus model checker.
This includes an implementation of the mu-calculus model checker.
*/
#ifndef _SMP_MODEL_CHECKER_MU_CALCULUS_H_
#define _SMP_MODEL_CHECKER_MU_CALCULUS_H_
#include <smp/components/model_checkers/base.h>
#include <smp/external_libraries/inc_mu_mc/ms.h>
#include <smp/external_libraries/inc_mu_mc/pt.h>
namespace smp {
//! Implements the vertex data for mu-calculus model checking
/*!
The data stored in each vertex of the graph required for the mu-calculus model
checking operation.
*/
class model_checker_mu_calculus_vertex_data {
public:
//! State variable for mu-calculus model checking library.
/*!
This variable is a data type used by the external mu-calculus model
checking library. The class holds the set of all sub-formula of the
specification that the associated vertex satisfies. It is incrementally
updated by the procedure.
*/
MS_state *state;
};
//! Implements the edge data for mu-calculus model checking
/*!
This empty class is implemented for the sake of completeness.
*/
class model_checker_mu_calculus_edge_data {
};
//! Implements the mu-calculus model checker.
/*!
This class inherits from the model_checker_base class. It implements the
mu-calculus model checker using the mu-calculus external libraries that are
included with the smp library.
\ingroup model_checkers
*/
template< class typeparams >
class model_checker_mu_calculus : public model_checker_base<typeparams>{
typedef typename typeparams::state state_t;
typedef typename typeparams::input input_t;
typedef vertex<typeparams> vertex_t;
typedef edge<typeparams> edge_t;
typedef trajectory<typeparams> trajectory_t;
int uid_counter;
bool found_solution;
public:
//! An instance of the mu-calculus model checker external library.
/*!
This variable instantiates the main class of the external library that
carries out the mu-calculus model checking operation.
*/
rModelChecker ms;
model_checker_mu_calculus ();
~model_checker_mu_calculus ();
int mc_update_insert_vertex (vertex_t *vertex_new);
int mc_update_insert_edge (edge_t *edge_new);
int mc_update_delete_vertex (vertex_t *vertex_new);
int mc_update_delete_edge (edge_t *edge_new);
int get_solution (trajectory_t &trajectory_out);
};
}
#endif
| 26.038462 | 84 | 0.677991 |
daaa612a2f31a25dff22f37324985c00ee778ef5 | 884 | c | C | Lab04/a2.c | dipsonu10/DSALabClass | 05c6315da3682339ce7062f0d93fc05618bce22f | [
"MIT"
] | null | null | null | Lab04/a2.c | dipsonu10/DSALabClass | 05c6315da3682339ce7062f0d93fc05618bce22f | [
"MIT"
] | 4 | 2021-12-05T10:25:00.000Z | 2021-12-13T09:25:02.000Z | Lab04/a2.c | dipsonu10/DSALabClass | 05c6315da3682339ce7062f0d93fc05618bce22f | [
"MIT"
] | null | null | null | /*WAP to reverse the sequence elements in a double linked list.*/
#include <stdio.h>
#include <stdlib.h>
#include "../Lab04/DLL.h"
void reverse(struct Node **head)
{
struct Node *temp = NULL;
struct Node *curr = *head;
if(!(*head))
return;
if((*head)->next==0){
return;
}
while (curr != NULL){
temp = curr->prev;
curr->prev = curr->next;
curr->next = temp;
curr = curr->prev;
}
// printf("temp: %d\n",temp->data);
(*head) = temp->prev;
}
int main(int argc, char const *argv[])
{
struct Node* head=0;
head=insertUsr(head, 23);
head=insertUsr(head, 2);
head=insertUsr(head, 3);
head=insertUsr(head, 13);
head=insertUsr(head, 53);
display(head);
reverse(&head);
display(head);
deleteNode(head);
remove(argv[0]);
return 0;
}
| 20.090909 | 65 | 0.542986 |
1f21b9aef1ddebde91b8dfdc6569f9d710b114d7 | 1,024 | h | C | homeworks/05/Huffman.h | x-sile/made_2019_algo | 5edb5c0b580ff65d356ae7d9f4a6de4ac06a63de | [
"MIT"
] | null | null | null | homeworks/05/Huffman.h | x-sile/made_2019_algo | 5edb5c0b580ff65d356ae7d9f4a6de4ac06a63de | [
"MIT"
] | null | null | null | homeworks/05/Huffman.h | x-sile/made_2019_algo | 5edb5c0b580ff65d356ae7d9f4a6de4ac06a63de | [
"MIT"
] | null | null | null | #include <iostream>
#include <fstream>
#include <vector>
using byte = unsigned char;
class IInputStream {
public:
IInputStream(std::ifstream &stream_) : stream(stream_) {}
bool Read(byte &value) {
if (!stream.eof()) {
stream.get(reinterpret_cast<char &>(value));
// нужно проверить что мы читаем не ерунду, иначе запишем последний символ дважды
return !stream.fail();
}
return false;
}
~IInputStream() {
stream.close();
}
private:
std::ifstream &stream;
};
class IOutputStream {
public:
IOutputStream(std::ofstream &stream_) : stream(stream_) {}
void Write(byte value) {
stream << value;
}
~IOutputStream() {
stream.close();
}
private:
std::ofstream &stream;
};
// Метод архивирует данные из потока original
void Encode(IInputStream &original, IOutputStream &compressed);
// Метод восстанавливает оригинальные данные
void Decode(IInputStream &compressed, IOutputStream &original);
| 20.897959 | 93 | 0.641602 |
97880634e8359a6c820570c80ee9495570b6807c | 14,164 | c | C | lib/file.c | kjmkznr/h2o | c5ca18ae2ea5ce8b8943e5205a84b11531c65684 | [
"MIT"
] | null | null | null | lib/file.c | kjmkznr/h2o | c5ca18ae2ea5ce8b8943e5205a84b11531c65684 | [
"MIT"
] | null | null | null | lib/file.c | kjmkznr/h2o | c5ca18ae2ea5ce8b8943e5205a84b11531c65684 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2014 DeNA Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include "h2o.h"
#define MAX_BUF_SIZE 65000
struct st_h2o_sendfile_generator_t {
h2o_generator_t super;
int fd;
h2o_req_t *req;
size_t bytesleft;
char last_modified_buf[H2O_TIMESTR_RFC1123_LEN + 1];
char etag_buf[sizeof("\"deadbeef-deadbeefdeadbeef\"")];
size_t etag_len;
char *buf;
};
struct st_h2o_file_handler_t {
h2o_handler_t super;
h2o_iovec_t real_path; /* has "/" appended at last */
h2o_mimemap_t *mimemap;
int flags;
size_t max_index_file_len;
h2o_iovec_t index_files[1];
};
static const char *default_index_files[] = {
"index.html",
"index.htm",
"index.txt",
NULL
};
const char **h2o_file_default_index_files = default_index_files;
#include "file/templates.c.h"
static void do_close(h2o_generator_t *_self, h2o_req_t *req)
{
struct st_h2o_sendfile_generator_t *self = (void*)_self;
close(self->fd);
}
static void do_proceed(h2o_generator_t *_self, h2o_req_t *req)
{
struct st_h2o_sendfile_generator_t *self = (void*)_self;
size_t rlen;
ssize_t rret;
h2o_iovec_t vec;
int is_final;
/* read the file */
rlen = self->bytesleft;
if (rlen > MAX_BUF_SIZE)
rlen = MAX_BUF_SIZE;
while ((rret = read(self->fd, self->buf, rlen)) == -1 && errno == EINTR)
;
if (rret == -1) {
is_final = 1;
req->http1_is_persistent = 0; /* FIXME need a better interface to dispose an errored response w. content-length */
h2o_send(req, NULL, 0, 1);
do_close(&self->super, req);
return;
}
self->bytesleft -= rret;
is_final = self->bytesleft == 0;
/* send (and close if done) */
vec.base = self->buf;
vec.len = rret;
h2o_send(req, &vec, 1, is_final);
if (is_final)
do_close(&self->super, req);
}
static int do_pull(h2o_generator_t *_self, h2o_req_t *req, h2o_iovec_t *buf)
{
struct st_h2o_sendfile_generator_t *self = (void*)_self;
ssize_t rret;
if (self->bytesleft < buf->len)
buf->len = self->bytesleft;
while ((rret = read(self->fd, buf->base, buf->len)) == -1 && errno == EINTR)
;
if (rret <= 0) {
req->http1_is_persistent = 0; /* FIXME need a better interface to dispose an errored response w. content-length */
buf->len = 0;
self->bytesleft = 0;
} else {
buf->len = rret;
self->bytesleft -= rret;
}
if (self->bytesleft != 0)
return 0;
do_close(&self->super, req);
return 1;
}
static struct st_h2o_sendfile_generator_t *create_generator(h2o_mem_pool_t *pool, const char *path, int *is_dir, int flags)
{
struct st_h2o_sendfile_generator_t *self;
int fd;
struct stat st;
size_t bufsz;
*is_dir = 0;
if ((fd = open(path, O_RDONLY)) == -1)
return NULL;
if (fstat(fd, &st) != 0) {
perror("fstat");
close(fd);
return NULL;
}
if (S_ISDIR(st.st_mode)) {
close(fd);
*is_dir = 1;
return NULL;
}
bufsz = MAX_BUF_SIZE;
if (st.st_size < bufsz)
bufsz = st.st_size;
self = h2o_mem_alloc_pool(pool, sizeof(*self));
self->super.proceed = do_proceed;
self->super.stop = do_close;
self->fd = fd;
self->req = NULL;
self->bytesleft = st.st_size;
h2o_time2str_rfc1123(self->last_modified_buf, st.st_mtime);
if ((flags & H2O_FILE_FLAG_NO_ETAG) != 0) {
self->etag_len = 0;
} else {
self->etag_len = sprintf(self->etag_buf, "\"%08x-%zx\"", (unsigned)st.st_mtime, (size_t)st.st_size);
}
return self;
}
static void do_send_file(struct st_h2o_sendfile_generator_t *self, h2o_req_t *req, int status, const char *reason, h2o_iovec_t mime_type)
{
/* link the request */
self->req = req;
/* setup response */
req->res.status = status;
req->res.reason = reason;
req->res.content_length = self->bytesleft;
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE, mime_type.base, mime_type.len);
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_LAST_MODIFIED, self->last_modified_buf, H2O_TIMESTR_RFC1123_LEN);
if (self->etag_len != 0)
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_ETAG, self->etag_buf, self->etag_len);
/* send data */
h2o_start_response(req, &self->super);
if (req->_ostr_top->start_pull != NULL) {
req->_ostr_top->start_pull(req->_ostr_top, do_pull);
} else {
size_t bufsz = MAX_BUF_SIZE;
if (self->bytesleft < bufsz)
bufsz = self->bytesleft;
self->buf = h2o_mem_alloc_pool(&req->pool, bufsz);
do_proceed(&self->super, req);
}
}
int h2o_file_send(h2o_req_t *req, int status, const char *reason, const char *path, h2o_iovec_t mime_type, int flags)
{
struct st_h2o_sendfile_generator_t *self;
int is_dir;
if ((self = create_generator(&req->pool, path, &is_dir, flags)) == NULL)
return -1;
/* note: is_dir is not handled */
do_send_file(self, req, status, reason, mime_type);
return 0;
}
static int redirect_to_dir(h2o_req_t *req, const char *path, size_t path_len)
{
static h2o_generator_t generator = { NULL, NULL };
static const h2o_iovec_t body_prefix = {
H2O_STRLIT("<!DOCTYPE html><TITLE>301 Moved Permanently</TITLE><P>The document has moved <A HREF=\"")
};
static const h2o_iovec_t body_suffix = {
H2O_STRLIT("\">here</A>")
};
h2o_iovec_t url;
size_t alloc_size;
h2o_iovec_t bufs[3];
/* determine the size of the memory needed */
alloc_size = sizeof(":///") + req->scheme.len + req->authority.len + path_len;
/* allocate and build url */
url.base = h2o_mem_alloc_pool(&req->pool, alloc_size);
url.len = sprintf(url.base, "%.*s://%.*s%.*s/", (int)req->scheme.len, req->scheme.base, (int)req->authority.len, req->authority.base, (int)path_len, path);
assert(url.len + 1 == alloc_size);
/* build response header */
req->res.status = 301;
req->res.reason = "Moved Permanently";
memset(&req->res.headers, 0, sizeof(req->res.headers));
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_LOCATION, url.base, url.len);
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE, H2O_STRLIT("text/html; charset=utf-8"));
/* build response */
bufs[0] = body_prefix;
bufs[1] = h2o_htmlescape(&req->pool, url.base, url.len);
bufs[2] = body_suffix;
/* send */
h2o_start_response(req, &generator);
h2o_send(req, bufs, 3, 1);
return 0;
}
static int send_dir_listing(h2o_req_t *req, const char *path, size_t path_len)
{
static h2o_generator_t generator = { NULL, NULL };
DIR *dp;
h2o_buffer_t *body;
h2o_iovec_t bodyvec;
/* build html */
if ((dp = opendir(path)) == NULL)
return -1;
body = build_dir_listing_html(&req->pool, h2o_iovec_init(path, path_len), dp);
closedir(dp);
bodyvec = h2o_iovec_init(body->bytes, body->size);
h2o_buffer_link_to_pool(body, &req->pool);
/* send response */
req->res.status = 200;
req->res.reason = "OK";
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_CONTENT_TYPE, H2O_STRLIT("text/html; charset=utf-8"));
h2o_start_response(req, &generator);
h2o_send(req, &bodyvec, 1, 1);
return 0;
}
static int on_req(h2o_handler_t *_self, h2o_req_t *req)
{
h2o_file_handler_t *self = (void*)_self;
h2o_iovec_t mime_type;
char *rpath;
size_t rpath_len, req_path_prefix;
struct st_h2o_sendfile_generator_t *generator = NULL;
size_t if_modified_since_header_index, if_none_match_header_index;
int is_dir;
/* only accept GET (TODO accept HEAD as well) */
if (! h2o_memis(req->method.base, req->method.len, H2O_STRLIT("GET")))
return -1;
/* do not handle non-normalized paths */
if (req->path_normalized.base == NULL)
return -1;
/* build path (still unterminated at the end of the block) */
req_path_prefix = req->pathconf->path.len;
rpath = alloca(
self->real_path.len
+ (req->path_normalized.len - req_path_prefix)
+ self->max_index_file_len
+ 1);
rpath_len = 0;
memcpy(rpath + rpath_len, self->real_path.base, self->real_path.len);
rpath_len += self->real_path.len;
memcpy(rpath + rpath_len, req->path_normalized.base + req_path_prefix, req->path_normalized.len - req_path_prefix);
rpath_len += req->path_normalized.len - req_path_prefix;
/* build generator (as well as terminating the rpath and its length upon success) */
if (rpath[rpath_len - 1] == '/') {
h2o_iovec_t *index_file;
for (index_file = self->index_files; index_file->base != NULL; ++index_file) {
memcpy(rpath + rpath_len, index_file->base, index_file->len);
rpath[rpath_len + index_file->len] = '\0';
if ((generator = create_generator(&req->pool, rpath, &is_dir, self->flags)) != NULL) {
rpath_len += index_file->len;
goto Opened;
}
if (is_dir) {
/* note: apache redirects "path/" to "path/index.txt/" if index.txt is a dir */
char *path = alloca(req->path.len + index_file->len + 1);
size_t path_len = sprintf(path, "%.*s%.*s", (int)req->path.len, req->path.base, (int)index_file->len, index_file->base);
return redirect_to_dir(req, path, path_len);
}
if (errno != ENOENT)
break;
}
if (index_file->base == NULL && (self->flags & H2O_FILE_FLAG_DIR_LISTING) != 0) {
rpath[rpath_len] = '\0';
if (send_dir_listing(req, rpath, rpath_len) == 0)
return 0;
}
} else {
rpath[rpath_len] = '\0';
if ((generator = create_generator(&req->pool, rpath, &is_dir, self->flags)) != NULL)
goto Opened;
if (is_dir)
return redirect_to_dir(req, req->path.base, req->path.len);
}
/* failed to open */
if (errno == ENOENT) {
h2o_send_error(req, 404, "File Not Found", "file not found");
} else {
h2o_send_error(req, 403, "Access Forbidden", "access forbidden");
}
return 0;
Opened:
if ((if_none_match_header_index = h2o_find_header(&req->headers, H2O_TOKEN_IF_NONE_MATCH, SIZE_MAX)) != -1) {
h2o_iovec_t *if_none_match = &req->headers.entries[if_none_match_header_index].value;
if (h2o_memis(if_none_match->base, if_none_match->len, generator->etag_buf, generator->etag_len))
goto NotModified;
} else if ((if_modified_since_header_index = h2o_find_header(&req->headers, H2O_TOKEN_IF_MODIFIED_SINCE, SIZE_MAX)) != -1) {
h2o_iovec_t *if_modified_since = &req->headers.entries[if_modified_since_header_index].value;
if (h2o_memis(if_modified_since->base, if_modified_since->len, generator->last_modified_buf, H2O_TIMESTR_RFC1123_LEN))
goto NotModified;
}
/* obtain mime type */
mime_type = h2o_mimemap_get_type(self->mimemap, h2o_get_filext(rpath, rpath_len));
/* return file */
do_send_file(generator, req, 200, "OK", mime_type);
return 0;
NotModified:
req->res.status = 304;
req->res.reason = "Not Modified";
h2o_send_inline(req, NULL, 0);
do_close(&generator->super, req);
return 0;
}
static void on_dispose(h2o_handler_t *_self)
{
h2o_file_handler_t *self = (void*)_self;
size_t i;
free(self->real_path.base);
h2o_mem_release_shared(self->mimemap);
for (i = 0; self->index_files[i].base != NULL; ++i)
free(self->index_files[i].base);
}
h2o_file_handler_t *h2o_file_register(h2o_pathconf_t *pathconf, const char *real_path, const char **index_files, h2o_mimemap_t *mimemap, int flags)
{
h2o_file_handler_t *self;
size_t i;
if (index_files == NULL)
index_files = default_index_files;
/* allocate memory */
for (i = 0; index_files[i] != NULL; ++i)
;
self = (void*)h2o_create_handler(pathconf, offsetof(h2o_file_handler_t, index_files[0]) + sizeof(self->index_files[0]) * (i + 1));
/* setup callbacks */
self->super.dispose = on_dispose;
self->super.on_req = on_req;
/* setup attributes */
self->real_path = h2o_strdup_slashed(NULL, real_path, SIZE_MAX);
if (mimemap != NULL) {
h2o_mem_addref_shared(mimemap);
self->mimemap = mimemap;
} else {
self->mimemap = h2o_mimemap_create();
}
self->flags = flags;
for (i = 0; index_files[i] != NULL; ++i) {
self->index_files[i] = h2o_strdup(NULL, index_files[i], SIZE_MAX);
if (self->max_index_file_len < self->index_files[i].len)
self->max_index_file_len = self->index_files[i].len;
}
return self;
}
h2o_mimemap_t *h2o_file_get_mimemap(h2o_file_handler_t *handler)
{
return handler->mimemap;
}
| 33.643705 | 159 | 0.643886 |
97bfb6241644c340302af0785e3fbda436d475e8 | 5,866 | h | C | geometry/matrix.h | jsharf/math | f9ecfc4325a2685c2d0d49a8469971dc3146212d | [
"MIT"
] | 1 | 2019-12-02T07:18:50.000Z | 2019-12-02T07:18:50.000Z | geometry/matrix.h | jsharf/plasticity | f9ecfc4325a2685c2d0d49a8469971dc3146212d | [
"MIT"
] | null | null | null | geometry/matrix.h | jsharf/plasticity | f9ecfc4325a2685c2d0d49a8469971dc3146212d | [
"MIT"
] | null | null | null | #ifndef MATRIX_H
#define MATRIX_H
#include <array>
#include <functional>
#include <iostream>
#include <string>
#include <sstream>
#include <tuple>
using std::string;
template <size_t ROWS, size_t COLS, typename T>
class Matrix {
using SimularMatrix = Matrix<ROWS, COLS, T>;
public:
Matrix(std::initializer_list<std::initializer_list<T>> values) {
size_t i = 0;
size_t j = 0;
for (auto list : values) {
j = 0;
for (auto value : list) {
at(i, j) = value;
j++;
}
i++;
}
}
Matrix() {}
Matrix(const Matrix<ROWS, COLS, T>& other) {
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
at(i, j) = other.at(i, j);
}
}
}
explicit Matrix(T value) {
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
at(i, j) = value;
}
}
}
std::tuple<size_t, size_t> size() const {
return std::make_tuple(ROWS, COLS);
}
static constexpr Matrix<ROWS, COLS, T> Eye() {
SimularMatrix result;
for (size_t i = 0; i < ROWS; ++i) {
result.at(i, i) = 1;
}
return result;
}
constexpr Matrix<ROWS, COLS, T> operator*(T n) const {
SimularMatrix res;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
res.at(i, j) = at(i, j) * n;
}
}
return res;
}
constexpr Matrix<ROWS, COLS, T> operator+(Matrix<ROWS, COLS, T> rhs) const {
SimularMatrix res;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
res.at(i, j) = at(i, j) + rhs.at(i, j);
}
}
return res;
}
constexpr Matrix<ROWS, COLS, T> operator-(Matrix<ROWS, COLS, T> rhs) const {
SimularMatrix res;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
res.at(i, j) = at(i, j) - rhs.at(i, j);
}
}
return res;
}
constexpr const T& at(size_t i, size_t j) const { return data_.at(i).at(j); }
constexpr T& at(size_t i, size_t j) { return data_.at(i).at(j); }
// Return value is a std::pair of Matrices <lower, upper>.
constexpr std::pair<Matrix<ROWS, COLS, T>, Matrix<ROWS, COLS, T>> LUDecomp() {
if (ROWS != COLS) {
std::cerr << "Warning: LUDecomp requested for non-square matrix."
<< std::endl;
}
SimularMatrix lower, upper;
for (size_t i = 0; i < ROWS; ++i) {
upper.at(i, i) = 1;
}
for (size_t j = 0; j < ROWS; ++j) {
for (size_t i = j; i < ROWS; ++i) {
T sum = 0;
for (size_t k = 0; k < j; ++k) {
sum = sum + lower.at(i, k) * upper.at(k, j);
}
lower.at(i, j) = at(i, j) - sum;
}
for (size_t i = j; i < ROWS; ++i) {
T sum = 0;
for (size_t k = 0; k < j; ++k) {
sum = sum + lower.at(j, k) * upper.at(k, i);
}
if (lower.at(j, j) == 0) {
std::cerr << "det(lower) close to 0!\n Can't divide by 0...\n"
<< std::endl;
}
upper.at(j, i) = (at(j, i) - sum) / lower.at(j, j);
}
}
return std::make_pair(lower, upper);
}
constexpr Matrix<ROWS, 1, T> LUSolve(Matrix<ROWS, 1, T> b) {
Matrix<ROWS, 1, T> d, x;
auto matpair = LUDecomp();
auto& lower = matpair.first;
auto& upper = matpair.second;
d.at(0, 0) = b.at(0, 0) / lower.at(0, 0);
for (size_t i = 1; i < ROWS; ++i) {
T sum = 0;
for (size_t j = 0; j < i; ++j) {
sum += lower.at(i, j) * d.at(j, 0);
}
d.at(i, 0) = (b.at(i, 0) - sum) / lower.at(i, i);
}
x.at(ROWS - 1, 0) = d.at(ROWS - 1, 0);
for (int i = ROWS - 2; i >= 0; --i) {
T sum = 0;
for (size_t j = i + 1; j < ROWS; ++j) {
sum += upper.at(i, j) * x.at(j, 0);
}
x.at(i, 0) = d.at(i, 0) - sum;
}
return x;
}
constexpr Matrix<ROWS, COLS, T> Invert() {
using Colvec = Matrix<ROWS, 1, T>;
std::array<Colvec, COLS> columns{};
for (size_t i = 0; i < COLS; ++i) {
columns[i].at(i, 0) = 1;
columns[i] = LUSolve(columns[i]);
}
Matrix<ROWS, COLS, T> result;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
result.at(i, j) = columns[j].at(i, 0);
}
}
return result;
}
// Matrix multiplication is only possible if # COLS of LHS = # ROWS of RHS
template <size_t RHSCOLS>
Matrix<ROWS, RHSCOLS, T> operator*(Matrix<COLS, RHSCOLS, T> rhs) const {
Matrix<ROWS, RHSCOLS, T> result;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < RHSCOLS; ++j) {
T kSum = 0;
for (size_t k = 0; k < COLS; ++k) {
kSum = kSum + at(i, k) * rhs.at(k, j);
}
result.at(i, j) = kSum;
}
}
return result;
}
Matrix<COLS, ROWS, T> Transpose() const {
Matrix<COLS, ROWS, T> result;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
result.at(j, i) = at(i, j);
}
}
return result;
}
template <typename ReturnType>
Matrix<ROWS, COLS, ReturnType> Map(
const std::function<ReturnType(const T&)>& function) const {
Matrix<ROWS, COLS, ReturnType> result;
for (size_t i = 0; i < ROWS; ++i) {
for (size_t j = 0; j < COLS; ++j) {
result.at(i, j) = function(at(i, j));
}
}
return result;
}
string to_string() const {
std::stringstream out;
out << "{\n";
for (size_t i = 0; i < ROWS; ++i) {
out << "{";
for (size_t j = 0; j < COLS; ++j) {
out << at(i, j);
if (j != COLS - 1) {
out << ", ";
}
}
out << "},\n";
}
out << "}\n";
return out.str();
}
private:
// Empty curly braces means default value-initialize to zeros.
std::array<std::array<T, COLS>, ROWS> data_{};
};
#endif /* MATRIX_H */
| 24.961702 | 80 | 0.488749 |
e1948581926dc923be270dd396e568b085241803 | 1,862 | h | C | src/ac.h | dcjones/quip | 9165bb5ac17a2cf2822e437df573487d7adfa1cc | [
"BSD-3-Clause"
] | 41 | 2015-02-22T21:56:23.000Z | 2021-09-16T13:39:29.000Z | src/ac.h | dcjones/quip | 9165bb5ac17a2cf2822e437df573487d7adfa1cc | [
"BSD-3-Clause"
] | 7 | 2015-03-05T16:29:22.000Z | 2021-05-03T16:08:57.000Z | src/ac.h | dcjones/quip | 9165bb5ac17a2cf2822e437df573487d7adfa1cc | [
"BSD-3-Clause"
] | 7 | 2015-08-07T02:10:31.000Z | 2020-10-28T13:25:59.000Z | /*
* This file is part of quip.
*
* Copyright (c) 2012 by Daniel C. Jones <dcjones@cs.washington.edu>
*
*/
/*
* ac:
* A general purpose arithmetic encoder, following mostly from the
* implementation described in "Introduction to Arithmetic Coding -- Theory and
* Practice" by Amir Said.
*/
#ifndef QUIP_AC
#define QUIP_AC
#include "quip.h"
#include <stdint.h>
typedef struct ac_t_
{
/* coder state */
uint32_t b; /* base */
uint32_t l; /* length */
uint32_t v; /* value */
/* input or output buffer (depending on whether we are decoding or encoding,
* respectively). */
uint8_t* buf;
/* size allocated to buf */
size_t buflen;
/* index next vacant buffer position */
size_t bufpos;
/* available indput (for decoding) */
size_t bufavail;
/* callback function for encoder output */
quip_writer_t writer;
void* writer_data;
/* callback function for decoder input */
quip_reader_t reader;
void* reader_data;
} ac_t;
extern const uint32_t min_length;
extern const uint32_t max_length;
/* Allocate for encoding, decoding respectively. */
ac_t* ac_alloc_encoder(quip_writer_t writer, void* writer_data);
ac_t* ac_alloc_decoder(quip_reader_t reader, void* reader_data);
void ac_free(ac_t*);
/* Choose the final code value and return the number of compressed bytes. */
size_t ac_finish_encoder(ac_t*);
/* Write buffered compressed bases and reset the encoder. */
void ac_flush_encoder(ac_t*);
/* This must be called following a call to alloc_decoder or
* reset_decoder prior to any symbols are decoded. */
void ac_start_decoder(ac_t*);
/* Start over decoding. */
void ac_reset_decoder(ac_t*);
/* If you don't know what these do, don't call them. */
void ac_renormalize_encoder(ac_t*);
void ac_renormalize_decoder(ac_t*);
void ac_propogate_carry(ac_t*);
#endif
| 23.275 | 80 | 0.704619 |
4000945d9ba4c18cf328f9b8876968da1d346c92 | 265 | h | C | exampleProjects/IncrementalStore/Incremental Store Demo/ISDUserListViewController.h | icyblazek/encrypted-core-data | 9e2411c9ff3389661a1f53ed5933ab84141a3b62 | [
"Apache-2.0"
] | 1 | 2015-12-10T07:06:54.000Z | 2015-12-10T07:06:54.000Z | exampleProjects/IncrementalStore/Incremental Store Demo/ISDUserListViewController.h | icyblazek/encrypted-core-data | 9e2411c9ff3389661a1f53ed5933ab84141a3b62 | [
"Apache-2.0"
] | null | null | null | exampleProjects/IncrementalStore/Incremental Store Demo/ISDUserListViewController.h | icyblazek/encrypted-core-data | 9e2411c9ff3389661a1f53ed5933ab84141a3b62 | [
"Apache-2.0"
] | null | null | null | //
// ISDUserListViewController.h
// Incremental Store Demo
//
// Created by Caleb Davenport on 7/31/12.
// Copyright (c) 2012 Caleb Davenport. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ISDUserListViewController : UITableViewController
@end
| 18.928571 | 60 | 0.739623 |
98138e913a9c9f09a76d10e06b8ad439557f65f4 | 14,858 | h | C | Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | 2 | 2015-06-21T17:38:11.000Z | 2015-06-22T20:54:42.000Z | Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Curves/CurveFloat.h"
#include "UserInterfaceSettings.h"
#include "RendererSettings.generated.h"
/**
* Enumerates ways to clear a scene.
*/
UENUM()
namespace EClearSceneOptions
{
enum Type
{
NoClear = 0 UMETA(DisplayName="Do not clear",ToolTip="This option is fastest but can cause artifacts unless you render to every pixel. Make sure to use a skybox with this option!"),
HardwareClear = 1 UMETA(DisplayName="Hardware clear",ToolTip="Perform a full hardware clear before rendering. Most projects should use this option."),
QuadAtMaxZ = 2 UMETA(DisplayName="Clear at far plane",ToolTip="Draws a quad to perform the clear at the far plane, this is faster than a hardware clear on some GPUs."),
};
}
/**
* Enumerates available compositing sample counts.
*/
UENUM()
namespace ECompositingSampleCount
{
enum Type
{
One = 1 UMETA(DisplayName="No MSAA"),
Two = 2 UMETA(DisplayName="2x MSAA"),
Four = 4 UMETA(DisplayName="4x MSAA"),
Eight = 8 UMETA(DisplayName="8x MSAA"),
};
}
/**
* Enumerates available options for custom depth.
*/
UENUM()
namespace ECustomDepthStencil
{
enum Type
{
Disabled = 0,
Enabled = 1 UMETA(ToolTip="Depth buffer created immediately. Stencil disabled."),
EnabledOnDemand = 2 UMETA(ToolTip="Depth buffer created on first use, can save memory but cause stalls. Stencil disabled."),
EnabledWithStencil = 3 UMETA(ToolTip="Depth buffer created immediately. Stencil available for read/write."),
};
}
/**
* Enumerates available options for early Z-passes.
*/
UENUM()
namespace EEarlyZPass
{
enum Type
{
None = 0 UMETA(DisplayName="None"),
OpaqueOnly = 1 UMETA(DisplayName="Opaque meshes only"),
OpaqueAndMasked = 2 UMETA(DisplayName="Opaque and masked meshes"),
Auto = 3 UMETA(DisplayName="Decide automatically",ToolTip="Let the engine decide what to render in the early Z pass based on the features being used."),
};
}
/** used by FPostProcessSettings Anti-aliasing */
UENUM()
namespace EAntiAliasingMethodUI
{
enum Type
{
AAM_None UMETA(DisplayName = "None"),
AAM_FXAA UMETA(DisplayName = "FXAA"),
AAM_TemporalAA UMETA(DisplayName = "TemporalAA"),
AAM_MAX,
};
}
/**
* Rendering settings.
*/
UCLASS(config=Engine, defaultconfig, meta=(DisplayName="Rendering"))
class ENGINE_API URendererSettings : public UDeveloperSettings
{
GENERATED_UCLASS_BODY()
UPROPERTY(config, EditAnywhere, Category=Mobile, meta=(
ConsoleVariable="r.MobileHDR",DisplayName="Mobile HDR",
ToolTip="If true, mobile renders in full HDR. Disable this setting for games that do not require lighting features for better performance on slow devices."))
uint32 bMobileHDR:1;
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (
ConsoleVariable = "r.MobileNumDynamicPointLights", DisplayName = "Max Dynamic Point Lights", ClampMax = 4,
ToolTip = "The number of dynamic point lights to support on mobile devices. Setting this to 0 for games which do not require dynamic point lights will reduce the number of shaders generated. Changing this setting requires restarting the editor.",
ConfigRestartRequired = true))
uint32 MobileNumDynamicPointLights;
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (
ConsoleVariable = "r.MobileDynamicPointLightsUseStaticBranch", DisplayName = "Use Shared Dynamic Point Light Shaders",
ToolTip = "If this setting is enabled, the same shader will be used for any number of dynamic point lights (up to the maximum specified above) hitting a surface. This is slightly slower but reduces the number of shaders generated. Changing this setting requires restarting the editor.",
ConfigRestartRequired = true))
uint32 bMobileDynamicPointLightsUseStaticBranch : 1;
UPROPERTY(config, EditAnywhere, Category=Culling, meta=(
ConsoleVariable="r.AllowOcclusionQueries",DisplayName="Occlusion Culling",
ToolTip="Allows occluded meshes to be culled and no rendered."))
uint32 bOcclusionCulling:1;
UPROPERTY(config, EditAnywhere, Category=Culling, meta=(
ConsoleVariable="r.MinScreenRadiusForLights",DisplayName="Min Screen Radius for Lights",
ToolTip="Screen radius at which lights are culled. Larger values can improve performance but causes lights to pop off when they affect a small area of the screen."))
float MinScreenRadiusForLights;
UPROPERTY(config, EditAnywhere, Category=Culling, meta=(
ConsoleVariable="r.MinScreenRadiusForDepthPrepass",DisplayName="Min Screen Radius for Early Z Pass",
ToolTip="Screen radius at which objects are culled for the early Z pass. Larger values can improve performance but very large values can degrade performance if large occluders are not rendered."))
float MinScreenRadiusForEarlyZPass;
UPROPERTY(config, EditAnywhere, Category=Culling, meta=(
ConsoleVariable="r.MinScreenRadiusForDepthPrepass",DisplayName="Min Screen Radius for Cascaded Shadow Maps",
ToolTip="Screen radius at which objects are culled for cascaded shadow map depth passes. Larger values can improve performance but can cause artifacts as objects stop casting shadows."))
float MinScreenRadiusForCSMdepth;
UPROPERTY(config, EditAnywhere, Category=Culling, meta=(
ConsoleVariable="r.PrecomputedVisibilityWarning",DisplayName="Warn about no precomputed visibility",
ToolTip="Displays a warning when no precomputed visibility data is available for the current camera location. This can be helpful if you are making a game that relies on precomputed visibility, e.g. a first person mobile game."))
uint32 bPrecomputedVisibilityWarning:1;
UPROPERTY(config, EditAnywhere, Category=Textures, meta=(
ConsoleVariable="r.TextureStreaming",DisplayName="Texture Streaming",
ToolTip="When enabled textures will stream in based on what is visible on screen."))
uint32 bTextureStreaming:1;
UPROPERTY(config, EditAnywhere, Category=Textures, meta=(
ConsoleVariable="Compat.UseDXT5NormalMaps",DisplayName="Use DXT5 Normal Maps",
ToolTip="Whether to use DXT5 for normal maps, otherwise BC5 will be used, which is not supported on all hardware. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bUseDXT5NormalMaps:1;
UPROPERTY(config, EditAnywhere, Category=Lighting, meta=(
ConsoleVariable="r.AllowStaticLighting",
ToolTip="Whether to allow any static lighting to be generated and used, like lightmaps and shadowmaps. Games that only use dynamic lighting should set this to 0 to save some static lighting overhead. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bAllowStaticLighting:1;
UPROPERTY(config, EditAnywhere, Category=Lighting, meta=(
ConsoleVariable="r.NormalMapsForStaticLighting",
ToolTip="Whether to allow any static lighting to use normal maps for lighting computations."))
uint32 bUseNormalMapsForStaticLighting:1;
UPROPERTY(config, EditAnywhere, Category=Lighting, meta=(
ConsoleVariable="r.GenerateMeshDistanceFields",
ToolTip="Whether to build distance fields of static meshes, needed for distance field AO, which is used to implement Movable SkyLight shadows, and ray traced distance field shadows on directional lights. Enabling will increase mesh build times and memory usage. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bGenerateMeshDistanceFields:1;
UPROPERTY(config, EditAnywhere, Category = Lighting, meta = (
EditCondition = "bGenerateMeshDistanceFields",
ConsoleVariable = "r.GenerateLandscapeGIData", DisplayName = "Generate Landscape Real-time GI Data",
ToolTip = "Whether to generate a low-resolution base color texture for landscapes for rendering real-time global illumination. This feature requires GenerateMeshDistanceFields is also enabled, and will increase mesh build times and memory usage."))
uint32 bGenerateLandscapeGIData : 1;
UPROPERTY(config, EditAnywhere, Category=Tessellation, meta=(
ConsoleVariable="r.TessellationAdaptivePixelsPerTriangle",DisplayName="Adaptive pixels per triangle",
ToolTip="When adaptive tessellation is enabled it will try to tessellate a mesh so that each triangle contains the specified number of pixels. The tessellation multiplier specified in the material can increase or decrease the amount of tessellation."))
float TessellationAdaptivePixelsPerTriangle;
UPROPERTY(config, EditAnywhere, Category=Postprocessing, meta=(
ConsoleVariable="r.SeparateTranslucency",
ToolTip="Allow translucency to be rendered to a separate render targeted and composited after depth of field. Prevents translucency from appearing out of focus."))
uint32 bSeparateTranslucency:1;
UPROPERTY(config, EditAnywhere, Category=Translucency, meta=(
ConsoleVariable="r.TranslucentSortPolicy",DisplayName="Translucent Sort Policy",
ToolTip="The sort mode for translucent primitives, affecting how they are ordered and how they change order as the camera moves."))
TEnumAsByte<ETranslucentSortPolicy::Type> TranslucentSortPolicy;
UPROPERTY(config, EditAnywhere, Category=Translucency, meta=(
DisplayName="Translucent Sort Axis",
ToolTip="The axis that sorting will occur along when Translucent Sort Policy is set to SortAlongAxis."))
FVector TranslucentSortAxis;
UPROPERTY(config, EditAnywhere, Category=Postprocessing, meta=(
ConsoleVariable="r.CustomDepth",DisplayName="Custom Depth-Stencil Pass",
ToolTip="Whether the custom depth pass for tagging primitives for postprocessing passes is enabled. Enabling it on demand can save memory but may cause a hitch the first time the feature is used."))
TEnumAsByte<ECustomDepthStencil::Type> CustomDepthStencil;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.Bloom", DisplayName = "Bloom",
ToolTip = "Whether the default for Bloom is enabled or not (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureBloom : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.AmbientOcclusion", DisplayName = "Ambient Occlusion",
ToolTip = "Whether the default for AmbientOcclusion is enabled or not (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureAmbientOcclusion : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.AmbientOcclusionStaticFraction", DisplayName = "Ambient Occlusion Static Fraction (AO for baked lighting)",
ToolTip = "Whether the default for AmbientOcclusionStaticFraction is enabled or not (only useful for baked lighting and if AO is on, allows to have SSAO affect baked lighting as well, costs performance, postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureAmbientOcclusionStaticFraction : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.AutoExposure", DisplayName = "Auto Exposure",
ToolTip = "Whether the default for AutoExposure is enabled or not (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureAutoExposure : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.MotionBlur", DisplayName = "Motion Blur",
ToolTip = "Whether the default for MotionBlur is enabled or not (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureMotionBlur : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.LensFlare", DisplayName = "Lens Flares (Image based)",
ToolTip = "Whether the default for LensFlare is enabled or not (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
uint32 bDefaultFeatureLensFlare : 1;
UPROPERTY(config, EditAnywhere, Category = DefaultPostprocessingSettings, meta = (
ConsoleVariable = "r.DefaultFeature.AntiAliasing", DisplayName = "Anti-Aliasing Method",
ToolTip = "What anti-aliasing mode is used by default (postprocess volume/camera/game setting can still override and enable or disable it independently)"))
TEnumAsByte<EAntiAliasingMethodUI::Type> DefaultFeatureAntiAliasing;
UPROPERTY(config, EditAnywhere, Category = Optimizations, meta = (
ConsoleVariable="r.EarlyZPass",DisplayName="Early Z-pass",
ToolTip="Whether to use a depth only pass to initialize Z culling for the base pass. Need to reload the level!"))
TEnumAsByte<EEarlyZPass::Type> EarlyZPass;
UPROPERTY(config, EditAnywhere, Category=Optimizations, meta=(
ConsoleVariable="r.EarlyZPassMovable",DisplayName="Movables in early Z-pass",
ToolTip="Whether to render movable objects in the early Z pass. Need to reload the level!"))
uint32 bEarlyZPassMovable:1;
UPROPERTY(config, EditAnywhere, Category=Lighting, meta=(
ConsoleVariable="r.DBuffer",DisplayName="DBuffer Decals",
ToolTip="Experimental decal feature (see r.DBuffer, ideally combined with 'Movables in early Z-pass' and 'Early Z-pass')"))
uint32 bDBuffer:1;
UPROPERTY(config, EditAnywhere, Category=Optimizations, meta=(
ConsoleVariable="r.ClearSceneMethod",DisplayName="Clear Scene",
ToolTip="Select how the g-buffer is cleared in game mode (only affects deferred shading)."))
TEnumAsByte<EClearSceneOptions::Type> ClearSceneMethod;
UPROPERTY(config, EditAnywhere, Category=Optimizations, meta=(
ConsoleVariable="r.BasePassOutputsVelocity", DisplayName="Accurate velocities from Vertex Deformation",
ToolTip="Enables materials with time-based World Position Offset and/or World Displacement to output accurate velocities. This incurs a performance cost. If this is disabled, those materials will not output velocities. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bBasePassOutputsVelocity:1;
UPROPERTY(config, EditAnywhere, Category=Editor, meta=(
ConsoleVariable="r.WireframeCullThreshold",DisplayName="Wireframe Cull Threshold",
ToolTip="Screen radius at which wireframe objects are culled. Larger values can improve performance when viewing a scene in wireframe."))
float WireframeCullThreshold;
public:
// Begin UObject interface
virtual void PostInitProperties() override;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
// End UObject interface
private:
UPROPERTY(config)
TEnumAsByte<EUIScalingRule> UIScaleRule_DEPRECATED;
UPROPERTY(config)
FRuntimeFloatCurve UIScaleCurve_DEPRECATED;
};
| 52.501767 | 321 | 0.792031 |
092c913de4ca63848785aea637e173d0c721ce72 | 68 | c | C | Virtual Memory Implementation/Theme_B_9/GeekOS (os)/src/user/PaxHeader/pipe-p1.c | Pintulalmeena/Projects | 4d5d5e80aa8cbad47b6d5d9c407147429568d277 | [
"MIT"
] | null | null | null | Virtual Memory Implementation/Theme_B_9/GeekOS (os)/src/user/PaxHeader/pipe-p1.c | Pintulalmeena/Projects | 4d5d5e80aa8cbad47b6d5d9c407147429568d277 | [
"MIT"
] | null | null | null | Virtual Memory Implementation/Theme_B_9/GeekOS (os)/src/user/PaxHeader/pipe-p1.c | Pintulalmeena/Projects | 4d5d5e80aa8cbad47b6d5d9c407147429568d277 | [
"MIT"
] | null | null | null | 14 uid=311598
27 mtime=1430738578.290251
27 atime=1430738578.289251
| 17 | 26 | 0.838235 |
51f598fa2df98ef32ad66fdfdd83350b1c44bd36 | 414 | c | C | v3/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/compile/pr84111.c | zchee/cznic-cc | f7ff0a5ccc28f2d8bf1d681a1cc49c48ea8dd4aa | [
"BSD-3-Clause"
] | null | null | null | v3/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/compile/pr84111.c | zchee/cznic-cc | f7ff0a5ccc28f2d8bf1d681a1cc49c48ea8dd4aa | [
"BSD-3-Clause"
] | null | null | null | v3/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/compile/pr84111.c | zchee/cznic-cc | f7ff0a5ccc28f2d8bf1d681a1cc49c48ea8dd4aa | [
"BSD-3-Clause"
] | null | null | null | /* PR tree-optimization/84111 */
void
foo (int x, int y, int z)
{
int a = 0;
int *b = &x;
while (a < 1)
{
int c = y;
*b = x;
lab:
for (a = 0; a < 36; ++a)
{
*b = 0;
if (x != 0)
y = 0;
while (c < 1)
;
}
}
if (z < 33)
{
b = (int *) 0;
++y;
++z;
if (x / *b != 0)
goto lab;
}
}
| 12.9375 | 32 | 0.282609 |
4ee6d33a7beab368c3f9d23c22e75dde6145da0d | 1,561 | h | C | Classes/WAPhotosListViewController.h | brewpoo/WebAlbums | 468d609df7b1c199b789b6ee2db04154c39c33ee | [
"Apache-2.0"
] | 1 | 2021-08-30T10:33:21.000Z | 2021-08-30T10:33:21.000Z | Classes/WAPhotosListViewController.h | brewpoo/WebAlbums | 468d609df7b1c199b789b6ee2db04154c39c33ee | [
"Apache-2.0"
] | null | null | null | Classes/WAPhotosListViewController.h | brewpoo/WebAlbums | 468d609df7b1c199b789b6ee2db04154c39c33ee | [
"Apache-2.0"
] | null | null | null | //
// WAPhotosListViewController.h
// WebAlbums
//
// Created by JJL on 7/15/09.
// Copyright 2009 NetGuyzApps. All rights reserved.
//
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#import <UIKit/UIKit.h>
#import "WAAlbum.h"
#import "WAAccount.h"
#import "WAAccountType.h"
@interface WAPhotosListViewController : UITableViewController <WAAccountDelegate> {
NSManagedObjectContext *managedObjectContext;
WAAlbum *album;
WAAccount *account;
NSArray *photos;
UIViewController *photoDetailViewController;
WAAccountType *accountController;
}
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain) WAAlbum *album;
@property (nonatomic, retain) WAAccount *account;
@property (nonatomic, retain) NSArray *photos;
@property (nonatomic, retain) UIViewController *photoDetailViewController;
@property (nonatomic, retain) WAAccountType *accountController;
- (id)initWithAccountController:(WAAccountType*)thisController andAlbum:(WAAlbum*)thisAlbum;
- (void)albumPhotosUpdated;
@end
| 29.45283 | 92 | 0.769379 |
82524b6b0c568ae1c7c2ed16d7d2031721bb9133 | 500 | h | C | common/residualFunction.h | chl9797/EmbeddedDeformation | 50c4b723a91045787d071dddfd9f8c19283c30ef | [
"MIT"
] | 3 | 2018-07-20T02:04:53.000Z | 2020-11-04T02:37:36.000Z | common/residualFunction.h | chl9797/EmbeddedDeformation | 50c4b723a91045787d071dddfd9f8c19283c30ef | [
"MIT"
] | null | null | null | common/residualFunction.h | chl9797/EmbeddedDeformation | 50c4b723a91045787d071dddfd9f8c19283c30ef | [
"MIT"
] | 5 | 2018-05-18T06:53:02.000Z | 2019-11-26T09:37:35.000Z | #ifndef _RESIDUAL_FUNCTION_H
#define _RESIDUAL_FUNCTION_H
#include <Eigen/Sparse>
#include <Eigen/Dense>
#include <memory>
class Param;
class ResidualFunction
{
public:
virtual Eigen::SparseMatrix<double> calcJf(std::shared_ptr<Param> param) = 0;
virtual Eigen::VectorXd calcfx(std::shared_ptr<Param> param) = 0;
virtual double calcFx(std::shared_ptr<Param> param) = 0;
virtual Eigen::VectorXd calcJF(std::shared_ptr<Param> param) = 0;
};
#endif | 23.809524 | 78 | 0.69 |
61cd381dd51de82ce31e904a622aee3ddf3d9cc3 | 14,753 | c | C | ZQMonitor/Classes/Yoosee/P2PCore/des2.c | git-timor/ZQMonitor | deafff4d5d622ac45d9f84b1822181bb7177978f | [
"MIT"
] | 1 | 2017-10-17T07:05:31.000Z | 2017-10-17T07:05:31.000Z | ZQMonitor/Classes/Yoosee/P2PCore/des2.c | git-timor/ZQMonitor | deafff4d5d622ac45d9f84b1822181bb7177978f | [
"MIT"
] | null | null | null | ZQMonitor/Classes/Yoosee/P2PCore/des2.c | git-timor/ZQMonitor | deafff4d5d622ac45d9f84b1822181bb7177978f | [
"MIT"
] | null | null | null |
int des(unsigned char *source,unsigned char * dest,unsigned char * inkey, int flg);
/* ============================================================
des()
Description: DES algorithm,do encript or descript.
============================================================ */
int des(unsigned char *source,unsigned char * dest,unsigned char * inkey, int flg)
{
unsigned char bufout[64],
kwork[56], worka[48], kn[48], buffer[64], key[64],
nbrofshift, temp1, temp2;
int valindex;
int i, j, k, iter;
/* INITIALIZE THE TABLES */
/* Table - s1 */
static unsigned char s1[4][16] =
{
{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
{0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
{4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
{15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}
};
/* Table - s2 */
static unsigned char s2[4][16] = {
{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
{3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
{0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
{13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}
};
/* Table - s3 */
static unsigned char s3[4][16] = {
{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
{13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
{13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
{1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}
};
/* Table - s4 */
static unsigned char s4[4][16] = {
{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
{13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
{10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
{3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}
};
/* Table - s5 */
static unsigned char s5[4][16] = {
{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
{14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
{4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
{11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}
};
/* Table - s6 */
static unsigned char s6[4][16] = {
{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
{10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
{9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
{4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 }
};
/* Table - s7 */
static unsigned char s7[4][16] = {
{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
{13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
{1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
{6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 }
};
/* Table - s8 */
static unsigned char s8[4][16] = {
{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
{1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
{7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
{2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}
};
/* Table - Shift */
static unsigned char shift[16] = {
1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
/* Table - Binary */
static unsigned char binary[64] = {
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1,
0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1,
1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1,
1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1 };
/* MAIN PROCESS */
/* Convert from 64-bit key into 64-byte key */
for (i = 0; i < 8; i++) {
key[8*i] = ((j = *(inkey + i)) / 128) % 2;
key[8*i+1] = (j / 64) % 2;
key[8*i+2] = (j / 32) % 2;
key[8*i+3] = (j / 16) % 2;
key[8*i+4] = (j / 8) % 2;
key[8*i+5] = (j / 4) % 2;
key[8*i+6] = (j / 2) % 2;
key[8*i+7] = j % 2;
}
/* Convert from 64-bit data into 64-byte data */
for (i = 0; i < 8; i++) {
buffer[8*i] = ((j = *(source + i)) / 128) % 2;
buffer[8*i+1] = (j / 64) % 2;
buffer[8*i+2] = (j / 32) % 2;
buffer[8*i+3] = (j / 16) % 2;
buffer[8*i+4] = (j / 8) % 2;
buffer[8*i+5] = (j / 4) % 2;
buffer[8*i+6] = (j / 2) % 2;
buffer[8*i+7] = j % 2;
}
/* Initial Permutation of Data */
bufout[ 0] = buffer[57];
bufout[ 1] = buffer[49];
bufout[ 2] = buffer[41];
bufout[ 3] = buffer[33];
bufout[ 4] = buffer[25];
bufout[ 5] = buffer[17];
bufout[ 6] = buffer[ 9];
bufout[ 7] = buffer[ 1];
bufout[ 8] = buffer[59];
bufout[ 9] = buffer[51];
bufout[10] = buffer[43];
bufout[11] = buffer[35];
bufout[12] = buffer[27];
bufout[13] = buffer[19];
bufout[14] = buffer[11];
bufout[15] = buffer[ 3];
bufout[16] = buffer[61];
bufout[17] = buffer[53];
bufout[18] = buffer[45];
bufout[19] = buffer[37];
bufout[20] = buffer[29];
bufout[21] = buffer[21];
bufout[22] = buffer[13];
bufout[23] = buffer[ 5];
bufout[24] = buffer[63];
bufout[25] = buffer[55];
bufout[26] = buffer[47];
bufout[27] = buffer[39];
bufout[28] = buffer[31];
bufout[29] = buffer[23];
bufout[30] = buffer[15];
bufout[31] = buffer[ 7];
bufout[32] = buffer[56];
bufout[33] = buffer[48];
bufout[34] = buffer[40];
bufout[35] = buffer[32];
bufout[36] = buffer[24];
bufout[37] = buffer[16];
bufout[38] = buffer[ 8];
bufout[39] = buffer[ 0];
bufout[40] = buffer[58];
bufout[41] = buffer[50];
bufout[42] = buffer[42];
bufout[43] = buffer[34];
bufout[44] = buffer[26];
bufout[45] = buffer[18];
bufout[46] = buffer[10];
bufout[47] = buffer[ 2];
bufout[48] = buffer[60];
bufout[49] = buffer[52];
bufout[50] = buffer[44];
bufout[51] = buffer[36];
bufout[52] = buffer[28];
bufout[53] = buffer[20];
bufout[54] = buffer[12];
bufout[55] = buffer[ 4];
bufout[56] = buffer[62];
bufout[57] = buffer[54];
bufout[58] = buffer[46];
bufout[59] = buffer[38];
bufout[60] = buffer[30];
bufout[61] = buffer[22];
bufout[62] = buffer[14];
bufout[63] = buffer[ 6];
/* Initial Permutation of Key */
kwork[ 0] = key[56];
kwork[ 1] = key[48];
kwork[ 2] = key[40];
kwork[ 3] = key[32];
kwork[ 4] = key[24];
kwork[ 5] = key[16];
kwork[ 6] = key[ 8];
kwork[ 7] = key[ 0];
kwork[ 8] = key[57];
kwork[ 9] = key[49];
kwork[10] = key[41];
kwork[11] = key[33];
kwork[12] = key[25];
kwork[13] = key[17];
kwork[14] = key[ 9];
kwork[15] = key[ 1];
kwork[16] = key[58];
kwork[17] = key[50];
kwork[18] = key[42];
kwork[19] = key[34];
kwork[20] = key[26];
kwork[21] = key[18];
kwork[22] = key[10];
kwork[23] = key[ 2];
kwork[24] = key[59];
kwork[25] = key[51];
kwork[26] = key[43];
kwork[27] = key[35];
kwork[28] = key[62];
kwork[29] = key[54];
kwork[30] = key[46];
kwork[31] = key[38];
kwork[32] = key[30];
kwork[33] = key[22];
kwork[34] = key[14];
kwork[35] = key[ 6];
kwork[36] = key[61];
kwork[37] = key[53];
kwork[38] = key[45];
kwork[39] = key[37];
kwork[40] = key[29];
kwork[41] = key[21];
kwork[42] = key[13];
kwork[43] = key[ 5];
kwork[44] = key[60];
kwork[45] = key[52];
kwork[46] = key[44];
kwork[47] = key[36];
kwork[48] = key[28];
kwork[49] = key[20];
kwork[50] = key[12];
kwork[51] = key[ 4];
kwork[52] = key[27];
kwork[53] = key[19];
kwork[54] = key[11];
kwork[55] = key[ 3];
/* 16 Iterations */
for (iter = 1; iter < 17; iter++) {
for (i = 0; i < 32; i++)
{
buffer[i] = bufout[32+i];
}
/* Calculation of F(R, K) */
/* Permute - E */
worka[ 0] = buffer[31];
worka[ 1] = buffer[ 0];
worka[ 2] = buffer[ 1];
worka[ 3] = buffer[ 2];
worka[ 4] = buffer[ 3];
worka[ 5] = buffer[ 4];
worka[ 6] = buffer[ 3];
worka[ 7] = buffer[ 4];
worka[ 8] = buffer[ 5];
worka[ 9] = buffer[ 6];
worka[10] = buffer[ 7];
worka[11] = buffer[ 8];
worka[12] = buffer[ 7];
worka[13] = buffer[ 8];
worka[14] = buffer[ 9];
worka[15] = buffer[10];
worka[16] = buffer[11];
worka[17] = buffer[12];
worka[18] = buffer[11];
worka[19] = buffer[12];
worka[20] = buffer[13];
worka[21] = buffer[14];
worka[22] = buffer[15];
worka[23] = buffer[16];
worka[24] = buffer[15];
worka[25] = buffer[16];
worka[26] = buffer[17];
worka[27] = buffer[18];
worka[28] = buffer[19];
worka[29] = buffer[20];
worka[30] = buffer[19];
worka[31] = buffer[20];
worka[32] = buffer[21];
worka[33] = buffer[22];
worka[34] = buffer[23];
worka[35] = buffer[24];
worka[36] = buffer[23];
worka[37] = buffer[24];
worka[38] = buffer[25];
worka[39] = buffer[26];
worka[40] = buffer[27];
worka[41] = buffer[28];
worka[42] = buffer[27];
worka[43] = buffer[28];
worka[44] = buffer[29];
worka[45] = buffer[30];
worka[46] = buffer[31];
worka[47] = buffer[ 0];
/* KS Function Begin */
if (flg) {
nbrofshift = shift[iter-1];
for (i = 0; i < (int) nbrofshift; i++) {
temp1 = kwork[0];
temp2 = kwork[28];
for (j = 0; j < 27; j++) {
kwork[j] = kwork[j+1];
kwork[j+28] = kwork[j+29];
}
kwork[27] = temp1;
kwork[55] = temp2;
}
} else if (iter > 1) {
nbrofshift = shift[17-iter];
for (i = 0; i < (int) nbrofshift; i++) {
temp1 = kwork[27];
temp2 = kwork[55];
for (j = 27; j > 0; j--) {
kwork[j] = kwork[j-1];
kwork[j+28] = kwork[j+27];
}
kwork[0] = temp1;
kwork[28] = temp2;
}
}
/* Permute kwork - PC2 */
kn[ 0] = kwork[13];
kn[ 1] = kwork[16];
kn[ 2] = kwork[10];
kn[ 3] = kwork[23];
kn[ 4] = kwork[ 0];
kn[ 5] = kwork[ 4];
kn[ 6] = kwork[ 2];
kn[ 7] = kwork[27];
kn[ 8] = kwork[14];
kn[ 9] = kwork[ 5];
kn[10] = kwork[20];
kn[11] = kwork[ 9];
kn[12] = kwork[22];
kn[13] = kwork[18];
kn[14] = kwork[11];
kn[15] = kwork[ 3];
kn[16] = kwork[25];
kn[17] = kwork[ 7];
kn[18] = kwork[15];
kn[19] = kwork[ 6];
kn[20] = kwork[26];
kn[21] = kwork[19];
kn[22] = kwork[12];
kn[23] = kwork[ 1];
kn[24] = kwork[40];
kn[25] = kwork[51];
kn[26] = kwork[30];
kn[27] = kwork[36];
kn[28] = kwork[46];
kn[29] = kwork[54];
kn[30] = kwork[29];
kn[31] = kwork[39];
kn[32] = kwork[50];
kn[33] = kwork[44];
kn[34] = kwork[32];
kn[35] = kwork[47];
kn[36] = kwork[43];
kn[37] = kwork[48];
kn[38] = kwork[38];
kn[39] = kwork[55];
kn[40] = kwork[33];
kn[41] = kwork[52];
kn[42] = kwork[45];
kn[43] = kwork[41];
kn[44] = kwork[49];
kn[45] = kwork[35];
kn[46] = kwork[28];
kn[47] = kwork[31];
/* KS Function End */
/* worka XOR kn */
for (i = 0; i < 48; i++)
worka[i] = worka[i] ^ kn[i];
/* 8 s-functions */
valindex = s1[2*worka[ 0]+worka[ 5]]
[2*(2*(2*worka[ 1]+worka[ 2])+
worka[ 3])+worka[ 4]];
valindex = valindex * 4;
kn[ 0] = binary[0+valindex];
kn[ 1] = binary[1+valindex];
kn[ 2] = binary[2+valindex];
kn[ 3] = binary[3+valindex];
valindex = s2[2*worka[ 6]+worka[11]]
[2*(2*(2*worka[ 7]+worka[ 8])+
worka[ 9])+worka[10]];
valindex = valindex * 4;
kn[ 4] = binary[0+valindex];
kn[ 5] = binary[1+valindex];
kn[ 6] = binary[2+valindex];
kn[ 7] = binary[3+valindex];
valindex = s3[2*worka[12]+worka[17]]
[2*(2*(2*worka[13]+worka[14])+
worka[15])+worka[16]];
valindex = valindex * 4;
kn[ 8] = binary[0+valindex];
kn[ 9] = binary[1+valindex];
kn[10] = binary[2+valindex];
kn[11] = binary[3+valindex];
valindex = s4[2*worka[18]+worka[23]]
[2*(2*(2*worka[19]+worka[20])+
worka[21])+worka[22]];
valindex = valindex * 4;
kn[12] = binary[0+valindex];
kn[13] = binary[1+valindex];
kn[14] = binary[2+valindex];
kn[15] = binary[3+valindex];
valindex = s5[2*worka[24]+worka[29]]
[2*(2*(2*worka[25]+worka[26])+
worka[27])+worka[28]];
valindex = valindex * 4;
kn[16] = binary[0+valindex];
kn[17] = binary[1+valindex];
kn[18] = binary[2+valindex];
kn[19] = binary[3+valindex];
valindex = s6[2*worka[30]+worka[35]]
[2*(2*(2*worka[31]+worka[32])+
worka[33])+worka[34]];
valindex = valindex * 4;
kn[20] = binary[0+valindex];
kn[21] = binary[1+valindex];
kn[22] = binary[2+valindex];
kn[23] = binary[3+valindex];
valindex = s7[2*worka[36]+worka[41]]
[2*(2*(2*worka[37]+worka[38])+
worka[39])+worka[40]];
valindex = valindex * 4;
kn[24] = binary[0+valindex];
kn[25] = binary[1+valindex];
kn[26] = binary[2+valindex];
kn[27] = binary[3+valindex];
valindex = s8[2*worka[42]+worka[47]]
[2*(2*(2*worka[43]+worka[44])+
worka[45])+worka[46]];
valindex = valindex * 4;
kn[28] = binary[0+valindex];
kn[29] = binary[1+valindex];
kn[30] = binary[2+valindex];
kn[31] = binary[3+valindex];
/* Permute - P */
worka[ 0] = kn[15];
worka[ 1] = kn[ 6];
worka[ 2] = kn[19];
worka[ 3] = kn[20];
worka[ 4] = kn[28];
worka[ 5] = kn[11];
worka[ 6] = kn[27];
worka[ 7] = kn[16];
worka[ 8] = kn[ 0];
worka[ 9] = kn[14];
worka[10] = kn[22];
worka[11] = kn[25];
worka[12] = kn[ 4];
worka[13] = kn[17];
worka[14] = kn[30];
worka[15] = kn[ 9];
worka[16] = kn[ 1];
worka[17] = kn[ 7];
worka[18] = kn[23];
worka[19] = kn[13];
worka[20] = kn[31];
worka[21] = kn[26];
worka[22] = kn[ 2];
worka[23] = kn[ 8];
worka[24] = kn[18];
worka[25] = kn[12];
worka[26] = kn[29];
worka[27] = kn[ 5];
worka[28] = kn[21];
worka[29] = kn[10];
worka[30] = kn[ 3];
worka[31] = kn[24];
/* bufout XOR worka */
for (i = 0; i < 32; i++) {
bufout[i+32] = bufout[i] ^ worka[i];
bufout[i] = buffer[i];
}
} /* End of Iter */
/* Prepare Output */
for (i = 0; i < 32; i++) {
j = bufout[i];
bufout[i] = bufout[32+i];
bufout[32+i] = j;
}
/* Inverse Initial Permutation */
buffer[ 0] = bufout[39];
buffer[ 1] = bufout[ 7];
buffer[ 2] = bufout[47];
buffer[ 3] = bufout[15];
buffer[ 4] = bufout[55];
buffer[ 5] = bufout[23];
buffer[ 6] = bufout[63];
buffer[ 7] = bufout[31];
buffer[ 8] = bufout[38];
buffer[ 9] = bufout[ 6];
buffer[10] = bufout[46];
buffer[11] = bufout[14];
buffer[12] = bufout[54];
buffer[13] = bufout[22];
buffer[14] = bufout[62];
buffer[15] = bufout[30];
buffer[16] = bufout[37];
buffer[17] = bufout[ 5];
buffer[18] = bufout[45];
buffer[19] = bufout[13];
buffer[20] = bufout[53];
buffer[21] = bufout[21];
buffer[22] = bufout[61];
buffer[23] = bufout[29];
buffer[24] = bufout[36];
buffer[25] = bufout[ 4];
buffer[26] = bufout[44];
buffer[27] = bufout[12];
buffer[28] = bufout[52];
buffer[29] = bufout[20];
buffer[30] = bufout[60];
buffer[31] = bufout[28];
buffer[32] = bufout[35];
buffer[33] = bufout[ 3];
buffer[34] = bufout[43];
buffer[35] = bufout[11];
buffer[36] = bufout[51];
buffer[37] = bufout[19];
buffer[38] = bufout[59];
buffer[39] = bufout[27];
buffer[40] = bufout[34];
buffer[41] = bufout[ 2];
buffer[42] = bufout[42];
buffer[43] = bufout[10];
buffer[44] = bufout[50];
buffer[45] = bufout[18];
buffer[46] = bufout[58];
buffer[47] = bufout[26];
buffer[48] = bufout[33];
buffer[49] = bufout[ 1];
buffer[50] = bufout[41];
buffer[51] = bufout[ 9];
buffer[52] = bufout[49];
buffer[53] = bufout[17];
buffer[54] = bufout[57];
buffer[55] = bufout[25];
buffer[56] = bufout[32];
buffer[57] = bufout[ 0];
buffer[58] = bufout[40];
buffer[59] = bufout[ 8];
buffer[60] = bufout[48];
buffer[61] = bufout[16];
buffer[62] = bufout[56];
buffer[63] = bufout[24];
j = 0;
for (i = 0; i < 8; i++) {
*(dest + i) = 0x00;
for (k = 0; k < 7; k++)
*(dest + i) = ((*(dest + i)) + buffer[j+k]) * 2;
*(dest + i) = *(dest + i) + buffer[j+7];
j += 8;
}
return 0;
}
| 26.774955 | 84 | 0.524503 |
258357d42f5aa13dcf22746b32048c72c8986eef | 3,389 | h | C | mame/src/emu/cpu/mips/mips3fe.h | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | 15 | 2015-03-03T23:15:57.000Z | 2021-11-12T07:09:24.000Z | mame/src/emu/cpu/mips/mips3fe.h | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | null | null | null | mame/src/emu/cpu/mips/mips3fe.h | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | 8 | 2015-07-07T16:40:44.000Z | 2020-08-18T06:57:29.000Z | /***************************************************************************
mips3fe.h
Front-end for MIPS3 recompiler
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''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 AARON GILES 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.
***************************************************************************/
#pragma once
#ifndef __MIPS3FE_H__
#define __MIPS3FE_H__
#include "mips3com.h"
#include "cpu/drcfe.h"
//**************************************************************************
// MACROS
//**************************************************************************
// register flags 0
#define REGFLAG_R(n) (((n) == 0) ? 0 : (1 << (n)))
// register flags 1
#define REGFLAG_CPR1(n) (1 << (n))
// register flags 2
#define REGFLAG_LO (1 << 0)
#define REGFLAG_HI (1 << 1)
#define REGFLAG_FCC (1 << 2)
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
class mips3_frontend : public drc_frontend
{
public:
// construction/destruction
mips3_frontend(mips3_state &state, UINT32 window_start, UINT32 window_end, UINT32 max_sequence);
protected:
// required overrides
virtual bool describe(opcode_desc &desc, const opcode_desc *prev);
private:
// internal helpers
bool describe_special(UINT32 op, opcode_desc &desc);
bool describe_regimm(UINT32 op, opcode_desc &desc);
bool describe_idt(UINT32 op, opcode_desc &desc);
bool describe_cop0(UINT32 op, opcode_desc &desc);
bool describe_cop1(UINT32 op, opcode_desc &desc);
bool describe_cop1x(UINT32 op, opcode_desc &desc);
bool describe_cop2(UINT32 op, opcode_desc &desc);
// internal state
mips3_state &m_context;
};
#endif /* __MIPS3FE_H__ */
| 35.302083 | 98 | 0.59044 |
e8548da1860580c9d98d9ca9d95c5b974acf57b4 | 1,145 | h | C | src/dfm/nodestore/NodeObject.h | dfm-official/dfm | 97f133aa87b17c760b90f2358d6ba10bc7ad9d1f | [
"ISC"
] | null | null | null | src/dfm/nodestore/NodeObject.h | dfm-official/dfm | 97f133aa87b17c760b90f2358d6ba10bc7ad9d1f | [
"ISC"
] | null | null | null | src/dfm/nodestore/NodeObject.h | dfm-official/dfm | 97f133aa87b17c760b90f2358d6ba10bc7ad9d1f | [
"ISC"
] | null | null | null |
#ifndef RIPPLE_NODESTORE_NODEOBJECT_H_INCLUDED
#define RIPPLE_NODESTORE_NODEOBJECT_H_INCLUDED
#include <ripple/basics/Blob.h>
#include <ripple/basics/CountedObject.h>
#include <ripple/protocol/Protocol.h>
namespace ripple {
enum NodeObjectType
: std::uint32_t
{
hotUNKNOWN = 0,
hotLEDGER = 1,
hotACCOUNT_NODE = 3,
hotTRANSACTION_NODE = 4
};
class NodeObject : public CountedObject <NodeObject>
{
public:
static char const* getCountedObjectName () { return "NodeObject"; }
enum
{
keyBytes = 32,
};
private:
struct PrivateAccess
{
explicit PrivateAccess() = default;
};
public:
NodeObject (NodeObjectType type,
Blob&& data,
uint256 const& hash,
PrivateAccess);
static
std::shared_ptr<NodeObject>
createObject (NodeObjectType type,
Blob&& data, uint256 const& hash);
NodeObjectType getType () const;
uint256 const& getHash () const;
Blob const& getData () const;
private:
NodeObjectType mType;
uint256 mHash;
Blob mData;
};
}
#endif
| 14.679487 | 71 | 0.630568 |
9f983027cc843af3bac1dc7882217a46bd6faa41 | 221 | h | C | lib/NullReferenceException.h | prakashutoledo/pacman-cpp | 0d3e46bd79970d722bc83fd5aeb52a34ad6c27e5 | [
"Apache-2.0"
] | 1 | 2021-04-19T12:10:01.000Z | 2021-04-19T12:10:01.000Z | lib/NullReferenceException.h | prakashutoledo/pacman-cpp | 0d3e46bd79970d722bc83fd5aeb52a34ad6c27e5 | [
"Apache-2.0"
] | null | null | null | lib/NullReferenceException.h | prakashutoledo/pacman-cpp | 0d3e46bd79970d722bc83fd5aeb52a34ad6c27e5 | [
"Apache-2.0"
] | null | null | null | #ifndef NULL_REFERENCE_EXCEPTION_H
#define NULL_REFERENCE_EXCEPTION_H
#include "Exception.h"
class NullReferenceException : public Exception
{
public:
NullReferenceException(string variable, string method);
};
#endif
| 15.785714 | 55 | 0.823529 |
e5e07fa4b71f998cc628e1b1736b006e5d9d58ed | 8,139 | c | C | src/lib/runscript.c | tech-niche-biz/bacula-9.4.4 | 5e74458b612354f6838652dac9ddff94be1bbce6 | [
"BSD-2-Clause"
] | null | null | null | src/lib/runscript.c | tech-niche-biz/bacula-9.4.4 | 5e74458b612354f6838652dac9ddff94be1bbce6 | [
"BSD-2-Clause"
] | null | null | null | src/lib/runscript.c | tech-niche-biz/bacula-9.4.4 | 5e74458b612354f6838652dac9ddff94be1bbce6 | [
"BSD-2-Clause"
] | null | null | null | /*
Bacula(R) - The Network Backup Solution
Copyright (C) 2000-2018 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
You may use this file and others of this release according to the
license defined in the LICENSE file, which includes the Affero General
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
This notice must be preserved when any source code is
conveyed and/or propagated.
Bacula(R) is a registered trademark of Kern Sibbald.
*/
/*
* Manipulation routines for RunScript list
*
* Eric Bollengier, May 2006
*
*/
#include "bacula.h"
#include "jcr.h"
#include "runscript.h"
/*
* This function pointer is set only by the Director (dird.c),
* and is not set in the File daemon, because the File
* daemon cannot run console commands.
*/
bool (*console_command)(JCR *jcr, const char *cmd) = NULL;
RUNSCRIPT *new_runscript()
{
Dmsg0(500, "runscript: creating new RUNSCRIPT object\n");
RUNSCRIPT *cmd = (RUNSCRIPT *)malloc(sizeof(RUNSCRIPT));
memset(cmd, 0, sizeof(RUNSCRIPT));
cmd->reset_default();
return cmd;
}
void RUNSCRIPT::reset_default(bool free_strings)
{
if (free_strings && command) {
free_pool_memory(command);
}
if (free_strings && target) {
free_pool_memory(target);
}
target = NULL;
command = NULL;
on_success = true;
on_failure = false;
fail_on_error = true;
when = SCRIPT_Never;
old_proto = false; /* TODO: drop this with bacula 1.42 */
job_code_callback = NULL;
}
RUNSCRIPT *copy_runscript(RUNSCRIPT *src)
{
Dmsg0(500, "runscript: creating new RUNSCRIPT object from other\n");
RUNSCRIPT *dst = (RUNSCRIPT *)malloc(sizeof(RUNSCRIPT));
memcpy(dst, src, sizeof(RUNSCRIPT));
dst->command = NULL;
dst->target = NULL;
dst->set_command(src->command, src->cmd_type);
dst->set_target(src->target);
return dst;
}
void free_runscript(RUNSCRIPT *script)
{
Dmsg0(500, "runscript: freeing RUNSCRIPT object\n");
if (script->command) {
free_pool_memory(script->command);
}
if (script->target) {
free_pool_memory(script->target);
}
free(script);
}
int run_scripts(JCR *jcr, alist *runscripts, const char *label)
{
Dmsg2(200, "runscript: running all RUNSCRIPT object (%s) JobStatus=%c\n", label, jcr->JobStatus);
RUNSCRIPT *script;
bool runit;
int when;
if (strstr(label, NT_("Before"))) {
when = SCRIPT_Before;
} else if (bstrcmp(label, NT_("ClientAfterVSS"))) {
when = SCRIPT_AfterVSS;
} else {
when = SCRIPT_After;
}
if (runscripts == NULL) {
Dmsg0(100, "runscript: WARNING RUNSCRIPTS list is NULL\n");
return 0;
}
foreach_alist(script, runscripts) {
Dmsg2(200, "runscript: try to run %s:%s\n", NPRT(script->target), NPRT(script->command));
runit = false;
if ((script->when & SCRIPT_Before) && (when & SCRIPT_Before)) {
if ((script->on_success &&
(jcr->JobStatus == JS_Running || jcr->JobStatus == JS_Created))
|| (script->on_failure &&
(job_canceled(jcr) || jcr->JobStatus == JS_Differences))
)
{
Dmsg4(200, "runscript: Run it because SCRIPT_Before (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
runit = true;
}
}
if ((script->when & SCRIPT_AfterVSS) && (when & SCRIPT_AfterVSS)) {
if ((script->on_success && (jcr->JobStatus == JS_Blocked))
|| (script->on_failure && job_canceled(jcr))
)
{
Dmsg4(200, "runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
runit = true;
}
}
if ((script->when & SCRIPT_After) && (when & SCRIPT_After)) {
if ((script->on_success &&
(jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings))
|| (script->on_failure &&
(job_canceled(jcr) || jcr->JobStatus == JS_Differences))
)
{
Dmsg4(200, "runscript: Run it because SCRIPT_After (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
runit = true;
}
}
if (!script->is_local()) {
runit = false;
}
/* we execute it */
if (runit) {
script->run(jcr, label);
}
}
return 1;
}
bool RUNSCRIPT::is_local()
{
if (!target || (strcmp(target, "") == 0)) {
return true;
} else {
return false;
}
}
/* set this->command to cmd */
void RUNSCRIPT::set_command(const char *cmd, int acmd_type)
{
Dmsg1(500, "runscript: setting command = %s\n", NPRT(cmd));
if (!cmd) {
return;
}
if (!command) {
command = get_pool_memory(PM_FNAME);
}
pm_strcpy(command, cmd);
cmd_type = acmd_type;
}
/* set this->target to client_name */
void RUNSCRIPT::set_target(const char *client_name)
{
Dmsg1(500, "runscript: setting target = %s\n", NPRT(client_name));
if (!client_name) {
return;
}
if (!target) {
target = get_pool_memory(PM_FNAME);
}
pm_strcpy(target, client_name);
}
bool RUNSCRIPT::run(JCR *jcr, const char *name)
{
Dmsg1(100, "runscript: running a RUNSCRIPT object type=%d\n", cmd_type);
POOLMEM *ecmd = get_pool_memory(PM_FNAME);
int status;
BPIPE *bpipe;
char line[MAXSTRING];
ecmd = edit_job_codes(jcr, ecmd, this->command, "", this->job_code_callback);
Dmsg1(100, "runscript: running '%s'...\n", ecmd);
Jmsg(jcr, M_INFO, 0, _("%s: run %s \"%s\"\n"),
cmd_type==SHELL_CMD?"shell command":"console command", name, ecmd);
switch (cmd_type) {
case SHELL_CMD:
bpipe = open_bpipe(ecmd, 0, "r");
if (bpipe == NULL) {
berrno be;
Jmsg(jcr, M_ERROR, 0, _("Runscript: %s could not execute. ERR=%s\n"), name,
be.bstrerror());
goto bail_out;
}
while (fgets(line, sizeof(line), bpipe->rfd)) {
int len = strlen(line);
if (len > 0 && line[len-1] == '\n') {
line[len-1] = 0;
}
Jmsg(jcr, M_INFO, 0, _("%s: %s\n"), name, line);
}
status = close_bpipe(bpipe);
if (status != 0) {
berrno be;
Jmsg(jcr, M_ERROR, 0, _("Runscript: %s returned non-zero status=%d. ERR=%s\n"), name,
be.code(status), be.bstrerror(status));
goto bail_out;
}
Dmsg0(100, "runscript OK\n");
break;
case CONSOLE_CMD:
if (console_command) { /* can we run console command? */
if (!console_command(jcr, ecmd)) { /* yes, do so */
goto bail_out;
}
}
break;
}
free_pool_memory(ecmd);
return true;
bail_out:
free_pool_memory(ecmd);
/* cancel running job properly */
if (fail_on_error) {
jcr->setJobStatus(JS_ErrorTerminated);
}
Dmsg1(100, "runscript failed. fail_on_error=%d\n", fail_on_error);
return false;
}
void free_runscripts(alist *runscripts)
{
Dmsg0(500, "runscript: freeing all RUNSCRIPTS object\n");
if (runscripts){
RUNSCRIPT *elt;
foreach_alist(elt, runscripts) {
free_runscript(elt);
}
}
}
void RUNSCRIPT::debug()
{
Dmsg0(200, "runscript: debug\n");
Dmsg0(200, _(" --> RunScript\n"));
Dmsg1(200, _(" --> Command=%s\n"), NPRT(command));
Dmsg1(200, _(" --> Target=%s\n"), NPRT(target));
Dmsg1(200, _(" --> RunOnSuccess=%u\n"), on_success);
Dmsg1(200, _(" --> RunOnFailure=%u\n"), on_failure);
Dmsg1(200, _(" --> FailJobOnError=%u\n"), fail_on_error);
Dmsg1(200, _(" --> RunWhen=%u\n"), when);
}
void RUNSCRIPT::set_job_code_callback(job_code_callback_t arg_job_code_callback)
{
this->job_code_callback = arg_job_code_callback;
}
| 26.773026 | 100 | 0.593808 |
bf04400e4fb560ca0d447e65f13839c8ebc07dec | 1,663 | h | C | libs/DS4_SDK/include/dzindexlist.h | Red54/reality | 510d4f5fde2f4c5535482f1ea199f914102b8a2a | [
"BSD-3-Clause"
] | null | null | null | libs/DS4_SDK/include/dzindexlist.h | Red54/reality | 510d4f5fde2f4c5535482f1ea199f914102b8a2a | [
"BSD-3-Clause"
] | null | null | null | libs/DS4_SDK/include/dzindexlist.h | Red54/reality | 510d4f5fde2f4c5535482f1ea199f914102b8a2a | [
"BSD-3-Clause"
] | null | null | null | /**********************************************************************
Copyright (C) 2002-2012 DAZ 3D, Inc. All Rights Reserved.
This file is part of the DAZ Studio SDK.
This file may be used only in accordance with the DAZ Studio SDK
license provided with the DAZ Studio SDK.
The contents of this file may not be disclosed to third parties,
copied or duplicated in any form, in whole or in part, without the
prior written permission of DAZ 3D, Inc, except as explicitly
allowed in the DAZ Studio SDK license.
See http://www.daz3d.com to contact DAZ 3D or for more
information about the DAZ Studio SDK.
**********************************************************************/
/**
@sdk
@file
Defines the DzIndexList class.
**/
#ifndef DAZ_INDEX_LIST_H
#define DAZ_INDEX_LIST_H
/*****************************
Include files
*****************************/
#include "dzbase.h"
/*****************************
Class definitions
*****************************/
class DZ_EXPORT DzIndexList : public DzBase {
Q_OBJECT
public:
DzIndexList();
DzIndexList( const QString &name );
DzIndexList( const DzIndexList &list );
virtual ~DzIndexList();
DzIndexList &operator=( const DzIndexList &list );
int* setCount( int count );
void preSizeArray( int count );
public slots:
void addIndex( int idx );
int findIndex( int idx ) const;
bool removeIndex( int idx );
bool removeComponent( int idx );
void clear();
int count() const;
int getIndex( int i ) const;
public:
const int* getIndicesPtr() const;
private:
struct Data;
Data *m_data;
};
#endif // DAZ_INDEX_LIST_H
| 24.820896 | 72 | 0.586891 |
bf07b2f45687da20662a3c379eb2c630422e11c1 | 325 | h | C | phSolver/common/phasta.h | yangf4/phasta | a096094f33b98047de0a2e28225c4d74875a88d8 | [
"BSD-3-Clause"
] | 49 | 2015-04-16T13:45:34.000Z | 2022-02-07T01:02:49.000Z | phSolver/common/phasta.h | yangf4/phasta | a096094f33b98047de0a2e28225c4d74875a88d8 | [
"BSD-3-Clause"
] | 21 | 2015-10-06T19:50:43.000Z | 2017-12-17T03:47:51.000Z | phSolver/common/phasta.h | yangf4/phasta | a096094f33b98047de0a2e28225c4d74875a88d8 | [
"BSD-3-Clause"
] | 38 | 2015-04-21T12:13:40.000Z | 2021-11-12T19:38:00.000Z | #ifndef PHASTA_H_
#define PHASTA_H_
#include "Input.h"
struct RStream;
struct GRStream;
int phasta(int argc, char**argv);
int phasta(phSolver::Input& ctrl);
int phasta(phSolver::Input& ctrl, GRStream* in);
int phasta(phSolver::Input& ctrl, RStream* out);
int phasta(phSolver::Input& ctrl, GRStream* in, RStream* out);
#endif
| 27.083333 | 62 | 0.747692 |
bf4abfb7554e7e842c2eb632cf4786ec353aae2a | 4,460 | h | C | alljoyn/services/time/cpp/src/common/TimeServiceAlarmUtility.h | octoblu/alljoyn | a74003fa25af1d0790468bf781a4d49347ec05c4 | [
"ISC"
] | 37 | 2015-01-18T21:27:23.000Z | 2018-01-12T00:33:43.000Z | alljoyn/services/time/cpp/src/common/TimeServiceAlarmUtility.h | octoblu/alljoyn | a74003fa25af1d0790468bf781a4d49347ec05c4 | [
"ISC"
] | 14 | 2015-02-24T11:44:01.000Z | 2020-07-20T18:48:44.000Z | alljoyn/services/time/cpp/src/common/TimeServiceAlarmUtility.h | octoblu/alljoyn | a74003fa25af1d0790468bf781a4d49347ec05c4 | [
"ISC"
] | 29 | 2015-01-23T16:40:52.000Z | 2019-10-21T12:22:30.000Z | /******************************************************************************
* Copyright AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
#ifndef TIMESERVICEALARMUTILITY_H_
#define TIMESERVICEALARMUTILITY_H_
#include <alljoyn/BusAttachment.h>
#include <alljoyn/Status.h>
#include <alljoyn/InterfaceDescription.h>
#include <alljoyn/time/TimeServiceConstants.h>
#include <alljoyn/time/TimeServiceSchedule.h>
namespace ajn {
namespace services {
namespace tsAlarmUtility {
//Alarm interface and object
const qcc::String IFACE_PROP_VERSION = "Version";
const qcc::String IFACE_PROP_SCHEDULE = "Schedule";
const qcc::String IFACE_PROP_TITLE = "Title";
const qcc::String IFACE_PROP_ENABLED = "Enabled";
const qcc::String IFACE_SIG_ALARM_REACHED = "AlarmReached";
const qcc::String IFACE_DESCRIPTION = "Alarm";
const qcc::String IFACE_DESCRIPTION_LAGN = "en";
const qcc::String IFACE_SIG_ALARM_REACHED_DESC = "Alarm reached signal";
const qcc::String OBJ_PATH_PREFIX = "/Alarm";
const uint16_t ALARM_REACHED_TTL_SECONDS = 50;
const qcc::String IFACE_FAC_PROP_VERSION = "Version";
const qcc::String IFACE_FAC_METHOD_NEW_ALARM = "NewAlarm";
const qcc::String IFACE_FAC_METHOD_DELETE_ALARM = "DeleteAlarm";
const qcc::String FAC_OBJ_PATH_PREFIX = "/AlarmFactory";
/**
* Create Alarm interface
*
* @param bus BusAttachment
* @param ptrIfaceDesc InterfaceDescription
*/
QStatus createInterface(BusAttachment* bus, InterfaceDescription** ptrIfaceDesc);
/**
* Unmarshal Schedule
*
* @param msgArg Contains schedule to be unmarshalled
* @param schedule Out variable. Unmarshalled Schedule
*/
QStatus unmarshalSchedule(const MsgArg& msgArg, TimeServiceSchedule* schedule);
/**
* Marshal Schedule
*
* @param msgArg Out variable. MsgArg contains marshalled schedule.
* @param schedule Schedule to be marshalled.
*/
QStatus marshalSchedule(MsgArg& msgArg, const TimeServiceSchedule& schedule);
/**
* Unmarshal title
*
* @param msgArg Contains title to be unmarshalled
* @param title Out variable. Unmarshalled title
*/
QStatus unmarshalTitle(const MsgArg& msgArg, qcc::String* title);
/**
* Marshal Title
*
* @param msgArg Out variable. MsgArg contains marshalled title.
* @param title Title to be marshalled.
*/
QStatus marshalTitle(MsgArg& msgArg, const qcc::String& title);
/**
* Unmarshal Enabled property
*
* @param msgArg Contains Enabled property to be unmarshalled
* @param isEnabled Out variable. Unmarshalled Enabled property
*/
QStatus unmarshalEnabled(const MsgArg& msgArg, bool* isEnabled);
/**
* Marshal Enabled property
*
* @param msgArg Out variable. MsgArg contains marshalled Enabled property.
* @param isEnabled Enabled property to be marshalled.
*/
QStatus marshalEnabled(MsgArg& msgArg, const bool isEnabled);
/**
* Create AlarmFactory interface
*
* @param bus BusAttachment
* @param ptrIfaceDesc InterfaceDescription
*/
QStatus createFactoryInterface(BusAttachment* bus, InterfaceDescription** ptrIfaceDesc);
/**
* Marshal object path
*
* @param msgArg Out. Contains object path to marshal
* @param objPath Object path to marshal
*/
QStatus marshalObjectPath(MsgArg& msgArg, const qcc::String& objPath);
/**
* Unmarshal object path
*
* @param msgArg Out. Contains object path to be unmarshalled
* @param objPath Object path to unmarshal
*/
QStatus unmarshalObjectPath(const MsgArg& msgArg, qcc::String* objPath);
} /* namespace tsAlarmUtility */
} /* namespace services */
} /* namespace ajn */
#endif /* TIMESERVICEALARMUTILITY_H_ */
| 33.787879 | 88 | 0.715695 |
c7bb1d697825945e7e2aa7cea0e441d8d360d197 | 641 | h | C | TTNews/Classes/Me/MyShoppongTableCell.h | 1370156363/TTNews1 | 8775ec0e4bc878ddfc978c50f95add5504492e03 | [
"Unlicense",
"MIT"
] | null | null | null | TTNews/Classes/Me/MyShoppongTableCell.h | 1370156363/TTNews1 | 8775ec0e4bc878ddfc978c50f95add5504492e03 | [
"Unlicense",
"MIT"
] | null | null | null | TTNews/Classes/Me/MyShoppongTableCell.h | 1370156363/TTNews1 | 8775ec0e4bc878ddfc978c50f95add5504492e03 | [
"Unlicense",
"MIT"
] | null | null | null | //
// MyShoppongTableCell.h
// TTNews
//
// Created by 薛立强 on 2017/11/7.
// Copyright © 2017年 瑞文戴尔. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyShoppongTableCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *imgShopView;
@property (weak, nonatomic) IBOutlet UILabel *labTitle;
@property (weak, nonatomic) IBOutlet UILabel *labPrice;
@property (weak, nonatomic) IBOutlet UIButton *btnOperate;
@property (weak, nonatomic) IBOutlet UILabel *labDingdanState;
@property (weak, nonatomic) IBOutlet UIButton *btnDeletaDingdan;
@property (nonatomic, copy) void(^MyShoppongTable)(NSInteger index);
@end
| 29.136364 | 68 | 0.762871 |
a7d040afd5027f240d7650a1a122f8d0d02e48b9 | 396 | h | C | SkimaServer/SkimaServer/ContactListener.h | dlakwwkd/CommitAgain | 3fdad38f7951b1a58ae244bd5d68f5a92e97f633 | [
"MIT"
] | 1 | 2015-04-07T06:08:11.000Z | 2015-04-07T06:08:11.000Z | SkimaServer/SkimaServer/ContactListener.h | dlakwwkd/CommitAgain | 3fdad38f7951b1a58ae244bd5d68f5a92e97f633 | [
"MIT"
] | 1 | 2015-01-01T11:14:29.000Z | 2015-01-01T12:19:04.000Z | SkimaServer/SkimaServer/ContactListener.h | dlakwwkd/CommitAgain | 3fdad38f7951b1a58ae244bd5d68f5a92e97f633 | [
"MIT"
] | null | null | null | #pragma once
class ContactListener : public b2ContactListener
{
public:
ContactListener(){}
virtual ~ContactListener(){}
virtual void BeginContact(b2Contact *contact){}
virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold){}
virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
virtual void EndContact(b2Contact* contact);
};
| 28.285714 | 80 | 0.75 |
4420211b4e3ac5ee3d2296d5c3a2fdad16fd7618 | 5,063 | h | C | rs12.h | giulioz/s550util | 966811aad39b1277d8a952db06a725569024b3a7 | [
"BSD-3-Clause-No-Nuclear-License"
] | 1 | 2021-04-24T15:15:20.000Z | 2021-04-24T15:15:20.000Z | rs12.h | giulioz/s550util | 966811aad39b1277d8a952db06a725569024b3a7 | [
"BSD-3-Clause-No-Nuclear-License"
] | null | null | null | rs12.h | giulioz/s550util | 966811aad39b1277d8a952db06a725569024b3a7 | [
"BSD-3-Clause-No-Nuclear-License"
] | null | null | null | #ifndef RS12_H
#define RS12_H
/************************************************************************/
/* NAME */
/* rs12.h */
/* DESCRIPTION */
/* Roland 12-bit-sampler disk format for the S-550, S-330, etc.). */
/* AUTHOR */
/* Copyright 1992 by Gary J. Murakami <gjm@research.att.com> */
/* V1.0 (4 May 1992) Freely distibutable for non-comercial use. */
/* All other rights reserved. */
/************************************************************************/
#define SamplesPerSegment 12288
typedef struct systemProgram {
char data[0176000]; /* 0xFC00 == 64512 */
} SystemProgram;
typedef struct patchParameter {
uint8_t patchName[12];
uint8_t bendRange;
uint8_t dummy1[1];
uint8_t afterTouchSense;
uint8_t keyMode;
uint8_t velocitySwThreshold;
uint8_t toneToKey1[109];
uint8_t toneToKey2[109];
uint8_t copySource;
uint8_t octaveShift;
uint8_t outputLevel;
uint8_t dummy2[1];
uint8_t detune;
uint8_t velocityMixRatio;
uint8_t afterTouchAssign;
uint8_t keyAssign;
uint8_t outputAssign;
uint8_t dummy3[12];
} PatchParameter;
typedef struct functionParameter {
uint8_t masterTune;
uint8_t dummy1[13];
uint8_t audioTrig;
uint8_t dummy2[1];
uint8_t voiceMode;
uint8_t multiMidiRxCh[8];
uint8_t multiPatchNumber[8];
uint8_t dummy3[9];
uint8_t keyboardDisplay;
uint8_t multiLevel[8];
uint8_t diskLabel[60];
uint8_t dummy4[4];
uint8_t externalController;
uint8_t dummy5[140];
} FunctionParameter;
typedef struct midiParameter {
uint8_t dummy1[32];
uint8_t rxChannel[8];
uint8_t rxProgramChange[8];
uint8_t rxBender[8];
uint8_t rxModulation[8];
uint8_t rxHold[8];
uint8_t rxAfterTouch[8];
uint8_t rxVolume[8];
uint8_t rxBendRange[8];
uint8_t dummy2[1];
uint8_t systemExclusive;
uint8_t deviceId;
uint8_t dummy3[1];
uint8_t rxProgramChangeNumber[32];
uint8_t dummy4[124];
} MidiParameter;
typedef struct toneParameter {
uint8_t toneName[8];
uint8_t outputAssign;
uint8_t sourceTone;
uint8_t orgSubTone;
uint8_t samplingFrequency;
uint8_t origKeyNumber;
uint8_t waveBank;
uint8_t waveSegmentTop;
uint8_t waveSegmentLength;
uint8_t startPoint[3];
uint8_t endPoint[3];
uint8_t loopPoint[3];
uint8_t loopMode;
uint8_t tvaLfoDepth;
uint8_t dummy1[1];
uint8_t lfoRate;
uint8_t lfoSync;
uint8_t lfoDelay;
uint8_t dummy2[1];
uint8_t lfoMode;
uint8_t oscLfoDepth;
uint8_t lfoPolarity;
uint8_t lfoOffset;
uint8_t transpose;
uint8_t fineTune;
uint8_t tvfCutOff;
uint8_t tvfResonance;
uint8_t tvfKeyFollow;
uint8_t dummy3[1];
uint8_t tvfLfoDepth;
uint8_t tvfEgDepth;
uint8_t tvfEgPolarity;
uint8_t tvfLevelCurve;
uint8_t tvfKeyRateFollow;
uint8_t tvfVelocityRateFollow;
uint8_t dummy4[1];
uint8_t tvfSwitch;
uint8_t benderSwitch;
uint8_t tvaEnvSustainPoint;
uint8_t tvaEnvEndPoint;
uint8_t tvaEnvLevel1;
uint8_t tvaEnvRate1;
uint8_t tvaEnvLevel2;
uint8_t tvaEnvRate2;
uint8_t tvaEnvLevel3;
uint8_t tvaEnvRate3;
uint8_t tvaEnvLevel4;
uint8_t tvaEnvRate4;
uint8_t tvaEnvLevel5;
uint8_t tvaEnvRate5;
uint8_t tvaEnvLevel6;
uint8_t tvaEnvRate6;
uint8_t tvaEnvLevel7;
uint8_t tvaEnvRate7;
uint8_t tvaEnvLevel8;
uint8_t tvaEnvRate8;
uint8_t dummy5[1];
uint8_t tvaEnvKeyRate;
uint8_t level;
uint8_t envVelRate;
uint8_t recThreshold;
uint8_t recPreTrigger;
uint8_t recSamplingFrequency;
uint8_t recStartPoint[3];
uint8_t recEndPoint[3];
uint8_t recLoopPoint[3];
uint8_t zoomT;
uint8_t zoomL;
uint8_t copySource;
uint8_t loopTune;
uint8_t tvaLevelCurve;
uint8_t dummy6[12];
uint8_t loopLength[3];
uint8_t pitchFollow;
uint8_t envZoom;
uint8_t tvfEnvSustainPoint;
uint8_t tvfEnvEndPoint;
uint8_t tvfEnvLevel1;
uint8_t tvfEnvRate1;
uint8_t tvfEnvLevel2;
uint8_t tvfEnvRate2;
uint8_t tvfEnvLevel3;
uint8_t tvfEnvRate3;
uint8_t tvfEnvLevel4;
uint8_t tvfEnvRate4;
uint8_t tvfEnvLevel5;
uint8_t tvfEnvRate5;
uint8_t tvfEnvLevel6;
uint8_t tvfEnvRate6;
uint8_t tvfEnvLevel7;
uint8_t tvfEnvRate7;
uint8_t tvfEnvLevel8;
uint8_t tvfEnvRate8;
uint8_t afterTouchSwitch;
uint8_t dummy7[2];
} ToneParameter;
typedef struct toneList {
uint8_t toneName[8];
uint8_t unknown[8];
} ToneList;
typedef struct waveData {
uint8_t data[SamplesPerSegment * 3 / 2];
} WaveData;
typedef struct disk {
SystemProgram systemProgram; /* 0000 */
PatchParameter patchParameter[16]; /* FC00 */
FunctionParameter functionParameter; /* 10C00 */
MidiParameter midiParameter; /* 10D00 */
ToneParameter toneParameter[32]; /* 10E00 */
ToneList toneList[32]; /* 11E00 */
WaveData waveDataA[18]; /* 12000 */
WaveData waveDataB[18];
} Disk;
#endif
| 25.831633 | 74 | 0.673909 |
db48c8979ea7a7d9253eb18dc0f3ad0cdf88667f | 655 | c | C | src/chunkops.c | msaw328/msbignum | 67747a9af072608321e637110ec03e5650f1c939 | [
"MIT"
] | null | null | null | src/chunkops.c | msaw328/msbignum | 67747a9af072608321e637110ec03e5650f1c939 | [
"MIT"
] | null | null | null | src/chunkops.c | msaw328/msbignum | 67747a9af072608321e637110ec03e5650f1c939 | [
"MIT"
] | null | null | null | #include "msbignum/types.h"
#include "internal/defaults.h"
#define BITSHIFT (sizeof(bignum_chunk_t) * 8)
bignum_chunksafe_t __bignum_chunk_promote(bignum_chunk_t c) {
return (bignum_chunksafe_t) c;
}
bignum_chunksafe_t __bignum_chunk_promote_withborrow(bignum_chunk_t c, bignum_chunk_t borrow) {
return (((bignum_chunksafe_t) borrow) << BITSHIFT) | (bignum_chunksafe_t) c;
}
bignum_chunk_t __bignum_chunk_value_part(bignum_chunksafe_t cs) {
return (bignum_chunk_t) (cs & BIGNUM_MAX_CHUNK);
}
bignum_chunk_t __bignum_chunk_carry_part(bignum_chunksafe_t cs) {
cs = cs >> BITSHIFT;
return (bignum_chunk_t) (cs & BIGNUM_MAX_CHUNK);
}
| 29.772727 | 95 | 0.777099 |
dba9e57b11386b434a49781e22946af917ded03a | 2,673 | h | C | user.h | Paresh-Kr/System-Calls-Implementation-in-XV6 | 14417432d6e36185e8d41b4196d4a3a8a72e2ce6 | [
"MIT-0"
] | null | null | null | user.h | Paresh-Kr/System-Calls-Implementation-in-XV6 | 14417432d6e36185e8d41b4196d4a3a8a72e2ce6 | [
"MIT-0"
] | null | null | null | user.h | Paresh-Kr/System-Calls-Implementation-in-XV6 | 14417432d6e36185e8d41b4196d4a3a8a72e2ce6 | [
"MIT-0"
] | null | null | null | #include "types.h"
struct stat;
struct rtcdate;
// system calls
int fork(void);
int exit(void) __attribute__((noreturn));
int wait(void);
int pipe(int*);
int write(int, void*, int);
int read(int, void*, int);
int close(int);
int kill(int);
int exec(char*, char**);
int open(char*, int);
int mknod(char*, short, short);
int unlink(char*);
int fstat(int fd, struct stat*);
int link(char*, char*);
int mkdir(char*);
int chdir(char*);
int dup(int);
int getpid(void);
char* sbrk(int);
int sleep(int);
int uptime(void);
int date(struct rtcdate *);
// ulib.c
int stat(char*, struct stat*);
char* strcpy(char*, char*);
void *memmove(void*, void*, int);
char* strchr(const char*, char c);
int strcmp(const char*, const char*);
void printf(int, char*, ...);
char* gets(char*, int max);
uint strlen(char*);
void* memset(void*, int, uint);
void* malloc(uint);
void free(void*);
int atoi(const char*);
//int first(void);
//int second(void);
int aaICO(void);
int RwwzQ(void);
int vPlkH(void);
int nAAkW(void);
int V4XHy(void);
int DIJ1J(void);
int uby8E(void);
int HrYmw(void);
int It9GD(void);
int kBqyL(void);
int uFvqh(void);
int kCOzo(void);
int BdglP(void);
int vsu9T(void);
int GhENr(void);
int cNlc2(void);
int AUX47(void);
int OJjUF(void);
int rwbCB(void);
int U63O6(void);
int buYn9(void);
int pvRfc(void);
int IbIsf(void);
int RH7FR(void);
int u5Ncu(void);
int vA3kF(void);
int ZyJFv(void);
int a_kuY(void);
int DF2ak(void);
int bifXB(void);
int OpuAe(void);
int DNUxN(void);
int ancIB(void);
int fiuCL(void);
int f85c4(void);
int pKQyj(void);
int sPh9f(void);
int aSdV9(void);
int hEwee(void);
int m7xSo(void);
int lpg5S(void);
int J7GF1(void);
int GYEGy(void);
int UHuoA(void);
int lfawm(void);
int SkxVQ(void);
int m7dk_(void);
int C2FTH(void);
int ZFvwG(void);
int xMznMiMbd2ASBAopjUBD(void);
int ajJ2rUS36Ds7gCvYhWvRMQ4cM(void);
int lcQQ6(void);
int tG0cd(void);
int BQaye(void);
int vRL61(void);
int BfPAS(void);
int VWqcU(void);
int rNV_x(void);
int m9TVP(void);
int dN3rB(void);
int NEorw(void);
int iE45d(void);
int VFGu_(void);
int zqf7e(void);
int Ayr5H(void);
int y7dVW(void);
int RhaR2(void);
int GUT_3(void);
int mtwGL(void);
int Rz1qA(void);
int BDslj(void);
int DYcHF(void);
int XVI4N(void);
int RknTi(void);
int eraAb(void);
int K7plu(void);
int UPjQy(void);
int uFjK1(void);
int E8Jj9(void);
int viJpE(void);
int y8hmu(void);
int GhPNY(void);
int mEymb(void);
int UAi7z(void);
int g3fke(void);
int spiXC(void);
int sCY6P(void);
int lQ5p2(void);
int yFLZV(void);
int y7NBZ(void);
int JS_81(void);
int pHGgA(void);
int D3BT2(void);
int LYSUb(void);
int UHDeS(void);
int zQQm5(void);
int T4IiC(void);
int ZnCtG(void);
int TBDYx(void);
int k_jNM(void);
| 17.585526 | 41 | 0.695473 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.