content
stringlengths 15
442k
| obf_code
stringlengths 15
442k
| probability
float64 0
1
| obf_dict
stringlengths 0
13.5k
| lang
stringclasses 3
values | classification
stringclasses 5
values | confiability
stringlengths 1
10
|
---|---|---|---|---|---|---|
/** @file
This file contains definitions of Si Schedule Reset HOB.
Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _SI_SCHEDULE_RESET_HOB_H_
#define _SI_SCHEDULE_RESET_HOB_H_
/**
This structure is used to provide information about PCH Resets
**/
typedef struct {
EFI_RESET_TYPE ResetType;
PCH_RESET_DATA ResetData;
} SI_SCHEDULE_RESET_HOB;
extern EFI_GUID gSiScheduleResetHobGuid;
#endif // _SI_SCHEDULE_RESET_HOB_H_
| /** @file
This file contains definitions of Si Schedule Reset HOB.
Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef VAR_0
#define VAR_0
/**
This structure is used to provide information about PCH Resets
**/
typedef struct {
EFI_RESET_TYPE ResetType;
CLASS_0 ResetData;
} ID_0;
extern EFI_GUID gSiScheduleResetHobGuid;
#endif // _SI_SCHEDULE_RESET_HOB_H_
| 0.288208 | {'VAR_0': '_SI_SCHEDULE_RESET_HOB_H_', 'CLASS_0': 'PCH_RESET_DATA', 'ID_0': 'SI_SCHEDULE_RESET_HOB'} | c | Hibrido | 100.00% |
//
// UIViewController+KeyboardCorver.h
// KeyBoardTest
//
// Created by CxDtreeg on 15/10/30.
// Copyright © 2015年 CxDtreeg. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#define APPWINDOWHEIGHT ([UIScreen mainScreen].bounds.size.height)
#define APPWINDOWWIDTH ([UIScreen mainScreen].bounds.size.width)
@interface UIViewController (KeyboardCorver)
@property (strong, nonatomic) UITapGestureRecognizer * keyboardHideTapGesture;//键盘点击隐藏手势
@property (strong, nonatomic) UIView * objectView;//目标视图
#pragma mark - 添加键盘通知
- (void)addNotification;
#pragma mark - 清理通知和移除手势 在控制器的dealloc中记得要释放
- (void)clearNotificationAndGesture;
@end
| //
// UIViewController+KeyboardCorver.h
// KeyBoardTest
//
// Created by CxDtreeg on 15/10/30.
// Copyright © 2015年 CxDtreeg. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#define APPWINDOWHEIGHT ([UIScreen mainScreen].bounds.size.height)
#define APPWINDOWWIDTH ([UIScreen mainScreen].bounds.size.width)
@interface FUNC_0 (VAR_0)
@VAR_1 (strong, nonatomic) UITapGestureRecognizer * keyboardHideTapGesture;//键盘点击隐藏手势
@VAR_1 (strong, nonatomic) UIView * VAR_2;//目标视图
#pragma mark - 添加键盘通知
- (void)addNotification;
#pragma mark - 清理通知和移除手势 在控制器的dealloc中记得要释放
- (void)clearNotificationAndGesture;
@CLASS_0
| 0.364914 | {'FUNC_0': 'UIViewController', 'VAR_0': 'KeyboardCorver', 'VAR_1': 'property', 'VAR_2': 'objectView', 'CLASS_0': 'end'} | c | Procedural | 100.00% |
plan: navigation: gotoMe
Select Window [ Name: "Planned Workouts"; Current file ]
Select Window [ Name: "My Workouts"; Current file ]
January 8, 平成26 12:29:06 Fat and Muscle Efficiency Research.fp7 - gotoMe -1-
| plan: navigation: gotoMe
Select Window [ VAR_0: "Planned Workouts"; Current VAR_1 ]
Select Window [ VAR_0: "My Workouts"; Current VAR_1 ]
January 8, VAR_229:06 Fat VAR_3 VAR_4cVAR_5iciency Research.fp7 VAR_6otoVAR_7
| 0.711198 | {'VAR_0': 'Name', 'VAR_1': 'file', 'VAR_2': '平成26 12:', 'VAR_3': 'and', 'VAR_4': 'Mus', 'VAR_5': 'le Eff', 'VAR_6': '- g', 'VAR_7': 'Me -1-'} | c | Texto | 100.00% |
//
// XQDTabBarItem.h
// gongfudai
//
// Created by <NAME> on 15/10/19.
// Copyright (c) 2015年 dashu. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface XQDTabBarItem : UITabBarItem
@end
| //
// XQDTabBarItem.h
// gongfudai
//
// Created by <NAME> on 15/10/19.
// Copyright (c) 2015年 dashu. All rights reserved.
//
#import <UIKit/UIKit.h>
@CLASS_0 VAR_0 : VAR_1
@end
| 0.712631 | {'CLASS_0': 'interface', 'VAR_0': 'XQDTabBarItem', 'VAR_1': 'UITabBarItem'} | c | Procedural | 100.00% |
DECL|ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_|macro|ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_
DECL|data_imei|member|char *data_imei;
DECL|data_manufacturer|member|char *data_manufacturer;
DECL|data_model|member|char *data_model;
DECL|data_revision|member|char *data_revision;
DECL|data_rssi|member|int data_rssi;
DECL|mdm_receiver_context|struct|struct mdm_receiver_context {
DECL|rx_sem|member|struct k_sem rx_sem;
DECL|uart_dev|member|struct device *uart_dev;
DECL|uart_pipe_buf|member|u8_t *uart_pipe_buf;
DECL|uart_pipe_size|member|size_t uart_pipe_size;
DECL|uart_pipe|member|struct k_pipe uart_pipe;
| DECL|ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_|macro|ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_
DECL|data_imei|VAR_0|char *data_imei;
DECL|data_manufacturer|VAR_0|char *data_manufacturer;
DECL|data_model|VAR_0|char *data_model;
DECL|data_revision|VAR_0|char *data_revision;
DECL|data_rssi|VAR_0|int data_rssi;
DECL|VAR_1|struct|struct VAR_1 {
DECL|rx_sem|VAR_0|struct CLASS_0 rx_sem;
DECL|VAR_2|VAR_0|struct device *VAR_2;
DECL|uart_pipe_buf|VAR_0|u8_t *uart_pipe_buf;
DECL|uart_pipe_size|VAR_0|size_t uart_pipe_size;
DECL|uart_pipe|VAR_0|struct k_pipe uart_pipe;
| 0.374832 | {'VAR_0': 'member', 'VAR_1': 'mdm_receiver_context', 'CLASS_0': 'k_sem', 'VAR_2': 'uart_dev'} | c | OOP | 100.00% |
/*
* Copyright (C) 2004-2020 <NAME>
*
* This file is part of Libint.
*
* Libint 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 3 of the License, or
* (at your option) any later version.
*
* Libint 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 Libint. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _libint2_header_
#define _libint2_header_
#define LIBINT_T_SS_EREP_SS(mValue) _aB_s___0__s___1___TwoPRep_s___0__s___1___Ab__up_##mValue
#define LIBINT_T_SS_Km1G12_SS(mValue) _aB_s___0__s___1___r12_minus_1_g12_s___0__s___1___Ab__up_##mValue
#define LIBINT_T_SS_K0G12_SS_0 _aB_s___0__s___1___r12_0_g12_s___0__s___1___Ab__up_0
#define LIBINT_T_SS_K2G12_SS_0 _aB_s___0__s___1___r12_2_g12_s___0__s___1___Ab__up_0
#define LIBINT_T_SS_K4G12_SS_0 _aB_s___0__s___1___r12_4_g12_s___0__s___1___Ab__up_0
#define LIBINT_T_S_OVERLAP_S _aB_s___0___Overlap_s___0___Ab__up_
#define LIBINT_T_S_KINETIC_S _aB_s___0___Kinetic_s___0___Ab__up_
#define LIBINT_T_S_ELECPOT_S(mValue) _aB_s___0___ElecPot_s___0___Ab__up_##mValue
#include <libint2/util/intrinsic_types.h>
#include <libint2/util/generated/libint2_params.h>
#include <libint2/util/generated/libint2_types.h>
#if defined(__cplusplus)
#include <libint2/numeric.h>
#endif
#endif /* header guard */
#include <libint2/util/generated/libint2_iface.h>
| /*
* Copyright (C) 2004-2020 <NAME>
*
* This file is part of Libint.
*
* Libint 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 3 of the License, or
* (at your option) any later version.
*
* Libint 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 Libint. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _libint2_header_
#define _libint2_header_
#define FUNC_0(VAR_0) _aB_s___0__s___1___TwoPRep_s___0__s___1___Ab__up_##mValue
#define FUNC_1(VAR_0) _aB_s___0__s___1___r12_minus_1_g12_s___0__s___1___Ab__up_##mValue
#define LIBINT_T_SS_K0G12_SS_0 _aB_s___0__s___1___r12_0_g12_s___0__s___1___Ab__up_0
#define VAR_1 _aB_s___0__s___1___r12_2_g12_s___0__s___1___Ab__up_0
#define VAR_2 _aB_s___0__s___1___r12_4_g12_s___0__s___1___Ab__up_0
#define VAR_3 _aB_s___0___Overlap_s___0___Ab__up_
#define VAR_4 _aB_s___0___Kinetic_s___0___Ab__up_
#define LIBINT_T_S_ELECPOT_S(VAR_0) _aB_s___0___ElecPot_s___0___Ab__up_##mValue
#include <libint2/util/intrinsic_types.h>
#include <libint2/util/generated/libint2_params.h>
#include <IMPORT_0>
#if defined(VAR_5)
#include <libint2/numeric.h>
#endif
#endif /* header guard */
#include <IMPORT_1>
| 0.680258 | {'FUNC_0': 'LIBINT_T_SS_EREP_SS', 'VAR_0': 'mValue', 'FUNC_1': 'LIBINT_T_SS_Km1G12_SS', 'VAR_1': 'LIBINT_T_SS_K2G12_SS_0', 'VAR_2': 'LIBINT_T_SS_K4G12_SS_0', 'VAR_3': 'LIBINT_T_S_OVERLAP_S', 'VAR_4': 'LIBINT_T_S_KINETIC_S', 'IMPORT_0': 'libint2/util/generated/libint2_types.h', 'VAR_5': '__cplusplus', 'IMPORT_1': 'libint2/util/generated/libint2_iface.h'} | c | Procedural | 100.00% |
//
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by <NAME>.
//
#import "APTableViewCell.h"
@class AUInputBox;
@interface APInputBoxCell : APTableViewCell
{
AUInputBox *_textField;
}
+ (float)cellHeight;
@property(retain, nonatomic) AUInputBox *textField; // @synthesize textField=_textField;
- (void).cxx_destruct;
- (id)textFieldInCell;
- (void)setSelected:(_Bool)arg1 animated:(_Bool)arg2;
- (id)initWithStyle:(long long)arg1 reuseIdentifier:(id)arg2;
@end
| //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by <NAME>.
//
#import "APTableViewCell.h"
@class VAR_0;
@interface VAR_1 : VAR_2
{
CLASS_0 *VAR_3;
}
+ (float)VAR_4;
@FUNC_0(retain, VAR_5) CLASS_0 *textField; // @synthesize textField=_textField;
- (void).cxx_destruct;
- (ID_0)VAR_7;
- (void)setSelected:(_Bool)arg1 animated:(_Bool)VAR_8;
- (ID_0)initWithStyle:(long long)arg1 VAR_9:(VAR_6)VAR_8;
@end
| 0.603561 | {'VAR_0': 'AUInputBox', 'CLASS_0': 'AUInputBox', 'VAR_1': 'APInputBoxCell', 'VAR_2': 'APTableViewCell', 'VAR_3': '_textField', 'VAR_4': 'cellHeight', 'FUNC_0': 'property', 'VAR_5': 'nonatomic', 'ID_0': 'id', 'VAR_6': 'id', 'VAR_7': 'textFieldInCell', 'VAR_8': 'arg2', 'VAR_9': 'reuseIdentifier'} | c | Hibrido | 35.37% |
#ifndef FITBASE_H_
#define FITBASE_H_
static inline void check_interrupt_impl(void* /*dummy*/) {
R_CheckUserInterrupt();
}
inline bool check_interrupt() {
return (R_ToplevelExec(check_interrupt_impl, NULL) == FALSE);
}
class EcmAlgorithm {
public:
int n_iter, n_threads;
EcmAlgorithm() :
n_iter(10),
n_threads(1) {};
EcmAlgorithm(const Rcpp::List & iter_list) {
n_iter = Rcpp::as<int>(iter_list["n_iter"]);
n_threads = Rcpp::as<int>(iter_list["n_threads"]);
};
virtual ~EcmAlgorithm() {};
Rcpp::List run() {
bool input_ok = checkInput();
bool interrupt = false;
if (!input_ok)
Rcpp::stop("invalid input");
try {
for(int i = 0; (i < n_iter) & (!interrupt); i++) {
iterate(i);
collectIteration(i);
if (check_interrupt())
interrupt = true;
}
return gatherOutput();
} catch (...) {
return gatherOutput();
//::Rf_error("c++ exception (unknown reason)");
}
Rcpp::List out = Rcpp::List::create(Rcpp::Named("") = R_NilValue);
return out;
}
private:
virtual bool checkInput() =0;
virtual void iterate(const int & iter_idx) =0;
virtual void collectIteration(const int & iter_idx) =0;
virtual const Rcpp::List gatherOutput() =0;
};
class MHTuner {
int num_accept;
int num_trials;
int total_trials;
int n_burn;
int adjustment_interval;
double target_prop;
double scale;
void update_scale() {
const double emp_prop = ((double) num_accept) / num_trials;
if (emp_prop < target_prop - .05) {
scale *= 1.0 - .4 * (target_prop - emp_prop) / target_prop;
} else if (emp_prop > target_prop + .05) {
scale *= 1.0 + .4 * (emp_prop - target_prop) / (1.0 - target_prop);
}
num_accept = 0;
num_trials = 0;
}
public:
MHTuner() : num_accept(0), num_trials(0), total_trials(0), n_burn(0),
adjustment_interval(100), target_prop(.40),
scale(log(2)) {};
MHTuner(int burn) : num_accept(0), num_trials(0), total_trials(0), n_burn(burn),
adjustment_interval(100), target_prop(.40),
scale(log(2)) {};
void update(bool accepted) {
num_accept += accepted;
num_trials++;
total_trials++;
if (num_trials == adjustment_interval && num_trials < n_burn)
update_scale();
};
double getScale() const {
return scale;
}
};
class MarkovChain {
public:
int n_samples, n_burn, n_thin, n_threads, seed;
MarkovChain(const Rcpp::List & chain_list) :
n_samples(Rcpp::as<int>(chain_list["n_samples"])),
n_burn(Rcpp::as<int>(chain_list["n_burn"])),
n_thin(Rcpp::as<int>(chain_list["n_thin"])),
n_threads(Rcpp::as<int>(chain_list["n_threads"])),
seed(Rcpp::as<int>(chain_list["seed"])) {};
virtual ~MarkovChain() {};
Rcpp::List run() {
// burn in the chain
bool interrupt = false;
for(int i = 0; (i < n_burn) & (!interrupt); i++) {
// chains should NOT implement both of these
// or else...
iterate();
if (check_interrupt())
interrupt = true;
}
// collect samples
int sample_idx = 0;
const int total_iter = n_samples * n_thin + n_burn;
for(int i = n_burn + 1; (i <= total_iter) & (!interrupt); i++) {
iterate();
if ((i - n_burn) % n_thin == 0) {
if (check_interrupt())
interrupt = true;
collectIteration(sample_idx);
sample_idx++;
}
}
if (interrupt)
return Rcpp::List::create(Rcpp::Named("NULL") = R_NilValue);
return chainOutput();
}
private:
virtual void iterate() {};
virtual void collectIteration(const int & sample_idx) =0;
virtual const Rcpp::List chainOutput() =0;
};
#endif
|
#ifndef VAR_0
#define VAR_0
static inline void check_interrupt_impl(void* /*dummy*/) {
FUNC_0();
}
inline bool check_interrupt() {
return (R_ToplevelExec(check_interrupt_impl, NULL) == FALSE);
}
class EcmAlgorithm {
public:
VAR_1 VAR_2, n_threads;
EcmAlgorithm() :
FUNC_1(10),
n_threads(1) {};
EcmAlgorithm(const Rcpp::List & iter_list) {
VAR_2 = Rcpp::VAR_3<VAR_1>(iter_list["n_iter"]);
n_threads = Rcpp::VAR_3<VAR_1>(iter_list["n_threads"]);
};
virtual ~EcmAlgorithm() {};
Rcpp::List run() {
bool input_ok = checkInput();
bool VAR_4 = false;
if (!input_ok)
Rcpp::stop("invalid input");
try {
for(int i = 0; (i < VAR_2) & (!VAR_4); i++) {
iterate(i);
collectIteration(i);
if (check_interrupt())
VAR_4 = true;
}
return FUNC_2();
} VAR_5 (...) {
return FUNC_2();
//::Rf_error("c++ exception (unknown reason)");
}
Rcpp::List VAR_6 = Rcpp::List::create(Rcpp::Named("") = VAR_7);
return VAR_6;
}
private:
virtual bool checkInput() =0;
virtual void iterate(const int & VAR_8) =0;
virtual void collectIteration(const int & VAR_8) =0;
virtual const Rcpp::List FUNC_2() =0;
};
class VAR_9 {
int VAR_10;
int num_trials;
int total_trials;
int VAR_11;
int VAR_12;
double target_prop;
double VAR_13;
void update_scale() {
const double emp_prop = ((double) VAR_10) / num_trials;
if (emp_prop < target_prop - .05) {
VAR_13 *= 1.0 - .4 * (target_prop - emp_prop) / target_prop;
} else if (emp_prop > target_prop + .05) {
VAR_13 *= 1.0 + .4 * (emp_prop - target_prop) / (1.0 - target_prop);
}
VAR_10 = 0;
num_trials = 0;
}
public:
FUNC_3() : FUNC_4(0), num_trials(0), total_trials(0), FUNC_5(0),
FUNC_6(100), target_prop(.40),
FUNC_7(log(2)) {};
VAR_9(int burn) : FUNC_4(0), num_trials(0), total_trials(0), FUNC_5(burn),
FUNC_6(100), target_prop(.40),
FUNC_7(log(2)) {};
void update(bool accepted) {
CLASS_0 += accepted;
num_trials++;
total_trials++;
if (num_trials == VAR_12 && num_trials < VAR_11)
update_scale();
};
double FUNC_8() const {
return VAR_13;
}
};
class MarkovChain {
public:
VAR_1 n_samples, VAR_11, VAR_14, n_threads, seed;
MarkovChain(const Rcpp::List & chain_list) :
n_samples(Rcpp::VAR_3<VAR_1>(chain_list["n_samples"])),
FUNC_5(Rcpp::VAR_3<VAR_1>(chain_list["n_burn"])),
FUNC_9(Rcpp::VAR_3<VAR_1>(chain_list["n_thin"])),
n_threads(Rcpp::VAR_3<VAR_1>(chain_list["n_threads"])),
seed(Rcpp::VAR_3<VAR_1>(chain_list["seed"])) {};
virtual ~MarkovChain() {};
Rcpp::List run() {
// burn in the chain
bool VAR_4 = false;
for(int i = 0; (i < VAR_11) & (!VAR_4); i++) {
// chains should NOT implement both of these
// or else...
iterate();
if (check_interrupt())
VAR_4 = true;
}
// collect samples
int sample_idx = 0;
const int total_iter = n_samples * VAR_14 + VAR_11;
for(int i = VAR_11 + 1; (i <= total_iter) & (!VAR_4); i++) {
iterate();
if ((i - VAR_11) % VAR_14 == 0) {
if (check_interrupt())
VAR_4 = true;
collectIteration(sample_idx);
sample_idx++;
}
}
if (VAR_4)
return Rcpp::List::create(Rcpp::Named("NULL") = VAR_7);
return FUNC_10();
}
private:
virtual void iterate() {};
virtual void collectIteration(const int & sample_idx) =0;
virtual const Rcpp::List FUNC_10() =0;
};
#endif
| 0.471824 | {'VAR_0': 'FITBASE_H_', 'FUNC_0': 'R_CheckUserInterrupt', 'VAR_1': 'int', 'VAR_2': 'n_iter', 'FUNC_1': 'n_iter', 'VAR_3': 'as', 'VAR_4': 'interrupt', 'FUNC_2': 'gatherOutput', 'VAR_5': 'catch', 'VAR_6': 'out', 'VAR_7': 'R_NilValue', 'VAR_8': 'iter_idx', 'VAR_9': 'MHTuner', 'FUNC_3': 'MHTuner', 'VAR_10': 'num_accept', 'FUNC_4': 'num_accept', 'CLASS_0': 'num_accept', 'VAR_11': 'n_burn', 'FUNC_5': 'n_burn', 'VAR_12': 'adjustment_interval', 'FUNC_6': 'adjustment_interval', 'VAR_13': 'scale', 'FUNC_7': 'scale', 'FUNC_8': 'getScale', 'VAR_14': 'n_thin', 'FUNC_9': 'n_thin', 'FUNC_10': 'chainOutput'} | c | Hibrido | 100.00% |
/* map the network device into our memory space */
int open_dev(off_t base_addr, volatile void **mem)
{
int fd;
fd = open("/dev/mem", O_RDWR);
if (fd < 0) {
perror("open");
return -1;
}
*mem = mmap(NULL, MEM_WINDOW_SZ, (PROT_READ|PROT_WRITE), MAP_SHARED, fd,
base_addr);
if (*mem == MAP_FAILED) {
perror("mmap/readable - try rebooting with iomem=relaxed");
close(fd);
return -1;
}
return fd;
} | /* map the network device into our memory space */
int open_dev(CLASS_0 base_addr, volatile void **mem)
{
int VAR_0;
VAR_0 = FUNC_0("/dev/mem", VAR_1);
if (VAR_0 < 0) {
perror("open");
return -1;
}
*mem = mmap(NULL, VAR_2, (VAR_3|PROT_WRITE), MAP_SHARED, VAR_0,
base_addr);
if (*mem == VAR_4) {
perror("mmap/readable - try rebooting with iomem=relaxed");
FUNC_1(VAR_0);
return -1;
}
return VAR_0;
} | 0.619144 | {'CLASS_0': 'off_t', 'VAR_0': 'fd', 'FUNC_0': 'open', 'VAR_1': 'O_RDWR', 'VAR_2': 'MEM_WINDOW_SZ', 'VAR_3': 'PROT_READ', 'VAR_4': 'MAP_FAILED', 'FUNC_1': 'close'} | c | Procedural | 100.00% |
/*
* Print the header for a given host.
*/
static void
print_host_header(Host *host)
{
assert(host != NULL);
printf("[%s%s%s]", colors.cyan, host->name, colors.reset);
} | /*
* Print the header for a given host.
*/
static void
FUNC_0(CLASS_0 *host)
{
FUNC_1(host != NULL);
FUNC_2("[%s%s%s]", VAR_0.VAR_1, host->VAR_2, VAR_0.VAR_3);
} | 0.943357 | {'FUNC_0': 'print_host_header', 'CLASS_0': 'Host', 'FUNC_1': 'assert', 'FUNC_2': 'printf', 'VAR_0': 'colors', 'VAR_1': 'cyan', 'VAR_2': 'name', 'VAR_3': 'reset'} | c | Procedural | 100.00% |
//! Get next byte from the file using temporary buffer
viSerror tigFileInitBuffer(bufManager_p buf_p) {
buf_p->max = 0;
buf_p->bc = buf_p->max;
buf_p->avail_bits = 0;
return VIS_OK;
} | //! Get next byte from the file using temporary buffer
viSerror FUNC_0(bufManager_p buf_p) {
buf_p->max = 0;
buf_p->bc = buf_p->max;
buf_p->VAR_0 = 0;
return VIS_OK;
} | 0.345274 | {'FUNC_0': 'tigFileInitBuffer', 'VAR_0': 'avail_bits'} | c | Procedural | 100.00% |
#import "MOBProjection.h"
@interface MOBProjectionEPSG32528 : MOBProjection
@end
| #import "MOBProjection.h"
@interface MOBProjectionEPSG32528 : VAR_0
@end
| 0.368296 | {'VAR_0': 'MOBProjection'} | c | Texto | 100.00% |
/*
Copyright (c) 2019 misson20000
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
*/
#include<stdio.h>
#include<errno.h>
#include<sys/iosupport.h>
#include "twili.h"
static Service g_twiliSrv;
static u64 g_twiliRefCnt;
static Result twiliOpenPipe(Service *srv_out, int id) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
ipcSendPid(&c);
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = id;
Result rc = serviceIpcDispatch(&g_twiliSrv);
if(R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
if(R_SUCCEEDED(rc)) {
serviceCreate(srv_out, r.Handles[0]);
}
}
return rc;
}
static Service g_twiliPipeStdin;
static Service g_twiliPipeStdout;
static Service g_twiliPipeStderr;
static ssize_t twiliWrite(Service *pipe, struct _reent *r, void *fd, const char *ptr, size_t len) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
ipcAddSendBuffer(&c, ptr, len, 0);
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 1;
Result rc = serviceIpcDispatch(pipe);
if(R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
}
if(R_SUCCEEDED(rc)) {
return len;
} else {
if(r == NULL) {
errno = EIO;
} else {
r->_errno = EIO;
}
return -1;
}
}
Result twiliWriteNamedPipe(Service *pipe, const char *ptr, size_t len) {
twiliWrite(pipe, NULL, NULL, ptr, len);
}
static ssize_t twiliRead(Service *pipe, struct _reent *r, void *fd, char *ptr, size_t len) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
ipcAddRecvBuffer(&c, ptr, len, 0);
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 0;
Result rc = serviceIpcDispatch(pipe);
if(R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u64 size;
} *resp = r.Raw;
rc = resp->result;
if(R_SUCCEEDED(rc)) {
return resp->size;
}
}
if(r == NULL) {
errno = EIO;
} else {
r->_errno = EIO;
}
return -1;
}
static ssize_t twiliReadStdin(struct _reent *r, void *fd, char *ptr, size_t len) {
return twiliRead(&g_twiliPipeStdin, r, fd, ptr, len);
}
static ssize_t twiliWriteStdout(struct _reent *r, void *fd, const char *ptr, size_t len) {
return twiliWrite(&g_twiliPipeStdout, r, fd, ptr, len);
}
static ssize_t twiliWriteStderr(struct _reent *r, void *fd, const char *ptr, size_t len) {
return twiliWrite(&g_twiliPipeStderr, r, fd, ptr, len);
}
static const inline devoptab_t twiliMakeDotab(const char *name, ssize_t (*write_r)(struct _reent *r, void *fd, const char *ptr, size_t len), ssize_t (*read_r)(struct _reent *r, void *fd, char *ptr, size_t len)) {
devoptab_t ret = {
.name = name,
.structSize = 0,
.open_r = NULL,
.close_r = NULL,
.write_r = write_r,
.read_r = read_r,
.seek_r = NULL,
.fstat_r = NULL,
.deviceData = NULL
};
return ret;
}
Result twiliCreateNamedOutputPipe(Service *srv_out, const char* name, size_t len) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
ipcAddSendBuffer(&c, name, len, 0);
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 10;
Result rc = serviceIpcDispatch(&g_twiliSrv);
if(R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
} *resp = r.Raw;
rc = resp->result;
if(R_SUCCEEDED(rc)) {
serviceCreate(srv_out, r.Handles[0]);
}
}
return rc;
}
Result twiliInitialize(void) {
Result r = 0;
atomicIncrement64(&g_twiliRefCnt);
if(!serviceIsActive(&g_twiliSrv)) {
r = smGetService(&g_twiliSrv, "twili");
if(R_SUCCEEDED(r)) {
r = twiliOpenPipe(&g_twiliPipeStdin, 0);
}
if(R_SUCCEEDED(r)) {
r = twiliOpenPipe(&g_twiliPipeStdout, 1);
}
if(R_SUCCEEDED(r)) {
r = twiliOpenPipe(&g_twiliPipeStderr, 2);
}
if(R_SUCCEEDED(r)) {
static devoptab_t dotab_twili_stdin;
static devoptab_t dotab_twili_stdout;
static devoptab_t dotab_twili_stderr;
dotab_twili_stdin = twiliMakeDotab("twili-in",
NULL, twiliReadStdin);
dotab_twili_stdout = twiliMakeDotab("twili-out",
twiliWriteStdout, NULL);
dotab_twili_stderr = twiliMakeDotab("twili-err",
twiliWriteStderr, NULL);
devoptab_list[STD_IN] = &dotab_twili_stdin;
devoptab_list[STD_OUT] = &dotab_twili_stdout;
devoptab_list[STD_ERR] = &dotab_twili_stderr;
}
}
if(R_FAILED(r)) {
twiliExit();
}
return r;
}
void twiliExit(void) {
serviceClose(&g_twiliPipeStderr);
serviceClose(&g_twiliPipeStdout);
serviceClose(&g_twiliPipeStdin);
serviceClose(&g_twiliSrv);
}
| /*
Copyright (c) 2019 misson20000
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
*/
#include<IMPORT_0>
#include<IMPORT_1>
#include<IMPORT_2>
#include "IMPORT_3"
static CLASS_0 VAR_0;
static CLASS_1 VAR_1;
static CLASS_2 FUNC_0(CLASS_0 *VAR_2, int VAR_3) {
CLASS_3 VAR_4;
FUNC_1(&VAR_4);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_6;
} *VAR_7;
FUNC_2(&VAR_4);
VAR_7 = FUNC_3(&VAR_4, sizeof(*VAR_7));
VAR_7->VAR_5 = VAR_8;
VAR_7->VAR_6 = VAR_3;
CLASS_2 VAR_9 = FUNC_4(&VAR_0);
if(FUNC_5(VAR_9)) {
CLASS_4 VAR_10;
FUNC_6(&VAR_10);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_11;
} *VAR_12 = VAR_10.VAR_13;
VAR_9 = VAR_12->VAR_11;
if(FUNC_5(VAR_9)) {
FUNC_7(VAR_2, VAR_10.VAR_14[0]);
}
}
return VAR_9;
}
static CLASS_0 VAR_15;
static CLASS_0 VAR_16;
static CLASS_0 g_twiliPipeStderr;
static ssize_t FUNC_8(CLASS_0 *VAR_17, struct CLASS_5 *VAR_10, void *VAR_18, const char *VAR_19, size_t VAR_20) {
CLASS_3 VAR_4;
FUNC_1(&VAR_4);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_6;
} *VAR_7;
FUNC_9(&VAR_4, VAR_19, VAR_20, 0);
VAR_7 = FUNC_3(&VAR_4, sizeof(*VAR_7));
VAR_7->VAR_5 = VAR_8;
VAR_7->VAR_6 = 1;
CLASS_2 VAR_9 = FUNC_4(VAR_17);
if(FUNC_5(VAR_9)) {
CLASS_4 VAR_10;
FUNC_6(&VAR_10);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_11;
} *VAR_12 = VAR_10.VAR_13;
VAR_9 = VAR_12->VAR_11;
}
if(FUNC_5(VAR_9)) {
return VAR_20;
} else {
if(VAR_10 == NULL) {
VAR_21 = VAR_22;
} else {
VAR_10->_errno = VAR_22;
}
return -1;
}
}
CLASS_2 FUNC_10(CLASS_0 *VAR_17, const char *VAR_19, size_t VAR_20) {
FUNC_8(VAR_17, NULL, NULL, VAR_19, VAR_20);
}
static ssize_t FUNC_11(CLASS_0 *VAR_17, struct CLASS_5 *VAR_10, void *VAR_18, char *VAR_19, size_t VAR_20) {
CLASS_3 VAR_4;
FUNC_1(&VAR_4);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_6;
} *VAR_7;
FUNC_12(&VAR_4, VAR_19, VAR_20, 0);
VAR_7 = FUNC_3(&VAR_4, sizeof(*VAR_7));
VAR_7->VAR_5 = VAR_8;
VAR_7->VAR_6 = 0;
CLASS_2 VAR_9 = FUNC_4(VAR_17);
if(FUNC_5(VAR_9)) {
CLASS_4 VAR_10;
FUNC_6(&VAR_10);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_11;
CLASS_1 size;
} *VAR_12 = VAR_10.VAR_13;
VAR_9 = VAR_12->VAR_11;
if(FUNC_5(VAR_9)) {
return VAR_12->size;
}
}
if(VAR_10 == NULL) {
VAR_21 = VAR_22;
} else {
VAR_10->_errno = VAR_22;
}
return -1;
}
static ssize_t twiliReadStdin(struct CLASS_5 *VAR_10, void *VAR_18, char *VAR_19, size_t VAR_20) {
return FUNC_11(&VAR_15, VAR_10, VAR_18, VAR_19, VAR_20);
}
static ssize_t FUNC_13(struct CLASS_5 *VAR_10, void *VAR_18, const char *VAR_19, size_t VAR_20) {
return FUNC_8(&VAR_16, VAR_10, VAR_18, VAR_19, VAR_20);
}
static ssize_t FUNC_14(struct CLASS_5 *VAR_10, void *VAR_18, const char *VAR_19, size_t VAR_20) {
return FUNC_8(&g_twiliPipeStderr, VAR_10, VAR_18, VAR_19, VAR_20);
}
static const inline devoptab_t FUNC_15(const char *VAR_25, ssize_t (*VAR_26)(struct CLASS_5 *VAR_10, void *VAR_18, const char *VAR_19, size_t VAR_20), ssize_t (*VAR_27)(struct CLASS_5 *VAR_10, void *VAR_18, char *VAR_19, size_t VAR_20)) {
devoptab_t VAR_28 = {
.VAR_25 = VAR_25,
.VAR_29 = 0,
.VAR_30 = NULL,
.VAR_31 = NULL,
.VAR_26 = VAR_26,
.VAR_27 = VAR_27,
.VAR_32 = NULL,
.VAR_33 = NULL,
.VAR_34 = NULL
};
return VAR_28;
}
CLASS_2 FUNC_16(CLASS_0 *VAR_2, const char* VAR_25, size_t VAR_20) {
CLASS_3 VAR_4;
FUNC_1(&VAR_4);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_6;
} *VAR_7;
FUNC_9(&VAR_4, VAR_25, VAR_20, 0);
VAR_7 = FUNC_3(&VAR_4, sizeof(*VAR_7));
VAR_7->VAR_5 = VAR_8;
VAR_7->VAR_6 = 10;
CLASS_2 VAR_9 = FUNC_4(&VAR_0);
if(FUNC_5(VAR_9)) {
CLASS_4 VAR_10;
FUNC_6(&VAR_10);
struct {
CLASS_1 VAR_5;
CLASS_1 VAR_11;
} *VAR_12 = VAR_10.VAR_13;
VAR_9 = VAR_12->VAR_11;
if(FUNC_5(VAR_9)) {
FUNC_7(VAR_2, VAR_10.VAR_14[0]);
}
}
return VAR_9;
}
CLASS_2 twiliInitialize(void) {
CLASS_2 VAR_10 = 0;
FUNC_17(&VAR_1);
if(!FUNC_18(&VAR_0)) {
VAR_10 = FUNC_19(&VAR_0, "twili");
if(FUNC_5(VAR_10)) {
VAR_10 = FUNC_0(&VAR_15, 0);
}
if(FUNC_5(VAR_10)) {
VAR_10 = FUNC_0(&VAR_16, 1);
}
if(FUNC_5(VAR_10)) {
VAR_10 = FUNC_0(&g_twiliPipeStderr, 2);
}
if(FUNC_5(VAR_10)) {
static devoptab_t VAR_35;
static devoptab_t VAR_36;
static devoptab_t VAR_37;
VAR_35 = FUNC_15("twili-in",
NULL, twiliReadStdin);
VAR_36 = FUNC_15("twili-out",
VAR_23, NULL);
VAR_37 = FUNC_15("twili-err",
VAR_24, NULL);
devoptab_list[VAR_38] = &VAR_35;
devoptab_list[VAR_39] = &VAR_36;
devoptab_list[VAR_40] = &VAR_37;
}
}
if(FUNC_20(VAR_10)) {
twiliExit();
}
return VAR_10;
}
void twiliExit(void) {
FUNC_21(&g_twiliPipeStderr);
FUNC_21(&VAR_16);
FUNC_21(&VAR_15);
FUNC_21(&VAR_0);
}
| 0.822342 | {'IMPORT_0': 'stdio.h', 'IMPORT_1': 'errno.h', 'IMPORT_2': 'sys/iosupport.h', 'IMPORT_3': 'twili.h', 'CLASS_0': 'Service', 'VAR_0': 'g_twiliSrv', 'CLASS_1': 'u64', 'VAR_1': 'g_twiliRefCnt', 'CLASS_2': 'Result', 'FUNC_0': 'twiliOpenPipe', 'VAR_2': 'srv_out', 'VAR_3': 'id', 'CLASS_3': 'IpcCommand', 'VAR_4': 'c', 'FUNC_1': 'ipcInitialize', 'VAR_5': 'magic', 'VAR_6': 'cmd_id', 'VAR_7': 'raw', 'FUNC_2': 'ipcSendPid', 'FUNC_3': 'ipcPrepareHeader', 'VAR_8': 'SFCI_MAGIC', 'VAR_9': 'rc', 'FUNC_4': 'serviceIpcDispatch', 'FUNC_5': 'R_SUCCEEDED', 'CLASS_4': 'IpcParsedCommand', 'VAR_10': 'r', 'FUNC_6': 'ipcParse', 'VAR_11': 'result', 'VAR_12': 'resp', 'VAR_13': 'Raw', 'FUNC_7': 'serviceCreate', 'VAR_14': 'Handles', 'VAR_15': 'g_twiliPipeStdin', 'VAR_16': 'g_twiliPipeStdout', 'FUNC_8': 'twiliWrite', 'VAR_17': 'pipe', 'CLASS_5': '_reent', 'VAR_18': 'fd', 'VAR_19': 'ptr', 'VAR_20': 'len', 'FUNC_9': 'ipcAddSendBuffer', 'VAR_21': 'errno', 'VAR_22': 'EIO', 'FUNC_10': 'twiliWriteNamedPipe', 'FUNC_11': 'twiliRead', 'FUNC_12': 'ipcAddRecvBuffer', 'FUNC_13': 'twiliWriteStdout', 'VAR_23': 'twiliWriteStdout', 'FUNC_14': 'twiliWriteStderr', 'VAR_24': 'twiliWriteStderr', 'FUNC_15': 'twiliMakeDotab', 'VAR_25': 'name', 'VAR_26': 'write_r', 'VAR_27': 'read_r', 'VAR_28': 'ret', 'VAR_29': 'structSize', 'VAR_30': 'open_r', 'VAR_31': 'close_r', 'VAR_32': 'seek_r', 'VAR_33': 'fstat_r', 'VAR_34': 'deviceData', 'FUNC_16': 'twiliCreateNamedOutputPipe', 'FUNC_17': 'atomicIncrement64', 'FUNC_18': 'serviceIsActive', 'FUNC_19': 'smGetService', 'VAR_35': 'dotab_twili_stdin', 'VAR_36': 'dotab_twili_stdout', 'VAR_37': 'dotab_twili_stderr', 'VAR_38': 'STD_IN', 'VAR_39': 'STD_OUT', 'VAR_40': 'STD_ERR', 'FUNC_20': 'R_FAILED', 'FUNC_21': 'serviceClose'} | c | Procedural | 27.55% |
// MIT License
// Copyright (c) 2020 Tracy
// 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.
#pragma once
#include "NonCopyable.h"
#include "Types.h"
namespace wind {
namespace base {
inline constexpr bool isInvalidFd(int fd)
{
return fd < 0;
}
constexpr int INVALID_FD = -1;
struct DefaultFdCloser {
void operator()(int fd)
{
TEMP_FAILURE_RETRY(::close(fd));
}
};
template <typename Closer>
class UniqueFdImpl : NonCopyable {
public:
UniqueFdImpl() = default;
explicit UniqueFdImpl(int fd) noexcept : fd_(fd) {}
~UniqueFdImpl() noexcept
{
reset();
}
// movable
UniqueFdImpl(UniqueFdImpl &&other) noexcept : fd_(other.release()) {}
UniqueFdImpl &operator=(UniqueFdImpl &&other) noexcept
{
reset(other.release()); // can avoid self-move.
return *this;
}
bool valid() const
{
return !isInvalidFd(fd_);
}
void reset(int fd = INVALID_FD) noexcept
{
close();
fd_ = fd;
}
int release()
{
int fd = fd_;
fd_ = INVALID_FD;
return fd;
}
[[nodiscard]] int get() const noexcept
{
return fd_;
}
explicit operator int() const
{
return fd_;
}
private:
void close()
{
static Closer closer;
if (!isInvalidFd(fd_)) {
closer(fd_);
fd_ = INVALID_FD;
}
}
int fd_ = INVALID_FD;
};
using UniqueFd = UniqueFdImpl<DefaultFdCloser>;
} // namespace base
} // namespace wind
| // MIT License
// Copyright (c) 2020 Tracy
// 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.
#pragma once
#include "IMPORT_0"
#include "IMPORT_1"
namespace VAR_0 {
namespace base {
inline constexpr bool FUNC_0(int fd)
{
return fd < 0;
}
constexpr int VAR_1 = -1;
struct CLASS_0 {
void VAR_3()(int fd)
{
TEMP_FAILURE_RETRY(::CLASS_1(fd));
}
};
template <typename VAR_4>
class UniqueFdImpl : NonCopyable {
public:
UniqueFdImpl() = VAR_5;
explicit UniqueFdImpl(int fd) noexcept : fd_(fd) {}
~UniqueFdImpl() VAR_6
{
FUNC_2();
}
// movable
UniqueFdImpl(UniqueFdImpl &&other) noexcept : fd_(other.release()) {}
UniqueFdImpl &VAR_3=(UniqueFdImpl &&other) VAR_6
{
FUNC_2(other.release()); // can avoid self-move.
return *this;
}
bool FUNC_3() const
{
return !FUNC_0(fd_);
}
void FUNC_2(int fd = VAR_1) VAR_6
{
FUNC_1();
fd_ = fd;
}
int release()
{
int fd = fd_;
fd_ = VAR_1;
return fd;
}
[[nodiscard]] int FUNC_4() const CLASS_3
{
return fd_;
}
explicit VAR_3 FUNC_5() const
{
return fd_;
}
private:
VAR_7 FUNC_1()
{
static CLASS_2 VAR_8;
if (!FUNC_0(fd_)) {
FUNC_6(fd_);
fd_ = VAR_1;
}
}
int fd_ = VAR_1;
};
using VAR_9 = UniqueFdImpl<VAR_2>;
} // namespace base
} // namespace wind
| 0.639964 | {'IMPORT_0': 'NonCopyable.h', 'IMPORT_1': 'Types.h', 'VAR_0': 'wind', 'FUNC_0': 'isInvalidFd', 'VAR_1': 'INVALID_FD', 'CLASS_0': 'DefaultFdCloser', 'VAR_2': 'DefaultFdCloser', 'VAR_3': 'operator', 'CLASS_1': 'close', 'FUNC_1': 'close', 'VAR_4': 'Closer', 'CLASS_2': 'Closer', 'VAR_5': 'default', 'VAR_6': 'noexcept', 'CLASS_3': 'noexcept', 'FUNC_2': 'reset', 'FUNC_3': 'valid', 'FUNC_4': 'get', 'FUNC_5': 'int', 'VAR_7': 'void', 'VAR_8': 'closer', 'FUNC_6': 'closer', 'VAR_9': 'UniqueFd'} | c | Procedural | 45.48% |
//
// ViewController.h
// GMImageDownLoad
//
// Created by xbm on 2017/2/3.
// Copyright © 2017年 xbm. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
| //
// ViewController.h
// GMImageDownLoad
//
// Created by xbm on 2017/2/3.
// Copyright © 2017年 xbm. All rights reserved.
//
#import <UIKit/UIKit.h>
@CLASS_0 VAR_0 : VAR_1
@VAR_2
| 0.925045 | {'CLASS_0': 'interface', 'VAR_0': 'ViewController', 'VAR_1': 'UIViewController', 'VAR_2': 'end'} | c | Texto | 100.00% |
#pragma once
#include <string.h>
#include <stdlib.h>
#include <initializer_list>
// Copies the given string into a fresh malloc-ed buffer
inline const char* string_copy_with_malloc(const char* src)
{
size_t size = strlen(src) + 1;
char* buff = (char*)malloc(size);
memcpy(buff, src, size);
return buff;
}
// Increments the pointer until the first occurence of a character which isn't whitespace
inline char* trim_front(char* str, char ch = ' ')
{
while (*str == ch)
{
str++;
}
return str;
}
inline const char* max(std::initializer_list<const char*> args)
{
const char* result = 0;
for (auto ptr : args)
{
if (result < ptr)
{
result = ptr;
}
}
return result;
} | #pragma once
#include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
// Copies the given string into a fresh malloc-ed buffer
inline const char* FUNC_0(const char* VAR_0)
{
size_t VAR_1 = FUNC_1(VAR_0) + 1;
char* VAR_2 = (char*)FUNC_2(VAR_1);
FUNC_3(VAR_2, VAR_0, VAR_1);
return VAR_2;
}
// Increments the pointer until the first occurence of a character which isn't whitespace
inline char* FUNC_4(char* VAR_3, char VAR_4 = ' ')
{
FUNC_5 (*VAR_3 == VAR_4)
{
VAR_3++;
}
VAR_5 VAR_3;
}
inline const char* max(CLASS_0::IMPORT_2<const char*> VAR_6)
{
const char* VAR_7 = 0;
for (auto CLASS_2 : FUNC_6)
{
if (CLASS_1 < VAR_8)
{
VAR_7 = VAR_8;
}
}
return VAR_7;
} | 0.867327 | {'IMPORT_0': 'string.h', 'IMPORT_1': 'stdlib.h', 'IMPORT_2': 'initializer_list', 'FUNC_0': 'string_copy_with_malloc', 'VAR_0': 'src', 'VAR_1': 'size', 'FUNC_1': 'strlen', 'VAR_2': 'buff', 'FUNC_2': 'malloc', 'FUNC_3': 'memcpy', 'FUNC_4': 'trim_front', 'VAR_3': 'str', 'VAR_4': 'ch', 'FUNC_5': 'while', 'VAR_5': 'return', 'CLASS_0': 'std', 'VAR_6': 'args', 'FUNC_6': 'args', 'VAR_7': 'result', 'CLASS_1': 'result', 'CLASS_2': 'ptr', 'VAR_8': 'ptr'} | c | Procedural | 100.00% |
/*
* set the sizes and field offsets for t
* look only as deeply as needed to size this type.
* cycsize type will clean up the rest.
*/
void
sizetype(Type *t)
{
Decl *id, *tg;
Szal szal;
long sz, al, a;
if(t == nil)
return;
if((t->ok & OKsized) == OKsized)
return;
t->ok |= OKsized;
if((t->ok & (OKverify|OKsized)) != (OKverify|OKsized))
fatal("sizetype bogus ok for %t", t);
switch(t->kind){
default:
fatal("sizetype: unknown type kind %d", t->kind);
break;
case Terror:
case Tnone:
case Tbyte:
case Tint:
case Tbig:
case Tstring:
case Tany:
case Treal:
fatal("%T should have a size", t);
break;
case Tref:
case Tchan:
case Tarray:
case Tlist:
case Tmodule:
case Tfix:
case Tpoly:
t->size = t->align = IBY2WD;
break;
case Ttuple:
case Tadt:
case Texception:
if(t->tags == nil){
if(!debug['z']){
szal = sizeids(t->ids, 0);
t->size = align(szal.size, szal.align);
t->align = szal.align;
}else{
szal = sizeids(t->ids, 0);
t->align = IBY2LG;
t->size = align(szal.size, IBY2LG);
}
return;
}
if(!debug['z']){
szal = sizeids(t->ids, IBY2WD);
sz = szal.size;
al = szal.align;
if(al < IBY2WD)
al = IBY2WD;
}else{
szal = sizeids(t->ids, IBY2WD);
sz = szal.size;
al = IBY2LG;
}
for(tg = t->tags; tg != nil; tg = tg->next){
if((tg->ty->ok & OKsized) == OKsized)
continue;
tg->ty->ok |= OKsized;
if(!debug['z']){
szal = sizeids(tg->ty->ids, sz);
a = szal.align;
if(a < al)
a = al;
tg->ty->size = align(szal.size, a);
tg->ty->align = a;
}else{
szal = sizeids(tg->ty->ids, sz);
tg->ty->size = align(szal.size, IBY2LG);
tg->ty->align = IBY2LG;
}
}
break;
case Tfn:
t->size = 0;
t->align = 1;
break;
case Tainit:
t->size = 0;
t->align = 1;
break;
case Talt:
t->size = t->cse->nlab * 2*IBY2WD + 2*IBY2WD;
t->align = IBY2WD;
break;
case Tcase:
case Tcasec:
t->size = t->cse->nlab * 3*IBY2WD + 2*IBY2WD;
t->align = IBY2WD;
break;
case Tcasel:
t->size = t->cse->nlab * 6*IBY2WD + 3*IBY2WD;
t->align = IBY2LG;
break;
case Tgoto:
t->size = t->cse->nlab * IBY2WD + IBY2WD;
if(t->cse->iwild != nil)
t->size += IBY2WD;
t->align = IBY2WD;
break;
case Tiface:
sz = IBY2WD;
for(id = t->ids; id != nil; id = id->next){
sz = align(sz, IBY2WD) + IBY2WD;
sz += id->sym->len + 1;
if(id->dot->ty->kind == Tadt)
sz += id->dot->sym->len + 1;
}
t->size = sz;
t->align = IBY2WD;
break;
case Texcept:
t->size = 0;
t->align = IBY2WD;
break;
}
} | /*
* set the sizes and field offsets for t
* look only as deeply as needed to size this type.
* cycsize type will clean up the rest.
*/
void
sizetype(Type *t)
{
CLASS_0 *VAR_0, *tg;
CLASS_1 VAR_1;
long sz, al, a;
if(t == VAR_2)
return;
if((t->ok & OKsized) == OKsized)
return;
t->ok |= OKsized;
if((t->ok & (OKverify|OKsized)) != (OKverify|OKsized))
fatal("sizetype bogus ok for %t", t);
switch(t->kind){
default:
fatal("sizetype: unknown type kind %d", t->kind);
break;
case VAR_3:
case VAR_4:
case VAR_5:
case Tint:
case VAR_6:
case Tstring:
case Tany:
case Treal:
fatal("%T should have a size", t);
break;
case Tref:
case Tchan:
case Tarray:
case Tlist:
case Tmodule:
case Tfix:
case Tpoly:
t->size = t->VAR_7 = IBY2WD;
break;
case Ttuple:
case Tadt:
case Texception:
if(t->VAR_8 == VAR_2){
if(!debug['z']){
VAR_1 = FUNC_1(t->VAR_9, 0);
t->size = FUNC_0(VAR_1.size, VAR_1.VAR_7);
t->VAR_7 = VAR_1.VAR_7;
}else{
VAR_1 = FUNC_1(t->VAR_9, 0);
t->VAR_7 = IBY2LG;
t->size = FUNC_0(VAR_1.size, IBY2LG);
}
return;
}
if(!debug['z']){
VAR_1 = FUNC_1(t->VAR_9, IBY2WD);
sz = VAR_1.size;
al = VAR_1.VAR_7;
if(al < IBY2WD)
al = IBY2WD;
}else{
VAR_1 = FUNC_1(t->VAR_9, IBY2WD);
sz = VAR_1.size;
al = IBY2LG;
}
for(tg = t->VAR_8; tg != VAR_2; tg = tg->VAR_10){
if((tg->ty->ok & OKsized) == OKsized)
continue;
tg->ty->ok |= OKsized;
if(!debug['z']){
VAR_1 = FUNC_1(tg->ty->VAR_9, sz);
a = VAR_1.VAR_7;
if(a < al)
a = al;
tg->ty->size = FUNC_0(VAR_1.size, a);
tg->ty->VAR_7 = a;
}else{
VAR_1 = FUNC_1(tg->ty->VAR_9, sz);
tg->ty->size = FUNC_0(VAR_1.size, IBY2LG);
tg->ty->VAR_7 = IBY2LG;
}
}
break;
case Tfn:
t->size = 0;
t->VAR_7 = 1;
break;
case Tainit:
t->size = 0;
t->VAR_7 = 1;
break;
case Talt:
t->size = t->VAR_11->nlab * 2*IBY2WD + 2*IBY2WD;
t->VAR_7 = IBY2WD;
break;
case Tcase:
case Tcasec:
t->size = t->VAR_11->nlab * 3*IBY2WD + 2*IBY2WD;
t->VAR_7 = IBY2WD;
break;
case VAR_12:
t->size = t->VAR_11->nlab * 6*IBY2WD + 3*IBY2WD;
t->VAR_7 = IBY2LG;
break;
case Tgoto:
t->size = t->VAR_11->nlab * IBY2WD + IBY2WD;
if(t->VAR_11->iwild != VAR_2)
t->size += IBY2WD;
t->VAR_7 = IBY2WD;
break;
case Tiface:
sz = IBY2WD;
for(VAR_0 = t->VAR_9; VAR_0 != VAR_2; VAR_0 = VAR_0->VAR_10){
sz = FUNC_0(sz, IBY2WD) + IBY2WD;
sz += VAR_0->sym->VAR_13 + 1;
if(VAR_0->VAR_14->ty->kind == Tadt)
sz += VAR_0->VAR_14->sym->VAR_13 + 1;
}
t->size = sz;
t->VAR_7 = IBY2WD;
break;
case Texcept:
t->size = 0;
t->VAR_7 = IBY2WD;
break;
}
} | 0.361674 | {'CLASS_0': 'Decl', 'VAR_0': 'id', 'CLASS_1': 'Szal', 'VAR_1': 'szal', 'VAR_2': 'nil', 'VAR_3': 'Terror', 'VAR_4': 'Tnone', 'VAR_5': 'Tbyte', 'VAR_6': 'Tbig', 'VAR_7': 'align', 'FUNC_0': 'align', 'VAR_8': 'tags', 'FUNC_1': 'sizeids', 'VAR_9': 'ids', 'VAR_10': 'next', 'VAR_11': 'cse', 'VAR_12': 'Tcasel', 'VAR_13': 'len', 'VAR_14': 'dot'} | c | Procedural | 100.00% |
/***************************** Internal Function ***************************\
* AttemptWrite
*
* Tries to write data to a metafile disk file
*
* dwBytes is the byte count of lpData.
*
* Returns TRUE iff the write was sucessful
*
*
\***************************************************************************/
BOOL AttemptWrite(PMFRECORDER16 pMFRec, DWORD dwBytes, LPBYTE lpData)
{
DWORD cbWritten;
BOOL fRet;
PUTS("AttemptWrite\n");
ASSERTGDI(dwBytes % 2 == 0, "AttemptWrite: bad dwBytes\n");
ASSERTGDI(!(pMFRec->recFlags & METAFILEFAILURE),
"AttemptWrite: Bad recording\n");
if (pMFRec->metaHeader.mtType == DISKMETAFILE)
{
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
fRet = WriteFile(pMFRec->hFile, (LPBYTE)pMFRec->hMem,
pMFRec->ibBuffer, &cbWritten, (LPOVERLAPPED)NULL);
if (!fRet || (cbWritten != pMFRec->ibBuffer))
{
ERROR_ASSERT(FALSE, "AttemptWrite: Write1 failed\n");
goto AttemptWrite_Error;
}
pMFRec->ibBuffer = 0;
}
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
fRet = WriteFile(pMFRec->hFile, lpData,
dwBytes, &cbWritten, (LPOVERLAPPED)NULL);
if (!fRet || (cbWritten != dwBytes))
{
ERROR_ASSERT(FALSE, "AttemptWrite: Write2 failed\n");
goto AttemptWrite_Error;
}
}
else
{
RtlCopyMemory((LPBYTE)pMFRec->hMem + pMFRec->ibBuffer, lpData, dwBytes);
pMFRec->ibBuffer += dwBytes;
}
}
else
{
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
DWORD cbNewSize;
HANDLE hMem;
cbNewSize = pMFRec->cbBuffer + MF16_BUFSIZE_INC
+ dwBytes / MF16_BUFSIZE_INC * MF16_BUFSIZE_INC;
hMem = LocalReAlloc(pMFRec->hMem, cbNewSize, LMEM_MOVEABLE);
if (hMem == NULL)
{
ERROR_ASSERT(FALSE, "AttemptWrite: out of memory\n");
goto AttemptWrite_Error;
}
pMFRec->hMem = hMem;
pMFRec->cbBuffer = cbNewSize;
}
RtlCopyMemory((LPBYTE)pMFRec->hMem + pMFRec->ibBuffer, lpData, dwBytes);
pMFRec->ibBuffer += dwBytes;
}
pMFRec->metaHeader.mtSize += dwBytes/sizeof(WORD);
return(TRUE);
AttemptWrite_Error:
MarkMetaFile(pMFRec);
return(FALSE);
} | /***************************** Internal Function ***************************\
* AttemptWrite
*
* Tries to write data to a metafile disk file
*
* dwBytes is the byte count of lpData.
*
* Returns TRUE iff the write was sucessful
*
*
\***************************************************************************/
BOOL AttemptWrite(PMFRECORDER16 pMFRec, DWORD dwBytes, LPBYTE lpData)
{
DWORD cbWritten;
BOOL fRet;
PUTS("AttemptWrite\n");
ASSERTGDI(dwBytes % 2 == 0, "AttemptWrite: bad dwBytes\n");
ASSERTGDI(!(pMFRec->recFlags & METAFILEFAILURE),
"AttemptWrite: Bad recording\n");
if (pMFRec->metaHeader.mtType == DISKMETAFILE)
{
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
fRet = WriteFile(pMFRec->hFile, (LPBYTE)pMFRec->hMem,
pMFRec->ibBuffer, &cbWritten, (LPOVERLAPPED)NULL);
if (!fRet || (cbWritten != pMFRec->ibBuffer))
{
ERROR_ASSERT(FALSE, "AttemptWrite: Write1 failed\n");
goto AttemptWrite_Error;
}
pMFRec->ibBuffer = 0;
}
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
fRet = WriteFile(pMFRec->hFile, lpData,
dwBytes, &cbWritten, (LPOVERLAPPED)NULL);
if (!fRet || (cbWritten != dwBytes))
{
ERROR_ASSERT(FALSE, "AttemptWrite: Write2 failed\n");
goto AttemptWrite_Error;
}
}
else
{
RtlCopyMemory((LPBYTE)pMFRec->hMem + pMFRec->ibBuffer, lpData, dwBytes);
pMFRec->ibBuffer += dwBytes;
}
}
else
{
if (dwBytes + pMFRec->ibBuffer > pMFRec->cbBuffer)
{
DWORD cbNewSize;
HANDLE hMem;
cbNewSize = pMFRec->cbBuffer + MF16_BUFSIZE_INC
+ dwBytes / MF16_BUFSIZE_INC * MF16_BUFSIZE_INC;
hMem = LocalReAlloc(pMFRec->hMem, cbNewSize, LMEM_MOVEABLE);
if (hMem == NULL)
{
ERROR_ASSERT(FALSE, "AttemptWrite: out of memory\n");
goto AttemptWrite_Error;
}
pMFRec->hMem = hMem;
pMFRec->cbBuffer = cbNewSize;
}
RtlCopyMemory((LPBYTE)pMFRec->hMem + pMFRec->ibBuffer, lpData, dwBytes);
pMFRec->ibBuffer += dwBytes;
}
pMFRec->metaHeader.mtSize += dwBytes/sizeof(WORD);
return(TRUE);
AttemptWrite_Error:
MarkMetaFile(pMFRec);
return(FALSE);
} | 0.014762 | {} | c | Procedural | 100.00% |
/******************************************************************
* *
* Copyright Mentor Graphics Corporation 2004 *
* *
* All Rights Reserved. *
* *
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION *
* WHICH IS THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS *
* LICENSORS AND IS SUBJECT TO LICENSE TERMS. *
* *
******************************************************************/
#ifndef __MUSB_HDRC_PROTO_H__
#define __MUSB_HDRC_PROTO_H__
/*
* Prototypes for HDRC-specific functions
* $Revision: 1.17 $
*/
#include "mu_impl.h"
#include "mu_drcpr.h"
/*
* Initialize (discover FIFO config, etc.)
*/
extern uint8_t MGC_HdrcInit(MGC_Port *pPort);
/**
* Try to allocate a local FIFO appropriate to the given remote endpoint (host role)
* or to be identified with the given endpoint descriptor (function role).
* NOTE: although this behavior is common with the FDRC,
* the way the code is conditionally compiled has the effect that it can't
* reside in a common file (unless always gets compiled, which is undesirable).
* @param pPort port pointer
* @param pUsbEnd device endpoint attributes pointer
* @param pRequest requested local endpoint attributes
* @param bBind TRUE to actually bind (reserve resources)
* @param pbIsTx pointer to storage to indicate Tx (TRUE) or Rx (FALSE)
* @return pointer on success
* @return NULL on failure
*/
extern MGC_EndpointResource *MGC_HdrcBindDynamicEndpoint(MGC_Port *pPort,
const MUSB_DeviceEndpoint *pUsbEnd,
MUSB_EndpointResource *pRequest,
uint8_t bBind, uint8_t *pbIsTx);
/** HDRC ISR */
extern int MGC_HdrcIsr(void *pParam);
/*
* Program the FDRC to start/stop (enable/disable interrupts, bus reset, etc.).
* This is where registers get twiddled; no place above.
*/
extern uint32_t MGC_HdrcStart(MGC_Controller *pController);
extern uint32_t MGC_HdrcStop(MGC_Controller *pController);
extern uint32_t MGC_HdrcDestroy(MGC_Controller *pController);
/*
* Read bus state
*/
extern uint32_t MGC_HdrcReadBusState(MGC_Port *pPort);
/* Program the bus state from the port (see MGC_Port) */
extern uint32_t MGC_HdrcProgramBusState(MGC_Port *pPort);
/*
* Find the first or best (host) or required (function)
* local endpoint resource to communicate with the given remote endpoint (host)
* or to be identified with the given endpoint descriptor (function).
* This is where registers get twiddled; no place above.
*/
extern MGC_EndpointResource *MGC_HdrcBindEndpoint(MGC_Port *pPort,
const MUSB_DeviceEndpoint *pUsbEnd,
MUSB_EndpointResource *pRequest,
uint8_t bBind);
/*
* Program the HDRC to initiate a transfer.
* This is where registers get twiddled; no place above.
*/
extern uint32_t MGC_HdrcStartRx(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t *pBuffer, uint32_t dwTotalBytes, void *pIrp, uint8_t bAllowDma);
extern uint32_t MGC_HdrcStartTx(MGC_Port *pPort, MGC_EndpointResource *pEnd,
const uint8_t *pBuffer, uint32_t dwTotalBytes, void *pIrp);
/*
* Program the underlying port to flush the given endpoint resource,
* with respect to the given USB direction (IN or OUT).
* The resource should be ready for normal operation by return time.
*/
extern uint32_t MGC_HdrcFlushEndpoint(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t bDir, uint8_t bReuse);
/*
* Program the HDRC's given endpoint's stall state
* (TRUE to set halt; FALSE to clear halt)
*/
extern uint32_t MGC_HdrcHaltEndpoint(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t bDir, uint8_t bHalt);
extern uint32_t MGC_HdrcDefaultEndResponse(MGC_Port *pPort, uint8_t bStall);
/*
* Interrupts
*/
extern uint8_t MGC_HdrcServiceDefaultEnd(MGC_Port *pPort, MGC_BsrItem *pItem);
extern uint8_t MGC_HdrcServiceTransmitAvail(MGC_Port *pPort, uint16_t wEndIndex, MGC_BsrItem *pItem);
extern uint8_t MGC_HdrcServiceReceiveReady(MGC_Port *pPort, uint16_t wEndIndex, MGC_BsrItem *pItem);
/*
* FIFOs
*/
extern uint8_t MGC_HdrcLoadFifo(MGC_Port *pPort, uint8_t bEnd, uint32_t dwCount, const uint8_t *pSource);
extern uint8_t MGC_HdrcUnloadFifo(MGC_Port *pPort, uint8_t bEnd, uint32_t dwCount, uint8_t *pDest);
extern void MGC_HdrcSetPortTestMode(MGC_Port *pPort, MUSB_HsetPortMode eMode);
extern void MGC_HdrcDynamicFifoLocation(MGC_Port *pPort,
uint8_t bEnd,
uint8_t bIsTx,
uint8_t bSet,
uint32_t *pdwBase,
uint8_t *pbSize83,
uint8_t *pbDoubleBuffered);
/**
* Set Vbus control options for ULPI PHYs.
* @param pPort port pointer
* @param bExtSource TRUE if the Vbus source is external; FALSE to use internal
* @param bExtIndicator TRUE to use an external Vbus valid indicator; FALSE to use internal
* @return TRUE on success
* @return FALSE on error
*/
extern uint8_t MGC_HdrcUlpiVbusControl(MGC_Port *pPort, uint8_t bExtSource, uint8_t bExtIndicator);
/**
* Read a ULPI PHY register.
* @param pPort port pointer
* @param bAddr ULPI register address
* @param pbData where to store register value
* @return TRUE on success
* @return FALSE on error (PHY is suspended so read is not possible)
*/
extern uint8_t MGC_HdrcReadUlpiReg(MGC_Port *pPort, uint8_t bAddr, uint8_t *pbData);
/**
* Write a ULPI PHY register.
* @param pPort port pointer
* @param bAddr ULPI register address
* @param bData value to write
* @return TRUE on success
* @return FALSE on error (PHY is suspended so write is not possible)
*/
extern uint8_t MGC_HdrcWriteUlpiReg(MGC_Port *pPort, uint8_t bAddr, uint8_t bData);
/**
* DMA channel status changed
*/
extern uint8_t MGC_HdrcDmaChannelStatusChanged(
void *pPrivateData, uint8_t bLocalEnd, uint8_t bTransmit);
#if MUSB_DIAG > 0
/*
* Dump info global to the FDRC
*/
extern int MGC_HdrcDumpState(MGC_Controller *pController);
/*
* Dump info relevant to the given local endpoint resource
*/
extern int MGC_HdrcDumpEndpoint(MGC_Controller *pController, MUSB_EndpointResource *pEnd);
#endif /* diagnostics enabled */
#endif /* multiple inclusion protection */
| /******************************************************************
* *
* Copyright Mentor Graphics Corporation 2004 *
* *
* All Rights Reserved. *
* *
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION *
* WHICH IS THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS *
* LICENSORS AND IS SUBJECT TO LICENSE TERMS. *
* *
******************************************************************/
#ifndef __MUSB_HDRC_PROTO_H__
#define __MUSB_HDRC_PROTO_H__
/*
* Prototypes for HDRC-specific functions
* $Revision: 1.17 $
*/
#include "mu_impl.h"
#include "IMPORT_0"
/*
* Initialize (discover FIFO config, etc.)
*/
extern uint8_t MGC_HdrcInit(MGC_Port *pPort);
/**
* Try to allocate a local FIFO appropriate to the given remote endpoint (host role)
* or to be identified with the given endpoint descriptor (function role).
* NOTE: although this behavior is common with the FDRC,
* the way the code is conditionally compiled has the effect that it can't
* reside in a common file (unless always gets compiled, which is undesirable).
* @param pPort port pointer
* @param pUsbEnd device endpoint attributes pointer
* @param pRequest requested local endpoint attributes
* @param bBind TRUE to actually bind (reserve resources)
* @param pbIsTx pointer to storage to indicate Tx (TRUE) or Rx (FALSE)
* @return pointer on success
* @return NULL on failure
*/
extern MGC_EndpointResource *MGC_HdrcBindDynamicEndpoint(MGC_Port *pPort,
const CLASS_0 *pUsbEnd,
MUSB_EndpointResource *pRequest,
uint8_t VAR_0, uint8_t *VAR_1);
/** HDRC ISR */
extern int MGC_HdrcIsr(void *pParam);
/*
* Program the FDRC to start/stop (enable/disable interrupts, bus reset, etc.).
* This is where registers get twiddled; no place above.
*/
extern uint32_t FUNC_0(MGC_Controller *VAR_2);
extern uint32_t FUNC_1(MGC_Controller *VAR_2);
extern uint32_t MGC_HdrcDestroy(MGC_Controller *VAR_2);
/*
* Read bus state
*/
extern uint32_t MGC_HdrcReadBusState(MGC_Port *pPort);
/* Program the bus state from the port (see MGC_Port) */
extern uint32_t MGC_HdrcProgramBusState(MGC_Port *pPort);
/*
* Find the first or best (host) or required (function)
* local endpoint resource to communicate with the given remote endpoint (host)
* or to be identified with the given endpoint descriptor (function).
* This is where registers get twiddled; no place above.
*/
extern MGC_EndpointResource *FUNC_2(MGC_Port *pPort,
const CLASS_0 *pUsbEnd,
MUSB_EndpointResource *pRequest,
uint8_t VAR_0);
/*
* Program the HDRC to initiate a transfer.
* This is where registers get twiddled; no place above.
*/
extern uint32_t MGC_HdrcStartRx(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t *VAR_3, uint32_t VAR_4, void *pIrp, uint8_t bAllowDma);
extern uint32_t MGC_HdrcStartTx(MGC_Port *pPort, MGC_EndpointResource *pEnd,
const uint8_t *VAR_3, uint32_t VAR_4, void *pIrp);
/*
* Program the underlying port to flush the given endpoint resource,
* with respect to the given USB direction (IN or OUT).
* The resource should be ready for normal operation by return time.
*/
extern uint32_t MGC_HdrcFlushEndpoint(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t bDir, uint8_t bReuse);
/*
* Program the HDRC's given endpoint's stall state
* (TRUE to set halt; FALSE to clear halt)
*/
extern uint32_t MGC_HdrcHaltEndpoint(MGC_Port *pPort, MGC_EndpointResource *pEnd,
uint8_t bDir, uint8_t bHalt);
extern uint32_t FUNC_3(MGC_Port *pPort, uint8_t VAR_5);
/*
* Interrupts
*/
extern uint8_t MGC_HdrcServiceDefaultEnd(MGC_Port *pPort, MGC_BsrItem *pItem);
extern uint8_t FUNC_4(MGC_Port *pPort, uint16_t wEndIndex, MGC_BsrItem *pItem);
extern uint8_t MGC_HdrcServiceReceiveReady(MGC_Port *pPort, uint16_t wEndIndex, MGC_BsrItem *pItem);
/*
* FIFOs
*/
extern uint8_t MGC_HdrcLoadFifo(MGC_Port *pPort, uint8_t VAR_6, uint32_t VAR_7, const uint8_t *VAR_8);
extern uint8_t MGC_HdrcUnloadFifo(MGC_Port *pPort, uint8_t VAR_6, uint32_t VAR_7, uint8_t *VAR_9);
extern void FUNC_5(MGC_Port *pPort, CLASS_1 eMode);
extern void MGC_HdrcDynamicFifoLocation(MGC_Port *pPort,
uint8_t VAR_6,
uint8_t VAR_10,
uint8_t bSet,
uint32_t *VAR_11,
uint8_t *pbSize83,
uint8_t *pbDoubleBuffered);
/**
* Set Vbus control options for ULPI PHYs.
* @param pPort port pointer
* @param bExtSource TRUE if the Vbus source is external; FALSE to use internal
* @param bExtIndicator TRUE to use an external Vbus valid indicator; FALSE to use internal
* @return TRUE on success
* @return FALSE on error
*/
extern uint8_t MGC_HdrcUlpiVbusControl(MGC_Port *pPort, uint8_t bExtSource, uint8_t bExtIndicator);
/**
* Read a ULPI PHY register.
* @param pPort port pointer
* @param bAddr ULPI register address
* @param pbData where to store register value
* @return TRUE on success
* @return FALSE on error (PHY is suspended so read is not possible)
*/
extern uint8_t MGC_HdrcReadUlpiReg(MGC_Port *pPort, uint8_t bAddr, uint8_t *pbData);
/**
* Write a ULPI PHY register.
* @param pPort port pointer
* @param bAddr ULPI register address
* @param bData value to write
* @return TRUE on success
* @return FALSE on error (PHY is suspended so write is not possible)
*/
extern uint8_t MGC_HdrcWriteUlpiReg(MGC_Port *pPort, uint8_t bAddr, uint8_t bData);
/**
* DMA channel status changed
*/
extern uint8_t MGC_HdrcDmaChannelStatusChanged(
void *pPrivateData, uint8_t bLocalEnd, uint8_t bTransmit);
#if MUSB_DIAG > 0
/*
* Dump info global to the FDRC
*/
extern int MGC_HdrcDumpState(MGC_Controller *VAR_2);
/*
* Dump info relevant to the given local endpoint resource
*/
extern int FUNC_6(MGC_Controller *VAR_2, MUSB_EndpointResource *pEnd);
#endif /* diagnostics enabled */
#endif /* multiple inclusion protection */
| 0.270877 | {'IMPORT_0': 'mu_drcpr.h', 'CLASS_0': 'MUSB_DeviceEndpoint', 'VAR_0': 'bBind', 'VAR_1': 'pbIsTx', 'FUNC_0': 'MGC_HdrcStart', 'VAR_2': 'pController', 'FUNC_1': 'MGC_HdrcStop', 'FUNC_2': 'MGC_HdrcBindEndpoint', 'VAR_3': 'pBuffer', 'VAR_4': 'dwTotalBytes', 'FUNC_3': 'MGC_HdrcDefaultEndResponse', 'VAR_5': 'bStall', 'FUNC_4': 'MGC_HdrcServiceTransmitAvail', 'VAR_6': 'bEnd', 'VAR_7': 'dwCount', 'VAR_8': 'pSource', 'VAR_9': 'pDest', 'FUNC_5': 'MGC_HdrcSetPortTestMode', 'CLASS_1': 'MUSB_HsetPortMode', 'VAR_10': 'bIsTx', 'VAR_11': 'pdwBase', 'FUNC_6': 'MGC_HdrcDumpEndpoint'} | c | Procedural | 100.00% |
/* Transfer a message to the PPE and busy wait for the reply. */
static void transfer_msg(ppebuf_t *buf)
{
buf->obj.next = NULL;
buf->completed = 0;
buf->cookie = ppe.cookie;
enqueue((void *)(uintptr_t) ppe.ppebufs_offset, ppe.queue, (obj_t *)buf);
while (buf->completed == 0)
SPINLOCK_BODY();
} | /* Transfer a message to the PPE and busy wait for the reply. */
static void transfer_msg(CLASS_0 *buf)
{
buf->obj.next = NULL;
buf->completed = 0;
buf->cookie = ppe.cookie;
enqueue((void *)(uintptr_t) ppe.ppebufs_offset, ppe.queue, (obj_t *)buf);
while (buf->completed == 0)
SPINLOCK_BODY();
} | 0.151333 | {'CLASS_0': 'ppebuf_t'} | c | Procedural | 100.00% |
#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxKinect.h"
#include "ofxOsc.h"
#include "ofxGui.h"
#include "Hand.h"
#define SEND_PORT 8000
class ofApp : public ofBaseApp
{
public:
void setup();
void update();
void draw();
void exit();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxKinect kinect;
ofImage kinectRGB;
ofxCvGrayscaleImage grayImage; // grayscale depth image
ofxCvGrayscaleImage grayThreshNear; // the near thresholded image
ofxCvGrayscaleImage grayThreshFar; // the far thresholded image
ofxCvGrayscaleImage grayThreshRes;
ofxCvContourFinder contourFinder;
ofParameter<int> cameraAngle;
ofParameter<int> nearThreshold;
ofParameter<int> farThreshold;
ofParameter<int> minBlobArea;
ofParameter<int> maxBlobArea;
ofParameter<int> nBlobsConsidered;
ofxPanel gui;
Hand left;
Hand right;
vector<ofDefaultVec3> hands;
ofxOscSender sender;
bool bDrawGui;
void cameraAngleChanged(int &cameraAngle);
};
| #pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
#include "ofxKinect.h"
#include "ofxOsc.h"
#include "ofxGui.h"
#include "IMPORT_0"
#define VAR_0 8000
CLASS_0 ofApp : VAR_1 ofBaseApp
{
public:
void setup();
void FUNC_0();
void draw();
void exit();
void FUNC_1(int VAR_2);
void keyReleased(int VAR_2);
void FUNC_2(int VAR_3, int VAR_4);
void mouseDragged(int VAR_3, int VAR_4, int VAR_5);
void mousePressed(int VAR_3, int VAR_4, int VAR_5);
void mouseReleased(int VAR_3, int VAR_4, int VAR_5);
void FUNC_3(int VAR_3, int VAR_4);
void mouseExited(int VAR_3, int VAR_4);
void FUNC_4(int w, int VAR_6);
void dragEvent(CLASS_1 dragInfo);
void gotMessage(ofMessage msg);
ofxKinect kinect;
ofImage VAR_7;
CLASS_2 VAR_8; // grayscale depth image
CLASS_2 grayThreshNear; // the near thresholded image
CLASS_2 VAR_9; // the far thresholded image
CLASS_2 grayThreshRes;
ofxCvContourFinder VAR_10;
VAR_11<VAR_12> VAR_13;
VAR_11<VAR_12> VAR_14;
VAR_11<VAR_12> VAR_15;
VAR_11<VAR_12> VAR_16;
VAR_11<VAR_12> maxBlobArea;
VAR_11<VAR_12> nBlobsConsidered;
ofxPanel gui;
Hand VAR_17;
Hand right;
vector<ofDefaultVec3> VAR_18;
ofxOscSender sender;
bool VAR_19;
void FUNC_5(int &VAR_13);
};
| 0.455864 | {'IMPORT_0': 'Hand.h', 'VAR_0': 'SEND_PORT', 'CLASS_0': 'class', 'VAR_1': 'public', 'FUNC_0': 'update', 'FUNC_1': 'keyPressed', 'VAR_2': 'key', 'FUNC_2': 'mouseMoved', 'VAR_3': 'x', 'VAR_4': 'y', 'VAR_5': 'button', 'FUNC_3': 'mouseEntered', 'FUNC_4': 'windowResized', 'VAR_6': 'h', 'CLASS_1': 'ofDragInfo', 'VAR_7': 'kinectRGB', 'CLASS_2': 'ofxCvGrayscaleImage', 'VAR_8': 'grayImage', 'VAR_9': 'grayThreshFar', 'VAR_10': 'contourFinder', 'VAR_11': 'ofParameter', 'VAR_12': 'int', 'VAR_13': 'cameraAngle', 'VAR_14': 'nearThreshold', 'VAR_15': 'farThreshold', 'VAR_16': 'minBlobArea', 'VAR_17': 'left', 'VAR_18': 'hands', 'VAR_19': 'bDrawGui', 'FUNC_5': 'cameraAngleChanged'} | c | OOP | 100.00% |
// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s
void f(int __attribute__((address_space(1))) * a, ...) {
__builtin_prefetch(a, 0, 1);
// CHECK: call void @llvm.prefetch.p1i8(i8 addrspace(1)* {{%.+}}, i32 0, i32 1, i32 1)
}
| // RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s
void f(int __attribute__((address_space(1))) * a, ...) {
__builtin_prefetch(a, 0, 1);
// CHECK: call void @llvm.prefetch.p1i8(i8 addrspace(1)* {{%.+}}, i32 0, i32 1, i32 1)
}
| 0.147835 | {} | c | Procedural | 84.31% |
/* SPDX-License-Identifier: MIT
*
* Copyright 2016-2021 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
#pragma tpc_printf (enable)
// Cast bfloat128 into float128
bfloat128_pair_t cast_bf16_to_32bits_lin_order(bfloat128 x)
{
bfloat128_pair_t y;
bfloat128 tmp;
// 0..15, 32..47, 64..79, 96..111
y.v1 = v_bf16_unpack_b(x, ((e_group_0) << 8) | ((e_every_second_element) << 9) | ((e_lower_half_group) << 10), y.v1);
// 16..31, 48..63, 80..95, 112..127
y.v2 = v_bf16_unpack_b(x, ((e_group_1) << 8) | ((e_every_second_element) << 9) | ((e_lower_half_group) << 10), y.v2);
tmp = y.v1;
// Rearranges the vector in correct order
// Move dualgroup0 of y.v2 to dualgroup1 of y.v1, 0..15, 16..31
y.v1 = v_bf16_mov_dual_group_b(y.v2, 0xFFFFFFFF, 0, 1, MkWr(1, 1), y.v1);
// Move dualgroup1 of y.v1 to dualgroup2 of y.v1, 0..15, 16..31, 32..47
y.v1 = v_bf16_mov_dual_group_b(tmp, 0xFFFFFFFF, 1, 2, MkWr(1, 1), y.v1);
// Move dualgroup1 of y.v2 to dualgroup3 of y.v1, 0..15, 16..31, 32..47, 48..63
y.v1 = v_bf16_mov_dual_group_b(y.v2, 0xFFFFFFFF, 1, 3, MkWr(1, 1), y.v1);
// Move dualgroup1 of y.v1 to dualgroup0 of y.v2, 64..79 48..63, 80..95, 112..127
y.v2 = v_bf16_mov_dual_group_b(tmp, 0xFFFFFFFF, 2, 0, MkWr(1, 1), y.v2);
// Move dualgroup2 of y.v2 to dualgroup1 of y.v2, 64..79 80..95, 80..95, 112..127
y.v2 = v_bf16_mov_dual_group_b(y.v2, 0xFFFFFFFF, 2, 1, MkWr(1, 1), y.v2);
// Move dualgroup3 of y.v1 to dualgroup2 of y.v2, 64..79 80..95, 96..111, 112..127
y.v2 = v_bf16_mov_dual_group_b(tmp, 0xFFFFFFFF, 3, 2, MkWr(1, 1), y.v2);
return y;
}
void main(tensor input_tensor,
tensor indices_tensor,
tensor lengths_tensor,
tensor output_tensor)
{
const int5 index_space_start = get_index_space_offset();
const int5 index_space_end = get_index_space_size() + index_space_start;
// DEPTH
const int depth_step = 128;
const int depth_start = index_space_start[0] * depth_step;
const int depth_end = index_space_end[0] * depth_step;
// WIDTH
const int width_step = 2;
const int width_start = index_space_start[1] * width_step;
const int width_end = index_space_end[1] * width_step;
int5 in_coord_1 = {0};
int5 in_coord_2 = {0};
int5 idx_coord_1 = {0};
int5 idx_coord_2 = {0};
int5 lengths_coord_1 = {0};
int5 lengths_coord_2 = {0};
int5 out_coord_1 = {0};
int5 out_coord_2 = {0};
int5 scale_bias_coord_1 = {0};
int5 scale_bias_coord_2 = {0};
const int input_dim0_len = get_dim_size(input_tensor, 0);
//the column number for scale and bias (the two float values take up 4 int8 pockets each)
const int scale_column = input_dim0_len - 8;
//assigning scale column
scale_bias_coord_1[0] = scale_bias_coord_2[0] = scale_column;
// LUT1 for shuffling first element to all 64 elements of the first dual group
const uchar256 lut1 = 0x80;
// LUT2 for shuffling third element to all 64 elements of the first dual group
const uchar256 lut2 = 0x82;
int index_offset = 0;
//finding the sum of length tensor upto the current element
for(int segment_no = 0; segment_no < width_start; segment_no++)
{
lengths_coord_1[0] = segment_no;
__global__ int* len_coord_ptr = gen_addr(lengths_coord_1, lengths_tensor);
index_offset += s_i32_ld_g(len_coord_ptr);
}
//this is the index tensor offset
const int index_offset_orig = index_offset;
for (int depth = depth_start; depth < depth_end; depth += depth_step)
{
in_coord_1[0] = out_coord_1[0] = depth;
in_coord_2[0] = out_coord_2[0] = depth;
//after each iteration in depth, offset_1 is reset to the original length tensor offset
int index_offset_1 = index_offset_orig;
int index_offset_2;
//iterating along the length tensor (i.e. the width of the output)
for (int segment_no = width_start; segment_no < width_end; segment_no += width_step)
{
//processing two length elements at a time
out_coord_1[1] = lengths_coord_1[0] = segment_no + 0;
out_coord_2[1] = lengths_coord_2[0] = segment_no + 1;
//address generation
__global__ int* len_coord_ptr_1 = gen_addr(lengths_coord_1, lengths_tensor);
__global__ int* len_coord_ptr_2 = gen_addr(lengths_coord_2, lengths_tensor);
//obtaining the two segment lengths
const int segment_length_1 = s_i32_ld_g(len_coord_ptr_1);
const int segment_length_2 = s_i32_ld_g(len_coord_ptr_2);
//offset_2 = offset_1 + segment_length_1
index_offset_2 = index_offset_1 + segment_length_1;
//finding the larger of the two lengths to iterate until
int max_length = s_i32_max(segment_length_2, segment_length_1);
//augmented float vector to hold the result
float128 out_value_1 = {0};
float128 out_value_2 = {0};
//intermediate int augmented vectors for the conversion from char256 to float256
bfloat128_pair_t in_value_1_bf16_av;
bfloat128_pair_t in_value_2_bf16_av;
idx_coord_1[0] = index_offset_1;
idx_coord_2[0] = index_offset_2;
//prologue
__global__ int* idx_coord_ptr_1 = gen_addr(idx_coord_1, indices_tensor);
__global__ int* idx_coord_ptr_2 = gen_addr(idx_coord_2, indices_tensor);
scale_bias_coord_1[1] = in_coord_1[1] = s_i32_ld_g(idx_coord_ptr_1);
scale_bias_coord_2[1] = in_coord_2[1] = s_i32_ld_g(idx_coord_ptr_2);
//loading value from input
bfloat128 in_value_1 = v_bf16_ld_tnsr_b(in_coord_1, input_tensor);
bfloat128 in_value_2 = v_bf16_ld_tnsr_b(in_coord_2, input_tensor);
//loading the vector containing the bias and the zp
float64 scale_zp_1 = v_f32_ld_tnsr_low_b(scale_bias_coord_1, input_tensor);
float64 scale_zp_2 = v_f32_ld_tnsr_low_b(scale_bias_coord_2, input_tensor);
//extracting scale and zp into separate vectors
/* Extract scale and broadcast to the whole vector */
// Shuffle first element of vector to dual group 0
float64 scale_1_v = v_f32_shuffle_b(scale_zp_1, lut1, 0, scale_zp_1);
float64 scale_2_v = v_f32_shuffle_b(scale_zp_2, lut1, 0, scale_zp_2);
printf("value 0 in vector scale_1_v is %f\n", scale_1_v[0]);
// Move dual group 0 to dual group 1
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), scale_2_v);
// Move dual group 0 to dual group 2
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), scale_2_v);
// Move dual group 0 to dual group 3
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), scale_2_v);
//assuming that the second column of the scale-bias tensor is filled with -sc*zp values
float64 neg_scale_x_bias_1_v = v_f32_shuffle_b(scale_zp_1, lut2, 0, scale_zp_1);
float64 neg_scale_x_bias_2_v = v_f32_shuffle_b(scale_zp_2, lut2, 0, scale_zp_2);
// Move dual group 0 to dual group 1
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), \
neg_scale_x_bias_2_v);
// Move dual group 0 to dual group 2
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), \
neg_scale_x_bias_2_v);
// Move dual group 0 to dual group 3
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), \
neg_scale_x_bias_2_v);
//char256 to int256
in_value_1_bf16_av = cast_bf16_to_32bits_lin_order(in_value_1);
in_value_2_bf16_av = cast_bf16_to_32bits_lin_order(in_value_2);
float128 in_value_1_float_0, in_value_1_float_1;
float128 in_value_2_float_0, in_value_2_float_1;
//iterating through the elements to be accumulated
for (int element_no = 1; element_no < max_length; element_no++)
{
//this predicate lets us stop accumulating past the the segment length selectively
char pred_1 = s_i32_cmp_leq(element_no, segment_length_1);
char pred_2 = s_i32_cmp_leq(element_no, segment_length_2);
//conversion to f32
in_value_1_float_0 = v_convert_bf16_to_f32_all_b(in_value_1_bf16_av.v1);
in_value_1_float_1 = v_convert_bf16_to_f32_all_b(in_value_1_bf16_av.v2);
//application of scale and bias
in_value_1_float_0.v1 = v_f32_mac_b(in_value_1_float_0.v1, scale_1_v, neg_scale_x_bias_1_v, (e_no_negation) << 1);
in_value_1_float_1.v1 = v_f32_mac_b(in_value_1_float_1.v1, scale_1_v, neg_scale_x_bias_1_v, (e_no_negation) << 1);
//conversion to f32
in_value_2_float_0 = v_convert_bf16_to_f32_all_b(in_value_2_bf16_av.v1);
in_value_2_float_1 = v_convert_bf16_to_f32_all_b(in_value_2_bf16_av.v2);
//application of scale and bias
in_value_2_float_0.v1 = v_f32_mac_b(in_value_2_float_0.v1, scale_2_v, neg_scale_x_bias_2_v, (e_no_negation) << 1);
in_value_2_float_1.v1 = v_f32_mac_b(in_value_2_float_1.v1, scale_2_v, neg_scale_x_bias_2_v, (e_no_negation) << 1);
//next index coordinate
idx_coord_1[0]++;
idx_coord_2[0]++;
idx_coord_ptr_1 = gen_addr(idx_coord_1, indices_tensor);
idx_coord_ptr_2 = gen_addr(idx_coord_2, indices_tensor);
scale_bias_coord_1[1] = in_coord_1[1] = s_i32_ld_g(idx_coord_ptr_1);
scale_bias_coord_2[1] = in_coord_2[1] = s_i32_ld_g(idx_coord_ptr_2);
//loading value from input
in_value_1 = v_bf16_ld_tnsr_b(in_coord_1, input_tensor);
in_value_2 = v_bf16_ld_tnsr_b(in_coord_2, input_tensor);
//char256 to float256
in_value_1_bf16_av = cast_bf16_to_32bits_lin_order(in_value_1);
in_value_2_bf16_av = cast_bf16_to_32bits_lin_order(in_value_2);
//accumulating
out_value_1.v1 = v_f32_add_b(out_value_1.v1, in_value_1_float_0.v1, 0, out_value_1.v1, pred_1, 0);
out_value_1.v2 = v_f32_add_b(out_value_1.v2, in_value_1_float_1.v1, 0, out_value_1.v2, pred_1, 0);
out_value_2.v1 = v_f32_add_b(out_value_2.v1, in_value_2_float_0.v1, 0, out_value_2.v1, pred_2, 0);
out_value_2.v2 = v_f32_add_b(out_value_2.v2, in_value_2_float_1.v1, 0, out_value_2.v2, pred_2, 0);
//scale is loaded from input tensor in the embedded version
//loading the vector containing the scale and the zp
float64 scale_zp_1 = v_f32_ld_tnsr_low_b(scale_bias_coord_1, input_tensor);
float64 scale_zp_2 = v_f32_ld_tnsr_low_b(scale_bias_coord_2, input_tensor);
//extracting scale and zp into separate vectors
/* Extract scale and broadcast to the whole vector */
// Shuffle first element of vector to dual group 0
scale_1_v = v_f32_shuffle_b(scale_zp_1, lut1, 0, scale_zp_1);
scale_2_v = v_f32_shuffle_b(scale_zp_2, lut1, 0, scale_zp_2);
// Move dual group 0 to dual group 1
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), scale_2_v);
// Move dual group 0 to dual group 2
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), scale_2_v);
// Move dual group 0 to dual group 3
scale_1_v = v_f32_mov_dual_group_b(scale_1_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), scale_1_v);
scale_2_v = v_f32_mov_dual_group_b(scale_2_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), scale_2_v);
//assuming that the second column of the scale-bias tensor is filled with -sc*zp values
neg_scale_x_bias_1_v = v_f32_shuffle_b(scale_zp_1, lut2, 0, scale_zp_1);
neg_scale_x_bias_2_v = v_f32_shuffle_b(scale_zp_2, lut2, 0, scale_zp_2);
// Move dual group 0 to dual group 1
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 1, MkWr(1, 1), \
neg_scale_x_bias_2_v);
// Move dual group 0 to dual group 2
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 2, MkWr(1, 1), \
neg_scale_x_bias_2_v);
// Move dual group 0 to dual group 3
neg_scale_x_bias_1_v = v_f32_mov_dual_group_b(neg_scale_x_bias_1_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), \
neg_scale_x_bias_1_v);
neg_scale_x_bias_2_v = v_f32_mov_dual_group_b(neg_scale_x_bias_2_v, 0xFFFFFFFF, 0, 3, MkWr(1, 1), \
neg_scale_x_bias_2_v);
}
//epilogue
char pred_1 = s_i32_cmp_leq(max_length, segment_length_1);
char pred_2 = s_i32_cmp_leq(max_length, segment_length_2);
in_value_1_float_0 = v_convert_bf16_to_f32_all_b(in_value_1_bf16_av.v1);
in_value_1_float_1 = v_convert_bf16_to_f32_all_b(in_value_1_bf16_av.v2);
in_value_1_float_0.v1 = v_f32_mac_b(in_value_1_float_0.v1, scale_1_v, neg_scale_x_bias_1_v, (e_no_negation) << 1);
in_value_1_float_1.v1 = v_f32_mac_b(in_value_1_float_1.v1, scale_1_v, neg_scale_x_bias_1_v, (e_no_negation) << 1);
in_value_2_float_0 = v_convert_bf16_to_f32_all_b(in_value_2_bf16_av.v1);
in_value_2_float_1 = v_convert_bf16_to_f32_all_b(in_value_2_bf16_av.v2);
in_value_2_float_0.v1 = v_f32_mac_b(in_value_2_float_0.v1, scale_2_v, neg_scale_x_bias_2_v, (e_no_negation) << 1);
in_value_2_float_1.v1 = v_f32_mac_b(in_value_2_float_1.v1, scale_2_v, neg_scale_x_bias_2_v, (e_no_negation) << 1);
out_value_1.v1 = v_f32_add_b(out_value_1.v1, in_value_1_float_0.v1, 0, out_value_1.v1, pred_1, 0);
out_value_1.v2 = v_f32_add_b(out_value_1.v2, in_value_1_float_1.v1, 0, out_value_1.v2, pred_1, 0);
out_value_2.v1 = v_f32_add_b(out_value_2.v1, in_value_2_float_0.v1, 0, out_value_2.v1, pred_2, 0);
out_value_2.v2 = v_f32_add_b(out_value_2.v2, in_value_2_float_1.v1, 0, out_value_2.v2, pred_2, 0);
//epilogue ends here
//for next iteration, offset is calculated from the last segment of the current iteration
index_offset_1 = index_offset_2 + segment_length_2;
//store the output vectors
v_f32_st_tnsr(out_coord_1, output_tensor, out_value_1.v1); out_coord_1[0] += 64;
v_f32_st_tnsr(out_coord_1, output_tensor, out_value_1.v2); out_coord_1[0] -= 64;
v_f32_st_tnsr(out_coord_2, output_tensor, out_value_2.v1); out_coord_2[0] += 64;
v_f32_st_tnsr(out_coord_2, output_tensor, out_value_2.v2); out_coord_2[0] -= 64;
}
}
}
| /* SPDX-License-Identifier: MIT
*
* Copyright 2016-2021 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
#pragma tpc_printf (enable)
// Cast bfloat128 into float128
CLASS_0 FUNC_0(CLASS_1 VAR_0)
{
CLASS_0 VAR_1;
CLASS_1 VAR_2;
// 0..15, 32..47, 64..79, 96..111
VAR_1.VAR_3 = FUNC_1(VAR_0, ((VAR_4) << 8) | ((e_every_second_element) << 9) | ((VAR_5) << 10), VAR_1.VAR_3);
// 16..31, 48..63, 80..95, 112..127
VAR_1.VAR_6 = FUNC_1(VAR_0, ((VAR_7) << 8) | ((e_every_second_element) << 9) | ((VAR_5) << 10), VAR_1.VAR_6);
VAR_2 = VAR_1.VAR_3;
// Rearranges the vector in correct order
// Move dualgroup0 of y.v2 to dualgroup1 of y.v1, 0..15, 16..31
VAR_1.VAR_3 = FUNC_2(VAR_1.VAR_6, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), VAR_1.VAR_3);
// Move dualgroup1 of y.v1 to dualgroup2 of y.v1, 0..15, 16..31, 32..47
VAR_1.VAR_3 = FUNC_2(VAR_2, 0xFFFFFFFF, 1, 2, FUNC_3(1, 1), VAR_1.VAR_3);
// Move dualgroup1 of y.v2 to dualgroup3 of y.v1, 0..15, 16..31, 32..47, 48..63
VAR_1.VAR_3 = FUNC_2(VAR_1.VAR_6, 0xFFFFFFFF, 1, 3, FUNC_3(1, 1), VAR_1.VAR_3);
// Move dualgroup1 of y.v1 to dualgroup0 of y.v2, 64..79 48..63, 80..95, 112..127
VAR_1.VAR_6 = FUNC_2(VAR_2, 0xFFFFFFFF, 2, 0, FUNC_3(1, 1), VAR_1.VAR_6);
// Move dualgroup2 of y.v2 to dualgroup1 of y.v2, 64..79 80..95, 80..95, 112..127
VAR_1.VAR_6 = FUNC_2(VAR_1.VAR_6, 0xFFFFFFFF, 2, 1, FUNC_3(1, 1), VAR_1.VAR_6);
// Move dualgroup3 of y.v1 to dualgroup2 of y.v2, 64..79 80..95, 96..111, 112..127
VAR_1.VAR_6 = FUNC_2(VAR_2, 0xFFFFFFFF, 3, 2, FUNC_3(1, 1), VAR_1.VAR_6);
return VAR_1;
}
void FUNC_4(CLASS_2 VAR_8,
CLASS_2 VAR_9,
CLASS_2 VAR_10,
CLASS_2 VAR_11)
{
const CLASS_3 VAR_12 = FUNC_5();
const CLASS_3 VAR_13 = FUNC_6() + VAR_12;
// DEPTH
const int VAR_14 = 128;
const int VAR_15 = VAR_12[0] * VAR_14;
const int VAR_16 = VAR_13[0] * VAR_14;
// WIDTH
const int VAR_17 = 2;
const int VAR_18 = VAR_12[1] * VAR_17;
const int VAR_19 = VAR_13[1] * VAR_17;
CLASS_3 VAR_20 = {0};
CLASS_3 VAR_21 = {0};
CLASS_3 idx_coord_1 = {0};
CLASS_3 VAR_22 = {0};
CLASS_3 VAR_23 = {0};
CLASS_3 VAR_24 = {0};
CLASS_3 VAR_25 = {0};
CLASS_3 VAR_26 = {0};
CLASS_3 scale_bias_coord_1 = {0};
CLASS_3 VAR_27 = {0};
const int VAR_28 = FUNC_7(VAR_8, 0);
//the column number for scale and bias (the two float values take up 4 int8 pockets each)
const int VAR_29 = VAR_28 - 8;
//assigning scale column
scale_bias_coord_1[0] = VAR_27[0] = VAR_29;
// LUT1 for shuffling first element to all 64 elements of the first dual group
const CLASS_4 lut1 = 0x80;
// LUT2 for shuffling third element to all 64 elements of the first dual group
const CLASS_4 VAR_30 = 0x82;
int VAR_31 = 0;
//finding the sum of length tensor upto the current element
for(int VAR_32 = 0; VAR_32 < VAR_18; VAR_32++)
{
VAR_23[0] = VAR_32;
CLASS_5 VAR_33* VAR_34 = FUNC_8(VAR_23, VAR_10);
VAR_31 += FUNC_9(VAR_34);
}
//this is the index tensor offset
const int VAR_35 = VAR_31;
for (int VAR_36 = VAR_15; VAR_36 < VAR_16; VAR_36 += VAR_14)
{
VAR_20[0] = VAR_25[0] = VAR_36;
VAR_21[0] = VAR_26[0] = VAR_36;
//after each iteration in depth, offset_1 is reset to the original length tensor offset
int VAR_37 = VAR_35;
int VAR_38;
//iterating along the length tensor (i.e. the width of the output)
for (int VAR_32 = VAR_18; VAR_32 < VAR_19; VAR_32 += VAR_17)
{
//processing two length elements at a time
VAR_25[1] = VAR_23[0] = VAR_32 + 0;
VAR_26[1] = VAR_24[0] = VAR_32 + 1;
//address generation
CLASS_5 VAR_33* len_coord_ptr_1 = FUNC_8(VAR_23, VAR_10);
CLASS_5 VAR_33* VAR_39 = FUNC_8(VAR_24, VAR_10);
//obtaining the two segment lengths
const int VAR_40 = FUNC_9(len_coord_ptr_1);
const int VAR_41 = FUNC_9(VAR_39);
//offset_2 = offset_1 + segment_length_1
VAR_38 = VAR_37 + VAR_40;
//finding the larger of the two lengths to iterate until
int VAR_42 = FUNC_10(VAR_41, VAR_40);
//augmented float vector to hold the result
CLASS_6 VAR_43 = {0};
CLASS_6 VAR_44 = {0};
//intermediate int augmented vectors for the conversion from char256 to float256
CLASS_0 VAR_45;
CLASS_0 VAR_46;
idx_coord_1[0] = VAR_37;
VAR_22[0] = VAR_38;
//prologue
CLASS_5 VAR_33* VAR_47 = FUNC_8(idx_coord_1, VAR_9);
CLASS_5 VAR_33* VAR_48 = FUNC_8(VAR_22, VAR_9);
scale_bias_coord_1[1] = VAR_20[1] = FUNC_9(VAR_47);
VAR_27[1] = VAR_21[1] = FUNC_9(VAR_48);
//loading value from input
CLASS_1 VAR_49 = v_bf16_ld_tnsr_b(VAR_20, VAR_8);
CLASS_1 VAR_50 = v_bf16_ld_tnsr_b(VAR_21, VAR_8);
//loading the vector containing the bias and the zp
CLASS_7 VAR_51 = FUNC_11(scale_bias_coord_1, VAR_8);
CLASS_7 VAR_52 = FUNC_11(VAR_27, VAR_8);
//extracting scale and zp into separate vectors
/* Extract scale and broadcast to the whole vector */
// Shuffle first element of vector to dual group 0
CLASS_7 VAR_53 = FUNC_12(VAR_51, lut1, 0, VAR_51);
CLASS_7 VAR_54 = FUNC_12(VAR_52, lut1, 0, VAR_52);
FUNC_13("value 0 in vector scale_1_v is %f\n", VAR_53[0]);
// Move dual group 0 to dual group 1
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), VAR_54);
// Move dual group 0 to dual group 2
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), VAR_54);
// Move dual group 0 to dual group 3
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), VAR_54);
//assuming that the second column of the scale-bias tensor is filled with -sc*zp values
CLASS_7 VAR_55 = FUNC_12(VAR_51, VAR_30, 0, VAR_51);
CLASS_7 VAR_56 = FUNC_12(VAR_52, VAR_30, 0, VAR_52);
// Move dual group 0 to dual group 1
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), \
VAR_56);
// Move dual group 0 to dual group 2
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), \
VAR_56);
// Move dual group 0 to dual group 3
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), \
VAR_56);
//char256 to int256
VAR_45 = FUNC_0(VAR_49);
VAR_46 = FUNC_0(VAR_50);
CLASS_6 in_value_1_float_0, VAR_57;
CLASS_6 VAR_58, VAR_59;
//iterating through the elements to be accumulated
for (int VAR_60 = 1; VAR_60 < VAR_42; VAR_60++)
{
//this predicate lets us stop accumulating past the the segment length selectively
char VAR_61 = s_i32_cmp_leq(VAR_60, VAR_40);
char VAR_62 = s_i32_cmp_leq(VAR_60, VAR_41);
//conversion to f32
in_value_1_float_0 = FUNC_15(VAR_45.VAR_3);
VAR_57 = FUNC_15(VAR_45.VAR_6);
//application of scale and bias
in_value_1_float_0.VAR_3 = FUNC_16(in_value_1_float_0.VAR_3, VAR_53, VAR_55, (VAR_63) << 1);
VAR_57.VAR_3 = FUNC_16(VAR_57.VAR_3, VAR_53, VAR_55, (VAR_63) << 1);
//conversion to f32
VAR_58 = FUNC_15(VAR_46.VAR_3);
VAR_59 = FUNC_15(VAR_46.VAR_6);
//application of scale and bias
VAR_58.VAR_3 = FUNC_16(VAR_58.VAR_3, VAR_54, VAR_56, (VAR_63) << 1);
VAR_59.VAR_3 = FUNC_16(VAR_59.VAR_3, VAR_54, VAR_56, (VAR_63) << 1);
//next index coordinate
idx_coord_1[0]++;
VAR_22[0]++;
VAR_47 = FUNC_8(idx_coord_1, VAR_9);
VAR_48 = FUNC_8(VAR_22, VAR_9);
scale_bias_coord_1[1] = VAR_20[1] = FUNC_9(VAR_47);
VAR_27[1] = VAR_21[1] = FUNC_9(VAR_48);
//loading value from input
VAR_49 = v_bf16_ld_tnsr_b(VAR_20, VAR_8);
VAR_50 = v_bf16_ld_tnsr_b(VAR_21, VAR_8);
//char256 to float256
VAR_45 = FUNC_0(VAR_49);
VAR_46 = FUNC_0(VAR_50);
//accumulating
VAR_43.VAR_3 = FUNC_17(VAR_43.VAR_3, in_value_1_float_0.VAR_3, 0, VAR_43.VAR_3, VAR_61, 0);
VAR_43.VAR_6 = FUNC_17(VAR_43.VAR_6, VAR_57.VAR_3, 0, VAR_43.VAR_6, VAR_61, 0);
VAR_44.VAR_3 = FUNC_17(VAR_44.VAR_3, VAR_58.VAR_3, 0, VAR_44.VAR_3, VAR_62, 0);
VAR_44.VAR_6 = FUNC_17(VAR_44.VAR_6, VAR_59.VAR_3, 0, VAR_44.VAR_6, VAR_62, 0);
//scale is loaded from input tensor in the embedded version
//loading the vector containing the scale and the zp
CLASS_7 VAR_51 = FUNC_11(scale_bias_coord_1, VAR_8);
CLASS_7 VAR_52 = FUNC_11(VAR_27, VAR_8);
//extracting scale and zp into separate vectors
/* Extract scale and broadcast to the whole vector */
// Shuffle first element of vector to dual group 0
VAR_53 = FUNC_12(VAR_51, lut1, 0, VAR_51);
VAR_54 = FUNC_12(VAR_52, lut1, 0, VAR_52);
// Move dual group 0 to dual group 1
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), VAR_54);
// Move dual group 0 to dual group 2
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), VAR_54);
// Move dual group 0 to dual group 3
VAR_53 = FUNC_14(VAR_53, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), VAR_53);
VAR_54 = FUNC_14(VAR_54, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), VAR_54);
//assuming that the second column of the scale-bias tensor is filled with -sc*zp values
VAR_55 = FUNC_12(VAR_51, VAR_30, 0, VAR_51);
VAR_56 = FUNC_12(VAR_52, VAR_30, 0, VAR_52);
// Move dual group 0 to dual group 1
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 1, FUNC_3(1, 1), \
VAR_56);
// Move dual group 0 to dual group 2
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 2, FUNC_3(1, 1), \
VAR_56);
// Move dual group 0 to dual group 3
VAR_55 = FUNC_14(VAR_55, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), \
VAR_55);
VAR_56 = FUNC_14(VAR_56, 0xFFFFFFFF, 0, 3, FUNC_3(1, 1), \
VAR_56);
}
//epilogue
char VAR_61 = s_i32_cmp_leq(VAR_42, VAR_40);
char VAR_62 = s_i32_cmp_leq(VAR_42, VAR_41);
in_value_1_float_0 = FUNC_15(VAR_45.VAR_3);
VAR_57 = FUNC_15(VAR_45.VAR_6);
in_value_1_float_0.VAR_3 = FUNC_16(in_value_1_float_0.VAR_3, VAR_53, VAR_55, (VAR_63) << 1);
VAR_57.VAR_3 = FUNC_16(VAR_57.VAR_3, VAR_53, VAR_55, (VAR_63) << 1);
VAR_58 = FUNC_15(VAR_46.VAR_3);
VAR_59 = FUNC_15(VAR_46.VAR_6);
VAR_58.VAR_3 = FUNC_16(VAR_58.VAR_3, VAR_54, VAR_56, (VAR_63) << 1);
VAR_59.VAR_3 = FUNC_16(VAR_59.VAR_3, VAR_54, VAR_56, (VAR_63) << 1);
VAR_43.VAR_3 = FUNC_17(VAR_43.VAR_3, in_value_1_float_0.VAR_3, 0, VAR_43.VAR_3, VAR_61, 0);
VAR_43.VAR_6 = FUNC_17(VAR_43.VAR_6, VAR_57.VAR_3, 0, VAR_43.VAR_6, VAR_61, 0);
VAR_44.VAR_3 = FUNC_17(VAR_44.VAR_3, VAR_58.VAR_3, 0, VAR_44.VAR_3, VAR_62, 0);
VAR_44.VAR_6 = FUNC_17(VAR_44.VAR_6, VAR_59.VAR_3, 0, VAR_44.VAR_6, VAR_62, 0);
//epilogue ends here
//for next iteration, offset is calculated from the last segment of the current iteration
VAR_37 = VAR_38 + VAR_41;
//store the output vectors
FUNC_18(VAR_25, VAR_11, VAR_43.VAR_3); VAR_25[0] += 64;
FUNC_18(VAR_25, VAR_11, VAR_43.VAR_6); VAR_25[0] -= 64;
FUNC_18(VAR_26, VAR_11, VAR_44.VAR_3); VAR_26[0] += 64;
FUNC_18(VAR_26, VAR_11, VAR_44.VAR_6); VAR_26[0] -= 64;
}
}
}
| 0.936592 | {'CLASS_0': 'bfloat128_pair_t', 'FUNC_0': 'cast_bf16_to_32bits_lin_order', 'CLASS_1': 'bfloat128', 'VAR_0': 'x', 'VAR_1': 'y', 'VAR_2': 'tmp', 'VAR_3': 'v1', 'FUNC_1': 'v_bf16_unpack_b', 'VAR_4': 'e_group_0', 'VAR_5': 'e_lower_half_group', 'VAR_6': 'v2', 'VAR_7': 'e_group_1', 'FUNC_2': 'v_bf16_mov_dual_group_b', 'FUNC_3': 'MkWr', 'FUNC_4': 'main', 'CLASS_2': 'tensor', 'VAR_8': 'input_tensor', 'VAR_9': 'indices_tensor', 'VAR_10': 'lengths_tensor', 'VAR_11': 'output_tensor', 'CLASS_3': 'int5', 'VAR_12': 'index_space_start', 'FUNC_5': 'get_index_space_offset', 'VAR_13': 'index_space_end', 'FUNC_6': 'get_index_space_size', 'VAR_14': 'depth_step', 'VAR_15': 'depth_start', 'VAR_16': 'depth_end', 'VAR_17': 'width_step', 'VAR_18': 'width_start', 'VAR_19': 'width_end', 'VAR_20': 'in_coord_1', 'VAR_21': 'in_coord_2', 'VAR_22': 'idx_coord_2', 'VAR_23': 'lengths_coord_1', 'VAR_24': 'lengths_coord_2', 'VAR_25': 'out_coord_1', 'VAR_26': 'out_coord_2', 'VAR_27': 'scale_bias_coord_2', 'VAR_28': 'input_dim0_len', 'FUNC_7': 'get_dim_size', 'VAR_29': 'scale_column', 'CLASS_4': 'uchar256', 'VAR_30': 'lut2', 'VAR_31': 'index_offset', 'VAR_32': 'segment_no', 'CLASS_5': '__global__', 'VAR_33': 'int', 'VAR_34': 'len_coord_ptr', 'FUNC_8': 'gen_addr', 'FUNC_9': 's_i32_ld_g', 'VAR_35': 'index_offset_orig', 'VAR_36': 'depth', 'VAR_37': 'index_offset_1', 'VAR_38': 'index_offset_2', 'VAR_39': 'len_coord_ptr_2', 'VAR_40': 'segment_length_1', 'VAR_41': 'segment_length_2', 'VAR_42': 'max_length', 'FUNC_10': 's_i32_max', 'CLASS_6': 'float128', 'VAR_43': 'out_value_1', 'VAR_44': 'out_value_2', 'VAR_45': 'in_value_1_bf16_av', 'VAR_46': 'in_value_2_bf16_av', 'VAR_47': 'idx_coord_ptr_1', 'VAR_48': 'idx_coord_ptr_2', 'VAR_49': 'in_value_1', 'VAR_50': 'in_value_2', 'CLASS_7': 'float64', 'VAR_51': 'scale_zp_1', 'FUNC_11': 'v_f32_ld_tnsr_low_b', 'VAR_52': 'scale_zp_2', 'VAR_53': 'scale_1_v', 'FUNC_12': 'v_f32_shuffle_b', 'VAR_54': 'scale_2_v', 'FUNC_13': 'printf', 'FUNC_14': 'v_f32_mov_dual_group_b', 'VAR_55': 'neg_scale_x_bias_1_v', 'VAR_56': 'neg_scale_x_bias_2_v', 'VAR_57': 'in_value_1_float_1', 'VAR_58': 'in_value_2_float_0', 'VAR_59': 'in_value_2_float_1', 'VAR_60': 'element_no', 'VAR_61': 'pred_1', 'VAR_62': 'pred_2', 'FUNC_15': 'v_convert_bf16_to_f32_all_b', 'FUNC_16': 'v_f32_mac_b', 'VAR_63': 'e_no_negation', 'FUNC_17': 'v_f32_add_b', 'FUNC_18': 'v_f32_st_tnsr'} | c | Procedural | 100.00% |
#ifndef GlobalRecHitsAnalyzer_h
#define GlobalRecHitsAnalyzer_h
/** \class GlobalHitsProducer
*
* Class to fill PGlobalRecHit object to be inserted into data stream
* containing information about various sub-systems in global coordinates
* with full geometry
*
* \author M. Strang SUNY-Buffalo
*/
// framework & common header files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/GetterOfProducts.h"
#include "FWCore/Framework/interface/ProcessMatch.h"
//DQM services
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
// ecal calorimeter info
#include "DataFormats/EcalDigi/interface/EBDataFrame.h"
#include "DataFormats/EcalDigi/interface/EEDataFrame.h"
#include "DataFormats/EcalDigi/interface/ESDataFrame.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/ESDetId.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
// hcal calorimeter info
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/HcalDigi/interface/HcalQIESample.h"
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
#include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
#include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
#include "DataFormats/HcalDigi/interface/HFDataFrame.h"
#include "DataFormats/HcalDigi/interface/HODataFrame.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
// silicon strip info
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
#include "Geometry/CommonTopologies/interface/StripTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
#include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
#include "DataFormats/Common/interface/OwnVector.h"
// silicon pixel info
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
// muon DT info
#include "DataFormats/DTDigi/interface/DTDigi.h"
#include "DataFormats/DTDigi/interface/DTDigiCollection.h"
#include "DataFormats/MuonDetId/interface/DTWireId.h"
#include "DataFormats/MuonDetId/interface/DTLayerId.h"
#include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
#include "Geometry/DTGeometry/interface/DTLayer.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
// muon CSC info
#include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
#include "Geometry/CSCGeometry/interface/CSCLayer.h"
// muon RPC info
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
#include "Geometry/RPCGeometry/interface/RPCRoll.h"
// event info
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
#include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
// general info
#include "DataFormats/DetId/interface/DetId.h"
#include "Geometry/CommonDetUnit/interface/GeomDetType.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include <cstdlib>
#include <string>
#include <memory>
#include <vector>
#include <map>
#include <cmath>
#include "TString.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
class CaloGeometryRecord;
class TrackerTopology;
class GlobalRecHitsAnalyzer : public DQMEDAnalyzer {
public:
typedef std::map<uint32_t, float, std::less<uint32_t>> MapType;
explicit GlobalRecHitsAnalyzer(const edm::ParameterSet &);
~GlobalRecHitsAnalyzer() override;
void analyze(const edm::Event &, const edm::EventSetup &) override;
protected:
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
private:
// production related methods
void fillECal(const edm::Event &, const edm::EventSetup &);
//void storeECal(PGlobalRecHit&);
void fillHCal(const edm::Event &, const edm::EventSetup &);
//void storeHCal(PGlobalRecHit&);
void fillTrk(const edm::Event &, const edm::EventSetup &);
//void storeTrk(PGlobalRecHit&);
void fillMuon(const edm::Event &, const edm::EventSetup &);
//void storeMuon(PGlobalRecHit&);
//void clear();
private:
// parameter information
std::string fName;
int verbosity;
int frequency;
std::string label;
bool getAllProvenances;
bool printProvenanceInfo;
std::string hitsProducer;
// Electromagnetic info
// ECal info
MonitorElement *mehEcaln[3];
MonitorElement *mehEcalRes[3];
edm::GetterOfProducts<edm::SortedCollection<HBHERecHit, edm::StrictWeakOrdering<HBHERecHit>>> HBHERecHitgetter_;
edm::GetterOfProducts<edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>> HFRecHitgetter_;
edm::GetterOfProducts<edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>> HORecHitgetter_;
edm::InputTag ECalEBSrc_;
edm::InputTag ECalUncalEBSrc_;
edm::InputTag ECalEESrc_;
edm::InputTag ECalUncalEESrc_;
edm::InputTag ECalESSrc_;
edm::EDGetTokenT<EBRecHitCollection> ECalEBSrc_Token_;
edm::EDGetTokenT<EERecHitCollection> ECalEESrc_Token_;
edm::EDGetTokenT<ESRecHitCollection> ECalESSrc_Token_;
edm::EDGetTokenT<EBUncalibratedRecHitCollection> ECalUncalEBSrc_Token_;
edm::EDGetTokenT<EEUncalibratedRecHitCollection> ECalUncalEESrc_Token_;
edm::EDGetTokenT<CrossingFrame<PCaloHit>> EBHits_Token_;
edm::EDGetTokenT<CrossingFrame<PCaloHit>> EEHits_Token_;
edm::EDGetTokenT<CrossingFrame<PCaloHit>> ESHits_Token_;
// HCal info
MonitorElement *mehHcaln[4];
MonitorElement *mehHcalRes[4];
edm::InputTag HCalSrc_;
edm::EDGetTokenT<edm::PCaloHitContainer> HCalSrc_Token_;
// Tracker info
// SiStrip
MonitorElement *mehSiStripn[19];
MonitorElement *mehSiStripResX[19];
MonitorElement *mehSiStripResY[19];
edm::InputTag SiStripSrc_;
edm::EDGetTokenT<SiStripMatchedRecHit2DCollection> SiStripSrc_Token_;
std::vector<PSimHit> matched;
std::pair<LocalPoint, LocalVector> projectHit(const PSimHit &hit,
const StripGeomDetUnit *stripDet,
const BoundPlane &plane);
TrackerHitAssociator::Config trackerHitAssociatorConfig_;
// SiPxl
MonitorElement *mehSiPixeln[7];
MonitorElement *mehSiPixelResX[7];
MonitorElement *mehSiPixelResY[7];
edm::InputTag SiPxlSrc_;
edm::EDGetTokenT<SiPixelRecHitCollection> SiPxlSrc_Token_;
// Muon info
// DT
MonitorElement *mehDtMuonn;
MonitorElement *mehCSCn;
MonitorElement *mehRPCn;
MonitorElement *mehDtMuonRes;
MonitorElement *mehCSCResRDPhi;
MonitorElement *mehRPCResX;
edm::InputTag MuDTSrc_;
edm::InputTag MuDTSimSrc_;
edm::EDGetTokenT<DTRecHitCollection> MuDTSrc_Token_;
edm::EDGetTokenT<edm::PSimHitContainer> MuDTSimSrc_Token_;
// Return a map between DTRecHit1DPair and wireId
std::map<DTWireId, std::vector<DTRecHit1DPair>> map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs);
// Compute SimHit distance from wire (cm)
float simHitDistFromWire(const DTLayer *layer, DTWireId wireId, const PSimHit &hit);
// Find the RecHit closest to the muon SimHit
template <typename type>
const type *findBestRecHit(const DTLayer *layer,
DTWireId wireId,
const std::vector<type> &recHits,
const float simHitDist);
// Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer);
// Compute the distance from wire (cm) of a hits in a DTRecHit1D
float recHitDistFromWire(const DTRecHit1D &recHit, const DTLayer *layer);
// Does the real job
template <typename type>
int compute(const DTGeometry *dtGeom,
const std::map<DTWireId, std::vector<PSimHit>> &simHitsPerWire,
const std::map<DTWireId, std::vector<type>> &recHitsPerWire,
int step);
// CSC
//Defined above....
edm::InputTag MuCSCSrc_;
edm::EDGetTokenT<CSCRecHit2DCollection> MuCSCSrc_Token_;
edm::EDGetTokenT<CrossingFrame<PSimHit>> MuCSCHits_Token_;
std::map<int, edm::PSimHitContainer> theMap;
void plotResolution(const PSimHit &simHit, const CSCRecHit2D &recHit, const CSCLayer *layer, int chamberType);
// RPC
//Defined above...
edm::InputTag MuRPCSrc_;
edm::InputTag MuRPCSimSrc_;
edm::EDGetTokenT<RPCRecHitCollection> MuRPCSrc_Token_;
edm::EDGetTokenT<edm::PSimHitContainer> MuRPCSimSrc_Token_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcGeomToken_;
// private statistics information
unsigned int count;
}; // end class declaration
#endif
#ifndef GlobalHitMap
#define GlobalHitMap
// geometry mapping
static const int dTrk = 1;
static const int sdPxlBrl = 1;
static const int sdPxlFwd = 2;
static const int sdSiTIB = 3;
static const int sdSiTID = 4;
static const int sdSiTOB = 5;
static const int sdSiTEC = 6;
static const int dMuon = 2;
static const int sdMuonDT = 1;
static const int sdMuonCSC = 2;
static const int sdMuonRPC = 3;
static const int sdMuonRPCRgnBrl = 0;
static const int sdMuonRPCRgnFwdp = 1;
static const int sdMuonRPCRgnFwdn = -1;
static const int dEcal = 3;
static const int sdEcalBrl = 1;
static const int sdEcalFwd = 2;
static const int sdEcalPS = 3;
static const int sdEcalTT = 4;
static const int sdEcalLPnD = 5;
static const int dHcal = 4;
static const int sdHcalEmpty = 0;
static const int sdHcalBrl = 1;
static const int sdHcalEC = 2;
static const int sdHcalOut = 3;
static const int sdHcalFwd = 4;
static const int sdHcalTT = 5;
static const int sdHcalCalib = 6;
static const int sdHcalCompst = 7;
#endif //PGlobalRecHitsProducer_h
| #ifndef VAR_0
#define VAR_0
/** \class GlobalHitsProducer
*
* Class to fill PGlobalRecHit object to be inserted into data stream
* containing information about various sub-systems in global coordinates
* with full geometry
*
* \author M. Strang SUNY-Buffalo
*/
// framework & common header files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "IMPORT_0"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "IMPORT_1"
#include "IMPORT_2"
//DQM services
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "IMPORT_3"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
// ecal calorimeter info
#include "DataFormats/EcalDigi/interface/EBDataFrame.h"
#include "DataFormats/EcalDigi/interface/EEDataFrame.h"
#include "DataFormats/EcalDigi/interface/ESDataFrame.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
#include "IMPORT_4"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/EcalDetId/interface/ESDetId.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
// hcal calorimeter info
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/HcalDigi/interface/HcalQIESample.h"
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
#include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
#include "IMPORT_5"
#include "DataFormats/HcalDigi/interface/HFDataFrame.h"
#include "IMPORT_6"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
// silicon strip info
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
#include "IMPORT_7"
#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
#include "Geometry/CommonTopologies/interface/StripTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
#include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "IMPORT_8"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "IMPORT_9"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
#include "DataFormats/Common/interface/OwnVector.h"
// silicon pixel info
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "IMPORT_10"
#include "IMPORT_11"
#include "IMPORT_12"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "IMPORT_13"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
// muon DT info
#include "DataFormats/DTDigi/interface/DTDigi.h"
#include "DataFormats/DTDigi/interface/DTDigiCollection.h"
#include "DataFormats/MuonDetId/interface/DTWireId.h"
#include "DataFormats/MuonDetId/interface/DTLayerId.h"
#include "IMPORT_14"
#include "IMPORT_15"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
// muon CSC info
#include "IMPORT_16"
#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
#include "Geometry/CSCGeometry/interface/CSCLayer.h"
// muon RPC info
#include "IMPORT_17"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
#include "IMPORT_18"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
#include "IMPORT_19"
// event info
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
#include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "IMPORT_20"
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
// general info
#include "DataFormats/DetId/interface/DetId.h"
#include "IMPORT_21"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include <cstdlib>
#include <IMPORT_22>
#include <memory>
#include <IMPORT_23>
#include <map>
#include <cmath>
#include "TString.h"
#include "IMPORT_24"
class CaloGeometryRecord;
class VAR_1;
class GlobalRecHitsAnalyzer : public DQMEDAnalyzer {
public:
typedef std::map<uint32_t, float, std::VAR_2<uint32_t>> MapType;
explicit GlobalRecHitsAnalyzer(const edm::ParameterSet &);
~GlobalRecHitsAnalyzer() override;
void analyze(const edm::Event &, const edm::EventSetup &) override;
protected:
VAR_3 bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
private:
// production related methods
VAR_3 fillECal(const edm::Event &, const edm::EventSetup &);
//void storeECal(PGlobalRecHit&);
void fillHCal(const edm::Event &, const edm::EventSetup &);
//void storeHCal(PGlobalRecHit&);
void fillTrk(const edm::Event &, const edm::EventSetup &);
//void storeTrk(PGlobalRecHit&);
void fillMuon(const edm::Event &, const edm::EventSetup &);
//void storeMuon(PGlobalRecHit&);
//void clear();
private:
// parameter information
std::IMPORT_22 fName;
int verbosity;
int frequency;
std::IMPORT_22 label;
bool VAR_4;
bool printProvenanceInfo;
std::IMPORT_22 hitsProducer;
// Electromagnetic info
// ECal info
MonitorElement *mehEcaln[3];
MonitorElement *VAR_5[3];
edm::GetterOfProducts<edm::SortedCollection<HBHERecHit, edm::StrictWeakOrdering<HBHERecHit>>> HBHERecHitgetter_;
edm::GetterOfProducts<edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>> HFRecHitgetter_;
edm::GetterOfProducts<edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>> HORecHitgetter_;
edm::InputTag ECalEBSrc_;
edm::InputTag VAR_6;
edm::InputTag ECalEESrc_;
edm::InputTag ECalUncalEESrc_;
edm::InputTag ECalESSrc_;
edm::VAR_7<VAR_8> VAR_9;
edm::VAR_7<EERecHitCollection> ECalEESrc_Token_;
edm::VAR_7<ESRecHitCollection> ECalESSrc_Token_;
edm::VAR_7<EBUncalibratedRecHitCollection> ECalUncalEBSrc_Token_;
edm::VAR_7<VAR_10> VAR_11;
edm::VAR_7<CrossingFrame<VAR_12>> EBHits_Token_;
edm::VAR_7<CrossingFrame<VAR_12>> EEHits_Token_;
edm::VAR_7<CrossingFrame<VAR_12>> ESHits_Token_;
// HCal info
MonitorElement *VAR_13[4];
MonitorElement *mehHcalRes[4];
edm::InputTag HCalSrc_;
edm::VAR_7<edm::PCaloHitContainer> VAR_14;
// Tracker info
// SiStrip
MonitorElement *VAR_15[19];
MonitorElement *mehSiStripResX[19];
MonitorElement *mehSiStripResY[19];
edm::InputTag SiStripSrc_;
edm::VAR_7<SiStripMatchedRecHit2DCollection> SiStripSrc_Token_;
std::IMPORT_23<PSimHit> matched;
std::VAR_16<LocalPoint, VAR_17> projectHit(const PSimHit &hit,
const StripGeomDetUnit *stripDet,
const BoundPlane &plane);
TrackerHitAssociator::Config trackerHitAssociatorConfig_;
// SiPxl
MonitorElement *VAR_18[7];
MonitorElement *mehSiPixelResX[7];
MonitorElement *mehSiPixelResY[7];
edm::InputTag SiPxlSrc_;
edm::VAR_7<SiPixelRecHitCollection> SiPxlSrc_Token_;
// Muon info
// DT
MonitorElement *mehDtMuonn;
MonitorElement *mehCSCn;
MonitorElement *mehRPCn;
MonitorElement *mehDtMuonRes;
MonitorElement *mehCSCResRDPhi;
MonitorElement *mehRPCResX;
edm::InputTag MuDTSrc_;
edm::InputTag MuDTSimSrc_;
edm::VAR_7<VAR_19> MuDTSrc_Token_;
edm::VAR_7<edm::VAR_20> MuDTSimSrc_Token_;
// Return a map between DTRecHit1DPair and wireId
std::map<DTWireId, std::IMPORT_23<DTRecHit1DPair>> map1DRecHitsPerWire(const VAR_19 *dt1DRecHitPairs);
// Compute SimHit distance from wire (cm)
float simHitDistFromWire(const DTLayer *layer, DTWireId VAR_21, const PSimHit &hit);
// Find the RecHit closest to the muon SimHit
template <typename type>
const type *findBestRecHit(const DTLayer *layer,
DTWireId VAR_21,
const std::IMPORT_23<type> &recHits,
const float simHitDist);
// Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer);
// Compute the distance from wire (cm) of a hits in a DTRecHit1D
float recHitDistFromWire(const CLASS_0 &VAR_22, const DTLayer *layer);
// Does the real job
template <typename type>
int compute(const CLASS_1 *dtGeom,
const std::map<DTWireId, std::IMPORT_23<PSimHit>> &simHitsPerWire,
const std::map<DTWireId, std::IMPORT_23<type>> &VAR_24,
int VAR_25);
// CSC
//Defined above....
edm::InputTag VAR_26;
edm::VAR_7<CSCRecHit2DCollection> VAR_27;
edm::VAR_7<CrossingFrame<PSimHit>> VAR_28;
std::map<int, edm::VAR_20> theMap;
void plotResolution(const PSimHit &simHit, const CSCRecHit2D &VAR_22, const CSCLayer *layer, int VAR_29);
// RPC
//Defined above...
edm::InputTag MuRPCSrc_;
edm::InputTag MuRPCSimSrc_;
edm::VAR_7<RPCRecHitCollection> MuRPCSrc_Token_;
edm::VAR_7<edm::VAR_20> VAR_30;
edm::VAR_31<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
edm::VAR_31<VAR_1, VAR_32> tTopoToken_;
edm::VAR_31<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
edm::VAR_31<VAR_23, MuonGeometryRecord> dtGeomToken_;
edm::VAR_31<VAR_33, MuonGeometryRecord> cscGeomToken_;
edm::VAR_31<RPCGeometry, MuonGeometryRecord> rpcGeomToken_;
// private statistics information
unsigned int count;
}; // end class declaration
#endif
#ifndef VAR_34
#define VAR_34
// geometry mapping
static const int dTrk = 1;
static const int sdPxlBrl = 1;
static const int sdPxlFwd = 2;
static const int VAR_35 = 3;
static const int sdSiTID = 4;
static const int VAR_36 = 5;
static const int sdSiTEC = 6;
static const int dMuon = 2;
static const int VAR_37 = 1;
static const int sdMuonCSC = 2;
static const int sdMuonRPC = 3;
static const int VAR_38 = 0;
static const int sdMuonRPCRgnFwdp = 1;
static const int sdMuonRPCRgnFwdn = -1;
static const int dEcal = 3;
static const int sdEcalBrl = 1;
static const int sdEcalFwd = 2;
static const int sdEcalPS = 3;
static const int sdEcalTT = 4;
static const int sdEcalLPnD = 5;
static const int dHcal = 4;
static const int VAR_39 = 0;
static const int sdHcalBrl = 1;
static const int sdHcalEC = 2;
static const int sdHcalOut = 3;
static const int sdHcalFwd = 4;
static const int sdHcalTT = 5;
static const int sdHcalCalib = 6;
static const int sdHcalCompst = 7;
#endif //PGlobalRecHitsProducer_h
| 0.237735 | {'VAR_0': 'GlobalRecHitsAnalyzer_h', 'IMPORT_0': 'FWCore/Framework/interface/Event.h', 'IMPORT_1': 'FWCore/Framework/interface/GetterOfProducts.h', 'IMPORT_2': 'FWCore/Framework/interface/ProcessMatch.h', 'IMPORT_3': 'DataFormats/Provenance/interface/Provenance.h', 'IMPORT_4': 'DataFormats/EcalDetId/interface/EBDetId.h', 'IMPORT_5': 'DataFormats/HcalDigi/interface/HBHEDataFrame.h', 'IMPORT_6': 'DataFormats/HcalDigi/interface/HODataFrame.h', 'IMPORT_7': 'DataFormats/SiStripDetId/interface/StripSubdetector.h', 'IMPORT_8': 'DataFormats/GeometryVector/interface/GlobalPoint.h', 'IMPORT_9': 'DataFormats/SiStripCluster/interface/SiStripClusterCollection.h', 'IMPORT_10': 'DataFormats/SiPixelDetId/interface/PixelSubdetector.h', 'IMPORT_11': 'Geometry/CommonTopologies/interface/PixelTopology.h', 'IMPORT_12': 'Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h', 'IMPORT_13': 'DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h', 'IMPORT_14': 'DataFormats/DTRecHit/interface/DTRecHitCollection.h', 'IMPORT_15': 'Geometry/DTGeometry/interface/DTLayer.h', 'IMPORT_16': 'DataFormats/CSCDigi/interface/CSCStripDigi.h', 'IMPORT_17': 'Geometry/RPCGeometry/interface/RPCGeometry.h', 'IMPORT_18': 'DataFormats/MuonDetId/interface/RPCDetId.h', 'IMPORT_19': 'Geometry/RPCGeometry/interface/RPCRoll.h', 'IMPORT_20': 'SimDataFormats/CaloHit/interface/PCaloHitContainer.h', 'IMPORT_21': 'Geometry/CommonDetUnit/interface/GeomDetType.h', 'IMPORT_22': 'string', 'IMPORT_23': 'vector', 'IMPORT_24': 'DQMServices/Core/interface/DQMEDAnalyzer.h', 'VAR_1': 'TrackerTopology', 'VAR_2': 'less', 'VAR_3': 'void', 'VAR_4': 'getAllProvenances', 'VAR_5': 'mehEcalRes', 'VAR_6': 'ECalUncalEBSrc_', 'VAR_7': 'EDGetTokenT', 'VAR_8': 'EBRecHitCollection', 'VAR_9': 'ECalEBSrc_Token_', 'VAR_10': 'EEUncalibratedRecHitCollection', 'VAR_11': 'ECalUncalEESrc_Token_', 'VAR_12': 'PCaloHit', 'VAR_13': 'mehHcaln', 'VAR_14': 'HCalSrc_Token_', 'VAR_15': 'mehSiStripn', 'VAR_16': 'pair', 'VAR_17': 'LocalVector', 'VAR_18': 'mehSiPixeln', 'VAR_19': 'DTRecHitCollection', 'VAR_20': 'PSimHitContainer', 'VAR_21': 'wireId', 'CLASS_0': 'DTRecHit1D', 'VAR_22': 'recHit', 'CLASS_1': 'DTGeometry', 'VAR_23': 'DTGeometry', 'VAR_24': 'recHitsPerWire', 'VAR_25': 'step', 'VAR_26': 'MuCSCSrc_', 'VAR_27': 'MuCSCSrc_Token_', 'VAR_28': 'MuCSCHits_Token_', 'VAR_29': 'chamberType', 'VAR_30': 'MuRPCSimSrc_Token_', 'VAR_31': 'ESGetToken', 'VAR_32': 'TrackerTopologyRcd', 'VAR_33': 'CSCGeometry', 'VAR_34': 'GlobalHitMap', 'VAR_35': 'sdSiTIB', 'VAR_36': 'sdSiTOB', 'VAR_37': 'sdMuonDT', 'VAR_38': 'sdMuonRPCRgnBrl', 'VAR_39': 'sdHcalEmpty'} | c | OOP | 100.00% |
#include <SFMT.h>
uint32_t wrap_genrand_uint32(sfmt_t* sfmt) {
return sfmt_genrand_uint32(sfmt);
}
uint64_t wrap_genrand_uint64(sfmt_t* sfmt) {
return sfmt_genrand_uint64(sfmt);
}
double wrap_genrand_real2(sfmt_t* sfmt) {
return sfmt_genrand_real2(sfmt);
}
double wrap_genrand_res53(sfmt_t* sfmt) {
return sfmt_genrand_res53(sfmt);
}
| #include <IMPORT_0>
uint32_t FUNC_0(CLASS_0* VAR_0) {
return FUNC_1(VAR_0);
}
uint64_t FUNC_2(CLASS_0* VAR_0) {
return FUNC_3(VAR_0);
}
double wrap_genrand_real2(CLASS_0* VAR_0) {
return FUNC_4(VAR_0);
}
double FUNC_5(CLASS_0* VAR_0) {
return FUNC_6(VAR_0);
}
| 0.601606 | {'IMPORT_0': 'SFMT.h', 'FUNC_0': 'wrap_genrand_uint32', 'CLASS_0': 'sfmt_t', 'VAR_0': 'sfmt', 'FUNC_1': 'sfmt_genrand_uint32', 'FUNC_2': 'wrap_genrand_uint64', 'FUNC_3': 'sfmt_genrand_uint64', 'FUNC_4': 'sfmt_genrand_real2', 'FUNC_5': 'wrap_genrand_res53', 'FUNC_6': 'sfmt_genrand_res53'} | c | Procedural | 100.00% |
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_jme3_bullet_joints_SixDofJoint */
#ifndef _Included_com_jme3_bullet_joints_SixDofJoint
#define _Included_com_jme3_bullet_joints_SixDofJoint
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: getRotationalLimitMotor
* Signature: (JI)J
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_getRotationalLimitMotor
(JNIEnv *, jobject, jlong, jint);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: getTranslationalLimitMotor
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_getTranslationalLimitMotor
(JNIEnv *, jobject, jlong);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setLinearUpperLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearUpperLimit
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setLinearLowerLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearLowerLimit
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setAngularUpperLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularUpperLimit
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setAngularLowerLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularLowerLimit
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: createJoint
* Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(JNIEnv *, jobject, jlong, jlong, jobject, jobject, jobject, jobject, jboolean);
#ifdef __cplusplus
}
#endif
#endif
| /* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_jme3_bullet_joints_SixDofJoint */
#ifndef _Included_com_jme3_bullet_joints_SixDofJoint
#define _Included_com_jme3_bullet_joints_SixDofJoint
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: getRotationalLimitMotor
* Signature: (JI)J
*/
JNIEXPORT jlong CLASS_0 FUNC_0
(CLASS_1 *, jobject, jlong, CLASS_2);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: getTranslationalLimitMotor
* Signature: (J)J
*/
JNIEXPORT jlong CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_getTranslationalLimitMotor
(CLASS_1 *, jobject, jlong);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setLinearUpperLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT VAR_0 CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_setLinearUpperLimit
(CLASS_1 *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setLinearLowerLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT VAR_0 CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_setLinearLowerLimit
(CLASS_1 *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setAngularUpperLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT VAR_0 CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_setAngularUpperLimit
(CLASS_1 *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: setAngularLowerLimit
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT VAR_0 CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_setAngularLowerLimit
(CLASS_1 *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: createJoint
* Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
*/
JNIEXPORT jlong CLASS_0 Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(CLASS_1 *, jobject, jlong, jlong, jobject, jobject, jobject, jobject, jboolean);
#ifdef __cplusplus
}
#endif
#endif
| 0.331164 | {'CLASS_0': 'JNICALL', 'FUNC_0': 'Java_com_jme3_bullet_joints_SixDofJoint_getRotationalLimitMotor', 'CLASS_1': 'JNIEnv', 'CLASS_2': 'jint', 'VAR_0': 'void'} | c | OOP | 100.00% |
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPolyPlane.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPolyPlane - Implicit function that is generated by extrusion of a polyline along the Z axis
// .SECTION Description
// vtkPolyPlane is, as the name suggests, an extrusion of a vtkPolyLine.
// The extrusion direction is assumed to be the Z vector. It can be used in
// combination with a vtkCutter to cut a dataset with a polyplane.
// vtkPolyPlane is a concrete implementation of the abstract class
// vtkImplicitFunction.
//
// .SECTION ToDo
// Generalize to extrusions along arbitrary directions.
#ifndef vtkPolyPlane_h
#define vtkPolyPlane_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkImplicitFunction.h"
class vtkPolyLine;
class vtkDoubleArray;
class VTKCOMMONDATAMODEL_EXPORT vtkPolyPlane : public vtkImplicitFunction
{
public:
// Description
// Construct plane passing through origin and normal to z-axis.
static vtkPolyPlane *New();
vtkTypeMacro(vtkPolyPlane,vtkImplicitFunction);
void PrintSelf(ostream& os, vtkIndent indent);
// Description
// Evaluate plane equation for point x[3].
double EvaluateFunction(double x[3]);
double EvaluateFunction(double x, double y, double z)
{return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;
// Description
// Evaluate function gradient at point x[3].
void EvaluateGradient(double x[3], double g[3]);
// Description:
// Set/get point through which plane passes. Plane is defined by point
// and normal.
virtual void SetPolyLine( vtkPolyLine * );
vtkGetObjectMacro( PolyLine, vtkPolyLine );
// Description:
// Override GetMTime to include the polyline
virtual unsigned long GetMTime();
protected:
vtkPolyPlane();
~vtkPolyPlane();
void ComputeNormals();
double ExtrusionDirection[3];
vtkPolyLine * PolyLine;
vtkTimeStamp NormalComputeTime;
vtkDoubleArray * Normals;
vtkIdType ClosestPlaneIdx;
private:
vtkPolyPlane(const vtkPolyPlane&); // Not implemented.
void operator=(const vtkPolyPlane&); // Not implemented.
};
#endif
| /*=========================================================================
Program: Visualization Toolkit
Module: vtkPolyPlane.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPolyPlane - Implicit function that is generated by extrusion of a polyline along the Z axis
// .SECTION Description
// vtkPolyPlane is, as the name suggests, an extrusion of a vtkPolyLine.
// The extrusion direction is assumed to be the Z vector. It can be used in
// combination with a vtkCutter to cut a dataset with a polyplane.
// vtkPolyPlane is a concrete implementation of the abstract class
// vtkImplicitFunction.
//
// .SECTION ToDo
// Generalize to extrusions along arbitrary directions.
#ifndef vtkPolyPlane_h
#define vtkPolyPlane_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkImplicitFunction.h"
class vtkPolyLine;
class vtkDoubleArray;
class VTKCOMMONDATAMODEL_EXPORT vtkPolyPlane : public vtkImplicitFunction
{
public:
// Description
// Construct plane passing through origin and normal to z-axis.
static vtkPolyPlane *New();
FUNC_0(vtkPolyPlane,vtkImplicitFunction);
void PrintSelf(ostream& os, vtkIndent VAR_0);
// Description
// Evaluate plane equation for point x[3].
double EvaluateFunction(double x[3]);
double EvaluateFunction(double x, double VAR_1, double VAR_2)
{return this->vtkImplicitFunction::EvaluateFunction(x, VAR_1, VAR_2); } ;
// Description
// Evaluate function gradient at point x[3].
void EvaluateGradient(double x[3], double VAR_3[3]);
// Description:
// Set/get point through which plane passes. Plane is defined by point
// and normal.
virtual void SetPolyLine( vtkPolyLine * );
vtkGetObjectMacro( VAR_4, vtkPolyLine );
// Description:
// Override GetMTime to include the polyline
virtual unsigned long GetMTime();
protected:
vtkPolyPlane();
~vtkPolyPlane();
void ComputeNormals();
double ExtrusionDirection[3];
vtkPolyLine * VAR_4;
CLASS_0 NormalComputeTime;
vtkDoubleArray * Normals;
vtkIdType VAR_5;
private:
vtkPolyPlane(const vtkPolyPlane&); // Not implemented.
void operator=(const vtkPolyPlane&); // Not implemented.
};
#endif
| 0.292217 | {'FUNC_0': 'vtkTypeMacro', 'VAR_0': 'indent', 'VAR_1': 'y', 'VAR_2': 'z', 'VAR_3': 'g', 'VAR_4': 'PolyLine', 'CLASS_0': 'vtkTimeStamp', 'VAR_5': 'ClosestPlaneIdx'} | c | Hibrido | 100.00% |
/* { dg-do compile } */
/* { dg-skip-if "" { ! { clmcpu } } } */
/* { dg-options "-O2 -Werror-implicit-function-declaration -mARC700 -msimd" } */
#define STEST1(name, rettype, op1) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1); \
}
#define STEST2(name, rettype, op1, op2) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2); \
}
#define STEST3(name, rettype, op1, op2, op3) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2, op3); \
}
#define STEST4(name, rettype, op1, op2, op3, op4) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2, op3, op4); \
}
typedef short v8hi __attribute__ ((vector_size (16)));
v8hi Va;
v8hi Vb;
v8hi Vc;
#define rlimm 0xf3eec0fe
#define Ic 0x02
#define Ib 0x02
#define u3 0x02
#define u6 0x1F
#define u8 0xB0
STEST2 ( vaddaw, v8hi, Vb, Vc)
STEST2 ( vaddw, v8hi, Vb, Vc)
STEST2 ( vavb, v8hi, Vb, Vc)
STEST2 ( vavrb, v8hi, Vb, Vc)
STEST2 ( vdifaw, v8hi, Vb, Vc)
STEST2 ( vdifw, v8hi, Vb, Vc)
STEST2 ( vmaxaw, v8hi, Vb, Vc)
STEST2 ( vmaxw, v8hi, Vb, Vc)
STEST2 ( vminaw, v8hi, Vb, Vc)
STEST2 ( vminw, v8hi, Vb, Vc)
STEST2 ( vmulaw, v8hi, Vb, Vc)
STEST2 (vmulfaw, v8hi, Vb, Vc)
STEST2 ( vmulfw, v8hi, Vb, Vc)
STEST2 ( vmulw, v8hi, Vb, Vc)
STEST2 ( vsubaw, v8hi, Vb, Vc)
STEST2 ( vsubw, v8hi, Vb, Vc)
STEST2 ( vsummw, v8hi, Vb, Vc)
STEST2 ( vand, v8hi, Vb, Vc)
STEST2 ( vandaw, v8hi, Vb, Vc)
STEST2 ( vbic, v8hi, Vb, Vc)
STEST2 ( vbicaw, v8hi, Vb, Vc)
STEST2 ( vor, v8hi, Vb, Vc)
STEST2 ( vxor, v8hi, Vb, Vc)
STEST2 ( vxoraw, v8hi, Vb, Vc)
STEST2 ( veqw, v8hi, Vb, Vc)
STEST2 ( vlew, v8hi, Vb, Vc)
STEST2 ( vltw, v8hi, Vb, Vc)
STEST2 ( vnew, v8hi, Vb, Vc)
STEST2 ( vmr1aw, v8hi, Vb, Vc)
STEST2 ( vmr1w, v8hi, Vb, Vc)
STEST2 ( vmr2aw, v8hi, Vb, Vc)
STEST2 ( vmr2w, v8hi, Vb, Vc)
STEST2 ( vmr3aw, v8hi, Vb, Vc)
STEST2 ( vmr3w, v8hi, Vb, Vc)
STEST2 ( vmr4aw, v8hi, Vb, Vc)
STEST2 ( vmr4w, v8hi, Vb, Vc)
STEST2 ( vmr5aw, v8hi, Vb, Vc)
STEST2 ( vmr5w, v8hi, Vb, Vc)
STEST2 ( vmr6aw, v8hi, Vb, Vc)
STEST2 ( vmr6w, v8hi, Vb, Vc)
STEST2 ( vmr7aw, v8hi, Vb, Vc)
STEST2 ( vmr7w, v8hi, Vb, Vc)
STEST2 ( vmrb, v8hi, Vb, Vc)
STEST2 ( vh264f, v8hi, Vb, Vc)
STEST2 (vh264ft, v8hi, Vb, Vc)
STEST2 (vh264fw, v8hi, Vb, Vc)
STEST2 ( vvc1f, v8hi, Vb, Vc)
STEST2 ( vvc1ft, v8hi, Vb, Vc)
STEST2 ( vbaddw, v8hi, Vb, rlimm)
STEST2 ( vbmaxw, v8hi, Vb, rlimm)
STEST2 ( vbminw, v8hi, Vb, rlimm)
STEST2 (vbmulaw, v8hi, Vb, rlimm)
STEST2 (vbmulfw, v8hi, Vb, rlimm)
STEST2 ( vbmulw, v8hi, Vb, rlimm)
STEST2 (vbrsubw, v8hi, Vb, rlimm)
STEST2 ( vbsubw, v8hi, Vb, rlimm)
/* Va, Vb, Ic instructions. */
STEST2 ( vasrw, v8hi, Vb, Ic)
STEST2 ( vsr8, v8hi, Vb, Ic)
STEST2 (vsr8aw, v8hi, Vb, Ic)
/* Va, Vb, u6 instructions. */
STEST2 ( vasrrwi, v8hi, Vb, u6)
STEST2 ( vasrsrwi, v8hi, Vb, u6)
STEST2 ( vasrwi, v8hi, Vb, u6)
STEST2 ( vasrpwbi, v8hi, Vb, u6)
STEST2 (vasrrpwbi, v8hi, Vb, u6)
STEST2 ( vsr8awi, v8hi, Vb, u6)
STEST2 ( vsr8i, v8hi, Vb, u6)
/* Va, Vb, u8 (simm) instructions. */
STEST2 ( vmvaw, v8hi, Vb, u8)
STEST2 ( vmvw, v8hi, Vb, u8)
STEST2 ( vmvzw, v8hi, Vb, u8)
STEST2 (vd6tapf, v8hi, Vb, u8)
/* Va, rlimm, u8 (simm) instructions. */
STEST2 (vmovaw, v8hi, rlimm, u8)
STEST2 ( vmovw, v8hi, rlimm, u8)
STEST2 (vmovzw, v8hi, rlimm, u8)
/* Va, Vb instructions. */
STEST1 ( vabsaw, v8hi, Vb)
STEST1 ( vabsw, v8hi, Vb)
STEST1 (vaddsuw, v8hi, Vb)
STEST1 ( vsignw, v8hi, Vb)
STEST1 ( vexch1, v8hi, Vb)
STEST1 ( vexch2, v8hi, Vb)
STEST1 ( vexch4, v8hi, Vb)
STEST1 ( vupbaw, v8hi, Vb)
STEST1 ( vupbw, v8hi, Vb)
STEST1 (vupsbaw, v8hi, Vb)
STEST1 ( vupsbw, v8hi, Vb)
/* DIb, rlimm, rlimm instructions. */
STEST2 (vdirun, void, rlimm, rlimm)
STEST2 (vdorun, void, rlimm, rlimm)
/* DIb, limm, rlimm instructions. */
STEST2 (vdiwr, void, u3, rlimm)
STEST2 (vdowr, void, u3, rlimm)
/* rlimm instructions. */
STEST1 ( vrec, void, rlimm)
STEST1 ( vrun, void, rlimm)
STEST1 (vrecrun, void, rlimm)
STEST1 (vendrec, void, rlimm)
/* Va, [Ib,u8] instructions. */
STEST3 (vld32wh, v8hi, Vb, Ic, u8)
STEST3 (vld32wl, v8hi, Vb, Ic, u8)
STEST3 ( vld64, v8hi, Vb, Ic, u8)
STEST3 ( vld32, v8hi, Vb, Ic, u8)
STEST2 (vld64w, v8hi, Ib, u8)
STEST2 (vld128, v8hi, Ib, u8)
STEST3 (vst128, void, Va, Ib, u8)
STEST3 ( vst64, void, Va, Ib, u8)
/* Va, [Ib, u8] instructions. */
STEST4 (vst16_n, void, Va, u3, Ib, u8)
STEST4 (vst32_n, void, Va, u3, Ib, u8)
STEST1 (vinti, void, u6)
| /* { dg-do compile } */
/* { dg-skip-if "" { ! { clmcpu } } } */
/* { dg-options "-O2 -Werror-implicit-function-declaration -mARC700 -msimd" } */
#define STEST1(name, VAR_0, VAR_1) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1); \
}
#define STEST2(name, VAR_0, VAR_1, VAR_2) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2); \
}
#define STEST3(name, VAR_0, VAR_1, VAR_2, VAR_3) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2, op3); \
}
#define FUNC_0(name, VAR_0, VAR_1, VAR_2, VAR_3, op4) \
rettype test_ ## name \
(void) \
{ \
return __builtin_arc_ ## name (op1, op2, op3, op4); \
}
typedef short v8hi __attribute__ ((vector_size (16)));
v8hi VAR_5;
v8hi Vb;
v8hi Vc;
#define rlimm 0xf3eec0fe
#define Ic 0x02
#define VAR_6 0x02
#define u3 0x02
#define VAR_7 0x1F
#define u8 0xB0
STEST2 ( vaddaw, v8hi, Vb, Vc)
STEST2 ( VAR_8, v8hi, Vb, Vc)
STEST2 ( vavb, v8hi, Vb, Vc)
STEST2 ( VAR_9, v8hi, Vb, Vc)
STEST2 ( VAR_10, v8hi, Vb, Vc)
STEST2 ( VAR_11, v8hi, Vb, Vc)
STEST2 ( vmaxaw, v8hi, Vb, Vc)
STEST2 ( vmaxw, v8hi, Vb, Vc)
STEST2 ( VAR_12, v8hi, Vb, Vc)
STEST2 ( VAR_13, v8hi, Vb, Vc)
STEST2 ( vmulaw, v8hi, Vb, Vc)
STEST2 (VAR_14, v8hi, Vb, Vc)
STEST2 ( VAR_15, v8hi, Vb, Vc)
STEST2 ( VAR_16, v8hi, Vb, Vc)
STEST2 ( vsubaw, v8hi, Vb, Vc)
STEST2 ( vsubw, v8hi, Vb, Vc)
STEST2 ( vsummw, v8hi, Vb, Vc)
STEST2 ( vand, v8hi, Vb, Vc)
STEST2 ( vandaw, v8hi, Vb, Vc)
STEST2 ( VAR_17, v8hi, Vb, Vc)
STEST2 ( vbicaw, v8hi, Vb, Vc)
STEST2 ( vor, v8hi, Vb, Vc)
STEST2 ( vxor, v8hi, Vb, Vc)
STEST2 ( VAR_18, v8hi, Vb, Vc)
STEST2 ( veqw, v8hi, Vb, Vc)
STEST2 ( vlew, v8hi, Vb, Vc)
STEST2 ( vltw, v8hi, Vb, Vc)
STEST2 ( vnew, v8hi, Vb, Vc)
STEST2 ( vmr1aw, v8hi, Vb, Vc)
STEST2 ( VAR_19, v8hi, Vb, Vc)
STEST2 ( VAR_20, v8hi, Vb, Vc)
STEST2 ( vmr2w, v8hi, Vb, Vc)
STEST2 ( VAR_21, v8hi, Vb, Vc)
STEST2 ( vmr3w, v8hi, Vb, Vc)
STEST2 ( VAR_22, v8hi, Vb, Vc)
STEST2 ( VAR_23, v8hi, Vb, Vc)
STEST2 ( vmr5aw, v8hi, Vb, Vc)
STEST2 ( VAR_24, v8hi, Vb, Vc)
STEST2 ( vmr6aw, v8hi, Vb, Vc)
STEST2 ( vmr6w, v8hi, Vb, Vc)
STEST2 ( vmr7aw, v8hi, Vb, Vc)
STEST2 ( vmr7w, v8hi, Vb, Vc)
STEST2 ( vmrb, v8hi, Vb, Vc)
STEST2 ( VAR_25, v8hi, Vb, Vc)
STEST2 (VAR_26, v8hi, Vb, Vc)
STEST2 (vh264fw, v8hi, Vb, Vc)
STEST2 ( VAR_27, v8hi, Vb, Vc)
STEST2 ( VAR_28, v8hi, Vb, Vc)
STEST2 ( VAR_29, v8hi, Vb, rlimm)
STEST2 ( vbmaxw, v8hi, Vb, rlimm)
STEST2 ( VAR_30, v8hi, Vb, rlimm)
STEST2 (VAR_31, v8hi, Vb, rlimm)
STEST2 (vbmulfw, v8hi, Vb, rlimm)
STEST2 ( VAR_32, v8hi, Vb, rlimm)
STEST2 (VAR_33, v8hi, Vb, rlimm)
STEST2 ( VAR_34, v8hi, Vb, rlimm)
/* Va, Vb, Ic instructions. */
STEST2 ( VAR_35, v8hi, Vb, Ic)
STEST2 ( VAR_36, v8hi, Vb, Ic)
STEST2 (VAR_37, v8hi, Vb, Ic)
/* Va, Vb, u6 instructions. */
STEST2 ( vasrrwi, v8hi, Vb, VAR_7)
STEST2 ( vasrsrwi, v8hi, Vb, VAR_7)
STEST2 ( vasrwi, v8hi, Vb, VAR_7)
STEST2 ( VAR_38, v8hi, Vb, VAR_7)
STEST2 (vasrrpwbi, v8hi, Vb, VAR_7)
STEST2 ( vsr8awi, v8hi, Vb, VAR_7)
STEST2 ( vsr8i, v8hi, Vb, VAR_7)
/* Va, Vb, u8 (simm) instructions. */
STEST2 ( VAR_39, v8hi, Vb, u8)
STEST2 ( VAR_40, v8hi, Vb, u8)
STEST2 ( vmvzw, v8hi, Vb, u8)
STEST2 (vd6tapf, v8hi, Vb, u8)
/* Va, rlimm, u8 (simm) instructions. */
STEST2 (vmovaw, v8hi, rlimm, u8)
STEST2 ( VAR_41, v8hi, rlimm, u8)
STEST2 (vmovzw, v8hi, rlimm, u8)
/* Va, Vb instructions. */
STEST1 ( vabsaw, v8hi, Vb)
STEST1 ( VAR_42, v8hi, Vb)
STEST1 (vaddsuw, v8hi, Vb)
STEST1 ( vsignw, v8hi, Vb)
STEST1 ( vexch1, v8hi, Vb)
STEST1 ( vexch2, v8hi, Vb)
STEST1 ( vexch4, v8hi, Vb)
STEST1 ( VAR_43, v8hi, Vb)
STEST1 ( VAR_44, v8hi, Vb)
STEST1 (VAR_45, v8hi, Vb)
STEST1 ( vupsbw, v8hi, Vb)
/* DIb, rlimm, rlimm instructions. */
STEST2 (vdirun, VAR_46, rlimm, rlimm)
STEST2 (VAR_47, VAR_46, rlimm, rlimm)
/* DIb, limm, rlimm instructions. */
STEST2 (VAR_48, VAR_46, u3, rlimm)
STEST2 (vdowr, VAR_46, u3, rlimm)
/* rlimm instructions. */
STEST1 ( vrec, VAR_46, rlimm)
STEST1 ( vrun, VAR_46, rlimm)
STEST1 (VAR_49, VAR_46, rlimm)
STEST1 (vendrec, VAR_46, rlimm)
/* Va, [Ib,u8] instructions. */
STEST3 (vld32wh, v8hi, Vb, Ic, u8)
STEST3 (VAR_50, v8hi, Vb, Ic, u8)
STEST3 ( VAR_51, v8hi, Vb, Ic, u8)
STEST3 ( vld32, v8hi, Vb, Ic, u8)
STEST2 (VAR_52, v8hi, VAR_6, u8)
STEST2 (VAR_53, v8hi, VAR_6, u8)
STEST3 (vst128, VAR_46, VAR_5, VAR_6, u8)
STEST3 ( vst64, VAR_46, VAR_5, VAR_6, u8)
/* Va, [Ib, u8] instructions. */
VAR_4 (vst16_n, VAR_46, VAR_5, u3, VAR_6, u8)
VAR_4 (vst32_n, VAR_46, VAR_5, u3, VAR_6, u8)
STEST1 (VAR_54, VAR_46, VAR_7)
| 0.368563 | {'VAR_0': 'rettype', 'VAR_1': 'op1', 'VAR_2': 'op2', 'VAR_3': 'op3', 'FUNC_0': 'STEST4', 'VAR_4': 'STEST4', 'VAR_5': 'Va', 'VAR_6': 'Ib', 'VAR_7': 'u6', 'VAR_8': 'vaddw', 'VAR_9': 'vavrb', 'VAR_10': 'vdifaw', 'VAR_11': 'vdifw', 'VAR_12': 'vminaw', 'VAR_13': 'vminw', 'VAR_14': 'vmulfaw', 'VAR_15': 'vmulfw', 'VAR_16': 'vmulw', 'VAR_17': 'vbic', 'VAR_18': 'vxoraw', 'VAR_19': 'vmr1w', 'VAR_20': 'vmr2aw', 'VAR_21': 'vmr3aw', 'VAR_22': 'vmr4aw', 'VAR_23': 'vmr4w', 'VAR_24': 'vmr5w', 'VAR_25': 'vh264f', 'VAR_26': 'vh264ft', 'VAR_27': 'vvc1f', 'VAR_28': 'vvc1ft', 'VAR_29': 'vbaddw', 'VAR_30': 'vbminw', 'VAR_31': 'vbmulaw', 'VAR_32': 'vbmulw', 'VAR_33': 'vbrsubw', 'VAR_34': 'vbsubw', 'VAR_35': 'vasrw', 'VAR_36': 'vsr8', 'VAR_37': 'vsr8aw', 'VAR_38': 'vasrpwbi', 'VAR_39': 'vmvaw', 'VAR_40': 'vmvw', 'VAR_41': 'vmovw', 'VAR_42': 'vabsw', 'VAR_43': 'vupbaw', 'VAR_44': 'vupbw', 'VAR_45': 'vupsbaw', 'VAR_46': 'void', 'VAR_47': 'vdorun', 'VAR_48': 'vdiwr', 'VAR_49': 'vrecrun', 'VAR_50': 'vld32wl', 'VAR_51': 'vld64', 'VAR_52': 'vld64w', 'VAR_53': 'vld128', 'VAR_54': 'vinti'} | c | Texto | 0.11% |
// Sorts the slice array[low..high] where the indices are inclusive.
static void insertion_sort_slice_with_cb(PyroVM* vm, Value* array, size_t low, size_t high, Value callback) {
for (size_t i = low + 1; i <= high; i++) {
for (size_t j = i; j > low; j--) {
pyro_push(vm, callback);
pyro_push(vm, array[j]);
pyro_push(vm, array[j - 1]);
Value item_j_is_less_than_previous = pyro_call_function(vm, 2);
if (vm->halt_flag) {
return;
}
if (!IS_BOOL(item_j_is_less_than_previous)) {
pyro_panic(vm, ERR_TYPE_ERROR, "Comparison function must return a boolean.");
return;
}
if (item_j_is_less_than_previous.as.boolean) {
swap(&array[j], &array[j - 1]);
} else {
break;
}
}
}
} | // Sorts the slice array[low..high] where the indices are inclusive.
static void FUNC_0(CLASS_0* vm, CLASS_1* VAR_0, size_t VAR_1, size_t high, CLASS_1 VAR_2) {
for (size_t VAR_3 = VAR_1 + 1; VAR_3 <= high; VAR_3++) {
for (size_t VAR_4 = VAR_3; VAR_4 > VAR_1; VAR_4--) {
FUNC_1(vm, VAR_2);
FUNC_1(vm, VAR_0[VAR_4]);
FUNC_1(vm, VAR_0[VAR_4 - 1]);
CLASS_1 VAR_5 = FUNC_2(vm, 2);
if (vm->halt_flag) {
return;
}
if (!IS_BOOL(VAR_5)) {
pyro_panic(vm, ERR_TYPE_ERROR, "Comparison function must return a boolean.");
return;
}
if (VAR_5.VAR_6.boolean) {
FUNC_3(&VAR_0[VAR_4], &VAR_0[VAR_4 - 1]);
} else {
break;
}
}
}
} | 0.690893 | {'FUNC_0': 'insertion_sort_slice_with_cb', 'CLASS_0': 'PyroVM', 'CLASS_1': 'Value', 'VAR_0': 'array', 'VAR_1': 'low', 'VAR_2': 'callback', 'VAR_3': 'i', 'VAR_4': 'j', 'FUNC_1': 'pyro_push', 'VAR_5': 'item_j_is_less_than_previous', 'FUNC_2': 'pyro_call_function', 'VAR_6': 'as', 'FUNC_3': 'swap'} | c | Procedural | 100.00% |
/*
* Copyright (c) 2014-2018 Cesanta Software Limited
* 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.
*/
/*
* HAL that needs to be implemented for each hardware platform.
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Get system memory size. */
size_t mgos_get_heap_size(void);
/* Get system free memory. */
size_t mgos_get_free_heap_size(void);
/* Get minimal watermark of the system free memory. */
size_t mgos_get_min_free_heap_size(void);
/* Get filesystem memory usage */
size_t mgos_get_fs_memory_usage(void);
/*
* Get filesystem size.
* Deprecated, please use mgos_vfs_get_space_total("/") instead.
*/
size_t mgos_get_fs_size(void);
/*
* Get filesystem free space.
* Deprecated, please use mgos_vfs_get_space_free("/") instead.
*/
size_t mgos_get_free_fs_size(void);
/* Garbage-collect filesystem */
void mgos_fs_gc(void);
/* Feed watchdog */
void mgos_wdt_feed(void);
/* Set watchdog timeout*/
void mgos_wdt_set_timeout(int secs);
/* Enable watchdog */
void mgos_wdt_enable(void);
/* Disable watchdog */
void mgos_wdt_disable(void);
/* Restart system */
void mgos_system_restart(void) __attribute__((noreturn));
/* Delay given number of milliseconds */
void mgos_msleep(uint32_t msecs);
/* Delay given number of microseconds */
void mgos_usleep(uint32_t usecs);
extern void (*mgos_nsleep100)(uint32_t n);
/* Disable interrupts */
void mgos_ints_disable(void);
/* Enable interrupts */
void mgos_ints_enable(void);
/* Callback for `mgos_invoke_cb()` */
typedef void (*mgos_cb_t)(void *arg);
#define MGOS_INVOKE_CB_F_FROM_ISR (1 << 0)
#define MGOS_INVOKE_CB_F_BG_TASK (1 << 1)
/*
* Schedule a callback for execution.
*
* By default callbacks are executed on the main task.
* MGOS_INVOKE_CB_F_BG_TASK can be used to execute on a background task
* (if platform provides a separate task for this purpose).
*
* Returns true if the callback has been scheduled for execution.
*/
bool mgos_invoke_cb(mgos_cb_t cb, void *arg, uint32_t flags);
/* Get the CPU frequency in Hz */
uint32_t mgos_get_cpu_freq(void);
/* Opaque recursive lock type. */
struct mgos_rlock_type;
/* Create a recursive lock. */
struct mgos_rlock_type *mgos_rlock_create(void);
/* Acquire a recursive lock. */
void mgos_rlock(struct mgos_rlock_type *l);
/* Release a recursive lock. */
void mgos_runlock(struct mgos_rlock_type *l);
/* Destroy a recursive lock. */
void mgos_rlock_destroy(struct mgos_rlock_type *l);
/*
* Converts integer to string in given base (2 to 16).
* Returns number of characters written, excluding '\0'.
*/
int mgos_itoa(int value, char *out, int base);
/*
* Converts unsigned integer to string in given base (2 to 16).
* Returns number of characters written, excluding '\0'.
*/
int mgos_utoa(unsigned int value, char *out, int base);
#ifdef __cplusplus
}
#endif
| /*
* Copyright (c) 2014-2018 Cesanta Software Limited
* 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.
*/
/*
* HAL that needs to be implemented for each hardware platform.
*/
#pragma once
#include <stdbool.h>
#include <IMPORT_0>
#include <stdlib.h>
#ifdef VAR_0
extern "C" {
#endif
/* Get system memory size. */
size_t mgos_get_heap_size(void);
/* Get system free memory. */
size_t FUNC_0(void);
/* Get minimal watermark of the system free memory. */
size_t FUNC_1(void);
/* Get filesystem memory usage */
size_t mgos_get_fs_memory_usage(void);
/*
* Get filesystem size.
* Deprecated, please use mgos_vfs_get_space_total("/") instead.
*/
size_t FUNC_2(void);
/*
* Get filesystem free space.
* Deprecated, please use mgos_vfs_get_space_free("/") instead.
*/
size_t mgos_get_free_fs_size(void);
/* Garbage-collect filesystem */
void FUNC_3(void);
/* Feed watchdog */
void mgos_wdt_feed(void);
/* Set watchdog timeout*/
void mgos_wdt_set_timeout(int VAR_1);
/* Enable watchdog */
void FUNC_4(void);
/* Disable watchdog */
void FUNC_5(void);
/* Restart system */
void mgos_system_restart(void) __attribute__((noreturn));
/* Delay given number of milliseconds */
void FUNC_6(uint32_t msecs);
/* Delay given number of microseconds */
void FUNC_7(uint32_t VAR_2);
extern void (*VAR_3)(uint32_t VAR_4);
/* Disable interrupts */
void FUNC_8(void);
/* Enable interrupts */
void FUNC_9(void);
/* Callback for `mgos_invoke_cb()` */
typedef void (*CLASS_0)(void *arg);
#define MGOS_INVOKE_CB_F_FROM_ISR (1 << 0)
#define MGOS_INVOKE_CB_F_BG_TASK (1 << 1)
/*
* Schedule a callback for execution.
*
* By default callbacks are executed on the main task.
* MGOS_INVOKE_CB_F_BG_TASK can be used to execute on a background task
* (if platform provides a separate task for this purpose).
*
* Returns true if the callback has been scheduled for execution.
*/
bool FUNC_10(CLASS_0 VAR_5, void *arg, uint32_t VAR_6);
/* Get the CPU frequency in Hz */
uint32_t FUNC_11(void);
/* Opaque recursive lock type. */
struct CLASS_1;
/* Create a recursive lock. */
struct CLASS_1 *FUNC_12(void);
/* Acquire a recursive lock. */
void mgos_rlock(struct CLASS_1 *l);
/* Release a recursive lock. */
void FUNC_13(struct CLASS_1 *l);
/* Destroy a recursive lock. */
void FUNC_14(struct CLASS_1 *l);
/*
* Converts integer to string in given base (2 to 16).
* Returns number of characters written, excluding '\0'.
*/
int FUNC_15(int VAR_7, char *VAR_8, int VAR_9);
/*
* Converts unsigned integer to string in given base (2 to 16).
* Returns number of characters written, excluding '\0'.
*/
int FUNC_16(unsigned int VAR_7, char *VAR_8, int VAR_9);
#ifdef VAR_0
}
#endif
| 0.694782 | {'IMPORT_0': 'stdint.h', 'VAR_0': '__cplusplus', 'FUNC_0': 'mgos_get_free_heap_size', 'FUNC_1': 'mgos_get_min_free_heap_size', 'FUNC_2': 'mgos_get_fs_size', 'FUNC_3': 'mgos_fs_gc', 'VAR_1': 'secs', 'FUNC_4': 'mgos_wdt_enable', 'FUNC_5': 'mgos_wdt_disable', 'FUNC_6': 'mgos_msleep', 'FUNC_7': 'mgos_usleep', 'VAR_2': 'usecs', 'VAR_3': 'mgos_nsleep100', 'VAR_4': 'n', 'FUNC_8': 'mgos_ints_disable', 'FUNC_9': 'mgos_ints_enable', 'CLASS_0': 'mgos_cb_t', 'FUNC_10': 'mgos_invoke_cb', 'VAR_5': 'cb', 'VAR_6': 'flags', 'FUNC_11': 'mgos_get_cpu_freq', 'CLASS_1': 'mgos_rlock_type', 'FUNC_12': 'mgos_rlock_create', 'FUNC_13': 'mgos_runlock', 'FUNC_14': 'mgos_rlock_destroy', 'FUNC_15': 'mgos_itoa', 'VAR_7': 'value', 'VAR_8': 'out', 'VAR_9': 'base', 'FUNC_16': 'mgos_utoa'} | c | Procedural | 24.69% |
//
// ReportsFilterViewController.h
// CityWatch
//
// Copyright 2012-2013 Kinvey, Inc
//
// 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>
typedef enum : NSUInteger {
FilterOptionAll = 0,
FilterOptionMine
} FilterOption;
typedef enum : NSUInteger {
SortOptionRecent = 0,
SortOptionDistance
} SortOption;
extern NSString *const kFilterOptionKey;
extern NSString *const kSortOptionKey;
@protocol ReportsFilterViewControllerDelegate
- (void)reportFilterEditingFinishedWithOptions:(NSDictionary *)options;
- (void)reportFilterEditingFinishedWithFilterOption:(NSInteger)filterRow sortOption:(NSInteger)sortRow;
@end
@interface ReportsFilterViewController : UITableViewController
@property FilterOption selectedFilterOption;
@property SortOption selectedSortOption;
@property (weak, nonatomic) id <ReportsFilterViewControllerDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITableViewCell *allReportsCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *myReportsCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *datePostedCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *distanceCell;
@end
| //
// ReportsFilterViewController.h
// CityWatch
//
// Copyright 2012-2013 Kinvey, Inc
//
// 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>
typedef enum : NSUInteger {
FilterOptionAll = 0,
FilterOptionMine
} FilterOption;
typedef enum : NSUInteger {
SortOptionRecent = 0,
SortOptionDistance
} SortOption;
extern NSString *const kFilterOptionKey;
extern NSString *const kSortOptionKey;
@protocol ReportsFilterViewControllerDelegate
- (void)reportFilterEditingFinishedWithOptions:(NSDictionary *)options;
- (void)reportFilterEditingFinishedWithFilterOption:(NSInteger)filterRow sortOption:(NSInteger)sortRow;
@end
@interface ReportsFilterViewController : UITableViewController
@property FilterOption selectedFilterOption;
@property SortOption selectedSortOption;
@property (weak, nonatomic) id <ReportsFilterViewControllerDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITableViewCell *allReportsCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *myReportsCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *datePostedCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *distanceCell;
@end
| 0.032127 | {} | c | Procedural | 50.26% |
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AudioEditorModule.h"
class FSoundWaveAssetActionExtender : public ISoundWaveAssetActionExtensions,
public TSharedFromThis<FSoundWaveAssetActionExtender>
{
public:
virtual ~FSoundWaveAssetActionExtender() {}
virtual void GetExtendedActions(const TArray<TWeakObjectPtr<USoundWave>>& InObjects, FMenuBuilder& MenuBuilder) override;
void ExecuteCreateSimpleSound(TArray<TWeakObjectPtr<USoundWave>> Objects);
};
| // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AudioEditorModule.h"
class FSoundWaveAssetActionExtender : public VAR_0,
public VAR_1<FSoundWaveAssetActionExtender>
{
public:
virtual ~FSoundWaveAssetActionExtender() {}
virtual void GetExtendedActions(const CLASS_0<VAR_2<VAR_3>>& InObjects, CLASS_1& MenuBuilder) override;
void ExecuteCreateSimpleSound(CLASS_0<VAR_2<VAR_3>> Objects);
};
| 0.251495 | {'VAR_0': 'ISoundWaveAssetActionExtensions', 'VAR_1': 'TSharedFromThis', 'CLASS_0': 'TArray', 'VAR_2': 'TWeakObjectPtr', 'VAR_3': 'USoundWave', 'CLASS_1': 'FMenuBuilder'} | c | Texto | 38.30% |
//========================================================================================
//
// $File: TextTools.h $
//
// $Revision: #4 $
//
// Copyright 1987-2007 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
/*******************************************************************************
**
** PROTOTYPES
**
**/
#include "common.h"
#define ttObjectArt 1
#define ttTextArt 2
#define ttUnknownArt 4
#define MICR_FONT_NAME "MICR"
#define BARCODE_FONT_NAME "IDAutomationC39XS"
#define LASER_BARCODE_OFFSET 25
#define MICR_LINE_LABEL ai::UnicodeString("__MICR_LINE__")
#define MICR_BARCODE_LABEL ai::UnicodeString("__MICR_BARCODE__")
bool ConvertToPointType();
bool Align(ATE::ParagraphJustification alignStyle);
//This is the main Align function. It checks what type of art is selected in the document and calls the appropriate align funcs
//for each different type of art
void AlignText(AIArtSet* artSet, ATE::ParagraphJustification alignStyle);
void AlignText(AIArtHandle currArt, ATE::ParagraphJustification alignStyle);
void AlignPointType(AIArtHandle currArt, ATE::ParagraphJustification alignStyle);
//Changes the alignment of text objects without changing their location.
//The artset version should only be called with an artset that only contains text art.
//If a key object is selected, aligns the text objects to the key object.
//If there is no key object selected, it simply adjusts the paragraph justification.
void AlignObject(AIArtSet* artSet, ATE::ParagraphJustification alignStyle);
//Main loop for aligning objects
//The bounds of each root object are determined, then passed to:
void AlignObject(AIArtHandle root, AIArtHandle currArtHandle, AIRealRect selBounds, AIArtSet* artSet, ATE::ParagraphJustification alignStyle);
//Changes the alignment of art objects.
//All children of the root object are moved
//The bounds of the selected parts of the root object must be supplied. These can be adjusted for various effects on alignment.
//If a key object is selected, aligns all art objects to the key object.
//If no key object is selected, aligns all art objects to the page.
short GetTypesFromArtSet(AIArtSet* artSet);
void RemoveChildrenFromArtSet(AIArtHandle root, AIArtHandle currArtHandle, AIArtSet* artSet);
bool CreateMICRBarcode();
ai::UnicodeString CreateBarcodeStringFromMICRString(ai::UnicodeString micrString);
void FindBarcodeAnchorPoint(AIRealPoint* anchor); | //========================================================================================
//
// $File: TextTools.h $
//
// $Revision: #4 $
//
// Copyright 1987-2007 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
/*******************************************************************************
**
** PROTOTYPES
**
**/
#include "common.h"
#define VAR_0 1
#define VAR_1 2
#define ttUnknownArt 4
#define MICR_FONT_NAME "MICR"
#define BARCODE_FONT_NAME "IDAutomationC39XS"
#define LASER_BARCODE_OFFSET 25
#define VAR_2 ai::UnicodeString("__MICR_LINE__")
#define VAR_3 ai::UnicodeString("__MICR_BARCODE__")
bool ConvertToPointType();
bool FUNC_0(CLASS_0::ParagraphJustification alignStyle);
//This is the main Align function. It checks what type of art is selected in the document and calls the appropriate align funcs
//for each different type of art
void FUNC_1(CLASS_1* artSet, CLASS_0::ParagraphJustification alignStyle);
void FUNC_1(CLASS_2 VAR_4, CLASS_0::ParagraphJustification alignStyle);
void FUNC_2(CLASS_2 VAR_4, CLASS_0::ParagraphJustification alignStyle);
//Changes the alignment of text objects without changing their location.
//The artset version should only be called with an artset that only contains text art.
//If a key object is selected, aligns the text objects to the key object.
//If there is no key object selected, it simply adjusts the paragraph justification.
void AlignObject(CLASS_1* artSet, CLASS_0::ParagraphJustification alignStyle);
//Main loop for aligning objects
//The bounds of each root object are determined, then passed to:
void AlignObject(CLASS_2 root, CLASS_2 currArtHandle, AIRealRect selBounds, CLASS_1* artSet, CLASS_0::ParagraphJustification alignStyle);
//Changes the alignment of art objects.
//All children of the root object are moved
//The bounds of the selected parts of the root object must be supplied. These can be adjusted for various effects on alignment.
//If a key object is selected, aligns all art objects to the key object.
//If no key object is selected, aligns all art objects to the page.
short GetTypesFromArtSet(CLASS_1* artSet);
void RemoveChildrenFromArtSet(CLASS_2 root, CLASS_2 currArtHandle, CLASS_1* artSet);
bool CreateMICRBarcode();
ai::UnicodeString FUNC_3(VAR_5::UnicodeString micrString);
void FindBarcodeAnchorPoint(AIRealPoint* anchor); | 0.424201 | {'VAR_0': 'ttObjectArt', 'VAR_1': 'ttTextArt', 'VAR_2': 'MICR_LINE_LABEL', 'VAR_3': 'MICR_BARCODE_LABEL', 'FUNC_0': 'Align', 'CLASS_0': 'ATE', 'FUNC_1': 'AlignText', 'CLASS_1': 'AIArtSet', 'CLASS_2': 'AIArtHandle', 'VAR_4': 'currArt', 'FUNC_2': 'AlignPointType', 'VAR_5': 'ai', 'FUNC_3': 'CreateBarcodeStringFromMICRString'} | c | Procedural | 100.00% |
// SPDX-License-Identifier: GPL-2.0
/*
* Amlogic Meson VPU Power Domain Controller driver
*
* Copyright (c) 2018 BayLibre, SAS.
* Author: <NAME> <<EMAIL>>
*/
#include <common.h>
#include <dm.h>
#include <power-domain-uclass.h>
#include <regmap.h>
#include <syscon.h>
#include <reset.h>
#include <clk.h>
/* AO Offsets */
#define AO_RTI_GEN_PWR_SLEEP0 (0x3a << 2)
#define GEN_PWR_VPU_HDMI BIT(8)
#define GEN_PWR_VPU_HDMI_ISO BIT(9)
/* HHI Offsets */
#define HHI_MEM_PD_REG0 (0x40 << 2)
#define HHI_VPU_MEM_PD_REG0 (0x41 << 2)
#define HHI_VPU_MEM_PD_REG1 (0x42 << 2)
struct meson_gx_pwrc_vpu_priv {
struct regmap *regmap_ao;
struct regmap *regmap_hhi;
struct reset_ctl_bulk resets;
struct clk_bulk clks;
};
static int meson_gx_pwrc_vpu_request(struct power_domain *power_domain)
{
return 0;
}
static int meson_gx_pwrc_vpu_free(struct power_domain *power_domain)
{
return 0;
}
static int meson_gx_pwrc_vpu_on(struct power_domain *power_domain)
{
struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(power_domain->dev);
int i, ret;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI, 0);
udelay(20);
/* Power Up Memories */
for (i = 0; i < 32; i += 2) {
regmap_update_bits(priv->regmap_hhi, HHI_VPU_MEM_PD_REG0,
0x3 << i, 0);
udelay(5);
}
for (i = 0; i < 32; i += 2) {
regmap_update_bits(priv->regmap_hhi, HHI_VPU_MEM_PD_REG1,
0x3 << i, 0);
udelay(5);
}
for (i = 8; i < 16; i++) {
regmap_update_bits(priv->regmap_hhi, HHI_MEM_PD_REG0,
BIT(i), 0);
udelay(5);
}
udelay(20);
ret = reset_assert_bulk(&priv->resets);
if (ret)
return ret;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI_ISO, 0);
ret = reset_deassert_bulk(&priv->resets);
if (ret)
return ret;
ret = clk_enable_bulk(&priv->clks);
if (ret)
return ret;
return 0;
}
static int meson_gx_pwrc_vpu_off(struct power_domain *power_domain)
{
struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(power_domain->dev);
int i;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI_ISO, GEN_PWR_VPU_HDMI_ISO);
udelay(20);
/* Power Down Memories */
for (i = 0; i < 32; i += 2) {
regmap_update_bits(priv->regmap_hhi, HHI_VPU_MEM_PD_REG0,
0x3 << i, 0x3 << i);
udelay(5);
}
for (i = 0; i < 32; i += 2) {
regmap_update_bits(priv->regmap_hhi, HHI_VPU_MEM_PD_REG1,
0x3 << i, 0x3 << i);
udelay(5);
}
for (i = 8; i < 16; i++) {
regmap_update_bits(priv->regmap_hhi, HHI_MEM_PD_REG0,
BIT(i), BIT(i));
udelay(5);
}
udelay(20);
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI, GEN_PWR_VPU_HDMI);
mdelay(20);
clk_disable_bulk(&priv->clks);
return 0;
}
static int meson_gx_pwrc_vpu_of_xlate(struct power_domain *power_domain,
struct ofnode_phandle_args *args)
{
/* #power-domain-cells is 0 */
if (args->args_count != 0) {
debug("Invalid args_count: %d\n", args->args_count);
return -EINVAL;
}
return 0;
}
struct power_domain_ops meson_gx_pwrc_vpu_ops = {
.free = meson_gx_pwrc_vpu_free,
.off = meson_gx_pwrc_vpu_off,
.on = meson_gx_pwrc_vpu_on,
.request = meson_gx_pwrc_vpu_request,
.of_xlate = meson_gx_pwrc_vpu_of_xlate,
};
static const struct udevice_id meson_gx_pwrc_vpu_ids[] = {
{ .compatible = "amlogic,meson-gx-pwrc-vpu" },
{ }
};
static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
{
struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(dev);
u32 hhi_phandle;
ofnode hhi_node;
int ret;
priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node);
if (IS_ERR(priv->regmap_ao))
return PTR_ERR(priv->regmap_ao);
ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl",
&hhi_phandle);
if (ret)
return ret;
hhi_node = ofnode_get_by_phandle(hhi_phandle);
if (!ofnode_valid(hhi_node))
return -EINVAL;
priv->regmap_hhi = syscon_node_to_regmap(hhi_node);
if (IS_ERR(priv->regmap_hhi))
return PTR_ERR(priv->regmap_hhi);
ret = reset_get_bulk(dev, &priv->resets);
if (ret)
return ret;
ret = clk_get_bulk(dev, &priv->clks);
if (ret)
return ret;
return 0;
}
U_BOOT_DRIVER(meson_gx_pwrc_vpu) = {
.name = "meson_gx_pwrc_vpu",
.id = UCLASS_POWER_DOMAIN,
.of_match = meson_gx_pwrc_vpu_ids,
.probe = meson_gx_pwrc_vpu_probe,
.ops = &meson_gx_pwrc_vpu_ops,
.priv_auto_alloc_size = sizeof(struct meson_gx_pwrc_vpu_priv),
};
| // SPDX-License-Identifier: GPL-2.0
/*
* Amlogic Meson VPU Power Domain Controller driver
*
* Copyright (c) 2018 BayLibre, SAS.
* Author: <NAME> <<EMAIL>>
*/
#include <common.h>
#include <dm.h>
#include <power-domain-uclass.h>
#include <regmap.h>
#include <syscon.h>
#include <IMPORT_0>
#include <clk.h>
/* AO Offsets */
#define AO_RTI_GEN_PWR_SLEEP0 (0x3a << 2)
#define GEN_PWR_VPU_HDMI BIT(8)
#define GEN_PWR_VPU_HDMI_ISO BIT(9)
/* HHI Offsets */
#define HHI_MEM_PD_REG0 (0x40 << 2)
#define HHI_VPU_MEM_PD_REG0 (0x41 << 2)
#define HHI_VPU_MEM_PD_REG1 (0x42 << 2)
struct CLASS_0 {
struct regmap *regmap_ao;
struct regmap *VAR_0;
struct reset_ctl_bulk resets;
struct CLASS_1 clks;
};
static int meson_gx_pwrc_vpu_request(struct power_domain *power_domain)
{
return 0;
}
static int meson_gx_pwrc_vpu_free(struct power_domain *power_domain)
{
return 0;
}
static int meson_gx_pwrc_vpu_on(struct power_domain *power_domain)
{
struct CLASS_0 *priv = FUNC_0(power_domain->VAR_1);
int VAR_2, ret;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI, 0);
udelay(20);
/* Power Up Memories */
for (VAR_2 = 0; VAR_2 < 32; VAR_2 += 2) {
regmap_update_bits(priv->VAR_0, HHI_VPU_MEM_PD_REG0,
0x3 << VAR_2, 0);
udelay(5);
}
for (VAR_2 = 0; VAR_2 < 32; VAR_2 += 2) {
regmap_update_bits(priv->VAR_0, HHI_VPU_MEM_PD_REG1,
0x3 << VAR_2, 0);
udelay(5);
}
for (VAR_2 = 8; VAR_2 < 16; VAR_2++) {
regmap_update_bits(priv->VAR_0, HHI_MEM_PD_REG0,
BIT(VAR_2), 0);
udelay(5);
}
udelay(20);
ret = reset_assert_bulk(&priv->resets);
if (ret)
return ret;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI_ISO, 0);
ret = reset_deassert_bulk(&priv->resets);
if (ret)
return ret;
ret = clk_enable_bulk(&priv->clks);
if (ret)
return ret;
return 0;
}
static int FUNC_1(struct power_domain *power_domain)
{
struct CLASS_0 *priv = FUNC_0(power_domain->VAR_1);
int VAR_2;
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI_ISO, GEN_PWR_VPU_HDMI_ISO);
udelay(20);
/* Power Down Memories */
for (VAR_2 = 0; VAR_2 < 32; VAR_2 += 2) {
regmap_update_bits(priv->VAR_0, HHI_VPU_MEM_PD_REG0,
0x3 << VAR_2, 0x3 << VAR_2);
udelay(5);
}
for (VAR_2 = 0; VAR_2 < 32; VAR_2 += 2) {
regmap_update_bits(priv->VAR_0, HHI_VPU_MEM_PD_REG1,
0x3 << VAR_2, 0x3 << VAR_2);
udelay(5);
}
for (VAR_2 = 8; VAR_2 < 16; VAR_2++) {
regmap_update_bits(priv->VAR_0, HHI_MEM_PD_REG0,
BIT(VAR_2), BIT(VAR_2));
udelay(5);
}
udelay(20);
regmap_update_bits(priv->regmap_ao, AO_RTI_GEN_PWR_SLEEP0,
GEN_PWR_VPU_HDMI, GEN_PWR_VPU_HDMI);
mdelay(20);
FUNC_2(&priv->clks);
return 0;
}
static int FUNC_3(struct power_domain *power_domain,
struct ofnode_phandle_args *args)
{
/* #power-domain-cells is 0 */
if (args->args_count != 0) {
debug("Invalid args_count: %d\n", args->args_count);
return -EINVAL;
}
return 0;
}
struct power_domain_ops meson_gx_pwrc_vpu_ops = {
.free = meson_gx_pwrc_vpu_free,
.off = VAR_3,
.on = meson_gx_pwrc_vpu_on,
.request = meson_gx_pwrc_vpu_request,
.VAR_5 = VAR_4,
};
static const struct CLASS_2 meson_gx_pwrc_vpu_ids[] = {
{ .compatible = "amlogic,meson-gx-pwrc-vpu" },
{ }
};
static int meson_gx_pwrc_vpu_probe(struct udevice *VAR_1)
{
struct CLASS_0 *priv = FUNC_0(VAR_1);
u32 hhi_phandle;
ofnode VAR_6;
int ret;
priv->regmap_ao = FUNC_4(dev_get_parent(VAR_1)->node);
if (IS_ERR(priv->regmap_ao))
return PTR_ERR(priv->regmap_ao);
ret = FUNC_5(VAR_1->node, "amlogic,hhi-sysctrl",
&hhi_phandle);
if (ret)
return ret;
VAR_6 = FUNC_6(hhi_phandle);
if (!ofnode_valid(VAR_6))
return -EINVAL;
priv->VAR_0 = FUNC_4(VAR_6);
if (IS_ERR(priv->VAR_0))
return PTR_ERR(priv->VAR_0);
ret = reset_get_bulk(VAR_1, &priv->resets);
if (ret)
return ret;
ret = FUNC_7(VAR_1, &priv->clks);
if (ret)
return ret;
return 0;
}
U_BOOT_DRIVER(VAR_7) = {
.name = "meson_gx_pwrc_vpu",
.id = UCLASS_POWER_DOMAIN,
.of_match = meson_gx_pwrc_vpu_ids,
.VAR_8 = meson_gx_pwrc_vpu_probe,
.ops = &meson_gx_pwrc_vpu_ops,
.priv_auto_alloc_size = sizeof(struct CLASS_0),
};
| 0.255117 | {'IMPORT_0': 'reset.h', 'CLASS_0': 'meson_gx_pwrc_vpu_priv', 'VAR_0': 'regmap_hhi', 'CLASS_1': 'clk_bulk', 'FUNC_0': 'dev_get_priv', 'VAR_1': 'dev', 'VAR_2': 'i', 'FUNC_1': 'meson_gx_pwrc_vpu_off', 'VAR_3': 'meson_gx_pwrc_vpu_off', 'FUNC_2': 'clk_disable_bulk', 'FUNC_3': 'meson_gx_pwrc_vpu_of_xlate', 'VAR_4': 'meson_gx_pwrc_vpu_of_xlate', 'VAR_5': 'of_xlate', 'CLASS_2': 'udevice_id', 'VAR_6': 'hhi_node', 'FUNC_4': 'syscon_node_to_regmap', 'FUNC_5': 'ofnode_read_u32', 'FUNC_6': 'ofnode_get_by_phandle', 'FUNC_7': 'clk_get_bulk', 'VAR_7': 'meson_gx_pwrc_vpu', 'VAR_8': 'probe'} | c | Hibrido | 16.98% |
#pragma once
namespace Graphics
{
enum DataType
{
Float, Int
};
} | #pragma once
namespace Graphics
{
enum DataType
{
Float, Int
};
} | 0.138547 | {} | c | Texto | 41.67% |
#include <stdio.h>
#include <string.h>
int main(void){
int j,i=0; int con=0;
int count[1000]={0};
char word[1000][33]={0};
int maxlen,maxcon,len;
while( scanf("%s", &word[i])!= EOF){
con++; /*単語数*/
for(j=0; j<i-1;j++)
if(strcmp(&word[i][0],&word[j][0])==0) {count[j]++; break;};
i++;
};
maxlen=strlen(&word[0][0]);
maxcon=count[0];
for(i=1; i<con; i++) {
len=strlen(&word[i][0]);
if(maxlen<len) maxlen=len;
if(maxcon<count[i]) maxcon=count[i];
};
for(i=0;i<con;i++){
len=strlen(&word[i][0]);
if(len==maxlen) break;
};
for(j=0;j<con;j++) if(maxcon==count[j]) break;
printf("%s %s\n", &word[j][0],&word[i][0]);
return (0);
} | #include <IMPORT_0>
#include <string.h>
int FUNC_0(void){
int VAR_0,i=0; int VAR_1=0;
int VAR_2[1000]={0};
char word[1000][33]={0};
int VAR_3,VAR_4,VAR_5;
while( FUNC_1("%s", &word[i])!= EOF){
VAR_1++; /*単語数*/
for(VAR_0=0; VAR_0<i-1;VAR_0++)
if(strcmp(&word[i][0],&word[VAR_0][0])==0) {VAR_2[VAR_0]++; break;};
i++;
};
VAR_3=FUNC_2(&word[0][0]);
VAR_4=VAR_2[0];
for(i=1; i<VAR_1; i++) {
VAR_5=FUNC_2(&word[i][0]);
if(VAR_3<VAR_5) VAR_3=VAR_5;
if(VAR_4<VAR_2[i]) VAR_4=VAR_2[i];
};
for(i=0;i<VAR_1;i++){
VAR_5=FUNC_2(&word[i][0]);
if(VAR_5==VAR_3) break;
};
for(VAR_0=0;VAR_0<VAR_1;VAR_0++) if(VAR_4==VAR_2[VAR_0]) break;
FUNC_3("%s %s\n", &word[VAR_0][0],&word[i][0]);
return (0);
} | 0.559205 | {'IMPORT_0': 'stdio.h', 'FUNC_0': 'main', 'VAR_0': 'j', 'VAR_1': 'con', 'VAR_2': 'count', 'VAR_3': 'maxlen', 'VAR_4': 'maxcon', 'VAR_5': 'len', 'FUNC_1': 'scanf', 'FUNC_2': 'strlen', 'FUNC_3': 'printf'} | c | Procedural | 100.00% |
/*
* Gamedev Framework (gf)
* Copyright (C) 2016-2019 <NAME>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef GF_RENDER_PIPELINE_H
#define GF_RENDER_PIPELINE_H
#include <vector>
#include "Effects.h"
#include "Portability.h"
#include "RenderTarget.h"
#include "Ref.h"
namespace gf {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
inline namespace v1 {
#endif
class Effect;
class Window;
/**
* @ingroup graphics
* @brief A render pipeline
*
* A render pipeline automates the application of post-processing effects.
* A good way to use this class is to make a subclass with all the effects
* you want to add.
*
* ~~~{.cc}
* class MyPipeline : public gf::RenderPipeline {
* public:
* MyPipeline(gf::Window& window)
* : gf::RenderPipeline(window)
* {
* addEffect(m_effect);
* addEffect(m_other);
* }
*
* protected:
* virtual void onFramebufferResize(Vector2i size) override {
* // update effects with size
* }
*
* private:
* MyEffect m_effect;
* MyOtherEffect m_other;
* };
* ~~~
*
* @sa gf::Effect
*/
class GF_API RenderPipeline : public RenderTarget {
public:
/**
* @brief Constructor
*
* @param window The window to render to
*/
RenderPipeline(Window& window);
/**
* @brief Add an effect to the pipeline
*
* @param effect The effect
*/
void addEffect(Effect& effect);
/**
* @brief Clear the pipeline
*/
void clearEffects();
/**
* @brief Update the size of the target
*
* This function must be called when the window change its size, before
* anything is drawn on the target. You can do it in the event processing.
*
* ~~~{.cc}
* gf::Event event;
*
* // ...
*
* switch (event.type) {
* case gf::EventType::Resized:
* renderer.resized();
* break;
*
* // ...
* }
* ~~~
*/
void resized();
virtual Vector2i getSize() const override;
/**
* @brief Apply the effects and display what has been rendered
*/
void display();
protected:
/**
* @brief Callback when the screen has just been resized
*
* This function is called by resized() with the correct size.
*
* @param size The new framebuffer size
*/
virtual void onFramebufferResize(Vector2i size);
private:
Window& m_window;
struct TextureBuffer {
Texture texture;
GraphicsHandle<GraphicsTag::Framebuffer> framebuffer;
};
TextureBuffer m_buffers[2];
int m_current;
DefaultEffect m_defaultEffect;
std::vector<Ref<Effect>> m_effects;
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
}
#endif
}
#endif // GF_RENDER_PIPELINE_H
| /*
* Gamedev Framework (gf)
* Copyright (C) 2016-2019 <NAME>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef GF_RENDER_PIPELINE_H
#define GF_RENDER_PIPELINE_H
#include <vector>
#include "Effects.h"
#include "IMPORT_0"
#include "RenderTarget.h"
#include "Ref.h"
CLASS_0 gf {
#ifndef DOXYGEN_SHOULD_SKIP_THIS
inline CLASS_0 v1 {
#endif
class Effect;
class VAR_0;
/**
* @ingroup graphics
* @brief A render pipeline
*
* A render pipeline automates the application of post-processing effects.
* A good way to use this class is to make a subclass with all the effects
* you want to add.
*
* ~~~{.cc}
* class MyPipeline : public gf::RenderPipeline {
* public:
* MyPipeline(gf::Window& window)
* : gf::RenderPipeline(window)
* {
* addEffect(m_effect);
* addEffect(m_other);
* }
*
* protected:
* virtual void onFramebufferResize(Vector2i size) override {
* // update effects with size
* }
*
* private:
* MyEffect m_effect;
* MyOtherEffect m_other;
* };
* ~~~
*
* @sa gf::Effect
*/
class GF_API RenderPipeline : public RenderTarget {
public:
/**
* @brief Constructor
*
* @param window The window to render to
*/
RenderPipeline(VAR_0& window);
/**
* @brief Add an effect to the pipeline
*
* @param effect The effect
*/
void addEffect(Effect& effect);
/**
* @brief Clear the pipeline
*/
void clearEffects();
/**
* @brief Update the size of the target
*
* This function must be called when the window change its size, before
* anything is drawn on the target. You can do it in the event processing.
*
* ~~~{.cc}
* gf::Event event;
*
* // ...
*
* switch (event.type) {
* case gf::EventType::Resized:
* renderer.resized();
* break;
*
* // ...
* }
* ~~~
*/
void resized();
CLASS_1 Vector2i getSize() const override;
/**
* @brief Apply the effects and display what has been rendered
*/
void display();
CLASS_2:
/**
* @brief Callback when the screen has just been resized
*
* This function is called by resized() with the correct size.
*
* @param size The new framebuffer size
*/
VAR_1 void onFramebufferResize(Vector2i size);
private:
VAR_0& m_window;
struct TextureBuffer {
Texture texture;
GraphicsHandle<VAR_2::Framebuffer> VAR_3;
};
TextureBuffer m_buffers[2];
int m_current;
DefaultEffect VAR_4;
std::vector<Ref<Effect>> m_effects;
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
}
#endif
}
#endif // GF_RENDER_PIPELINE_H
| 0.267943 | {'IMPORT_0': 'Portability.h', 'CLASS_0': 'namespace', 'VAR_0': 'Window', 'CLASS_1': 'virtual', 'VAR_1': 'virtual', 'CLASS_2': 'protected', 'VAR_2': 'GraphicsTag', 'VAR_3': 'framebuffer', 'VAR_4': 'm_defaultEffect'} | c | Procedural | 34.15% |
#include <stdio.h>
#include <stdlib.h>
#include <sl_queue.h>
#include <sl_iterator.h>
#define QTD 100
void print_queue_iter(sl_queue_root *queue) {
iterator_s *i = sl_iter_create(queue);
printf("[");
if (i != NULL) {
do {
printf("'%d', ", *((int *) sl_iter_item(i)));
} while (sl_iter_next(i));
};
printf("]\n");
sl_iter_free(i);
}
int main() {
sl_queue_root *a;
int *num;
a = sl_queue_create(&free);
printf("##### Test 1 - sl_queue_push - Insert element in the queue.\n");
for (int i = 0; i < QTD; i++) {
num = (int *) malloc(sizeof(int));
*num = i;
sl_queue_push(a, num);
}
print_queue_iter(a);
printf("##### Test 2 - sl_queue_peek - View the last element without pop it from the queue.\n");
num = sl_queue_peek(a);
printf("Peeked item: %d\n", *num);
printf("##### Test 3 - sl_queue_pop - Remove the last element without pop it from the queue.\n");
for (int i = 0; i < 5; i++) {
num = sl_queue_pop(a);
printf("Popped item: %d\n", *num);
free(num);
}
print_queue_iter(a);
printf("##### Test 2 - sl_queue_destroy - Destroy queue (call destroyfunc for every member).\n");
sl_queue_destroy(a);
return EXIT_SUCCESS;
}
| #include <IMPORT_0>
#include <stdlib.h>
#include <IMPORT_1>
#include <sl_iterator.h>
#define VAR_0 100
void FUNC_0(CLASS_0 *queue) {
CLASS_1 *VAR_1 = FUNC_1(queue);
printf("[");
if (VAR_1 != NULL) {
do {
printf("'%d', ", *((int *) FUNC_2(VAR_1)));
} while (FUNC_3(VAR_1));
};
printf("]\n");
sl_iter_free(VAR_1);
}
int main() {
CLASS_0 *VAR_2;
int *num;
VAR_2 = FUNC_4(&VAR_3);
printf("##### Test 1 - sl_queue_push - Insert element in the queue.\n");
for (int VAR_1 = 0; VAR_1 < VAR_0; VAR_1++) {
num = (int *) FUNC_6(sizeof(int));
*num = VAR_1;
FUNC_7(VAR_2, num);
}
FUNC_0(VAR_2);
printf("##### Test 2 - sl_queue_peek - View the last element without pop it from the queue.\n");
num = FUNC_8(VAR_2);
printf("Peeked item: %d\n", *num);
printf("##### Test 3 - sl_queue_pop - Remove the last element without pop it from the queue.\n");
for (int VAR_1 = 0; VAR_1 < 5; VAR_1++) {
num = FUNC_9(VAR_2);
printf("Popped item: %d\n", *num);
FUNC_5(num);
}
FUNC_0(VAR_2);
printf("##### Test 2 - sl_queue_destroy - Destroy queue (call destroyfunc for every member).\n");
sl_queue_destroy(VAR_2);
return VAR_4;
}
| 0.631407 | {'IMPORT_0': 'stdio.h', 'IMPORT_1': 'sl_queue.h', 'VAR_0': 'QTD', 'FUNC_0': 'print_queue_iter', 'CLASS_0': 'sl_queue_root', 'CLASS_1': 'iterator_s', 'VAR_1': 'i', 'FUNC_1': 'sl_iter_create', 'FUNC_2': 'sl_iter_item', 'FUNC_3': 'sl_iter_next', 'VAR_2': 'a', 'FUNC_4': 'sl_queue_create', 'VAR_3': 'free', 'FUNC_5': 'free', 'FUNC_6': 'malloc', 'FUNC_7': 'sl_queue_push', 'FUNC_8': 'sl_queue_peek', 'FUNC_9': 'sl_queue_pop', 'VAR_4': 'EXIT_SUCCESS'} | c | Procedural | 100.00% |
int main ()
{
int *x_p312;
int y_p313;
y_p313 = 3;
}
|
int FUNC_0 ()
{
int *VAR_0;
int VAR_1;
VAR_1 = 3;
}
| 0.477014 | {'FUNC_0': 'main', 'VAR_0': 'x_p312', 'VAR_1': 'y_p313'} | c | Procedural | 100.00% |
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* 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 disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
/*
Title: USBGenericDescriptor implementation
About: Purpose
Implementation of the USBGenericDescriptor class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <at91/usb/common/core/USBGenericDescriptor.h>
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the length of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Length of descriptor in bytes.
//------------------------------------------------------------------------------
unsigned int USBGenericDescriptor_GetLength(
const USBGenericDescriptor *descriptor)
{
return descriptor->bLength;
}
//------------------------------------------------------------------------------
/// Returns the type of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Type of descriptor.
//------------------------------------------------------------------------------
unsigned char USBGenericDescriptor_GetType(
const USBGenericDescriptor *descriptor)
{
return descriptor->bDescriptorType;
}
//------------------------------------------------------------------------------
/// Returns a pointer to the descriptor right after the given one, when
/// parsing a Configuration descriptor.
/// \param descriptor - Pointer to a USBGenericDescriptor instance.
/// \return Pointer to the next descriptor.
//------------------------------------------------------------------------------
USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
const USBGenericDescriptor *descriptor)
{
return (USBGenericDescriptor *)
(((char *) descriptor) + USBGenericDescriptor_GetLength(descriptor));
}
| /* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* 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 disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
/*
Title: USBGenericDescriptor implementation
About: Purpose
Implementation of the USBGenericDescriptor class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <IMPORT_0>
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the length of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Length of descriptor in bytes.
//------------------------------------------------------------------------------
unsigned int FUNC_0(
const CLASS_0 *VAR_0)
{
return VAR_0->VAR_1;
}
//------------------------------------------------------------------------------
/// Returns the type of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Type of descriptor.
//------------------------------------------------------------------------------
unsigned char FUNC_1(
const CLASS_0 *VAR_0)
{
return VAR_0->VAR_2;
}
//------------------------------------------------------------------------------
/// Returns a pointer to the descriptor right after the given one, when
/// parsing a Configuration descriptor.
/// \param descriptor - Pointer to a USBGenericDescriptor instance.
/// \return Pointer to the next descriptor.
//------------------------------------------------------------------------------
CLASS_0 *FUNC_2(
const CLASS_0 *VAR_0)
{
return (CLASS_0 *)
(((char *) VAR_0) + FUNC_0(VAR_0));
}
| 0.816851 | {'IMPORT_0': 'at91/usb/common/core/USBGenericDescriptor.h', 'FUNC_0': 'USBGenericDescriptor_GetLength', 'CLASS_0': 'USBGenericDescriptor', 'VAR_0': 'descriptor', 'VAR_1': 'bLength', 'FUNC_1': 'USBGenericDescriptor_GetType', 'VAR_2': 'bDescriptorType', 'FUNC_2': 'USBGenericDescriptor_GetNextDescriptor'} | c | Hibrido | 100.00% |
#ifndef EXPRESS_H
#define EXPRESS_H
#include <QWidget>
class express : public QWidget
{
Q_OBJECT
public:
express(QWidget *parent);
~express();
private:
};
#endif // EXPRESS_H
| #ifndef EXPRESS_H
#define EXPRESS_H
#include <QWidget>
class express : public QWidget
{
Q_OBJECT
public:
express(QWidget *parent);
~express();
private:
};
#endif // EXPRESS_H
| 0.185751 | {} | c | OOP | 100.00% |
//
// INSidebarViewController.h
// BigSur
//
// Created by <NAME> on 5/13/14.
// Copyright (c) 2014 Inbox. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface INSidebarViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, INModelProviderDelegate>
{
NSArray * _tableSectionData;
NSString * _tableViewSelectedItemName;
}
@property (nonatomic, weak) IBOutlet UITableView * tableView;
@property (nonatomic, strong) INModelProvider * tagProvider;
- (void)refresh;
- (void)selectItemWithName:(NSString*)name;
- (IBAction)unauthenticateTapped:(id)sender;
- (IBAction)syncStatusTapped:(id)sender;
@end
| //
// INSidebarViewController.h
// BigSur
//
// Created by <NAME> on 5/13/14.
// Copyright (c) 2014 Inbox. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface VAR_0 : VAR_1 <VAR_2, VAR_3, VAR_4>
{
CLASS_0 * VAR_5;
CLASS_1 * VAR_7;
}
@property (VAR_8, weak) IBOutlet CLASS_2 * tableView;
@property (VAR_8, VAR_9) INModelProvider * tagProvider;
- (void)VAR_10;
- (void)selectItemWithName:(VAR_6*)VAR_11;
- (IBAction)VAR_12:(VAR_13)VAR_14;
- (IBAction)syncStatusTapped:(VAR_13)VAR_14;
@VAR_15
| 0.466599 | {'VAR_0': 'INSidebarViewController', 'VAR_1': 'UIViewController', 'VAR_2': 'UITableViewDataSource', 'VAR_3': 'UITableViewDelegate', 'VAR_4': 'INModelProviderDelegate', 'CLASS_0': 'NSArray', 'VAR_5': '_tableSectionData', 'CLASS_1': 'NSString', 'VAR_6': 'NSString', 'VAR_7': '_tableViewSelectedItemName', 'VAR_8': 'nonatomic', 'CLASS_2': 'UITableView', 'VAR_9': 'strong', 'VAR_10': 'refresh', 'VAR_11': 'name', 'VAR_12': 'unauthenticateTapped', 'VAR_13': 'id', 'VAR_14': 'sender', 'VAR_15': 'end'} | c | Procedural | 34.67% |
#pragma once
#include <map>
#include <mutex>
#include <string>
#include <vector>
#include "texture.h"
#include <assimp/material.h>
#include <rfw/context/structs.h>
#include <rfw/context/device_structs.h>
namespace rfw
{
class material_list;
class HostMaterial
{
public:
struct MapProps
{
int textureID = -1; // texture ID; -1 denotes empty slot
float valueScale = 1; // texture value scale, only sensible for normal maps
glm::vec2 uvscale = glm::vec2(1.0f); // uv coordinate scale
glm::vec2 uvoffset = glm::vec2(0.0f); // uv coordinate offset
};
HostMaterial()
{
for (auto &i : map)
i.textureID = -1;
}
enum
{
SMOOTH = 1, // material uses normal interpolation
HASALPHA = 2, // material textures use alpha channel
ANISOTROPIC = 4, // material has anisotropic roughness
FROM_MTL = 128, // changes are persistent for these, not for others
ISCONDUCTOR = 256, // rough conductor
ISDIELECTRIC = 512 // rough dielectric. If 256 and 512 not specified: diffuse.
};
std::string name = "unnamed"; // material name, not for unique identification
std::string origin; // origin: file from which the data was loaded, with full path
int ID = -1; // unique integer ID of this material
uint flags = SMOOTH; // material properties
uint refCount = 1; // the number of models that use this material
glm::vec3 color = glm::vec3(1.f);
glm::vec3 absorption = glm::vec3(0.f);
float metallic = 0.0f;
float subsurface = 0.0f;
float specular = 0.5f;
float roughness = 0.5f;
float specularTint = 0.0f;
float anisotropic = 0.0f;
float sheen = 0.0f;
float sheenTint = 0.0f;
float clearcoat = 0.0f;
float clearcoatGloss = 1.0f;
float transmission = 0.0f;
float eta = 1.0f;
float custom0 = 0.0f;
float custom1 = 0.0f;
float custom2 = 0.0f;
float custom3 = 0.0f;
MapProps map[11]; // bitmap data
// field for the BuildMaterialList method of HostMesh
bool visited = false; // last mesh that checked this material
void setFlag(MatPropFlags flag) { flags |= (1u << uint(flag)); }
[[nodiscard]] bool hasFlag(MatPropFlags flag) const { return (flags & (1u << uint(flag))); }
std::pair<Material, MaterialTexIds> convertToDeviceMaterial(material_list *list) const;
[[nodiscard]] bool isEmissive() const { return any(greaterThan(color, vec3(1.0f))); }
};
class material_list
{
public:
material_list();
~material_list();
uint add(const HostMaterial &mat);
uint add(const aiMaterial *aiMat, const std::string_view &basedir);
uint add(const texture &tex);
uint add(texture &&tex);
void set(uint index, const HostMaterial &mat);
void generate_device_materials();
[[nodiscard]] bool is_dirty() const;
[[nodiscard]] const HostMaterial &get(uint index) const { return m_HostMaterials.at(index); }
[[nodiscard]] HostMaterial &get(uint index) { return m_HostMaterials.at(index); }
[[nodiscard]] const std::vector<HostMaterial> &get_materials() const { return m_HostMaterials; }
[[nodiscard]] const std::vector<DeviceMaterial> &get_device_materials() const { return m_Materials; }
[[nodiscard]] const std::vector<MaterialTexIds> &get_material_tex_ids() const { return m_MaterialTexIds; }
[[nodiscard]] const std::vector<texture> &get_textures() const { return m_Textures; }
[[nodiscard]] const std::vector<TextureData> &get_texture_descriptors() const { return m_TextureDescriptors; }
[[nodiscard]] const std::vector<bool> &get_material_light_flags() const { return m_IsEmissive; }
size_t size() const { return m_Materials.size(); }
private:
bool m_IsDirty = true;
int get_texture_index(const std::string_view &file);
std::mutex m_MatMutex;
std::mutex m_TexMutex;
std::vector<bool> m_IsEmissive;
std::vector<HostMaterial> m_HostMaterials;
std::vector<MaterialTexIds> m_MaterialTexIds;
std::vector<DeviceMaterial> m_Materials;
std::vector<texture> m_Textures;
std::vector<TextureData> m_TextureDescriptors;
std::map<std::string, int> m_TexMapping;
};
} // namespace rfw
| #pragma once
#include <map>
#include <mutex>
#include <string>
#include <vector>
#include "texture.h"
#include <assimp/material.h>
#include <rfw/context/structs.h>
#include <rfw/context/device_structs.h>
namespace rfw
{
class material_list;
class HostMaterial
{
public:
struct MapProps
{
int VAR_0 = -1; // texture ID; -1 denotes empty slot
float valueScale = 1; // texture value scale, only sensible for normal maps
glm::vec2 uvscale = glm::vec2(1.0f); // uv coordinate scale
glm::vec2 uvoffset = glm::vec2(0.0f); // uv coordinate offset
};
HostMaterial()
{
for (auto &i : map)
i.VAR_0 = -1;
}
enum
{
SMOOTH = 1, // material uses normal interpolation
HASALPHA = 2, // material textures use alpha channel
ANISOTROPIC = 4, // material has anisotropic roughness
FROM_MTL = 128, // changes are persistent for these, not for others
ISCONDUCTOR = 256, // rough conductor
ISDIELECTRIC = 512 // rough dielectric. If 256 and 512 not specified: diffuse.
};
std::string name = "unnamed"; // material name, not for unique identification
std::string origin; // origin: file from which the data was loaded, with full path
int ID = -1; // unique integer ID of this material
uint flags = SMOOTH; // material properties
uint VAR_1 = 1; // the number of models that use this material
glm::VAR_2 color = glm::FUNC_0(1.f);
glm::VAR_2 VAR_3 = glm::FUNC_0(0.f);
float metallic = 0.0f;
float VAR_4 = 0.0f;
float VAR_5 = 0.5f;
float roughness = 0.5f;
float specularTint = 0.0f;
float anisotropic = 0.0f;
float sheen = 0.0f;
float sheenTint = 0.0f;
float clearcoat = 0.0f;
float clearcoatGloss = 1.0f;
float transmission = 0.0f;
float eta = 1.0f;
float custom0 = 0.0f;
float VAR_6 = 0.0f;
float VAR_7 = 0.0f;
float VAR_8 = 0.0f;
MapProps map[11]; // bitmap data
// field for the BuildMaterialList method of HostMesh
bool visited = false; // last mesh that checked this material
void setFlag(MatPropFlags flag) { flags |= (1u << uint(flag)); }
[[nodiscard]] bool FUNC_1(MatPropFlags flag) const { return (flags & (1u << uint(flag))); }
std::pair<Material, MaterialTexIds> FUNC_2(material_list *list) const;
[[nodiscard]] bool isEmissive() const { return any(greaterThan(color, FUNC_0(1.0f))); }
};
class material_list
{
public:
material_list();
~material_list();
uint add(const HostMaterial &mat);
uint add(const aiMaterial *aiMat, const std::string_view &VAR_9);
uint add(const CLASS_0 &tex);
uint add(CLASS_0 &&tex);
void set(uint index, const HostMaterial &mat);
void generate_device_materials();
[[nodiscard]] bool is_dirty() const;
[[nodiscard]] const HostMaterial &get(uint index) const { return m_HostMaterials.at(index); }
[[nodiscard]] HostMaterial &get(uint index) { return m_HostMaterials.at(index); }
[[nodiscard]] const std::vector<HostMaterial> &get_materials() const { return m_HostMaterials; }
[[nodiscard]] const std::vector<VAR_11> &get_device_materials() const { return m_Materials; }
[[nodiscard]] const std::vector<MaterialTexIds> &get_material_tex_ids() const { return m_MaterialTexIds; }
[[nodiscard]] const std::vector<VAR_10> &get_textures() const { return VAR_12; }
[[nodiscard]] const std::vector<TextureData> &get_texture_descriptors() const { return m_TextureDescriptors; }
[[nodiscard]] const std::vector<bool> &get_material_light_flags() const { return m_IsEmissive; }
size_t FUNC_3() const { return m_Materials.FUNC_3(); }
private:
bool m_IsDirty = true;
int get_texture_index(const std::string_view &file);
std::mutex m_MatMutex;
std::mutex m_TexMutex;
std::vector<bool> m_IsEmissive;
std::vector<HostMaterial> m_HostMaterials;
std::vector<MaterialTexIds> m_MaterialTexIds;
std::vector<VAR_11> m_Materials;
std::vector<VAR_10> VAR_12;
std::vector<TextureData> m_TextureDescriptors;
std::map<std::string, int> m_TexMapping;
};
} // namespace rfw
| 0.164714 | {'VAR_0': 'textureID', 'VAR_1': 'refCount', 'VAR_2': 'vec3', 'FUNC_0': 'vec3', 'VAR_3': 'absorption', 'VAR_4': 'subsurface', 'VAR_5': 'specular', 'VAR_6': 'custom1', 'VAR_7': 'custom2', 'VAR_8': 'custom3', 'FUNC_1': 'hasFlag', 'FUNC_2': 'convertToDeviceMaterial', 'VAR_9': 'basedir', 'CLASS_0': 'texture', 'VAR_10': 'texture', 'VAR_11': 'DeviceMaterial', 'VAR_12': 'm_Textures', 'FUNC_3': 'size'} | c | Texto | 4.99% |
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _MSDASQL_H_
#define _MSDASQL_H_
#undef MSDASQLDECLSPEC
#define MSDASQLDECLSPEC __declspec(selectany)
#ifdef DBINITCONSTANTS
extern const MSDASQLDECLSPEC GUID IID_ISQLRequestDiagFields = { 0x228972f0,0xb5ff,0x11d0,{ 0x8a,0x80,0x0,0xc0,0x4f,0xd6,0x11,0xcd } };
extern const MSDASQLDECLSPEC GUID IID_ISQLGetDiagField = { 0x228972f1,0xb5ff,0x11d0,{ 0x8a,0x80,0x0,0xc0,0x4f,0xd6,0x11,0xcd } };
extern const MSDASQLDECLSPEC GUID IID_IRowsetChangeExtInfo = {0x0C733A8FL,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
extern const MSDASQLDECLSPEC GUID CLSID_MSDASQL = {0xC8B522CBL,0x5CF3,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
extern const MSDASQLDECLSPEC GUID CLSID_MSDASQL_ENUMERATOR = {0xC8B522CDL,0x5CF3,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
#else
extern const GUID IID_ISQLRequestDiagFields;
extern const GUID IID_ISQLGetDiagField;
extern const GUID IID_IRowsetChangeExtInfo;
extern const GUID CLSID_MSDASQL;
extern const GUID CLSID_MSDASQL_ENUMERATOR;
#endif
#ifdef DBINITCONSTANTS
extern const MSDASQLDECLSPEC GUID DBPROPSET_PROVIDERDATASOURCEINFO = {0x497c60e0,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const MSDASQLDECLSPEC GUID DBPROPSET_PROVIDERROWSET = {0x497c60e1,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const MSDASQLDECLSPEC GUID DBPROPSET_PROVIDERDBINIT = {0x497c60e2,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const MSDASQLDECLSPEC GUID DBPROPSET_PROVIDERSTMTATTR = {0x497c60e3,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const MSDASQLDECLSPEC GUID DBPROPSET_PROVIDERCONNATTR = {0x497c60e4,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
#else
extern const GUID DBPROPSET_PROVIDERDATASOURCEINFO;
extern const GUID DBPROPSET_PROVIDERROWSET;
extern const GUID DBPROPSET_PROVIDERDBINIT;
extern const GUID DBPROPSET_PROVIDERSTMTATTR;
extern const GUID DBPROPSET_PROVIDERCONNATTR;
#endif
#define KAGPROP_QUERYBASEDUPDATES 2
#define KAGPROP_MARSHALLABLE 3
#define KAGPROP_POSITIONONNEWROW 4
#define KAGPROP_IRowsetChangeExtInfo 5
#define KAGPROP_CURSOR 6
#define KAGPROP_CONCURRENCY 7
#define KAGPROP_BLOBSONFOCURSOR 8
#define KAGPROP_INCLUDENONEXACT 9
#define KAGPROP_FORCESSFIREHOSEMODE 10
#define KAGPROP_FORCENOPARAMETERREBIND 11
#define KAGPROP_FORCENOPREPARE 12
#define KAGPROP_FORCENOREEXECUTE 13
#define KAGPROP_ACCESSIBLEPROCEDURES 2
#define KAGPROP_ACCESSIBLETABLES 3
#define KAGPROP_ODBCSQLOPTIEF 4
#define KAGPROP_OJCAPABILITY 5
#define KAGPROP_PROCEDURES 6
#define KAGPROP_DRIVERNAME 7
#define KAGPROP_DRIVERVER 8
#define KAGPROP_DRIVERODBCVER 9
#define KAGPROP_LIKEESCAPECLAUSE 10
#define KAGPROP_SPECIALCHARACTERS 11
#define KAGPROP_MAXCOLUMNSINGROUPBY 12
#define KAGPROP_MAXCOLUMNSININDEX 13
#define KAGPROP_MAXCOLUMNSINORDERBY 14
#define KAGPROP_MAXCOLUMNSINSELECT 15
#define KAGPROP_MAXCOLUMNSINTABLE 16
#define KAGPROP_NUMERICFUNCTIONS 17
#define KAGPROP_ODBCSQLCONFORMANCE 18
#define KAGPROP_OUTERJOINS 19
#define KAGPROP_STRINGFUNCTIONS 20
#define KAGPROP_SYSTEMFUNCTIONS 21
#define KAGPROP_TIMEDATEFUNCTIONS 22
#define KAGPROP_FILEUSAGE 23
#define KAGPROP_ACTIVESTATEMENTS 24
#define KAGPROP_AUTH_TRUSTEDCONNECTION 2
#define KAGPROP_AUTH_SERVERINTEGRATED 3
#define KAGPROPVAL_CONCUR_ROWVER 0x00000001
#define KAGPROPVAL_CONCUR_VALUES 0x00000002
#define KAGPROPVAL_CONCUR_LOCK 0x00000004
#define KAGPROPVAL_CONCUR_READ_ONLY 0x00000008
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 440
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error This stub requires an updated version of <rpcndr.h>
#endif
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif
#ifndef __rstcei_h__
#define __rstcei_h__
#ifndef __IRowsetChangeExtInfo_FWD_DEFINED__
#define __IRowsetChangeExtInfo_FWD_DEFINED__
typedef struct IRowsetChangeExtInfo IRowsetChangeExtInfo;
#endif
#include "oledb.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MIDL_user_allocate_free_DEFINED__
#define __MIDL_user_allocate_free_DEFINED__
void *__RPC_API MIDL_user_allocate(size_t);
void __RPC_API MIDL_user_free(void *);
#endif
#ifndef __IRowsetChangeExtInfo_INTERFACE_DEFINED__
#define __IRowsetChangeExtInfo_INTERFACE_DEFINED__
EXTERN_C const IID IID_IRowsetChangeExtInfo;
#if defined(__cplusplus) && !defined(CINTERFACE)
struct IRowsetChangeExtInfo : public IUnknown {
public:
virtual HRESULT WINAPI GetOriginalRow(HCHAPTER hReserved,HROW hRow,HROW *phRowOriginal) = 0;
virtual HRESULT WINAPI GetPendingColumns(HCHAPTER hReserved,HROW hRow,ULONG cColumnOrdinals,const ULONG rgiOrdinals[],DBPENDINGSTATUS rgColumnStatus[]) = 0;
};
#else
typedef struct IRowsetChangeExtInfoVtbl {
BEGIN_INTERFACE
HRESULT (WINAPI *QueryInterface)(IRowsetChangeExtInfo *This,REFIID riid,void **ppvObject);
ULONG (WINAPI *AddRef)(IRowsetChangeExtInfo *This);
ULONG (WINAPI *Release)(IRowsetChangeExtInfo *This);
HRESULT (WINAPI *GetOriginalRow)(IRowsetChangeExtInfo *This,HCHAPTER hReserved,HROW hRow,HROW *phRowOriginal);
HRESULT (WINAPI *GetPendingColumns)(IRowsetChangeExtInfo *This,HCHAPTER hReserved,HROW hRow,ULONG cColumnOrdinals,const ULONG rgiOrdinals[],DBPENDINGSTATUS rgColumnStatus[]);
END_INTERFACE
} IRowsetChangeExtInfoVtbl;
struct IRowsetChangeExtInfo {
CONST_VTBL struct IRowsetChangeExtInfoVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IRowsetChangeExtInfo_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IRowsetChangeExtInfo_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IRowsetChangeExtInfo_Release(This) (This)->lpVtbl->Release(This)
#define IRowsetChangeExtInfo_GetOriginalRow(This,hReserved,hRow,phRowOriginal) (This)->lpVtbl->GetOriginalRow(This,hReserved,hRow,phRowOriginal)
#define IRowsetChangeExtInfo_GetPendingColumns(This,hReserved,hRow,cColumnOrdinals,rgiOrdinals,rgColumnStatus) (This)->lpVtbl->GetPendingColumns(This,hReserved,hRow,cColumnOrdinals,rgiOrdinals,rgColumnStatus)
#endif
#endif
HRESULT WINAPI IRowsetChangeExtInfo_GetOriginalRow_Proxy(IRowsetChangeExtInfo *This,HCHAPTER hReserved,HROW hRow,HROW *phRowOriginal);
void __RPC_STUB IRowsetChangeExtInfo_GetOriginalRow_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
HRESULT WINAPI IRowsetChangeExtInfo_GetPendingColumns_Proxy(IRowsetChangeExtInfo *This,HCHAPTER hReserved,HROW hRow,ULONG cColumnOrdinals,const ULONG rgiOrdinals[],DBPENDINGSTATUS rgColumnStatus[]);
void __RPC_STUB IRowsetChangeExtInfo_GetPendingColumns_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 440
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error This stub requires an updated version of <rpcndr.h>
#endif
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif
#ifndef __kagdiag_h__
#define __kagdiag_h__
#ifndef __ISQLRequestDiagFields_FWD_DEFINED__
#define __ISQLRequestDiagFields_FWD_DEFINED__
typedef struct ISQLRequestDiagFields ISQLRequestDiagFields;
#endif
#ifndef __ISQLGetDiagField_FWD_DEFINED__
#define __ISQLGetDiagField_FWD_DEFINED__
typedef struct ISQLGetDiagField ISQLGetDiagField;
#endif
#include "unknwn.h"
#include "oaidl.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MIDL_user_allocate_free_DEFINED__
#define __MIDL_user_allocate_free_DEFINED__
void *__RPC_API MIDL_user_allocate(size_t);
void __RPC_API MIDL_user_free(void *);
#endif
enum KAGREQDIAGFLAGSENUM {
KAGREQDIAGFLAGS_HEADER = 0x1,KAGREQDIAGFLAGS_RECORD = 0x2
};
typedef struct tagKAGREQDIAG {
ULONG ulDiagFlags;
VARTYPE vt;
SHORT sDiagField;
} KAGREQDIAG;
typedef struct tagKAGGETDIAG {
ULONG ulSize;
VARIANTARG vDiagInfo;
SHORT sDiagField;
} KAGGETDIAG;
extern RPC_IF_HANDLE __MIDL_itf_kagdiag_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_kagdiag_0000_v0_0_s_ifspec;
#ifndef __ISQLRequestDiagFields_INTERFACE_DEFINED__
#define __ISQLRequestDiagFields_INTERFACE_DEFINED__
EXTERN_C const IID IID_ISQLRequestDiagFields;
#if defined(__cplusplus) && !defined(CINTERFACE)
struct ISQLRequestDiagFields : public IUnknown {
public:
virtual HRESULT WINAPI RequestDiagFields(ULONG cDiagFields,KAGREQDIAG rgDiagFields[]) = 0;
};
#else
typedef struct ISQLRequestDiagFieldsVtbl {
BEGIN_INTERFACE
HRESULT (WINAPI *QueryInterface)(ISQLRequestDiagFields *This,REFIID riid,void **ppvObject);
ULONG (WINAPI *AddRef)(ISQLRequestDiagFields *This);
ULONG (WINAPI *Release)(ISQLRequestDiagFields *This);
HRESULT (WINAPI *RequestDiagFields)(ISQLRequestDiagFields *This,ULONG cDiagFields,KAGREQDIAG rgDiagFields[]);
END_INTERFACE
} ISQLRequestDiagFieldsVtbl;
struct ISQLRequestDiagFields {
CONST_VTBL struct ISQLRequestDiagFieldsVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ISQLRequestDiagFields_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define ISQLRequestDiagFields_AddRef(This) (This)->lpVtbl->AddRef(This)
#define ISQLRequestDiagFields_Release(This) (This)->lpVtbl->Release(This)
#define ISQLRequestDiagFields_RequestDiagFields(This,cDiagFields,rgDiagFields) (This)->lpVtbl->RequestDiagFields(This,cDiagFields,rgDiagFields)
#endif
#endif
HRESULT WINAPI ISQLRequestDiagFields_RequestDiagFields_Proxy(ISQLRequestDiagFields *This,ULONG cDiagFields,KAGREQDIAG rgDiagFields[]);
void __RPC_STUB ISQLRequestDiagFields_RequestDiagFields_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif
#ifndef __ISQLGetDiagField_INTERFACE_DEFINED__
#define __ISQLGetDiagField_INTERFACE_DEFINED__
EXTERN_C const IID IID_ISQLGetDiagField;
#if defined(__cplusplus) && !defined(CINTERFACE)
struct ISQLGetDiagField : public IUnknown {
public:
virtual HRESULT WINAPI GetDiagField(KAGGETDIAG *pDiagInfo) = 0;
};
#else
typedef struct ISQLGetDiagFieldVtbl {
BEGIN_INTERFACE
HRESULT (WINAPI *QueryInterface)(ISQLGetDiagField *This,REFIID riid,void **ppvObject);
ULONG (WINAPI *AddRef)(ISQLGetDiagField *This);
ULONG (WINAPI *Release)(ISQLGetDiagField *This);
HRESULT (WINAPI *GetDiagField)(ISQLGetDiagField *This,KAGGETDIAG *pDiagInfo);
END_INTERFACE
} ISQLGetDiagFieldVtbl;
struct ISQLGetDiagField {
CONST_VTBL struct ISQLGetDiagFieldVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ISQLGetDiagField_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define ISQLGetDiagField_AddRef(This) (This)->lpVtbl->AddRef(This)
#define ISQLGetDiagField_Release(This) (This)->lpVtbl->Release(This)
#define ISQLGetDiagField_GetDiagField(This,pDiagInfo) (This)->lpVtbl->GetDiagField(This,pDiagInfo)
#endif
#endif
HRESULT WINAPI ISQLGetDiagField_GetDiagField_Proxy(ISQLGetDiagField *This,KAGGETDIAG *pDiagInfo);
void __RPC_STUB ISQLGetDiagField_GetDiagField_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif
unsigned long __RPC_API VARIANT_UserSize(unsigned long *,unsigned long,VARIANT *);
unsigned char *__RPC_API VARIANT_UserMarshal(unsigned long *,unsigned char *,VARIANT *);
unsigned char *__RPC_API VARIANT_UserUnmarshal(unsigned long *,unsigned char *,VARIANT *);
void __RPC_API VARIANT_UserFree(unsigned long *,VARIANT *);
#ifdef __cplusplus
}
#endif
#endif
#endif
| /**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _MSDASQL_H_
#define _MSDASQL_H_
#undef MSDASQLDECLSPEC
#define VAR_0 __declspec(selectany)
#ifdef DBINITCONSTANTS
extern const CLASS_0 VAR_1 VAR_2 = { 0x228972f0,0xb5ff,0x11d0,{ 0x8a,0x80,0x0,0xc0,0x4f,0xd6,0x11,0xcd } };
extern const CLASS_0 VAR_1 VAR_3 = { 0x228972f1,0xb5ff,0x11d0,{ 0x8a,0x80,0x0,0xc0,0x4f,0xd6,0x11,0xcd } };
extern const CLASS_0 VAR_1 VAR_4 = {0x0C733A8FL,0x2A1C,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
extern const CLASS_0 VAR_1 CLSID_MSDASQL = {0xC8B522CBL,0x5CF3,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
extern const CLASS_0 VAR_1 VAR_5 = {0xC8B522CDL,0x5CF3,0x11CE,{0xAD,0xE5,0x00,0xAA,0x00,0x44,0x77,0x3D}};
#else
extern const CLASS_1 VAR_2;
extern const CLASS_1 VAR_3;
extern const CLASS_1 VAR_4;
extern const CLASS_1 CLSID_MSDASQL;
extern const CLASS_1 VAR_5;
#endif
#ifdef DBINITCONSTANTS
extern const CLASS_0 VAR_1 VAR_6 = {0x497c60e0,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const CLASS_0 VAR_1 DBPROPSET_PROVIDERROWSET = {0x497c60e1,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const CLASS_0 VAR_1 VAR_7 = {0x497c60e2,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const CLASS_0 VAR_1 DBPROPSET_PROVIDERSTMTATTR = {0x497c60e3,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
extern const CLASS_0 VAR_1 VAR_8 = {0x497c60e4,0x7123,0x11cf,{0xb1,0x71,0x0,0xaa,0x0,0x57,0x59,0x9e}};
#else
extern const CLASS_1 VAR_6;
extern const CLASS_1 DBPROPSET_PROVIDERROWSET;
extern const CLASS_1 VAR_7;
extern const CLASS_1 DBPROPSET_PROVIDERSTMTATTR;
extern const CLASS_1 VAR_8;
#endif
#define VAR_9 2
#define KAGPROP_MARSHALLABLE 3
#define VAR_10 4
#define KAGPROP_IRowsetChangeExtInfo 5
#define VAR_11 6
#define VAR_12 7
#define VAR_13 8
#define KAGPROP_INCLUDENONEXACT 9
#define VAR_14 10
#define VAR_15 11
#define VAR_16 12
#define VAR_17 13
#define VAR_18 2
#define KAGPROP_ACCESSIBLETABLES 3
#define VAR_19 4
#define VAR_20 5
#define VAR_21 6
#define VAR_22 7
#define KAGPROP_DRIVERVER 8
#define VAR_23 9
#define VAR_24 10
#define VAR_25 11
#define VAR_26 12
#define VAR_27 13
#define VAR_28 14
#define VAR_29 15
#define VAR_30 16
#define KAGPROP_NUMERICFUNCTIONS 17
#define VAR_31 18
#define KAGPROP_OUTERJOINS 19
#define KAGPROP_STRINGFUNCTIONS 20
#define VAR_32 21
#define VAR_33 22
#define KAGPROP_FILEUSAGE 23
#define KAGPROP_ACTIVESTATEMENTS 24
#define VAR_34 2
#define VAR_35 3
#define KAGPROPVAL_CONCUR_ROWVER 0x00000001
#define VAR_36 0x00000002
#define VAR_37 0x00000004
#define VAR_38 0x00000008
#ifndef VAR_39
#define VAR_39 440
#endif
#include "IMPORT_0"
#include "IMPORT_1"
#ifndef VAR_40
#error This stub requires an updated version of <rpcndr.h>
#endif
#ifndef VAR_41
#include "IMPORT_2"
#include "IMPORT_3"
#endif
#ifndef VAR_42
#define VAR_42
#ifndef VAR_43
#define VAR_43
typedef struct CLASS_2 ID_0;
#endif
#include "IMPORT_4"
#ifdef VAR_45
extern "C" {
#endif
#ifndef VAR_46
#define VAR_46
void *__RPC_API FUNC_0(size_t);
void __RPC_API FUNC_1(void *);
#endif
#ifndef VAR_49
#define VAR_49
CLASS_3 const IID VAR_4;
#if defined(VAR_45) && !defined(CINTERFACE)
struct CLASS_2 : VAR_50 VAR_51 {
public:
VAR_52 CLASS_5 WINAPI FUNC_2(CLASS_6 VAR_55,HROW hRow,HROW *phRowOriginal) = 0;
CLASS_4 VAR_53 WINAPI GetPendingColumns(CLASS_6 VAR_55,HROW hRow,ULONG VAR_56,const ULONG rgiOrdinals[],CLASS_7 VAR_58[]) = 0;
};
#else
typedef struct CLASS_8 {
CLASS_9
VAR_53 (WINAPI *VAR_61)(CLASS_2 *VAR_62,CLASS_10 VAR_63,void **VAR_64);
ULONG (WINAPI *VAR_65)(VAR_44 *VAR_62);
ULONG (WINAPI *VAR_66)(VAR_44 *VAR_62);
VAR_53 (WINAPI *ID_1)(VAR_44 *VAR_62,VAR_54 VAR_55,HROW hRow,HROW *phRowOriginal);
VAR_53 (WINAPI *GetPendingColumns)(VAR_44 *VAR_62,VAR_54 VAR_55,HROW hRow,ULONG VAR_56,VAR_67 ULONG rgiOrdinals[],VAR_57 VAR_58[]);
CLASS_11
} VAR_59;
struct CLASS_2 {
CLASS_12 VAR_68 CLASS_8 *VAR_69;
};
#ifdef VAR_70
#define FUNC_3(VAR_62,VAR_63,VAR_64) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define FUNC_4(VAR_62) (This)->lpVtbl->AddRef(This)
#define IRowsetChangeExtInfo_Release(VAR_62) (This)->lpVtbl->Release(This)
#define FUNC_5(VAR_62,VAR_55,hRow,phRowOriginal) (This)->lpVtbl->GetOriginalRow(This,hReserved,hRow,phRowOriginal)
#define FUNC_6(VAR_62,VAR_55,hRow,VAR_56,rgiOrdinals,VAR_58) (This)->lpVtbl->GetPendingColumns(This,hReserved,hRow,cColumnOrdinals,rgiOrdinals,rgColumnStatus)
#endif
#endif
CLASS_5 WINAPI VAR_71(CLASS_2 *VAR_62,CLASS_6 VAR_55,HROW hRow,HROW *phRowOriginal);
void __RPC_STUB IRowsetChangeExtInfo_GetOriginalRow_Stub(IRpcStubBuffer *VAR_62,CLASS_13 *VAR_72,CLASS_14 VAR_73,DWORD *VAR_74);
CLASS_5 WINAPI VAR_75(CLASS_2 *VAR_62,CLASS_6 VAR_55,HROW hRow,ULONG VAR_56,const ULONG rgiOrdinals[],CLASS_7 VAR_58[]);
void __RPC_STUB IRowsetChangeExtInfo_GetPendingColumns_Stub(IRpcStubBuffer *VAR_62,CLASS_13 *VAR_72,CLASS_14 VAR_73,DWORD *VAR_74);
#endif
#ifdef VAR_45
}
#endif
#endif
#ifndef VAR_39
#define VAR_39 440
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef VAR_40
#error This stub requires an updated version of <rpcndr.h>
#endif
#ifndef VAR_41
#include "windows.h"
#include "ole2.h"
#endif
#ifndef VAR_76
#define VAR_76
#ifndef __ISQLRequestDiagFields_FWD_DEFINED__
#define __ISQLRequestDiagFields_FWD_DEFINED__
typedef VAR_68 CLASS_15 VAR_77;
#endif
#ifndef __ISQLGetDiagField_FWD_DEFINED__
#define __ISQLGetDiagField_FWD_DEFINED__
typedef VAR_68 CLASS_16 VAR_78;
#endif
#include "unknwn.h"
#include "oaidl.h"
#ifdef VAR_45
extern "CLASS_17" {
#endif
#ifndef VAR_46
#define VAR_46
void *__RPC_API VAR_47(size_t);
void __RPC_API VAR_48(void *);
#endif
enum CLASS_18 {
VAR_79 = 0x1,KAGREQDIAGFLAGS_RECORD = 0x2
};
typedef VAR_68 tagKAGREQDIAG {
ULONG VAR_80;
CLASS_19 VAR_81;
SHORT VAR_82;
} KAGREQDIAG;
typedef struct CLASS_20 {
ULONG VAR_83;
CLASS_21 VAR_84;
SHORT VAR_82;
} ID_2;
extern CLASS_23 __MIDL_itf_kagdiag_0000_v0_0_c_ifspec;
extern CLASS_23 VAR_86;
#ifndef VAR_87
#define VAR_87
CLASS_3 const IID VAR_2;
#if defined(VAR_45) && !defined(CINTERFACE)
struct CLASS_15 : VAR_50 VAR_51 {
public:
VAR_52 CLASS_5 WINAPI FUNC_7(ULONG cDiagFields,KAGREQDIAG VAR_88[]) = 0;
};
#else
typedef struct VAR_89 {
CLASS_9
VAR_53 (WINAPI *VAR_61)(CLASS_15 *VAR_62,CLASS_10 VAR_63,void **VAR_64);
ULONG (WINAPI *VAR_65)(VAR_77 *VAR_62);
ULONG (WINAPI *VAR_66)(VAR_77 *VAR_62);
VAR_53 (WINAPI *ID_3)(VAR_77 *VAR_62,ULONG cDiagFields,KAGREQDIAG VAR_88[]);
CLASS_11
} VAR_89;
struct CLASS_15 {
CLASS_12 VAR_68 CLASS_24 *VAR_69;
};
#ifdef VAR_70
#define ISQLRequestDiagFields_QueryInterface(VAR_62,VAR_63,VAR_64) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define FUNC_8(VAR_62) (This)->lpVtbl->AddRef(This)
#define FUNC_9(VAR_62) (This)->lpVtbl->Release(This)
#define ISQLRequestDiagFields_RequestDiagFields(VAR_62,cDiagFields,VAR_88) (This)->lpVtbl->RequestDiagFields(This,cDiagFields,rgDiagFields)
#endif
#endif
CLASS_5 WINAPI VAR_90(CLASS_15 *VAR_62,ULONG cDiagFields,KAGREQDIAG VAR_88[]);
void __RPC_STUB ISQLRequestDiagFields_RequestDiagFields_Stub(IRpcStubBuffer *VAR_62,CLASS_13 *VAR_72,CLASS_14 VAR_73,DWORD *VAR_74);
#endif
#ifndef VAR_91
#define VAR_91
CLASS_3 const IID VAR_3;
#if defined(VAR_45) && !defined(CINTERFACE)
struct CLASS_16 : VAR_50 VAR_51 {
VAR_50:
VAR_52 CLASS_5 WINAPI VAR_92(CLASS_22 *pDiagInfo) = 0;
};
#else
typedef VAR_68 VAR_93 {
VAR_60
VAR_53 (WINAPI *VAR_61)(CLASS_16 *VAR_62,CLASS_10 VAR_63,void **VAR_64);
ULONG (WINAPI *VAR_65)(VAR_78 *VAR_62);
ULONG (WINAPI *VAR_66)(VAR_78 *VAR_62);
VAR_53 (WINAPI *ID_4)(VAR_78 *VAR_62,VAR_85 *pDiagInfo);
CLASS_11
} VAR_93;
struct CLASS_16 {
CLASS_12 VAR_68 CLASS_25 *VAR_69;
};
#ifdef VAR_70
#define ISQLGetDiagField_QueryInterface(VAR_62,VAR_63,VAR_64) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define FUNC_10(VAR_62) (This)->lpVtbl->AddRef(This)
#define ISQLGetDiagField_Release(VAR_62) (This)->lpVtbl->Release(This)
#define FUNC_11(VAR_62,pDiagInfo) (This)->lpVtbl->GetDiagField(This,pDiagInfo)
#endif
#endif
CLASS_5 WINAPI ISQLGetDiagField_GetDiagField_Proxy(CLASS_16 *VAR_62,CLASS_22 *pDiagInfo);
void __RPC_STUB VAR_94(IRpcStubBuffer *VAR_62,CLASS_13 *VAR_72,CLASS_14 VAR_73,DWORD *VAR_74);
#endif
unsigned long __RPC_API VARIANT_UserSize(unsigned long *,unsigned long,VARIANT *);
unsigned char *__RPC_API VARIANT_UserMarshal(unsigned long *,unsigned char *,VARIANT *);
unsigned char *__RPC_API VAR_95(unsigned long *,unsigned char *,VARIANT *);
void __RPC_API VAR_96(unsigned long *,VARIANT *);
#ifdef VAR_45
}
#endif
#endif
#endif
| 0.699081 | {'VAR_0': 'MSDASQLDECLSPEC', 'CLASS_0': 'MSDASQLDECLSPEC', 'VAR_1': 'GUID', 'CLASS_1': 'GUID', 'VAR_2': 'IID_ISQLRequestDiagFields', 'VAR_3': 'IID_ISQLGetDiagField', 'VAR_4': 'IID_IRowsetChangeExtInfo', 'VAR_5': 'CLSID_MSDASQL_ENUMERATOR', 'VAR_6': 'DBPROPSET_PROVIDERDATASOURCEINFO', 'VAR_7': 'DBPROPSET_PROVIDERDBINIT', 'VAR_8': 'DBPROPSET_PROVIDERCONNATTR', 'VAR_9': 'KAGPROP_QUERYBASEDUPDATES', 'VAR_10': 'KAGPROP_POSITIONONNEWROW', 'VAR_11': 'KAGPROP_CURSOR', 'VAR_12': 'KAGPROP_CONCURRENCY', 'VAR_13': 'KAGPROP_BLOBSONFOCURSOR', 'VAR_14': 'KAGPROP_FORCESSFIREHOSEMODE', 'VAR_15': 'KAGPROP_FORCENOPARAMETERREBIND', 'VAR_16': 'KAGPROP_FORCENOPREPARE', 'VAR_17': 'KAGPROP_FORCENOREEXECUTE', 'VAR_18': 'KAGPROP_ACCESSIBLEPROCEDURES', 'VAR_19': 'KAGPROP_ODBCSQLOPTIEF', 'VAR_20': 'KAGPROP_OJCAPABILITY', 'VAR_21': 'KAGPROP_PROCEDURES', 'VAR_22': 'KAGPROP_DRIVERNAME', 'VAR_23': 'KAGPROP_DRIVERODBCVER', 'VAR_24': 'KAGPROP_LIKEESCAPECLAUSE', 'VAR_25': 'KAGPROP_SPECIALCHARACTERS', 'VAR_26': 'KAGPROP_MAXCOLUMNSINGROUPBY', 'VAR_27': 'KAGPROP_MAXCOLUMNSININDEX', 'VAR_28': 'KAGPROP_MAXCOLUMNSINORDERBY', 'VAR_29': 'KAGPROP_MAXCOLUMNSINSELECT', 'VAR_30': 'KAGPROP_MAXCOLUMNSINTABLE', 'VAR_31': 'KAGPROP_ODBCSQLCONFORMANCE', 'VAR_32': 'KAGPROP_SYSTEMFUNCTIONS', 'VAR_33': 'KAGPROP_TIMEDATEFUNCTIONS', 'VAR_34': 'KAGPROP_AUTH_TRUSTEDCONNECTION', 'VAR_35': 'KAGPROP_AUTH_SERVERINTEGRATED', 'VAR_36': 'KAGPROPVAL_CONCUR_VALUES', 'VAR_37': 'KAGPROPVAL_CONCUR_LOCK', 'VAR_38': 'KAGPROPVAL_CONCUR_READ_ONLY', 'VAR_39': '__REQUIRED_RPCNDR_H_VERSION__', 'IMPORT_0': 'rpc.h', 'IMPORT_1': 'rpcndr.h', 'VAR_40': '__RPCNDR_H_VERSION__', 'VAR_41': 'COM_NO_WINDOWS_H', 'IMPORT_2': 'windows.h', 'IMPORT_3': 'ole2.h', 'VAR_42': '__rstcei_h__', 'VAR_43': '__IRowsetChangeExtInfo_FWD_DEFINED__', 'CLASS_2': 'IRowsetChangeExtInfo', 'ID_0': 'IRowsetChangeExtInfo', 'VAR_44': 'IRowsetChangeExtInfo', 'IMPORT_4': 'oledb.h', 'VAR_45': '__cplusplus', 'VAR_46': '__MIDL_user_allocate_free_DEFINED__', 'FUNC_0': 'MIDL_user_allocate', 'VAR_47': 'MIDL_user_allocate', 'FUNC_1': 'MIDL_user_free', 'VAR_48': 'MIDL_user_free', 'VAR_49': '__IRowsetChangeExtInfo_INTERFACE_DEFINED__', 'CLASS_3': 'EXTERN_C', 'VAR_50': 'public', 'VAR_51': 'IUnknown', 'VAR_52': 'virtual', 'CLASS_4': 'virtual', 'CLASS_5': 'HRESULT', 'VAR_53': 'HRESULT', 'FUNC_2': 'GetOriginalRow', 'ID_1': 'GetOriginalRow', 'CLASS_6': 'HCHAPTER', 'VAR_54': 'HCHAPTER', 'VAR_55': 'hReserved', 'VAR_56': 'cColumnOrdinals', 'CLASS_7': 'DBPENDINGSTATUS', 'VAR_57': 'DBPENDINGSTATUS', 'VAR_58': 'rgColumnStatus', 'CLASS_8': 'IRowsetChangeExtInfoVtbl', 'VAR_59': 'IRowsetChangeExtInfoVtbl', 'CLASS_9': 'BEGIN_INTERFACE', 'VAR_60': 'BEGIN_INTERFACE', 'VAR_61': 'QueryInterface', 'VAR_62': 'This', 'CLASS_10': 'REFIID', 'VAR_63': 'riid', 'VAR_64': 'ppvObject', 'VAR_65': 'AddRef', 'VAR_66': 'Release', 'VAR_67': 'const', 'CLASS_11': 'END_INTERFACE', 'CLASS_12': 'CONST_VTBL', 'VAR_68': 'struct', 'VAR_69': 'lpVtbl', 'VAR_70': 'COBJMACROS', 'FUNC_3': 'IRowsetChangeExtInfo_QueryInterface', 'FUNC_4': 'IRowsetChangeExtInfo_AddRef', 'FUNC_5': 'IRowsetChangeExtInfo_GetOriginalRow', 'FUNC_6': 'IRowsetChangeExtInfo_GetPendingColumns', 'VAR_71': 'IRowsetChangeExtInfo_GetOriginalRow_Proxy', 'CLASS_13': 'IRpcChannelBuffer', 'VAR_72': '_pRpcChannelBuffer', 'CLASS_14': 'PRPC_MESSAGE', 'VAR_73': '_pRpcMessage', 'VAR_74': '_pdwStubPhase', 'VAR_75': 'IRowsetChangeExtInfo_GetPendingColumns_Proxy', 'VAR_76': '__kagdiag_h__', 'CLASS_15': 'ISQLRequestDiagFields', 'VAR_77': 'ISQLRequestDiagFields', 'CLASS_16': 'ISQLGetDiagField', 'VAR_78': 'ISQLGetDiagField', 'CLASS_17': 'C', 'CLASS_18': 'KAGREQDIAGFLAGSENUM', 'VAR_79': 'KAGREQDIAGFLAGS_HEADER', 'VAR_80': 'ulDiagFlags', 'CLASS_19': 'VARTYPE', 'VAR_81': 'vt', 'VAR_82': 'sDiagField', 'CLASS_20': 'tagKAGGETDIAG', 'VAR_83': 'ulSize', 'CLASS_21': 'VARIANTARG', 'VAR_84': 'vDiagInfo', 'ID_2': 'KAGGETDIAG', 'CLASS_22': 'KAGGETDIAG', 'VAR_85': 'KAGGETDIAG', 'CLASS_23': 'RPC_IF_HANDLE', 'VAR_86': '__MIDL_itf_kagdiag_0000_v0_0_s_ifspec', 'VAR_87': '__ISQLRequestDiagFields_INTERFACE_DEFINED__', 'FUNC_7': 'RequestDiagFields', 'ID_3': 'RequestDiagFields', 'VAR_88': 'rgDiagFields', 'VAR_89': 'ISQLRequestDiagFieldsVtbl', 'CLASS_24': 'ISQLRequestDiagFieldsVtbl', 'FUNC_8': 'ISQLRequestDiagFields_AddRef', 'FUNC_9': 'ISQLRequestDiagFields_Release', 'VAR_90': 'ISQLRequestDiagFields_RequestDiagFields_Proxy', 'VAR_91': '__ISQLGetDiagField_INTERFACE_DEFINED__', 'VAR_92': 'GetDiagField', 'ID_4': 'GetDiagField', 'VAR_93': 'ISQLGetDiagFieldVtbl', 'CLASS_25': 'ISQLGetDiagFieldVtbl', 'FUNC_10': 'ISQLGetDiagField_AddRef', 'FUNC_11': 'ISQLGetDiagField_GetDiagField', 'VAR_94': 'ISQLGetDiagField_GetDiagField_Stub', 'VAR_95': 'VARIANT_UserUnmarshal', 'VAR_96': 'VARIANT_UserFree'} | c | Procedural | 4.41% |
/*****************************************************************************/
/* */
/* Random Polygon Generator (RPG) */
/* */
/* Copyright (C) <NAME>, <NAME>, <NAME>, <NAME> 1994-2020 */
/* */
/*****************************************************************************/
#include "basicIntArray.h"
#include "pointArray.h"
#include "basicPoly.h"
#ifndef __STARPOLY_H_
#define __STARPOLY_H_
/********************************************************************/
/* */
/* Constants and the like */
/* */
/********************************************************************/
/********************************************************************/
/* */
/* Data Types */
/* */
/********************************************************************/
typedef struct {
t_polygon polygon; /* the polygon */
/* at next[i] we have the Index of the point that is following
i in the polygon (in ccw order) */
t_intArray next;
} t_starPoly;
/********************************************************************/
/* */
/* Procedures and functions */
/* */
/********************************************************************/
void SPinit(t_starPoly *aStarPoly, int nrOfPoints);
void SPcreatePoly(t_starPoly *aStarPoly, t_point centerPoint,
t_pointArray *pArray);
int SPgetPIndex(t_starPoly *aStarPoly, int index);
void SPswapPoints(t_starPoly *aStarPoly, int index1, int index2);
int SPgetNextPIndex(t_starPoly *aStarPoly, int index);
int SPsizeOf(t_starPoly *aStarPoly);
void SPcopyPoly(t_starPoly *sourceStarPoly, t_starPoly *destStarPoly);
int SPisPolyEdge(t_starPoly *aStarPoly, int pIndex1, int pIndex2);
t_polygon *SPgetPoly(t_starPoly *aStarPoly);
void SPfree(t_starPoly *aStarPoly);
/* this routine is faulty! do not use it! */
t_point SPpInKernel(t_starPoly *aStarPoly, t_pointArray *pArray);
#endif
| /*****************************************************************************/
/* */
/* Random Polygon Generator (RPG) */
/* */
/* Copyright (C) <NAME>, <NAME>, <NAME>, <NAME> 1994-2020 */
/* */
/*****************************************************************************/
#include "IMPORT_0"
#include "IMPORT_1"
#include "IMPORT_2"
#ifndef VAR_0
#define VAR_0
/********************************************************************/
/* */
/* Constants and the like */
/* */
/********************************************************************/
/********************************************************************/
/* */
/* Data Types */
/* */
/********************************************************************/
typedef struct {
CLASS_0 VAR_1; /* the polygon */
/* at next[i] we have the Index of the point that is following
i in the polygon (in ccw order) */
t_intArray VAR_2;
} ID_0;
/********************************************************************/
/* */
/* Procedures and functions */
/* */
/********************************************************************/
void FUNC_0(CLASS_1 *VAR_3, int VAR_4);
void FUNC_1(CLASS_1 *VAR_3, CLASS_2 VAR_5,
t_pointArray *VAR_6);
int FUNC_2(CLASS_1 *VAR_3, int VAR_7);
void FUNC_3(CLASS_1 *VAR_3, int index1, int VAR_8);
int FUNC_4(CLASS_1 *VAR_3, int VAR_7);
int FUNC_5(CLASS_1 *VAR_3);
void FUNC_6(CLASS_1 *VAR_9, CLASS_1 *VAR_10);
int FUNC_7(CLASS_1 *VAR_3, int VAR_11, int VAR_12);
CLASS_0 *SPgetPoly(CLASS_1 *VAR_3);
void FUNC_8(CLASS_1 *VAR_3);
/* this routine is faulty! do not use it! */
CLASS_2 FUNC_9(CLASS_1 *VAR_3, t_pointArray *VAR_6);
#endif
| 0.903469 | {'IMPORT_0': 'basicIntArray.h', 'IMPORT_1': 'pointArray.h', 'IMPORT_2': 'basicPoly.h', 'VAR_0': '__STARPOLY_H_', 'CLASS_0': 't_polygon', 'VAR_1': 'polygon', 'VAR_2': 'next', 'ID_0': 't_starPoly', 'CLASS_1': 't_starPoly', 'FUNC_0': 'SPinit', 'VAR_3': 'aStarPoly', 'VAR_4': 'nrOfPoints', 'FUNC_1': 'SPcreatePoly', 'CLASS_2': 't_point', 'VAR_5': 'centerPoint', 'VAR_6': 'pArray', 'FUNC_2': 'SPgetPIndex', 'VAR_7': 'index', 'FUNC_3': 'SPswapPoints', 'VAR_8': 'index2', 'FUNC_4': 'SPgetNextPIndex', 'FUNC_5': 'SPsizeOf', 'FUNC_6': 'SPcopyPoly', 'VAR_9': 'sourceStarPoly', 'VAR_10': 'destStarPoly', 'FUNC_7': 'SPisPolyEdge', 'VAR_11': 'pIndex1', 'VAR_12': 'pIndex2', 'FUNC_8': 'SPfree', 'FUNC_9': 'SPpInKernel'} | c | Hibrido | 100.00% |
#ifndef _CHIP8_H_
#define _CHIP8_H_
// CHIP8 module.
// Provides low level emulation of the CHIP8 cpu, graphics and audio. Used only
// by the VM module.
#include "def.h"
#define CHIP8_W 64
#define CHIP8_H 32
#define CHIP8_USERMEM_START 0x200
#define CHIP8_USERMEM_END 0xFFF
#define CHIP8_USERMEM_TOTAL (CHIP8_USERMEM_END - CHIP8_USERMEM_START)
#define CHIP8_STACK_MAX 16
typedef union tChip8WaitingKey {
uint8_t val;
struct {
// First 4 bits for the register that stores waiting key.
unsigned int reg : 4;
// 5th bit determines if waiting is enabled.
unsigned int waiting : 1;
// Unused bits.
unsigned int unused : 3;
};
} Chip8WaitingKey;
// The CHIP-8 system.
typedef union tChip8 {
uint8_t memory[0x1000];
struct {
uint8_t V[16];
uint8_t delayTimer;
uint8_t soundTimer;
uint8_t SP;
uint8_t keys[16];
Chip8WaitingKey waitingKey;
uint8_t display[(CHIP8_W * CHIP8_H) / 8];
uint8_t font[16 * 5];
uint16_t PC;
uint16_t stack[CHIP8_STACK_MAX];
uint16_t I;
};
} Chip8;
// Chip8Init() - Initialises the CHIP-8 CPU.
void Chip8Init(Chip8 *chip8);
// Chip8Cycle() - Read and execute an instruction.
void Chip8Cycle(Chip8 *chip8);
// Chip8WaitingForKey() - Returns if the CHIP8 is waiting for a key.
bool Chip8WaitingForKey(Chip8 *chip8);
#endif // _CHIP8_H_
| #ifndef _CHIP8_H_
#define _CHIP8_H_
// CHIP8 module.
// Provides low level emulation of the CHIP8 cpu, graphics and audio. Used only
// by the VM module.
#include "IMPORT_0"
#define VAR_0 64
#define CHIP8_H 32
#define VAR_1 0x200
#define VAR_2 0xFFF
#define VAR_3 (CHIP8_USERMEM_END - CHIP8_USERMEM_START)
#define VAR_4 16
typedef union CLASS_0 {
uint8_t VAR_5;
struct {
// First 4 bits for the register that stores waiting key.
unsigned int VAR_6 : 4;
// 5th bit determines if waiting is enabled.
unsigned int VAR_7 : 1;
// Unused bits.
unsigned int VAR_8 : 3;
};
} ID_0;
// The CHIP-8 system.
typedef union CLASS_2 {
uint8_t VAR_9[0x1000];
struct {
uint8_t VAR_10[16];
uint8_t delayTimer;
uint8_t VAR_11;
uint8_t VAR_12;
uint8_t keys[16];
CLASS_1 VAR_13;
uint8_t VAR_14[(VAR_0 * CHIP8_H) / 8];
uint8_t VAR_15[16 * 5];
uint16_t PC;
uint16_t VAR_16[VAR_4];
uint16_t VAR_17;
};
} ID_1;
// Chip8Init() - Initialises the CHIP-8 CPU.
void FUNC_0(CLASS_3 *VAR_18);
// Chip8Cycle() - Read and execute an instruction.
void FUNC_1(CLASS_3 *VAR_18);
// Chip8WaitingForKey() - Returns if the CHIP8 is waiting for a key.
bool FUNC_2(CLASS_3 *VAR_18);
#endif // _CHIP8_H_
| 0.8621 | {'IMPORT_0': 'def.h', 'VAR_0': 'CHIP8_W', 'VAR_1': 'CHIP8_USERMEM_START', 'VAR_2': 'CHIP8_USERMEM_END', 'VAR_3': 'CHIP8_USERMEM_TOTAL', 'VAR_4': 'CHIP8_STACK_MAX', 'CLASS_0': 'tChip8WaitingKey', 'VAR_5': 'val', 'VAR_6': 'reg', 'VAR_7': 'waiting', 'VAR_8': 'unused', 'ID_0': 'Chip8WaitingKey', 'CLASS_1': 'Chip8WaitingKey', 'CLASS_2': 'tChip8', 'VAR_9': 'memory', 'VAR_10': 'V', 'VAR_11': 'soundTimer', 'VAR_12': 'SP', 'VAR_13': 'waitingKey', 'VAR_14': 'display', 'VAR_15': 'font', 'VAR_16': 'stack', 'VAR_17': 'I', 'ID_1': 'Chip8', 'CLASS_3': 'Chip8', 'FUNC_0': 'Chip8Init', 'VAR_18': 'chip8', 'FUNC_1': 'Chip8Cycle', 'FUNC_2': 'Chip8WaitingForKey'} | c | Procedural | 27.22% |
#include <stdio.h>
#include <stdlib.h>
#include "internal.h"
#include "elixr.h"
#include "table.h"
#include "xrstring.h"
#include "symbol.h"
#include "closure.h"
XR xr_double(double num)
{
struct XRDouble *d = malloc(sizeof (struct XRDouble));
d->val = num;
d->mt[-1] = num_vt;
return (XR)d;
}
XR number_string(XR cl, XR self)
{
(void) cl;
char buf[40];
if (xrIsNum(self)) {
sprintf(buf, "%ld", xrInt(self));
} else {
int len = sprintf(buf, "%.16f", ((struct XRDouble *)self)->val);
while (len > 0 && buf[len - 1] == '0') len--;
if (buf[len - 1] == '.') len++;
buf[len] = '\0';
}
return xr_str(buf);
}
XR number_add(XR cl, XR self, XR num)
{
(void) cl;
if (xrIsNum(self) && xrIsNum(num))
return xrNum(xrInt(self) + xrInt(num));
return xr_double(xrDbl(self) + xrDbl(num));
}
XR number_sub(XR cl, XR self, XR num)
{
(void) cl;
if (xrIsNum(self) && xrIsNum(num))
return xrNum(xrInt(self) - xrInt(num));
return xr_double(xrDbl(self) - xrDbl(num));
}
XR number_mul(XR cl, XR self, XR num)
{
(void) cl;
if (xrIsNum(self) && xrIsNum(num))
return xrNum(xrInt(self) * xrInt(num));
return xr_double(xrDbl(self) * xrDbl(num));
}
XR number_div(XR cl, XR self, XR num)
{
(void) cl;
if (xrIsNum(self) && xrIsNum(num))
return xrNum(xrInt(self) / xrInt(num));
return xr_double(xrDbl(self) / xrDbl(num));
}
XR number_pack(XR cl, XR self, FILE *fp)
{
(void) cl;
if (xrIsNum(self)) {
fwrite("N", 1, 1, fp);
fwrite(&self, sizeof(self), 1, fp);
} else {
fwrite("D", 1, 1, fp);
double val = xrDbl(self);
fwrite(&val, sizeof(double), 1, fp);
}
return self;
}
XR number_unpack(FILE *fp)
{
XR d;
fread(&d, sizeof(d), 1, fp);
return d;
}
XR double_unpack(FILE *fp)
{
double d;
fread(&d, sizeof(double), 1, fp);
return xr_double(d);
}
void xr_number_methods(void)
{
#define m(NAME) qdef_method(num_vt, #NAME, number_##NAME)
m(string);
m(pack);
#undef m
qdef_method(num_vt, "literal", number_string);
qdef_method(num_vt, "+", number_add);
qdef_method(num_vt, "-", number_sub);
qdef_method(num_vt, "*", number_mul);
qdef_method(num_vt, "/", number_div);
}
| #include <stdio.h>
#include <IMPORT_0>
#include "IMPORT_1"
#include "elixr.h"
#include "table.h"
#include "IMPORT_2"
#include "symbol.h"
#include "closure.h"
CLASS_0 xr_double(double VAR_0)
{
struct CLASS_1 *d = FUNC_0(sizeof (struct CLASS_1));
d->VAR_1 = VAR_0;
d->mt[-1] = num_vt;
return (ID_0)d;
}
CLASS_0 number_string(CLASS_0 cl, CLASS_0 self)
{
(void) cl;
char buf[40];
if (FUNC_1(self)) {
sprintf(buf, "%ld", FUNC_2(self));
} else {
int len = sprintf(buf, "%.16f", ((struct CLASS_1 *)self)->VAR_1);
while (len > 0 && buf[len - 1] == '0') len--;
if (buf[len - 1] == '.') len++;
buf[len] = '\0';
}
return FUNC_3(buf);
}
CLASS_0 number_add(CLASS_0 cl, CLASS_0 self, CLASS_0 VAR_0)
{
(void) cl;
if (FUNC_1(self) && FUNC_1(VAR_0))
return FUNC_4(FUNC_2(self) + FUNC_2(VAR_0));
return xr_double(FUNC_5(self) + FUNC_5(VAR_0));
}
CLASS_0 number_sub(CLASS_0 cl, CLASS_0 self, CLASS_0 VAR_0)
{
(void) cl;
if (FUNC_1(self) && FUNC_1(VAR_0))
return FUNC_4(FUNC_2(self) - FUNC_2(VAR_0));
return xr_double(FUNC_5(self) - FUNC_5(VAR_0));
}
CLASS_0 FUNC_6(CLASS_0 cl, CLASS_0 self, CLASS_0 VAR_0)
{
(void) cl;
if (FUNC_1(self) && FUNC_1(VAR_0))
return FUNC_4(FUNC_2(self) * FUNC_2(VAR_0));
return xr_double(FUNC_5(self) * FUNC_5(VAR_0));
}
CLASS_0 number_div(CLASS_0 cl, CLASS_0 self, CLASS_0 VAR_0)
{
(void) cl;
if (FUNC_1(self) && FUNC_1(VAR_0))
return FUNC_4(FUNC_2(self) / FUNC_2(VAR_0));
return xr_double(FUNC_5(self) / FUNC_5(VAR_0));
}
CLASS_0 number_pack(CLASS_0 cl, CLASS_0 self, FILE *fp)
{
(void) cl;
if (FUNC_1(self)) {
fwrite("N", 1, 1, fp);
fwrite(&self, sizeof(self), 1, fp);
} else {
fwrite("D", 1, 1, fp);
double VAR_1 = FUNC_5(self);
fwrite(&VAR_1, sizeof(double), 1, fp);
}
return self;
}
CLASS_0 number_unpack(FILE *fp)
{
CLASS_0 d;
fread(&d, sizeof(d), 1, fp);
return d;
}
CLASS_0 double_unpack(FILE *fp)
{
double d;
fread(&d, sizeof(double), 1, fp);
return xr_double(d);
}
void FUNC_7(void)
{
#define m(VAR_3) qdef_method(num_vt, #NAME, number_##NAME)
m(string);
m(pack);
#undef m
FUNC_8(num_vt, "literal", number_string);
FUNC_8(num_vt, "+", number_add);
FUNC_8(num_vt, "-", number_sub);
FUNC_8(num_vt, "*", VAR_2);
FUNC_8(num_vt, "/", number_div);
}
| 0.328065 | {'IMPORT_0': 'stdlib.h', 'IMPORT_1': 'internal.h', 'IMPORT_2': 'xrstring.h', 'CLASS_0': 'XR', 'ID_0': 'XR', 'VAR_0': 'num', 'CLASS_1': 'XRDouble', 'FUNC_0': 'malloc', 'VAR_1': 'val', 'FUNC_1': 'xrIsNum', 'FUNC_2': 'xrInt', 'FUNC_3': 'xr_str', 'FUNC_4': 'xrNum', 'FUNC_5': 'xrDbl', 'FUNC_6': 'number_mul', 'VAR_2': 'number_mul', 'FUNC_7': 'xr_number_methods', 'VAR_3': 'NAME', 'FUNC_8': 'qdef_method'} | c | Procedural | 5.66% |
/****************************************************************************************************//**
* @file FM33A0XX.h
*
* @brief CMSIS Cortex-M0 Peripheral Access Layer Header File for
* FM33A0XX from Keil.
*
* @version V1.1
* @date 30-11-2017
*
* @note Generated with SVDConv V2.87e
* from CMSIS SVD File 'FM32L0XX.SVD' Version 1.0,
*
* @par ARM Limited (ARM) is supplying this software for use with Cortex-M
* processor based microcontroller, but can be equally used for other
* suitable processor architectures. This file can be freely distributed.
* Modifications to this file shall be clearly marked.
*
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
*******************************************************************************************************/
/** @addtogroup Keil
* @{
*/
/** @addtogroup FM33A0XX
* @{
*/
#ifndef FM33A0XX_H
#define FM33A0XX_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, FlagState, IFState;
typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState, FunState;
typedef enum {FAIL = 0, PASS = !FAIL} ErrorStatus, ResState;
typedef enum {
SCU_num = 0, PMU_num = 1, RTC_num = 2, LPTRC_num = 3, CRC_num = 4, TRNG_num = 5,
ADC_num = 6, LCD_num = 7, DMA_num = 8, FLS_num = 9, AES_num = 10, SPI1_num = 11,
SPI2_num = 12, HSPI_num = 13, UART0_num = 14, UART1_num = 15, UART2_num = 16,
UART3_num = 17, UART4_num = 18, UART5_num = 19, U78160_num = 20, U78161_num = 21,
I2C_num = 22, BT1_num = 23, BT2_num = 24, ET1_num = 25, ET2_num = 26, ET3_num = 27,
ET4_num = 28, LPTFC_num = 29, IWDT_num = 30, PDC_num = 31, ANA_num = 32,
EXTI0_num = 33, EXTI1_num = 34, EXTI2_num = 35, DCU_num = 36, RAMBIST_num = 37,
WWDT_num = 38, UART_COM_num = 39,
}Periph_Type;
#define __RCHF_INITIAL_CLOCK (8000000) /* Value of the Internal RC HIGH oscillator in Hz */
#define __RCLP_CLOCK (32000) /* Value of the Internal RC LOW oscillator in Hz */
#define __XTLF_CLOCK (32768) /* Value of the EXTERNAL oscillator in Hz */
/* ------------------------- Interrupt Number Definition ------------------------ */
typedef enum {
/* ------------------- Cortex-M0 Processor Exceptions Numbers ------------------- */
Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */
NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */
HardFault_IRQn = -13, /*!< 3 Hard Fault, all classes of Fault */
SVCall_IRQn = -5, /*!< 11 System Service Call via SVC instruction */
PendSV_IRQn = -2, /*!< 14 Pendable request for system service */
SysTick_IRQn = -1, /*!< 15 System Tick Timer */
/* --------------------- FM32L0XX Specific Interrupt Numbers -------------------- */
WWDT_IRQn = 0, /*!< 0 WWDT */
SVD_IRQn = 1, /*!< 1 SVD_IRQn */
RTC_IRQn = 2, /*!< 2 RTC_IRQn */
NVMIF_IRQn = 3, /*!< 3 NVMIF_IRQn */
FDET_IRQn = 4, /*!< 4 FDET_IRQn */
ADC_IRQn = 5, /*!< 5 ADC_IRQn */
HSPI_IRQn = 6, /*!< 6 HSPI_IRQn */
SPI1_IRQn = 7, /*!< 7 SPI1_IRQn */
SPI2_IRQn = 8, /*!< 8 SPI2_IRQn */
UART0_IRQn = 9, /*!< 9 UART0_IRQn */
UART1_IRQn = 10, /*!< 10 UART1_IRQn */
UART2_IRQn = 11, /*!< 11 UART2_IRQn */
UART3_IRQn = 12, /*!< 12 UART3_IRQn */
UART4_IRQn = 13, /*!< 13 UART4_IRQn */
UART5_IRQn = 14, /*!< 14 UART5_IRQn */
U78160_IRQn = 15, /*!< 15 U78160_IRQn */
U78161_IRQn = 16, /*!< 16 U78161_IRQn */
I2C_IRQn = 17, /*!< 17 I2C_IRQn */
LCD_IRQn = 18, /*!< 18 LCD_IRQn */
AES_IRQn = 19, /*!< 19 AES_IRQn */
LPTIM_IRQn = 20, /*!< 20 LPTIM_IRQn */
DMA_IRQn = 21, /*!< 21 DMA_IRQn */
TRNG_IRQn = 22, /*!< 22 TRNG_IRQnSPI2_IRQn */
COMP_IRQn = 23, /*!< 23 COMP_IRQn */
BTIM1_IRQn = 24, /*!< 24 BTIMER1_IRQn */
BTIM2_IRQn = 25, /*!< 25 BTIMER2_IRQn */
ETIM1_IRQn = 26, /*!< 26 ETIMER1_IRQn */
ETIM2_IRQn = 27, /*!< 27 ETIMER2_IRQn */
ETIM3_IRQn = 28, /*!< 28 ETIMER3_IRQn */
ETIM4_IRQn = 29, /*!< 29 ETIMER4_IRQn */
GPIO_IRQn = 30, /*!< 30 GPIO_IRQn */
} IRQn_Type;
/** @addtogroup Configuration_of_CMSIS
* @{
*/
/* ================================================================================ */
/* ================ Processor and Core Peripheral Section ================ */
/* ================================================================================ */
/* ----------------Configuration of the Cortex-M0 Processor and Core Peripherals---------------- */
#define __CM0_REV 0x0100 /*!< Cortex-M0 Core Revision */
#define __MPU_PRESENT 1 /*!< MPU present or not */
#define __VTOR_PRESENT 1 /*!< VTOR present or not */
#define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
/** @} */ /* End of group Configuration_of_CMSIS */
#include "core_cm0plus.h" /*!< Cortex-M0 processor and core peripherals */
#include "system_FM33A0XX.h" /*!< FM33A0XX System */
/* ================================================================================ */
/* ================ Device Specific Peripheral Section ================ */
/* ================================================================================ */
/** @addtogroup Device_Peripheral_Registers
* @{
*/
/* ------------------- Start of section using anonymous unions ------------------ */
#if defined(__CC_ARM)
#pragma push
#pragma anon_unions
#elif defined(__ICCARM__)
#pragma language=extended
#elif defined(__GNUC__)
/* anonymous unions are enabled by default */
#elif defined(__TMS470__)
/* anonymous unions are enabled by default */
#elif defined(__TASKING__)
#pragma warning 586
#else
#warning Not supported compiler type
#endif
/* ================================================================================ */
/* ================ SCU ================ */
/* ================================================================================ */
typedef struct
{
__I uint32_t SYSCON; /*!< SYSTEM STAT */
__IO uint32_t MCUDBGCR; /*!< DEBUG CONFIG */
__IO uint32_t HDFFLAG; /*!< HARDFAULT FLAG */
}SCU_Type;
/* ================================================================================ */
/* ================ PMU ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t LPMCFG; /*!< LOW POWER CONFIG */
__IO uint32_t WKDLYCON; /*!< WAKEUP DELAY CONFIG */
__IO uint32_t WKPFLAG; /*!< WKPFLAG FLAG */
__IO uint32_t LPREIE; /*!< LPREIE INTERRUPT ENABLE*/
__IO uint32_t LPREIF; /*!< LPREIF INTERRUPT FLAG*/
}PMU_Type;
/* ================================================================================ */
/* ================ uart ================ */
/* ================================================================================ */
/* memory mapping struct for uart IE */
typedef struct
{
__IO uint32_t UARTIE; /*!< UART interrupt enable */
__IO uint32_t UARTIF; /*!< UART interrupt flag */
__IO uint32_t IRCON; /*!< UART infrared control */
} UART_common_Type;
/* memory mapping struct for uart module */
typedef struct
{
__IO uint32_t RXSTA; /*!< UART receive stat Register*/
__IO uint32_t TXSTA; /*!< UART send stat Register */
__IO uint32_t RXREG; /*!< UART receive data Register *8 */
__IO uint32_t TXREG; /*!< UART send data Register *8 */
__IO uint32_t SPBRG; /*!< UART communication baud rate Register */
__IO uint32_t TXBUFSTA; /*!< UART send stat flag Register */
__IO uint32_t RXBUFSTA; /*!< UART receive stat flag Register */
__IO uint32_t RTXCON; /*!< UART signal reverse conctol Register */
} UARTx_Type;
/* ================================================================================ */
/* ================ RCC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RSTCFG; /*!< RESET CONFIG REGISTER*/
__IO uint32_t SOFTRST; /*!< SOFTWARE RESET REGISTER*/
__IO uint32_t RSTFLAG; /*!< RESET FLAG REGISTER */
__IO uint32_t SYSCLKSEL; /*!< SYSCLK SELECT */
__IO uint32_t RCHFCON; /*!< RCHF CONFIG */
__IO uint32_t RCHFTRIM; /*!< RCHF TRIM */
__IO uint32_t PLLCON; /*!< PLL CONFIG */
__IO uint32_t RCLPCON; /*!< RCLP CONFIG */
__IO uint32_t RCLPTRIM; /*!< RCLP TRIM */
__IO uint32_t XTLFIPW; /*!< XTLF WORD STAT SELECT */
__IO uint32_t PERCLKCON1; /*!< PERRIPH RCC SELECT 1 */
__IO uint32_t PERCLKCON2; /*!< PERRIPH RCC SELECT 2 */
__IO uint32_t PERCLKCON3; /*!< PERRIPH RCC SELECT 3 */
__IO uint32_t PERCLKCON4; /*!< PERRIPH RCC SELECT 4 */
__IO uint32_t RSV0; /*!< 238 */
__IO uint32_t RSV1; /*!< 23C */
__IO uint32_t RSV2; /*!< 240 */
__IO uint32_t MPRIL; /*!< PERRIPH RCC SELECT 5 */
}RCC_Type;
/* ================================================================================ */
/* ================ DMA ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t GLOBALCTRL; /*!< GLOBAL EMANLE REGISTER */
__IO uint32_t CH0CTRL; /*!< CHANNEL0 CTRL REGISTER */
__IO uint32_t CH0RAMAD; /*!< CHANNEL0 RAM START ADDR */
__IO uint32_t CH1CTRL; /*!< CHANNEL1 CTRL REGISTER */
__IO uint32_t CH1RAMAD; /*!< CHANNEL1 RAM START ADDR */
__IO uint32_t CH2CTRL; /*!< CHANNEL2 CTRL REGISTER */
__IO uint32_t CH2RAMAD; /*!< CHANNEL2 RAM START ADDR */
__IO uint32_t CH3CTRL; /*!< CHANNEL3 CTRL REGISTER */
__IO uint32_t CH3RAMAD; /*!< CHANNEL3 RAM START ADDR */
__IO uint32_t CH4CTRL; /*!< CHANNEL4 CTRL REGISTER */
__IO uint32_t CH4RAMAD; /*!< CHANNEL4 RAM START ADDR */
__IO uint32_t CH5CTRL; /*!< CHANNEL5 CTRL REGISTER */
__IO uint32_t CH5RAMAD; /*!< CHANNEL5 RAM START ADDR */
__IO uint32_t CH6CTRL; /*!< CHANNEL6 CTRL REGISTER */
__IO uint32_t CH6RAMAD; /*!< CHANNEL6 RAM START ADDR */
__IO uint32_t CH7CTRL; /*!< CHANNEL7 CTRL REGISTER */
__IO uint32_t CH7FLSAD; /*!< CHANNEL7 FLASH START ADDR */
__IO uint32_t CH7RAMAD; /*!< CHANNEL7 RAM START ADDR */
__IO uint32_t CHSTATUS; /*!< INTERRUPT FLAG REGISTER */
}DMA_Type;
/* ================================================================================ */
/* ================ HSPI ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t SPICR1; /*!< SPI CONTROL REGISTER 1 */
__IO uint32_t SPICR2; /*!< SPI CONTROL REGISTER 2 */
__IO uint32_t SPICR3; /*!< SPI CONTROL REGISTER 3 */
__IO uint32_t SPIIE; /*!< SPI INTERRUPT ENABLE REGISTER */
__IO uint32_t SPIIF; /*!< SPI STATE REGISTER */
__IO uint32_t SPITXBUF; /*!< SPI TX REGISTER */
__IO uint32_t SPIRXBUF; /*!< SPI RX REGISTER */
}SPIx_Type;
/* ================================================================================ */
/* ================ GPIO ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t INEN; /*!< INPUT ENABLE CONFIG */
__IO uint32_t PUEN; /*!< PULLUP ENABLE CONFIG */
__IO uint32_t ODEN; /*!< OD ENABLE CONFIG */
__IO uint32_t FCR; /*!< FUNCTION CONFIG */
__IO uint32_t DO; /*!< output data register */
__O uint32_t DSET; /*!< bit set HIGH register */
__O uint32_t DRESET; /*!< bit reset low register */
__I uint32_t DIN; /*!< input data register */
}GPIOx_Type;
typedef struct
{
__IO uint32_t EXTI0_SEL; /*!< EDGE TRIGER SELECT CONFIG 0, Address offset: 0x00 */
__IO uint32_t EXTI1_SEL; /*!< EDGE TRIGER SELECT CONFIG 1, Address offset: 0x04 */
__IO uint32_t EXTI2_SEL; /*!< EDGE TRIGER SELECT CONFIG 2, Address offset: 0x08 */
__IO uint32_t EXTI0IF; /*!< triger flag 0, Address offset: 0x0C */
__IO uint32_t EXTI1IF; /*!< triger flag 1, Address offset: 0x10 */
__IO uint32_t EXTI2IF; /*!< triger flag 2, Address offset: 0x14 */
__IO uint32_t FOUTSEL; /*!< fout select config, Address offset: 0x18 */
__IO uint32_t HDSEL; /*!< high driver config, Address offset: 0x1C */
__IO uint32_t ANASEL; /*!< analog function select, Address offset: 0x20 */
__IO uint32_t IODF; /*!< input digit filter select, Address offset: 0x24 */
__IO uint32_t PINWKEN; /*!< pin wakeup enable, Address offset: 0x28 */
}GPIO_COMMON_Type;
/* ================================================================================ */
/* ================ IWDG ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t IWDTSERV; /*!< IWDG Key register, Address offset: 0x00 */
__IO uint32_t IWDTCFG; /*!< IWDG CONFIG register, Address offset: 0x04 */
__I uint32_t IWDTCNT; /*!< IWDG Reload register, Address offset: 0x08 */
} IWDT_Type;
/* ================================================================================ */
/* ================ NVMIF ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t FLSRDCON; /*!< NVMIF read control register, Address offset: 0x00 */
__IO uint32_t PRFTCON; /*!< NVMIF prdfatch control register, Address offset: 0x04 */
__I uint32_t OPTBR; /*!< NVMIF port protect stat register, Address offset: 0x08 */
__IO uint32_t ACLOCK1; /*!< NVMIF flash block0-31 protect register,wr 1 only Address offset: 0x0C */
__IO uint32_t ACLOCK2; /*!< NVMIF flash block32-63 protect register,wr 1 only Address offset: 0x10 */
__IO uint32_t EPCON; /*!< NVMIF erase & program start register Address offset: 0x14 */
__IO uint32_t FLSKEY; /*!< NVMIF flash key register Address offset: 0x18 */
__IO uint32_t FLSIE; /*!< NVMIF flash IE register Address offset: 0x1C */
__IO uint32_t FLSIF; /*!< NVMIF flash IF register Address offset: 0x20 */
__IO uint32_t RAMRPR0; /*!< NVMIF RAM REPAIR0 register Address offset: 0x24 */
__IO uint32_t RAMRPR1; /*!< NVMIF RAM REPAIR1 register Address offset: 0x28 */
__IO uint32_t RAMRPR2; /*!< NVMIF RAM REPAIR2 register Address offset: 0x2C */
__IO uint32_t RAMRPR3; /*!< NVMIF RAM REPAIR3 register Address offset: 0x30 */
} NVMIF_Type;
/* ================================================================================ */
/* ================ RAMBIST ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RAMBISTCON; /*!< RAMBIST control register, Address offset: 0x00 */
__IO uint32_t RAMFF; /*!< RAMBIST error flag register, Address offset: 0x04 */
} RAMBIST_Type;
/* ================================================================================ */
/* ================ BTIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t BTCR1; /*!< BTIMER CONTROL REGISTER 1, Address offset: 0x00 */
__IO uint32_t BTCR2; /*!< BTIMER CONTROL REGISTER 2, Address offset: 0x04 */
__IO uint32_t BTCFG1; /*!< BTIMER CONFIG REGISTER 1, Address offset: 0x08 */
__IO uint32_t BTCFG2; /*!< BTIMER CONFIG REGISTER 2, Address offset: 0x0C */
__IO uint32_t BTPRES; /*!< BTIMER PRESCALE VALUE, Address offset: 0x10 */
__IO uint32_t BTLOADCR; /*!< BTIMER LOAD CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t BTCNTL; /*!< BTIMER COUNTER LOW BYTE, Address offset: 0x18 */
__IO uint32_t BTCNTH; /*!< BTIMER COUNTER HIGH BYTE, Address offset: 0x1C */
__IO uint32_t BTPRESET; /*!< ETIMER PRESET VALUE, Address offset: 0x20 */
__IO uint32_t BTLOADL; /*!< ETIMER LOAD VALUE LOW BYTE, Address offset: 0x24 */
__IO uint32_t BTLOADH; /*!< ETIMER LOAD VALUE HIGH BYTE, Address offset: 0x28 */
__IO uint32_t BTCMPL; /*!< ETIMER CMP LOW, Address offset: 0x2C */
__IO uint32_t BTCMPH; /*!< ETIMER CMP HIGH, Address offset: 0x30 */
__IO uint32_t BTOUTCNT; /*!< ETIMER OUTPUT PULSE VALUE, Address offset: 0x34 */
__IO uint32_t BTOCR; /*!< ETIMER OUTPUT CONTROL REGISTER, Address offset: 0x38 */
__IO uint32_t BTIE; /*!< ETIMER INTERRUPT ENABLE, Address offset: 0x3C */
__IO uint32_t BTIF; /*!< ETIMER INTERRUPT FLAG & STATUS, Address offset: 0x40 */
} BTIMx_Type;
/* ================================================================================ */
/* ================ ETIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t ETxCR; /*!< ETIMER CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t ETxINSEL; /*!< ETIMER INPUT SELECT REGISTER, Address offset: 0x04 */
__IO uint32_t ETxPESCALE1; /*!< ETIMER PRESCALE REGISTER 1, Address offset: 0x08 */
__IO uint32_t ETxPESCALE2; /*!< ETIMER PRESCALE REGISTER 2, Address offset: 0x0C */
__IO uint32_t ETxIVR; /*!< ETIMER INITIAL VALUE, Address offset: 0x10 */
__IO uint32_t ETxCMP; /*!< ETIMER CMP REGISTER, Address offset: 0x14 */
__IO uint32_t ETxIE; /*!< ETIMER INTERRUPT ENABLE, Address offset: 0x18 */
__IO uint32_t ETxIF; /*!< ETIMER INTERRUPT FLAG & STATUS, Address offset: 0x1C */
} ETIMx_Type;
/* ================================================================================ */
/* ================ LPTIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t LPTCFG; /*!< LPTIM CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t LPTCNT; /*!< LPTIM COUNT REGISTER, Address offset: 0x04 */
__IO uint32_t LPTCMP; /*!< LPTIM COMPARE REGISTER, Address offset: 0x08 */
__IO uint32_t LPTTARGET; /*!< LPTIM TARGET REGISTER, Address offset: 0x0C */
__IO uint32_t LPTIE; /*!< LPTIM INTERRUPT ENABLE, Address offset: 0x10 */
__IO uint32_t LPTIF; /*!< LPTIM INTERRUPT FLAG REGISTER, Address offset: 0x14 */
__IO uint32_t LPTCTRL; /*!< LPTIM CONTROL REGISTER, Address offset: 0x18 */
} LPTIM_Type;
/* ================================================================================ */
/* ================ I2C ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t I2CCTRL; /*!< I2C CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t I2CSTA; /*!< I2C STATE REGISTER, Address offset: 0x04 */
__IO uint32_t I2CBRG; /*!< I2C BAUD SETTING REGISTER, Address offset: 0x08 */
__IO uint32_t I2CBUF; /*!< I2C BUFF REGISTER, Address offset: 0x0C */
__IO uint32_t I2CIR; /*!< I2C INTERRUPT ENABLE & FLAG, Address offset: 0x10 */
__IO uint32_t I2CFSM; /*!< I2C FSM STATE REGISTER, Address offset: 0x14 */
__IO uint32_t I2CERR; /*!< I2C ERR FLAG REGISTER, Address offset: 0x18 */
} I2C_Type;
/* ================================================================================ */
/* ================ ANAC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t PDRCON; /*!< ANAC PDR CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t BORCON; /*!< ANAC BOR CONFIG REGISTER, Address offset: 0x04 */
__IO uint32_t LDO15CON; /*!< ANAC LDO15CON CONFIG REGISTER, Address offset: 0x08 */
__IO uint32_t VREFTRIM; /*!< ANAC VREF TRIM REGISTER, Address offset: 0x0C */
__IO uint32_t ULPRCON; /*!< ANAC ULP LDO CONFIG REGISTER, Address offset: 0x10 */
__IO uint32_t SVDCFG; /*!< ANAC SVD CONFIG REGISTER, Address offset: 0x14 */
__IO uint32_t SVDCON; /*!< ANAC SVD CONTROL REGISTER, Address offset: 0x18 */
__IO uint32_t SVDSIF; /*!< ANAC SVD INTERRUPT FLAG REGISTER, Address offset: 0x1C */
__IO uint32_t FDETIE; /*!< ANAC FDET INTERRUPT ENABLE REGISTER, Address offset: 0x20 */
__IO uint32_t FDETIF; /*!< ANAC FDET INTERRUPT FLAG REGISTER, Address offset: 0x24 */
__IO uint32_t ADCINSEL; /*!< ANAC INPUT SELECT REGISTER, Address offset: 0x28 */
__IO uint32_t ADCCON; /*!< ANAC ADC CONFIG REGISTER, Address offset: 0x2C */
__IO uint32_t ADCTRIM; /*!< ANAC ADC TRIM REGISTER, Address offset: 0x30 */
__IO uint32_t ADCDATA; /*!< ANAC ADC DATA REGISTER, Address offset: 0x34 */
__IO uint32_t ADCIF; /*!< ANAC ADC INTERRUPT FLAG REGISTER, Address offset: 0x38 */
__IO uint32_t TRNGCON; /*!< ANAC TRNF ENABLE REGISTER, Address offset: 0x3C */
__IO uint32_t COMP1CR; /*!< ANAC COMP1 CONTROL REGISTER, Address offset: 0x40 */
__IO uint32_t COMP2CR; /*!< ANAC COMP2 CONTROL REGISTER, Address offset: 0x44 */
__IO uint32_t COMPICR; /*!< ANAC COMP12 INTERRUPT CONTROL REGISTER, Address offset: 0x48 */
__IO uint32_t COMPIF; /*!< ANAC COMP INTERRUPT FLAG REGISTER, Address offset: 0x4C */
__IO uint32_t RSV0;
__IO uint32_t RSV1;
__IO uint32_t RSV2;
__IO uint32_t SVDALM; /*!< ANAC SVDALM REGISTER, Address offset: 0x5C */
} ANAC_Type;
/* ================================================================================ */
/* ================ CRC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t CRCDR; /*!< CRC DATA REGISTER, Address offset: 0x00 */
__IO uint32_t CRCCR; /*!< CRC CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t CRCLFSR; /*!< CRC LFSR REGISTER, Address offset: 0x08 */
__IO uint32_t CRCXOR; /*!< CRC XOR DATA REGISTER, Address offset: 0x0C */
__IO uint32_t CRCFLSEN; /*!< CRC FLASH CRC VERIFY EN REGISTER, Address offset: 0x10 */
__IO uint32_t CRCFLSAD; /*!< CRC FLASH ADRESS REGISTER, Address offset: 0x14 */
__IO uint32_t CRCFLSSIZE; /*!< CRC VERIFY SIZE REGISTER, Address offset: 0x18 */
} CRC_Type;
/* ================================================================================ */
/* ================ DISP ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t DISPCTRL; /*!< DISP CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t LCDTEST; /*!< DISP TEST CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t DF; /*!< DISP DIVIDE CLK SETTING REGISTER, Address offset: 0x08 */
__IO uint32_t TON; /*!< DISP ON SETTING REGISTER, Address offset: 0x0C */
__IO uint32_t TOFF; /*!< DISP OFF SETTING REGISTER, Address offset: 0x10 */
__IO uint32_t DISPIE; /*!< DISP INTERRUPT CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t DISPIF; /*!< DISP INTERRUPT FLAG REGISTER, Address offset: 0x18 */
__IO uint32_t LCDSET; /*!< DISP SETTING REGISTER, Address offset: 0x1C */
__IO uint32_t LCDDRV; /*!< DISP DRV SETTING REGISTER, Address offset: 0x20 */
__IO uint32_t DISPDATA0; /*!< DISP DATA REGISTER 0, Address offset: 0x24 */
__IO uint32_t DISPDATA1; /*!< DISP DATA REGISTER 1, Address offset: 0x28 */
__IO uint32_t DISPDATA2; /*!< DISP DATA REGISTER 2, Address offset: 0x2C */
__IO uint32_t DISPDATA3; /*!< DISP DATA REGISTER 3, Address offset: 0x30 */
__IO uint32_t DISPDATA4; /*!< DISP DATA REGISTER 4, Address offset: 0x34 */
__IO uint32_t DISPDATA5; /*!< DISP DATA REGISTER 5, Address offset: 0x38 */
__IO uint32_t DISPDATA6; /*!< DISP DATA REGISTER 6, Address offset: 0x3C */
__IO uint32_t DISPDATA7; /*!< DISP DATA REGISTER 7, Address offset: 0x40 */
__IO uint32_t DISPDATA8; /*!< DISP DATA REGISTER 8, Address offset: 0x44 */
__IO uint32_t DISPDATA9; /*!< DISP DATA REGISTER 9, Address offset: 0x48 */
__IO uint32_t LCDBIAS; /*!< DISP BIAS SETTING REGISTER, Address offset: 0x4C */
__IO uint32_t COM_EN; /*!< DISP COM SETTING REGISTER, Address offset: 0x50 */
__IO uint32_t SEG_EN0; /*!< DISP SEG SETTING REGISTER, Address offset: 0x54 */
__IO uint32_t SEG_EN1; /*!< DISP SEG SETTING REGISTER, Address offset: 0x58 */
__IO uint32_t LCDBSTCON; /*!< DISP BOOST CONFIG REGISTER, Address offset: 0x5C */
} DISP_Type;
/* ================================================================================ */
/* ================ RTC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RTCWE; /*!< RTC WRITE PROTECT REGISTER, Address offset: 0x00 */
__IO uint32_t RTCIE; /*!< RTC INTERRUPT CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t RTCIF; /*!< RTC INTERRUPT FLAG REGISTER, Address offset: 0x08 */
__IO uint32_t BCDSEC; /*!< RTC SECOND IN BCD REGISTER, Address offset: 0x0C */
__IO uint32_t BCDMIN; /*!< RTC MINITE IN BCD REGISTER, Address offset: 0x10 */
__IO uint32_t BCDHOUR; /*!< RTC HOUR IN BCD REGISTER, Address offset: 0x14 */
__IO uint32_t BCDDATE; /*!< RTC DATE IN BCD REGISTER, Address offset: 0x18 */
__IO uint32_t BCDWEEK; /*!< RTC WEEK IN BCD REGISTER, Address offset: 0x1C */
__IO uint32_t BCDMONTH; /*!< RTC MONTH IN BCD REGISTER, Address offset: 0x20 */
__IO uint32_t BCDYEAR; /*!< RTC YEAR IN BCD REGISTER, Address offset: 0x24 */
__IO uint32_t ALARM; /*!< RTC ALARM SETTING REGISTER, Address offset: 0x28 */
__IO uint32_t FSEL; /*!< RTC OUTPUT SELECT REGISTER, Address offset: 0x2C */
__IO uint32_t ADJUST; /*!< RTC LTBC ADJUST REGISTER, Address offset: 0x30 */
__IO uint32_t ADSIGN; /*!< RTC LTBC ADJUST SIGN REGISTER, Address offset: 0x34 */
__IO uint32_t PR1SEN; /*!< RTC LTBC 1SEC ENABLE REGISTER, Address offset: 0x38 */
__IO uint32_t MSECCNT; /*!< RTC MS COUNTER REGISTER, Address offset: 0x3C */
__IO uint32_t STAMPEN; /*!< RTC TIME STAMP REGISTER, Address offset: 0x40 */
__IO uint32_t CLKSTAMP0R; /*!< RTC STAMP AT PB4 RISE REGISTER 0, Address offset: 0x44 */
__IO uint32_t CALSTAMP0R; /*!< RTC STAMP AT PB4 RISE REGISTER 0, Address offset: 0x48 */
__IO uint32_t CLKSTAMP0F; /*!< RTC STAMP AT PB4 FALL REGISTER 0, Address offset: 0x4C */
__IO uint32_t CALSTAMP0F; /*!< RTC STAMP AT PB4 FALL REGISTER 0, Address offset: 0x50 */
__IO uint32_t CLKSTAMP1R; /*!< RTC STAMP AT PB4 RISE REGISTER 1, Address offset: 0x54 */
__IO uint32_t CALSTAMP1R; /*!< RTC STAMP AT PB4 RISE REGISTER 1, Address offset: 0x58 */
__IO uint32_t CLKSTAMP1F; /*!< RTC STAMP AT PB4 FALL REGISTER 1, Address offset: 0x5C */
__IO uint32_t CALSTAMP1F; /*!< RTC STAMP AT PB4 FALL REGISTER 1, Address offset: 0x60 */
} RTC_Type;
/* ================================================================================ */
/* ================ AES ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t AESCR; /*!< AES CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t AESIF; /*!< AES INTERRUPT FLAG REGISTER, Address offset: 0x04 */
__IO uint32_t AESDIN; /*!< AES DATA INPUT REGISTER, Address offset: 0x08 */
__IO uint32_t AESDOUT; /*!< AES DATA OUTPUT REGISTER, Address offset: 0x0C */
__IO uint32_t AESKEY0; /*!< AES KEY LOW WORD REGISTER 0, Address offset: 0x10 */
__IO uint32_t AESKEY1; /*!< AES KEY REGISTER 1, Address offset: 0x14 */
__IO uint32_t AESKEY2; /*!< AES KEY REGISTER 2, Address offset: 0x18 */
__IO uint32_t AESKEY3; /*!< AES KEY REGISTER 3, Address offset: 0x1C */
__IO uint32_t AESKEY4; /*!< AES KEY REGISTER 4, Address offset: 0x20 */
__IO uint32_t AESKEY5; /*!< AES KEY REGISTER 5, Address offset: 0x24 */
__IO uint32_t AESKEY6; /*!< AES KEY REGISTER 6, Address offset: 0x28 */
__IO uint32_t AESKEY7; /*!< AES KEY REGISTER 7, Address offset: 0x2C */
__IO uint32_t AESIVR0; /*!< AES INITIAL DATA REGISTER 0, Address offset: 0x30 */
__IO uint32_t AESIVR1; /*!< AES INITIAL DATA REGISTER 1, Address offset: 0x34 */
__IO uint32_t AESIVR2; /*!< AES INITIAL DATA REGISTER 2, Address offset: 0x38 */
__IO uint32_t AESIVR3; /*!< AES INITIAL DATA REGISTER 3, Address offset: 0x3C */
} AES_Type;
/* ================================================================================ */
/* ================ U7816 ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t U7816CTRL; /*!< U7816 CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t U7816FRC; /*!< U7816 FRAME CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t U7816EGT; /*!< U7816 EGT CONFIG REGISTER, Address offset: 0x08 */
__IO uint32_t U7816CLKDIV; /*!< U7816 CLK DIVIDED REGISTER, Address offset: 0x0C */
__IO uint32_t U7816PDIV; /*!< U7816 PREDIVIDED REGISTER, Address offset: 0x10 */
__IO uint32_t U7816RXBUF; /*!< U7816 RX BUFFER REGISTER, Address offset: 0x14 */
__IO uint32_t U7816TXBUF; /*!< U7816 TX BUFFER REGISTER, Address offset: 0x18 */
__IO uint32_t U7816IE; /*!< U7816 INTERRUPT ENABLE REGISTER, Address offset: 0x1C */
__IO uint32_t U7816IF; /*!< U7816 INTERRUPT FLAG REGISTER, Address offset: 0x20 */
__IO uint32_t U7816ERR; /*!< U7816 ERR FLAG REGISTER, Address offset: 0x24 */
__IO uint32_t U7816STA; /*!< U7816 STATE REGISTER, Address offset: 0x28 */
} U7816x_Type;
/* ================================================================================ */
/* ================ WWDT ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t WWDTCON; /*!< WWDT CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t WWDTCFG; /*!< WWDT CONFIG REGISTER, Address offset: 0x04 */
__IO uint32_t WWDTCNT; /*!< WWDT COUNTER REGISTER, Address offset: 0x08 */
__IO uint32_t WWDTIE; /*!< WWDT INTERRUPT ENABLE REGISTER, Address offset: 0x0C */
__IO uint32_t WWDTIF; /*!< WWDT INTERRUPT FLAG REGISTER, Address offset: 0x10 */
__IO uint32_t WWDTDIV; /*!< WWDT WWDTDIV REGISTER, Address offset: 0x14 */
} WWDT_Type;
/* ================================================================================ */
/* ================ TRNG ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RSV0; /*!< RESERVED Address offset: 0x00 */
__IO uint32_t RNGOUT; /*!< TRNG OUTPUT REGISTER, Address offset: 0x04 */
__IO uint32_t RSV1; /*!< RESERVED Address offset: 0x08 */
__IO uint32_t RNGIE; /*!< TRNG INTERRUPT ENABLE REGISTER, Address offset: 0x0C */
__IO uint32_t RNGIF; /*!< TRNG INTERRUPT FLAG REGISTER, Address offset: 0x10 */
__IO uint32_t CRCCON; /*!< TRNG CRC CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t CRCIN; /*!< TRNG CRC INPUT REGISTER, Address offset: 0x18 */
__IO uint32_t CRCFLAG; /*!< TRNG CRC CRCFLAG REGISTER, Address offset: 0x1C */
} TRNG_Type;
/* -------------------- End of section using anonymous unions ------------------- */
#if defined(__CC_ARM)
#pragma pop
#elif defined(__ICCARM__)
/* leave anonymous unions enabled */
#elif defined(__GNUC__)
/* anonymous unions are enabled by default */
#elif defined(__TMS470__)
/* anonymous unions are enabled by default */
#elif defined(__TASKING__)
#pragma warning restore
#else
#warning Not supported compiler type
#endif
/* ================================================================================ */
/* ================ CPU memory map ================ */
/* ================================================================================ */
/* Peripheral and SRAM base address */
#define FLASH_BASE (( uint32_t)0x00000000)
#define SRAM_BASE (( uint32_t)0x20000000)
#define PERIPH_BASE (( uint32_t)0x40000000)
/* ================================================================================ */
/* ================ Peripheral memory map ================ */
/* ================================================================================ */
/* Peripheral memory map */
#define SCU_BASE (PERIPH_BASE +0x00000000)
#define PMU_BASE (PERIPH_BASE +0x00000100)
#define RCC_BASE (PERIPH_BASE +0x00000200)
#define DMA_BASE (PERIPH_BASE +0x00000400)
#define HSPI_BASE (PERIPH_BASE +0x00000800)
#define SPI1_BASE (PERIPH_BASE +0x00000840)
#define SPI2_BASE (PERIPH_BASE +0x00000880)
#define GPIOA_BASE (PERIPH_BASE +0x00000C00)
#define GPIOB_BASE (PERIPH_BASE +0x00000C20)
#define GPIOC_BASE (PERIPH_BASE +0x00000C40)
#define GPIOD_BASE (PERIPH_BASE +0x00000C60)
#define GPIOE_BASE (PERIPH_BASE +0x00000C80)
#define GPIOF_BASE (PERIPH_BASE +0x00000CA0)
#define GPIOG_BASE (PERIPH_BASE +0x00000CC0)
#define GPIO_COMMON_BASE (PERIPH_BASE +0x00000CE0)
#define NVMIF_BASE (PERIPH_BASE +0x00001000)
#define CRC_BASE (PERIPH_BASE +0x00010000)
#define DISP_BASE (PERIPH_BASE +0x00010C00)
#define RTC_BASE (PERIPH_BASE +0x00011000)
#define IWDT_BASE (PERIPH_BASE +0x00011400)
#define WWDT_BASE (PERIPH_BASE +0x00011800)
#define U78160_BASE (PERIPH_BASE +0x00011C00)
#define U78161_BASE (PERIPH_BASE +0x00011C2C)
#define UART_COMMON_BASE (PERIPH_BASE +0x00012000)
#define UART0_BASE (PERIPH_BASE +0x0001200C)
#define UART1_BASE (PERIPH_BASE +0x0001202C)
#define UART2_BASE (PERIPH_BASE +0x0001204C)
#define UART3_BASE (PERIPH_BASE +0x0001206C)
#define UART4_BASE (PERIPH_BASE +0x0001208C)
#define UART5_BASE (PERIPH_BASE +0x000120AC)
#define I2C_BASE (PERIPH_BASE +0x00012400)
#define ANAC_BASE (PERIPH_BASE +0x00012800)
#define RAMBIST_BASE (PERIPH_BASE +0x00012C00)
#define BTIMER1_BASE (PERIPH_BASE +0x00013000)
#define BTIMER2_BASE (PERIPH_BASE +0x00013044)
#define ETIMER1_BASE (PERIPH_BASE +0x00013090)
#define ETIMER2_BASE (PERIPH_BASE +0x000130B0)
#define ETIMER3_BASE (PERIPH_BASE +0x000130D0)
#define ETIMER4_BASE (PERIPH_BASE +0x000130F0)
#define LPTIM_BASE (PERIPH_BASE +0x00013400)
#define AES_BASE (PERIPH_BASE +0x00013800)
#define TRNG_BASE (PERIPH_BASE +0x00013C00)
/* ================================================================================ */
/* ================ Peripheral declaration ================ */
/* ================================================================================ */
#define SCU ((SCU_Type *) SCU_BASE )
#define PMU ((PMU_Type *) PMU_BASE )
#define RCC ((RCC_Type *) RCC_BASE )
#define DMA ((DMA_Type *) DMA_BASE )
#define HSPI ((SPIx_Type *) HSPI_BASE )
#define SPI1 ((SPIx_Type *) SPI1_BASE )
#define SPI2 ((SPIx_Type *) SPI2_BASE )
#define NVMIF ((NVMIF_Type *) NVMIF_BASE )
#define FLASH ((NVMIF_Type *) NVMIF_BASE )
#define UART ((UART_common_Type *) UART_COMMON_BASE )
#define UART0 ((UARTx_Type *) UART0_BASE )
#define UART1 ((UARTx_Type *) UART1_BASE )
#define UART2 ((UARTx_Type *) UART2_BASE )
#define UART3 ((UARTx_Type *) UART3_BASE )
#define UART4 ((UARTx_Type *) UART4_BASE )
#define UART5 ((UARTx_Type *) UART5_BASE )
#define IWDT ((IWDT_Type *) IWDT_BASE )
#define GPIOA ((GPIOx_Type *) GPIOA_BASE )
#define GPIOB ((GPIOx_Type *) GPIOB_BASE )
#define GPIOC ((GPIOx_Type *) GPIOC_BASE )
#define GPIOD ((GPIOx_Type *) GPIOD_BASE )
#define GPIOE ((GPIOx_Type *) GPIOE_BASE )
#define GPIOF ((GPIOx_Type *) GPIOF_BASE )
#define GPIOG ((GPIOx_Type *) GPIOG_BASE )
#define GPIO ((GPIO_COMMON_Type *) GPIO_COMMON_BASE )
#define RAMBIST ((RAMBIST_Type *) RAMBIST_BASE )
#define BTIM1 ((BTIMx_Type *) BTIMER1_BASE )
#define BTIM2 ((BTIMx_Type *) BTIMER2_BASE )
#define ETIM1 ((ETIMx_Type *) ETIMER1_BASE )
#define ETIM2 ((ETIMx_Type *) ETIMER2_BASE )
#define ETIM3 ((ETIMx_Type *) ETIMER3_BASE )
#define ETIM4 ((ETIMx_Type *) ETIMER4_BASE )
#define LPTIM ((LPTIM_Type *) LPTIM_BASE )
#define ANAC ((ANAC_Type *) ANAC_BASE )
#define WWDT ((WWDT_Type *) WWDT_BASE )
#define I2C ((I2C_Type *) I2C_BASE )
#define CRC ((CRC_Type *) CRC_BASE )
#define LCD ((DISP_Type *) DISP_BASE )
#define RTC ((RTC_Type *) RTC_BASE )
#define U78160 ((U7816x_Type *) U78160_BASE )
#define U78161 ((U7816x_Type *) U78161_BASE )
#define AES ((AES_Type *) AES_BASE )
#define TRNG ((TRNG_Type *) TRNG_BASE )
/* ================================================================================ */
/* ================ Peripheral include ================ */
/* ================================================================================ */
/** @} */ /* End of group Device_Peripheral_Registers */
/** @} */ /* End of group FM32L0XX */
/** @} */ /* End of group Keil */
#ifdef __cplusplus
}
#endif
#endif /* FM33A0XX_H */
|
/****************************************************************************************************//**
* @file FM33A0XX.h
*
* @brief CMSIS Cortex-M0 Peripheral Access Layer Header File for
* FM33A0XX from Keil.
*
* @version V1.1
* @date 30-11-2017
*
* @note Generated with SVDConv V2.87e
* from CMSIS SVD File 'FM32L0XX.SVD' Version 1.0,
*
* @par ARM Limited (ARM) is supplying this software for use with Cortex-M
* processor based microcontroller, but can be equally used for other
* suitable processor architectures. This file can be freely distributed.
* Modifications to this file shall be clearly marked.
*
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
*******************************************************************************************************/
/** @addtogroup Keil
* @{
*/
/** @addtogroup FM33A0XX
* @{
*/
#ifndef FM33A0XX_H
#define FM33A0XX_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {VAR_0 = 0, VAR_1 = !VAR_0} ID_0, ID_1, ID_2, IFState;
typedef enum {VAR_2 = 0, VAR_3 = !VAR_2} ID_3, FunState;
typedef enum {VAR_4 = 0, PASS = !VAR_4} ErrorStatus, ID_4;
typedef enum {
VAR_5 = 0, PMU_num = 1, RTC_num = 2, LPTRC_num = 3, VAR_6 = 4, VAR_7 = 5,
ADC_num = 6, LCD_num = 7, DMA_num = 8, FLS_num = 9, AES_num = 10, SPI1_num = 11,
SPI2_num = 12, HSPI_num = 13, UART0_num = 14, UART1_num = 15, UART2_num = 16,
UART3_num = 17, VAR_8 = 18, VAR_9 = 19, U78160_num = 20, U78161_num = 21,
VAR_10 = 22, VAR_11 = 23, VAR_12 = 24, ET1_num = 25, ET2_num = 26, ET3_num = 27,
ET4_num = 28, VAR_13 = 29, IWDT_num = 30, PDC_num = 31, VAR_14 = 32,
EXTI0_num = 33, VAR_15 = 34, VAR_16 = 35, VAR_17 = 36, RAMBIST_num = 37,
WWDT_num = 38, UART_COM_num = 39,
}Periph_Type;
#define VAR_18 (8000000) /* Value of the Internal RC HIGH oscillator in Hz */
#define __RCLP_CLOCK (32000) /* Value of the Internal RC LOW oscillator in Hz */
#define __XTLF_CLOCK (32768) /* Value of the EXTERNAL oscillator in Hz */
/* ------------------------- Interrupt Number Definition ------------------------ */
typedef enum {
/* ------------------- Cortex-M0 Processor Exceptions Numbers ------------------- */
Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */
NonMaskableInt_IRQn = -14, /*!< 2 Non maskable Interrupt, cannot be stopped or preempted */
VAR_19 = -13, /*!< 3 Hard Fault, all classes of Fault */
VAR_20 = -5, /*!< 11 System Service Call via SVC instruction */
PendSV_IRQn = -2, /*!< 14 Pendable request for system service */
SysTick_IRQn = -1, /*!< 15 System Tick Timer */
/* --------------------- FM32L0XX Specific Interrupt Numbers -------------------- */
VAR_21 = 0, /*!< 0 WWDT */
SVD_IRQn = 1, /*!< 1 SVD_IRQn */
RTC_IRQn = 2, /*!< 2 RTC_IRQn */
NVMIF_IRQn = 3, /*!< 3 NVMIF_IRQn */
FDET_IRQn = 4, /*!< 4 FDET_IRQn */
VAR_22 = 5, /*!< 5 ADC_IRQn */
HSPI_IRQn = 6, /*!< 6 HSPI_IRQn */
VAR_23 = 7, /*!< 7 SPI1_IRQn */
SPI2_IRQn = 8, /*!< 8 SPI2_IRQn */
UART0_IRQn = 9, /*!< 9 UART0_IRQn */
UART1_IRQn = 10, /*!< 10 UART1_IRQn */
UART2_IRQn = 11, /*!< 11 UART2_IRQn */
VAR_24 = 12, /*!< 12 UART3_IRQn */
VAR_25 = 13, /*!< 13 UART4_IRQn */
UART5_IRQn = 14, /*!< 14 UART5_IRQn */
U78160_IRQn = 15, /*!< 15 U78160_IRQn */
U78161_IRQn = 16, /*!< 16 U78161_IRQn */
I2C_IRQn = 17, /*!< 17 I2C_IRQn */
VAR_26 = 18, /*!< 18 LCD_IRQn */
AES_IRQn = 19, /*!< 19 AES_IRQn */
LPTIM_IRQn = 20, /*!< 20 LPTIM_IRQn */
DMA_IRQn = 21, /*!< 21 DMA_IRQn */
VAR_27 = 22, /*!< 22 TRNG_IRQnSPI2_IRQn */
VAR_28 = 23, /*!< 23 COMP_IRQn */
BTIM1_IRQn = 24, /*!< 24 BTIMER1_IRQn */
BTIM2_IRQn = 25, /*!< 25 BTIMER2_IRQn */
ETIM1_IRQn = 26, /*!< 26 ETIMER1_IRQn */
ETIM2_IRQn = 27, /*!< 27 ETIMER2_IRQn */
ETIM3_IRQn = 28, /*!< 28 ETIMER3_IRQn */
ETIM4_IRQn = 29, /*!< 29 ETIMER4_IRQn */
GPIO_IRQn = 30, /*!< 30 GPIO_IRQn */
} IRQn_Type;
/** @addtogroup Configuration_of_CMSIS
* @{
*/
/* ================================================================================ */
/* ================ Processor and Core Peripheral Section ================ */
/* ================================================================================ */
/* ----------------Configuration of the Cortex-M0 Processor and Core Peripherals---------------- */
#define __CM0_REV 0x0100 /*!< Cortex-M0 Core Revision */
#define __MPU_PRESENT 1 /*!< MPU present or not */
#define VAR_29 1 /*!< VTOR present or not */
#define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */
#define VAR_30 0 /*!< Set to 1 if different SysTick Config is used */
/** @} */ /* End of group Configuration_of_CMSIS */
#include "core_cm0plus.h" /*!< Cortex-M0 processor and core peripherals */
#include "system_FM33A0XX.h" /*!< FM33A0XX System */
/* ================================================================================ */
/* ================ Device Specific Peripheral Section ================ */
/* ================================================================================ */
/** @addtogroup Device_Peripheral_Registers
* @{
*/
/* ------------------- Start of section using anonymous unions ------------------ */
#if defined(__CC_ARM)
#pragma push
#pragma anon_unions
#elif defined(__ICCARM__)
#pragma language=extended
#elif defined(__GNUC__)
/* anonymous unions are enabled by default */
#elif defined(__TMS470__)
/* anonymous unions are enabled by default */
#elif defined(__TASKING__)
#pragma warning 586
#else
#warning Not supported compiler type
#endif
/* ================================================================================ */
/* ================ SCU ================ */
/* ================================================================================ */
typedef struct
{
__I uint32_t SYSCON; /*!< SYSTEM STAT */
__IO uint32_t MCUDBGCR; /*!< DEBUG CONFIG */
__IO uint32_t HDFFLAG; /*!< HARDFAULT FLAG */
}ID_5;
/* ================================================================================ */
/* ================ PMU ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_31; /*!< LOW POWER CONFIG */
__IO uint32_t WKDLYCON; /*!< WAKEUP DELAY CONFIG */
__IO uint32_t VAR_32; /*!< WKPFLAG FLAG */
__IO uint32_t LPREIE; /*!< LPREIE INTERRUPT ENABLE*/
__IO uint32_t VAR_33; /*!< LPREIF INTERRUPT FLAG*/
}PMU_Type;
/* ================================================================================ */
/* ================ uart ================ */
/* ================================================================================ */
/* memory mapping struct for uart IE */
typedef struct
{
__IO uint32_t VAR_34; /*!< UART interrupt enable */
__IO uint32_t VAR_35; /*!< UART interrupt flag */
__IO uint32_t VAR_36; /*!< UART infrared control */
} UART_common_Type;
/* memory mapping struct for uart module */
typedef struct
{
__IO uint32_t RXSTA; /*!< UART receive stat Register*/
__IO uint32_t TXSTA; /*!< UART send stat Register */
__IO uint32_t VAR_37; /*!< UART receive data Register *8 */
__IO uint32_t TXREG; /*!< UART send data Register *8 */
__IO uint32_t VAR_38; /*!< UART communication baud rate Register */
__IO uint32_t VAR_39; /*!< UART send stat flag Register */
__IO uint32_t RXBUFSTA; /*!< UART receive stat flag Register */
__IO uint32_t RTXCON; /*!< UART signal reverse conctol Register */
} UARTx_Type;
/* ================================================================================ */
/* ================ RCC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RSTCFG; /*!< RESET CONFIG REGISTER*/
__IO uint32_t SOFTRST; /*!< SOFTWARE RESET REGISTER*/
__IO uint32_t VAR_40; /*!< RESET FLAG REGISTER */
__IO uint32_t SYSCLKSEL; /*!< SYSCLK SELECT */
__IO uint32_t RCHFCON; /*!< RCHF CONFIG */
__IO uint32_t RCHFTRIM; /*!< RCHF TRIM */
__IO uint32_t PLLCON; /*!< PLL CONFIG */
__IO uint32_t RCLPCON; /*!< RCLP CONFIG */
__IO uint32_t RCLPTRIM; /*!< RCLP TRIM */
__IO uint32_t VAR_41; /*!< XTLF WORD STAT SELECT */
__IO uint32_t VAR_42; /*!< PERRIPH RCC SELECT 1 */
__IO uint32_t PERCLKCON2; /*!< PERRIPH RCC SELECT 2 */
__IO uint32_t PERCLKCON3; /*!< PERRIPH RCC SELECT 3 */
__IO uint32_t VAR_43; /*!< PERRIPH RCC SELECT 4 */
__IO uint32_t VAR_44; /*!< 238 */
__IO uint32_t VAR_45; /*!< 23C */
__IO uint32_t VAR_46; /*!< 240 */
__IO uint32_t MPRIL; /*!< PERRIPH RCC SELECT 5 */
}ID_6;
/* ================================================================================ */
/* ================ DMA ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t GLOBALCTRL; /*!< GLOBAL EMANLE REGISTER */
__IO uint32_t CH0CTRL; /*!< CHANNEL0 CTRL REGISTER */
__IO uint32_t VAR_47; /*!< CHANNEL0 RAM START ADDR */
__IO uint32_t CH1CTRL; /*!< CHANNEL1 CTRL REGISTER */
__IO uint32_t CH1RAMAD; /*!< CHANNEL1 RAM START ADDR */
__IO uint32_t CH2CTRL; /*!< CHANNEL2 CTRL REGISTER */
__IO uint32_t CH2RAMAD; /*!< CHANNEL2 RAM START ADDR */
__IO uint32_t CH3CTRL; /*!< CHANNEL3 CTRL REGISTER */
__IO uint32_t CH3RAMAD; /*!< CHANNEL3 RAM START ADDR */
__IO uint32_t CH4CTRL; /*!< CHANNEL4 CTRL REGISTER */
__IO uint32_t CH4RAMAD; /*!< CHANNEL4 RAM START ADDR */
__IO uint32_t VAR_48; /*!< CHANNEL5 CTRL REGISTER */
__IO uint32_t VAR_49; /*!< CHANNEL5 RAM START ADDR */
__IO uint32_t VAR_50; /*!< CHANNEL6 CTRL REGISTER */
__IO uint32_t CH6RAMAD; /*!< CHANNEL6 RAM START ADDR */
__IO uint32_t CH7CTRL; /*!< CHANNEL7 CTRL REGISTER */
__IO uint32_t CH7FLSAD; /*!< CHANNEL7 FLASH START ADDR */
__IO uint32_t CH7RAMAD; /*!< CHANNEL7 RAM START ADDR */
__IO uint32_t CHSTATUS; /*!< INTERRUPT FLAG REGISTER */
}ID_7;
/* ================================================================================ */
/* ================ HSPI ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t SPICR1; /*!< SPI CONTROL REGISTER 1 */
__IO uint32_t SPICR2; /*!< SPI CONTROL REGISTER 2 */
__IO uint32_t SPICR3; /*!< SPI CONTROL REGISTER 3 */
__IO uint32_t VAR_51; /*!< SPI INTERRUPT ENABLE REGISTER */
__IO uint32_t SPIIF; /*!< SPI STATE REGISTER */
__IO uint32_t SPITXBUF; /*!< SPI TX REGISTER */
__IO uint32_t SPIRXBUF; /*!< SPI RX REGISTER */
}SPIx_Type;
/* ================================================================================ */
/* ================ GPIO ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t INEN; /*!< INPUT ENABLE CONFIG */
__IO uint32_t VAR_52; /*!< PULLUP ENABLE CONFIG */
__IO uint32_t ODEN; /*!< OD ENABLE CONFIG */
__IO uint32_t FCR; /*!< FUNCTION CONFIG */
__IO uint32_t DO; /*!< output data register */
__O uint32_t DSET; /*!< bit set HIGH register */
__O uint32_t VAR_53; /*!< bit reset low register */
__I uint32_t DIN; /*!< input data register */
}ID_8;
typedef struct
{
__IO uint32_t EXTI0_SEL; /*!< EDGE TRIGER SELECT CONFIG 0, Address offset: 0x00 */
__IO uint32_t VAR_54; /*!< EDGE TRIGER SELECT CONFIG 1, Address offset: 0x04 */
__IO uint32_t EXTI2_SEL; /*!< EDGE TRIGER SELECT CONFIG 2, Address offset: 0x08 */
__IO uint32_t EXTI0IF; /*!< triger flag 0, Address offset: 0x0C */
__IO uint32_t VAR_55; /*!< triger flag 1, Address offset: 0x10 */
__IO uint32_t EXTI2IF; /*!< triger flag 2, Address offset: 0x14 */
__IO uint32_t VAR_56; /*!< fout select config, Address offset: 0x18 */
__IO uint32_t HDSEL; /*!< high driver config, Address offset: 0x1C */
__IO uint32_t ANASEL; /*!< analog function select, Address offset: 0x20 */
__IO uint32_t VAR_57; /*!< input digit filter select, Address offset: 0x24 */
__IO uint32_t PINWKEN; /*!< pin wakeup enable, Address offset: 0x28 */
}ID_9;
/* ================================================================================ */
/* ================ IWDG ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t IWDTSERV; /*!< IWDG Key register, Address offset: 0x00 */
__IO uint32_t VAR_58; /*!< IWDG CONFIG register, Address offset: 0x04 */
__I uint32_t IWDTCNT; /*!< IWDG Reload register, Address offset: 0x08 */
} ID_10;
/* ================================================================================ */
/* ================ NVMIF ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t FLSRDCON; /*!< NVMIF read control register, Address offset: 0x00 */
__IO uint32_t PRFTCON; /*!< NVMIF prdfatch control register, Address offset: 0x04 */
__I uint32_t VAR_59; /*!< NVMIF port protect stat register, Address offset: 0x08 */
__IO uint32_t ACLOCK1; /*!< NVMIF flash block0-31 protect register,wr 1 only Address offset: 0x0C */
__IO uint32_t ACLOCK2; /*!< NVMIF flash block32-63 protect register,wr 1 only Address offset: 0x10 */
__IO uint32_t EPCON; /*!< NVMIF erase & program start register Address offset: 0x14 */
__IO uint32_t FLSKEY; /*!< NVMIF flash key register Address offset: 0x18 */
__IO uint32_t FLSIE; /*!< NVMIF flash IE register Address offset: 0x1C */
__IO uint32_t FLSIF; /*!< NVMIF flash IF register Address offset: 0x20 */
__IO uint32_t RAMRPR0; /*!< NVMIF RAM REPAIR0 register Address offset: 0x24 */
__IO uint32_t VAR_60; /*!< NVMIF RAM REPAIR1 register Address offset: 0x28 */
__IO uint32_t VAR_61; /*!< NVMIF RAM REPAIR2 register Address offset: 0x2C */
__IO uint32_t RAMRPR3; /*!< NVMIF RAM REPAIR3 register Address offset: 0x30 */
} NVMIF_Type;
/* ================================================================================ */
/* ================ RAMBIST ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RAMBISTCON; /*!< RAMBIST control register, Address offset: 0x00 */
__IO uint32_t VAR_62; /*!< RAMBIST error flag register, Address offset: 0x04 */
} RAMBIST_Type;
/* ================================================================================ */
/* ================ BTIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_63; /*!< BTIMER CONTROL REGISTER 1, Address offset: 0x00 */
__IO uint32_t BTCR2; /*!< BTIMER CONTROL REGISTER 2, Address offset: 0x04 */
__IO uint32_t BTCFG1; /*!< BTIMER CONFIG REGISTER 1, Address offset: 0x08 */
__IO uint32_t VAR_64; /*!< BTIMER CONFIG REGISTER 2, Address offset: 0x0C */
__IO uint32_t VAR_65; /*!< BTIMER PRESCALE VALUE, Address offset: 0x10 */
__IO uint32_t BTLOADCR; /*!< BTIMER LOAD CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t BTCNTL; /*!< BTIMER COUNTER LOW BYTE, Address offset: 0x18 */
__IO uint32_t VAR_66; /*!< BTIMER COUNTER HIGH BYTE, Address offset: 0x1C */
__IO uint32_t VAR_67; /*!< ETIMER PRESET VALUE, Address offset: 0x20 */
__IO uint32_t VAR_68; /*!< ETIMER LOAD VALUE LOW BYTE, Address offset: 0x24 */
__IO uint32_t BTLOADH; /*!< ETIMER LOAD VALUE HIGH BYTE, Address offset: 0x28 */
__IO uint32_t BTCMPL; /*!< ETIMER CMP LOW, Address offset: 0x2C */
__IO uint32_t VAR_69; /*!< ETIMER CMP HIGH, Address offset: 0x30 */
__IO uint32_t BTOUTCNT; /*!< ETIMER OUTPUT PULSE VALUE, Address offset: 0x34 */
__IO uint32_t BTOCR; /*!< ETIMER OUTPUT CONTROL REGISTER, Address offset: 0x38 */
__IO uint32_t VAR_70; /*!< ETIMER INTERRUPT ENABLE, Address offset: 0x3C */
__IO uint32_t BTIF; /*!< ETIMER INTERRUPT FLAG & STATUS, Address offset: 0x40 */
} ID_11;
/* ================================================================================ */
/* ================ ETIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_71; /*!< ETIMER CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t ETxINSEL; /*!< ETIMER INPUT SELECT REGISTER, Address offset: 0x04 */
__IO uint32_t ETxPESCALE1; /*!< ETIMER PRESCALE REGISTER 1, Address offset: 0x08 */
__IO uint32_t ETxPESCALE2; /*!< ETIMER PRESCALE REGISTER 2, Address offset: 0x0C */
__IO uint32_t ETxIVR; /*!< ETIMER INITIAL VALUE, Address offset: 0x10 */
__IO uint32_t ETxCMP; /*!< ETIMER CMP REGISTER, Address offset: 0x14 */
__IO uint32_t VAR_72; /*!< ETIMER INTERRUPT ENABLE, Address offset: 0x18 */
__IO uint32_t VAR_73; /*!< ETIMER INTERRUPT FLAG & STATUS, Address offset: 0x1C */
} ETIMx_Type;
/* ================================================================================ */
/* ================ LPTIM ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t LPTCFG; /*!< LPTIM CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t LPTCNT; /*!< LPTIM COUNT REGISTER, Address offset: 0x04 */
__IO uint32_t LPTCMP; /*!< LPTIM COMPARE REGISTER, Address offset: 0x08 */
__IO uint32_t LPTTARGET; /*!< LPTIM TARGET REGISTER, Address offset: 0x0C */
__IO uint32_t LPTIE; /*!< LPTIM INTERRUPT ENABLE, Address offset: 0x10 */
__IO uint32_t VAR_74; /*!< LPTIM INTERRUPT FLAG REGISTER, Address offset: 0x14 */
__IO uint32_t LPTCTRL; /*!< LPTIM CONTROL REGISTER, Address offset: 0x18 */
} LPTIM_Type;
/* ================================================================================ */
/* ================ I2C ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t I2CCTRL; /*!< I2C CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t VAR_75; /*!< I2C STATE REGISTER, Address offset: 0x04 */
__IO uint32_t I2CBRG; /*!< I2C BAUD SETTING REGISTER, Address offset: 0x08 */
__IO uint32_t VAR_76; /*!< I2C BUFF REGISTER, Address offset: 0x0C */
__IO uint32_t VAR_77; /*!< I2C INTERRUPT ENABLE & FLAG, Address offset: 0x10 */
__IO uint32_t VAR_78; /*!< I2C FSM STATE REGISTER, Address offset: 0x14 */
__IO uint32_t I2CERR; /*!< I2C ERR FLAG REGISTER, Address offset: 0x18 */
} I2C_Type;
/* ================================================================================ */
/* ================ ANAC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_79; /*!< ANAC PDR CONFIG REGISTER, Address offset: 0x00 */
__IO uint32_t VAR_80; /*!< ANAC BOR CONFIG REGISTER, Address offset: 0x04 */
__IO uint32_t LDO15CON; /*!< ANAC LDO15CON CONFIG REGISTER, Address offset: 0x08 */
__IO uint32_t VAR_81; /*!< ANAC VREF TRIM REGISTER, Address offset: 0x0C */
__IO uint32_t VAR_82; /*!< ANAC ULP LDO CONFIG REGISTER, Address offset: 0x10 */
__IO uint32_t SVDCFG; /*!< ANAC SVD CONFIG REGISTER, Address offset: 0x14 */
__IO uint32_t VAR_83; /*!< ANAC SVD CONTROL REGISTER, Address offset: 0x18 */
__IO uint32_t SVDSIF; /*!< ANAC SVD INTERRUPT FLAG REGISTER, Address offset: 0x1C */
__IO uint32_t VAR_84; /*!< ANAC FDET INTERRUPT ENABLE REGISTER, Address offset: 0x20 */
__IO uint32_t FDETIF; /*!< ANAC FDET INTERRUPT FLAG REGISTER, Address offset: 0x24 */
__IO uint32_t ADCINSEL; /*!< ANAC INPUT SELECT REGISTER, Address offset: 0x28 */
__IO uint32_t VAR_85; /*!< ANAC ADC CONFIG REGISTER, Address offset: 0x2C */
__IO uint32_t ADCTRIM; /*!< ANAC ADC TRIM REGISTER, Address offset: 0x30 */
__IO uint32_t VAR_86; /*!< ANAC ADC DATA REGISTER, Address offset: 0x34 */
__IO uint32_t ADCIF; /*!< ANAC ADC INTERRUPT FLAG REGISTER, Address offset: 0x38 */
__IO uint32_t VAR_87; /*!< ANAC TRNF ENABLE REGISTER, Address offset: 0x3C */
__IO uint32_t COMP1CR; /*!< ANAC COMP1 CONTROL REGISTER, Address offset: 0x40 */
__IO uint32_t COMP2CR; /*!< ANAC COMP2 CONTROL REGISTER, Address offset: 0x44 */
__IO uint32_t COMPICR; /*!< ANAC COMP12 INTERRUPT CONTROL REGISTER, Address offset: 0x48 */
__IO uint32_t COMPIF; /*!< ANAC COMP INTERRUPT FLAG REGISTER, Address offset: 0x4C */
__IO uint32_t VAR_44;
__IO uint32_t VAR_45;
__IO uint32_t VAR_46;
__IO uint32_t SVDALM; /*!< ANAC SVDALM REGISTER, Address offset: 0x5C */
} ID_12;
/* ================================================================================ */
/* ================ CRC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_88; /*!< CRC DATA REGISTER, Address offset: 0x00 */
__IO uint32_t CRCCR; /*!< CRC CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t CRCLFSR; /*!< CRC LFSR REGISTER, Address offset: 0x08 */
__IO uint32_t VAR_89; /*!< CRC XOR DATA REGISTER, Address offset: 0x0C */
__IO uint32_t CRCFLSEN; /*!< CRC FLASH CRC VERIFY EN REGISTER, Address offset: 0x10 */
__IO uint32_t CRCFLSAD; /*!< CRC FLASH ADRESS REGISTER, Address offset: 0x14 */
__IO uint32_t CRCFLSSIZE; /*!< CRC VERIFY SIZE REGISTER, Address offset: 0x18 */
} ID_13;
/* ================================================================================ */
/* ================ DISP ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t DISPCTRL; /*!< DISP CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t LCDTEST; /*!< DISP TEST CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t DF; /*!< DISP DIVIDE CLK SETTING REGISTER, Address offset: 0x08 */
__IO uint32_t TON; /*!< DISP ON SETTING REGISTER, Address offset: 0x0C */
__IO uint32_t TOFF; /*!< DISP OFF SETTING REGISTER, Address offset: 0x10 */
__IO uint32_t DISPIE; /*!< DISP INTERRUPT CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t DISPIF; /*!< DISP INTERRUPT FLAG REGISTER, Address offset: 0x18 */
__IO uint32_t VAR_90; /*!< DISP SETTING REGISTER, Address offset: 0x1C */
__IO uint32_t LCDDRV; /*!< DISP DRV SETTING REGISTER, Address offset: 0x20 */
__IO uint32_t DISPDATA0; /*!< DISP DATA REGISTER 0, Address offset: 0x24 */
__IO uint32_t DISPDATA1; /*!< DISP DATA REGISTER 1, Address offset: 0x28 */
__IO uint32_t VAR_91; /*!< DISP DATA REGISTER 2, Address offset: 0x2C */
__IO uint32_t VAR_92; /*!< DISP DATA REGISTER 3, Address offset: 0x30 */
__IO uint32_t DISPDATA4; /*!< DISP DATA REGISTER 4, Address offset: 0x34 */
__IO uint32_t DISPDATA5; /*!< DISP DATA REGISTER 5, Address offset: 0x38 */
__IO uint32_t DISPDATA6; /*!< DISP DATA REGISTER 6, Address offset: 0x3C */
__IO uint32_t VAR_93; /*!< DISP DATA REGISTER 7, Address offset: 0x40 */
__IO uint32_t DISPDATA8; /*!< DISP DATA REGISTER 8, Address offset: 0x44 */
__IO uint32_t DISPDATA9; /*!< DISP DATA REGISTER 9, Address offset: 0x48 */
__IO uint32_t LCDBIAS; /*!< DISP BIAS SETTING REGISTER, Address offset: 0x4C */
__IO uint32_t COM_EN; /*!< DISP COM SETTING REGISTER, Address offset: 0x50 */
__IO uint32_t SEG_EN0; /*!< DISP SEG SETTING REGISTER, Address offset: 0x54 */
__IO uint32_t VAR_94; /*!< DISP SEG SETTING REGISTER, Address offset: 0x58 */
__IO uint32_t LCDBSTCON; /*!< DISP BOOST CONFIG REGISTER, Address offset: 0x5C */
} DISP_Type;
/* ================================================================================ */
/* ================ RTC ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t RTCWE; /*!< RTC WRITE PROTECT REGISTER, Address offset: 0x00 */
__IO uint32_t RTCIE; /*!< RTC INTERRUPT CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t RTCIF; /*!< RTC INTERRUPT FLAG REGISTER, Address offset: 0x08 */
__IO uint32_t BCDSEC; /*!< RTC SECOND IN BCD REGISTER, Address offset: 0x0C */
__IO uint32_t BCDMIN; /*!< RTC MINITE IN BCD REGISTER, Address offset: 0x10 */
__IO uint32_t VAR_95; /*!< RTC HOUR IN BCD REGISTER, Address offset: 0x14 */
__IO uint32_t BCDDATE; /*!< RTC DATE IN BCD REGISTER, Address offset: 0x18 */
__IO uint32_t BCDWEEK; /*!< RTC WEEK IN BCD REGISTER, Address offset: 0x1C */
__IO uint32_t BCDMONTH; /*!< RTC MONTH IN BCD REGISTER, Address offset: 0x20 */
__IO uint32_t VAR_96; /*!< RTC YEAR IN BCD REGISTER, Address offset: 0x24 */
__IO uint32_t ALARM; /*!< RTC ALARM SETTING REGISTER, Address offset: 0x28 */
__IO uint32_t FSEL; /*!< RTC OUTPUT SELECT REGISTER, Address offset: 0x2C */
__IO uint32_t ADJUST; /*!< RTC LTBC ADJUST REGISTER, Address offset: 0x30 */
__IO uint32_t ADSIGN; /*!< RTC LTBC ADJUST SIGN REGISTER, Address offset: 0x34 */
__IO uint32_t PR1SEN; /*!< RTC LTBC 1SEC ENABLE REGISTER, Address offset: 0x38 */
__IO uint32_t VAR_97; /*!< RTC MS COUNTER REGISTER, Address offset: 0x3C */
__IO uint32_t VAR_98; /*!< RTC TIME STAMP REGISTER, Address offset: 0x40 */
__IO uint32_t CLKSTAMP0R; /*!< RTC STAMP AT PB4 RISE REGISTER 0, Address offset: 0x44 */
__IO uint32_t CALSTAMP0R; /*!< RTC STAMP AT PB4 RISE REGISTER 0, Address offset: 0x48 */
__IO uint32_t CLKSTAMP0F; /*!< RTC STAMP AT PB4 FALL REGISTER 0, Address offset: 0x4C */
__IO uint32_t CALSTAMP0F; /*!< RTC STAMP AT PB4 FALL REGISTER 0, Address offset: 0x50 */
__IO uint32_t CLKSTAMP1R; /*!< RTC STAMP AT PB4 RISE REGISTER 1, Address offset: 0x54 */
__IO uint32_t VAR_99; /*!< RTC STAMP AT PB4 RISE REGISTER 1, Address offset: 0x58 */
__IO uint32_t CLKSTAMP1F; /*!< RTC STAMP AT PB4 FALL REGISTER 1, Address offset: 0x5C */
__IO uint32_t CALSTAMP1F; /*!< RTC STAMP AT PB4 FALL REGISTER 1, Address offset: 0x60 */
} ID_14;
/* ================================================================================ */
/* ================ AES ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t AESCR; /*!< AES CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t AESIF; /*!< AES INTERRUPT FLAG REGISTER, Address offset: 0x04 */
__IO uint32_t AESDIN; /*!< AES DATA INPUT REGISTER, Address offset: 0x08 */
__IO uint32_t AESDOUT; /*!< AES DATA OUTPUT REGISTER, Address offset: 0x0C */
__IO uint32_t AESKEY0; /*!< AES KEY LOW WORD REGISTER 0, Address offset: 0x10 */
__IO uint32_t AESKEY1; /*!< AES KEY REGISTER 1, Address offset: 0x14 */
__IO uint32_t AESKEY2; /*!< AES KEY REGISTER 2, Address offset: 0x18 */
__IO uint32_t VAR_100; /*!< AES KEY REGISTER 3, Address offset: 0x1C */
__IO uint32_t AESKEY4; /*!< AES KEY REGISTER 4, Address offset: 0x20 */
__IO uint32_t VAR_101; /*!< AES KEY REGISTER 5, Address offset: 0x24 */
__IO uint32_t AESKEY6; /*!< AES KEY REGISTER 6, Address offset: 0x28 */
__IO uint32_t VAR_102; /*!< AES KEY REGISTER 7, Address offset: 0x2C */
__IO uint32_t AESIVR0; /*!< AES INITIAL DATA REGISTER 0, Address offset: 0x30 */
__IO uint32_t AESIVR1; /*!< AES INITIAL DATA REGISTER 1, Address offset: 0x34 */
__IO uint32_t VAR_103; /*!< AES INITIAL DATA REGISTER 2, Address offset: 0x38 */
__IO uint32_t VAR_104; /*!< AES INITIAL DATA REGISTER 3, Address offset: 0x3C */
} ID_15;
/* ================================================================================ */
/* ================ U7816 ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t U7816CTRL; /*!< U7816 CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t U7816FRC; /*!< U7816 FRAME CONTROL REGISTER, Address offset: 0x04 */
__IO uint32_t U7816EGT; /*!< U7816 EGT CONFIG REGISTER, Address offset: 0x08 */
__IO uint32_t U7816CLKDIV; /*!< U7816 CLK DIVIDED REGISTER, Address offset: 0x0C */
__IO uint32_t U7816PDIV; /*!< U7816 PREDIVIDED REGISTER, Address offset: 0x10 */
__IO uint32_t U7816RXBUF; /*!< U7816 RX BUFFER REGISTER, Address offset: 0x14 */
__IO uint32_t VAR_105; /*!< U7816 TX BUFFER REGISTER, Address offset: 0x18 */
__IO uint32_t U7816IE; /*!< U7816 INTERRUPT ENABLE REGISTER, Address offset: 0x1C */
__IO uint32_t U7816IF; /*!< U7816 INTERRUPT FLAG REGISTER, Address offset: 0x20 */
__IO uint32_t U7816ERR; /*!< U7816 ERR FLAG REGISTER, Address offset: 0x24 */
__IO uint32_t U7816STA; /*!< U7816 STATE REGISTER, Address offset: 0x28 */
} U7816x_Type;
/* ================================================================================ */
/* ================ WWDT ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t WWDTCON; /*!< WWDT CONTROL REGISTER, Address offset: 0x00 */
__IO uint32_t WWDTCFG; /*!< WWDT CONFIG REGISTER, Address offset: 0x04 */
__IO uint32_t WWDTCNT; /*!< WWDT COUNTER REGISTER, Address offset: 0x08 */
__IO uint32_t WWDTIE; /*!< WWDT INTERRUPT ENABLE REGISTER, Address offset: 0x0C */
__IO uint32_t WWDTIF; /*!< WWDT INTERRUPT FLAG REGISTER, Address offset: 0x10 */
__IO uint32_t WWDTDIV; /*!< WWDT WWDTDIV REGISTER, Address offset: 0x14 */
} WWDT_Type;
/* ================================================================================ */
/* ================ TRNG ================ */
/* ================================================================================ */
typedef struct
{
__IO uint32_t VAR_44; /*!< RESERVED Address offset: 0x00 */
__IO uint32_t RNGOUT; /*!< TRNG OUTPUT REGISTER, Address offset: 0x04 */
__IO uint32_t VAR_45; /*!< RESERVED Address offset: 0x08 */
__IO uint32_t RNGIE; /*!< TRNG INTERRUPT ENABLE REGISTER, Address offset: 0x0C */
__IO uint32_t RNGIF; /*!< TRNG INTERRUPT FLAG REGISTER, Address offset: 0x10 */
__IO uint32_t CRCCON; /*!< TRNG CRC CONTROL REGISTER, Address offset: 0x14 */
__IO uint32_t CRCIN; /*!< TRNG CRC INPUT REGISTER, Address offset: 0x18 */
__IO uint32_t CRCFLAG; /*!< TRNG CRC CRCFLAG REGISTER, Address offset: 0x1C */
} TRNG_Type;
/* -------------------- End of section using anonymous unions ------------------- */
#if defined(__CC_ARM)
#pragma pop
#elif defined(__ICCARM__)
/* leave anonymous unions enabled */
#elif defined(__GNUC__)
/* anonymous unions are enabled by default */
#elif defined(__TMS470__)
/* anonymous unions are enabled by default */
#elif defined(__TASKING__)
#pragma warning restore
#else
#warning Not supported compiler type
#endif
/* ================================================================================ */
/* ================ CPU memory map ================ */
/* ================================================================================ */
/* Peripheral and SRAM base address */
#define FLASH_BASE (( uint32_t)0x00000000)
#define SRAM_BASE (( uint32_t)0x20000000)
#define PERIPH_BASE (( uint32_t)0x40000000)
/* ================================================================================ */
/* ================ Peripheral memory map ================ */
/* ================================================================================ */
/* Peripheral memory map */
#define VAR_106 (PERIPH_BASE +0x00000000)
#define PMU_BASE (PERIPH_BASE +0x00000100)
#define RCC_BASE (PERIPH_BASE +0x00000200)
#define DMA_BASE (PERIPH_BASE +0x00000400)
#define HSPI_BASE (PERIPH_BASE +0x00000800)
#define VAR_107 (PERIPH_BASE +0x00000840)
#define VAR_108 (PERIPH_BASE +0x00000880)
#define GPIOA_BASE (PERIPH_BASE +0x00000C00)
#define VAR_109 (PERIPH_BASE +0x00000C20)
#define GPIOC_BASE (PERIPH_BASE +0x00000C40)
#define VAR_110 (PERIPH_BASE +0x00000C60)
#define GPIOE_BASE (PERIPH_BASE +0x00000C80)
#define GPIOF_BASE (PERIPH_BASE +0x00000CA0)
#define VAR_111 (PERIPH_BASE +0x00000CC0)
#define GPIO_COMMON_BASE (PERIPH_BASE +0x00000CE0)
#define NVMIF_BASE (PERIPH_BASE +0x00001000)
#define VAR_112 (PERIPH_BASE +0x00010000)
#define DISP_BASE (PERIPH_BASE +0x00010C00)
#define RTC_BASE (PERIPH_BASE +0x00011000)
#define IWDT_BASE (PERIPH_BASE +0x00011400)
#define WWDT_BASE (PERIPH_BASE +0x00011800)
#define VAR_113 (PERIPH_BASE +0x00011C00)
#define VAR_114 (PERIPH_BASE +0x00011C2C)
#define UART_COMMON_BASE (PERIPH_BASE +0x00012000)
#define UART0_BASE (PERIPH_BASE +0x0001200C)
#define UART1_BASE (PERIPH_BASE +0x0001202C)
#define UART2_BASE (PERIPH_BASE +0x0001204C)
#define VAR_115 (PERIPH_BASE +0x0001206C)
#define UART4_BASE (PERIPH_BASE +0x0001208C)
#define VAR_116 (PERIPH_BASE +0x000120AC)
#define VAR_117 (PERIPH_BASE +0x00012400)
#define ANAC_BASE (PERIPH_BASE +0x00012800)
#define RAMBIST_BASE (PERIPH_BASE +0x00012C00)
#define BTIMER1_BASE (PERIPH_BASE +0x00013000)
#define VAR_118 (PERIPH_BASE +0x00013044)
#define ETIMER1_BASE (PERIPH_BASE +0x00013090)
#define ETIMER2_BASE (PERIPH_BASE +0x000130B0)
#define ETIMER3_BASE (PERIPH_BASE +0x000130D0)
#define ETIMER4_BASE (PERIPH_BASE +0x000130F0)
#define LPTIM_BASE (PERIPH_BASE +0x00013400)
#define VAR_119 (PERIPH_BASE +0x00013800)
#define TRNG_BASE (PERIPH_BASE +0x00013C00)
/* ================================================================================ */
/* ================ Peripheral declaration ================ */
/* ================================================================================ */
#define SCU ((SCU_Type *) SCU_BASE )
#define PMU ((PMU_Type *) PMU_BASE )
#define RCC ((RCC_Type *) RCC_BASE )
#define DMA ((DMA_Type *) DMA_BASE )
#define VAR_120 ((SPIx_Type *) HSPI_BASE )
#define VAR_121 ((SPIx_Type *) SPI1_BASE )
#define SPI2 ((SPIx_Type *) SPI2_BASE )
#define NVMIF ((NVMIF_Type *) NVMIF_BASE )
#define VAR_122 ((NVMIF_Type *) NVMIF_BASE )
#define UART ((UART_common_Type *) UART_COMMON_BASE )
#define UART0 ((UARTx_Type *) UART0_BASE )
#define UART1 ((UARTx_Type *) UART1_BASE )
#define UART2 ((UARTx_Type *) UART2_BASE )
#define UART3 ((UARTx_Type *) UART3_BASE )
#define UART4 ((UARTx_Type *) UART4_BASE )
#define VAR_123 ((UARTx_Type *) UART5_BASE )
#define IWDT ((IWDT_Type *) IWDT_BASE )
#define GPIOA ((GPIOx_Type *) GPIOA_BASE )
#define GPIOB ((GPIOx_Type *) GPIOB_BASE )
#define VAR_124 ((GPIOx_Type *) GPIOC_BASE )
#define VAR_125 ((GPIOx_Type *) GPIOD_BASE )
#define GPIOE ((GPIOx_Type *) GPIOE_BASE )
#define GPIOF ((GPIOx_Type *) GPIOF_BASE )
#define VAR_126 ((GPIOx_Type *) GPIOG_BASE )
#define GPIO ((GPIO_COMMON_Type *) GPIO_COMMON_BASE )
#define VAR_127 ((RAMBIST_Type *) RAMBIST_BASE )
#define BTIM1 ((BTIMx_Type *) BTIMER1_BASE )
#define BTIM2 ((BTIMx_Type *) BTIMER2_BASE )
#define VAR_128 ((ETIMx_Type *) ETIMER1_BASE )
#define ETIM2 ((ETIMx_Type *) ETIMER2_BASE )
#define ETIM3 ((ETIMx_Type *) ETIMER3_BASE )
#define VAR_129 ((ETIMx_Type *) ETIMER4_BASE )
#define VAR_130 ((LPTIM_Type *) LPTIM_BASE )
#define VAR_131 ((ANAC_Type *) ANAC_BASE )
#define VAR_132 ((WWDT_Type *) WWDT_BASE )
#define VAR_133 ((I2C_Type *) I2C_BASE )
#define VAR_134 ((CRC_Type *) CRC_BASE )
#define LCD ((DISP_Type *) DISP_BASE )
#define VAR_135 ((RTC_Type *) RTC_BASE )
#define U78160 ((U7816x_Type *) U78160_BASE )
#define U78161 ((U7816x_Type *) U78161_BASE )
#define AES ((AES_Type *) AES_BASE )
#define TRNG ((TRNG_Type *) TRNG_BASE )
/* ================================================================================ */
/* ================ Peripheral include ================ */
/* ================================================================================ */
/** @} */ /* End of group Device_Peripheral_Registers */
/** @} */ /* End of group FM32L0XX */
/** @} */ /* End of group Keil */
#ifdef __cplusplus
}
#endif
#endif /* FM33A0XX_H */
| 0.312793 | {'VAR_0': 'RESET', 'VAR_1': 'SET', 'ID_0': 'FlagStatus', 'ID_1': 'ITStatus', 'ID_2': 'FlagState', 'VAR_2': 'DISABLE', 'VAR_3': 'ENABLE', 'ID_3': 'FunctionalState', 'VAR_4': 'FAIL', 'ID_4': 'ResState', 'VAR_5': 'SCU_num', 'VAR_6': 'CRC_num', 'VAR_7': 'TRNG_num', 'VAR_8': 'UART4_num', 'VAR_9': 'UART5_num', 'VAR_10': 'I2C_num', 'VAR_11': 'BT1_num', 'VAR_12': 'BT2_num', 'VAR_13': 'LPTFC_num', 'VAR_14': 'ANA_num', 'VAR_15': 'EXTI1_num', 'VAR_16': 'EXTI2_num', 'VAR_17': 'DCU_num', 'VAR_18': '__RCHF_INITIAL_CLOCK', 'VAR_19': 'HardFault_IRQn', 'VAR_20': 'SVCall_IRQn', 'VAR_21': 'WWDT_IRQn', 'VAR_22': 'ADC_IRQn', 'VAR_23': 'SPI1_IRQn', 'VAR_24': 'UART3_IRQn', 'VAR_25': 'UART4_IRQn', 'VAR_26': 'LCD_IRQn', 'VAR_27': 'TRNG_IRQn', 'VAR_28': 'COMP_IRQn', 'VAR_29': '__VTOR_PRESENT', 'VAR_30': '__Vendor_SysTickConfig', 'ID_5': 'SCU_Type', 'VAR_31': 'LPMCFG', 'VAR_32': 'WKPFLAG', 'VAR_33': 'LPREIF', 'VAR_34': 'UARTIE', 'VAR_35': 'UARTIF', 'VAR_36': 'IRCON', 'VAR_37': 'RXREG', 'VAR_38': 'SPBRG', 'VAR_39': 'TXBUFSTA', 'VAR_40': 'RSTFLAG', 'VAR_41': 'XTLFIPW', 'VAR_42': 'PERCLKCON1', 'VAR_43': 'PERCLKCON4', 'VAR_44': 'RSV0', 'VAR_45': 'RSV1', 'VAR_46': 'RSV2', 'ID_6': 'RCC_Type', 'VAR_47': 'CH0RAMAD', 'VAR_48': 'CH5CTRL', 'VAR_49': 'CH5RAMAD', 'VAR_50': 'CH6CTRL', 'ID_7': 'DMA_Type', 'VAR_51': 'SPIIE', 'VAR_52': 'PUEN', 'VAR_53': 'DRESET', 'ID_8': 'GPIOx_Type', 'VAR_54': 'EXTI1_SEL', 'VAR_55': 'EXTI1IF', 'VAR_56': 'FOUTSEL', 'VAR_57': 'IODF', 'ID_9': 'GPIO_COMMON_Type', 'VAR_58': 'IWDTCFG', 'ID_10': 'IWDT_Type', 'VAR_59': 'OPTBR', 'VAR_60': 'RAMRPR1', 'VAR_61': 'RAMRPR2', 'VAR_62': 'RAMFF', 'VAR_63': 'BTCR1', 'VAR_64': 'BTCFG2', 'VAR_65': 'BTPRES', 'VAR_66': 'BTCNTH', 'VAR_67': 'BTPRESET', 'VAR_68': 'BTLOADL', 'VAR_69': 'BTCMPH', 'VAR_70': 'BTIE', 'ID_11': 'BTIMx_Type', 'VAR_71': 'ETxCR', 'VAR_72': 'ETxIE', 'VAR_73': 'ETxIF', 'VAR_74': 'LPTIF', 'VAR_75': 'I2CSTA', 'VAR_76': 'I2CBUF', 'VAR_77': 'I2CIR', 'VAR_78': 'I2CFSM', 'VAR_79': 'PDRCON', 'VAR_80': 'BORCON', 'VAR_81': 'VREFTRIM', 'VAR_82': 'ULPRCON', 'VAR_83': 'SVDCON', 'VAR_84': 'FDETIE', 'VAR_85': 'ADCCON', 'VAR_86': 'ADCDATA', 'VAR_87': 'TRNGCON', 'ID_12': 'ANAC_Type', 'VAR_88': 'CRCDR', 'VAR_89': 'CRCXOR', 'ID_13': 'CRC_Type', 'VAR_90': 'LCDSET', 'VAR_91': 'DISPDATA2', 'VAR_92': 'DISPDATA3', 'VAR_93': 'DISPDATA7', 'VAR_94': 'SEG_EN1', 'VAR_95': 'BCDHOUR', 'VAR_96': 'BCDYEAR', 'VAR_97': 'MSECCNT', 'VAR_98': 'STAMPEN', 'VAR_99': 'CALSTAMP1R', 'ID_14': 'RTC_Type', 'VAR_100': 'AESKEY3', 'VAR_101': 'AESKEY5', 'VAR_102': 'AESKEY7', 'VAR_103': 'AESIVR2', 'VAR_104': 'AESIVR3', 'ID_15': 'AES_Type', 'VAR_105': 'U7816TXBUF', 'VAR_106': 'SCU_BASE', 'VAR_107': 'SPI1_BASE', 'VAR_108': 'SPI2_BASE', 'VAR_109': 'GPIOB_BASE', 'VAR_110': 'GPIOD_BASE', 'VAR_111': 'GPIOG_BASE', 'VAR_112': 'CRC_BASE', 'VAR_113': 'U78160_BASE', 'VAR_114': 'U78161_BASE', 'VAR_115': 'UART3_BASE', 'VAR_116': 'UART5_BASE', 'VAR_117': 'I2C_BASE', 'VAR_118': 'BTIMER2_BASE', 'VAR_119': 'AES_BASE', 'VAR_120': 'HSPI', 'VAR_121': 'SPI1', 'VAR_122': 'FLASH', 'VAR_123': 'UART5', 'VAR_124': 'GPIOC', 'VAR_125': 'GPIOD', 'VAR_126': 'GPIOG', 'VAR_127': 'RAMBIST', 'VAR_128': 'ETIM1', 'VAR_129': 'ETIM4', 'VAR_130': 'LPTIM', 'VAR_131': 'ANAC', 'VAR_132': 'WWDT', 'VAR_133': 'I2C', 'VAR_134': 'CRC', 'VAR_135': 'RTC'} | c | Procedural | 3.43% |
/*
************************************************************************************************************************
* Release a mutex
*
* Description: This function is called to release a mutex.
*
* Arguments :mutex_ptr is the address of the mutex object want to be released
*
*
*
* Returns RAW_SUCCESS: raw os return success
* Note(s) Any task pended on this semphore will be waked up and will return RAW_B_DEL.
*
*
************************************************************************************************************************
*/
RAW_U16 raw_mutex_put(RAW_MUTEX *mutex_ptr)
{
LIST *block_list_head;
RAW_TASK_OBJ *tcb;
RAW_SR_ALLOC();
#if (RAW_MUTEX_FUNCTION_CHECK > 0)
if (mutex_ptr == 0) {
return RAW_NULL_OBJECT;
}
if (raw_int_nesting) {
return RAW_NOT_CALLED_BY_ISR;
}
#endif
RAW_CRITICAL_ENTER();
if (mutex_ptr->common_block_obj.object_type != RAW_MUTEX_OBJ_TYPE) {
RAW_CRITICAL_EXIT();
return RAW_ERROR_OBJECT_TYPE;
}
if (raw_task_active != mutex_ptr->mtxtsk) {
RAW_CRITICAL_EXIT();
return RAW_MUTEX_NOT_RELEASE_BY_OCCYPY;
}
mutex_ptr->owner_nested--;
if (mutex_ptr->owner_nested) {
RAW_CRITICAL_EXIT();
return RAW_MUTEX_OWNER_NESTED;
}
release_mutex(raw_task_active, mutex_ptr);
block_list_head = &mutex_ptr->common_block_obj.block_list;
if (is_list_empty(block_list_head)) {
mutex_ptr->mtxtsk = 0;
RAW_CRITICAL_EXIT();
TRACE_MUTEX_RELEASE_SUCCESS(raw_task_active, mutex_ptr);
return RAW_SUCCESS;
}
tcb = raw_list_entry(block_list_head->next, RAW_TASK_OBJ, task_list);
raw_wake_object(tcb);
mutex_ptr->mtxtsk = tcb;
mutex_ptr->mtxlist = tcb->mtxlist;
tcb->mtxlist = mutex_ptr;
mutex_ptr->owner_nested = 1u;
if (mutex_ptr->policy == RAW_MUTEX_CEILING_POLICY) {
if (tcb->priority > mutex_ptr->ceiling_prio) {
change_internal_task_priority(tcb, mutex_ptr->ceiling_prio);
}
}
TRACE_MUTEX_WAKE_TASK(raw_task_active, tcb);
RAW_CRITICAL_EXIT();
raw_sched();
return RAW_SUCCESS;
} | /*
************************************************************************************************************************
* Release a mutex
*
* Description: This function is called to release a mutex.
*
* Arguments :mutex_ptr is the address of the mutex object want to be released
*
*
*
* Returns RAW_SUCCESS: raw os return success
* Note(s) Any task pended on this semphore will be waked up and will return RAW_B_DEL.
*
*
************************************************************************************************************************
*/
RAW_U16 raw_mutex_put(RAW_MUTEX *mutex_ptr)
{
LIST *block_list_head;
RAW_TASK_OBJ *tcb;
RAW_SR_ALLOC();
#if (RAW_MUTEX_FUNCTION_CHECK > 0)
if (mutex_ptr == 0) {
return VAR_0;
}
if (raw_int_nesting) {
return RAW_NOT_CALLED_BY_ISR;
}
#endif
RAW_CRITICAL_ENTER();
if (mutex_ptr->common_block_obj.object_type != RAW_MUTEX_OBJ_TYPE) {
RAW_CRITICAL_EXIT();
return RAW_ERROR_OBJECT_TYPE;
}
if (raw_task_active != mutex_ptr->mtxtsk) {
RAW_CRITICAL_EXIT();
return RAW_MUTEX_NOT_RELEASE_BY_OCCYPY;
}
mutex_ptr->owner_nested--;
if (mutex_ptr->owner_nested) {
RAW_CRITICAL_EXIT();
return RAW_MUTEX_OWNER_NESTED;
}
release_mutex(raw_task_active, mutex_ptr);
block_list_head = &mutex_ptr->common_block_obj.block_list;
if (is_list_empty(block_list_head)) {
mutex_ptr->mtxtsk = 0;
RAW_CRITICAL_EXIT();
TRACE_MUTEX_RELEASE_SUCCESS(raw_task_active, mutex_ptr);
return RAW_SUCCESS;
}
tcb = raw_list_entry(block_list_head->next, RAW_TASK_OBJ, task_list);
raw_wake_object(tcb);
mutex_ptr->mtxtsk = tcb;
mutex_ptr->mtxlist = tcb->mtxlist;
tcb->mtxlist = mutex_ptr;
mutex_ptr->owner_nested = 1u;
if (mutex_ptr->policy == RAW_MUTEX_CEILING_POLICY) {
if (tcb->priority > mutex_ptr->ceiling_prio) {
change_internal_task_priority(tcb, mutex_ptr->ceiling_prio);
}
}
TRACE_MUTEX_WAKE_TASK(raw_task_active, tcb);
RAW_CRITICAL_EXIT();
FUNC_0();
return RAW_SUCCESS;
} | 0.031786 | {'VAR_0': 'RAW_NULL_OBJECT', 'FUNC_0': 'raw_sched'} | c | Procedural | 100.00% |
/********************************************************************************************
*
* PNGU
*
* Original author: frontier (http://frontier-dev.net)
* Modified by Tantric, 2009-2010
*
********************************************************************************************/
#include "pngu.h"
#include <gccore.h>
#include <malloc.h>
#include <png.h>
#include <stdio.h>
#include <string.h>
// Constants
#define PNGU_SOURCE_BUFFER 1
#define PNGU_SOURCE_DEVICE 2
// Return codes
#define PNGU_OK 0
#define PNGU_ODD_WIDTH 1
#define PNGU_ODD_STRIDE 2
#define PNGU_INVALID_WIDTH_OR_HEIGHT 3
#define PNGU_FILE_IS_NOT_PNG 4
#define PNGU_UNSUPPORTED_COLOR_TYPE 5
#define PNGU_NO_FILE_SELECTED 6
#define PNGU_CANT_OPEN_FILE 7
#define PNGU_CANT_READ_FILE 8
#define PNGU_LIB_ERROR 9
// Color types
#define PNGU_COLOR_TYPE_GRAY 1
#define PNGU_COLOR_TYPE_GRAY_ALPHA 2
#define PNGU_COLOR_TYPE_PALETTE 3
#define PNGU_COLOR_TYPE_RGB 4
#define PNGU_COLOR_TYPE_RGB_ALPHA 5
#define PNGU_COLOR_TYPE_UNKNOWN 6
// PNGU Image context struct
struct _IMGCTX {
int source;
void *buffer;
char *filename;
PNGU_u32 cursor;
PNGU_u32 propRead;
PNGUPROP prop;
PNGU_u32 infoRead;
png_structp png_ptr;
png_infop info_ptr;
FILE *fd;
png_bytep *row_pointers;
png_bytep img_data;
};
// PNGU Implementation
static void pngu_free_info(IMGCTX ctx) {
if (ctx->infoRead) {
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
png_destroy_read_struct(&(ctx->png_ptr), &(ctx->info_ptr),
(png_infopp)NULL);
ctx->infoRead = 0;
}
}
// Custom data provider function used for reading from memory buffers.
static void pngu_read_data_from_buffer(png_structp png_ptr, png_bytep data,
png_size_t length) {
IMGCTX ctx = (IMGCTX)png_get_io_ptr(png_ptr);
memcpy(data, ctx->buffer + ctx->cursor, length);
ctx->cursor += length;
}
// Custom data writer function used for writing to memory buffers.
static void pngu_write_data_to_buffer(png_structp png_ptr, png_bytep data,
png_size_t length) {
IMGCTX ctx = (IMGCTX)png_get_io_ptr(png_ptr);
memcpy(ctx->buffer + ctx->cursor, data, length);
ctx->cursor += length;
}
// Custom data flusher function used for writing to memory buffers.
static void pngu_flush_data_to_buffer(png_structp png_ptr) {
// Nothing to do here
}
static int pngu_info(IMGCTX ctx) {
png_byte magic[8];
png_uint_32 width;
png_uint_32 height;
png_color_16p background;
png_bytep trans;
png_color_16p trans_values;
int scale, i;
// Check if there is a file selected and if it is a valid .png
if (ctx->source == PNGU_SOURCE_BUFFER)
memcpy(magic, ctx->buffer, 8);
else if (ctx->source == PNGU_SOURCE_DEVICE) {
// Open file
if (!(ctx->fd = fopen(ctx->filename, "rb")))
return PNGU_CANT_OPEN_FILE;
// Load first 8 bytes into magic buffer
if (fread(magic, 1, 8, ctx->fd) != 8) {
fclose(ctx->fd);
return PNGU_CANT_READ_FILE;
}
}
else
return PNGU_NO_FILE_SELECTED;
;
if (png_sig_cmp(magic, 0, 8) != 0) {
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_FILE_IS_NOT_PNG;
}
// Allocation of libpng structs
ctx->png_ptr =
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!(ctx->png_ptr)) {
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_LIB_ERROR;
}
ctx->info_ptr = png_create_info_struct(ctx->png_ptr);
if (!(ctx->info_ptr)) {
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
png_destroy_read_struct(&(ctx->png_ptr), (png_infopp)NULL,
(png_infopp)NULL);
return PNGU_LIB_ERROR;
}
if (ctx->source == PNGU_SOURCE_BUFFER) {
// Installation of our custom data provider function
ctx->cursor = 0;
png_set_read_fn(ctx->png_ptr, ctx, pngu_read_data_from_buffer);
} else if (ctx->source == PNGU_SOURCE_DEVICE) {
// Default data provider uses function fread, so it needs to use our
// FILE*
png_init_io(ctx->png_ptr, ctx->fd);
png_set_sig_bytes(
ctx->png_ptr,
8); // We have read 8 bytes already to check PNG authenticity
}
// Read png header
png_read_info(ctx->png_ptr, ctx->info_ptr);
// Query image properties if they have not been queried before
if (!ctx->propRead) {
int ctxNumTrans;
png_get_IHDR(ctx->png_ptr, ctx->info_ptr, &width, &height,
(int *)&(ctx->prop.imgBitDepth),
(int *)&(ctx->prop.imgColorType), NULL, NULL, NULL);
ctx->prop.imgWidth = width;
ctx->prop.imgHeight = height;
switch (ctx->prop.imgColorType) {
case PNG_COLOR_TYPE_GRAY:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_GRAY;
break;
case PNG_COLOR_TYPE_GRAY_ALPHA:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_GRAY_ALPHA;
break;
case PNG_COLOR_TYPE_PALETTE:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_PALETTE;
break;
case PNG_COLOR_TYPE_RGB:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_RGB;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_RGB_ALPHA;
break;
default:
ctx->prop.imgColorType = PNGU_COLOR_TYPE_UNKNOWN;
break;
}
// Constant used to scale 16 bit values to 8 bit values
scale = 0;
if (ctx->prop.imgBitDepth == 16)
scale = 8;
// Query background color, if any.
ctx->prop.validBckgrnd = 0;
switch (ctx->prop.imgColorType) {
case PNGU_COLOR_TYPE_RGB:
case PNGU_COLOR_TYPE_RGB_ALPHA: {
if (png_get_bKGD(ctx->png_ptr, ctx->info_ptr, &background)) {
ctx->prop.validBckgrnd = 1;
ctx->prop.bckgrnd.r = background->red >> scale;
ctx->prop.bckgrnd.g = background->green >> scale;
ctx->prop.bckgrnd.b = background->blue >> scale;
}
// Query list of transparent colors, if any.
ctx->prop.numTrans = 0;
ctx->prop.trans = NULL;
if (png_get_tRNS(ctx->png_ptr, ctx->info_ptr, &trans,
(int *)&(ctx->prop.numTrans), &trans_values)) {
ctxNumTrans = ctx->prop.numTrans;
if (ctxNumTrans) {
ctx->prop.trans = malloc(sizeof(PNGUCOLOR) * ctxNumTrans);
if (ctx->prop.trans)
for (i = 0; i < ctxNumTrans; i++) {
ctx->prop.trans[i].r = trans_values[i].red >> scale;
ctx->prop.trans[i].g =
trans_values[i].green >> scale;
ctx->prop.trans[i].b =
trans_values[i].blue >> scale;
}
else
ctx->prop.numTrans = 0;
}
}
} break;
case PNGU_COLOR_TYPE_GRAY:
case PNGU_COLOR_TYPE_GRAY_ALPHA: {
if (png_get_bKGD(ctx->png_ptr, ctx->info_ptr, &background)) {
ctx->prop.validBckgrnd = 1;
ctx->prop.bckgrnd.r = ctx->prop.bckgrnd.g =
ctx->prop.bckgrnd.b = background->gray >> scale;
}
// Query list of transparent colors, if any.
ctx->prop.numTrans = 0;
ctx->prop.trans = NULL;
if (png_get_tRNS(ctx->png_ptr, ctx->info_ptr, &trans,
(int *)&(ctx->prop.numTrans), &trans_values)) {
ctxNumTrans = ctx->prop.numTrans;
if (ctxNumTrans) {
ctx->prop.trans = malloc(sizeof(PNGUCOLOR) * ctxNumTrans);
if (ctx->prop.trans)
for (i = 0; i < ctxNumTrans; i++)
ctx->prop.trans[i].r = ctx->prop.trans[i].g =
ctx->prop.trans[i].b =
trans_values[i].gray >> scale;
else
ctx->prop.numTrans = 0;
}
}
} break;
default:
// It was none of those things,
{
// Query list of transparent colors, if any.
ctx->prop.numTrans = 0;
ctx->prop.trans = NULL;
}
break;
}
ctx->propRead = 1;
}
// Success
ctx->infoRead = 1;
return PNGU_OK;
}
static int pngu_decode(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height,
PNGU_u32 stripAlpha) {
png_uint_32 rowbytes;
png_uint_32 i, propImgHeight;
// Read info if it hasn't been read before
if (!ctx->infoRead) {
int c = pngu_info(ctx);
if (c != PNGU_OK)
return c;
}
// Check if the user has specified the real width and height of the image
if ((ctx->prop.imgWidth != width) || (ctx->prop.imgHeight != height))
return PNGU_INVALID_WIDTH_OR_HEIGHT;
// Check if color type is supported by PNGU
if ((ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE) ||
(ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN))
return PNGU_UNSUPPORTED_COLOR_TYPE;
// Scale 16 bit samples to 8 bit
if (ctx->prop.imgBitDepth == 16)
png_set_strip_16(ctx->png_ptr);
// Remove alpha channel if we don't need it
if (stripAlpha && ((ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) ||
(ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA)))
png_set_strip_alpha(ctx->png_ptr);
// Expand 1, 2 and 4 bit samples to 8 bit
if (ctx->prop.imgBitDepth < 8)
png_set_packing(ctx->png_ptr);
// Transform grayscale images to RGB
if ((ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY) ||
(ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA))
png_set_gray_to_rgb(ctx->png_ptr);
// Flush transformations
png_read_update_info(ctx->png_ptr, ctx->info_ptr);
// Allocate memory to store the image
rowbytes = png_get_rowbytes(ctx->png_ptr, ctx->info_ptr);
if (rowbytes & 3)
rowbytes =
((rowbytes >> 2) + 1)
<< 2; // Add extra padding so each row starts in a 4 byte boundary
ctx->img_data = malloc(rowbytes * ctx->prop.imgHeight);
if (!ctx->img_data) {
pngu_free_info(ctx);
return PNGU_LIB_ERROR;
}
ctx->row_pointers = malloc(sizeof(png_bytep) * ctx->prop.imgHeight);
if (!ctx->row_pointers) {
free(ctx->img_data);
pngu_free_info(ctx);
return PNGU_LIB_ERROR;
}
propImgHeight = ctx->prop.imgHeight;
for (i = 0; i < propImgHeight; ++i)
ctx->row_pointers[i] = ctx->img_data + (i * rowbytes);
// Transform the image and copy it to our allocated memory
png_read_image(ctx->png_ptr, ctx->row_pointers);
// Free resources
pngu_free_info(ctx);
// Success
return PNGU_OK;
}
static inline PNGU_u32 coordsRGBA8(PNGU_u32 x, PNGU_u32 y, PNGU_u32 w) {
return ((((y >> 2) * (w >> 2) + (x >> 2)) << 5) + ((y & 3) << 2) + (x & 3))
<< 1;
}
static u8 *PNGU_DecodeTo4x4RGBA8(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height,
int *dstWidth, int *dstHeight, int maxWidth,
int maxHeight) {
PNGU_u8 default_alpha = 255;
u8 *dst;
int x, y, x2, y2, offset;
int xRatio = 0, yRatio = 0;
png_byte *pixel;
if (pngu_decode(ctx, width, height, 0) != PNGU_OK)
return NULL;
int newWidth = width;
int newHeight = height;
if ((maxWidth > 0 && width > maxWidth) ||
(maxHeight > 0 && height > maxHeight)) {
float ratio = (float)width / (float)height;
newWidth = maxWidth;
newHeight = maxWidth / ratio;
if (newHeight > maxHeight) {
newWidth = maxHeight * ratio;
newHeight = maxHeight;
}
xRatio = (int)((width << 16) / newWidth) + 1;
yRatio = (int)((height << 16) / newHeight) + 1;
}
int padWidth = newWidth;
int padHeight = newHeight;
if (padWidth % 4)
padWidth += (4 - padWidth % 4);
if (padHeight % 4)
padHeight += (4 - padHeight % 4);
int len = (padWidth * padHeight) << 2;
if (len % 32)
len += (32 - len % 32);
dst = memalign(32, len);
if (!dst)
return NULL;
for (y = 0; y < padHeight; y++) {
for (x = 0; x < padWidth; x++) {
offset = coordsRGBA8(x, y, padWidth);
if (y >= newHeight || x >= newWidth) {
dst[offset] = 0;
dst[offset + 1] = 255;
dst[offset + 32] = 255;
dst[offset + 33] = 255;
} else {
if (xRatio > 0) {
x2 = ((x * xRatio) >> 16);
y2 = ((y * yRatio) >> 16);
}
if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA ||
ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) {
if (xRatio > 0)
pixel = &(ctx->row_pointers[y2][x2 * 4]);
else
pixel = &(ctx->row_pointers[y][x * 4]);
dst[offset] = pixel[3]; // Alpha
dst[offset + 1] = pixel[0]; // Red
dst[offset + 32] = pixel[1]; // Green
dst[offset + 33] = pixel[2]; // Blue
} else {
if (xRatio > 0)
pixel = &(ctx->row_pointers[y2][x2 * 3]);
else
pixel = &(ctx->row_pointers[y][x * 3]);
dst[offset] = default_alpha; // Alpha
dst[offset + 1] = pixel[0]; // Red
dst[offset + 32] = pixel[1]; // Green
dst[offset + 33] = pixel[2]; // Blue
}
}
}
}
// Free resources
free(ctx->img_data);
free(ctx->row_pointers);
*dstWidth = padWidth;
*dstHeight = padHeight;
DCFlushRange(dst, len);
return dst;
}
IMGCTX PNGU_SelectImageFromBuffer(const void *buffer) {
IMGCTX ctx = NULL;
if (!buffer)
return NULL;
ctx = malloc(sizeof(struct _IMGCTX));
if (!ctx)
return NULL;
ctx->buffer = (void *)buffer;
ctx->source = PNGU_SOURCE_BUFFER;
ctx->cursor = 0;
ctx->filename = NULL;
ctx->propRead = 0;
ctx->infoRead = 0;
return ctx;
}
IMGCTX PNGU_SelectImageFromDevice(const char *filename) {
IMGCTX ctx = NULL;
if (!filename)
return NULL;
ctx = malloc(sizeof(struct _IMGCTX));
if (!ctx)
return NULL;
ctx->buffer = NULL;
ctx->source = PNGU_SOURCE_DEVICE;
ctx->cursor = 0;
ctx->filename = malloc(strlen(filename) + 1);
if (!ctx->filename) {
free(ctx);
return NULL;
}
strcpy(ctx->filename, filename);
ctx->propRead = 0;
ctx->infoRead = 0;
return ctx;
}
void PNGU_ReleaseImageContext(IMGCTX ctx) {
if (!ctx)
return;
if (ctx->filename)
free(ctx->filename);
if ((ctx->propRead) && (ctx->prop.trans))
free(ctx->prop.trans);
pngu_free_info(ctx);
free(ctx);
}
int PNGU_GetImageProperties(IMGCTX ctx, PNGUPROP *imgprop) {
int res;
if (!ctx->propRead) {
res = pngu_info(ctx);
if (res != PNGU_OK)
return res;
}
*imgprop = ctx->prop;
return PNGU_OK;
}
PNGU_u8 *DecodePNG(const PNGU_u8 *src, int *width, int *height, int maxwidth,
int maxheight) {
PNGUPROP imgProp;
IMGCTX ctx = PNGU_SelectImageFromBuffer(src);
u8 *dst = NULL;
if (!ctx)
return NULL;
if (PNGU_GetImageProperties(ctx, &imgProp) == PNGU_OK)
dst = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight,
width, height, maxwidth, maxheight);
PNGU_ReleaseImageContext(ctx);
return dst;
}
int PNGU_EncodeFromRGB(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height,
void *buffer, PNGU_u32 stride) {
png_uint_32 rowbytes;
PNGU_u32 y;
// Erase from the context any readed info
pngu_free_info(ctx);
ctx->propRead = 0;
// Check if the user has selected a file to write the image
if (ctx->source == PNGU_SOURCE_BUFFER)
;
else if (ctx->source == PNGU_SOURCE_DEVICE) {
// Open file
if (!(ctx->fd = fopen(ctx->filename, "wb")))
return PNGU_CANT_OPEN_FILE;
}
else
return PNGU_NO_FILE_SELECTED;
// Allocation of libpng structs
ctx->png_ptr =
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!(ctx->png_ptr)) {
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_LIB_ERROR;
}
ctx->info_ptr = png_create_info_struct(ctx->png_ptr);
if (!(ctx->info_ptr)) {
png_destroy_write_struct(&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_LIB_ERROR;
}
if (ctx->source == PNGU_SOURCE_BUFFER) {
// Installation of our custom data writer function
ctx->cursor = 0;
png_set_write_fn(ctx->png_ptr, ctx, pngu_write_data_to_buffer,
pngu_flush_data_to_buffer);
} else if (ctx->source == PNGU_SOURCE_DEVICE) {
// Default data writer uses function fwrite, so it needs to use our
// FILE*
png_init_io(ctx->png_ptr, ctx->fd);
}
// Setup output file properties
png_set_IHDR(ctx->png_ptr, ctx->info_ptr, width, height, 8,
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// Allocate memory to store the image in RGB format
rowbytes = width * 3;
if (rowbytes % 4)
rowbytes =
((rowbytes >> 2) + 1)
<< 2; // Add extra padding so each row starts in a 4 byte boundary
ctx->img_data = malloc(rowbytes * height);
memset(ctx->img_data, 0, rowbytes * height);
if (!ctx->img_data) {
png_destroy_write_struct(&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_LIB_ERROR;
}
ctx->row_pointers = malloc(sizeof(png_bytep) * height);
memset(ctx->row_pointers, 0, sizeof(png_bytep) * height);
if (!ctx->row_pointers) {
png_destroy_write_struct(&(ctx->png_ptr), (png_infopp)NULL);
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
return PNGU_LIB_ERROR;
}
for (y = 0; y < height; ++y) {
ctx->row_pointers[y] = buffer + (y * rowbytes);
}
// Tell libpng where is our image data
png_set_rows(ctx->png_ptr, ctx->info_ptr, ctx->row_pointers);
// Write file header and image data
png_write_png(ctx->png_ptr, ctx->info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
// Tell libpng we have no more data to write
png_write_end(ctx->png_ptr, (png_infop)NULL);
// Free resources
free(ctx->img_data);
free(ctx->row_pointers);
png_destroy_write_struct(&(ctx->png_ptr), &(ctx->info_ptr));
if (ctx->source == PNGU_SOURCE_DEVICE)
fclose(ctx->fd);
// Success
return ctx->cursor;
}
int PNGU_EncodeFromGXTexture(IMGCTX ctx, PNGU_u32 width, PNGU_u32 height,
void *buffer, PNGU_u32 stride) {
int res;
PNGU_u32 x, y, tmpy1, tmpy2, tmpyWid, tmpxy;
unsigned char *ptr = (unsigned char *)buffer;
unsigned char *tmpbuffer = (unsigned char *)malloc(width * height * 3);
memset(tmpbuffer, 0, width * height * 3);
png_uint_32 offset;
for (y = 0; y < height; y++) {
tmpy1 = y * 640 * 3;
tmpy2 = y % 4 << 2;
tmpyWid = (((y >> 2) << 4) * width);
for (x = 0; x < width; x++) {
offset = tmpyWid + ((x >> 2) << 6) + ((tmpy2 + x % 4) << 1);
tmpxy = x * 3 + tmpy1;
tmpbuffer[tmpxy] = ptr[offset + 1]; // R
tmpbuffer[tmpxy + 1] = ptr[offset + 32]; // G
tmpbuffer[tmpxy + 2] = ptr[offset + 33]; // B
}
}
res = PNGU_EncodeFromRGB(ctx, width, height, tmpbuffer, stride);
free(tmpbuffer);
return res;
}
| /********************************************************************************************
*
* PNGU
*
* Original author: frontier (http://frontier-dev.net)
* Modified by Tantric, 2009-2010
*
********************************************************************************************/
#include "IMPORT_0"
#include <IMPORT_1>
#include <IMPORT_2>
#include <IMPORT_3>
#include <IMPORT_4>
#include <IMPORT_5>
// Constants
#define VAR_0 1
#define VAR_1 2
// Return codes
#define VAR_2 0
#define VAR_3 1
#define VAR_4 2
#define VAR_5 3
#define VAR_6 4
#define VAR_7 5
#define VAR_8 6
#define VAR_9 7
#define VAR_10 8
#define VAR_11 9
// Color types
#define VAR_12 1
#define VAR_13 2
#define VAR_14 3
#define VAR_15 4
#define VAR_16 5
#define VAR_17 6
// PNGU Image context struct
struct CLASS_0 {
int VAR_18;
void *VAR_19;
char *VAR_20;
CLASS_1 VAR_21;
CLASS_1 VAR_22;
CLASS_2 VAR_23;
CLASS_1 VAR_24;
CLASS_3 VAR_25;
CLASS_4 VAR_26;
CLASS_5 *VAR_27;
CLASS_6 *VAR_29;
CLASS_6 VAR_30;
};
// PNGU Implementation
static void FUNC_0(CLASS_7 VAR_31) {
if (VAR_31->VAR_24) {
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
FUNC_2(&(VAR_31->VAR_25), &(VAR_31->VAR_26),
(ID_2)NULL);
VAR_31->VAR_24 = 0;
}
}
// Custom data provider function used for reading from memory buffers.
static void FUNC_3(CLASS_3 VAR_25, CLASS_6 VAR_33,
CLASS_8 VAR_34) {
CLASS_7 VAR_31 = (ID_1)FUNC_4(VAR_25);
FUNC_5(VAR_33, VAR_31->VAR_19 + VAR_31->VAR_21, VAR_34);
VAR_31->VAR_21 += VAR_34;
}
// Custom data writer function used for writing to memory buffers.
static void FUNC_6(CLASS_3 VAR_25, CLASS_6 VAR_33,
CLASS_8 VAR_34) {
CLASS_7 VAR_31 = (ID_1)FUNC_4(VAR_25);
FUNC_5(VAR_31->VAR_19 + VAR_31->VAR_21, VAR_33, VAR_34);
VAR_31->VAR_21 += VAR_34;
}
// Custom data flusher function used for writing to memory buffers.
static void FUNC_7(CLASS_3 VAR_25) {
// Nothing to do here
}
static int FUNC_8(CLASS_7 VAR_31) {
CLASS_9 VAR_37[8];
CLASS_10 VAR_38;
CLASS_10 VAR_39;
CLASS_11 VAR_40;
CLASS_6 VAR_41;
CLASS_11 VAR_42;
int VAR_43, VAR_44;
// Check if there is a file selected and if it is a valid .png
if (VAR_31->VAR_18 == VAR_0)
FUNC_5(VAR_37, VAR_31->VAR_19, 8);
else if (VAR_31->VAR_18 == VAR_1) {
// Open file
if (!(VAR_31->VAR_27 = FUNC_9(VAR_31->VAR_20, "rb")))
return VAR_9;
// Load first 8 bytes into magic buffer
if (FUNC_10(VAR_37, 1, 8, VAR_31->VAR_27) != 8) {
FUNC_1(VAR_31->VAR_27);
return VAR_10;
}
}
else
return VAR_8;
;
if (FUNC_11(VAR_37, 0, 8) != 0) {
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_6;
}
// Allocation of libpng structs
VAR_31->VAR_25 =
FUNC_12(VAR_45, NULL, NULL, NULL);
if (!(VAR_31->VAR_25)) {
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_11;
}
VAR_31->VAR_26 = FUNC_13(VAR_31->VAR_25);
if (!(VAR_31->VAR_26)) {
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
FUNC_2(&(VAR_31->VAR_25), (ID_2)NULL,
(ID_2)NULL);
return VAR_11;
}
if (VAR_31->VAR_18 == VAR_0) {
// Installation of our custom data provider function
VAR_31->VAR_21 = 0;
FUNC_14(VAR_31->VAR_25, VAR_31, VAR_32);
} else if (VAR_31->VAR_18 == VAR_1) {
// Default data provider uses function fread, so it needs to use our
// FILE*
FUNC_15(VAR_31->VAR_25, VAR_31->VAR_27);
FUNC_16(
VAR_31->VAR_25,
8); // We have read 8 bytes already to check PNG authenticity
}
// Read png header
FUNC_17(VAR_31->VAR_25, VAR_31->VAR_26);
// Query image properties if they have not been queried before
if (!VAR_31->VAR_22) {
int VAR_46;
FUNC_18(VAR_31->VAR_25, VAR_31->VAR_26, &VAR_38, &VAR_39,
(int *)&(VAR_31->VAR_23.VAR_47),
(int *)&(VAR_31->VAR_23.VAR_48), NULL, NULL, NULL);
VAR_31->VAR_23.VAR_49 = VAR_38;
VAR_31->VAR_23.VAR_50 = VAR_39;
switch (VAR_31->VAR_23.VAR_48) {
case VAR_51:
VAR_31->VAR_23.VAR_48 = VAR_12;
break;
case VAR_52:
VAR_31->VAR_23.VAR_48 = VAR_13;
break;
case PNG_COLOR_TYPE_PALETTE:
VAR_31->VAR_23.VAR_48 = VAR_14;
break;
case VAR_53:
VAR_31->VAR_23.VAR_48 = VAR_15;
break;
case VAR_54:
VAR_31->VAR_23.VAR_48 = VAR_16;
break;
default:
VAR_31->VAR_23.VAR_48 = VAR_17;
break;
}
// Constant used to scale 16 bit values to 8 bit values
VAR_43 = 0;
if (VAR_31->VAR_23.VAR_47 == 16)
VAR_43 = 8;
// Query background color, if any.
VAR_31->VAR_23.VAR_55 = 0;
switch (VAR_31->VAR_23.VAR_48) {
case VAR_15:
case VAR_16: {
if (FUNC_19(VAR_31->VAR_25, VAR_31->VAR_26, &VAR_40)) {
VAR_31->VAR_23.VAR_55 = 1;
VAR_31->VAR_23.VAR_56.VAR_57 = VAR_40->VAR_58 >> VAR_43;
VAR_31->VAR_23.VAR_56.VAR_59 = VAR_40->VAR_60 >> VAR_43;
VAR_31->VAR_23.VAR_56.VAR_61 = VAR_40->VAR_62 >> VAR_43;
}
// Query list of transparent colors, if any.
VAR_31->VAR_23.VAR_63 = 0;
VAR_31->VAR_23.VAR_41 = NULL;
if (FUNC_20(VAR_31->VAR_25, VAR_31->VAR_26, &VAR_41,
(int *)&(VAR_31->VAR_23.VAR_63), &VAR_42)) {
VAR_46 = VAR_31->VAR_23.VAR_63;
if (VAR_46) {
VAR_31->VAR_23.VAR_41 = FUNC_21(sizeof(VAR_64) * VAR_46);
if (VAR_31->VAR_23.VAR_41)
for (VAR_44 = 0; VAR_44 < VAR_46; VAR_44++) {
VAR_31->VAR_23.VAR_41[VAR_44].VAR_57 = VAR_42[VAR_44].VAR_58 >> VAR_43;
VAR_31->VAR_23.VAR_41[VAR_44].VAR_59 =
VAR_42[VAR_44].VAR_60 >> VAR_43;
VAR_31->VAR_23.VAR_41[VAR_44].VAR_61 =
VAR_42[VAR_44].VAR_62 >> VAR_43;
}
else
VAR_31->VAR_23.VAR_63 = 0;
}
}
} break;
case VAR_12:
case VAR_13: {
if (FUNC_19(VAR_31->VAR_25, VAR_31->VAR_26, &VAR_40)) {
VAR_31->VAR_23.VAR_55 = 1;
VAR_31->VAR_23.VAR_56.VAR_57 = VAR_31->VAR_23.VAR_56.VAR_59 =
VAR_31->VAR_23.VAR_56.VAR_61 = VAR_40->VAR_65 >> VAR_43;
}
// Query list of transparent colors, if any.
VAR_31->VAR_23.VAR_63 = 0;
VAR_31->VAR_23.VAR_41 = NULL;
if (FUNC_20(VAR_31->VAR_25, VAR_31->VAR_26, &VAR_41,
(int *)&(VAR_31->VAR_23.VAR_63), &VAR_42)) {
VAR_46 = VAR_31->VAR_23.VAR_63;
if (VAR_46) {
VAR_31->VAR_23.VAR_41 = FUNC_21(sizeof(VAR_64) * VAR_46);
if (VAR_31->VAR_23.VAR_41)
for (VAR_44 = 0; VAR_44 < VAR_46; VAR_44++)
VAR_31->VAR_23.VAR_41[VAR_44].VAR_57 = VAR_31->VAR_23.VAR_41[VAR_44].VAR_59 =
VAR_31->VAR_23.VAR_41[VAR_44].VAR_61 =
VAR_42[VAR_44].VAR_65 >> VAR_43;
else
VAR_31->VAR_23.VAR_63 = 0;
}
}
} break;
default:
// It was none of those things,
{
// Query list of transparent colors, if any.
VAR_31->VAR_23.VAR_63 = 0;
VAR_31->VAR_23.VAR_41 = NULL;
}
break;
}
VAR_31->VAR_22 = 1;
}
// Success
VAR_31->VAR_24 = 1;
return VAR_2;
}
static int FUNC_22(CLASS_7 VAR_31, CLASS_1 VAR_38, CLASS_1 VAR_39,
CLASS_1 VAR_66) {
CLASS_10 VAR_67;
CLASS_10 VAR_44, VAR_68;
// Read info if it hasn't been read before
if (!VAR_31->VAR_24) {
int VAR_69 = FUNC_8(VAR_31);
if (VAR_69 != VAR_2)
return VAR_69;
}
// Check if the user has specified the real width and height of the image
if ((VAR_31->VAR_23.VAR_49 != VAR_38) || (VAR_31->VAR_23.VAR_50 != VAR_39))
return VAR_5;
// Check if color type is supported by PNGU
if ((VAR_31->VAR_23.VAR_48 == VAR_14) ||
(VAR_31->VAR_23.VAR_48 == VAR_17))
return VAR_7;
// Scale 16 bit samples to 8 bit
if (VAR_31->VAR_23.VAR_47 == 16)
FUNC_23(VAR_31->VAR_25);
// Remove alpha channel if we don't need it
if (VAR_66 && ((VAR_31->VAR_23.VAR_48 == VAR_16) ||
(VAR_31->VAR_23.VAR_48 == VAR_13)))
FUNC_24(VAR_31->VAR_25);
// Expand 1, 2 and 4 bit samples to 8 bit
if (VAR_31->VAR_23.VAR_47 < 8)
FUNC_25(VAR_31->VAR_25);
// Transform grayscale images to RGB
if ((VAR_31->VAR_23.VAR_48 == VAR_12) ||
(VAR_31->VAR_23.VAR_48 == VAR_13))
FUNC_26(VAR_31->VAR_25);
// Flush transformations
FUNC_27(VAR_31->VAR_25, VAR_31->VAR_26);
// Allocate memory to store the image
VAR_67 = FUNC_28(VAR_31->VAR_25, VAR_31->VAR_26);
if (VAR_67 & 3)
VAR_67 =
((VAR_67 >> 2) + 1)
<< 2; // Add extra padding so each row starts in a 4 byte boundary
VAR_31->VAR_30 = FUNC_21(VAR_67 * VAR_31->VAR_23.VAR_50);
if (!VAR_31->VAR_30) {
FUNC_0(VAR_31);
return VAR_11;
}
VAR_31->VAR_29 = FUNC_21(sizeof(VAR_28) * VAR_31->VAR_23.VAR_50);
if (!VAR_31->VAR_29) {
FUNC_29(VAR_31->VAR_30);
FUNC_0(VAR_31);
return VAR_11;
}
VAR_68 = VAR_31->VAR_23.VAR_50;
for (VAR_44 = 0; VAR_44 < VAR_68; ++VAR_44)
VAR_31->VAR_29[VAR_44] = VAR_31->VAR_30 + (VAR_44 * VAR_67);
// Transform the image and copy it to our allocated memory
FUNC_30(VAR_31->VAR_25, VAR_31->VAR_29);
// Free resources
FUNC_0(VAR_31);
// Success
return VAR_2;
}
static inline CLASS_1 FUNC_31(CLASS_1 VAR_70, CLASS_1 VAR_71, CLASS_1 VAR_72) {
return ((((VAR_71 >> 2) * (VAR_72 >> 2) + (VAR_70 >> 2)) << 5) + ((VAR_71 & 3) << 2) + (VAR_70 & 3))
<< 1;
}
static CLASS_12 *FUNC_32(CLASS_7 VAR_31, CLASS_1 VAR_38, CLASS_1 VAR_39,
int *VAR_73, int *VAR_74, int VAR_75,
int VAR_76) {
CLASS_13 VAR_77 = 255;
CLASS_12 *VAR_78;
int VAR_70, VAR_71, VAR_79, VAR_80, VAR_81;
int VAR_82 = 0, VAR_83 = 0;
CLASS_9 *VAR_84;
if (FUNC_22(VAR_31, VAR_38, VAR_39, 0) != VAR_2)
return NULL;
int VAR_85 = VAR_38;
int VAR_86 = VAR_39;
if ((VAR_75 > 0 && VAR_38 > VAR_75) ||
(VAR_76 > 0 && VAR_39 > VAR_76)) {
float VAR_87 = (float)VAR_38 / (float)VAR_39;
VAR_85 = VAR_75;
VAR_86 = VAR_75 / VAR_87;
if (VAR_86 > VAR_76) {
VAR_85 = VAR_76 * VAR_87;
VAR_86 = VAR_76;
}
VAR_82 = (int)((VAR_38 << 16) / VAR_85) + 1;
VAR_83 = (int)((VAR_39 << 16) / VAR_86) + 1;
}
int VAR_88 = VAR_85;
int VAR_89 = VAR_86;
if (VAR_88 % 4)
VAR_88 += (4 - VAR_88 % 4);
if (VAR_89 % 4)
VAR_89 += (4 - VAR_89 % 4);
int VAR_90 = (VAR_88 * VAR_89) << 2;
if (VAR_90 % 32)
VAR_90 += (32 - VAR_90 % 32);
VAR_78 = FUNC_33(32, VAR_90);
if (!VAR_78)
return NULL;
for (VAR_71 = 0; VAR_71 < VAR_89; VAR_71++) {
for (VAR_70 = 0; VAR_70 < VAR_88; VAR_70++) {
VAR_81 = FUNC_31(VAR_70, VAR_71, VAR_88);
if (VAR_71 >= VAR_86 || VAR_70 >= VAR_85) {
VAR_78[VAR_81] = 0;
VAR_78[VAR_81 + 1] = 255;
VAR_78[VAR_81 + 32] = 255;
VAR_78[VAR_81 + 33] = 255;
} else {
if (VAR_82 > 0) {
VAR_79 = ((VAR_70 * VAR_82) >> 16);
VAR_80 = ((VAR_71 * VAR_83) >> 16);
}
if (VAR_31->VAR_23.VAR_48 == VAR_13 ||
VAR_31->VAR_23.VAR_48 == VAR_16) {
if (VAR_82 > 0)
VAR_84 = &(VAR_31->VAR_29[VAR_80][VAR_79 * 4]);
else
VAR_84 = &(VAR_31->VAR_29[VAR_71][VAR_70 * 4]);
VAR_78[VAR_81] = VAR_84[3]; // Alpha
VAR_78[VAR_81 + 1] = VAR_84[0]; // Red
VAR_78[VAR_81 + 32] = VAR_84[1]; // Green
VAR_78[VAR_81 + 33] = VAR_84[2]; // Blue
} else {
if (VAR_82 > 0)
VAR_84 = &(VAR_31->VAR_29[VAR_80][VAR_79 * 3]);
else
VAR_84 = &(VAR_31->VAR_29[VAR_71][VAR_70 * 3]);
VAR_78[VAR_81] = VAR_77; // Alpha
VAR_78[VAR_81 + 1] = VAR_84[0]; // Red
VAR_78[VAR_81 + 32] = VAR_84[1]; // Green
VAR_78[VAR_81 + 33] = VAR_84[2]; // Blue
}
}
}
}
// Free resources
FUNC_29(VAR_31->VAR_30);
FUNC_29(VAR_31->VAR_29);
*VAR_73 = VAR_88;
*VAR_74 = VAR_89;
FUNC_34(VAR_78, VAR_90);
return VAR_78;
}
CLASS_7 FUNC_35(const void *VAR_19) {
CLASS_7 VAR_31 = NULL;
if (!VAR_19)
return NULL;
VAR_31 = FUNC_21(sizeof(struct CLASS_0));
if (!VAR_31)
return NULL;
VAR_31->VAR_19 = (void *)VAR_19;
VAR_31->VAR_18 = VAR_0;
VAR_31->VAR_21 = 0;
VAR_31->VAR_20 = NULL;
VAR_31->VAR_22 = 0;
VAR_31->VAR_24 = 0;
return VAR_31;
}
CLASS_7 FUNC_36(const char *VAR_20) {
CLASS_7 VAR_31 = NULL;
if (!VAR_20)
return NULL;
VAR_31 = FUNC_21(sizeof(struct CLASS_0));
if (!VAR_31)
return NULL;
VAR_31->VAR_19 = NULL;
VAR_31->VAR_18 = VAR_1;
VAR_31->VAR_21 = 0;
VAR_31->VAR_20 = FUNC_21(FUNC_37(VAR_20) + 1);
if (!VAR_31->VAR_20) {
FUNC_29(VAR_31);
return NULL;
}
FUNC_38(VAR_31->VAR_20, VAR_20);
VAR_31->VAR_22 = 0;
VAR_31->VAR_24 = 0;
return VAR_31;
}
void FUNC_39(CLASS_7 VAR_31) {
if (!VAR_31)
return;
if (VAR_31->VAR_20)
FUNC_29(VAR_31->VAR_20);
if ((VAR_31->VAR_22) && (VAR_31->VAR_23.VAR_41))
FUNC_29(VAR_31->VAR_23.VAR_41);
FUNC_0(VAR_31);
FUNC_29(VAR_31);
}
int FUNC_40(CLASS_7 VAR_31, CLASS_2 *VAR_91) {
int VAR_92;
if (!VAR_31->VAR_22) {
VAR_92 = FUNC_8(VAR_31);
if (VAR_92 != VAR_2)
return VAR_92;
}
*VAR_91 = VAR_31->VAR_23;
return VAR_2;
}
CLASS_13 *FUNC_41(const CLASS_13 *VAR_93, int *VAR_38, int *VAR_39, int VAR_94,
int VAR_95) {
CLASS_2 VAR_96;
CLASS_7 VAR_31 = FUNC_35(VAR_93);
CLASS_12 *VAR_78 = NULL;
if (!VAR_31)
return NULL;
if (FUNC_40(VAR_31, &VAR_96) == VAR_2)
VAR_78 = FUNC_32(VAR_31, VAR_96.VAR_49, VAR_96.VAR_50,
VAR_38, VAR_39, VAR_94, VAR_95);
FUNC_39(VAR_31);
return VAR_78;
}
int FUNC_42(CLASS_7 VAR_31, CLASS_1 VAR_38, CLASS_1 VAR_39,
void *VAR_19, CLASS_1 VAR_97) {
CLASS_10 VAR_67;
CLASS_1 VAR_71;
// Erase from the context any readed info
FUNC_0(VAR_31);
VAR_31->VAR_22 = 0;
// Check if the user has selected a file to write the image
if (VAR_31->VAR_18 == VAR_0)
;
else if (VAR_31->VAR_18 == VAR_1) {
// Open file
if (!(VAR_31->VAR_27 = FUNC_9(VAR_31->VAR_20, "wb")))
return VAR_9;
}
else
return VAR_8;
// Allocation of libpng structs
VAR_31->VAR_25 =
FUNC_43(VAR_45, NULL, NULL, NULL);
if (!(VAR_31->VAR_25)) {
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_11;
}
VAR_31->VAR_26 = FUNC_13(VAR_31->VAR_25);
if (!(VAR_31->VAR_26)) {
FUNC_44(&(VAR_31->VAR_25), (ID_2)NULL);
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_11;
}
if (VAR_31->VAR_18 == VAR_0) {
// Installation of our custom data writer function
VAR_31->VAR_21 = 0;
FUNC_45(VAR_31->VAR_25, VAR_31, VAR_35,
VAR_36);
} else if (VAR_31->VAR_18 == VAR_1) {
// Default data writer uses function fwrite, so it needs to use our
// FILE*
FUNC_15(VAR_31->VAR_25, VAR_31->VAR_27);
}
// Setup output file properties
FUNC_46(VAR_31->VAR_25, VAR_31->VAR_26, VAR_38, VAR_39, 8,
VAR_53, VAR_98,
VAR_99, VAR_100);
// Allocate memory to store the image in RGB format
VAR_67 = VAR_38 * 3;
if (VAR_67 % 4)
VAR_67 =
((VAR_67 >> 2) + 1)
<< 2; // Add extra padding so each row starts in a 4 byte boundary
VAR_31->VAR_30 = FUNC_21(VAR_67 * VAR_39);
FUNC_47(VAR_31->VAR_30, 0, VAR_67 * VAR_39);
if (!VAR_31->VAR_30) {
FUNC_44(&(VAR_31->VAR_25), (ID_2)NULL);
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_11;
}
VAR_31->VAR_29 = FUNC_21(sizeof(VAR_28) * VAR_39);
FUNC_47(VAR_31->VAR_29, 0, sizeof(VAR_28) * VAR_39);
if (!VAR_31->VAR_29) {
FUNC_44(&(VAR_31->VAR_25), (ID_2)NULL);
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
return VAR_11;
}
for (VAR_71 = 0; VAR_71 < VAR_39; ++VAR_71) {
VAR_31->VAR_29[VAR_71] = VAR_19 + (VAR_71 * VAR_67);
}
// Tell libpng where is our image data
FUNC_48(VAR_31->VAR_25, VAR_31->VAR_26, VAR_31->VAR_29);
// Write file header and image data
FUNC_49(VAR_31->VAR_25, VAR_31->VAR_26, VAR_101, NULL);
// Tell libpng we have no more data to write
FUNC_50(VAR_31->VAR_25, (ID_0)NULL);
// Free resources
FUNC_29(VAR_31->VAR_30);
FUNC_29(VAR_31->VAR_29);
FUNC_44(&(VAR_31->VAR_25), &(VAR_31->VAR_26));
if (VAR_31->VAR_18 == VAR_1)
FUNC_1(VAR_31->VAR_27);
// Success
return VAR_31->VAR_21;
}
int FUNC_51(CLASS_7 VAR_31, CLASS_1 VAR_38, CLASS_1 VAR_39,
void *VAR_19, CLASS_1 VAR_97) {
int VAR_92;
CLASS_1 VAR_70, VAR_71, VAR_102, VAR_103, VAR_104, VAR_105;
unsigned char *VAR_106 = (unsigned char *)VAR_19;
unsigned char *tmpbuffer = (unsigned char *)FUNC_21(VAR_38 * VAR_39 * 3);
FUNC_47(tmpbuffer, 0, VAR_38 * VAR_39 * 3);
CLASS_10 VAR_81;
for (VAR_71 = 0; VAR_71 < VAR_39; VAR_71++) {
VAR_102 = VAR_71 * 640 * 3;
VAR_103 = VAR_71 % 4 << 2;
VAR_104 = (((VAR_71 >> 2) << 4) * VAR_38);
for (VAR_70 = 0; VAR_70 < VAR_38; VAR_70++) {
VAR_81 = VAR_104 + ((VAR_70 >> 2) << 6) + ((VAR_103 + VAR_70 % 4) << 1);
VAR_105 = VAR_70 * 3 + VAR_102;
tmpbuffer[VAR_105] = VAR_106[VAR_81 + 1]; // R
tmpbuffer[VAR_105 + 1] = VAR_106[VAR_81 + 32]; // G
tmpbuffer[VAR_105 + 2] = VAR_106[VAR_81 + 33]; // B
}
}
VAR_92 = FUNC_42(VAR_31, VAR_38, VAR_39, tmpbuffer, VAR_97);
FUNC_29(tmpbuffer);
return VAR_92;
}
| 0.987852 | {'IMPORT_0': 'pngu.h', 'IMPORT_1': 'gccore.h', 'IMPORT_2': 'malloc.h', 'IMPORT_3': 'png.h', 'IMPORT_4': 'stdio.h', 'IMPORT_5': 'string.h', 'VAR_0': 'PNGU_SOURCE_BUFFER', 'VAR_1': 'PNGU_SOURCE_DEVICE', 'VAR_2': 'PNGU_OK', 'VAR_3': 'PNGU_ODD_WIDTH', 'VAR_4': 'PNGU_ODD_STRIDE', 'VAR_5': 'PNGU_INVALID_WIDTH_OR_HEIGHT', 'VAR_6': 'PNGU_FILE_IS_NOT_PNG', 'VAR_7': 'PNGU_UNSUPPORTED_COLOR_TYPE', 'VAR_8': 'PNGU_NO_FILE_SELECTED', 'VAR_9': 'PNGU_CANT_OPEN_FILE', 'VAR_10': 'PNGU_CANT_READ_FILE', 'VAR_11': 'PNGU_LIB_ERROR', 'VAR_12': 'PNGU_COLOR_TYPE_GRAY', 'VAR_13': 'PNGU_COLOR_TYPE_GRAY_ALPHA', 'VAR_14': 'PNGU_COLOR_TYPE_PALETTE', 'VAR_15': 'PNGU_COLOR_TYPE_RGB', 'VAR_16': 'PNGU_COLOR_TYPE_RGB_ALPHA', 'VAR_17': 'PNGU_COLOR_TYPE_UNKNOWN', 'CLASS_0': '_IMGCTX', 'VAR_18': 'source', 'VAR_19': 'buffer', 'VAR_20': 'filename', 'CLASS_1': 'PNGU_u32', 'VAR_21': 'cursor', 'VAR_22': 'propRead', 'CLASS_2': 'PNGUPROP', 'VAR_23': 'prop', 'VAR_24': 'infoRead', 'CLASS_3': 'png_structp', 'VAR_25': 'png_ptr', 'CLASS_4': 'png_infop', 'ID_0': 'png_infop', 'VAR_26': 'info_ptr', 'CLASS_5': 'FILE', 'VAR_27': 'fd', 'CLASS_6': 'png_bytep', 'VAR_28': 'png_bytep', 'VAR_29': 'row_pointers', 'VAR_30': 'img_data', 'FUNC_0': 'pngu_free_info', 'CLASS_7': 'IMGCTX', 'ID_1': 'IMGCTX', 'VAR_31': 'ctx', 'FUNC_1': 'fclose', 'FUNC_2': 'png_destroy_read_struct', 'ID_2': 'png_infopp', 'FUNC_3': 'pngu_read_data_from_buffer', 'VAR_32': 'pngu_read_data_from_buffer', 'VAR_33': 'data', 'CLASS_8': 'png_size_t', 'VAR_34': 'length', 'FUNC_4': 'png_get_io_ptr', 'FUNC_5': 'memcpy', 'FUNC_6': 'pngu_write_data_to_buffer', 'VAR_35': 'pngu_write_data_to_buffer', 'FUNC_7': 'pngu_flush_data_to_buffer', 'VAR_36': 'pngu_flush_data_to_buffer', 'FUNC_8': 'pngu_info', 'CLASS_9': 'png_byte', 'VAR_37': 'magic', 'CLASS_10': 'png_uint_32', 'VAR_38': 'width', 'VAR_39': 'height', 'CLASS_11': 'png_color_16p', 'VAR_40': 'background', 'VAR_41': 'trans', 'VAR_42': 'trans_values', 'VAR_43': 'scale', 'VAR_44': 'i', 'FUNC_9': 'fopen', 'FUNC_10': 'fread', 'FUNC_11': 'png_sig_cmp', 'FUNC_12': 'png_create_read_struct', 'VAR_45': 'PNG_LIBPNG_VER_STRING', 'FUNC_13': 'png_create_info_struct', 'FUNC_14': 'png_set_read_fn', 'FUNC_15': 'png_init_io', 'FUNC_16': 'png_set_sig_bytes', 'FUNC_17': 'png_read_info', 'VAR_46': 'ctxNumTrans', 'FUNC_18': 'png_get_IHDR', 'VAR_47': 'imgBitDepth', 'VAR_48': 'imgColorType', 'VAR_49': 'imgWidth', 'VAR_50': 'imgHeight', 'VAR_51': 'PNG_COLOR_TYPE_GRAY', 'VAR_52': 'PNG_COLOR_TYPE_GRAY_ALPHA', 'VAR_53': 'PNG_COLOR_TYPE_RGB', 'VAR_54': 'PNG_COLOR_TYPE_RGB_ALPHA', 'VAR_55': 'validBckgrnd', 'FUNC_19': 'png_get_bKGD', 'VAR_56': 'bckgrnd', 'VAR_57': 'r', 'VAR_58': 'red', 'VAR_59': 'g', 'VAR_60': 'green', 'VAR_61': 'b', 'VAR_62': 'blue', 'VAR_63': 'numTrans', 'FUNC_20': 'png_get_tRNS', 'FUNC_21': 'malloc', 'VAR_64': 'PNGUCOLOR', 'VAR_65': 'gray', 'FUNC_22': 'pngu_decode', 'VAR_66': 'stripAlpha', 'VAR_67': 'rowbytes', 'VAR_68': 'propImgHeight', 'VAR_69': 'c', 'FUNC_23': 'png_set_strip_16', 'FUNC_24': 'png_set_strip_alpha', 'FUNC_25': 'png_set_packing', 'FUNC_26': 'png_set_gray_to_rgb', 'FUNC_27': 'png_read_update_info', 'FUNC_28': 'png_get_rowbytes', 'FUNC_29': 'free', 'FUNC_30': 'png_read_image', 'FUNC_31': 'coordsRGBA8', 'VAR_70': 'x', 'VAR_71': 'y', 'VAR_72': 'w', 'CLASS_12': 'u8', 'FUNC_32': 'PNGU_DecodeTo4x4RGBA8', 'VAR_73': 'dstWidth', 'VAR_74': 'dstHeight', 'VAR_75': 'maxWidth', 'VAR_76': 'maxHeight', 'CLASS_13': 'PNGU_u8', 'VAR_77': 'default_alpha', 'VAR_78': 'dst', 'VAR_79': 'x2', 'VAR_80': 'y2', 'VAR_81': 'offset', 'VAR_82': 'xRatio', 'VAR_83': 'yRatio', 'VAR_84': 'pixel', 'VAR_85': 'newWidth', 'VAR_86': 'newHeight', 'VAR_87': 'ratio', 'VAR_88': 'padWidth', 'VAR_89': 'padHeight', 'VAR_90': 'len', 'FUNC_33': 'memalign', 'FUNC_34': 'DCFlushRange', 'FUNC_35': 'PNGU_SelectImageFromBuffer', 'FUNC_36': 'PNGU_SelectImageFromDevice', 'FUNC_37': 'strlen', 'FUNC_38': 'strcpy', 'FUNC_39': 'PNGU_ReleaseImageContext', 'FUNC_40': 'PNGU_GetImageProperties', 'VAR_91': 'imgprop', 'VAR_92': 'res', 'FUNC_41': 'DecodePNG', 'VAR_93': 'src', 'VAR_94': 'maxwidth', 'VAR_95': 'maxheight', 'VAR_96': 'imgProp', 'FUNC_42': 'PNGU_EncodeFromRGB', 'VAR_97': 'stride', 'FUNC_43': 'png_create_write_struct', 'FUNC_44': 'png_destroy_write_struct', 'FUNC_45': 'png_set_write_fn', 'FUNC_46': 'png_set_IHDR', 'VAR_98': 'PNG_INTERLACE_NONE', 'VAR_99': 'PNG_COMPRESSION_TYPE_DEFAULT', 'VAR_100': 'PNG_FILTER_TYPE_DEFAULT', 'FUNC_47': 'memset', 'FUNC_48': 'png_set_rows', 'FUNC_49': 'png_write_png', 'VAR_101': 'PNG_TRANSFORM_IDENTITY', 'FUNC_50': 'png_write_end', 'FUNC_51': 'PNGU_EncodeFromGXTexture', 'VAR_102': 'tmpy1', 'VAR_103': 'tmpy2', 'VAR_104': 'tmpyWid', 'VAR_105': 'tmpxy', 'VAR_106': 'ptr'} | c | Hibrido | 67.21% |
/*
* Copyright (c) 2014 NARUSE, Yui <<EMAIL>>
*
* 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.
*/
#define _GNU_SOURCE
#include <config.h>
#include <stddef.h>
#include <stdint.h>
#ifndef HAVE_EXPLICIT_BZERO
void explicit_bzero(void *p, size_t n);
#endif
#ifndef HAVE_TIMINGSAFE_BCMP
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
#endif
#ifndef HAVE_BCRYPT_PBKDF
int bcrypt_pbkdf(const char *pass, size_t passlen, const uint8_t *salt,
size_t saltlen, uint8_t *key, size_t keylen, unsigned int rounds);
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#ifndef HAVE_ARC4RANDOM
void arc4random_buf(void *buf, size_t n);
/* signify isn't multithreaded */
# define _ARC4_LOCK()
# define _ARC4_UNLOCK()
#endif
#define SHA2_SMALL
#ifndef TCSASOFT
# define TCSASOFT 0
#endif
| /*
* Copyright (c) 2014 NARUSE, Yui <<EMAIL>>
*
* 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.
*/
#define VAR_0
#include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
#ifndef VAR_1
void FUNC_0(void *VAR_2, size_t VAR_3);
#endif
#ifndef VAR_4
int FUNC_1(const void *VAR_5, const void *VAR_6, size_t VAR_3);
#endif
#ifndef VAR_7
int FUNC_2(const char *VAR_8, size_t VAR_9, const uint8_t *salt,
size_t VAR_10, uint8_t *VAR_11, size_t VAR_12, unsigned int VAR_13);
#endif
#ifndef VAR_14
size_t FUNC_3(char *VAR_15, const char *src, size_t VAR_16);
#endif
#ifndef VAR_17
void FUNC_4(void *VAR_18, size_t VAR_3);
/* signify isn't multithreaded */
# define FUNC_5()
# define FUNC_6()
#endif
#define VAR_19
#ifndef VAR_20
# define VAR_20 0
#endif
| 0.936332 | {'VAR_0': '_GNU_SOURCE', 'IMPORT_0': 'config.h', 'IMPORT_1': 'stddef.h', 'IMPORT_2': 'stdint.h', 'VAR_1': 'HAVE_EXPLICIT_BZERO', 'FUNC_0': 'explicit_bzero', 'VAR_2': 'p', 'VAR_3': 'n', 'VAR_4': 'HAVE_TIMINGSAFE_BCMP', 'FUNC_1': 'timingsafe_bcmp', 'VAR_5': 'b1', 'VAR_6': 'b2', 'VAR_7': 'HAVE_BCRYPT_PBKDF', 'FUNC_2': 'bcrypt_pbkdf', 'VAR_8': 'pass', 'VAR_9': 'passlen', 'VAR_10': 'saltlen', 'VAR_11': 'key', 'VAR_12': 'keylen', 'VAR_13': 'rounds', 'VAR_14': 'HAVE_STRLCPY', 'FUNC_3': 'strlcpy', 'VAR_15': 'dst', 'VAR_16': 'siz', 'VAR_17': 'HAVE_ARC4RANDOM', 'FUNC_4': 'arc4random_buf', 'VAR_18': 'buf', 'FUNC_5': '_ARC4_LOCK', 'FUNC_6': '_ARC4_UNLOCK', 'VAR_19': 'SHA2_SMALL', 'VAR_20': 'TCSASOFT'} | c | Procedural | 100.00% |
/*
* Copyright 2018 Google LLC
*
* 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 VR180_CPP_SENSOR_FUSION_ONLINE_SENSOR_FUSION_H_
#define VR180_CPP_SENSOR_FUSION_ONLINE_SENSOR_FUSION_H_
#include <memory>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "cpp/sensor_fusion/orientation_filter.h"
namespace vr180 {
// Class for fusing gyroscope and accelerometer readings to produce orientation
// for a device with IMU.
//
// Example usage:
//
// * Construct the filter
// OnlineSensorFusion::Options options;
// LoadPersistentImuOrientation(persistent_calibration_result_path,
// options.device_to_imu_transform);
// OnlineSensorFusion filter(options);
//
// * Function for streaming processing of events in timestamp order:
// void OnSensorEventAvailable(filter, event) {
// if (event.type == accel) {
// filter.AddAccelMeasurement(event.sample, event.timestamp_s);
// } else if (event.type == gyro) {
// filter.AddGyroMeasurement(event.sample, event.timestamp_s);
// SaveCammMetadata(event.timestamp_s, filter.GetOrientation());
// }
// }
//
// * Other recommended logic:
// - Right before each video capture, call filter.Recenter() so video starts
// with the same heading.
// - Use uncalibrated gyro data, and call filter.SetGyroBias right before
// each video capture to update the bias once.
class OnlineSensorFusion {
public:
struct Options {
// Controls the bias estimation feedback. A high value decreases the time to
// adopt to gyroscope bias but can result in a tilting horizon.
// See OrientationFilter::OrientationFilterConfiguration for details.
double gyroscope_bias_correction_gain = 0.1;
// Control the yaw correction feedback for the accelerometer.
// See OrientationFilter::OrientationFilterConfiguration for details.
double accel_yaw_correction_gain = 1.0;
// Control the stationary bias correcion feedback.
// See OrientationFilter::OrientationFilterConfiguration for details.
double stationary_bias_correction_gain = 0.1;
// Rotation between device orientation and imu orientation, which
// should be calibrated in a factory or approximated according to CAD
// design.
//
// Typically this is close to 0 or 90 degree rotation around Z-axis.
Eigen::Matrix3d device_to_imu_transform = Eigen::Matrix3d::Identity();
};
// Constructs a filter with specified fusion options.
explicit OnlineSensorFusion(const Options& options);
// Adds a gyroscope measurement, timesamps should be monotonically increasing.
//
// @param sample the rotation around each axis, in rad/s
// @param timestamp_s the measurement timestamp, in seconds
void AddGyroMeasurement(const Eigen::Vector3d& sample, double timestamp_s);
// Adds an accelerometer measurement, timestamps should be monotonically
// increasing.
//
// @param sample the acceleration along each axis, in m/s^2
// @param timestamp_s the measurement timestamp, in seconds
void AddAccelMeasurement(const Eigen::Vector3d& sample, double timestamp_s);
// Returns the sensor-fused orientation of the device in global coordinates as
// an angle axis; this is the result of applying a gravity transform and
// sensor-fused orientation to the device_to_imu_transform.
Eigen::Vector3f GetOrientation() const;
// Sets the gyro bias to use within the orientation filter. This could be used
// before a continuous data capture, but should not be used during the
// capture.
void SetGyroBias(const Eigen::Vector3d& bias);
// Resets the yaw of the orientation filter.
void Recenter();
private:
std::unique_ptr<OrientationFilter> orientation_filter_;
Eigen::Matrix3d calibrated_imu_orientation_;
double last_timestamp_s_;
};
} // namespace vr180
#endif // VR180_CPP_SENSOR_FUSION_ONLINE_SENSOR_FUSION_H_
| /*
* Copyright 2018 Google LLC
*
* 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 VAR_0
#define VAR_0
#include <memory>
#include <IMPORT_0>
#include <IMPORT_1>
#include "IMPORT_2"
CLASS_0 VAR_1 {
// Class for fusing gyroscope and accelerometer readings to produce orientation
// for a device with IMU.
//
// Example usage:
//
// * Construct the filter
// OnlineSensorFusion::Options options;
// LoadPersistentImuOrientation(persistent_calibration_result_path,
// options.device_to_imu_transform);
// OnlineSensorFusion filter(options);
//
// * Function for streaming processing of events in timestamp order:
// void OnSensorEventAvailable(filter, event) {
// if (event.type == accel) {
// filter.AddAccelMeasurement(event.sample, event.timestamp_s);
// } else if (event.type == gyro) {
// filter.AddGyroMeasurement(event.sample, event.timestamp_s);
// SaveCammMetadata(event.timestamp_s, filter.GetOrientation());
// }
// }
//
// * Other recommended logic:
// - Right before each video capture, call filter.Recenter() so video starts
// with the same heading.
// - Use uncalibrated gyro data, and call filter.SetGyroBias right before
// each video capture to update the bias once.
CLASS_1 VAR_2 {
public:
VAR_3 VAR_4 {
// Controls the bias estimation feedback. A high value decreases the time to
// adopt to gyroscope bias but can result in a tilting horizon.
// See OrientationFilter::OrientationFilterConfiguration for details.
double VAR_5 = 0.1;
// Control the yaw correction feedback for the accelerometer.
// See OrientationFilter::OrientationFilterConfiguration for details.
double VAR_6 = 1.0;
// Control the stationary bias correcion feedback.
// See OrientationFilter::OrientationFilterConfiguration for details.
double VAR_7 = 0.1;
// Rotation between device orientation and imu orientation, which
// should be calibrated in a factory or approximated according to CAD
// design.
//
// Typically this is close to 0 or 90 degree rotation around Z-axis.
Eigen::VAR_9 VAR_10 = VAR_8::Matrix3d::FUNC_1();
};
// Constructs a filter with specified fusion options.
CLASS_4 FUNC_0(const CLASS_2& VAR_11);
// Adds a gyroscope measurement, timesamps should be monotonically increasing.
//
// @param sample the rotation around each axis, in rad/s
// @param timestamp_s the measurement timestamp, in seconds
void FUNC_2(const CLASS_3::VAR_12& VAR_13, double VAR_14);
// Adds an accelerometer measurement, timestamps should be monotonically
// increasing.
//
// @param sample the acceleration along each axis, in m/s^2
// @param timestamp_s the measurement timestamp, in seconds
void FUNC_3(const CLASS_3::VAR_12& VAR_13, double VAR_14);
// Returns the sensor-fused orientation of the device in global coordinates as
// an angle axis; this is the result of applying a gravity transform and
// sensor-fused orientation to the device_to_imu_transform.
Eigen::VAR_15 FUNC_4() const;
// Sets the gyro bias to use within the orientation filter. This could be used
// before a continuous data capture, but should not be used during the
// capture.
void FUNC_5(const CLASS_3::VAR_12& VAR_16);
// Resets the yaw of the orientation filter.
void FUNC_6();
private:
std::VAR_17<VAR_18> VAR_19;
Eigen::VAR_9 VAR_20;
double VAR_21;
};
} // namespace vr180
#endif // VR180_CPP_SENSOR_FUSION_ONLINE_SENSOR_FUSION_H_
| 0.888351 | {'VAR_0': 'VR180_CPP_SENSOR_FUSION_ONLINE_SENSOR_FUSION_H_', 'IMPORT_0': 'Eigen/Core', 'IMPORT_1': 'Eigen/Geometry', 'IMPORT_2': 'cpp/sensor_fusion/orientation_filter.h', 'CLASS_0': 'namespace', 'VAR_1': 'vr180', 'CLASS_1': 'class', 'VAR_2': 'OnlineSensorFusion', 'FUNC_0': 'OnlineSensorFusion', 'VAR_3': 'struct', 'VAR_4': 'Options', 'CLASS_2': 'Options', 'VAR_5': 'gyroscope_bias_correction_gain', 'VAR_6': 'accel_yaw_correction_gain', 'VAR_7': 'stationary_bias_correction_gain', 'VAR_8': 'Eigen', 'CLASS_3': 'Eigen', 'VAR_9': 'Matrix3d', 'VAR_10': 'device_to_imu_transform', 'FUNC_1': 'Identity', 'CLASS_4': 'explicit', 'VAR_11': 'options', 'FUNC_2': 'AddGyroMeasurement', 'VAR_12': 'Vector3d', 'VAR_13': 'sample', 'VAR_14': 'timestamp_s', 'FUNC_3': 'AddAccelMeasurement', 'VAR_15': 'Vector3f', 'FUNC_4': 'GetOrientation', 'FUNC_5': 'SetGyroBias', 'VAR_16': 'bias', 'FUNC_6': 'Recenter', 'VAR_17': 'unique_ptr', 'VAR_18': 'OrientationFilter', 'VAR_19': 'orientation_filter_', 'VAR_20': 'calibrated_imu_orientation_', 'VAR_21': 'last_timestamp_s_'} | c | Procedural | 19.19% |
//
// Created by <NAME> on 05/04/2022.
//
#ifndef UNBOUNDED_INT_DICTIONARY_H
#define UNBOUNDED_INT_DICTIONARY_H
typedef struct dictionary *dictionary;
extern dictionary create_dictionary(void);
extern void destroy_dictionary(dictionary dictionary);
extern void insert_into_dictionary(dictionary dictionary, const char *key, unbounded_int value);
extern unbounded_int *search_in_dictionary(dictionary dictionary, const char *key);
extern void delete_from_dictionary(dictionary dictionary, const char *key);
#endif //UNBOUNDED_INT_DICTIONARY_H
| //
// Created by <NAME> on 05/04/2022.
//
#ifndef VAR_0
#define VAR_0
typedef struct CLASS_0 *CLASS_0;
extern CLASS_0 create_dictionary(void);
extern void destroy_dictionary(CLASS_0 VAR_1);
extern void FUNC_0(CLASS_0 VAR_1, const char *VAR_2, unbounded_int VAR_3);
extern unbounded_int *FUNC_1(CLASS_0 VAR_1, const char *VAR_2);
extern void delete_from_dictionary(CLASS_0 VAR_1, const char *VAR_2);
#endif //UNBOUNDED_INT_DICTIONARY_H
| 0.633459 | {'VAR_0': 'UNBOUNDED_INT_DICTIONARY_H', 'CLASS_0': 'dictionary', 'VAR_1': 'dictionary', 'FUNC_0': 'insert_into_dictionary', 'VAR_2': 'key', 'VAR_3': 'value', 'FUNC_1': 'search_in_dictionary'} | c | Hibrido | 100.00% |
/*
* Copyright (c) 2016 HGST, a Western Digital Company.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/
#include <rdma/ib_verbs.h>
#include <rdma/mr_pool.h>
struct ib_mr *ib_mr_pool_get(struct ib_qp *qp, struct list_head *list)
{
struct ib_mr *mr;
unsigned long flags;
spin_lock_irqsave(&qp->mr_lock, flags);
mr = list_first_entry_or_null(list, struct ib_mr, qp_entry);
if (mr) {
list_del(&mr->qp_entry);
qp->mrs_used++;
}
spin_unlock_irqrestore(&qp->mr_lock, flags);
return mr;
}
EXPORT_SYMBOL(ib_mr_pool_get);
void ib_mr_pool_put(struct ib_qp *qp, struct list_head *list, struct ib_mr *mr)
{
unsigned long flags;
spin_lock_irqsave(&qp->mr_lock, flags);
list_add(&mr->qp_entry, list);
qp->mrs_used--;
spin_unlock_irqrestore(&qp->mr_lock, flags);
}
EXPORT_SYMBOL(ib_mr_pool_put);
int ib_mr_pool_init(struct ib_qp *qp, struct list_head *list, int nr,
enum ib_mr_type type, u32 max_num_sg)
{
struct ib_mr *mr;
unsigned long flags;
int ret, i;
for (i = 0; i < nr; i++) {
mr = ib_alloc_mr(qp->pd, type, max_num_sg);
if (IS_ERR(mr)) {
ret = PTR_ERR(mr);
goto out;
}
spin_lock_irqsave(&qp->mr_lock, flags);
list_add_tail(&mr->qp_entry, list);
spin_unlock_irqrestore(&qp->mr_lock, flags);
}
return 0;
out:
ib_mr_pool_destroy(qp, list);
return ret;
}
EXPORT_SYMBOL(ib_mr_pool_init);
void ib_mr_pool_destroy(struct ib_qp *qp, struct list_head *list)
{
struct ib_mr *mr;
unsigned long flags;
spin_lock_irqsave(&qp->mr_lock, flags);
while (!list_empty(list)) {
mr = list_first_entry(list, struct ib_mr, qp_entry);
list_del(&mr->qp_entry);
spin_unlock_irqrestore(&qp->mr_lock, flags);
ib_dereg_mr(mr);
spin_lock_irqsave(&qp->mr_lock, flags);
}
spin_unlock_irqrestore(&qp->mr_lock, flags);
}
EXPORT_SYMBOL(ib_mr_pool_destroy);
| /*
* Copyright (c) 2016 HGST, a Western Digital Company.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/
#include <IMPORT_0>
#include <rdma/mr_pool.h>
struct ib_mr *FUNC_0(struct CLASS_0 *VAR_1, struct list_head *VAR_2)
{
struct ib_mr *mr;
unsigned long VAR_3;
spin_lock_irqsave(&VAR_1->mr_lock, VAR_3);
mr = FUNC_1(VAR_2, struct ib_mr, VAR_4);
if (mr) {
FUNC_2(&mr->VAR_4);
VAR_1->mrs_used++;
}
spin_unlock_irqrestore(&VAR_1->mr_lock, VAR_3);
return mr;
}
EXPORT_SYMBOL(VAR_0);
void FUNC_3(struct CLASS_0 *VAR_1, struct list_head *VAR_2, struct ib_mr *mr)
{
unsigned long VAR_3;
spin_lock_irqsave(&VAR_1->mr_lock, VAR_3);
FUNC_4(&mr->VAR_4, VAR_2);
VAR_1->mrs_used--;
spin_unlock_irqrestore(&VAR_1->mr_lock, VAR_3);
}
EXPORT_SYMBOL(VAR_5);
int ib_mr_pool_init(struct CLASS_0 *VAR_1, struct list_head *VAR_2, int nr,
enum CLASS_1 VAR_6, CLASS_2 max_num_sg)
{
struct ib_mr *mr;
unsigned long VAR_3;
int VAR_7, VAR_8;
for (VAR_8 = 0; VAR_8 < nr; VAR_8++) {
mr = ib_alloc_mr(VAR_1->VAR_9, VAR_6, max_num_sg);
if (IS_ERR(mr)) {
VAR_7 = PTR_ERR(mr);
goto out;
}
spin_lock_irqsave(&VAR_1->mr_lock, VAR_3);
list_add_tail(&mr->VAR_4, VAR_2);
spin_unlock_irqrestore(&VAR_1->mr_lock, VAR_3);
}
return 0;
out:
FUNC_5(VAR_1, VAR_2);
return VAR_7;
}
EXPORT_SYMBOL(ib_mr_pool_init);
void FUNC_5(struct CLASS_0 *VAR_1, struct list_head *VAR_2)
{
struct ib_mr *mr;
unsigned long VAR_3;
spin_lock_irqsave(&VAR_1->mr_lock, VAR_3);
while (!list_empty(VAR_2)) {
mr = FUNC_6(VAR_2, struct ib_mr, VAR_4);
FUNC_2(&mr->VAR_4);
spin_unlock_irqrestore(&VAR_1->mr_lock, VAR_3);
ib_dereg_mr(mr);
spin_lock_irqsave(&VAR_1->mr_lock, VAR_3);
}
spin_unlock_irqrestore(&VAR_1->mr_lock, VAR_3);
}
EXPORT_SYMBOL(VAR_10);
| 0.460488 | {'IMPORT_0': 'rdma/ib_verbs.h', 'FUNC_0': 'ib_mr_pool_get', 'VAR_0': 'ib_mr_pool_get', 'CLASS_0': 'ib_qp', 'VAR_1': 'qp', 'VAR_2': 'list', 'VAR_3': 'flags', 'FUNC_1': 'list_first_entry_or_null', 'VAR_4': 'qp_entry', 'FUNC_2': 'list_del', 'FUNC_3': 'ib_mr_pool_put', 'VAR_5': 'ib_mr_pool_put', 'FUNC_4': 'list_add', 'CLASS_1': 'ib_mr_type', 'VAR_6': 'type', 'CLASS_2': 'u32', 'VAR_7': 'ret', 'VAR_8': 'i', 'VAR_9': 'pd', 'FUNC_5': 'ib_mr_pool_destroy', 'VAR_10': 'ib_mr_pool_destroy', 'FUNC_6': 'list_first_entry'} | c | Hibrido | 26.00% |
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMPOSITE_PARSER_H_
#define COMPOSITE_PARSER_H_
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include "composite/util.h"
namespace akg {
std::tuple<std::string, std::string, picojson::array, picojson::array, picojson::array> ParseInputJson(
const picojson::value &input_json);
void ParseInputTensors(const picojson::array &input_descs, std::vector<std::string> &input_tensors);
void ParseOutputTensors(const picojson::array &output_descs, std::vector<std::string> &output_tensors);
std::vector<OpDesc> ParseOpDesc(const std::string &json_str);
std::string ParseKernelName(const std::string &json_str);
Stmt MakeStmt(const std::vector<OpDesc> &op_descs);
Stmt Parse(const picojson::value &input_json, BuildInfo &info);
class OpDescsParser {
public:
OpDescsParser(picojson::array op_descs_json, const std::vector<std::string> &input_tensors,
const std::vector<std::string> &output_tensors)
: op_descs_json_(std::move(op_descs_json)), input_tensors_(input_tensors), output_tensors_(output_tensors) {}
~OpDescsParser() = default;
void Parse() {
for (const auto &item : op_descs_json_) {
CHECK(item.is<picojson::object>());
const picojson::object &op_desc = item.get<picojson::object>();
ParseOpDesc(op_desc);
}
}
void Dump() {
LOG(INFO) << "========OP_DESCS========";
for (const auto &item : op_descs_) {
LOG(INFO) << "op_name: " << item.op_name;
for (const auto &attr : item.attrs) {
LOG(INFO) << "attrs: " << attr.first << ":" << attr.second;
}
for (const auto &input : item.input_descs) {
LOG(INFO) << "input: " << input;
}
for (const auto &output : item.output_descs) {
LOG(INFO) << "output: " << output;
}
for (const auto &input_info : item.input_tensor_info) {
LOG(INFO) << "input_info: ";
LOG(INFO) << input_info.name_;
LOG(INFO) << input_info.shape_;
}
for (const auto &output_info : item.output_tensor_info) {
LOG(INFO) << "output_info: ";
LOG(INFO) << output_info.name_;
LOG(INFO) << output_info.shape_;
}
}
}
public:
std::vector<OpDesc> op_descs_;
FuncRefList input_funcs_;
FuncRefList output_funcs_;
private:
const picojson::array op_descs_json_;
const std::vector<std::string> input_tensors_;
const std::vector<std::string> output_tensors_;
std::unordered_map<std::string, Tensor> tensor_map_;
private:
static void ParseTensorValue(const picojson::value &tensor_value, const std::string &tensor_name,
const Array<Expr> &shape, const Type &type, Array<NodeRef> &input_output) {
CHECK_EQ(shape.size(), 1) << "We should not make a expr for a not const tensor.";
CHECK(Equal(shape[0], Expr(1))) << "We should not make a expr for a not const tensor.";
CHECK(!tensor_value.is<picojson::null>()) << "We should has default value of tensor(expr): " << tensor_name;
if (tensor_value.is<double>()) {
input_output.push_back(make_const(type, tensor_value.get<double>()));
} else if (tensor_value.is<int64_t>()) {
input_output.push_back(make_const(type, tensor_value.get<int64_t>()));
} else {
CHECK(0) << "Unknown value type of tensor: " << tensor_name;
}
}
void MakeTensors(const std::vector<TensorInfo> &tensor_info, Array<NodeRef> &tensors) {
for (const auto &info : tensor_info) {
if (info.has_value_) {
// In case when current tensor already has value information
ParseTensorValue(info.value_, info.name_, info.shape_, info.dtype_, tensors);
continue;
}
if (tensor_map_.count(info.name_) == 0) {
Tensor t = placeholder(info.shape_, info.dtype_, info.name_);
tensor_map_[info.name_] = t;
if (std::find(input_tensors_.begin(), input_tensors_.end(), info.name_) != input_tensors_.end()) {
input_funcs_.emplace_back(t->op);
}
if (std::find(output_tensors_.begin(), output_tensors_.end(), info.name_) != output_tensors_.end()) {
output_funcs_.emplace_back(t->op);
}
}
tensors.push_back(tensor_map_[info.name_]);
}
}
void ParseTensorInfo(const picojson::object &tensor_desc, std::vector<TensorInfo> &tensor_info) {
TensorInfo info;
for (const auto &item : tensor_desc) {
if (item.first == "tensor_name") {
CHECK(item.second.is<std::string>());
info.name_ = item.second.get<std::string>();
} else if (item.first == "format") {
CHECK(item.second.is<std::string>());
info.format_ = item.second.get<std::string>();
} else if (item.first == "shape") {
CHECK(item.second.is<picojson::array>());
const picojson::array &dims = item.second.get<picojson::array>();
for (const auto &dim : dims) {
CHECK(dim.is<int64_t>());
info.shape_.push_back(Expr(static_cast<int>(dim.get<int64_t>())));
}
} else if (item.first == "data_type") {
CHECK(item.second.is<std::string>());
std::string dtype_str = item.second.get<std::string>();
if (type_mapping.find(dtype_str) == type_mapping.end()) {
LOG(FATAL) << "Not support dtype str " << dtype_str;
}
info.dtype_ = type_mapping[dtype_str];
} else if (item.first == "value" && !item.second.is<picojson::null>()) {
info.has_value_ = true;
info.value_ = item.second;
}
}
tensor_info.emplace_back(info);
}
void ParseTensorFormat(const std::vector<TensorInfo> &tensor_info, Map<std::string, NodeRef> &attrs) {
for (const auto &info : tensor_info) {
if (!info.format_.empty()) {
auto key = CreateDataFormatKey(info.name_);
auto format = StringImm::make(info.format_);
if (attrs.find(key) != attrs.end()) {
LOG(WARNING) << key << " already exists in attrs";
}
attrs.Set(key, format);
}
}
}
void ParseInputTensors(const picojson::array &tensor_descs, OpDesc &op_desc_info) {
std::vector<TensorInfo> tensor_info;
for (const auto &tensor_desc_l0 : tensor_descs) {
CHECK(tensor_desc_l0.is<picojson::array>());
const picojson::array &tensor_desc_l1 = tensor_desc_l0.get<picojson::array>();
for (const auto &tensor_desc : tensor_desc_l1) {
CHECK(tensor_desc.is<picojson::object>());
const picojson::object &tensor_desc_info = tensor_desc.get<picojson::object>();
ParseTensorInfo(tensor_desc_info, tensor_info);
}
}
// Gather data format information of input tensors
ParseTensorFormat(tensor_info, op_desc_info.attrs);
op_desc_info.input_tensor_info = tensor_info;
MakeTensors(tensor_info, op_desc_info.input_descs);
}
void ParseOutputTensors(const picojson::array &tensor_descs, OpDesc &op_desc_info) {
std::vector<TensorInfo> tensor_info;
for (const auto &tensor_desc : tensor_descs) {
CHECK(tensor_desc.is<picojson::object>());
const picojson::object &tensor_desc_info = tensor_desc.get<picojson::object>();
ParseTensorInfo(tensor_desc_info, tensor_info);
}
// Gather data format information of output tensors
ParseTensorFormat(tensor_info, op_desc_info.attrs);
op_desc_info.output_tensor_info = tensor_info;
MakeTensors(tensor_info, op_desc_info.output_descs);
}
void ParseOpDesc(const picojson::object &op_desc) {
OpDesc op_desc_info;
auto it = op_desc.find("name");
if (it != op_desc.end()) {
op_desc_info.op_name = it->second.get<std::string>();
}
it = op_desc.find("attr");
if (it != op_desc.end() && it->second.is<picojson::array>()) {
const picojson::array &attrs = it->second.get<picojson::array>();
ParseAttrs(attrs, &op_desc_info.attrs);
}
it = op_desc.find("input_desc");
if (it != op_desc.end() && it->second.is<picojson::array>()) {
const picojson::array &input_descs = it->second.get<picojson::array>();
ParseInputTensors(input_descs, op_desc_info);
}
it = op_desc.find("output_desc");
if (it != op_desc.end() && it->second.is<picojson::array>()) {
const picojson::array &output_descs = it->second.get<picojson::array>();
ParseOutputTensors(output_descs, op_desc_info);
}
// In some scenarios, for example, FRACTAL_NZ is transfered to DefaultFormat,
// for the TransData operator to execute, output_shape(original_shape) information is necessary.
if (op_desc_info.op_name == "TransData") {
CHECK_EQ(op_desc_info.output_tensor_info.size(), 1);
auto output_shape = op_desc_info.output_tensor_info[0].shape_;
op_desc_info.attrs.Set("output_shape", output_shape);
}
op_descs_.emplace_back(op_desc_info);
}
static void ParseAttrs(const picojson::array &arr, Map<std::string, NodeRef> *op_attrs) {
CHECK(op_attrs) << "input op_attrs is invalid.";
for (const auto &item : arr) {
CHECK(item.is<picojson::object>());
const picojson::object &obj = item.get<picojson::object>();
std::string name;
NodeRef value;
bool name_found = false;
bool value_found = false;
for (const auto &kv : obj) {
// parse attr name
if (kv.first == "name") {
name = kv.second.get<std::string>();
name_found = true;
continue;
}
if (kv.first != "value") {
continue;
}
// parse attr value
value_found = true;
if (kv.second.is<picojson::array>()) {
Array<NodeRef> arr_v;
const picojson::array &arr_s = kv.second.get<picojson::array>();
for (const auto &v : arr_s) {
if (v.is<int64_t>()) {
arr_v.push_back(Integer(static_cast<int>(v.get<int64_t>())));
} else if (v.is<std::string>()) {
arr_v.push_back(StringImm::make(v.get<std::string>()));
} else {
LOG(FATAL) << "Not parsed type in array attr.";
}
}
value = arr_v;
} else if (kv.second.is<bool>()) {
value = make_const(Int(1), kv.second.get<bool>());
} else if (kv.second.is<int64_t>()) {
value = Integer(static_cast<int>(kv.second.get<int64_t>()));
} else if (kv.second.is<std::string>()) {
value = StringImm::make(kv.second.get<std::string>());
} else {
LOG(FATAL) << "Not parsed type in op_attrs.";
}
}
CHECK(name_found);
CHECK(value_found);
op_attrs->Set(name, value);
}
}
};
} // namespace akg
#endif // COMPOSITE_PARSER_H_
| /**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VAR_0
#define VAR_0
#include <string>
#include <tuple>
#include <IMPORT_0>
#include <IMPORT_1>
#include <vector>
#include "IMPORT_2"
namespace VAR_1 {
std::tuple<VAR_2::string, VAR_2::string, VAR_3::VAR_4, VAR_3::VAR_4, VAR_3::VAR_4> ParseInputJson(
VAR_5 VAR_3::VAR_6 &input_json);
void FUNC_0(const CLASS_1::VAR_4 &input_descs, CLASS_0::vector<VAR_2::string> &VAR_7);
void FUNC_1(const CLASS_1::VAR_4 &VAR_8, CLASS_0::vector<VAR_2::string> &output_tensors);
std::vector<VAR_9> FUNC_2(VAR_5 VAR_2::string &json_str);
std::string ParseKernelName(VAR_5 VAR_2::string &json_str);
Stmt MakeStmt(const CLASS_0::vector<VAR_9> &op_descs);
Stmt Parse(const CLASS_1::VAR_6 &input_json, CLASS_3 &VAR_10);
class VAR_11 {
public:
FUNC_3(VAR_3::VAR_4 VAR_12, VAR_5 VAR_2::vector<VAR_2::string> &VAR_7,
VAR_5 VAR_2::vector<VAR_2::string> &output_tensors)
: VAR_13(VAR_2::FUNC_4(VAR_12)), FUNC_5(VAR_7), FUNC_6(output_tensors) {}
~FUNC_3() = default;
void Parse() {
for (const auto &item : VAR_13) {
FUNC_7(item.VAR_16<VAR_3::VAR_17>());
VAR_5 VAR_3::VAR_17 &op_desc = item.VAR_18<VAR_3::VAR_17>(VAR_19);
FUNC_2(op_desc);
}
}
void FUNC_8() {
LOG(VAR_20) << "========OP_DESCS========";
for (VAR_5 VAR_21 &item : VAR_22) {
LOG(VAR_20) << "op_name: " << item.VAR_23;
for (VAR_5 VAR_21 &VAR_24 : item.VAR_25) {
LOG(VAR_20) << "attrs: " << VAR_24.VAR_26 << ":" << VAR_24.second;
}
for (VAR_5 VAR_21 &VAR_27 : item.input_descs) {
LOG(VAR_20) << "input: " << VAR_27;
}
for (VAR_5 VAR_21 &VAR_28 : item.VAR_8) {
LOG(VAR_20) << "output: " << VAR_28;
}
for (VAR_5 VAR_21 &VAR_29 : item.VAR_30) {
LOG(VAR_20) << "input_info: ";
LOG(VAR_20) << VAR_29.VAR_31;
LOG(VAR_20) << VAR_29.shape_;
}
for (VAR_5 VAR_21 &VAR_32 : item.VAR_33) {
LOG(VAR_20) << "output_info: ";
LOG(VAR_20) << VAR_32.VAR_31;
LOG(VAR_20) << VAR_32.shape_;
}
}
}
public:
VAR_2::vector<VAR_9> VAR_22;
VAR_34 input_funcs_;
VAR_34 VAR_35;
VAR_36:
const VAR_3::VAR_4 VAR_13;
const VAR_2::vector<VAR_2::string> VAR_14;
const VAR_2::vector<VAR_2::string> VAR_15;
VAR_2::IMPORT_0<VAR_2::string, Tensor> tensor_map_;
VAR_36:
static void VAR_37(const VAR_3::VAR_6 &tensor_value, const VAR_2::string &VAR_38,
const VAR_39<VAR_40> &VAR_41, const Type &VAR_42, VAR_39<VAR_43> &VAR_44) {
CHECK_EQ(VAR_41.FUNC_11(), 1) << "We should not make a expr for a not const tensor.";
FUNC_7(Equal(VAR_41[0], FUNC_10(1))) << "We should not make a expr for a not const tensor.";
FUNC_7(!tensor_value.VAR_16<VAR_3::VAR_45>()) << "We should has default value of tensor(expr): " << VAR_38;
if (tensor_value.VAR_16<VAR_46>(VAR_19)) {
VAR_44.FUNC_12(FUNC_13(VAR_42, tensor_value.VAR_18<VAR_46>(VAR_19)));
} else if (tensor_value.VAR_16<int64_t>(VAR_19)) {
VAR_44.FUNC_12(FUNC_13(VAR_42, tensor_value.VAR_18<int64_t>(VAR_19)));
} else {
FUNC_7(0) << "Unknown value type of tensor: " << VAR_38;
}
}
void FUNC_14(const CLASS_0::vector<VAR_47> &tensor_info, CLASS_5<VAR_43> &VAR_48) {
for (const auto &CLASS_4 : tensor_info) {
if (CLASS_4.VAR_49) {
// In case when current tensor already has value information
FUNC_9(CLASS_4.VAR_50, CLASS_4.VAR_31, CLASS_4.shape_, CLASS_4.VAR_51, CLASS_7);
continue;
}
if (tensor_map_.FUNC_16(VAR_10.VAR_31) == 0) {
Tensor VAR_52 = placeholder(VAR_10.shape_, VAR_10.VAR_51, VAR_10.VAR_31);
tensor_map_[VAR_10.VAR_31] = VAR_52;
if (VAR_2::FUNC_17(VAR_14.begin(), VAR_14.FUNC_18(), VAR_10.VAR_31) != VAR_14.FUNC_18()) {
input_funcs_.FUNC_19(VAR_52->VAR_53);
}
if (VAR_2::FUNC_17(VAR_15.begin(), VAR_15.FUNC_18(), VAR_10.VAR_31) != VAR_15.FUNC_18()) {
VAR_35.FUNC_19(VAR_52->VAR_53);
}
}
VAR_48.FUNC_12(tensor_map_[VAR_10.VAR_31]);
}
}
void FUNC_20(VAR_5 VAR_3::VAR_17 &VAR_54, VAR_2::vector<VAR_47> &tensor_info) {
FUNC_15 VAR_10;
for (VAR_5 VAR_21 &item : VAR_54) {
if (item.VAR_26 == "tensor_name") {
FUNC_7(item.second.VAR_16<VAR_2::string>());
VAR_10.VAR_31 = item.second.VAR_18<VAR_2::string>();
} CLASS_9 FUNC_21 (item.VAR_26 == "VAR_55") {
FUNC_7(item.second.VAR_16<VAR_2::string>());
VAR_10.format_ = item.second.VAR_18<VAR_2::string>();
} CLASS_9 FUNC_21 (item.VAR_26 == "VAR_41") {
FUNC_7(item.second.VAR_16<VAR_3::VAR_4>());
const CLASS_1::VAR_4 &dims = item.second.VAR_18<VAR_3::VAR_4>();
for (const auto &CLASS_10 : dims) {
FUNC_7(CLASS_10.VAR_16<int64_t>());
VAR_10.shape_.FUNC_12(FUNC_10(static_cast<int>(VAR_56.VAR_18<int64_t>(VAR_19))));
}
} else if (item.VAR_26 == "data_type") {
FUNC_7(item.second.VAR_16<VAR_2::string>());
std::string VAR_57 = item.second.VAR_18<VAR_2::string>(VAR_19);
if (type_mapping.FUNC_17(VAR_57) == type_mapping.FUNC_18()) {
LOG(VAR_58) << "Not support dtype str " << VAR_57;
}
VAR_10.VAR_51 = type_mapping[VAR_57];
} CLASS_9 FUNC_21 (item.VAR_26 == "VAR_6" && !item.second.VAR_16<VAR_3::VAR_45>()) {
VAR_10.VAR_49 = true;
VAR_10.VAR_50 = item.second;
}
}
tensor_info.FUNC_19(VAR_10);
}
void FUNC_22(const CLASS_0::vector<VAR_47> &tensor_info, Map<VAR_2::string, CLASS_6> &VAR_25) {
for (const auto &CLASS_4 : tensor_info) {
if (!CLASS_4.format_.FUNC_23()) {
auto key = FUNC_24(VAR_10.VAR_31);
VAR_21 VAR_55 = VAR_59::FUNC_25(VAR_10.format_);
FUNC_21 (VAR_25.FUNC_17(key) != VAR_25.FUNC_18()) {
LOG(VAR_60) << key << " already exists in attrs";
}
VAR_25.Set(key, VAR_55);
}
}
}
void FUNC_0(VAR_5 VAR_3::VAR_4 &VAR_61, VAR_9 &VAR_62) {
VAR_2::vector<VAR_47> tensor_info;
for (VAR_5 VAR_21 &tensor_desc_l0 : VAR_61) {
FUNC_7(tensor_desc_l0.VAR_16<VAR_3::VAR_4>());
const CLASS_1::VAR_4 &tensor_desc_l1 = tensor_desc_l0.VAR_18<VAR_3::VAR_4>();
for (const auto &CLASS_8 : tensor_desc_l1) {
FUNC_7(CLASS_8.VAR_16<VAR_3::VAR_17>());
VAR_5 VAR_3::VAR_17 &VAR_63 = VAR_54.VAR_18<VAR_3::VAR_17>(VAR_19);
FUNC_20(VAR_63, tensor_info);
}
}
// Gather data format information of input tensors
FUNC_22(tensor_info, VAR_62.VAR_25);
VAR_62.VAR_30 = tensor_info;
FUNC_14(tensor_info, VAR_62.input_descs);
}
void FUNC_1(VAR_5 VAR_3::VAR_4 &VAR_61, VAR_9 &VAR_62) {
VAR_2::vector<VAR_47> tensor_info;
for (VAR_5 VAR_21 &VAR_54 : VAR_61) {
FUNC_7(VAR_54.VAR_16<VAR_3::VAR_17>());
const CLASS_1::VAR_17 &VAR_63 = VAR_54.VAR_18<VAR_3::VAR_17>();
FUNC_20(VAR_63, tensor_info);
}
// Gather data format information of output tensors
FUNC_22(tensor_info, VAR_62.VAR_25);
VAR_62.VAR_33 = tensor_info;
FUNC_14(tensor_info, VAR_62.VAR_8);
}
void FUNC_2(const CLASS_1::VAR_17 &op_desc) {
CLASS_2 VAR_62;
auto CLASS_11VAR_19 = op_desc.FUNC_17("name");
if (VAR_64 != op_desc.FUNC_18()) {
VAR_62.VAR_23 = VAR_64->second.VAR_18<VAR_2::string>();
}
VAR_64 = op_desc.FUNC_17("attr");
if (VAR_64 != op_desc.FUNC_18() && VAR_64->second.VAR_16<VAR_3::VAR_4>()) {
const CLASS_1::VAR_4 &VAR_25 = VAR_64->second.VAR_18<VAR_3::VAR_4>();
FUNC_26(VAR_25, &VAR_62.VAR_25);
}
VAR_64 = op_desc.FUNC_17("input_desc");
if (VAR_64 != op_desc.FUNC_18() && VAR_64->second.VAR_16<VAR_3::VAR_4>()) {
const CLASS_1::VAR_4 &input_descs = VAR_64->second.VAR_18<VAR_3::VAR_4>();
FUNC_0(input_descs, VAR_62);
}
VAR_64 = op_desc.FUNC_17("output_desc");
if (VAR_64 != op_desc.FUNC_18() && VAR_64->second.VAR_16<VAR_3::VAR_4>()) {
const CLASS_1::VAR_4 &VAR_8 = VAR_64->second.VAR_18<VAR_3::VAR_4>();
FUNC_1(VAR_8, VAR_62);
}
// In some scenarios, for example, FRACTAL_NZ is transfered to DefaultFormat,
// for the TransData operator to execute, output_shape(original_shape) information is necessary.
if (VAR_62.VAR_23 == "TransData") {
CHECK_EQ(VAR_62.VAR_33.FUNC_11(), 1);
auto CLASS_12VAR_19 = VAR_62.VAR_33[0].shape_;
VAR_62.VAR_25.Set("output_shape", VAR_65);
}
VAR_22.FUNC_19(VAR_62);
}
static void FUNC_26(const CLASS_1::VAR_4 &VAR_66, Map<VAR_2::string, CLASS_6> *VAR_67) {
FUNC_7(VAR_67) << "input op_attrs is invalid.";
for (const auto &item : VAR_66) {
FUNC_7(item.VAR_16<VAR_3::VAR_17>());
VAR_5 VAR_3::VAR_17 &obj = item.VAR_18<VAR_3::VAR_17>(VAR_19);
VAR_2::string name;
VAR_43 VAR_6;
bool VAR_68 = false;
bool VAR_69 = false;
for (VAR_5 VAR_21 &VAR_70 : obj) {
// parse attr name
if (VAR_70.VAR_26 == "name") {
name = VAR_70.second.VAR_18<VAR_2::string>();
VAR_68 = true;
continue;
}
if (VAR_70.VAR_26 != "value") {
continue;
}
// parse attr value
VAR_69 = true;
if (VAR_70.second.VAR_16<VAR_3::VAR_4>()) {
VAR_39<VAR_43> VAR_71;
const CLASS_1::VAR_4 &VAR_72 = VAR_70.second.VAR_18<VAR_3::VAR_4>();
for (const auto &v : FUNC_27) {
if (v.VAR_16<int64_t>()) {
VAR_71.FUNC_12(VAR_73(static_cast<int>(v.VAR_18<int64_t>())));
} else if (v.VAR_16<VAR_2::string>()) {
VAR_71.FUNC_12(VAR_59::FUNC_25(v.VAR_18<VAR_2::string>()));
} else {
LOG(VAR_58) << "Not parsed type in array attr.";
}
}
VAR_6 = VAR_71;
} else if (VAR_70.second.VAR_16<bool>()) {
VAR_6 = FUNC_13(FUNC_29(1), VAR_70.second.VAR_18<bool>(VAR_19));
} CLASS_9 FUNC_21 (CLASS_13.second.VAR_16<int64_t>()) {
VAR_6 = FUNC_28(static_cast<int>(VAR_70.second.VAR_18<int64_t>(VAR_19)));
} CLASS_9 FUNC_21 (CLASS_13.second.VAR_16<VAR_2::string>()) {
VAR_6 = VAR_59::FUNC_25(VAR_70.second.VAR_18<VAR_2::string>());
} CLASS_9 {
LOG(VAR_58) << "Not parsed type in op_attrs.";
}
}
FUNC_7(VAR_68);
FUNC_7(VAR_69);
VAR_67->Set(name, VAR_6);
}
}
};
} // namespace akg
#endif // COMPOSITE_PARSER_H_
| 0.725512 | {'VAR_0': 'COMPOSITE_PARSER_H_', 'IMPORT_0': 'unordered_map', 'IMPORT_1': 'utility', 'IMPORT_2': 'composite/util.h', 'VAR_1': 'akg', 'VAR_2': 'std', 'CLASS_0': 'std', 'VAR_3': 'picojson', 'CLASS_1': 'picojson', 'VAR_4': 'array', 'VAR_5': 'const', 'VAR_6': 'value', 'FUNC_0': 'ParseInputTensors', 'VAR_7': 'input_tensors', 'FUNC_1': 'ParseOutputTensors', 'VAR_8': 'output_descs', 'VAR_9': 'OpDesc', 'CLASS_2': 'OpDesc', 'FUNC_2': 'ParseOpDesc', 'CLASS_3': 'BuildInfo', 'VAR_10': 'info', 'CLASS_4': 'info', 'VAR_11': 'OpDescsParser', 'FUNC_3': 'OpDescsParser', 'VAR_12': 'op_descs_json', 'VAR_13': 'op_descs_json_', 'FUNC_4': 'move', 'FUNC_5': 'input_tensors_', 'VAR_14': 'input_tensors_', 'FUNC_6': 'output_tensors_', 'VAR_15': 'output_tensors_', 'FUNC_7': 'CHECK', 'VAR_16': 'is', 'VAR_17': 'object', 'VAR_18': 'get', 'VAR_19': '', 'FUNC_8': 'Dump', 'VAR_20': 'INFO', 'VAR_21': 'auto', 'VAR_22': 'op_descs_', 'VAR_23': 'op_name', 'VAR_24': 'attr', 'VAR_25': 'attrs', 'VAR_26': 'first', 'VAR_27': 'input', 'VAR_28': 'output', 'VAR_29': 'input_info', 'VAR_30': 'input_tensor_info', 'VAR_31': 'name_', 'VAR_32': 'output_info', 'VAR_33': 'output_tensor_info', 'VAR_34': 'FuncRefList', 'VAR_35': 'output_funcs_', 'VAR_36': 'private', 'VAR_37': 'ParseTensorValue', 'FUNC_9': 'ParseTensorValue', 'VAR_38': 'tensor_name', 'VAR_39': 'Array', 'CLASS_5': 'Array', 'VAR_40': 'Expr', 'FUNC_10': 'Expr', 'VAR_41': 'shape', 'VAR_42': 'type', 'VAR_43': 'NodeRef', 'CLASS_6': 'NodeRef', 'VAR_44': 'input_output', 'FUNC_11': 'size', 'VAR_45': 'null', 'VAR_46': 'double', 'FUNC_12': 'push_back', 'FUNC_13': 'make_const', 'FUNC_14': 'MakeTensors', 'VAR_47': 'TensorInfo', 'FUNC_15': 'TensorInfo', 'VAR_48': 'tensors', 'CLASS_7': 'tensors', 'VAR_49': 'has_value_', 'VAR_50': 'value_', 'VAR_51': 'dtype_', 'FUNC_16': 'count', 'VAR_52': 't', 'FUNC_17': 'find', 'FUNC_18': 'end', 'FUNC_19': 'emplace_back', 'VAR_53': 'op', 'FUNC_20': 'ParseTensorInfo', 'VAR_54': 'tensor_desc', 'CLASS_8': 'tensor_desc', 'CLASS_9': 'else', 'FUNC_21': 'if', 'VAR_55': 'format', 'CLASS_10': 'dim', 'VAR_56': 'dim', 'VAR_57': 'dtype_str', 'VAR_58': 'FATAL', 'FUNC_22': 'ParseTensorFormat', 'FUNC_23': 'empty', 'FUNC_24': 'CreateDataFormatKey', 'VAR_59': 'StringImm', 'FUNC_25': 'make', 'VAR_60': 'WARNING', 'VAR_61': 'tensor_descs', 'VAR_62': 'op_desc_info', 'VAR_63': 'tensor_desc_info', 'CLASS_11': 'it', 'VAR_64': 'it', 'FUNC_26': 'ParseAttrs', 'CLASS_12': 'output_shape', 'VAR_65': 'output_shape', 'VAR_66': 'arr', 'VAR_67': 'op_attrs', 'VAR_68': 'name_found', 'VAR_69': 'value_found', 'VAR_70': 'kv', 'CLASS_13': 'kv', 'VAR_71': 'arr_v', 'VAR_72': 'arr_s', 'FUNC_27': 'arr_s', 'VAR_73': 'Integer', 'FUNC_28': 'Integer', 'FUNC_29': 'Int'} | c | Procedural | 6.31% |
#ifndef Kinematics_h_DEFINED
#define Kinematics_h_DEFINED
/**
* This file is strictly specific to the Nao robot.
* It contains infomation relevant to the physical configuration of the robot
* including:
* length of links
* number of chains, etc.
* It includes method definitions related to the calculation of forward and
* inverse kinematics.
* It also supports the creation of rotation and translation matrices.
* NOTE: All of the lengths are in millimeters.
*/
#include <string.h>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/lu.hpp> // for lu_factorize
#include <boost/numeric/ublas/io.hpp> // for cout
#include <math.h>
#include "NBMath.h"
#include "NBMatrixMath.h"
#include "CoordFrame.h"
namespace Kinematics {
enum ChainID {
HEAD_CHAIN = 0,
LARM_CHAIN,
LLEG_CHAIN,
RLEG_CHAIN,
RARM_CHAIN,
LANKLE_CHAIN, // only goes to the ankle
RANKLE_CHAIN // (same)
};
// Interpolation types
enum InterpolationType {
INTERPOLATION_SMOOTH = 0,
INTERPOLATION_LINEAR
};
/// Joint Name constants ///
enum JointNames {
HEAD_YAW = 0,
HEAD_PITCH,
// LARM,
L_SHOULDER_PITCH,
L_SHOULDER_ROLL,
L_ELBOW_YAW,
L_ELBOW_ROLL,
// LLEG,
L_HIP_YAW_PITCH,
L_HIP_ROLL,
L_HIP_PITCH,
L_KNEE_PITCH,
L_ANKLE_PITCH,
L_ANKLE_ROLL,
// RLEG,
R_HIP_YAW_PITCH,
R_HIP_ROLL,
R_HIP_PITCH,
R_KNEE_PITCH,
R_ANKLE_PITCH,
R_ANKLE_ROLL,
// RARM,
R_SHOULDER_PITCH,
R_SHOULDER_ROLL,
R_ELBOW_YAW,
R_ELBOW_ROLL
};
static const unsigned int FIRST_HEAD_JOINT = HEAD_YAW;
/**
* (Deprecated)
enum Motion_IntFlag {
UNINT_INTR_CMD, // Un-interruptable interrupter command
INT_INTR_CMD, // Interruptable interupter command
UNINT_CMD, // Un-interruptable command
INT_CMD // Interruptable command
};
enum SupportLeg{
BOTH_LEGS = 0,
RIGHT_LEG,
LEFT_LEG
};
**/
static const unsigned int HEAD_JOINTS = 2;
static const unsigned int ARM_JOINTS = 4;
static const unsigned int LEG_JOINTS = 6;
static const unsigned int NUM_CHAINS = 5;
static const unsigned int NUM_BODY_CHAINS = 4;
static const unsigned int NUM_JOINTS = HEAD_JOINTS + ARM_JOINTS*2 +
LEG_JOINTS*2;
static const unsigned int NUM_BODY_JOINTS = ARM_JOINTS*2 + LEG_JOINTS*2;
static const unsigned int chain_lengths[NUM_CHAINS] = {2, 4, 6, 6, 4};
static const unsigned int chain_first_joint[NUM_CHAINS] = {0,2,6,12,18};
static const unsigned int chain_last_joint[NUM_CHAINS] = {1,5,11,17,21};
static const std::string CHAIN_STRINGS[NUM_CHAINS] =
{ "Head",
"LArm",
"LLeg",
"RLeg",
"RArm" };
//Note: this joint list constains RHipYawPitch, which is not compatible
//with the DCM convention on naming joints (this joint is technially
//nonexistant)
static const std::string JOINT_STRINGS[NUM_JOINTS] =
{ "HeadYaw",
"HeadPitch",
"LShoulderPitch",
"LShoulderRoll",
"LElbowYaw",
"LElbowRoll",
"LHipYawPitch",
"LHipRoll",
"LHipPitch",
"LKneePitch",
"LAnklePitch",
"LAnkleRoll",
"RHipYawPitch",
"RHipRoll",
"RHipPitch",
"RKneePitch",
"RAnklePitch",
"RAnkleRoll",
"RShoulderPitch",
"RShoulderRoll",
"RElbowYaw",
"RElbowRoll"};
/********** Bodily dimensions ***********/
static const double SHOULDER_OFFSET_Y = 98.0;
static const double UPPER_ARM_LENGTH = 105.0;
static const double LOWER_ARM_LENGTH = 55.95;
static const double SHOULDER_OFFSET_Z = 100;
static const double THIGH_LENGTH = 100.0;
static const double TIBIA_LENGTH = 102.9;
static const double NECK_OFFSET_Z = 126.5;
static const double HIP_OFFSET_Y = 50.0;
static const double HIP_OFFSET_Z = 85.0;
static const double FOOT_HEIGHT = 45.19;
// Camera
static const double CAMERA_OFF_X = 48.80; // in millimeters
static const double CAMERA_OFF_Z = 23.81; // in millimeters
static const double CAMERA_PITCH_ANGLE = 40.0 * TO_RAD; // 40 degrees
/********** Joint Bounds ***********/
static const double HEAD_BOUNDS[2][2] = {{-2.09,2.09},{-.785,.785}};
// Order of arm joints: ShoulderPitch, SRoll, ElbowYaw, ERoll
static const double LEFT_ARM_BOUNDS[][2] = {{-2.09,2.09},
{0.0,1.65},
{-2.09,2.09},
{-1.57,0.0}};
static const double RIGHT_ARM_BOUNDS[][2] = {{-2.09,2.09},
{-1.65,0.0},
{-2.09,2.09},
{0.0,1.57}};
// Order of leg joints: HYPitch HipRoll HipPitch KneePitch APitch ARoll
static const double LEFT_LEG_BOUNDS[][2] = {{-1.57,0.0},
{-.349,.785},
{-1.57,.436},
{0.0,2.269},
{-1.309,.524},
{-.785,.349}};
static const double RIGHT_LEG_BOUNDS[][2] = {{-1.57,0.0},
{-.785,.349},
{-1.57,.436},
{0.0,2.269},
{-1.309,.524},
{-.349,.785}};
/********** joint velocity limits **********/
//Set hardware values- nominal speed in rad/20ms
//from $AL_DIR/doc/reddoc
//M=motor r = reduction ratio
static const double M1R1_NOMINAL = 0.0658;
static const double M1R2_NOMINAL = 0.1012;
static const double M2R1_NOMINAL = 0.1227;
static const double M2R2_NOMINAL = 0.1065;
static const double M1R1_NO_LOAD = 0.08308;
static const double M1R2_NO_LOAD = 0.1279;
static const double M2R1_NO_LOAD = 0.16528;
static const double M2R2_NO_LOAD = 0.1438;
static const double M1R1_AVG = (M1R1_NOMINAL + M1R1_NO_LOAD )*0.5;
static const double M1R2_AVG = (M1R2_NOMINAL + M1R2_NO_LOAD )*0.5;
static const double M2R1_AVG = (M2R1_NOMINAL + M2R1_NO_LOAD )*0.5;
static const double M2R2_AVG = (M2R2_NOMINAL + M2R2_NO_LOAD )*0.5;
static const double jointsMaxVelNominal[Kinematics::NUM_JOINTS] = {
//head
M2R2_NOMINAL, M2R1_NOMINAL,
//left arm
M2R1_NOMINAL, M2R2_NOMINAL, M2R1_NOMINAL, M2R2_NOMINAL,
//left leg
M1R1_NOMINAL, M1R1_NOMINAL, M1R2_NOMINAL,
M1R2_NOMINAL, M1R2_NOMINAL, M1R1_NOMINAL,
//right leg
M1R1_NOMINAL, M1R1_NOMINAL, M1R2_NOMINAL,
M1R2_NOMINAL, M1R2_NOMINAL, M1R1_NOMINAL,
//right arm
M2R2_NOMINAL, M2R2_NOMINAL, M2R1_NOMINAL, M2R2_NOMINAL
};
static const double jointsMaxVelNoLoad[Kinematics::NUM_JOINTS] = {
//head
M2R2_NO_LOAD, M2R1_NO_LOAD,
//left arm
M2R1_NO_LOAD, M2R2_NO_LOAD, M2R1_NO_LOAD, M2R2_NO_LOAD,
//left leg
M1R1_NO_LOAD, M1R1_NO_LOAD, M1R2_NO_LOAD,
M1R2_NO_LOAD, M1R2_NO_LOAD, M1R1_NO_LOAD,
//right leg
M1R1_NO_LOAD, M1R1_NO_LOAD, M1R2_NO_LOAD,
M1R2_NO_LOAD, M1R2_NO_LOAD, M1R1_NO_LOAD,
//right arm
M2R2_NO_LOAD, M2R2_NO_LOAD, M2R1_NO_LOAD, M2R2_NO_LOAD
};
static const double jointsMaxVelAvg[Kinematics::NUM_JOINTS] = {
//head
M2R2_AVG, M2R1_AVG,
//left arm
M2R1_AVG, M2R2_AVG, M2R1_AVG, M2R2_AVG,
//left leg
M1R1_AVG, M1R1_AVG, M1R2_AVG,
M1R2_AVG, M1R2_AVG, M1R1_AVG,
//right leg
M1R1_AVG, M1R1_AVG, M1R2_AVG,
M1R2_AVG, M1R2_AVG, M1R1_AVG,
//right arm
M2R2_AVG, M2R2_AVG, M2R1_AVG, M2R2_AVG
};
/********** mDH parameters ***********/
enum mDHNames {
ALPHA = 0,
L,
THETA,
D
};
// (alpha, a , theta , d )
const double HEAD_MDH_PARAMS[2][4] = {{0.0 , 0.0, 0.0 , 0.0},
{-M_PI_double/2, 0.0, -M_PI_double/2 , 0.0}};
const double LEFT_ARM_MDH_PARAMS[4][4] = {{-M_PI_double/2,0.0,0.0,0.0},
{ M_PI_double/2,0.0,M_PI_double/2,0.0},
{ M_PI_double/2,0.0,0.0,UPPER_ARM_LENGTH},
{-M_PI_double/2,0.0,0.0,0.0}};
const double LEFT_LEG_MDH_PARAMS[6][4] = {{ -3*M_PI_double/4, 0.0, -M_PI_double/2, 0.0},
{ -M_PI_double/2, 0.0, M_PI_double/4, 0.0},
{ M_PI_double/2, 0.0, 0.0, 0.0},
{ 0.0,-THIGH_LENGTH,0.0, 0.0},
{ 0.0,-TIBIA_LENGTH,0.0, 0.0},
{-M_PI_double/2, 0.0, 0.0, 0.0}};
const double RIGHT_LEG_MDH_PARAMS[6][4]= {{ -M_PI_double/4, 0.0, -M_PI_double/2, 0.0},
{ -M_PI_double/2, 0.0, -M_PI_double/4, 0.0},
{ M_PI_double/2, 0.0, 0.0, 0.0},
{ 0.0,-THIGH_LENGTH,0.0, 0.0},
{0.0,-TIBIA_LENGTH,0.0,0.0},
{-M_PI_double/2,0.0,0.0,0.0}};
const double RIGHT_ARM_MDH_PARAMS[4][4] = {{-M_PI_double/2, 0.0,0.0,0.0},
{ M_PI_double/2, 0.0,M_PI_double/2,0.0},
{ M_PI_double/2, 0.0,0.0,UPPER_ARM_LENGTH},
{-M_PI_double/2, 0.0,0.0,0.0}};
static const double* MDH_PARAMS[NUM_CHAINS] = {&HEAD_MDH_PARAMS[0][0],
&LEFT_ARM_MDH_PARAMS[0][0],
&LEFT_LEG_MDH_PARAMS[0][0],
&RIGHT_LEG_MDH_PARAMS[0][0],
&RIGHT_ARM_MDH_PARAMS[0][0]};
//Base transforms to get from body center to beg. of chain
static const boost::numeric::ublas::matrix <double> HEAD_BASE_TRANSFORMS[1]
= { CoordFrame4D::translation4D( 0.0,
0.0,
NECK_OFFSET_Z ) };
static const boost::numeric::ublas::matrix <double> LEFT_ARM_BASE_TRANSFORMS[1]
= { CoordFrame4D::translation4D( 0.0,
SHOULDER_OFFSET_Y,
SHOULDER_OFFSET_Z ) };
static const boost::numeric::ublas::matrix <double> LEFT_LEG_BASE_TRANSFORMS[1]
={ CoordFrame4D::translation4D( 0.0,
HIP_OFFSET_Y,
-HIP_OFFSET_Z ) };
static const boost::numeric::ublas::matrix <double> RIGHT_LEG_BASE_TRANSFORMS[1]
={ CoordFrame4D::translation4D( 0.0,
-HIP_OFFSET_Y,
-HIP_OFFSET_Z ) };
static const boost::numeric::ublas::matrix <double> RIGHT_ARM_BASE_TRANSFORMS[1]
={ CoordFrame4D::translation4D( 0.0,
-SHOULDER_OFFSET_Y,
SHOULDER_OFFSET_Z ) };
static const boost::numeric::ublas::matrix <double> * BASE_TRANSFORMS[NUM_CHAINS] =
{ &HEAD_BASE_TRANSFORMS[0],
&LEFT_ARM_BASE_TRANSFORMS[0],
&LEFT_LEG_BASE_TRANSFORMS[0],
&RIGHT_LEG_BASE_TRANSFORMS[0],
&RIGHT_ARM_BASE_TRANSFORMS[0] };
//Base transforms to get from body center to beg. of chain
static const boost::numeric::ublas::matrix <double> HEAD_END_TRANSFORMS[4]
= { CoordFrame4D::rotation4D(CoordFrame4D::X_AXIS, M_PI_double/2),
CoordFrame4D::rotation4D(CoordFrame4D::Y_AXIS,M_PI_double/2),
CoordFrame4D::translation4D(CAMERA_OFF_X, 0, CAMERA_OFF_Z),
CoordFrame4D::rotation4D(CoordFrame4D::Y_AXIS, CAMERA_PITCH_ANGLE) };
static const boost::numeric::ublas::matrix <double> LEFT_ARM_END_TRANSFORMS[2]
= { CoordFrame4D::rotation4D(CoordFrame4D::Z_AXIS, -M_PI_double/2),
CoordFrame4D::translation4D(LOWER_ARM_LENGTH,0.0,0.0) };
static const boost::numeric::ublas::matrix <double> LEFT_LEG_END_TRANSFORMS[3]
= { CoordFrame4D::rotation4D(CoordFrame4D::Z_AXIS, M_PI_double),
CoordFrame4D::rotation4D(CoordFrame4D::Y_AXIS, -M_PI_double/2),
CoordFrame4D::translation4D(0.0,
0.0,
-FOOT_HEIGHT) };
static const boost::numeric::ublas::matrix <double> RIGHT_LEG_END_TRANSFORMS[3] =
{ CoordFrame4D::rotation4D(CoordFrame4D::Z_AXIS, M_PI_double),
CoordFrame4D::rotation4D(CoordFrame4D::Y_AXIS, -M_PI_double/2),
CoordFrame4D::translation4D(0.0,
0.0,
-FOOT_HEIGHT) };
static const boost::numeric::ublas::matrix <double> RIGHT_ARM_END_TRANSFORMS[2] =
{ CoordFrame4D::rotation4D(CoordFrame4D::Z_AXIS, -M_PI_double/2),
CoordFrame4D::translation4D(LOWER_ARM_LENGTH,0.0,0.0) };
static const boost::numeric::ublas::matrix <double> * END_TRANSFORMS[NUM_CHAINS] =
{ &HEAD_END_TRANSFORMS[0],
&LEFT_ARM_END_TRANSFORMS[0],
&LEFT_LEG_END_TRANSFORMS[0],
&RIGHT_LEG_END_TRANSFORMS[0],
&RIGHT_ARM_END_TRANSFORMS[0] };
static const int NUM_BASE_TRANSFORMS[NUM_CHAINS] = {1,1,1,1,1};
static const int NUM_END_TRANSFORMS[NUM_CHAINS] = {4,2,3,3,2};
static const int NUM_JOINTS_CHAIN[NUM_CHAINS] = {2,4,6,6,4};
//locally expressed constants (with respect to an individual joint
//and the GLOBAL coordinate frame)
static const double CHEST_MASS_Z = 43.42;
static const double CHEST_MASS_X = -4.13;
static const double HEAD_MASS_Z = 179.08 - NECK_OFFSET_Z;
static const double UPPER_ARM_MASS_X = 49.1;
static const double LOWER_ARM_MASS_X = 156.12 - UPPER_ARM_LENGTH;
static const double THIGH_MASS_Z = 123.0 - HIP_OFFSET_Z;
static const double TIBIA_MASS_Z = 251.1 - HIP_OFFSET_Z - THIGH_LENGTH;
static const double FOOT_MASS_Z = 315.0 - HIP_OFFSET_Z -
THIGH_LENGTH - TIBIA_LENGTH;
static const double FOOT_MASS_X = 25.42;
//Weight constants
static const double CHEST_MASS_g = 1199.68;
static const double HEAD_MASS_g = 540.91;
static const double UPPER_ARM_MASS_g = 287.0;
static const double LOWER_ARM_MASS_g = 142.44;
static const double THIGH_MASS_g = 600.02;
static const double TIBIA_MASS_g = 435.58;
static const double FOOT_MASS_g = 171.84;
static const double TOTAL_MASS =
CHEST_MASS_g + HEAD_MASS_g +
2.0*(UPPER_ARM_MASS_g + LOWER_ARM_MASS_g + THIGH_MASS_g +
TIBIA_MASS_g + FOOT_MASS_g);
//The locations of the massses are translated from their
//global coordinate frame into the local frame in tuples like
// {X,Y,Z,WEIGHT}
static const double HEAD_INERTIAL_POS[2][4] = {
{0.0, 0.0, 0.0, 0.0},
{HEAD_MASS_Z, 0.0, 0.0, HEAD_MASS_g}};
static const double LEFT_ARM_INERTIAL_POS[4][4] = {
{0.0, 0.0, 0.0, 0.0},
{ 0.0, -UPPER_ARM_MASS_X, 0.0, UPPER_ARM_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{ 0.0,-UPPER_ARM_MASS_X, 0.0, LOWER_ARM_MASS_g}};
//Z,X,Y is the correct order for most of the leg
static const double LEFT_LEG_INERTIAL_POS[6][4] = {
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{-THIGH_MASS_Z, 0.0, 0.0, THIGH_MASS_g},
{-TIBIA_MASS_Z, 0.0, 0.0, TIBIA_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{-FOOT_MASS_Z, 0.0, FOOT_MASS_X, FOOT_MASS_g}};
static const double RIGHT_LEG_INERTIAL_POS[6][4] = {
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{-THIGH_MASS_Z, 0.0, 0.0, THIGH_MASS_g},
{-TIBIA_MASS_Z, 0.0, 0.0, TIBIA_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{-FOOT_MASS_Z, 0.0, FOOT_MASS_X, FOOT_MASS_g}};
static const double RIGHT_ARM_INERTIAL_POS[4][4] = {
{0.0, 0.0, 0.0, 0.0},
{ 0.0, -UPPER_ARM_MASS_X, 0.0, UPPER_ARM_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{ 0.0,-UPPER_ARM_MASS_X, 0.0, LOWER_ARM_MASS_g}};
static const double* INERTIAL_POS[NUM_CHAINS] = {&HEAD_INERTIAL_POS[0][0],
&LEFT_ARM_INERTIAL_POS[0][0],
&LEFT_LEG_INERTIAL_POS[0][0],
&RIGHT_LEG_INERTIAL_POS[0][0],
&RIGHT_ARM_INERTIAL_POS[0][0]};
static const unsigned int MASS_INDEX = 3;
};
#endif
| #ifndef VAR_0
#define VAR_0
/**
* This file is strictly specific to the Nao robot.
* It contains infomation relevant to the physical configuration of the robot
* including:
* length of links
* number of chains, etc.
* It includes method definitions related to the calculation of forward and
* inverse kinematics.
* It also supports the creation of rotation and translation matrices.
* NOTE: All of the lengths are in millimeters.
*/
#include <IMPORT_0>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <IMPORT_1>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <IMPORT_2> // for lu_factorize
#include <boost/numeric/ublas/io.hpp> // for cout
#include <math.h>
#include "NBMath.h"
#include "NBMatrixMath.h"
#include "CoordFrame.h"
namespace Kinematics {
enum ChainID {
VAR_1 = 0,
VAR_2,
LLEG_CHAIN,
VAR_3,
VAR_4,
VAR_5, // only goes to the ankle
VAR_6 // (same)
};
// Interpolation types
enum CLASS_0 {
VAR_7 = 0,
INTERPOLATION_LINEAR
};
/// Joint Name constants ///
enum CLASS_1 {
HEAD_YAW = 0,
VAR_8,
// LARM,
L_SHOULDER_PITCH,
VAR_9,
VAR_10,
L_ELBOW_ROLL,
// LLEG,
VAR_11,
VAR_12,
L_HIP_PITCH,
L_KNEE_PITCH,
L_ANKLE_PITCH,
VAR_13,
// RLEG,
R_HIP_YAW_PITCH,
R_HIP_ROLL,
R_HIP_PITCH,
VAR_14,
VAR_15,
VAR_16,
// RARM,
R_SHOULDER_PITCH,
R_SHOULDER_ROLL,
R_ELBOW_YAW,
VAR_17
};
static const unsigned int FIRST_HEAD_JOINT = HEAD_YAW;
/**
* (Deprecated)
enum Motion_IntFlag {
UNINT_INTR_CMD, // Un-interruptable interrupter command
INT_INTR_CMD, // Interruptable interupter command
UNINT_CMD, // Un-interruptable command
INT_CMD // Interruptable command
};
enum SupportLeg{
BOTH_LEGS = 0,
RIGHT_LEG,
LEFT_LEG
};
**/
static const unsigned int HEAD_JOINTS = 2;
static const unsigned int VAR_18 = 4;
static const unsigned int VAR_19 = 6;
static const unsigned int NUM_CHAINS = 5;
static const unsigned int NUM_BODY_CHAINS = 4;
static const unsigned int VAR_20 = HEAD_JOINTS + VAR_18*2 +
VAR_19*2;
static const unsigned int VAR_21 = VAR_18*2 + VAR_19*2;
static const unsigned int VAR_22[NUM_CHAINS] = {2, 4, 6, 6, 4};
static const unsigned int chain_first_joint[NUM_CHAINS] = {0,2,6,12,18};
static const unsigned int VAR_23[NUM_CHAINS] = {1,5,11,17,21};
static const CLASS_2::VAR_24 CHAIN_STRINGS[NUM_CHAINS] =
{ "Head",
"LArm",
"LLeg",
"RLeg",
"RArm" };
//Note: this joint list constains RHipYawPitch, which is not compatible
//with the DCM convention on naming joints (this joint is technially
//nonexistant)
static const CLASS_2::VAR_24 VAR_25[VAR_20] =
{ "HeadYaw",
"HeadPitch",
"LShoulderPitch",
"LShoulderRoll",
"LElbowYaw",
"LElbowRoll",
"LHipYawPitch",
"LHipRoll",
"LHipPitch",
"LKneePitch",
"LAnklePitch",
"LAnkleRoll",
"RHipYawPitch",
"RHipRoll",
"RHipPitch",
"RKneePitch",
"RAnklePitch",
"RAnkleRoll",
"RShoulderPitch",
"RShoulderRoll",
"RElbowYaw",
"RElbowRoll"};
/********** Bodily dimensions ***********/
static const double SHOULDER_OFFSET_Y = 98.0;
static const double UPPER_ARM_LENGTH = 105.0;
static const double LOWER_ARM_LENGTH = 55.95;
static const double SHOULDER_OFFSET_Z = 100;
static const double THIGH_LENGTH = 100.0;
static const double TIBIA_LENGTH = 102.9;
static const double NECK_OFFSET_Z = 126.5;
static const double HIP_OFFSET_Y = 50.0;
static const double VAR_26 = 85.0;
static const double FOOT_HEIGHT = 45.19;
// Camera
static const double VAR_27 = 48.80; // in millimeters
static const double VAR_28 = 23.81; // in millimeters
static const double CAMERA_PITCH_ANGLE = 40.0 * VAR_29; // 40 degrees
/********** Joint Bounds ***********/
static const double VAR_30[2][2] = {{-2.09,2.09},{-.785,.785}};
// Order of arm joints: ShoulderPitch, SRoll, ElbowYaw, ERoll
static const double VAR_31[][2] = {{-2.09,2.09},
{0.0,1.65},
{-2.09,2.09},
{-1.57,0.0}};
static const double VAR_32[][2] = {{-2.09,2.09},
{-1.65,0.0},
{-2.09,2.09},
{0.0,1.57}};
// Order of leg joints: HYPitch HipRoll HipPitch KneePitch APitch ARoll
static const double LEFT_LEG_BOUNDS[][2] = {{-1.57,0.0},
{-.349,.785},
{-1.57,.436},
{0.0,2.269},
{-1.309,.524},
{-.785,.349}};
static const double VAR_33[][2] = {{-1.57,0.0},
{-.785,.349},
{-1.57,.436},
{0.0,2.269},
{-1.309,.524},
{-.349,.785}};
/********** joint velocity limits **********/
//Set hardware values- nominal speed in rad/20ms
//from $AL_DIR/doc/reddoc
//M=motor r = reduction ratio
static const double M1R1_NOMINAL = 0.0658;
static const double M1R2_NOMINAL = 0.1012;
static const double VAR_34 = 0.1227;
static const double M2R2_NOMINAL = 0.1065;
static const double VAR_35 = 0.08308;
static const double VAR_36 = 0.1279;
static const double VAR_37 = 0.16528;
static const double M2R2_NO_LOAD = 0.1438;
static const double M1R1_AVG = (M1R1_NOMINAL + VAR_35 )*0.5;
static const double M1R2_AVG = (M1R2_NOMINAL + VAR_36 )*0.5;
static const double M2R1_AVG = (VAR_34 + VAR_37 )*0.5;
static const double M2R2_AVG = (M2R2_NOMINAL + M2R2_NO_LOAD )*0.5;
static const double jointsMaxVelNominal[Kinematics::VAR_20] = {
//head
M2R2_NOMINAL, VAR_34,
//left arm
VAR_34, M2R2_NOMINAL, VAR_34, M2R2_NOMINAL,
//left leg
M1R1_NOMINAL, M1R1_NOMINAL, M1R2_NOMINAL,
M1R2_NOMINAL, M1R2_NOMINAL, M1R1_NOMINAL,
//right leg
M1R1_NOMINAL, M1R1_NOMINAL, M1R2_NOMINAL,
M1R2_NOMINAL, M1R2_NOMINAL, M1R1_NOMINAL,
//right arm
M2R2_NOMINAL, M2R2_NOMINAL, VAR_34, M2R2_NOMINAL
};
static const double VAR_38[Kinematics::VAR_20] = {
//head
M2R2_NO_LOAD, VAR_37,
//left arm
VAR_37, M2R2_NO_LOAD, VAR_37, M2R2_NO_LOAD,
//left leg
VAR_35, VAR_35, VAR_36,
VAR_36, VAR_36, VAR_35,
//right leg
VAR_35, VAR_35, VAR_36,
VAR_36, VAR_36, VAR_35,
//right arm
M2R2_NO_LOAD, M2R2_NO_LOAD, VAR_37, M2R2_NO_LOAD
};
static const double VAR_39[Kinematics::VAR_20] = {
//head
M2R2_AVG, M2R1_AVG,
//left arm
M2R1_AVG, M2R2_AVG, M2R1_AVG, M2R2_AVG,
//left leg
M1R1_AVG, M1R1_AVG, M1R2_AVG,
M1R2_AVG, M1R2_AVG, M1R1_AVG,
//right leg
M1R1_AVG, M1R1_AVG, M1R2_AVG,
M1R2_AVG, M1R2_AVG, M1R1_AVG,
//right arm
M2R2_AVG, M2R2_AVG, M2R1_AVG, M2R2_AVG
};
/********** mDH parameters ***********/
enum CLASS_3 {
VAR_40 = 0,
L,
VAR_41,
D
};
// (alpha, a , theta , d )
const double HEAD_MDH_PARAMS[2][4] = {{0.0 , 0.0, 0.0 , 0.0},
{-M_PI_double/2, 0.0, -M_PI_double/2 , 0.0}};
const double VAR_42[4][4] = {{-M_PI_double/2,0.0,0.0,0.0},
{ M_PI_double/2,0.0,M_PI_double/2,0.0},
{ M_PI_double/2,0.0,0.0,UPPER_ARM_LENGTH},
{-M_PI_double/2,0.0,0.0,0.0}};
const double VAR_43[6][4] = {{ -3*M_PI_double/4, 0.0, -M_PI_double/2, 0.0},
{ -M_PI_double/2, 0.0, M_PI_double/4, 0.0},
{ M_PI_double/2, 0.0, 0.0, 0.0},
{ 0.0,-THIGH_LENGTH,0.0, 0.0},
{ 0.0,-TIBIA_LENGTH,0.0, 0.0},
{-M_PI_double/2, 0.0, 0.0, 0.0}};
const double RIGHT_LEG_MDH_PARAMS[6][4]= {{ -M_PI_double/4, 0.0, -M_PI_double/2, 0.0},
{ -M_PI_double/2, 0.0, -M_PI_double/4, 0.0},
{ M_PI_double/2, 0.0, 0.0, 0.0},
{ 0.0,-THIGH_LENGTH,0.0, 0.0},
{0.0,-TIBIA_LENGTH,0.0,0.0},
{-M_PI_double/2,0.0,0.0,0.0}};
const double RIGHT_ARM_MDH_PARAMS[4][4] = {{-M_PI_double/2, 0.0,0.0,0.0},
{ M_PI_double/2, 0.0,M_PI_double/2,0.0},
{ M_PI_double/2, 0.0,0.0,UPPER_ARM_LENGTH},
{-M_PI_double/2, 0.0,0.0,0.0}};
static const double* MDH_PARAMS[NUM_CHAINS] = {&HEAD_MDH_PARAMS[0][0],
&VAR_42[0][0],
&VAR_43[0][0],
&RIGHT_LEG_MDH_PARAMS[0][0],
&RIGHT_ARM_MDH_PARAMS[0][0]};
//Base transforms to get from body center to beg. of chain
static const CLASS_4::VAR_44::VAR_45::matrix <double> HEAD_BASE_TRANSFORMS[1]
= { VAR_46::translation4D( 0.0,
0.0,
NECK_OFFSET_Z ) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> LEFT_ARM_BASE_TRANSFORMS[1]
= { VAR_46::translation4D( 0.0,
SHOULDER_OFFSET_Y,
SHOULDER_OFFSET_Z ) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> LEFT_LEG_BASE_TRANSFORMS[1]
={ VAR_46::translation4D( 0.0,
HIP_OFFSET_Y,
-VAR_26 ) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> RIGHT_LEG_BASE_TRANSFORMS[1]
={ VAR_46::translation4D( 0.0,
-HIP_OFFSET_Y,
-VAR_26 ) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> RIGHT_ARM_BASE_TRANSFORMS[1]
={ VAR_46::translation4D( 0.0,
-SHOULDER_OFFSET_Y,
SHOULDER_OFFSET_Z ) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> * VAR_47[NUM_CHAINS] =
{ &HEAD_BASE_TRANSFORMS[0],
&LEFT_ARM_BASE_TRANSFORMS[0],
&LEFT_LEG_BASE_TRANSFORMS[0],
&RIGHT_LEG_BASE_TRANSFORMS[0],
&RIGHT_ARM_BASE_TRANSFORMS[0] };
//Base transforms to get from body center to beg. of chain
static const CLASS_4::VAR_44::VAR_45::matrix <double> VAR_48[4]
= { VAR_46::rotation4D(VAR_46::X_AXIS, M_PI_double/2),
VAR_46::rotation4D(VAR_46::Y_AXIS,M_PI_double/2),
VAR_46::translation4D(VAR_27, 0, VAR_28),
VAR_46::rotation4D(VAR_46::Y_AXIS, CAMERA_PITCH_ANGLE) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> LEFT_ARM_END_TRANSFORMS[2]
= { VAR_46::rotation4D(VAR_46::VAR_49, -M_PI_double/2),
VAR_46::translation4D(LOWER_ARM_LENGTH,0.0,0.0) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> VAR_50[3]
= { VAR_46::rotation4D(VAR_46::VAR_49, M_PI_double),
VAR_46::rotation4D(VAR_46::Y_AXIS, -M_PI_double/2),
VAR_46::translation4D(0.0,
0.0,
-FOOT_HEIGHT) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> RIGHT_LEG_END_TRANSFORMS[3] =
{ VAR_46::rotation4D(VAR_46::VAR_49, M_PI_double),
VAR_46::rotation4D(VAR_46::Y_AXIS, -M_PI_double/2),
VAR_46::translation4D(0.0,
0.0,
-FOOT_HEIGHT) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> RIGHT_ARM_END_TRANSFORMS[2] =
{ VAR_46::rotation4D(VAR_46::VAR_49, -M_PI_double/2),
VAR_46::translation4D(LOWER_ARM_LENGTH,0.0,0.0) };
static const CLASS_4::VAR_44::VAR_45::matrix <double> * VAR_51[NUM_CHAINS] =
{ &VAR_48[0],
&LEFT_ARM_END_TRANSFORMS[0],
&VAR_50[0],
&RIGHT_LEG_END_TRANSFORMS[0],
&RIGHT_ARM_END_TRANSFORMS[0] };
static const int NUM_BASE_TRANSFORMS[NUM_CHAINS] = {1,1,1,1,1};
static const int VAR_52[NUM_CHAINS] = {4,2,3,3,2};
static const int VAR_53[NUM_CHAINS] = {2,4,6,6,4};
//locally expressed constants (with respect to an individual joint
//and the GLOBAL coordinate frame)
static const double VAR_54 = 43.42;
static const double VAR_55 = -4.13;
static const double VAR_56 = 179.08 - NECK_OFFSET_Z;
static const double VAR_57 = 49.1;
static const double VAR_58 = 156.12 - UPPER_ARM_LENGTH;
static const double VAR_59 = 123.0 - VAR_26;
static const double TIBIA_MASS_Z = 251.1 - VAR_26 - THIGH_LENGTH;
static const double FOOT_MASS_Z = 315.0 - VAR_26 -
THIGH_LENGTH - TIBIA_LENGTH;
static const double FOOT_MASS_X = 25.42;
//Weight constants
static const double VAR_60 = 1199.68;
static const double VAR_61 = 540.91;
static const double UPPER_ARM_MASS_g = 287.0;
static const double VAR_62 = 142.44;
static const double VAR_63 = 600.02;
static const double TIBIA_MASS_g = 435.58;
static const double FOOT_MASS_g = 171.84;
static const double TOTAL_MASS =
VAR_60 + VAR_61 +
2.0*(UPPER_ARM_MASS_g + VAR_62 + VAR_63 +
TIBIA_MASS_g + FOOT_MASS_g);
//The locations of the massses are translated from their
//global coordinate frame into the local frame in tuples like
// {X,Y,Z,WEIGHT}
static const double VAR_64[2][4] = {
{0.0, 0.0, 0.0, 0.0},
{VAR_56, 0.0, 0.0, VAR_61}};
static const double LEFT_ARM_INERTIAL_POS[4][4] = {
{0.0, 0.0, 0.0, 0.0},
{ 0.0, -VAR_57, 0.0, UPPER_ARM_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{ 0.0,-VAR_57, 0.0, VAR_62}};
//Z,X,Y is the correct order for most of the leg
static const double VAR_65[6][4] = {
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{-VAR_59, 0.0, 0.0, VAR_63},
{-TIBIA_MASS_Z, 0.0, 0.0, TIBIA_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{-FOOT_MASS_Z, 0.0, FOOT_MASS_X, FOOT_MASS_g}};
static const double VAR_66[6][4] = {
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{-VAR_59, 0.0, 0.0, VAR_63},
{-TIBIA_MASS_Z, 0.0, 0.0, TIBIA_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{-FOOT_MASS_Z, 0.0, FOOT_MASS_X, FOOT_MASS_g}};
static const double VAR_67[4][4] = {
{0.0, 0.0, 0.0, 0.0},
{ 0.0, -VAR_57, 0.0, UPPER_ARM_MASS_g},
{0.0, 0.0, 0.0, 0.0},
{ 0.0,-VAR_57, 0.0, VAR_62}};
static const double* INERTIAL_POS[NUM_CHAINS] = {&VAR_64[0][0],
&LEFT_ARM_INERTIAL_POS[0][0],
&VAR_65[0][0],
&VAR_66[0][0],
&VAR_67[0][0]};
static const unsigned int MASS_INDEX = 3;
};
#endif
| 0.489814 | {'VAR_0': 'Kinematics_h_DEFINED', 'IMPORT_0': 'string.h', 'IMPORT_1': 'boost/numeric/ublas/triangular.hpp', 'IMPORT_2': 'boost/numeric/ublas/lu.hpp', 'VAR_1': 'HEAD_CHAIN', 'VAR_2': 'LARM_CHAIN', 'VAR_3': 'RLEG_CHAIN', 'VAR_4': 'RARM_CHAIN', 'VAR_5': 'LANKLE_CHAIN', 'VAR_6': 'RANKLE_CHAIN', 'CLASS_0': 'InterpolationType', 'VAR_7': 'INTERPOLATION_SMOOTH', 'CLASS_1': 'JointNames', 'VAR_8': 'HEAD_PITCH', 'VAR_9': 'L_SHOULDER_ROLL', 'VAR_10': 'L_ELBOW_YAW', 'VAR_11': 'L_HIP_YAW_PITCH', 'VAR_12': 'L_HIP_ROLL', 'VAR_13': 'L_ANKLE_ROLL', 'VAR_14': 'R_KNEE_PITCH', 'VAR_15': 'R_ANKLE_PITCH', 'VAR_16': 'R_ANKLE_ROLL', 'VAR_17': 'R_ELBOW_ROLL', 'VAR_18': 'ARM_JOINTS', 'VAR_19': 'LEG_JOINTS', 'VAR_20': 'NUM_JOINTS', 'VAR_21': 'NUM_BODY_JOINTS', 'VAR_22': 'chain_lengths', 'VAR_23': 'chain_last_joint', 'CLASS_2': 'std', 'VAR_24': 'string', 'VAR_25': 'JOINT_STRINGS', 'VAR_26': 'HIP_OFFSET_Z', 'VAR_27': 'CAMERA_OFF_X', 'VAR_28': 'CAMERA_OFF_Z', 'VAR_29': 'TO_RAD', 'VAR_30': 'HEAD_BOUNDS', 'VAR_31': 'LEFT_ARM_BOUNDS', 'VAR_32': 'RIGHT_ARM_BOUNDS', 'VAR_33': 'RIGHT_LEG_BOUNDS', 'VAR_34': 'M2R1_NOMINAL', 'VAR_35': 'M1R1_NO_LOAD', 'VAR_36': 'M1R2_NO_LOAD', 'VAR_37': 'M2R1_NO_LOAD', 'VAR_38': 'jointsMaxVelNoLoad', 'VAR_39': 'jointsMaxVelAvg', 'CLASS_3': 'mDHNames', 'VAR_40': 'ALPHA', 'VAR_41': 'THETA', 'VAR_42': 'LEFT_ARM_MDH_PARAMS', 'VAR_43': 'LEFT_LEG_MDH_PARAMS', 'CLASS_4': 'boost', 'VAR_44': 'numeric', 'VAR_45': 'ublas', 'VAR_46': 'CoordFrame4D', 'VAR_47': 'BASE_TRANSFORMS', 'VAR_48': 'HEAD_END_TRANSFORMS', 'VAR_49': 'Z_AXIS', 'VAR_50': 'LEFT_LEG_END_TRANSFORMS', 'VAR_51': 'END_TRANSFORMS', 'VAR_52': 'NUM_END_TRANSFORMS', 'VAR_53': 'NUM_JOINTS_CHAIN', 'VAR_54': 'CHEST_MASS_Z', 'VAR_55': 'CHEST_MASS_X', 'VAR_56': 'HEAD_MASS_Z', 'VAR_57': 'UPPER_ARM_MASS_X', 'VAR_58': 'LOWER_ARM_MASS_X', 'VAR_59': 'THIGH_MASS_Z', 'VAR_60': 'CHEST_MASS_g', 'VAR_61': 'HEAD_MASS_g', 'VAR_62': 'LOWER_ARM_MASS_g', 'VAR_63': 'THIGH_MASS_g', 'VAR_64': 'HEAD_INERTIAL_POS', 'VAR_65': 'LEFT_LEG_INERTIAL_POS', 'VAR_66': 'RIGHT_LEG_INERTIAL_POS', 'VAR_67': 'RIGHT_ARM_INERTIAL_POS'} | c | Texto | 8.53% |
#pragma once
#include <CharacterEncoding.h>
#include "TimeSpanHelpers.h"
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Media::Core;
namespace FFmpegInterop
{
///<summary>This class allows configuring the FFmpegInteropMSS instance.</summary>
public ref class FFmpegInteropConfig sealed
{
public:
FFmpegInteropConfig()
{
PassthroughAudioMP3 = false;
PassthroughAudioAAC = false;
PassthroughVideoH264 = true;
PassthroughVideoH264Hi10P = false;
PassthroughVideoHEVC = true;
PassthroughVideoWMV3 = true;
PassthroughVideoVC1 = true;
PassthroughVideoMPEG2 = false;
PassthroughVideoVP9 = false;
VideoOutputAllowIyuv = false;
VideoOutputAllow10bit = false;
VideoOutputAllowBgra8 = false;
VideoOutputAllowNv12 = true;
SkipErrors = 50;
MaxAudioThreads = 2;
MaxSupportedPlaybackRate = 4.0;
StreamBufferSize = 16384;
FFmpegOptions = ref new PropertySet();
AutoSelectForcedSubtitles = true;
OverrideSubtitleStyles = false;
SubtitleRegion = ref new TimedTextRegion();
TimedTextSize extent;
extent.Unit = TimedTextUnit::Percentage;
extent.Width = 100;
extent.Height = 88;
SubtitleRegion->Extent = extent;
TimedTextPoint position;
position.Unit = TimedTextUnit::Pixels;
position.X = 0;
position.Y = 0;
SubtitleRegion->Position = position;
SubtitleRegion->DisplayAlignment = TimedTextDisplayAlignment::After;
SubtitleRegion->Background = Windows::UI::Colors::Transparent;
SubtitleRegion->ScrollMode = TimedTextScrollMode::Rollup;
SubtitleRegion->TextWrapping = TimedTextWrapping::Wrap;
SubtitleRegion->WritingMode = TimedTextWritingMode::LeftRightTopBottom;
SubtitleRegion->IsOverflowClipped = false;
SubtitleRegion->ZIndex = 0;
TimedTextDouble LineHeight;
LineHeight.Unit = TimedTextUnit::Percentage;
LineHeight.Value = 100;
SubtitleRegion->LineHeight = LineHeight;
TimedTextPadding padding;
padding.Unit = TimedTextUnit::Percentage;
padding.Start = 0;
SubtitleRegion->Padding = padding;
SubtitleRegion->Name = "";
SubtitleStyle = ref new TimedTextStyle();
SubtitleStyle->FontFamily = "default";
TimedTextDouble fontSize;
fontSize.Unit = TimedTextUnit::Pixels;
fontSize.Value = 44;
SubtitleStyle->FontSize = fontSize;
SubtitleStyle->LineAlignment = TimedTextLineAlignment::Center;
if (Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent("Windows.Media.Core.TimedTextStyle", "FontStyle"))
{
SubtitleStyle->FontStyle = TimedTextFontStyle::Normal;
}
SubtitleStyle->FontWeight = TimedTextWeight::Normal;
SubtitleStyle->Foreground = Windows::UI::Colors::White;
SubtitleStyle->Background = Windows::UI::Colors::Transparent;
//OutlineRadius = new TimedTextDouble { Unit = TimedTextUnit.Percentage, Value = 10 },
TimedTextDouble outlineThickness;
outlineThickness.Unit = TimedTextUnit::Percentage;
outlineThickness.Value = 4.5;
SubtitleStyle->OutlineThickness = outlineThickness;
SubtitleStyle->FlowDirection = TimedTextFlowDirection::LeftToRight;
SubtitleStyle->OutlineColor = { 0x80, 0, 0, 0 };
AutoCorrectAnsiSubtitles = true;
AnsiSubtitleEncoding = CharacterEncoding::GetSystemDefault();
DefaultAudioStreamName = "Audio Stream";
DefaultSubtitleStreamName = "Subtitle";
DefaultExternalSubtitleStreamName = "External Subtitle";
AttachmentCacheFolderName = "FFmpegAttachmentCache";
UseEmbeddedSubtitleFonts = true;
};
///<summary>Enable passthrough for MP3 audio.</summary>
property bool PassthroughAudioMP3;
///<summary>Enable passthrough for AAC audio.</summary>
property bool PassthroughAudioAAC;
///<summary>Allow passthrough for H264 video.</summary>
property bool PassthroughVideoH264;
///<summary>Allow passthrough for H264 video (High10 Profile - 10 Bit). Not recommended: Neither Windows codecs nor known HW decoders support Hi10P!</summary>
property bool PassthroughVideoH264Hi10P;
///<summary>Allow passthrough for HEVC video.</summary>
property bool PassthroughVideoHEVC;
///<summary>Allow passthrough for WMV3 video.</summary>
property bool PassthroughVideoWMV3;
///<summary>Allow passthrough for VC-1 video.</summary>
property bool PassthroughVideoVC1;
///<summary>Allow passthrough for MPEG-2 video. Requires "MPEG-2 Video Extension" from Windows Store.</summary>
property bool PassthroughVideoMPEG2;
///<summary>Allow passthrough for VP9 video. Requires "VP9 Video Extensions" from Windows Store.</summary>
property bool PassthroughVideoVP9;
///<summary>Allow video output in IYuv format.</summary>
property bool VideoOutputAllowIyuv;
///<summary>Allow video output in 10bit formats.</summary>
property bool VideoOutputAllow10bit;
///<summary>Allow video output in BGRA format - required for video transparency.</summary>
property bool VideoOutputAllowBgra8;
///<summary>Allow video output in NV12 format.</summary>
property bool VideoOutputAllowNv12;
///<summary>The maximum number of broken frames to skipp in a stream before stopping decoding.</summary>
property unsigned int SkipErrors;
///<summary>The maximum number of video decoding threads.</summary>
property unsigned int MaxVideoThreads;
///<summary>The maximum number of audio decoding threads.</summary>
property unsigned int MaxAudioThreads;
///<summary>The maximum supported playback rate. This is set on the media stream source itself.
/// This does not modify what the transport control default UI shows as available playback speeds. Custom UI is necessary!</summary>
property double MaxSupportedPlaybackRate;
///<summary>The buffer size to use for streaming sources (URI based).</summary>
property unsigned int StreamBufferSize;
///<summary>Additional options to use when creating the ffmpeg AVFormatContext.</summary>
property PropertySet^ FFmpegOptions;
///<summary>Automatically select subtitles when they have the 'forced' flag set.</summary>
property bool AutoSelectForcedSubtitles;
///<summary>Use SubtitleRegion and SubtitleStyle from config class, even if custom styles are defined for a subtitle.</summary>
property bool OverrideSubtitleStyles;
///<summary>Default region to use for subtitles.</summary>
property TimedTextRegion^ SubtitleRegion;
///<summary>Default style to use for subtitles.</summary>
property TimedTextStyle^ SubtitleStyle;
///<summary>Enable conversion of ANSI encoded subtitles to UTF-8.</summary>
property bool AutoCorrectAnsiSubtitles;
///<summary>The character encoding used to decode ANSI encoded subtitles. By default, the active windows codepage is used.</summary>
property CharacterEncoding^ AnsiSubtitleEncoding
{
void set(CharacterEncoding^ value)
{
if (value == nullptr)
throw ref new InvalidArgumentException();
m_CharacterEncoding = value;
}
CharacterEncoding^ get()
{
return m_CharacterEncoding;
}
}
///<summary>The subtitle delay will be initially applied to all subtitle tracks.
///Use SetSubtitleDelay() on the FFmpegInteropMSS instance if you want to change the delay during playback.</summary>
property TimeSpan DefaultSubtitleDelay;
///<summary>The default name to use for audio streams.</summary>
property String^ DefaultAudioStreamName;
///<summary>The default name to use for subtitle streams.</summary>
property String^ DefaultSubtitleStreamName;
///<summary>The default name to use for external subtitle streams.</summary>
property String^ DefaultExternalSubtitleStreamName;
///<summary>Use subtitle font files that are embedded in the media file.</summary>
property bool UseEmbeddedSubtitleFonts;
///<summary>The folder where attachments such as fonts are stored (inside the app's temp folder).</summary>
property String^ AttachmentCacheFolderName;
internal:
/*Internal use:determines if a FFmpegInteropInstance is in frame grabber mode. This mode is used to grab frames from a video stream.*/
property bool IsFrameGrabber;
/*Internal use:determines if a FFmpegInteropInstance is in external subtitle parser mode. This mode is used to parse files which contain only subtitle streams*/
property bool IsExternalSubtitleParser;
/*Used to pass additional, specific options to external sub parsers*/
property PropertySet^ AdditionalFFmpegSubtitleOptions;
private:
CharacterEncoding^ m_CharacterEncoding;
};
} | #pragma once
#include <CharacterEncoding.h>
#include "IMPORT_0"
CLASS_0 namespace Platform;
CLASS_0 namespace Windows::VAR_1;
CLASS_0 namespace Windows::Foundation::VAR_2;
CLASS_0 namespace Windows::Media::VAR_3;
namespace VAR_4
{
///<summary>This class allows configuring the FFmpegInteropMSS instance.</summary>
CLASS_1 VAR_5 class FFmpegInteropConfig VAR_6
{
public:
FFmpegInteropConfig()
{
VAR_7 = false;
VAR_8 = false;
VAR_9 = true;
VAR_10 = false;
VAR_11 = true;
VAR_12 = true;
PassthroughVideoVC1 = true;
PassthroughVideoMPEG2 = false;
VAR_13 = false;
VAR_14 = false;
VAR_15 = false;
VAR_16 = false;
VAR_17 = true;
VAR_18 = 50;
MaxAudioThreads = 2;
VAR_19 = 4.0;
VAR_20 = 16384;
VAR_21 = VAR_5 CLASS_3 FUNC_0();
AutoSelectForcedSubtitles = true;
VAR_24 = false;
VAR_25 = VAR_5 CLASS_3 FUNC_1();
TimedTextSize VAR_27;
VAR_27.VAR_28 = VAR_29::VAR_30;
VAR_27.VAR_31 = 100;
VAR_27.Height = 88;
VAR_25->VAR_32 = VAR_27;
CLASS_4 VAR_33;
VAR_33.VAR_28 = VAR_29::VAR_34;
VAR_33.VAR_35 = 0;
VAR_33.VAR_36 = 0;
VAR_25->VAR_37 = VAR_33;
VAR_25->VAR_38 = VAR_39::VAR_40;
VAR_25->VAR_41 = VAR_0::UI::Colors::VAR_42;
VAR_25->VAR_43 = VAR_44::VAR_45;
VAR_25->VAR_46 = VAR_47::Wrap;
VAR_25->VAR_48 = TimedTextWritingMode::VAR_49;
VAR_25->VAR_50 = false;
VAR_25->VAR_51 = 0;
CLASS_5 VAR_52;
VAR_52.VAR_28 = VAR_29::VAR_30;
VAR_52.VAR_53 = 100;
VAR_25->VAR_52 = VAR_52;
CLASS_6 VAR_54;
VAR_54.VAR_28 = VAR_29::VAR_30;
VAR_54.VAR_55 = 0;
VAR_25->VAR_56 = VAR_54;
VAR_25->VAR_57 = "";
VAR_58 = VAR_5 CLASS_3 FUNC_2();
VAR_58->VAR_60 = "default";
CLASS_5 VAR_61;
VAR_61.VAR_28 = VAR_29::VAR_34;
VAR_61.VAR_53 = 44;
VAR_58->VAR_62 = VAR_61;
VAR_58->VAR_63 = VAR_64::VAR_65;
if (VAR_0::VAR_1::VAR_66::VAR_67::FUNC_3("Windows.Media.Core.TimedTextStyle", "FontStyle"))
{
VAR_58->VAR_68 = VAR_69::VAR_70;
}
VAR_58->VAR_71 = VAR_72::VAR_70;
VAR_58->Foreground = VAR_0::UI::Colors::VAR_73;
VAR_58->VAR_41 = VAR_0::UI::Colors::VAR_42;
//OutlineRadius = new TimedTextDouble { Unit = TimedTextUnit.Percentage, Value = 10 },
CLASS_5 VAR_74;
VAR_74.VAR_28 = VAR_29::VAR_30;
VAR_74.VAR_53 = 4.5;
VAR_58->VAR_75 = VAR_74;
VAR_58->VAR_76 = VAR_77::VAR_78;
VAR_58->VAR_79 = { 0x80, 0, 0, 0 };
VAR_80 = true;
VAR_81 = VAR_82::GetSystemDefault();
VAR_83 = "Audio Stream";
VAR_84 = "Subtitle";
VAR_85 = "External Subtitle";
VAR_86 = "FFmpegAttachmentCache";
VAR_87 = true;
};
///<summary>Enable passthrough for MP3 audio.</summary>
CLASS_8 VAR_89 VAR_7;
///<summary>Enable passthrough for AAC audio.</summary>
CLASS_8 VAR_89 VAR_8;
///<summary>Allow passthrough for H264 video.</summary>
CLASS_8 VAR_89 VAR_9;
///<summary>Allow passthrough for H264 video (High10 Profile - 10 Bit). Not recommended: Neither Windows codecs nor known HW decoders support Hi10P!</summary>
CLASS_8 VAR_89 VAR_10;
///<summary>Allow passthrough for HEVC video.</summary>
CLASS_8 VAR_89 VAR_11;
///<summary>Allow passthrough for WMV3 video.</summary>
CLASS_8 VAR_89 VAR_12;
///<summary>Allow passthrough for VC-1 video.</summary>
CLASS_8 VAR_89 PassthroughVideoVC1;
///<summary>Allow passthrough for MPEG-2 video. Requires "MPEG-2 Video Extension" from Windows Store.</summary>
CLASS_8 VAR_89 PassthroughVideoMPEG2;
///<summary>Allow passthrough for VP9 video. Requires "VP9 Video Extensions" from Windows Store.</summary>
CLASS_8 VAR_89 VAR_13;
///<summary>Allow video output in IYuv format.</summary>
CLASS_8 VAR_89 VAR_14;
///<summary>Allow video output in 10bit formats.</summary>
CLASS_8 VAR_89 VAR_15;
///<summary>Allow video output in BGRA format - required for video transparency.</summary>
CLASS_8 VAR_89 VAR_16;
///<summary>Allow video output in NV12 format.</summary>
CLASS_8 VAR_89 VAR_17;
///<summary>The maximum number of broken frames to skipp in a stream before stopping decoding.</summary>
ID_0 unsigned VAR_90 VAR_18;
///<summary>The maximum number of video decoding threads.</summary>
ID_0 unsigned VAR_90 VAR_91;
///<summary>The maximum number of audio decoding threads.</summary>
ID_0 unsigned VAR_90 MaxAudioThreads;
///<summary>The maximum supported playback rate. This is set on the media stream source itself.
/// This does not modify what the transport control default UI shows as available playback speeds. Custom UI is necessary!</summary>
CLASS_8 VAR_92 VAR_19;
///<summary>The buffer size to use for streaming sources (URI based).</summary>
ID_0 unsigned VAR_90 VAR_20;
///<summary>Additional options to use when creating the ffmpeg AVFormatContext.</summary>
CLASS_8 VAR_23^ VAR_21;
///<summary>Automatically select subtitles when they have the 'forced' flag set.</summary>
CLASS_8 VAR_89 AutoSelectForcedSubtitles;
///<summary>Use SubtitleRegion and SubtitleStyle from config class, even if custom styles are defined for a subtitle.</summary>
CLASS_8 VAR_89 VAR_24;
///<summary>Default region to use for subtitles.</summary>
CLASS_8 VAR_26^ VAR_25;
///<summary>Default style to use for subtitles.</summary>
CLASS_8 VAR_59^ VAR_58;
///<summary>Enable conversion of ANSI encoded subtitles to UTF-8.</summary>
CLASS_8 VAR_89 VAR_80;
///<summary>The character encoding used to decode ANSI encoded subtitles. By default, the active windows codepage is used.</summary>
CLASS_8 VAR_82^ VAR_81
{
void FUNC_4(CLASS_7^ VAR_93)
{
if (VAR_93 == nullptr)
VAR_94 CLASS_2 VAR_22 InvalidArgumentException();
VAR_95 = VAR_93;
}
VAR_82^ FUNC_5()
{
return VAR_95;
}
}
///<summary>The subtitle delay will be initially applied to all subtitle tracks.
///Use SetSubtitleDelay() on the FFmpegInteropMSS instance if you want to change the delay during playback.</summary>
CLASS_8 VAR_96 VAR_97;
///<summary>The default name to use for audio streams.</summary>
CLASS_8 VAR_98^ VAR_83;
///<summary>The default name to use for subtitle streams.</summary>
CLASS_8 VAR_98^ VAR_84;
///<summary>The default name to use for external subtitle streams.</summary>
CLASS_8 VAR_98^ VAR_85;
///<summary>Use subtitle font files that are embedded in the media file.</summary>
CLASS_8 VAR_89 VAR_87;
///<summary>The folder where attachments such as fonts are stored (inside the app's temp folder).</summary>
CLASS_8 VAR_98^ VAR_86;
internal:
/*Internal use:determines if a FFmpegInteropInstance is in frame grabber mode. This mode is used to grab frames from a video stream.*/
VAR_88 bool VAR_99;
/*Internal use:determines if a FFmpegInteropInstance is in external subtitle parser mode. This mode is used to parse files which contain only subtitle streams*/
CLASS_8 VAR_89 VAR_100;
/*Used to pass additional, specific options to external sub parsers*/
CLASS_8 VAR_23^ AdditionalFFmpegSubtitleOptions;
private:
VAR_82^ VAR_95;
};
} | 0.834824 | {'IMPORT_0': 'TimeSpanHelpers.h', 'CLASS_0': 'using', 'VAR_0': 'Windows', 'VAR_1': 'Foundation', 'VAR_2': 'Collections', 'VAR_3': 'Core', 'VAR_4': 'FFmpegInterop', 'CLASS_1': 'public', 'VAR_5': 'ref', 'CLASS_2': 'ref', 'VAR_6': 'sealed', 'VAR_7': 'PassthroughAudioMP3', 'VAR_8': 'PassthroughAudioAAC', 'VAR_9': 'PassthroughVideoH264', 'VAR_10': 'PassthroughVideoH264Hi10P', 'VAR_11': 'PassthroughVideoHEVC', 'VAR_12': 'PassthroughVideoWMV3', 'VAR_13': 'PassthroughVideoVP9', 'VAR_14': 'VideoOutputAllowIyuv', 'VAR_15': 'VideoOutputAllow10bit', 'VAR_16': 'VideoOutputAllowBgra8', 'VAR_17': 'VideoOutputAllowNv12', 'VAR_18': 'SkipErrors', 'VAR_19': 'MaxSupportedPlaybackRate', 'VAR_20': 'StreamBufferSize', 'VAR_21': 'FFmpegOptions', 'CLASS_3': 'new', 'VAR_22': 'new', 'FUNC_0': 'PropertySet', 'VAR_23': 'PropertySet', 'VAR_24': 'OverrideSubtitleStyles', 'VAR_25': 'SubtitleRegion', 'FUNC_1': 'TimedTextRegion', 'VAR_26': 'TimedTextRegion', 'VAR_27': 'extent', 'VAR_28': 'Unit', 'VAR_29': 'TimedTextUnit', 'VAR_30': 'Percentage', 'VAR_31': 'Width', 'VAR_32': 'Extent', 'CLASS_4': 'TimedTextPoint', 'VAR_33': 'position', 'VAR_34': 'Pixels', 'VAR_35': 'X', 'VAR_36': 'Y', 'VAR_37': 'Position', 'VAR_38': 'DisplayAlignment', 'VAR_39': 'TimedTextDisplayAlignment', 'VAR_40': 'After', 'VAR_41': 'Background', 'VAR_42': 'Transparent', 'VAR_43': 'ScrollMode', 'VAR_44': 'TimedTextScrollMode', 'VAR_45': 'Rollup', 'VAR_46': 'TextWrapping', 'VAR_47': 'TimedTextWrapping', 'VAR_48': 'WritingMode', 'VAR_49': 'LeftRightTopBottom', 'VAR_50': 'IsOverflowClipped', 'VAR_51': 'ZIndex', 'CLASS_5': 'TimedTextDouble', 'VAR_52': 'LineHeight', 'VAR_53': 'Value', 'CLASS_6': 'TimedTextPadding', 'VAR_54': 'padding', 'VAR_55': 'Start', 'VAR_56': 'Padding', 'VAR_57': 'Name', 'VAR_58': 'SubtitleStyle', 'FUNC_2': 'TimedTextStyle', 'VAR_59': 'TimedTextStyle', 'VAR_60': 'FontFamily', 'VAR_61': 'fontSize', 'VAR_62': 'FontSize', 'VAR_63': 'LineAlignment', 'VAR_64': 'TimedTextLineAlignment', 'VAR_65': 'Center', 'VAR_66': 'Metadata', 'VAR_67': 'ApiInformation', 'FUNC_3': 'IsPropertyPresent', 'VAR_68': 'FontStyle', 'VAR_69': 'TimedTextFontStyle', 'VAR_70': 'Normal', 'VAR_71': 'FontWeight', 'VAR_72': 'TimedTextWeight', 'VAR_73': 'White', 'VAR_74': 'outlineThickness', 'VAR_75': 'OutlineThickness', 'VAR_76': 'FlowDirection', 'VAR_77': 'TimedTextFlowDirection', 'VAR_78': 'LeftToRight', 'VAR_79': 'OutlineColor', 'VAR_80': 'AutoCorrectAnsiSubtitles', 'VAR_81': 'AnsiSubtitleEncoding', 'VAR_82': 'CharacterEncoding', 'CLASS_7': 'CharacterEncoding', 'VAR_83': 'DefaultAudioStreamName', 'VAR_84': 'DefaultSubtitleStreamName', 'VAR_85': 'DefaultExternalSubtitleStreamName', 'VAR_86': 'AttachmentCacheFolderName', 'VAR_87': 'UseEmbeddedSubtitleFonts', 'CLASS_8': 'property', 'ID_0': 'property', 'VAR_88': 'property', 'VAR_89': 'bool', 'VAR_90': 'int', 'VAR_91': 'MaxVideoThreads', 'VAR_92': 'double', 'FUNC_4': 'set', 'VAR_93': 'value', 'VAR_94': 'throw', 'VAR_95': 'm_CharacterEncoding', 'FUNC_5': 'get', 'VAR_96': 'TimeSpan', 'VAR_97': 'DefaultSubtitleDelay', 'VAR_98': 'String', 'VAR_99': 'IsFrameGrabber', 'VAR_100': 'IsExternalSubtitleParser'} | c | Texto | 3.06% |
// REB 3/22/11 #25290 For ease of compatibility with the new unicode API, this method will
// function like the old PA_GetTextParameter.
// WJF 6/30/16 Win-21 LONG_PTR -> LONG
LONG PA_GetTextParameter(PA_PluginParameters params, short index, char* text)
{
PA_Unistring *UnistringText;
LONG length;
char *textParameter;
size_t numChars;
UnistringText = PA_GetStringParameter(params, index);
if (text != 0L){
textParameter = malloc((UnistringText->fLength + 1) * sizeof(char));
memset(textParameter, 0, ((UnistringText->fLength + 1) * sizeof(char)));
wcstombs_s(&numChars, textParameter, MAXBUF, UnistringText->fString, UnistringText->fLength);
textParameter[strlen(textParameter)] = '\0';
strcpy_s(text, 32000, textParameter);
free(textParameter);
length = (LONG)strlen(text);
}
else{
length = UnistringText->fLength;
}
return length;
} | // REB 3/22/11 #25290 For ease of compatibility with the new unicode API, this method will
// function like the old PA_GetTextParameter.
// WJF 6/30/16 Win-21 LONG_PTR -> LONG
CLASS_0 FUNC_0(CLASS_1 VAR_0, short VAR_1, char* VAR_2)
{
CLASS_2 *VAR_3;
CLASS_0 length;
char *VAR_4;
size_t VAR_5;
VAR_3 = FUNC_1(VAR_0, VAR_1);
if (VAR_2 != 0L){
VAR_4 = FUNC_2((VAR_3->VAR_6 + 1) * sizeof(char));
FUNC_3(VAR_4, 0, ((VAR_3->VAR_6 + 1) * sizeof(char)));
FUNC_4(&VAR_5, VAR_4, VAR_7, VAR_3->VAR_8, VAR_3->VAR_6);
VAR_4[FUNC_5(VAR_4)] = '\0';
FUNC_6(VAR_2, 32000, VAR_4);
FUNC_7(VAR_4);
length = (ID_0)FUNC_5(VAR_2);
}
else{
length = VAR_3->VAR_6;
}
return length;
} | 0.930909 | {'CLASS_0': 'LONG', 'ID_0': 'LONG', 'FUNC_0': 'PA_GetTextParameter', 'CLASS_1': 'PA_PluginParameters', 'VAR_0': 'params', 'VAR_1': 'index', 'VAR_2': 'text', 'CLASS_2': 'PA_Unistring', 'VAR_3': 'UnistringText', 'VAR_4': 'textParameter', 'VAR_5': 'numChars', 'FUNC_1': 'PA_GetStringParameter', 'FUNC_2': 'malloc', 'VAR_6': 'fLength', 'FUNC_3': 'memset', 'FUNC_4': 'wcstombs_s', 'VAR_7': 'MAXBUF', 'VAR_8': 'fString', 'FUNC_5': 'strlen', 'FUNC_6': 'strcpy_s', 'FUNC_7': 'free'} | c | Procedural | 100.00% |
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2011-2013. 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.
*
* %CopyrightEnd%
*/
#include "erl_driver.h"
#define NO_ASYNC_JOBS 10000
static void stop(ErlDrvData drv_data);
static ErlDrvData start(ErlDrvPort port,
char *command);
static void output(ErlDrvData drv_data,
char *buf, ErlDrvSizeT len);
static void ready_async(ErlDrvData drv_data,
ErlDrvThreadData thread_data);
static ErlDrvEntry async_blast_drv_entry = {
NULL /* init */,
start,
stop,
output,
NULL /* ready_input */,
NULL /* ready_output */,
"async_blast_drv",
NULL /* finish */,
NULL /* handle */,
NULL /* control */,
NULL /* timeout */,
NULL /* outputv */,
ready_async,
NULL /* flush */,
NULL /* call */,
NULL /* event */,
ERL_DRV_EXTENDED_MARKER,
ERL_DRV_EXTENDED_MAJOR_VERSION,
ERL_DRV_EXTENDED_MINOR_VERSION,
ERL_DRV_FLAG_USE_PORT_LOCKING,
NULL /* handle2 */,
NULL /* handle_monitor */
};
typedef struct {
ErlDrvPort port;
ErlDrvTermData port_id;
ErlDrvTermData caller;
int counter;
} async_blast_data_t;
DRIVER_INIT(async_blast_drv)
{
return &async_blast_drv_entry;
}
static void stop(ErlDrvData drv_data)
{
driver_free((void *) drv_data);
}
static ErlDrvData start(ErlDrvPort port,
char *command)
{
async_blast_data_t *abd;
abd = driver_alloc(sizeof(async_blast_data_t));
if (!abd)
return ERL_DRV_ERROR_GENERAL;
abd->port = port;
abd->port_id = driver_mk_port(port);
abd->counter = 0;
return (ErlDrvData) abd;
}
static void async_invoke(void *data)
{
}
#include <stdio.h>
static void ready_async(ErlDrvData drv_data,
ErlDrvThreadData thread_data)
{
async_blast_data_t *abd = (async_blast_data_t *) drv_data;
if (--abd->counter == 0) {
ErlDrvTermData spec[] = {
ERL_DRV_PORT, abd->port_id,
ERL_DRV_ATOM, driver_mk_atom("done"),
ERL_DRV_TUPLE, 2
};
erl_drv_send_term(abd->port_id, abd->caller,
spec, sizeof(spec)/sizeof(spec[0]));
}
}
static void output(ErlDrvData drv_data,
char *buf, ErlDrvSizeT len)
{
async_blast_data_t *abd = (async_blast_data_t *) drv_data;
if (abd->counter == 0) {
int i;
abd->caller = driver_caller(abd->port);
abd->counter = NO_ASYNC_JOBS;
for (i = 0; i < NO_ASYNC_JOBS; i++) {
if (0 > driver_async(abd->port, NULL, async_invoke, NULL, NULL)) {
driver_failure_atom(abd->port, "driver_async_failed");
break;
}
}
}
}
| /*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2011-2013. 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.
*
* %CopyrightEnd%
*/
#include "erl_driver.h"
#define NO_ASYNC_JOBS 10000
static void stop(CLASS_0 VAR_0);
static CLASS_0 FUNC_0(CLASS_1 port,
char *VAR_2);
static void FUNC_1(CLASS_0 VAR_0,
char *VAR_4, CLASS_2 VAR_5);
static void FUNC_2(CLASS_0 VAR_0,
CLASS_3 VAR_7);
static CLASS_4 async_blast_drv_entry = {
NULL /* init */,
VAR_1,
stop,
VAR_3,
NULL /* ready_input */,
NULL /* ready_output */,
"async_blast_drv",
NULL /* finish */,
NULL /* handle */,
NULL /* control */,
NULL /* timeout */,
NULL /* outputv */,
VAR_6,
NULL /* flush */,
NULL /* call */,
NULL /* event */,
VAR_8,
VAR_9,
VAR_10,
ERL_DRV_FLAG_USE_PORT_LOCKING,
NULL /* handle2 */,
NULL /* handle_monitor */
};
typedef struct {
CLASS_1 port;
CLASS_5 port_id;
CLASS_5 caller;
int VAR_11;
} ID_1;
DRIVER_INIT(VAR_13)
{
return &async_blast_drv_entry;
}
static void stop(CLASS_0 VAR_0)
{
FUNC_3((void *) VAR_0);
}
static CLASS_0 FUNC_0(CLASS_1 port,
char *VAR_2)
{
CLASS_6 *abd;
abd = driver_alloc(sizeof(VAR_12));
if (!abd)
return ERL_DRV_ERROR_GENERAL;
abd->port = port;
abd->port_id = driver_mk_port(port);
abd->VAR_11 = 0;
return (ID_0) abd;
}
static void async_invoke(void *data)
{
}
#include <IMPORT_0>
static void FUNC_2(CLASS_0 VAR_0,
CLASS_3 VAR_7)
{
CLASS_6 *abd = (CLASS_6 *) VAR_0;
if (--abd->VAR_11 == 0) {
CLASS_5 VAR_14[] = {
VAR_15, abd->port_id,
VAR_16, driver_mk_atom("done"),
VAR_17, 2
};
erl_drv_send_term(abd->port_id, abd->caller,
VAR_14, sizeof(VAR_14)/sizeof(VAR_14[0]));
}
}
static void FUNC_1(CLASS_0 VAR_0,
char *VAR_4, CLASS_2 VAR_5)
{
CLASS_6 *abd = (CLASS_6 *) VAR_0;
if (abd->VAR_11 == 0) {
int VAR_18;
abd->caller = FUNC_4(abd->port);
abd->VAR_11 = NO_ASYNC_JOBS;
for (VAR_18 = 0; VAR_18 < NO_ASYNC_JOBS; VAR_18++) {
if (0 > FUNC_5(abd->port, NULL, async_invoke, NULL, NULL)) {
FUNC_6(abd->port, "driver_async_failed");
break;
}
}
}
}
| 0.712752 | {'CLASS_0': 'ErlDrvData', 'ID_0': 'ErlDrvData', 'VAR_0': 'drv_data', 'FUNC_0': 'start', 'VAR_1': 'start', 'CLASS_1': 'ErlDrvPort', 'VAR_2': 'command', 'FUNC_1': 'output', 'VAR_3': 'output', 'VAR_4': 'buf', 'CLASS_2': 'ErlDrvSizeT', 'VAR_5': 'len', 'FUNC_2': 'ready_async', 'VAR_6': 'ready_async', 'CLASS_3': 'ErlDrvThreadData', 'VAR_7': 'thread_data', 'CLASS_4': 'ErlDrvEntry', 'VAR_8': 'ERL_DRV_EXTENDED_MARKER', 'VAR_9': 'ERL_DRV_EXTENDED_MAJOR_VERSION', 'VAR_10': 'ERL_DRV_EXTENDED_MINOR_VERSION', 'CLASS_5': 'ErlDrvTermData', 'VAR_11': 'counter', 'ID_1': 'async_blast_data_t', 'CLASS_6': 'async_blast_data_t', 'VAR_12': 'async_blast_data_t', 'VAR_13': 'async_blast_drv', 'FUNC_3': 'driver_free', 'IMPORT_0': 'stdio.h', 'VAR_14': 'spec', 'VAR_15': 'ERL_DRV_PORT', 'VAR_16': 'ERL_DRV_ATOM', 'VAR_17': 'ERL_DRV_TUPLE', 'VAR_18': 'i', 'FUNC_4': 'driver_caller', 'FUNC_5': 'driver_async', 'FUNC_6': 'driver_failure_atom'} | c | Procedural | 34.92% |
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* <NAME> <<EMAIL>>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
/*!
* @class OFReadOrWriteFailedException \
* OFReadOrWriteFailedException.h ObjFW/OFReadOrWriteFailedException.h
*
* @brief An exception indicating that reading from or writing to an object
* failed.
*/
@interface OFReadOrWriteFailedException: OFException
{
id _object;
size_t _requestedLength;
int _errNo;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) id object;
@property (readonly) size_t requestedLength;
@property (readonly) int errNo;
#endif
/*!
* @brief Creates a new, autoreleased read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @return A new, autoreleased read or write failed exception
*/
+ (instancetype)exceptionWithObject: (id)object
requestedLength: (size_t)requestedLength;
/*!
* @brief Creates a new, autoreleased read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @param errNo The errno of the error that occurred
* @return A new, autoreleased read or write failed exception
*/
+ (instancetype)exceptionWithObject: (id)object
requestedLength: (size_t)requestedLength
errNo: (int)errNo;
/*!
* @brief Initializes an already allocated read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @return A new open file failed exception
*/
- initWithObject: (id)object
requestedLength: (size_t)requestedLength;
/*!
* @brief Initializes an already allocated read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @param errNo The errno of the error that occurred
* @return A new open file failed exception
*/
- initWithObject: (id)object
requestedLength: (size_t)requestedLength
errNo: (int)errNo;
/*!
* @brief Returns the object from which reading or to which writing failed
*
* @return The stream which caused the read or write failed exception
*/
- (id)object;
/*!
* @brief Returns the requested length of the data that couldn't be read /
* written.
*
* @return The requested length of the data that couldn't be read / written
*/
- (size_t)requestedLength;
/*!
* @brief Returns the errno of the error that occurred.
*
* @return The errno of the error that occurred
*/
- (int)errNo;
@end
| /*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* <NAME> <<EMAIL>>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
/*!
* @class OFReadOrWriteFailedException \
* OFReadOrWriteFailedException.h ObjFW/OFReadOrWriteFailedException.h
*
* @brief An exception indicating that reading from or writing to an object
* failed.
*/
@interface VAR_0: VAR_1
{
CLASS_0 VAR_3;
size_t VAR_4;
int _errNo;
}
#ifdef OF_HAVE_PROPERTIES
@FUNC_0 (VAR_6, VAR_7) CLASS_0 object;
@VAR_5 (ID_1) size_t VAR_8;
@VAR_5 (ID_1) VAR_9 VAR_10;
#endif
/*!
* @brief Creates a new, autoreleased read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @return A new, autoreleased read or write failed exception
*/
+ (ID_2)VAR_11: (VAR_2)object
requestedLength: (size_t)VAR_8;
/*!
* @brief Creates a new, autoreleased read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @param errNo The errno of the error that occurred
* @return A new, autoreleased read or write failed exception
*/
+ (ID_2)VAR_11: (VAR_2)object
requestedLength: (size_t)VAR_8
errNo: (int)VAR_10;
/*!
* @brief Initializes an already allocated read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @return A new open file failed exception
*/
- VAR_12: (VAR_2)object
requestedLength: (size_t)VAR_8;
/*!
* @brief Initializes an already allocated read or write failed exception.
*
* @param object The object from which reading or to which writing failed
* @param requestedLength The requested length of the data that couldn't be
* read / written
* @param errNo The errno of the error that occurred
* @return A new open file failed exception
*/
- VAR_12: (VAR_2)object
requestedLength: (size_t)VAR_8
errNo: (int)VAR_10;
/*!
* @brief Returns the object from which reading or to which writing failed
*
* @return The stream which caused the read or write failed exception
*/
- (ID_0)object;
/*!
* @brief Returns the requested length of the data that couldn't be read /
* written.
*
* @return The requested length of the data that couldn't be read / written
*/
- (size_t)VAR_8;
/*!
* @brief Returns the errno of the error that occurred.
*
* @return The errno of the error that occurred
*/
- (int)VAR_10;
@CLASS_1
| 0.865895 | {'VAR_0': 'OFReadOrWriteFailedException', 'VAR_1': 'OFException', 'CLASS_0': 'id', 'VAR_2': 'id', 'ID_0': 'id', 'VAR_3': '_object', 'VAR_4': '_requestedLength', 'FUNC_0': 'property', 'VAR_5': 'property', 'VAR_6': 'readonly', 'ID_1': 'readonly', 'VAR_7': 'retain', 'VAR_8': 'requestedLength', 'VAR_9': 'int', 'VAR_10': 'errNo', 'ID_2': 'instancetype', 'VAR_11': 'exceptionWithObject', 'VAR_12': 'initWithObject', 'CLASS_1': 'end'} | c | Procedural | 22.63% |
/* _set_current_refresh_rate:
* Sets the current refresh rate.
* (This function must be called by the gfx drivers)
*/
void _set_current_refresh_rate(int rate)
{
if ((rate<40) || (rate>200))
rate = 0;
current_refresh_rate = rate;
_vsync_speed = rate ? BPS_TO_TIMER(rate) : BPS_TO_TIMER(70);
} | /* _set_current_refresh_rate:
* Sets the current refresh rate.
* (This function must be called by the gfx drivers)
*/
void FUNC_0(int VAR_0)
{
if ((VAR_0<40) || (VAR_0>200))
VAR_0 = 0;
current_refresh_rate = VAR_0;
_vsync_speed = VAR_0 ? FUNC_1(VAR_0) : FUNC_1(70);
} | 0.819044 | {'FUNC_0': '_set_current_refresh_rate', 'VAR_0': 'rate', 'FUNC_1': 'BPS_TO_TIMER'} | c | Procedural | 100.00% |
#ifndef IMPROVEDMATH_H
#define IMPROVEDMATH_H
//GLM
#include <GLM/glm.hpp>
#include <GLM/GTC/type_ptr.hpp>
//GLEW
#include <GL/glew.h>
//Namespace declaration: our
namespace our {
//Class definition: Matrix4GLMHelper
class Matrix4GLMHelper {
public:
//NOT SAFE SOLUTION
glm::mat4 value;
//Std constructor
Matrix4GLMHelper() : value(glm::mat4()) {}
//Copy constructor
Matrix4GLMHelper(Matrix4GLMHelper& other) : value(other.value) {}
//Move constructor
Matrix4GLMHelper(Matrix4GLMHelper&& other) : value(std::move(other.value)) {}
Matrix4GLMHelper(glm::mat4 _matrix) : value(std::move(_matrix)) {}
//Get value pointer for OpenGL
GLfloat* getValuePtr() {
//Solution from GTC/type_ptr.inl
return &(value[0].x);
}
operator glm::mat4() {
return value;
}
//TODO: make all available operators for glm::mat4, then make value private
};
//Define a short type name
typedef Matrix4GLMHelper mat4;
//Our perspective matrix builder
mat4 perspective(float fovy, float aspect, float near, float far) {
return glm::perspective(fovy, aspect, near, far);
}
//Our otho matrix builder
mat4 ortho(float left, float right, float bottom, float top, float near, float far) {
return glm::ortho(left, right, bottom, top, near, far);
}
//Our lookAt matrix builder
mat4 lookAt(glm::vec3 &eye, glm::vec3 ¢er, glm::vec3 &up) {
return glm::lookAt(eye, center, up);
}
//Our rotate with our::mat4 as argument
mat4 rotate(mat4 const &m, float angle, glm::vec3 const &axis) {
return glm::rotate(m.value, angle, axis);
}
//Our rotate with glm::mat4 as argument
mat4 rotate(glm::mat4 const &m, float angle, glm::vec3 const &axis) {
return glm::rotate(m, angle, axis);
}
//Our translate with our::mat4 as argument
mat4 translate(mat4 const &m, glm::vec3 const &v) {
return glm::translate(m.value, v);
}
//Our translate with glm::mat4 as argument
mat4 translate(glm::mat4 const &m, glm::vec3 const &v) {
return glm::translate(m, v);
}
//Our scale with our::mat4 as argument
mat4 scale(mat4 const &m, glm::vec3 const &v) {
return glm::scale(m.value, v);
}
//Our scale with glm::mat4 as argument
mat4 scale(glm::mat4 const &m, glm::vec3 const &v) {
return glm::scale(m, v);
}
}
#endif | #ifndef IMPROVEDMATH_H
#define IMPROVEDMATH_H
//GLM
#include <GLM/glm.hpp>
#include <GLM/GTC/type_ptr.hpp>
//GLEW
#include <GL/glew.h>
//Namespace declaration: our
namespace our {
//Class definition: Matrix4GLMHelper
class Matrix4GLMHelper {
public:
//NOT SAFE SOLUTION
glm::mat4 value;
//Std constructor
Matrix4GLMHelper() : value(ID_0::mat4()) {}
//Copy constructor
Matrix4GLMHelper(Matrix4GLMHelper& other) : value(other.value) {}
//Move constructor
Matrix4GLMHelper(Matrix4GLMHelper&& other) : value(std::move(other.value)) {}
Matrix4GLMHelper(ID_0::mat4 _matrix) : value(std::move(_matrix)) {}
//Get value pointer for OpenGL
GLfloat* getValuePtr() {
//Solution from GTC/type_ptr.inl
return &(value[0].x);
}
operator VAR_0::mat4() {
return value;
}
//TODO: make all available operators for glm::mat4, then make value private
};
//Define a short type name
typedef Matrix4GLMHelper mat4;
//Our perspective matrix builder
mat4 perspective(float fovy, float aspect, float near, float far) {
return VAR_0::perspective(fovy, aspect, near, far);
}
//Our otho matrix builder
mat4 ortho(float VAR_1, float right, float bottom, float top, float near, float far) {
return VAR_0::ortho(VAR_1, right, bottom, top, near, far);
}
//Our lookAt matrix builder
mat4 lookAt(CLASS_0::vec3 &eye, CLASS_0::vec3 ¢er, CLASS_0::vec3 &up) {
return VAR_0::lookAt(eye, center, up);
}
//Our rotate with our::mat4 as argument
mat4 rotate(mat4 const &m, float angle, CLASS_0::vec3 const &axis) {
return VAR_0::rotate(m.value, angle, axis);
}
//Our rotate with glm::mat4 as argument
mat4 rotate(CLASS_0::mat4 const &m, float angle, CLASS_0::vec3 const &axis) {
return VAR_0::rotate(m, angle, axis);
}
//Our translate with our::mat4 as argument
mat4 translate(mat4 const &m, CLASS_0::vec3 const &v) {
return VAR_0::translate(m.value, v);
}
//Our translate with glm::mat4 as argument
mat4 translate(CLASS_0::mat4 const &m, CLASS_0::vec3 const &v) {
return VAR_0::translate(m, v);
}
//Our scale with our::mat4 as argument
mat4 scale(mat4 const &m, CLASS_0::vec3 const &v) {
return VAR_0::scale(m.value, v);
}
//Our scale with glm::mat4 as argument
mat4 scale(CLASS_0::mat4 const &m, CLASS_0::vec3 const &v) {
return VAR_0::scale(m, v);
}
}
#endif | 0.079359 | {'ID_0': 'glm', 'VAR_0': 'glm', 'CLASS_0': 'glm', 'VAR_1': 'left'} | c | Texto | 6.05% |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
// Each called version should have an IFunc.
// CHECK: @SingleVersion.ifunc = ifunc void (), void ()* ()* @SingleVersion.resolver
// CHECK: @TwoVersions.ifunc = ifunc void (), void ()* ()* @TwoVersions.resolver
// CHECK: @TwoVersionsSameAttr.ifunc = ifunc void (), void ()* ()* @TwoVersionsSameAttr.resolver
// CHECK: @ThreeVersionsSameAttr.ifunc = ifunc void (), void ()* ()* @ThreeVersionsSameAttr.resolver
__attribute__((cpu_specific(ivybridge)))
void SingleVersion(void){}
// CHECK: define void @SingleVersion.S() #[[S:[0-9]+]]
__attribute__((cpu_specific(ivybridge)))
void NotCalled(void){}
// CHECK: define void @NotCalled.S() #[[S]]
// Done before any of the implementations.
__attribute__((cpu_dispatch(ivybridge, knl)))
void TwoVersions(void);
// CHECK: define void ()* @TwoVersions.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @TwoVersions.Z
// CHECK: ret void ()* @TwoVersions.S
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((cpu_specific(ivybridge)))
void TwoVersions(void){}
// CHECK: define void @TwoVersions.S() #[[S]]
__attribute__((cpu_specific(knl)))
void TwoVersions(void){}
// CHECK: define void @TwoVersions.Z() #[[K:[0-9]+]]
__attribute__((cpu_specific(ivybridge, knl)))
void TwoVersionsSameAttr(void){}
// CHECK: define void @TwoVersionsSameAttr.S() #[[S]]
// CHECK: define void @TwoVersionsSameAttr.Z() #[[K]]
__attribute__((cpu_specific(atom, ivybridge, knl)))
void ThreeVersionsSameAttr(void){}
// CHECK: define void @ThreeVersionsSameAttr.O() #[[O:[0-9]+]]
// CHECK: define void @ThreeVersionsSameAttr.S() #[[S]]
// CHECK: define void @ThreeVersionsSameAttr.Z() #[[K]]
void usages() {
SingleVersion();
// CHECK: @SingleVersion.ifunc()
TwoVersions();
// CHECK: @TwoVersions.ifunc()
TwoVersionsSameAttr();
// CHECK: @TwoVersionsSameAttr.ifunc()
ThreeVersionsSameAttr();
// CHECK: @ThreeVersionsSameAttr.ifunc()
}
// has an extra config to emit!
__attribute__((cpu_dispatch(ivybridge, knl, atom)))
void TwoVersionsSameAttr(void);
// CHECK: define void ()* @TwoVersionsSameAttr.resolver()
// CHECK: ret void ()* @TwoVersionsSameAttr.Z
// CHECK: ret void ()* @TwoVersionsSameAttr.S
// CHECK: ret void ()* @TwoVersionsSameAttr.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((cpu_dispatch(atom, ivybridge, knl)))
void ThreeVersionsSameAttr(void){}
// CHECK: define void ()* @ThreeVersionsSameAttr.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @ThreeVersionsSameAttr.Z
// CHECK: ret void ()* @ThreeVersionsSameAttr.S
// CHECK: ret void ()* @ThreeVersionsSameAttr.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
// No Cpu Specific options.
__attribute__((cpu_dispatch(atom, ivybridge, knl)))
void NoSpecifics(void);
// CHECK: define void ()* @NoSpecifics.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @NoSpecifics.Z
// CHECK: ret void ()* @NoSpecifics.S
// CHECK: ret void ()* @NoSpecifics.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((cpu_dispatch(atom, generic, ivybridge, knl)))
void HasGeneric(void);
// CHECK: define void ()* @HasGeneric.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @HasGeneric.Z
// CHECK: ret void ()* @HasGeneric.S
// CHECK: ret void ()* @HasGeneric.O
// CHECK: ret void ()* @HasGeneric.A
// CHECK-NOT: call void @llvm.trap
// CHECK: attributes #[[S]] = {{.*}}"target-features"="+avx,+cmov,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
// CHECK: attributes #[[K]] = {{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
// CHECK: attributes #[[O]] = {{.*}}"target-features"="+cmov,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
| // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
// Each called version should have an IFunc.
// CHECK: @SingleVersion.ifunc = ifunc void (), void ()* ()* @SingleVersion.resolver
// CHECK: @TwoVersions.ifunc = ifunc void (), void ()* ()* @TwoVersions.resolver
// CHECK: @TwoVersionsSameAttr.ifunc = ifunc void (), void ()* ()* @TwoVersionsSameAttr.resolver
// CHECK: @ThreeVersionsSameAttr.ifunc = ifunc void (), void ()* ()* @ThreeVersionsSameAttr.resolver
__attribute__((cpu_specific(ivybridge)))
void FUNC_0(void){}
// CHECK: define void @SingleVersion.S() #[[S:[0-9]+]]
__attribute__((cpu_specific(ivybridge)))
void FUNC_1(void){}
// CHECK: define void @NotCalled.S() #[[S]]
// Done before any of the implementations.
__attribute__((FUNC_2(ivybridge, VAR_0)))
void TwoVersions(void);
// CHECK: define void ()* @TwoVersions.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @TwoVersions.Z
// CHECK: ret void ()* @TwoVersions.S
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((cpu_specific(ivybridge)))
void TwoVersions(void){}
// CHECK: define void @TwoVersions.S() #[[S]]
__attribute__((cpu_specific(VAR_0)))
void TwoVersions(void){}
// CHECK: define void @TwoVersions.Z() #[[K:[0-9]+]]
__attribute__((cpu_specific(ivybridge, VAR_0)))
void TwoVersionsSameAttr(void){}
// CHECK: define void @TwoVersionsSameAttr.S() #[[S]]
// CHECK: define void @TwoVersionsSameAttr.Z() #[[K]]
__attribute__((cpu_specific(VAR_1, ivybridge, VAR_0)))
void ThreeVersionsSameAttr(void){}
// CHECK: define void @ThreeVersionsSameAttr.O() #[[O:[0-9]+]]
// CHECK: define void @ThreeVersionsSameAttr.S() #[[S]]
// CHECK: define void @ThreeVersionsSameAttr.Z() #[[K]]
void FUNC_3() {
FUNC_0();
// CHECK: @SingleVersion.ifunc()
TwoVersions();
// CHECK: @TwoVersions.ifunc()
TwoVersionsSameAttr();
// CHECK: @TwoVersionsSameAttr.ifunc()
ThreeVersionsSameAttr();
// CHECK: @ThreeVersionsSameAttr.ifunc()
}
// has an extra config to emit!
__attribute__((FUNC_2(ivybridge, VAR_0, VAR_1)))
void TwoVersionsSameAttr(void);
// CHECK: define void ()* @TwoVersionsSameAttr.resolver()
// CHECK: ret void ()* @TwoVersionsSameAttr.Z
// CHECK: ret void ()* @TwoVersionsSameAttr.S
// CHECK: ret void ()* @TwoVersionsSameAttr.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((FUNC_2(VAR_1, ivybridge, VAR_0)))
void ThreeVersionsSameAttr(void){}
// CHECK: define void ()* @ThreeVersionsSameAttr.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @ThreeVersionsSameAttr.Z
// CHECK: ret void ()* @ThreeVersionsSameAttr.S
// CHECK: ret void ()* @ThreeVersionsSameAttr.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
// No Cpu Specific options.
__attribute__((FUNC_2(VAR_1, ivybridge, VAR_0)))
void NoSpecifics(void);
// CHECK: define void ()* @NoSpecifics.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @NoSpecifics.Z
// CHECK: ret void ()* @NoSpecifics.S
// CHECK: ret void ()* @NoSpecifics.O
// CHECK: call void @llvm.trap
// CHECK: unreachable
__attribute__((FUNC_2(VAR_1, VAR_2, ivybridge, VAR_0)))
void HasGeneric(void);
// CHECK: define void ()* @HasGeneric.resolver()
// CHECK: call void @__cpu_indicator_init
// CHECK: ret void ()* @HasGeneric.Z
// CHECK: ret void ()* @HasGeneric.S
// CHECK: ret void ()* @HasGeneric.O
// CHECK: ret void ()* @HasGeneric.A
// CHECK-NOT: call void @llvm.trap
// CHECK: attributes #[[S]] = {{.*}}"target-features"="+avx,+cmov,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
// CHECK: attributes #[[K]] = {{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
// CHECK: attributes #[[O]] = {{.*}}"target-features"="+cmov,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
| 0.721924 | {'FUNC_0': 'SingleVersion', 'FUNC_1': 'NotCalled', 'FUNC_2': 'cpu_dispatch', 'VAR_0': 'knl', 'VAR_1': 'atom', 'FUNC_3': 'usages', 'VAR_2': 'generic'} | c | Procedural | 97.18% |
#include <stdio.h>
#include <string.h>
/***** Problem 16 on Practice Test 2 *****/
// The main thing to learn here is how the pointer p is used to iterate through the string.
// Note the pointer to the original string is sent to the function and the string itself is changed.
// Without the pointer p the change to the string within the function would be temporary.
void replace(char *str, char x, char y);
int main(void) {
/* There is a nice article on strings in C here: https://www.geeksforgeeks.org/strings-in-c-2/
Here are four ways to declare a string according to the article:
char str[] = "Pamplona";
char str[21] = "Pamplona";
char str[] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
char str[9] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
*/
char s[9] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
// char s[21] = "Pamplona";
printf("Before: %s\n", s);
replace(s, 'a', 'o');
printf("After: %s\n", s);
return 0;
}
void replace(char *str, char x, char y) {
for(char *p = str; *p != '\0'; p++) {
if (*p == x) {
*p = y;
}
}
}
/********************* OUTPUT **************************
Before: Pamplona
After: Pomplono
********************************************************/ | #include <IMPORT_0>
#include <string.h>
/***** Problem 16 on Practice Test 2 *****/
// The main thing to learn here is how the pointer p is used to iterate through the string.
// Note the pointer to the original string is sent to the function and the string itself is changed.
// Without the pointer p the change to the string within the function would be temporary.
void FUNC_0(char *str, char VAR_0, char y);
int main(void) {
/* There is a nice article on strings in C here: https://www.geeksforgeeks.org/strings-in-c-2/
Here are four ways to declare a string according to the article:
char str[] = "Pamplona";
char str[21] = "Pamplona";
char str[] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
char str[9] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
*/
char VAR_1[9] = {'P', 'a', 'm', 'p', 'l', 'o', 'n', 'a', '\0'};
// char s[21] = "Pamplona";
FUNC_1("Before: %s\n", VAR_1);
FUNC_0(VAR_1, 'a', 'o');
FUNC_1("After: %s\n", VAR_1);
return 0;
}
void FUNC_0(char *str, char VAR_0, char y) {
for(char *VAR_2 = str; *VAR_2 != '\0'; VAR_2++) {
if (*VAR_2 == VAR_0) {
*VAR_2 = y;
}
}
}
/********************* OUTPUT **************************
Before: Pamplona
After: Pomplono
********************************************************/ | 0.413331 | {'IMPORT_0': 'stdio.h', 'FUNC_0': 'replace', 'VAR_0': 'x', 'VAR_1': 's', 'FUNC_1': 'printf', 'VAR_2': 'p'} | c | Procedural | 100.00% |
/******************************************************************************
* Function Name: intriicsti_proc_handler
* Description : ISR process function of STI interrupt.
* Arguments : channel - The channel number where interrupt occurred.
* Return Value : None.
******************************************************************************/
static void intriicsti_proc_handler (int_t channel)
{
uint32_t dummy;
r_riic_hld_set_start_asserted(channel);
dummy = RZA_IO_RegRead_32((volatile uint32_t *) &gsp_riic[channel]->ICSR2.LONG, RIIC_ICSR2_START_SHIFT,
RIIC_ICSR2_START);
RZA_IO_RegWrite_32((volatile uint32_t *) &gsp_riic[channel]->ICSR2.LONG, 0, RIIC_ICSR2_START_SHIFT,
RIIC_ICSR2_START);
} | /******************************************************************************
* Function Name: intriicsti_proc_handler
* Description : ISR process function of STI interrupt.
* Arguments : channel - The channel number where interrupt occurred.
* Return Value : None.
******************************************************************************/
static void intriicsti_proc_handler (CLASS_0 VAR_0)
{
uint32_t dummy;
r_riic_hld_set_start_asserted(VAR_0);
dummy = RZA_IO_RegRead_32((volatile uint32_t *) &gsp_riic[VAR_0]->ICSR2.LONG, RIIC_ICSR2_START_SHIFT,
RIIC_ICSR2_START);
RZA_IO_RegWrite_32((volatile uint32_t *) &gsp_riic[VAR_0]->ICSR2.LONG, 0, RIIC_ICSR2_START_SHIFT,
RIIC_ICSR2_START);
} | 0.290189 | {'CLASS_0': 'int_t', 'VAR_0': 'channel'} | c | Procedural | 100.00% |
/*
* Returns a string to uint64_t.
* No error checking is done, we make the following assumptions:
* - len > 0
* - string can only contain characters [0..9] and no signs
*/
uint64_t xstr_to_uint64(const char * src, size_t len)
{
char * pt = (char *) src;
uint64_t i = *pt - '0';
while (--len && isdigit(*(++pt)))
{
i = 10 * i + *pt - '0';
}
return i;
} | /*
* Returns a string to uint64_t.
* No error checking is done, we make the following assumptions:
* - len > 0
* - string can only contain characters [0..9] and no signs
*/
uint64_t FUNC_0(const char * VAR_0, size_t VAR_1)
{
char * pt = (char *) VAR_0;
uint64_t VAR_2 = *pt - '0';
while (--VAR_1 && FUNC_1(*(++pt)))
{
VAR_2 = 10 * VAR_2 + *pt - '0';
}
return VAR_2;
} | 0.628717 | {'FUNC_0': 'xstr_to_uint64', 'VAR_0': 'src', 'VAR_1': 'len', 'VAR_2': 'i', 'FUNC_1': 'isdigit'} | c | Procedural | 100.00% |
//******************************************************************************
/// \brief Allocate kernel log buffer
void dmesg_free_buffer(struct mxt_device *mxt)
{
free(mxt->sysfs.debug_msg_buf);
mxt->sysfs.debug_msg_buf = NULL;
} | //******************************************************************************
/// \brief Allocate kernel log buffer
void FUNC_0(struct CLASS_0 *mxt)
{
FUNC_1(mxt->VAR_0.debug_msg_buf);
mxt->VAR_0.debug_msg_buf = NULL;
} | 0.770712 | {'FUNC_0': 'dmesg_free_buffer', 'CLASS_0': 'mxt_device', 'FUNC_1': 'free', 'VAR_0': 'sysfs'} | c | Procedural | 37.50% |
#pragma once
#include <string>
#include <vector>
class HIBPPolicyEvaluator
{
public:
HIBPPolicyEvaluator();
~HIBPPolicyEvaluator();
bool IsAcceptablePassword(const std::wstring& password);
private:
std::wstring CalculateHash(const std::wstring& input);
std::wstring GetHashBucket(const std::wstring& input);
};
| #pragma once
#include <string>
#include <IMPORT_0>
CLASS_0 HIBPPolicyEvaluator
{
public:
HIBPPolicyEvaluator();
~HIBPPolicyEvaluator();
bool IsAcceptablePassword(const std::wstring& password);
private:
std::wstring CalculateHash(VAR_0 std::wstring& input);
std::wstring GetHashBucket(VAR_0 std::wstring& input);
};
| 0.386229 | {'IMPORT_0': 'vector', 'CLASS_0': 'class', 'VAR_0': 'const'} | c | OOP | 100.00% |
//-----------------------------------------------------------------------------
// ExternalLobVar_New()
// Create a new external LOB variable.
//-----------------------------------------------------------------------------
PyObject *ExternalLobVar_New(
udt_LobVar *var,
unsigned pos)
{
TRACE("ExternalLobVar_New");
udt_ExternalLobVar *self;
self = (udt_ExternalLobVar*)
g_ExternalLobVarType.tp_alloc(&g_ExternalLobVarType, 0);
if (!self)
return NULL;
self->pos = pos;
self->internalFetchNum = var->internalFetchNum;
Py_INCREF(var);
self->lobVar = var;
PySys_WriteStderr("ExternalLobVar_New(pos=%d) size=%d\n", pos,
ExternalLobVar_InternalSize(self));
return (PyObject*) self;
} | //-----------------------------------------------------------------------------
// ExternalLobVar_New()
// Create a new external LOB variable.
//-----------------------------------------------------------------------------
CLASS_0 *ExternalLobVar_New(
CLASS_1 *var,
unsigned pos)
{
FUNC_0("ExternalLobVar_New");
udt_ExternalLobVar *self;
self = (udt_ExternalLobVar*)
g_ExternalLobVarType.tp_alloc(&g_ExternalLobVarType, 0);
if (!self)
return NULL;
self->pos = pos;
self->VAR_0 = var->VAR_0;
FUNC_1(var);
self->VAR_1 = var;
PySys_WriteStderr("ExternalLobVar_New(pos=%d) size=%d\n", pos,
ExternalLobVar_InternalSize(self));
return (CLASS_0*) self;
} | 0.165338 | {'CLASS_0': 'PyObject', 'CLASS_1': 'udt_LobVar', 'FUNC_0': 'TRACE', 'VAR_0': 'internalFetchNum', 'FUNC_1': 'Py_INCREF', 'VAR_1': 'lobVar'} | c | Procedural | 100.00% |
#ifndef HOMOGRAPHY_ESTIMATOR_H
#define HOMOGRAPHY_ESTIMATOR_H
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <image_geometry/pinhole_camera_model.h>
#include <dynamic_reconfigure/server.h>
#include "drive_ros_camera_homography/homography_estimatorConfig.h"
enum class Pattern {
CHESSBOARD,
CIRCLES,
CIRCLES_ASYMMETRIC
};
/**
* @brief homography_estimator
**/
class HomographyEstimator {
public:
HomographyEstimator(const ros::NodeHandle nh, const ros::NodeHandle pnh);
~HomographyEstimator();
private:
ros::NodeHandle nh_;
ros::NodeHandle pnh_;
ros::Subscriber cam_info_sub;
image_transport::ImageTransport it_;
image_transport::Subscriber image_sub_;
image_transport::Publisher image_pub_;
Pattern pattern;
cv::Size patternSize;
std::vector<cv::Point2f> worldPoints;
cv::Mat estimate;
cv::Mat refinement;
cv::Mat cam2world;
cv::Mat world2cam;
cv::Mat topView2cam;
cv::Size topViewSize;
image_geometry::PinholeCameraModel camera_model_;
bool calLoaded = false;
bool imgLoaded = false;
int outlineScaleFactor;
void initParameters();
void camInfoCb(const sensor_msgs::CameraInfo& info);
void imageCb(const sensor_msgs::ImageConstPtr& msg);
void computePatternPoints();
void saveHomography();
bool findPoints(const cv::Mat& img, std::vector<cv::Point2f>& points);
bool computeRefinement(const std::vector<cv::Point2f> detectedPoints);
void computeTopView();
// make this public so we can test it
cv::Point checkPointSize(const cv::Mat& img, const int x, const int y);
dynamic_reconfigure::Server<drive_ros_camera_homography::homography_estimatorConfig> dyn_rec_server;
dynamic_reconfigure::Server<drive_ros_camera_homography::homography_estimatorConfig>::CallbackType dyn_rec_cbtype;
void reconfigureCB(drive_ros_camera_homography::homography_estimatorConfig& config, uint32_t level);
drive_ros_camera_homography::homography_estimatorConfig cfg;
// Blob Detector
cv::Ptr<cv::SimpleBlobDetector> blobDetector;
cv::SimpleBlobDetector::Params getBlobDetectorParams();
};
#endif // HOMOGRAPHY_ESTIMATOR_H
| #ifndef HOMOGRAPHY_ESTIMATOR_H
#define HOMOGRAPHY_ESTIMATOR_H
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <image_geometry/pinhole_camera_model.h>
#include <dynamic_reconfigure/server.h>
#include "drive_ros_camera_homography/homography_estimatorConfig.h"
enum class Pattern {
CHESSBOARD,
CIRCLES,
CIRCLES_ASYMMETRIC
};
/**
* @brief homography_estimator
**/
class HomographyEstimator {
public:
HomographyEstimator(const ros::NodeHandle nh, const ros::NodeHandle pnh);
~HomographyEstimator();
private:
ros::NodeHandle nh_;
ros::NodeHandle VAR_0;
ros::Subscriber cam_info_sub;
image_transport::ImageTransport it_;
image_transport::Subscriber image_sub_;
image_transport::VAR_1 image_pub_;
Pattern pattern;
cv::Size VAR_2;
std::vector<cv::Point2f> VAR_3;
cv::Mat estimate;
cv::Mat VAR_4;
cv::Mat cam2world;
cv::Mat VAR_5;
cv::Mat VAR_6;
cv::Size topViewSize;
image_geometry::PinholeCameraModel camera_model_;
bool calLoaded = false;
bool imgLoaded = false;
int outlineScaleFactor;
void initParameters();
void FUNC_0(const sensor_msgs::CameraInfo& info);
void imageCb(const sensor_msgs::ImageConstPtr& VAR_7);
void computePatternPoints();
void saveHomography();
bool findPoints(const cv::Mat& img, std::vector<cv::Point2f>& points);
bool computeRefinement(const std::vector<cv::Point2f> detectedPoints);
void computeTopView();
// make this public so we can test it
cv::Point checkPointSize(const cv::Mat& img, const int x, const int y);
dynamic_reconfigure::VAR_8<drive_ros_camera_homography::homography_estimatorConfig> dyn_rec_server;
dynamic_reconfigure::VAR_8<drive_ros_camera_homography::homography_estimatorConfig>::CallbackType dyn_rec_cbtype;
void reconfigureCB(drive_ros_camera_homography::homography_estimatorConfig& config, uint32_t level);
drive_ros_camera_homography::homography_estimatorConfig cfg;
// Blob Detector
cv::VAR_9<cv::SimpleBlobDetector> blobDetector;
cv::SimpleBlobDetector::VAR_10 getBlobDetectorParams();
};
#endif // HOMOGRAPHY_ESTIMATOR_H
| 0.101184 | {'VAR_0': 'pnh_', 'VAR_1': 'Publisher', 'VAR_2': 'patternSize', 'VAR_3': 'worldPoints', 'VAR_4': 'refinement', 'VAR_5': 'world2cam', 'VAR_6': 'topView2cam', 'FUNC_0': 'camInfoCb', 'VAR_7': 'msg', 'VAR_8': 'Server', 'VAR_9': 'Ptr', 'VAR_10': 'Params'} | c | OOP | 100.00% |
/**************************************************************************
* X11DRV_DIB_CreateDIBFromPixmap
*
* Allocates a packed DIB and copies the Pixmap data into it.
* The Pixmap passed in is deleted after the conversion.
*/
HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc)
{
HDC hdcMem;
X_PHYSBITMAP *physBitmap;
Pixmap orig_pixmap;
HBITMAP hBmp = 0;
HGLOBAL hPackedDIB = 0;
Window root;
int x,y;
unsigned border_width;
unsigned int depth, width, height;
wine_tsx11_lock();
if (!XGetGeometry(gdi_display, pixmap, &root, &x, &y, &width, &height,
&border_width, &depth)) depth = 0;
wine_tsx11_unlock();
if (!depth) return 0;
TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n",
width, height, depth);
if (!(hBmp = CreateBitmap( width, height, 1, depth_to_bpp(depth), NULL ))) return 0;
hdcMem = CreateCompatibleDC( hdc );
SelectObject( hdcMem, SelectObject( hdcMem, hBmp ));
DeleteDC( hdcMem );
physBitmap = X11DRV_get_phys_bitmap( hBmp );
orig_pixmap = physBitmap->pixmap;
physBitmap->pixmap = pixmap;
hPackedDIB = X11DRV_DIB_CreateDIBFromBitmap(hdc, hBmp);
physBitmap->pixmap = orig_pixmap;
DeleteObject(hBmp);
TRACE("\tReturning packed DIB %p\n", hPackedDIB);
return hPackedDIB;
} | /**************************************************************************
* X11DRV_DIB_CreateDIBFromPixmap
*
* Allocates a packed DIB and copies the Pixmap data into it.
* The Pixmap passed in is deleted after the conversion.
*/
CLASS_0 X11DRV_DIB_CreateDIBFromPixmap(CLASS_1 VAR_0, HDC hdc)
{
HDC VAR_1;
X_PHYSBITMAP *VAR_2;
CLASS_1 orig_pixmap;
CLASS_2 VAR_3 = 0;
CLASS_0 hPackedDIB = 0;
CLASS_3 VAR_4;
int x,VAR_5;
unsigned border_width;
unsigned int VAR_6, width, height;
wine_tsx11_lock();
if (!XGetGeometry(gdi_display, VAR_0, &VAR_4, &x, &VAR_5, &width, &height,
&border_width, &VAR_6)) VAR_6 = 0;
wine_tsx11_unlock();
if (!VAR_6) return 0;
FUNC_0("\tPixmap properties: width=%d, height=%d, depth=%d\n",
width, height, VAR_6);
if (!(VAR_3 = FUNC_1( width, height, 1, depth_to_bpp(VAR_6), NULL ))) return 0;
VAR_1 = FUNC_2( hdc );
FUNC_3( VAR_1, FUNC_3( VAR_1, VAR_3 ));
DeleteDC( VAR_1 );
VAR_2 = X11DRV_get_phys_bitmap( VAR_3 );
orig_pixmap = VAR_2->VAR_0;
VAR_2->VAR_0 = VAR_0;
hPackedDIB = FUNC_4(hdc, VAR_3);
VAR_2->VAR_0 = orig_pixmap;
FUNC_5(VAR_3);
FUNC_0("\tReturning packed DIB %p\n", hPackedDIB);
return hPackedDIB;
} | 0.367968 | {'CLASS_0': 'HGLOBAL', 'CLASS_1': 'Pixmap', 'VAR_0': 'pixmap', 'VAR_1': 'hdcMem', 'VAR_2': 'physBitmap', 'CLASS_2': 'HBITMAP', 'VAR_3': 'hBmp', 'CLASS_3': 'Window', 'VAR_4': 'root', 'VAR_5': 'y', 'VAR_6': 'depth', 'FUNC_0': 'TRACE', 'FUNC_1': 'CreateBitmap', 'FUNC_2': 'CreateCompatibleDC', 'FUNC_3': 'SelectObject', 'FUNC_4': 'X11DRV_DIB_CreateDIBFromBitmap', 'FUNC_5': 'DeleteObject'} | c | Procedural | 100.00% |
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
struct ListNode* prev = head;
struct ListNode* after = head;
for(int i = 0; i < n; i ++){
after = after->next;
}
if(after){
after = after->next;
while(after){
prev = prev->next;
after = after->next;
}
prev->next = prev->next->next;
return head;
}else{
return head->next;
}
}
| /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* FUNC_0(struct ListNode* head, int n){
struct ListNode* VAR_0 = head;
struct ListNode* VAR_1 = head;
for(int i = 0; i < n; i ++){
VAR_1 = VAR_1->VAR_2;
}
if(VAR_1){
VAR_1 = VAR_1->VAR_2;
while(VAR_1){
VAR_0 = VAR_0->VAR_2;
VAR_1 = VAR_1->VAR_2;
}
VAR_0->VAR_2 = VAR_0->VAR_2->VAR_2;
return head;
}else{
return head->VAR_2;
}
}
| 0.241453 | {'FUNC_0': 'removeNthFromEnd', 'VAR_0': 'prev', 'VAR_1': 'after', 'VAR_2': 'next'} | c | OOP | 23.46% |
#ifndef AMAZONSNSCLIENT_H_
#define AMAZONSNSCLIENT_H_
#include "AWSFoundationalTypes.h"
#include "AWSClient2.h"
class PublishInput {
MinimalString targetArn;
MinimalString message;
bool targetArnBeenSet;
bool messageBeenSet;
void reset();
public:
PublishInput();
bool requiredAreSet() const;
void setMessage(MinimalString message);
void setTargetArn(MinimalString targetArn);
MinimalString getMessage() const;
MinimalString getTargetArn() const;
MinimalString serialize() const;
};
class PublishOutput {
MinimalString messageId;
bool messageIdBeenSet;
MinimalString errorType;
MinimalString errorMessage;
void reset();
public:
PublishOutput();
MinimalString getErrorType() const;
MinimalString getErrorMessage() const;
void setMessageId(MinimalString messageId);
MinimalString getMessageId() const;
};
class AmazonSNSClient : public AWSClient2 {
public:
AmazonSNSClient();
PublishOutput publish(PublishInput input, ActionError& actionError);
};
#endif /* AMAZONSNSCLIENT_H_ */
| #ifndef AMAZONSNSCLIENT_H_
#define AMAZONSNSCLIENT_H_
#include "AWSFoundationalTypes.h"
#include "IMPORT_0"
class PublishInput {
CLASS_0 VAR_0;
CLASS_0 VAR_1;
bool targetArnBeenSet;
bool messageBeenSet;
void reset();
public:
PublishInput();
bool FUNC_0() const;
void FUNC_1(CLASS_0 VAR_1);
void FUNC_2(CLASS_0 VAR_0);
CLASS_0 FUNC_3() const;
CLASS_0 FUNC_4() const;
CLASS_0 FUNC_5() const;
};
class PublishOutput {
CLASS_0 messageId;
bool messageIdBeenSet;
CLASS_0 VAR_2;
CLASS_0 errorMessage;
void reset();
public:
PublishOutput();
CLASS_0 getErrorType() const;
CLASS_0 FUNC_6() const;
void setMessageId(CLASS_0 messageId);
CLASS_0 getMessageId() const;
};
class AmazonSNSClient : public AWSClient2 {
public:
AmazonSNSClient();
PublishOutput publish(PublishInput input, ActionError& actionError);
};
#endif /* AMAZONSNSCLIENT_H_ */
| 0.331655 | {'IMPORT_0': 'AWSClient2.h', 'CLASS_0': 'MinimalString', 'VAR_0': 'targetArn', 'VAR_1': 'message', 'FUNC_0': 'requiredAreSet', 'FUNC_1': 'setMessage', 'FUNC_2': 'setTargetArn', 'FUNC_3': 'getMessage', 'FUNC_4': 'getTargetArn', 'FUNC_5': 'serialize', 'VAR_2': 'errorType', 'FUNC_6': 'getErrorMessage'} | c | Texto | 7.56% |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "config.h"
const int vt100_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x00B0, 0x00B1, 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA,
0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00B7, 0x007F,
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
const int null_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x007F,
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x000A
};
const int user_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
0x00A7, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x00C4, 0x00D6, 0x00DC, '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x00E4, 0x00F6, 0x00FC, 0x00DF, 0x007F,
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
| /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "IMPORT_0"
const int vt100_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x00B0, 0x00B1, 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA,
0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00B7, 0x007F,
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
const int null_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x007F,
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x000A
};
const int user_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
0x00A7, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x00C4, 0x00D6, 0x00DC, '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x00E4, 0x00F6, 0x00FC, 0x00DF, 0x007F,
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
};
| 0.304362 | {'IMPORT_0': 'config.h'} | c | Procedural | 17.43% |
/*
Program to verify the workspace is set up properly.
Compile and run using:
gcc -Wall src/verify-uv.c -luv -Wl,-rpath,/usr/local/lib64 -o out/uv && ./out/uv
*/
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
int main(void)
{
uv_loop_t *loop = malloc(sizeof(uv_loop_t));
uv_loop_init(loop);
printf("Workspace set-up properly.\n");
uv_run(loop, UV_RUN_DEFAULT);
uv_loop_close(loop);
free(loop);
return 0;
}
| /*
Program to verify the workspace is set up properly.
Compile and run using:
gcc -Wall src/verify-uv.c -luv -Wl,-rpath,/usr/local/lib64 -o out/uv && ./out/uv
*/
#include <stdio.h>
#include <IMPORT_0>
#include <uv.h>
int main(void)
{
uv_loop_t *VAR_0 = malloc(sizeof(uv_loop_t));
uv_loop_init(VAR_0);
FUNC_0("Workspace set-up properly.\n");
uv_run(VAR_0, UV_RUN_DEFAULT);
uv_loop_close(VAR_0);
FUNC_1(VAR_0);
return 0;
}
| 0.261901 | {'IMPORT_0': 'stdlib.h', 'VAR_0': 'loop', 'FUNC_0': 'printf', 'FUNC_1': 'free'} | c | Procedural | 100.00% |
/**********
Copyright 1991 Regents of the University of California. All rights reserved.
Author: 1991 <NAME>, U. C. Berkeley CAD Group
Modifed: 2001 <NAME>
**********/
#include "ngspice/ngspice.h"
#include "ngspice/cktdefs.h"
#include "ngspice/numenum.h"
#include "ngspice/dopdefs.h"
#include "ngspice/meshext.h"
#include "ngspice/profile.h"
#include "ngspice/gendev.h"
#include "ngspice/sperror.h"
#include "ngspice/suffix.h"
#include "ngspice/cidersupt.h"
#include "ngspice/carddefs.h"
#include "ngspice/ciderinp.h"
/*
* Name: DOPcheck
* Purpose: checks a list of DOPcards for input errors
* Formals: cardList: the list to check
* Returns: OK/E_PRIVATE
* Users: numerical device setup routines
* Calls: error message handler
*/
int
DOPcheck(DOPcard *cardList, MESHcoord *xMeshList, MESHcoord *yMeshList)
{
DOPcard *card;
int cardNum = 0;
int error = OK;
for ( card = cardList; card != NULL; card = card->DOPnextCard ) {
cardNum++;
if (!card->DOPdomainsGiven) {
card->DOPnumDomains = 0;
card->DOPdomains = NULL;
}
if (!card->DOPprofileTypeGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d does not specify profile type", cardNum );
error = E_PRIVATE;
} else switch (card->DOPprofileType) {
case DOP_UNIF:
if (!card->DOPconcGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs conc of uniform distribution", cardNum );
error = E_PRIVATE;
}
break;
case DOP_LINEAR:
if (!card->DOPconcGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of linear distribution", cardNum );
error = E_PRIVATE;
}
break;
case DOP_GAUSS:
if (!card->DOPconcGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of gaussian distribution", cardNum );
error = E_PRIVATE;
}
break;
case DOP_ERFC:
if (!card->DOPconcGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of error-function distribution", cardNum );
error = E_PRIVATE;
}
break;
case DOP_EXP:
if (!card->DOPconcGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of exponential distribution", cardNum );
error = E_PRIVATE;
}
break;
case DOP_SUPREM3:
case DOP_SUPASCII:
if (!card->DOPinFileGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs input-file name of suprem3 data", cardNum );
error = E_PRIVATE;
}
break;
case DOP_ASCII:
if (!card->DOPinFileGiven) {
SPfrontEnd->IFerrorf( ERR_WARNING, "doping card %d needs input-file name of ascii data", cardNum );
error = E_PRIVATE;
}
break;
default:
SPfrontEnd->IFerrorf( ERR_FATAL, "doping card %d has unrecognized profile type", cardNum );
error = E_NOTFOUND;
break;
}
if (!card->DOProtateLatGiven) {
card->DOProtateLat = FALSE;
}
if (!card->DOPlatProfileTypeGiven || card->DOProtateLat) {
card->DOPlatProfileType = card->DOPprofileType;
}
if (!card->DOPratioLatGiven) {
card->DOPratioLat = 1.0;
}
if (!card->DOPcharLenGiven) {
card->DOPcharLen = 1.0e-4; /* 1um in centimeters */
}
if (!card->DOPlocationGiven) {
card->DOPlocation = 0.0;
}
if (!card->DOPimpurityTypeGiven) {
card->DOPimpurityType = IMP_N_TYPE;
} else switch (card->DOPimpurityType) {
case DOP_BORON:
card->DOPimpurityType = IMP_BORON;
break;
case DOP_PHOSP:
card->DOPimpurityType = IMP_PHOSPHORUS;
break;
case DOP_ARSEN:
card->DOPimpurityType = IMP_ARSENIC;
break;
case DOP_ANTIM:
card->DOPimpurityType = IMP_ANTIMONY;
break;
case DOP_N_TYPE:
card->DOPimpurityType = IMP_N_TYPE;
break;
case DOP_P_TYPE:
card->DOPimpurityType = IMP_P_TYPE;
break;
default:
break;
}
if (!card->DOPaxisTypeGiven) {
if ( xMeshList && yMeshList ) { /* both lists are non-empty */
card->DOPaxisType = DOP_Y_AXIS;
} else if ( xMeshList ) { /* x-mesh list is non-empty */
card->DOPaxisType = DOP_X_AXIS;
} else if ( yMeshList ) { /* y-mesh list is non-empty */
card->DOPaxisType = DOP_Y_AXIS;
}
}
/* Return now if anything has failed */
if (error) return(error);
}
return(OK);
}
/*
* Name: DOPsetup
* Purpose: convert a list of DOPcard's to DOPprofile's
* Formals: cardList: list of cards to setup
* profileList: returns the list of DOPprofile's
* xMeshList: list of coordinates in the x mesh
* yMeshList: list of coordinates in the y mesh
* Returns: OK/E_PRIVATE
* Users: numerical devices
* Calls: DOPcheck
*/
int
DOPsetup(DOPcard *cardList, DOPprofile **profileList, DOPtable **tableList,
MESHcoord *xMeshList, MESHcoord *yMeshList)
{
DOPcard *card;
DOPprofile *newProfile = NULL, *endProfile;
int impurityId = 0;
double xMin, xMax, yMin, yMax;
double sign;
int error, xProfUnif, yProfUnif;
/* Initialize list of profiles */
*profileList = endProfile = NULL;
/* Check the card list */
if ((error = DOPcheck( cardList, xMeshList, yMeshList )) != 0) return( error );
/* Find the limits on locations */
MESHlBounds( xMeshList, &xMin, &xMax );
MESHlBounds( yMeshList, &yMin, &yMax );
for ( card = cardList; card != NULL; card = card->DOPnextCard ) {
if (*profileList == NULL) {
RALLOC( newProfile, DOPprofile, 1 );
*profileList = newProfile;
}
else {
RALLOC( newProfile->next, DOPprofile, 1 );
newProfile = newProfile->next;
}
newProfile->next = NULL;
newProfile->numDomains = card->DOPnumDomains;
if ( newProfile->numDomains > 0 ) {
int i;
RALLOC( newProfile->domains, int, newProfile->numDomains );
for ( i=0; i < newProfile->numDomains; i++ ) {
newProfile->domains[i] = card->DOPdomains[i];
}
}
else {
newProfile->domains = NULL;
}
if ( card->DOPimpurityType == IMP_P_TYPE ) {
sign = -1.0;
}
else {
sign = 1.0;
}
switch( card->DOPprofileType ) {
case DOP_UNIF:
newProfile->type = UNIF;
newProfile->CONC = sign * card->DOPconc;
break;
case DOP_LINEAR:
newProfile->type = LIN;
newProfile->CONC = sign * card->DOPconc;
break;
case DOP_GAUSS:
newProfile->type = GAUSS;
newProfile->CONC = sign * card->DOPconc;
break;
case DOP_ERFC:
newProfile->type = ERRFC;
newProfile->CONC = sign * card->DOPconc;
break;
case DOP_EXP:
newProfile->type = EXP;
newProfile->CONC = sign * card->DOPconc;
break;
case DOP_SUPREM3:
newProfile->type = LOOKUP;
readSupremData( card->DOPinFile, 0, card->DOPimpurityType, tableList );
newProfile->IMPID = ++impurityId;
break;
case DOP_SUPASCII:
newProfile->type = LOOKUP;
readSupremData( card->DOPinFile, 1, card->DOPimpurityType, tableList );
newProfile->IMPID = ++impurityId;
break;
case DOP_ASCII:
newProfile->type = LOOKUP;
readAsciiData( card->DOPinFile, card->DOPimpurityType, tableList );
newProfile->IMPID = ++impurityId;
break;
default:
break;
}
switch( card->DOPlatProfileType ) {
case DOP_UNIF:
newProfile->latType = UNIF;
break;
case DOP_LINEAR:
newProfile->latType = LIN;
break;
case DOP_GAUSS:
newProfile->latType = GAUSS;
break;
case DOP_ERFC:
newProfile->latType = ERRFC;
break;
case DOP_EXP:
newProfile->latType = EXP;
break;
case DOP_SUPREM3:
case DOP_SUPASCII:
newProfile->latType = LOOKUP;
break;
case DOP_ASCII:
newProfile->latType = LOOKUP;
break;
default:
break;
}
newProfile->rotate = card->DOProtateLat;
newProfile->LOCATION = card->DOPlocation;
newProfile->CHAR_LENGTH = card->DOPcharLen;
newProfile->LAT_RATIO = card->DOPratioLat;
xProfUnif = yProfUnif = FALSE;
if (card->DOPaxisType == DOP_X_AXIS) {
newProfile->DIRECTION = X;
if (newProfile->type == UNIF) xProfUnif = TRUE;
if (newProfile->latType == UNIF) yProfUnif = TRUE;
}
else {
newProfile->DIRECTION = Y;
if (newProfile->type == UNIF) yProfUnif = TRUE;
if (newProfile->latType == UNIF) xProfUnif = TRUE;
}
/* Fill in x coordinates. Use defaults if necessary */
if (card->DOPxLowGiven && card->DOPxHighGiven) {
newProfile->X_LOW = card->DOPxLow;
newProfile->X_HIGH = card->DOPxHigh;
}
else if (card->DOPxLowGiven) {
newProfile->X_LOW = card->DOPxLow;
if (xProfUnif) {
newProfile->X_HIGH = xMax;
}
else {
newProfile->X_HIGH = newProfile->X_LOW;
}
}
else if (card->DOPxHighGiven) {
newProfile->X_HIGH = card->DOPxHigh;
if (xProfUnif) {
newProfile->X_LOW = xMin;
}
else {
newProfile->X_LOW = newProfile->X_HIGH;
}
}
else {
if (xProfUnif) {
newProfile->X_LOW = xMin;
newProfile->X_HIGH = xMax;
}
else {
newProfile->X_LOW = 0.5 * (xMin + xMax);
newProfile->X_HIGH = 0.5 * (xMin + xMax);
}
}
/* Fill in y coordinates. Use defaults if necessary */
if (card->DOPyLowGiven && card->DOPyHighGiven) {
newProfile->Y_LOW = card->DOPyLow;
newProfile->Y_HIGH = card->DOPyHigh;
}
else if (card->DOPyLowGiven) {
newProfile->Y_LOW = card->DOPyLow;
if (yProfUnif) {
newProfile->Y_HIGH = yMax;
}
else {
newProfile->Y_HIGH = newProfile->Y_LOW;
}
}
else if (card->DOPyHighGiven) {
newProfile->Y_HIGH = card->DOPyHigh;
if (xProfUnif) {
newProfile->Y_LOW = yMin;
}
else {
newProfile->Y_LOW = newProfile->Y_HIGH;
}
}
else {
if (yProfUnif) {
newProfile->Y_LOW = yMin;
newProfile->Y_HIGH = yMax;
}
else {
newProfile->Y_LOW = 0.5 * (yMin + yMax);
newProfile->Y_HIGH = 0.5 * (yMin + yMax);
}
}
}
return( OK );
}
| /**********
Copyright 1991 Regents of the University of California. All rights reserved.
Author: 1991 <NAME>, U. C. Berkeley CAD Group
Modifed: 2001 <NAME>
**********/
#include "ngspice/ngspice.h"
#include "ngspice/cktdefs.h"
#include "IMPORT_0"
#include "IMPORT_1"
#include "ngspice/meshext.h"
#include "IMPORT_2"
#include "IMPORT_3"
#include "IMPORT_4"
#include "ngspice/suffix.h"
#include "ngspice/cidersupt.h"
#include "IMPORT_5"
#include "IMPORT_6"
/*
* Name: DOPcheck
* Purpose: checks a list of DOPcards for input errors
* Formals: cardList: the list to check
* Returns: OK/E_PRIVATE
* Users: numerical device setup routines
* Calls: error message handler
*/
int
DOPcheck(CLASS_0 *VAR_0, CLASS_1 *VAR_1, CLASS_1 *VAR_2)
{
CLASS_0 *card;
int VAR_3 = 0;
int error = VAR_4;
for ( card = VAR_0; card != NULL; card = card->DOPnextCard ) {
VAR_3++;
if (!card->VAR_5) {
card->VAR_6 = 0;
card->DOPdomains = NULL;
}
if (!card->VAR_7) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d does not specify profile type", VAR_3 );
error = VAR_9;
} else switch (card->VAR_10) {
case DOP_UNIF:
if (!card->VAR_11) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs conc of uniform distribution", VAR_3 );
error = VAR_9;
}
break;
case VAR_12:
if (!card->VAR_11) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of linear distribution", VAR_3 );
error = VAR_9;
}
break;
case VAR_13:
if (!card->VAR_11) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of gaussian distribution", VAR_3 );
error = VAR_9;
}
break;
case DOP_ERFC:
if (!card->VAR_11) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of error-function distribution", VAR_3 );
error = VAR_9;
}
break;
case DOP_EXP:
if (!card->VAR_11) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs peak conc of exponential distribution", VAR_3 );
error = VAR_9;
}
break;
case DOP_SUPREM3:
case DOP_SUPASCII:
if (!card->VAR_14) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs input-file name of suprem3 data", VAR_3 );
error = VAR_9;
}
break;
case DOP_ASCII:
if (!card->VAR_14) {
VAR_8->IFerrorf( ERR_WARNING, "doping card %d needs input-file name of ascii data", VAR_3 );
error = VAR_9;
}
break;
default:
VAR_8->IFerrorf( ERR_FATAL, "doping card %d has unrecognized profile type", VAR_3 );
error = VAR_15;
break;
}
if (!card->DOProtateLatGiven) {
card->DOProtateLat = FALSE;
}
if (!card->DOPlatProfileTypeGiven || card->DOProtateLat) {
card->VAR_16 = card->VAR_10;
}
if (!card->DOPratioLatGiven) {
card->DOPratioLat = 1.0;
}
if (!card->DOPcharLenGiven) {
card->DOPcharLen = 1.0e-4; /* 1um in centimeters */
}
if (!card->DOPlocationGiven) {
card->VAR_17 = 0.0;
}
if (!card->DOPimpurityTypeGiven) {
card->DOPimpurityType = IMP_N_TYPE;
} else switch (card->DOPimpurityType) {
case VAR_18:
card->DOPimpurityType = IMP_BORON;
break;
case VAR_19:
card->DOPimpurityType = VAR_20;
break;
case DOP_ARSEN:
card->DOPimpurityType = VAR_21;
break;
case VAR_22:
card->DOPimpurityType = VAR_23;
break;
case DOP_N_TYPE:
card->DOPimpurityType = IMP_N_TYPE;
break;
case VAR_24:
card->DOPimpurityType = VAR_25;
break;
default:
break;
}
if (!card->VAR_26) {
if ( VAR_1 && VAR_2 ) { /* both lists are non-empty */
card->VAR_27 = DOP_Y_AXIS;
} else if ( VAR_1 ) { /* x-mesh list is non-empty */
card->VAR_27 = DOP_X_AXIS;
} else if ( VAR_2 ) { /* y-mesh list is non-empty */
card->VAR_27 = DOP_Y_AXIS;
}
}
/* Return now if anything has failed */
if (error) return(error);
}
return(VAR_4);
}
/*
* Name: DOPsetup
* Purpose: convert a list of DOPcard's to DOPprofile's
* Formals: cardList: list of cards to setup
* profileList: returns the list of DOPprofile's
* xMeshList: list of coordinates in the x mesh
* yMeshList: list of coordinates in the y mesh
* Returns: OK/E_PRIVATE
* Users: numerical devices
* Calls: DOPcheck
*/
int
FUNC_0(CLASS_0 *VAR_0, CLASS_2 **VAR_29, DOPtable **VAR_30,
CLASS_1 *VAR_1, CLASS_1 *VAR_2)
{
CLASS_0 *card;
CLASS_2 *VAR_31 = NULL, *endProfile;
int VAR_32 = 0;
double xMin, xMax, yMin, yMax;
double VAR_33;
int error, xProfUnif, VAR_34;
/* Initialize list of profiles */
*VAR_29 = endProfile = NULL;
/* Check the card list */
if ((error = DOPcheck( VAR_0, VAR_1, VAR_2 )) != 0) return( error );
/* Find the limits on locations */
FUNC_1( VAR_1, &xMin, &xMax );
FUNC_1( VAR_2, &yMin, &yMax );
for ( card = VAR_0; card != NULL; card = card->DOPnextCard ) {
if (*VAR_29 == NULL) {
FUNC_2( VAR_31, VAR_28, 1 );
*VAR_29 = VAR_31;
}
else {
FUNC_2( VAR_31->next, VAR_28, 1 );
VAR_31 = VAR_31->next;
}
VAR_31->next = NULL;
VAR_31->numDomains = card->VAR_6;
if ( VAR_31->numDomains > 0 ) {
int VAR_35;
FUNC_2( VAR_31->VAR_36, int, VAR_31->numDomains );
for ( VAR_35=0; VAR_35 < VAR_31->numDomains; VAR_35++ ) {
VAR_31->VAR_36[VAR_35] = card->DOPdomains[VAR_35];
}
}
else {
VAR_31->VAR_36 = NULL;
}
if ( card->DOPimpurityType == VAR_25 ) {
VAR_33 = -1.0;
}
else {
VAR_33 = 1.0;
}
switch( card->VAR_10 ) {
case DOP_UNIF:
VAR_31->VAR_37 = UNIF;
VAR_31->VAR_38 = VAR_33 * card->DOPconc;
break;
case VAR_12:
VAR_31->VAR_37 = LIN;
VAR_31->VAR_38 = VAR_33 * card->DOPconc;
break;
case VAR_13:
VAR_31->VAR_37 = VAR_39;
VAR_31->VAR_38 = VAR_33 * card->DOPconc;
break;
case DOP_ERFC:
VAR_31->VAR_37 = VAR_40;
VAR_31->VAR_38 = VAR_33 * card->DOPconc;
break;
case DOP_EXP:
VAR_31->VAR_37 = EXP;
VAR_31->VAR_38 = VAR_33 * card->DOPconc;
break;
case DOP_SUPREM3:
VAR_31->VAR_37 = LOOKUP;
FUNC_3( card->VAR_41, 0, card->DOPimpurityType, VAR_30 );
VAR_31->VAR_42 = ++VAR_32;
break;
case DOP_SUPASCII:
VAR_31->VAR_37 = LOOKUP;
FUNC_3( card->VAR_41, 1, card->DOPimpurityType, VAR_30 );
VAR_31->VAR_42 = ++VAR_32;
break;
case DOP_ASCII:
VAR_31->VAR_37 = LOOKUP;
readAsciiData( card->VAR_41, card->DOPimpurityType, VAR_30 );
VAR_31->VAR_42 = ++VAR_32;
break;
default:
break;
}
switch( card->VAR_16 ) {
case DOP_UNIF:
VAR_31->latType = UNIF;
break;
case VAR_12:
VAR_31->latType = LIN;
break;
case VAR_13:
VAR_31->latType = VAR_39;
break;
case DOP_ERFC:
VAR_31->latType = VAR_40;
break;
case DOP_EXP:
VAR_31->latType = EXP;
break;
case DOP_SUPREM3:
case DOP_SUPASCII:
VAR_31->latType = LOOKUP;
break;
case DOP_ASCII:
VAR_31->latType = LOOKUP;
break;
default:
break;
}
VAR_31->rotate = card->DOProtateLat;
VAR_31->LOCATION = card->VAR_17;
VAR_31->CHAR_LENGTH = card->DOPcharLen;
VAR_31->VAR_43 = card->DOPratioLat;
xProfUnif = VAR_34 = FALSE;
if (card->VAR_27 == DOP_X_AXIS) {
VAR_31->DIRECTION = X;
if (VAR_31->VAR_37 == UNIF) xProfUnif = TRUE;
if (VAR_31->latType == UNIF) VAR_34 = TRUE;
}
else {
VAR_31->DIRECTION = VAR_44;
if (VAR_31->VAR_37 == UNIF) VAR_34 = TRUE;
if (VAR_31->latType == UNIF) xProfUnif = TRUE;
}
/* Fill in x coordinates. Use defaults if necessary */
if (card->DOPxLowGiven && card->VAR_45) {
VAR_31->X_LOW = card->VAR_46;
VAR_31->VAR_47 = card->VAR_48;
}
else if (card->DOPxLowGiven) {
VAR_31->X_LOW = card->VAR_46;
if (xProfUnif) {
VAR_31->VAR_47 = xMax;
}
else {
VAR_31->VAR_47 = VAR_31->X_LOW;
}
}
else if (card->VAR_45) {
VAR_31->VAR_47 = card->VAR_48;
if (xProfUnif) {
VAR_31->X_LOW = xMin;
}
else {
VAR_31->X_LOW = VAR_31->VAR_47;
}
}
else {
if (xProfUnif) {
VAR_31->X_LOW = xMin;
VAR_31->VAR_47 = xMax;
}
else {
VAR_31->X_LOW = 0.5 * (xMin + xMax);
VAR_31->VAR_47 = 0.5 * (xMin + xMax);
}
}
/* Fill in y coordinates. Use defaults if necessary */
if (card->DOPyLowGiven && card->VAR_49) {
VAR_31->VAR_50 = card->DOPyLow;
VAR_31->VAR_51 = card->VAR_52;
}
else if (card->DOPyLowGiven) {
VAR_31->VAR_50 = card->DOPyLow;
if (VAR_34) {
VAR_31->VAR_51 = yMax;
}
else {
VAR_31->VAR_51 = VAR_31->VAR_50;
}
}
else if (card->VAR_49) {
VAR_31->VAR_51 = card->VAR_52;
if (xProfUnif) {
VAR_31->VAR_50 = yMin;
}
else {
VAR_31->VAR_50 = VAR_31->VAR_51;
}
}
else {
if (VAR_34) {
VAR_31->VAR_50 = yMin;
VAR_31->VAR_51 = yMax;
}
else {
VAR_31->VAR_50 = 0.5 * (yMin + yMax);
VAR_31->VAR_51 = 0.5 * (yMin + yMax);
}
}
}
return( VAR_4 );
}
| 0.547276 | {'IMPORT_0': 'ngspice/numenum.h', 'IMPORT_1': 'ngspice/dopdefs.h', 'IMPORT_2': 'ngspice/profile.h', 'IMPORT_3': 'ngspice/gendev.h', 'IMPORT_4': 'ngspice/sperror.h', 'IMPORT_5': 'ngspice/carddefs.h', 'IMPORT_6': 'ngspice/ciderinp.h', 'CLASS_0': 'DOPcard', 'VAR_0': 'cardList', 'CLASS_1': 'MESHcoord', 'VAR_1': 'xMeshList', 'VAR_2': 'yMeshList', 'VAR_3': 'cardNum', 'VAR_4': 'OK', 'VAR_5': 'DOPdomainsGiven', 'VAR_6': 'DOPnumDomains', 'VAR_7': 'DOPprofileTypeGiven', 'VAR_8': 'SPfrontEnd', 'VAR_9': 'E_PRIVATE', 'VAR_10': 'DOPprofileType', 'VAR_11': 'DOPconcGiven', 'VAR_12': 'DOP_LINEAR', 'VAR_13': 'DOP_GAUSS', 'VAR_14': 'DOPinFileGiven', 'VAR_15': 'E_NOTFOUND', 'VAR_16': 'DOPlatProfileType', 'VAR_17': 'DOPlocation', 'VAR_18': 'DOP_BORON', 'VAR_19': 'DOP_PHOSP', 'VAR_20': 'IMP_PHOSPHORUS', 'VAR_21': 'IMP_ARSENIC', 'VAR_22': 'DOP_ANTIM', 'VAR_23': 'IMP_ANTIMONY', 'VAR_24': 'DOP_P_TYPE', 'VAR_25': 'IMP_P_TYPE', 'VAR_26': 'DOPaxisTypeGiven', 'VAR_27': 'DOPaxisType', 'FUNC_0': 'DOPsetup', 'CLASS_2': 'DOPprofile', 'VAR_28': 'DOPprofile', 'VAR_29': 'profileList', 'VAR_30': 'tableList', 'VAR_31': 'newProfile', 'VAR_32': 'impurityId', 'VAR_33': 'sign', 'VAR_34': 'yProfUnif', 'FUNC_1': 'MESHlBounds', 'FUNC_2': 'RALLOC', 'VAR_35': 'i', 'VAR_36': 'domains', 'VAR_37': 'type', 'VAR_38': 'CONC', 'VAR_39': 'GAUSS', 'VAR_40': 'ERRFC', 'FUNC_3': 'readSupremData', 'VAR_41': 'DOPinFile', 'VAR_42': 'IMPID', 'VAR_43': 'LAT_RATIO', 'VAR_44': 'Y', 'VAR_45': 'DOPxHighGiven', 'VAR_46': 'DOPxLow', 'VAR_47': 'X_HIGH', 'VAR_48': 'DOPxHigh', 'VAR_49': 'DOPyHighGiven', 'VAR_50': 'Y_LOW', 'VAR_51': 'Y_HIGH', 'VAR_52': 'DOPyHigh'} | c | Procedural | 100.00% |
#ifndef __FIFO_SEQNUM_SERVER_H_
#define __FIFO_SEQNUM_SERVER_H_
#endif /* __FIFO_SEQNUM_SERVER_H_ */
| #ifndef VAR_0
#define VAR_0
#endif /* __FIFO_SEQNUM_SERVER_H_ */
| 0.976602 | {'VAR_0': '__FIFO_SEQNUM_SERVER_H_'} | c | Texto | 100.00% |
#pragma once
#include "RE/Skyrim.h"
namespace Events
{
class MenuOpenCloseEventHandler : public RE::BSTEventSink<RE::MenuOpenCloseEvent>
{
public:
using EventResult = RE::BSEventNotifyControl;
static MenuOpenCloseEventHandler* GetSingleton();
virtual EventResult ProcessEvent(const RE::MenuOpenCloseEvent* a_event, RE::BSTEventSource<RE::MenuOpenCloseEvent>* a_eventSource) override;
void SetBethTranslator(RE::GPtr<RE::GFxTranslator>&& a_translator);
private:
MenuOpenCloseEventHandler() = default;
MenuOpenCloseEventHandler(const MenuOpenCloseEventHandler&) = delete;
MenuOpenCloseEventHandler(MenuOpenCloseEventHandler&&) = delete;
virtual ~MenuOpenCloseEventHandler();
MenuOpenCloseEventHandler& operator=(const MenuOpenCloseEventHandler&) = delete;
MenuOpenCloseEventHandler& operator=(MenuOpenCloseEventHandler&&) = delete;
RE::GPtr<RE::GFxTranslator> _bethImpl;
};
}
| #pragma once
#include "IMPORT_0"
CLASS_0 VAR_0
{
CLASS_1 VAR_1 : VAR_2 VAR_3::VAR_4<VAR_3::VAR_5>
{
public:
VAR_6 VAR_7 = VAR_3::VAR_8;
static CLASS_2* FUNC_1();
CLASS_4 VAR_7 ProcessEvent(const CLASS_3::VAR_5* VAR_9, VAR_3::VAR_10<VAR_3::VAR_5>* VAR_11) VAR_12;
void FUNC_2(CLASS_3::VAR_13<VAR_3::VAR_14>&& VAR_15);
private:
FUNC_0() = VAR_16;
VAR_1(const CLASS_2&) = VAR_17;
FUNC_0(VAR_1&&VAR_18) = VAR_17;
CLASS_4 ~FUNC_0();
VAR_1& VAR_19=(const CLASS_2&) = VAR_17;
VAR_1& VAR_19=(VAR_1&&VAR_18) = VAR_17;
RE::VAR_13<VAR_3::VAR_14> VAR_20;
};
}
| 0.996673 | {'IMPORT_0': 'RE/Skyrim.h', 'CLASS_0': 'namespace', 'VAR_0': 'Events', 'CLASS_1': 'class', 'VAR_1': 'MenuOpenCloseEventHandler', 'CLASS_2': 'MenuOpenCloseEventHandler', 'FUNC_0': 'MenuOpenCloseEventHandler', 'VAR_2': 'public', 'VAR_3': 'RE', 'CLASS_3': 'RE', 'VAR_4': 'BSTEventSink', 'VAR_5': 'MenuOpenCloseEvent', 'VAR_6': 'using', 'VAR_7': 'EventResult', 'VAR_8': 'BSEventNotifyControl', 'FUNC_1': 'GetSingleton', 'CLASS_4': 'virtual', 'VAR_9': 'a_event', 'VAR_10': 'BSTEventSource', 'VAR_11': 'a_eventSource', 'VAR_12': 'override', 'FUNC_2': 'SetBethTranslator', 'VAR_13': 'GPtr', 'VAR_14': 'GFxTranslator', 'VAR_15': 'a_translator', 'VAR_16': 'default', 'VAR_17': 'delete', 'VAR_18': '', 'VAR_19': 'operator', 'VAR_20': '_bethImpl'} | c | Texto | 6.82% |
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void decrypt(int *x,int z,int y){
int out=0;int i;
for(i=0;i<z;i++) {
out = *(x + i) - y;
if(out<32){
out+=90;
}
*(x+i)=out;
}
}
void encrypt(int *x,int z,int y){
int out=0;int i;
for(i=0;i<z;i++) {
out = *(x + i) + y;
if(out>=122){
out=(out%122)+32;
}
*(x+i)=out;
}
}
int main(){
int length,i,key;char ch,c;int *p;
// puts("How long string do you want to encrypt or decrypt?\n");
scanf("%d%d\n",&length,&key);
p=(int*)malloc(length*sizeof(int));
for(i=0;i<length;i++){
scanf("%c",&ch);
*(p+i)=(int)ch;
}
decrypt(p,length,key);
// encrypy(p,length,key);
for(i=0;i<length;i++){
c=(char)*(p+i);
printf("%c",c);
}
return 0;
}
| #include <stdio.h>
#include <string.h>
#include <stdlib.h>
void decrypt(int *x,int z,int y){
int VAR_0=0;int i;
for(i=0;i<z;i++) {
VAR_0 = *(x + i) - y;
if(VAR_0<32){
VAR_0+=90;
}
*(x+i)=VAR_0;
}
}
void encrypt(int *x,int z,int y){
int VAR_0=0;int i;
for(i=0;i<z;i++) {
VAR_0 = *(x + i) + y;
if(VAR_0>=122){
VAR_0=(VAR_0%122)+32;
}
*(x+i)=VAR_0;
}
}
int main(){
int length,i,key;char ch,c;int *p;
// puts("How long string do you want to encrypt or decrypt?\n");
scanf("%d%d\n",&length,&key);
p=(int*)malloc(length*sizeof(int));
for(i=0;i<length;i++){
scanf("%c",&ch);
*(p+i)=(int)ch;
}
decrypt(p,length,key);
// encrypy(p,length,key);
for(i=0;i<length;i++){
c=(char)*(p+i);
printf("%c",c);
}
return 0;
}
| 0.123496 | {'VAR_0': 'out'} | c | Procedural | 100.00% |
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
#pragma once
#include "RealSenseIDExports.h"
namespace RealSenseID
{
class PreviewImpl;
/**
* Preview modes
*/
enum class PreviewMode
{
MJPEG_1080P = 0, // default
MJPEG_720P = 1,
RAW10_1080P = 2 // dump all frames
};
/**
* Preview configuration
*/
struct RSID_API PreviewConfig
{
int cameraNumber = -1; // attempt to auto detect by default
PreviewMode previewMode = PreviewMode::MJPEG_1080P; // RAW10 requires custom fw support
};
/**
* RAW image metadata
*/
struct RSID_API ImageMetadata
{
unsigned int timestamp = 0; // sensor timestamp (miliseconds)
unsigned int status = 0;
unsigned int sensor_id = 0;
bool led = false;
bool projector = false;
};
/**
* Image data for preview
*/
struct RSID_API Image
{
unsigned char* buffer = nullptr;
unsigned int size = 0;
unsigned int width = 0;
unsigned int height = 0;
unsigned int stride = 0;
unsigned int number = 0;
ImageMetadata metadata;
};
/**
* User defined callback for preview.
* Callback will be used to provide preview image.
*/
class RSID_API PreviewImageReadyCallback
{
public:
virtual ~PreviewImageReadyCallback() = default;
virtual void OnPreviewImageReady(const Image image) = 0;
};
/**
* Preview Support. Use StartPreview to get callbacks for image frames
*/
class RSID_API Preview
{
public:
explicit Preview(const PreviewConfig&);
~Preview();
Preview(const Preview&) = delete;
Preview& operator=(const Preview&) = delete;
/**
* Start preview.
*
* @param callback reference to callback object
* @return True on success.
*/
bool StartPreview(PreviewImageReadyCallback& callback);
/**
* Pause preview.
*
* @return True on success.
*/
bool PausePreview();
/**
* Resume preview.
*
* @return True on success.
*/
bool ResumePreview();
/**
* Stop preview.
*
* @return True on success.
*/
bool StopPreview();
/**
* Convert Raw Image in_image to RGB24 and fill result in out_image
* @param in_image an raw10 Image to convert
* @param out_image an Image with pre-allocated buffer in size in_image.width * in_image.height * 3
* @return True on success.
*/
bool RawToRgb(const Image& in_image, Image& out_image);
private:
RealSenseID::PreviewImpl* _impl = nullptr;
};
} // namespace RealSenseID
| // License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020-2021 Intel Corporation. All Rights Reserved.
#pragma once
#include "RealSenseIDExports.h"
namespace RealSenseID
{
class VAR_0;
/**
* Preview modes
*/
enum class PreviewMode
{
MJPEG_1080P = 0, // default
MJPEG_720P = 1,
RAW10_1080P = 2 // dump all frames
};
/**
* Preview configuration
*/
struct RSID_API PreviewConfig
{
int VAR_1 = -1; // attempt to auto detect by default
PreviewMode previewMode = PreviewMode::MJPEG_1080P; // RAW10 requires custom fw support
};
/**
* RAW image metadata
*/
struct RSID_API ImageMetadata
{
unsigned int timestamp = 0; // sensor timestamp (miliseconds)
unsigned int VAR_2 = 0;
unsigned int sensor_id = 0;
bool led = false;
bool VAR_3 = false;
};
/**
* Image data for preview
*/
struct RSID_API Image
{
unsigned char* buffer = nullptr;
unsigned int size = 0;
unsigned int width = 0;
unsigned int VAR_4 = 0;
unsigned int VAR_5 = 0;
unsigned int number = 0;
ImageMetadata VAR_6;
};
/**
* User defined callback for preview.
* Callback will be used to provide preview image.
*/
class RSID_API VAR_7
{
public:
virtual ~FUNC_0() = default;
virtual VAR_8 OnPreviewImageReady(const Image image) = 0;
};
/**
* Preview Support. Use StartPreview to get callbacks for image frames
*/
class RSID_API Preview
{
public:
VAR_9 Preview(const PreviewConfig&);
~Preview();
Preview(const Preview&) = delete;
Preview& operator=(const Preview&) = delete;
/**
* Start preview.
*
* @param callback reference to callback object
* @return True on success.
*/
bool StartPreview(CLASS_0& VAR_10);
/**
* Pause preview.
*
* @return True on success.
*/
bool PausePreview();
/**
* Resume preview.
*
* @return True on success.
*/
bool ResumePreview();
/**
* Stop preview.
*
* @return True on success.
*/
bool FUNC_1();
/**
* Convert Raw Image in_image to RGB24 and fill result in out_image
* @param in_image an raw10 Image to convert
* @param out_image an Image with pre-allocated buffer in size in_image.width * in_image.height * 3
* @return True on success.
*/
bool RawToRgb(const Image& in_image, Image& out_image);
private:
RealSenseID::VAR_0* _impl = nullptr;
};
} // namespace RealSenseID
| 0.219679 | {'VAR_0': 'PreviewImpl', 'VAR_1': 'cameraNumber', 'VAR_2': 'status', 'VAR_3': 'projector', 'VAR_4': 'height', 'VAR_5': 'stride', 'VAR_6': 'metadata', 'VAR_7': 'PreviewImageReadyCallback', 'FUNC_0': 'PreviewImageReadyCallback', 'CLASS_0': 'PreviewImageReadyCallback', 'VAR_8': 'void', 'VAR_9': 'explicit', 'VAR_10': 'callback', 'FUNC_1': 'StopPreview'} | c | Procedural | 7.88% |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.c
* Author: Bruno Espezúa
*
* Created on 14 de mayo de 2017, 09:25 PM
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 101
/*
*
*/
//int sumMax(int arr[],int n);
int sumMaxDivVen(int arr[],int ini,int fin);
int max3(int a,int b,int c);
int main() {
int n,c=0;
int arr[MAX],arrAux[MAX];
int i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&arr[i]);
if (arr[i]==1){
c++;
arrAux[i]=-1;
}
else if(arr[i]==0){
arrAux[i]=1;
}
}
printf("%d\n",c + sumMaxDivVen(arrAux,0,n-1));
return 0;
}
/*int sumMax(int arr[],int n){
int sumActual=0,max=0;
int i;
for(i=0;i<n;i++){
sumActual+=arr[i];
if(sumActual>max){
max=sumActual;
}
else if(sumActual<0){
sumActual=0;
}
}
return max;
}*/
int sumMaxDivVen(int arr[],int ini,int fin){
int maxIzq,maxDer;
int sum=0;
int sumMaxBordeIzq,sumMaxBordeDer;
int centro = (ini + fin)/2;
int i;
if (ini>=fin) return arr[fin];
maxIzq=sumMaxDivVen(arr,ini,centro);
maxDer=sumMaxDivVen(arr,centro+1,fin);
sumMaxBordeIzq=arr[centro];
sumMaxBordeDer=arr[centro+1];
for(i=centro;i>=ini;i--){
sum += arr[i];
if (sum>sumMaxBordeIzq) sumMaxBordeIzq=sum;
}
sum=0;
for(i=centro+1;i<=fin;i++){
sum += arr[i];
if (sum>sumMaxBordeDer) sumMaxBordeDer=sum;
}
return max3(maxIzq,maxDer,sumMaxBordeIzq+sumMaxBordeDer);
}
int max3(int a,int b, int c){
if(a>b){
if(a>c) return a;
else return c;
}
else if(b>c) return b;
else return c;
} | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.c
* Author: Bruno Espezúa
*
* Created on 14 de mayo de 2017, 09:25 PM
*/
#include <IMPORT_0>
#include <IMPORT_1>
#define VAR_0 101
/*
*
*/
//int sumMax(int arr[],int n);
int FUNC_0(int VAR_1[],int VAR_2,int VAR_3);
int FUNC_1(int VAR_4,int VAR_5,int VAR_6);
int FUNC_2() {
int VAR_7,VAR_6=0;
int VAR_1[VAR_0],VAR_8[VAR_0];
int VAR_9;
FUNC_3("%d",&VAR_7);
for(VAR_9=0;VAR_9<VAR_7;VAR_9++){
FUNC_3("%d",&VAR_1[VAR_9]);
if (VAR_1[VAR_9]==1){
VAR_6++;
VAR_8[VAR_9]=-1;
}
else if(VAR_1[VAR_9]==0){
VAR_8[VAR_9]=1;
}
}
FUNC_4("%d\n",VAR_6 + FUNC_0(VAR_8,0,VAR_7-1));
return 0;
}
/*int sumMax(int arr[],int n){
int sumActual=0,max=0;
int i;
for(i=0;i<n;i++){
sumActual+=arr[i];
if(sumActual>max){
max=sumActual;
}
else if(sumActual<0){
sumActual=0;
}
}
return max;
}*/
int FUNC_0(int VAR_1[],int VAR_2,int VAR_3){
int VAR_10,VAR_11;
int VAR_12=0;
int VAR_13,VAR_14;
int VAR_15 = (VAR_2 + VAR_3)/2;
int VAR_9;
if (VAR_2>=VAR_3) return VAR_1[VAR_3];
VAR_10=FUNC_0(VAR_1,VAR_2,VAR_15);
VAR_11=FUNC_0(VAR_1,VAR_15+1,VAR_3);
VAR_13=VAR_1[VAR_15];
VAR_14=VAR_1[VAR_15+1];
for(VAR_9=VAR_15;VAR_9>=VAR_2;VAR_9--){
VAR_12 += VAR_1[VAR_9];
if (VAR_12>VAR_13) VAR_13=VAR_12;
}
VAR_12=0;
for(VAR_9=VAR_15+1;VAR_9<=VAR_3;VAR_9++){
VAR_12 += VAR_1[VAR_9];
if (VAR_12>VAR_14) VAR_14=VAR_12;
}
return FUNC_1(VAR_10,VAR_11,VAR_13+VAR_14);
}
int FUNC_1(int VAR_4,int VAR_5, int VAR_6){
if(VAR_4>VAR_5){
if(VAR_4>VAR_6) return VAR_4;
else return VAR_6;
}
else if(VAR_5>VAR_6) return VAR_5;
else return VAR_6;
} | 0.921301 | {'IMPORT_0': 'stdio.h', 'IMPORT_1': 'stdlib.h', 'VAR_0': 'MAX', 'FUNC_0': 'sumMaxDivVen', 'VAR_1': 'arr', 'VAR_2': 'ini', 'VAR_3': 'fin', 'FUNC_1': 'max3', 'VAR_4': 'a', 'VAR_5': 'b', 'VAR_6': 'c', 'FUNC_2': 'main', 'VAR_7': 'n', 'VAR_8': 'arrAux', 'VAR_9': 'i', 'FUNC_3': 'scanf', 'FUNC_4': 'printf', 'VAR_10': 'maxIzq', 'VAR_11': 'maxDer', 'VAR_12': 'sum', 'VAR_13': 'sumMaxBordeIzq', 'VAR_14': 'sumMaxBordeDer', 'VAR_15': 'centro'} | c | Procedural | 100.00% |
//
// Created by 郭伟林 on 2017/6/23.
// Copyright © 2017年 SR. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SRSqliteTool : NSObject
+ (BOOL)executeSQL:(NSString *)sql uid:(NSString *)uid;
+ (BOOL)executeSQLs:(NSArray<NSString *> *)sqls uid:(NSString *)uid;
+ (NSMutableArray<NSMutableDictionary *> *)querySQL:(NSString *)sql uid:(NSString *)uid;
@end
| //
// Created by 郭伟林 on 2017/6/23.
// Copyright © 2017年 SR. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface VAR_0 : VAR_1
+ (ID_0)VAR_3:(VAR_4 *)sql VAR_5:(VAR_4 *)VAR_5;
+ (VAR_2)VAR_6:(VAR_7<VAR_4 *> *)VAR_8 VAR_5:(VAR_4 *)VAR_5;
+ (VAR_9<VAR_10 *> *)VAR_11:(VAR_4 *)sql VAR_5:(VAR_4 *)VAR_5;
@VAR_12
| 0.941705 | {'VAR_0': 'SRSqliteTool', 'VAR_1': 'NSObject', 'ID_0': 'BOOL', 'VAR_2': 'BOOL', 'VAR_3': 'executeSQL', 'VAR_4': 'NSString', 'VAR_5': 'uid', 'VAR_6': 'executeSQLs', 'VAR_7': 'NSArray', 'VAR_8': 'sqls', 'VAR_9': 'NSMutableArray', 'VAR_10': 'NSMutableDictionary', 'VAR_11': 'querySQL', 'VAR_12': 'end'} | c | Procedural | 100.00% |
#include <stdio.h>
int main()
{
int n, m, a, b, d=0, t, s;
scanf("%d %d %d %d",&n,&m,&a,&b);
if ((float)b/m <= a){
t=(n/m);
d += t*b;
s = (n-(t*m))*a;
if(s<=b){
d+=s;
}
if(b<s){
d+=b;
}
printf("%d",d);
}
else{
printf("%d",(a*n));
}
return 0;
}
| #include <stdio.h>
int main()
{
int n, m, a, b, d=0, t, s;
scanf("%d %d %d %d",&n,&m,&a,&b);
if ((float)b/m <= a){
t=(n/m);
d += t*b;
s = (n-(t*m))*a;
if(s<=b){
d+=s;
}
if(b<s){
d+=b;
}
printf("%d",d);
}
else{
printf("%d",(a*n));
}
return 0;
}
| 0.010864 | {} | c | Procedural | 100.00% |
#include "BST.h"
bst* createBST(){
return NULL;
}
info* createInfo(int value){
info* newInfo = (info*) calloc (1,sizeof(info));
newInfo->value = value;
return newInfo;
}
bst* createBSTNode(info* data){
bst* newNode = (bst*)calloc(1,sizeof(bst));
newNode->info = (info*) calloc(1,sizeof(info));
newNode->info = data;
printf("chave criada: [%i]\n", newNode->info->value);
return newNode;
}
bst* leftBST(bst* tree){
if(!tree) return NULL;
return tree->left;
}
bst* rightBST(bst* tree){
if(!tree) return NULL;
return tree->right;
}
void printpreOrder(bst* tree){
if(tree){
printf("|%i| ", tree->info->value);
printpreOrder(leftBST(tree));
printpreOrder(rightBST(tree));
}
else ("arvore vazia");
}
bst* searchBSTNode(bst* tree, bst* searchNode){
//printf("tree->info->value:%i\nsearchNode->info->value:%i\n", tree->info->value, searchNode->info->value);
if (!tree || tree->info->value == searchNode->info->value) return tree;
if(searchNode->info->value < tree->info->value) tree = searchBSTNode(leftBST(tree),searchNode);
else tree = searchBSTNode(rightBST(tree), searchNode);
return tree;
}
bst* searchBSTFather(bst* tree, bst* searchNode){
if (!tree || tree->info->value == searchNode->info->value) return NULL;
if(tree->right) if(tree->right->info->value == searchNode->info->value) return tree;
if(tree->left) if(tree->left->info->value == searchNode->info->value) return tree;
if(searchNode->info->value < tree->info->value) tree = searchBSTFather(leftBST(tree),searchNode);
else tree = searchBSTFather(rightBST(tree), searchNode);
}
bst* subInsertBSTNode(bst* tree, bst* newNode){
if (!tree){
return newNode;
}
if(newNode->info->value < tree->info->value) tree->left = subInsertBSTNode(leftBST(tree), newNode);
else tree->right = subInsertBSTNode(rightBST(tree), newNode);
return tree;
}
bst* insertBSTNode(bst* tree, info* data){
bst* newNode = createBSTNode(data);
bst* aux = tree;
bst* aux2;puts("51");
aux2 = subInsertBSTNode(aux, newNode);
printpreOrder(aux2);
return aux2;
}
bst* getLargerNode(bst* tree){
if (!tree || !tree->right) return tree;
tree = getLargerNode(rightBST(tree));
}
bst* getSmallerNode(bst* tree){
if (!tree || !tree->left) return tree;
tree = getSmallerNode(leftBST(tree));
}
int removeBSTNode(bst* tree, int value){
if(!tree) return 0;
else {
info* newInfo = createInfo(value);
bst* newNode = createBSTNode(newInfo);
bst* auxTree = tree;
auxTree = searchBSTNode(auxTree,newNode);
if (auxTree) printf("auxTree value:%i\n", auxTree->info->value);
bst* auxTreeFather = searchBSTFather(tree,auxTree);
if (auxTreeFather) printf("auxTreeFather value:%i\n", auxTreeFather->info->value);
printpreOrder(auxTree);
puts("86");
if (auxTree->left==NULL && auxTree->right==NULL){
if(auxTree->info == tree->info){
tree->right = NULL;
tree->left = NULL;
free(auxTree);
return 1;
}
else{
printf("No sendo removido:%i\n", auxTree->info->value);
printf("Pai:%i\n", auxTreeFather->info->value);
if(auxTreeFather > auxTree) auxTreeFather->left = NULL;
else auxTreeFather->right = NULL;
free(auxTree);
return 1;
}
}
if(auxTree->left!=NULL || auxTree->right!=NULL){
if(auxTree->left!=NULL && auxTree->right==NULL){
bst* aux = auxTree->left;
auxTree->info = auxTree->left->info;
auxTree->left = auxTree->left->left;
auxTree->right = auxTree->left->right;
free (aux);
return 1;
}
if(auxTree->right && !auxTree->left){
bst*aux = auxTree->right;
auxTree->info = auxTree->right->info;
auxTree->left = auxTree->right->left;
auxTree->right = auxTree->right->right;
free(aux);
return 1;
}
if(auxTree->left && auxTree->right){
bst* smaller;
bst* aux;
smaller = getSmallerNode(leftBST(auxTree));
aux = searchBSTFather(auxTree,smaller);
aux->left = NULL;
auxTree->info = smaller->info;
free(smaller);
}
}
return 1;
}
}
| #include "IMPORT_0"
bst* FUNC_0(){
return NULL;
}
info* FUNC_1(int value){
info* newInfo = (info*) FUNC_2 (1,sizeof(info));
newInfo->value = value;
return newInfo;
}
bst* FUNC_3(info* data){
bst* newNode = (bst*)FUNC_2(1,sizeof(bst));
newNode->info = (info*) FUNC_2(1,sizeof(info));
newNode->info = data;
printf("chave criada: [%i]\n", newNode->info->value);
return newNode;
}
bst* FUNC_4(bst* VAR_0){
if(!VAR_0) return NULL;
return VAR_0->left;
}
bst* rightBST(bst* VAR_0){
if(!VAR_0) return NULL;
return VAR_0->VAR_1;
}
void FUNC_5(bst* VAR_0){
if(VAR_0){
printf("|%i| ", VAR_0->info->value);
FUNC_5(FUNC_4(VAR_0));
FUNC_5(rightBST(VAR_0));
}
else ("arvore vazia");
}
bst* FUNC_6(bst* VAR_0, bst* searchNode){
//printf("tree->info->value:%i\nsearchNode->info->value:%i\n", tree->info->value, searchNode->info->value);
if (!VAR_0 || VAR_0->info->value == searchNode->info->value) return VAR_0;
if(searchNode->info->value < VAR_0->info->value) VAR_0 = FUNC_6(FUNC_4(VAR_0),searchNode);
else VAR_0 = FUNC_6(rightBST(VAR_0), searchNode);
return VAR_0;
}
bst* FUNC_7(bst* VAR_0, bst* searchNode){
if (!VAR_0 || VAR_0->info->value == searchNode->info->value) return NULL;
if(VAR_0->VAR_1) if(VAR_0->VAR_1->info->value == searchNode->info->value) return VAR_0;
if(VAR_0->left) if(VAR_0->left->info->value == searchNode->info->value) return VAR_0;
if(searchNode->info->value < VAR_0->info->value) VAR_0 = FUNC_7(FUNC_4(VAR_0),searchNode);
else VAR_0 = FUNC_7(rightBST(VAR_0), searchNode);
}
bst* subInsertBSTNode(bst* VAR_0, bst* newNode){
if (!VAR_0){
return newNode;
}
if(newNode->info->value < VAR_0->info->value) VAR_0->left = subInsertBSTNode(FUNC_4(VAR_0), newNode);
else VAR_0->VAR_1 = subInsertBSTNode(rightBST(VAR_0), newNode);
return VAR_0;
}
bst* FUNC_8(bst* VAR_0, info* data){
bst* newNode = FUNC_3(data);
bst* aux = VAR_0;
bst* VAR_2;puts("51");
VAR_2 = subInsertBSTNode(aux, newNode);
FUNC_5(VAR_2);
return VAR_2;
}
bst* getLargerNode(bst* VAR_0){
if (!VAR_0 || !VAR_0->VAR_1) return VAR_0;
VAR_0 = getLargerNode(rightBST(VAR_0));
}
bst* getSmallerNode(bst* VAR_0){
if (!VAR_0 || !VAR_0->left) return VAR_0;
VAR_0 = getSmallerNode(FUNC_4(VAR_0));
}
int FUNC_9(bst* VAR_0, int value){
if(!VAR_0) return 0;
else {
info* newInfo = FUNC_1(value);
bst* newNode = FUNC_3(newInfo);
bst* auxTree = VAR_0;
auxTree = FUNC_6(auxTree,newNode);
if (auxTree) printf("auxTree value:%i\n", auxTree->info->value);
bst* VAR_3 = FUNC_7(VAR_0,auxTree);
if (VAR_3) printf("auxTreeFather value:%i\n", VAR_3->info->value);
FUNC_5(auxTree);
puts("86");
if (auxTree->left==NULL && auxTree->VAR_1==NULL){
if(auxTree->info == VAR_0->info){
VAR_0->VAR_1 = NULL;
VAR_0->left = NULL;
free(auxTree);
return 1;
}
else{
printf("No sendo removido:%i\n", auxTree->info->value);
printf("Pai:%i\n", VAR_3->info->value);
if(VAR_3 > auxTree) VAR_3->left = NULL;
else VAR_3->VAR_1 = NULL;
free(auxTree);
return 1;
}
}
if(auxTree->left!=NULL || auxTree->VAR_1!=NULL){
if(auxTree->left!=NULL && auxTree->VAR_1==NULL){
bst* aux = auxTree->left;
auxTree->info = auxTree->left->info;
auxTree->left = auxTree->left->left;
auxTree->VAR_1 = auxTree->left->VAR_1;
free (aux);
return 1;
}
if(auxTree->VAR_1 && !auxTree->left){
bst*aux = auxTree->VAR_1;
auxTree->info = auxTree->VAR_1->info;
auxTree->left = auxTree->VAR_1->left;
auxTree->VAR_1 = auxTree->VAR_1->VAR_1;
free(aux);
return 1;
}
if(auxTree->left && auxTree->VAR_1){
bst* smaller;
bst* aux;
smaller = getSmallerNode(FUNC_4(auxTree));
aux = FUNC_7(auxTree,smaller);
aux->left = NULL;
auxTree->info = smaller->info;
free(smaller);
}
}
return 1;
}
}
| 0.455085 | {'IMPORT_0': 'BST.h', 'FUNC_0': 'createBST', 'FUNC_1': 'createInfo', 'FUNC_2': 'calloc', 'FUNC_3': 'createBSTNode', 'FUNC_4': 'leftBST', 'VAR_0': 'tree', 'VAR_1': 'right', 'FUNC_5': 'printpreOrder', 'FUNC_6': 'searchBSTNode', 'FUNC_7': 'searchBSTFather', 'FUNC_8': 'insertBSTNode', 'VAR_2': 'aux2', 'FUNC_9': 'removeBSTNode', 'VAR_3': 'auxTreeFather'} | c | Procedural | 100.00% |
// Copyright (c) 2009, Whispersoft s.r.l.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Whispersoft s.r.l. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: <NAME> & <NAME>
#ifndef __NET_RTMP_EVENTS_RTMP_EVENT_H__
#define __NET_RTMP_EVENTS_RTMP_EVENT_H__
#include <string>
#include <vector>
#include <whisperlib/common/base/types.h>
#include <whisperlib/common/base/log.h>
#include <whisperlib/common/base/ref_counted.h>
#include <whisperlib/common/io/buffer/memory_stream.h>
#include <whisperlib/common/io/num_streaming.h>
#include <whisperstreamlib/rtmp/objects/rtmp_objects.h>
#include <whisperstreamlib/rtmp/rtmp_consts.h>
#include <whisperstreamlib/rtmp/events/rtmp_header.h>
#include <whisperstreamlib/rtmp/objects/amf/amf0_util.h>
#include <whisperstreamlib/flv/flv_tag.h>
namespace rtmp {
// EventNotify, EventPing and EventInvoke in their different
// files, all other events are here.
class Event : public RefCounted {
public:
// Constructs an event based on a type and a header.
Event(const Header& header, EventType event_type, EventSubType event_subtype)
: header_(header),
event_type_(event_type),
event_subtype_(event_subtype) {
CHECK_EQ(header.event_type(), event_type);
}
virtual ~Event() {
}
EventType event_type() const {
return event_type_;
}
const char* event_type_name() const {
return EventTypeName(event_type());
}
EventSubType event_subtype() const {
return event_subtype_;
}
const char* event_subtype_name() const {
return EventSubTypeName(event_subtype_);
}
const Header& header() const {
return header_;
}
Header* mutable_header() {
return &header_;
}
virtual bool Equals(const Event* event) const {
return (event->event_type() == event_type() &&
event->event_subtype() == event_subtype());
}
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in,
AmfUtil::Version version) = 0;
virtual void EncodeBody(io::MemoryStream* out,
AmfUtil::Version version) const = 0;
string ToString() const {
return strutil::StringPrintf("Event{type: %s:%s, header: %s, %s}",
event_type_name(), event_subtype_name(), header_.ToString().c_str(),
ToStringAttr().c_str());
}
private:
// Subclasses must serialize their attributes in human readable form.
virtual string ToStringAttr() const = 0;
private:
Header header_;
const EventType event_type_;
const EventSubType event_subtype_;
private:
DISALLOW_EVIL_CONSTRUCTORS(Event);
};
inline ostream& operator<<(ostream& os, const Event& obj) {
return os << obj.ToString();
}
//////////////////////////////////////////////////////////////////////
// An event that has a bulk data member
// Extremely important: all ints in memory streams are big endian !!
class BulkDataEvent : public Event {
public:
BulkDataEvent(const Header& header,
EventType event_type,
EventSubType event_subtype,
int block_size = io::DataBlock::kDefaultBufferSize)
: Event(header, event_type, event_subtype),
data_(block_size) {
}
virtual ~BulkDataEvent() {
}
// Cannot do much w/ this getter .. but whatever..
const io::MemoryStream& data() const {
return data_;
}
// the meat..
io::MemoryStream* mutable_data() {
return &data_;
}
// moves data from in to our data buffer (clearing what is set before)
void set_data(io::MemoryStream* in) {
data_.Clear();
data_.AppendStream(in);
}
// append data from in to our data buffer
void append_data(io::MemoryStream* in) {
data_.AppendStream(in);
}
void append_data(const char* data, int32 size, Closure* disposer = NULL) {
data_.AppendRaw(data, size, disposer);
}
// copies data without destroying in
void copy_data(const io::MemoryStream* in) {
data_.Clear();
data_.AppendStreamNonDestructive(in);
}
virtual bool Equals(const Event* obj) const {
if ( !Event::Equals(obj) ) return false;
const BulkDataEvent* event = static_cast<const BulkDataEvent*>(obj);
return data_.Equals(event->data());
}
virtual string ToStringAttr() const {
return strutil::StringPrintf("data.size: %d", data_.Size());
}
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in,
AmfUtil::Version version) {
data_.AppendStream(in, in->Size());
return AmfUtil::READ_OK;
}
virtual void EncodeBody(io::MemoryStream* out,
AmfUtil::Version version) const {
out->AppendStreamNonDestructive(&data_);
}
protected:
io::MemoryStream data_;
DISALLOW_EVIL_CONSTRUCTORS(BulkDataEvent);
};
//////////////////////////////////////////////////////////////////////
// contains a single Video Tag
class EventVideoData : public BulkDataEvent {
public:
explicit EventVideoData(const Header& header)
: BulkDataEvent(header, EVENT_VIDEO_DATA, SUBTYPE_STREAM_DATA) {
}
// NO EncodeTag(), because Coder::EncodeWithAuxBuffer() offers a nice
// performance gain by encoding tag->data directly to Network stream
// Extracts 1 Video FlvTag from inside our body.
void DecodeTag(int64 timestamp_ms,
scoped_ref<streaming::FlvTag>* out) const;
private:
DISALLOW_EVIL_CONSTRUCTORS(EventVideoData);
};
// contains a single Audio Tag
class EventAudioData : public BulkDataEvent {
public:
explicit EventAudioData(const Header& header)
: BulkDataEvent(header, EVENT_AUDIO_DATA, SUBTYPE_STREAM_DATA) {
}
// NO EncodeTag(), because Coder::EncodeWithAuxBuffer() offers a nice
// performance gain by encoding tag->data directly to Network stream
// Extracts 1 Audio FlvTag from inside our body.
void DecodeTag(int64 timestamp_ms,
scoped_ref<streaming::FlvTag>* out) const;
private:
DISALLOW_EVIL_CONSTRUCTORS(EventAudioData);
};
// contains multiple Audio & Video Tags
class MediaDataEvent : public BulkDataEvent {
public:
explicit MediaDataEvent(const Header& header)
: BulkDataEvent(header, EVENT_MEDIA_DATA, SUBTYPE_STREAM_DATA),
first_tag_ts_(-1),
previous_tag_size_(0),
duration_ms_(0) {
}
int64 first_tag_ts() const { return first_tag_ts_; }
int64 duration_ms() const { return duration_ms_; }
// tag: tag to encode inside our body
// timestamp_ms: tag's timestamp (does not have to start on 0)
void EncodeAddTag(const streaming::FlvTag& tag, int64 timestamp_ms);
// After several EncodeAddTag(), call this method to finalize encoding
void EncodeFinalize();
// Decode all the tags inside our body.
// Offset tags timestamp by 'timestamp_ms'
void DecodeTags(int64 timestamp_ms,
vector<scoped_ref<streaming::FlvTag> >* out) const;
private:
int64 first_tag_ts_;
uint32 previous_tag_size_;
// accumulated tags duration (based on their timestamp)
int64 duration_ms_;
DISALLOW_EVIL_CONSTRUCTORS(MediaDataEvent);
};
//////////////////////////////////////////////////////////////////////
// NOTE: this is some kind of tricky stuff .. basically we use this
// *just to write* things that we know are metadata, and we don't
// want to split arround.
// They are read as notification events !
class EventStreamMetadata : public BulkDataEvent {
public:
explicit EventStreamMetadata(const Header& header)
: BulkDataEvent(header, EVENT_NOTIFY, SUBTYPE_SERVICE_CALL) {
}
virtual string ToStringAttr() const {
return strutil::StringPrintf("data.size: %d", data().Size());
}
private:
DISALLOW_EVIL_CONSTRUCTORS(EventStreamMetadata);
};
//////////////////////////////////////////////////////////////////////
// Events that have just one uint32 included
#define DECLARE_UINT32_EVENT(classname, evtype, evsubtype, member) \
class classname : public Event { \
public: \
classname(const Header& header, uint32 member) \
: Event(header, evtype, evsubtype), member##_(member) {} \
uint32 member() const { return member##_; } \
void set_##member(uint32 member) { member##_ = member; } \
virtual bool Equals(const Event* obj) const { \
if ( !Event::Equals(obj) ) return false; \
const classname* event = reinterpret_cast<const classname*>(obj); \
return event->member() == member(); \
} \
virtual string ToStringAttr() const { \
return strutil::StringPrintf(#member ": %d", member##_); \
} \
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in, \
AmfUtil::Version version) { \
if ( in->Size() < sizeof(member##_) ) { \
return AmfUtil::READ_NO_DATA; \
} \
member##_ = static_cast<uint32>(io::NumStreamer::ReadInt32(in, \
common::BIGENDIAN)); \
return AmfUtil::READ_OK; \
} \
virtual void EncodeBody(io::MemoryStream* out, \
AmfUtil::Version version) const { \
io::NumStreamer::WriteInt32(out, \
static_cast<int32>(member##_), \
common::BIGENDIAN); \
} \
private: \
uint32 member##_; \
DISALLOW_EVIL_CONSTRUCTORS(classname); \
}
// An event Sent every x bytes by both sides during read
DECLARE_UINT32_EVENT(EventBytesRead,
EVENT_BYTES_READ, SUBTYPE_STREAM_CONTROL,
bytes_read);
// Sets the protocol chunk size..
DECLARE_UINT32_EVENT(EventChunkSize,
EVENT_CHUNK_SIZE, SUBTYPE_SYSTEM,
chunk_size);
// This message is transmitted between client and server, it's meaning is
// unknown really (in terms of what bandwidth is expressed bps, Bps, etc),
// and in fact we don't really use it..
// see org.red5.server.net.rtmp.event.ServerBW
DECLARE_UINT32_EVENT(EventServerBW,
EVENT_SERVER_BANDWIDTH, SUBTYPE_STREAM_CONTROL,
bandwidth);
// This message is transmitted between client and server, it's meaning is
// unknown really (in terms of what bandwidth is expressed bps, Bps, etc),
// and in fact we don't really use it..
// see org.red5.server.net.rtmp.event.ClientBW
class EventClientBW : public Event {
public:
explicit EventClientBW(const Header& header, uint32 bandwidth, uint8 value2)
: Event(header, EVENT_CLIENT_BANDWIDTH, SUBTYPE_STREAM_CONTROL),
bandwidth_(bandwidth), value2_(value2) {
}
uint32 bandwidth() const { return bandwidth_; }
void set_bandwidth(uint32 bandwidth) { bandwidth_ = bandwidth; }
uint8 value2() const { return value2_; }
void set_value2(uint8 value2) { value2_ = value2; }
virtual bool Equals(const Event* obj) const {
if ( !Event::Equals(obj) ) return false;
const EventClientBW* event =
reinterpret_cast<const EventClientBW*>(obj);
return (event->bandwidth() == bandwidth() &&
event->value2() == value2());
}
virtual string ToStringAttr() const {
return strutil::StringPrintf("bandwidth_: %u, value2_: %hhu",
bandwidth_, value2_);
}
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in,
AmfUtil::Version version) {
if ( in->Size() < sizeof(bandwidth_) + sizeof(value2_) ) {
return AmfUtil::READ_NO_DATA;
}
bandwidth_ = static_cast<uint32>(io::NumStreamer::ReadInt32(in,
common::BIGENDIAN));
value2_ = uint8(io::NumStreamer::ReadByte(in));
return AmfUtil::READ_OK;
}
virtual void EncodeBody(io::MemoryStream* out,
AmfUtil::Version version) const {
io::NumStreamer::WriteInt32(out, bandwidth_, common::BIGENDIAN);
io::NumStreamer::WriteByte(out, value2_);
}
private:
uint32 bandwidth_;
uint8 value2_; // Unclear what this means ...
DISALLOW_EVIL_CONSTRUCTORS(EventClientBW);
};
// Flex message - seems to be just a vector of events
class EventFlexMessage : public Event {
public:
explicit EventFlexMessage(const Header& header)
: Event(header, EVENT_FLEX_MESSAGE, SUBTYPE_SERVICE_CALL),
unknown_(0) {
}
~EventFlexMessage() {
Clear();
}
// Returns a human readable string
virtual string ToStringAttr() const {
string s = "\n";
for ( uint32 i = 0; i < data_.size(); ++i ) {
s += strutil::StringPrintf("%5d: %s\n", i, data_[i]->ToString().c_str());
}
return s;
}
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in,
AmfUtil::Version version) {
if ( in->Size() < 1 ) {
return AmfUtil::READ_NO_DATA;
}
Clear();
unknown_ = io::NumStreamer::ReadByte(in);
while ( !in->IsEmpty() ) {
CObject* obj = NULL;
AmfUtil::ReadStatus err = Amf0Util::ReadNextObject(in, &obj);
if ( err != AmfUtil::READ_OK ) {
return err;
}
data_.push_back(obj);
}
return AmfUtil::READ_OK;
}
virtual void EncodeBody(
io::MemoryStream* out, AmfUtil::Version version) const {
io::NumStreamer::WriteByte(out, unknown_);
for ( uint32 i = 0; i < data_.size(); ++i ) {
data_[i]->Encode(out, version);
}
}
const vector<CObject*>& data() const { return data_; }
vector<CObject*>* mutable_data() { return &data_; }
void Clear() {
for ( uint32 i = 0; i < data_.size(); ++i ) {
delete data_[i];
}
data_.clear();
}
private:
uint8 unknown_;
vector<CObject*> data_;
private:
DISALLOW_EVIL_CONSTRUCTORS(EventFlexMessage);
};
//////////////////////////////////////////////////////////////////////
// The really stupid events - basically we don't know what they mean ..
class EventFlexSharedObject : public BulkDataEvent {
public:
explicit EventFlexSharedObject(const Header& header)
: BulkDataEvent(header, EVENT_FLEX_SHARED_OBJECT, SUBTYPE_SYSTEM) {
}
private:
DISALLOW_EVIL_CONSTRUCTORS(EventFlexSharedObject);
};
class EventSharedObject : public BulkDataEvent {
public:
explicit EventSharedObject(const Header& header)
: BulkDataEvent(header, EVENT_SHARED_OBJECT, SUBTYPE_SYSTEM) {
}
private:
DISALLOW_EVIL_CONSTRUCTORS(EventSharedObject);
};
//////////////////////////////////////////////////////////////////////
}
#endif // __NET_RTMP_EVENTS_RTMP_EVENT_H__
| // Copyright (c) 2009, Whispersoft s.r.l.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Whispersoft s.r.l. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: <NAME> & <NAME>
#ifndef VAR_0
#define VAR_0
#include <string>
#include <IMPORT_0>
#include <whisperlib/common/base/types.h>
#include <IMPORT_1>
#include <whisperlib/common/base/ref_counted.h>
#include <IMPORT_2>
#include <whisperlib/common/io/num_streaming.h>
#include <whisperstreamlib/rtmp/objects/rtmp_objects.h>
#include <whisperstreamlib/rtmp/rtmp_consts.h>
#include <whisperstreamlib/rtmp/events/rtmp_header.h>
#include <IMPORT_3>
#include <whisperstreamlib/flv/flv_tag.h>
namespace rtmp {
// EventNotify, EventPing and EventInvoke in their different
// files, all other events are here.
class VAR_1 : VAR_2 RefCounted {
public:
// Constructs an event based on a type and a header.
FUNC_0(const Header& header, VAR_3 event_type, EventSubType VAR_4)
: FUNC_2(header),
FUNC_3(event_type),
FUNC_4(VAR_4) {
CHECK_EQ(header.event_type(), event_type);
}
virtual ~FUNC_0() {
}
CLASS_1 event_type() const {
return VAR_6;
}
const char* FUNC_5() const {
return FUNC_6(event_type());
}
EventSubType FUNC_1() const {
return VAR_7;
}
const char* FUNC_7() const {
return FUNC_8(VAR_7);
}
const Header& header() const {
return VAR_5;
}
Header* FUNC_9() {
return &VAR_5;
}
virtual VAR_8 FUNC_10(const CLASS_0* VAR_9) const {
return (VAR_9->event_type() == event_type() &&
VAR_9->FUNC_1() == FUNC_1());
}
virtual VAR_10::VAR_11 DecodeBody(io::VAR_12* VAR_13,
CLASS_2::VAR_14 VAR_15) = 0;
virtual void EncodeBody(io::VAR_12* VAR_16,
CLASS_2::VAR_14 VAR_15) const = 0;
string FUNC_11() const {
return strutil::FUNC_12("Event{type: %s:%s, header: %s, %s}",
FUNC_5(), FUNC_7(), VAR_5.FUNC_11().c_str(),
FUNC_13().c_str());
}
private:
// Subclasses must serialize their attributes in human readable form.
virtual string FUNC_13() const = 0;
private:
Header VAR_5;
const CLASS_1 VAR_6;
const EventSubType VAR_7;
private:
FUNC_14(VAR_1);
};
inline ostream& VAR_17<<(ostream& VAR_18, const VAR_1& VAR_19) {
return VAR_18 << VAR_19.FUNC_11();
}
//////////////////////////////////////////////////////////////////////
// An event that has a bulk data member
// Extremely important: all ints in memory streams are big endian !!
class BulkDataEvent : VAR_2 VAR_1 {
public:
BulkDataEvent(const Header& header,
VAR_3 event_type,
EventSubType VAR_4,
VAR_20 block_size = io::VAR_21::VAR_22)
: FUNC_0(header, event_type, VAR_4),
FUNC_15(block_size) {
}
virtual ~BulkDataEvent() {
}
// Cannot do much w/ this getter .. but whatever..
const io::VAR_12& data() const {
return VAR_23;
}
// the meat..
io::VAR_12* FUNC_16() {
return &VAR_23;
}
// moves data from in to our data buffer (clearing what is set before)
void set_data(io::VAR_12* VAR_13) {
VAR_23.Clear();
VAR_23.AppendStream(VAR_13);
}
// append data from in to our data buffer
void append_data(io::VAR_12* VAR_13) {
VAR_23.AppendStream(VAR_13);
}
void append_data(const char* data, int32 size, CLASS_3* disposer = NULL) {
VAR_23.FUNC_17(data, size, disposer);
}
// copies data without destroying in
void copy_data(const io::VAR_12* VAR_13) {
VAR_23.Clear();
VAR_23.AppendStreamNonDestructive(VAR_13);
}
virtual VAR_8 FUNC_10(const CLASS_0* VAR_19) const {
if ( !VAR_1::FUNC_10(VAR_19) ) return false;
const BulkDataEvent* VAR_9 = VAR_24<const BulkDataEvent*>(VAR_19);
return VAR_23.FUNC_10(VAR_9->data());
}
virtual string FUNC_13() const {
return strutil::FUNC_12("data.size: %d", VAR_23.FUNC_18());
}
virtual VAR_10::VAR_11 DecodeBody(io::VAR_12* VAR_13,
CLASS_2::VAR_14 VAR_15) {
VAR_23.AppendStream(VAR_13, VAR_13->FUNC_18());
return VAR_10::VAR_25;
}
virtual void EncodeBody(io::VAR_12* VAR_16,
CLASS_2::VAR_14 VAR_15) const {
VAR_16->AppendStreamNonDestructive(&VAR_23);
}
protected:
io::VAR_12 VAR_23;
FUNC_14(BulkDataEvent);
};
//////////////////////////////////////////////////////////////////////
// contains a single Video Tag
class EventVideoData : VAR_2 BulkDataEvent {
public:
explicit EventVideoData(const Header& header)
: BulkDataEvent(header, EVENT_VIDEO_DATA, VAR_26) {
}
// NO EncodeTag(), because Coder::EncodeWithAuxBuffer() offers a nice
// performance gain by encoding tag->data directly to Network stream
// Extracts 1 Video FlvTag from inside our body.
void FUNC_19(int64 timestamp_ms,
scoped_ref<streaming::VAR_27>* VAR_16) const;
private:
FUNC_14(EventVideoData);
};
// contains a single Audio Tag
class EventAudioData : VAR_2 BulkDataEvent {
public:
explicit EventAudioData(const Header& header)
: BulkDataEvent(header, EVENT_AUDIO_DATA, VAR_26) {
}
// NO EncodeTag(), because Coder::EncodeWithAuxBuffer() offers a nice
// performance gain by encoding tag->data directly to Network stream
// Extracts 1 Audio FlvTag from inside our body.
void FUNC_19(int64 timestamp_ms,
scoped_ref<streaming::VAR_27>* VAR_16) const;
private:
FUNC_14(EventAudioData);
};
// contains multiple Audio & Video Tags
class VAR_28 : VAR_2 BulkDataEvent {
public:
explicit VAR_28(const Header& header)
: BulkDataEvent(header, EVENT_MEDIA_DATA, CLASS_4),
FUNC_20(-1),
previous_tag_size_(0),
duration_ms_(0) {
}
int64 first_tag_ts() const { return VAR_29; }
int64 duration_ms() const { return duration_ms_; }
// tag: tag to encode inside our body
// timestamp_ms: tag's timestamp (does not have to start on 0)
void FUNC_21(const streaming::VAR_27& VAR_30, int64 timestamp_ms);
// After several EncodeAddTag(), call this method to finalize encoding
void FUNC_22();
// Decode all the tags inside our body.
// Offset tags timestamp by 'timestamp_ms'
void DecodeTags(int64 timestamp_ms,
IMPORT_0<scoped_ref<streaming::VAR_27> >* VAR_16) const;
private:
int64 VAR_29;
CLASS_5 previous_tag_size_;
// accumulated tags duration (based on their timestamp)
int64 duration_ms_;
FUNC_14(VAR_28);
};
//////////////////////////////////////////////////////////////////////
// NOTE: this is some kind of tricky stuff .. basically we use this
// *just to write* things that we know are metadata, and we don't
// want to split arround.
// They are read as notification events !
class EventStreamMetadata : VAR_2 BulkDataEvent {
public:
explicit EventStreamMetadata(const Header& header)
: BulkDataEvent(header, VAR_32, VAR_33) {
}
virtual string FUNC_13() const {
return strutil::FUNC_12("data.size: %d", data().FUNC_18());
}
private:
FUNC_14(EventStreamMetadata);
};
//////////////////////////////////////////////////////////////////////
// Events that have just one uint32 included
#define FUNC_23(classname, VAR_34, evsubtype, VAR_35) \
class classname : public Event { \
public: \
classname(const Header& header, uint32 member) \
: Event(header, evtype, evsubtype), member##_(member) {} \
uint32 member() const { return member##_; } \
void set_##member(uint32 member) { member##_ = member; } \
virtual bool Equals(const Event* obj) const { \
if ( !Event::Equals(obj) ) return false; \
const classname* event = reinterpret_cast<const classname*>(obj); \
return event->member() == member(); \
} \
virtual string ToStringAttr() const { \
return strutil::StringPrintf(#member ": %d", member##_); \
} \
virtual AmfUtil::ReadStatus DecodeBody(io::MemoryStream* in, \
AmfUtil::Version version) { \
if ( in->Size() < sizeof(member##_) ) { \
return AmfUtil::READ_NO_DATA; \
} \
member##_ = static_cast<uint32>(io::NumStreamer::ReadInt32(in, \
common::BIGENDIAN)); \
return AmfUtil::READ_OK; \
} \
virtual void EncodeBody(io::MemoryStream* out, \
AmfUtil::Version version) const { \
io::NumStreamer::WriteInt32(out, \
static_cast<int32>(member##_), \
common::BIGENDIAN); \
} \
private: \
uint32 member##_; \
DISALLOW_EVIL_CONSTRUCTORS(classname); \
}
// An event Sent every x bytes by both sides during read
FUNC_23(VAR_36,
VAR_37, VAR_38,
bytes_read);
// Sets the protocol chunk size..
FUNC_23(VAR_39,
EVENT_CHUNK_SIZE, SUBTYPE_SYSTEM,
chunk_size);
// This message is transmitted between client and server, it's meaning is
// unknown really (in terms of what bandwidth is expressed bps, Bps, etc),
// and in fact we don't really use it..
// see org.red5.server.net.rtmp.event.ServerBW
FUNC_23(VAR_40,
EVENT_SERVER_BANDWIDTH, VAR_38,
bandwidth);
// This message is transmitted between client and server, it's meaning is
// unknown really (in terms of what bandwidth is expressed bps, Bps, etc),
// and in fact we don't really use it..
// see org.red5.server.net.rtmp.event.ClientBW
class EventClientBW : VAR_2 VAR_1 {
public:
explicit EventClientBW(const Header& header, VAR_31 bandwidth, VAR_41 VAR_42)
: FUNC_0(header, VAR_43, VAR_38),
bandwidth_(bandwidth), value2_(VAR_42) {
}
VAR_31 bandwidth() const { return bandwidth_; }
void FUNC_26(CLASS_5 bandwidth) { bandwidth_ = bandwidth; }
CLASS_7 FUNC_25() const { return value2_; }
void set_value2(CLASS_7 VAR_42) { value2_ = VAR_42; }
virtual VAR_8 FUNC_10(const CLASS_0* VAR_19) const {
if ( !VAR_1::FUNC_10(VAR_19) ) return false;
const EventClientBW* VAR_9 =
VAR_44<const EventClientBW*>(VAR_19);
return (VAR_9->bandwidth() == bandwidth() &&
VAR_9->FUNC_25() == FUNC_25());
}
virtual string FUNC_13() const {
return strutil::FUNC_12("bandwidth_: %u, value2_: %hhu",
bandwidth_, value2_);
}
virtual VAR_10::VAR_11 DecodeBody(io::VAR_12* VAR_13,
CLASS_2::VAR_14 VAR_15) {
if ( VAR_13->FUNC_18() < sizeof(bandwidth_) + sizeof(value2_) ) {
return VAR_10::VAR_45;
}
bandwidth_ = VAR_24<VAR_31>(io::NumStreamer::ReadInt32(VAR_13,
common::VAR_46));
value2_ = FUNC_24(io::NumStreamer::FUNC_27(VAR_13));
return VAR_10::VAR_25;
}
virtual void EncodeBody(io::VAR_12* VAR_16,
CLASS_2::VAR_14 VAR_15) const {
io::NumStreamer::WriteInt32(VAR_16, bandwidth_, common::VAR_46);
io::NumStreamer::FUNC_28(VAR_16, value2_);
}
private:
VAR_31 bandwidth_;
CLASS_7 value2_; // Unclear what this means ...
FUNC_14(EventClientBW);
};
// Flex message - seems to be just a vector of events
class EventFlexMessage : VAR_2 VAR_1 {
public:
explicit EventFlexMessage(const Header& header)
: FUNC_0(header, CLASS_8, CLASS_6),
FUNC_29(0) {
}
~EventFlexMessage() {
Clear();
}
// Returns a human readable string
virtual string FUNC_13() const {
string VAR_48 = "\n";
for ( CLASS_5 VAR_49 = 0; VAR_49 < VAR_23.size(); ++VAR_49 ) {
VAR_48 += strutil::FUNC_12("%5d: %s\n", VAR_49, VAR_23[VAR_49]->FUNC_11().c_str());
}
return VAR_48;
}
virtual VAR_10::VAR_11 DecodeBody(io::VAR_12* VAR_13,
CLASS_2::VAR_14 VAR_15) {
if ( VAR_13->FUNC_18() < 1 ) {
return VAR_10::VAR_45;
}
Clear();
VAR_47 = io::NumStreamer::FUNC_27(VAR_13);
while ( !VAR_13->FUNC_30() ) {
CLASS_9* VAR_19 = NULL;
AmfUtil::VAR_11 VAR_51 = Amf0Util::ReadNextObject(VAR_13, &VAR_19);
if ( VAR_51 != VAR_10::VAR_25 ) {
return VAR_51;
}
VAR_23.FUNC_31(VAR_19);
}
return VAR_10::VAR_25;
}
virtual void EncodeBody(
io::VAR_12* VAR_16, CLASS_2::VAR_14 VAR_15) const {
io::NumStreamer::FUNC_28(VAR_16, VAR_47);
for ( CLASS_5 VAR_49 = 0; VAR_49 < VAR_23.size(); ++VAR_49 ) {
VAR_23[VAR_49]->FUNC_32(VAR_16, VAR_15);
}
}
const IMPORT_0<VAR_50*>& data() const { return VAR_23; }
IMPORT_0<VAR_50*>* FUNC_16() { return &VAR_23; }
void Clear() {
for ( CLASS_5 VAR_49 = 0; VAR_49 < VAR_23.size(); ++VAR_49 ) {
CLASS_10 VAR_23[VAR_49];
}
VAR_23.FUNC_33();
}
private:
VAR_41 VAR_47;
IMPORT_0<VAR_50*> VAR_23;
private:
FUNC_14(EventFlexMessage);
};
//////////////////////////////////////////////////////////////////////
// The really stupid events - basically we don't know what they mean ..
class VAR_52 : VAR_2 BulkDataEvent {
public:
explicit VAR_52(const Header& header)
: BulkDataEvent(header, VAR_53, SUBTYPE_SYSTEM) {
}
private:
FUNC_14(VAR_52);
};
class VAR_54 : VAR_2 BulkDataEvent {
public:
explicit VAR_54(const Header& header)
: BulkDataEvent(header, EVENT_SHARED_OBJECT, SUBTYPE_SYSTEM) {
}
private:
FUNC_14(VAR_54);
};
//////////////////////////////////////////////////////////////////////
}
#endif // __NET_RTMP_EVENTS_RTMP_EVENT_H__
| 0.565608 | {'VAR_0': '__NET_RTMP_EVENTS_RTMP_EVENT_H__', 'IMPORT_0': 'vector', 'IMPORT_1': 'whisperlib/common/base/log.h', 'IMPORT_2': 'whisperlib/common/io/buffer/memory_stream.h', 'IMPORT_3': 'whisperstreamlib/rtmp/objects/amf/amf0_util.h', 'VAR_1': 'Event', 'FUNC_0': 'Event', 'CLASS_0': 'Event', 'VAR_2': 'public', 'VAR_3': 'EventType', 'CLASS_1': 'EventType', 'VAR_4': 'event_subtype', 'FUNC_1': 'event_subtype', 'FUNC_2': 'header_', 'VAR_5': 'header_', 'FUNC_3': 'event_type_', 'VAR_6': 'event_type_', 'FUNC_4': 'event_subtype_', 'VAR_7': 'event_subtype_', 'FUNC_5': 'event_type_name', 'FUNC_6': 'EventTypeName', 'FUNC_7': 'event_subtype_name', 'FUNC_8': 'EventSubTypeName', 'FUNC_9': 'mutable_header', 'VAR_8': 'bool', 'FUNC_10': 'Equals', 'VAR_9': 'event', 'VAR_10': 'AmfUtil', 'CLASS_2': 'AmfUtil', 'VAR_11': 'ReadStatus', 'VAR_12': 'MemoryStream', 'VAR_13': 'in', 'VAR_14': 'Version', 'VAR_15': 'version', 'VAR_16': 'out', 'FUNC_11': 'ToString', 'FUNC_12': 'StringPrintf', 'FUNC_13': 'ToStringAttr', 'FUNC_14': 'DISALLOW_EVIL_CONSTRUCTORS', 'VAR_17': 'operator', 'VAR_18': 'os', 'VAR_19': 'obj', 'VAR_20': 'int', 'VAR_21': 'DataBlock', 'VAR_22': 'kDefaultBufferSize', 'FUNC_15': 'data_', 'VAR_23': 'data_', 'FUNC_16': 'mutable_data', 'CLASS_3': 'Closure', 'FUNC_17': 'AppendRaw', 'VAR_24': 'static_cast', 'FUNC_18': 'Size', 'VAR_25': 'READ_OK', 'VAR_26': 'SUBTYPE_STREAM_DATA', 'CLASS_4': 'SUBTYPE_STREAM_DATA', 'FUNC_19': 'DecodeTag', 'VAR_27': 'FlvTag', 'VAR_28': 'MediaDataEvent', 'FUNC_20': 'first_tag_ts_', 'VAR_29': 'first_tag_ts_', 'FUNC_21': 'EncodeAddTag', 'VAR_30': 'tag', 'FUNC_22': 'EncodeFinalize', 'CLASS_5': 'uint32', 'VAR_31': 'uint32', 'VAR_32': 'EVENT_NOTIFY', 'VAR_33': 'SUBTYPE_SERVICE_CALL', 'CLASS_6': 'SUBTYPE_SERVICE_CALL', 'FUNC_23': 'DECLARE_UINT32_EVENT', 'VAR_34': 'evtype', 'VAR_35': 'member', 'VAR_36': 'EventBytesRead', 'VAR_37': 'EVENT_BYTES_READ', 'VAR_38': 'SUBTYPE_STREAM_CONTROL', 'VAR_39': 'EventChunkSize', 'VAR_40': 'EventServerBW', 'VAR_41': 'uint8', 'CLASS_7': 'uint8', 'FUNC_24': 'uint8', 'VAR_42': 'value2', 'FUNC_25': 'value2', 'VAR_43': 'EVENT_CLIENT_BANDWIDTH', 'FUNC_26': 'set_bandwidth', 'VAR_44': 'reinterpret_cast', 'VAR_45': 'READ_NO_DATA', 'VAR_46': 'BIGENDIAN', 'FUNC_27': 'ReadByte', 'FUNC_28': 'WriteByte', 'CLASS_8': 'EVENT_FLEX_MESSAGE', 'FUNC_29': 'unknown_', 'VAR_47': 'unknown_', 'VAR_48': 's', 'VAR_49': 'i', 'FUNC_30': 'IsEmpty', 'CLASS_9': 'CObject', 'VAR_50': 'CObject', 'VAR_51': 'err', 'FUNC_31': 'push_back', 'FUNC_32': 'Encode', 'CLASS_10': 'delete', 'FUNC_33': 'clear', 'VAR_52': 'EventFlexSharedObject', 'VAR_53': 'EVENT_FLEX_SHARED_OBJECT', 'VAR_54': 'EventSharedObject'} | c | Procedural | 14.24% |
/*
Copyright 2015 Bloomberg Finance L.P.
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.
*/
/*
* Comdb2 sql command line client.
*
* $Id: client.c 88379 2013-12-11 20:11:12Z mkhullar $
*/
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <signal.h>
#include <unistd.h>
#include <bb_getopt_long.h>
#include <sbuf2.h>
#include <string.h>
#include <str0.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "cdb2api.h"
#include <pthread.h>
#include <assert.h>
#include "mem.h"
#include "cdb2_constants.h"
#include "epochlib.h"
static char *dbname = NULL;
static char *dbtype = NULL;
static char *dbhostname = NULL;
static char main_prompt[MAX_DBNAME_LENGTH + 2];
static unsigned char gbl_in_stmt = 0;
static unsigned char gbl_sent_cancel_cnonce = 0;
/* display mode */
enum {
DEFAULT = 0x0000, /* default output */
TABS = 0x0001, /* separate columns by tabs */
BINARY = 0x0002, /* output binary */
GENSQL = 0x0004, /* generate insert statements */
/* flags */
STDERR = 0x1000
};
static int show_ports = 0;
static int debug_trace = 0;
static int pausemode = 0;
static int printmode = DEFAULT;
static int scriptmode = 0;
static int error = 0;
static int set_debug = 0;
static cdb2_hndl_tp *cdb2h = NULL;
static int time_mode = 0;
static int rowsleep = 0;
static int string_blobs = 0;
static int show_effects = 0;
static char doublefmt[32];
static int docost = 0;
static int maxretries = 0;
static FILE *redirect = NULL;
static int hold_stdout = -1;
static char *history_file = NULL;
static int istty = 0;
static char *gensql_tbl = NULL;
static char *prompt = main_prompt;
static void hexdump(FILE *f, void *datap, int len)
{
u_char *data = (u_char *)datap;
int i;
for (i = 0; i < len; i++)
fprintf(f, "%02x", (unsigned int)data[i]);
}
void dumpstring(FILE *f, char *s, int quotes, int quote_quotes)
{
if (quotes)
fprintf(f, "'");
while (*s) {
if (*s == '\'' && quote_quotes)
fprintf(f, "''");
else
fprintf(f, "%c", *s);
s++;
}
if (quotes)
fprintf(f, "'");
}
static const char *usage_text =
"Usage: cdb2sql [options] dbname [sql [type1 [type2 ...]]]\n"
"\n"
"Options:\n"
" -c, --cdb2cfg FL Set the config file to FL\n"
" --cost Log the cost of query in db trace files\n"
" --debugtrace Set debug trace flag on api handle\n"
" -f, --file FL Read queries from the specified file FL\n"
" -h, --help Help on usage \n"
" -n, --host HOST Host to connect to and run query.\n"
" -p, --precision # Set precision for floation point outputs\n"
" -s, --script Script mode (less verbose output)\n"
" --showeffects Show the effects of query at the end\n"
" --strblobs Display blobs as strings\n"
" --tabs Set column separator to tabs rather than commas\n"
" -t, --type TYPE Type of database or tier ('dev' or 'prod',"
" default 'local')\n"
"\n"
" Examples: \n"
" * Querying db with name mydb on local server \n"
" cdb2sql mydb 'select 1'\n"
" * Query db via interactive session:\n"
" cdb2sql mydb - \n"
" * Query db by connecting to a specific server:\n"
" cdb2sql mydb --host node1 'select 1'\n"
" * Query db by connecting to a known set of servers/ports:\n"
" cdb2sql mydb @node1:port=19007,node2:port=19000 'select 1'\n";
void cdb2sql_usage(int exit_val)
{
fprintf((exit_val == EXIT_SUCCESS) ? stdout : stderr, usage_text);
exit(exit_val);
}
const char *words[] = {
"ALTER", "ANALYZE",
"BEGIN",
"COMMIT",
"CREATE",
"DELETE", "DROP", "DRYRUN",
"EXEC", "EXPLAIN",
"INSERT",
"PUT",
"REBUILD",
"ROLLBACK",
"SELECT", "SELECTV", "SET",
"TRUNCATE",
"UPDATE",
"WITH", NULL, }; // must be terminated by NULL
// Generator function for word completion.
char *level_one_generator (const char *text, int state)
{
static int list_index, len;
const char *name;
if (!state) { //if state is 0 get the length of text
list_index = 0;
len = strlen (text);
}
while (name = words[list_index]) {
list_index++;
if (len == 0 || strncasecmp (name, text, len) == 0) {
return strdup (name);
}
}
return ((char *) NULL); // If no names matched, then return NULL.
}
char *db_generator (int state, const char *sql)
{
static char **db_words;
static int list_index, len;
const char *name;
if (!state) { //if state is 0 get the completions from the db
cdb2_hndl_tp *cdb2h_2 = NULL; // use a new db handle
if (db_words) {
char *wrd;
list_index = 0;
while ((wrd = db_words[list_index])) {
free(wrd);
db_words[list_index] = NULL;
list_index++;
}
free(db_words);
db_words = NULL;
}
list_index = 0;
int rc;
if (dbhostname) {
rc = cdb2_open(&cdb2h_2, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h_2, dbname, dbtype, 0);
}
if (rc) {
if (debug_trace)
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h_2);
return ((char *) NULL);
}
rc = cdb2_run_statement(cdb2h_2, sql);
if (rc) {
if (debug_trace)
fprintf(stderr, "failed to run sql '%s'\n", sql);
return ((char *) NULL);
}
int ncols = cdb2_numcolumns(cdb2h_2);
assert(ncols == 1);
int count = 0;
int sz = 0;
while ((rc = cdb2_next_record(cdb2h_2)) == CDB2_OK) {
if ( sz < count + 1 ) {
sz = (sz == 0) ? 32 : sz * 2;
void * m = (char**) realloc(db_words, sz * sizeof(char *));
if (!m) {
fprintf(stderr, "error with malloc/realloc\n");
abort();
break;
}
db_words = m;
}
void *val = cdb2_column_value(cdb2h_2, 0);
assert(count < sz);
db_words[count] = strdup((char*) val);
count++;
}
if (db_words)
db_words[count] = NULL; //last one always NULL
cdb2_close(cdb2h_2);
}
if (!db_words)
return ((char *) NULL);
while (name = db_words[list_index]) {
list_index++;
return strdup(name);
}
return ((char *) NULL); // If no names matched, then return NULL.
}
char *tunables_generator (const char *text, int state)
{
char sql[256];
if (*text)
//TODO: escape text
snprintf(sql, sizeof(sql),
"SELECT DISTINCT name FROM comdb2_tunables WHERE name LIKE '%s%%'", text);
else
snprintf(sql, sizeof(sql),
"SELECT DISTINCT name FROM comdb2_tunables");
return db_generator(state, sql);
}
char *generic_generator(const char *text, int state)
{
char sql[256];
//TODO: escape text
snprintf(sql, sizeof(sql),
"SELECT DISTINCT candidate "
"FROM comdb2_completion('%s')", text);
return db_generator(state, sql);
}
// Custom completion function
static char **my_completion (const char *text, int start, int end)
{
rl_attempted_completion_over = 1; // skip directory listing
char *bgn = rl_line_buffer;
while(*bgn && *bgn == ' ') bgn++; // skip beginning spaces
char *endptr = bgn;
while(*endptr) endptr++; //go to end
if(endptr == bgn)
return rl_completion_matches ((char *) text, &level_one_generator);
endptr--;
// find last space (or will hit bgn)
while(endptr != bgn && *endptr != ' ')
endptr--;
if(endptr == bgn)
return rl_completion_matches ((char *) text, &level_one_generator);
// find end of previous word
while(endptr != bgn && *endptr == ' ')
endptr--;
char *lastw = endptr;
// find begining of previous word
while(lastw != bgn && *lastw != ' ')
lastw--;
lastw++;
int l = sizeof("TUNABLE") - 1;
if(endptr - lastw + 1 == l && strncasecmp(lastw, "TUNABLE", l) == 0)
return rl_completion_matches ((char *) text, &tunables_generator);
else
return rl_completion_matches ((char *) text, &generic_generator);
}
static char *read_line()
{
static char *line = NULL;
if (istty) {
if (line) {
free(line);
line = NULL;
}
if ((line = readline(prompt)) != NULL && line[0] != 0)
add_history(line);
return line;
}
static size_t sz = 0;
ssize_t n = getline(&line, &sz, stdin);
if (n == -1) {
if (line) {
free(line);
line = NULL;
}
return NULL;
}
if (line[n - 1] == '\n')
line[n - 1] = 0;
return line;
}
#define checkfortype(str, STRTYPE, ret) \
do { \
int l = sizeof(STRTYPE) - 1; \
if (strncasecmp((str), STRTYPE, l) == 0) { \
(str) += l; \
return ret; \
} \
} while (0)
int get_type(const char **sqlstr)
{
// char * strptr = *sqlstr;
while (isspace(**sqlstr))
(*sqlstr)++;
if (strncasecmp(*sqlstr, "CDB2_", 5) != 0) {
printf("Type expected after @bind\n");
return -1;
}
*sqlstr += 5; // skip CDB2_
checkfortype(*sqlstr, "INTEGER", CDB2_INTEGER);
checkfortype(*sqlstr, "REAL", CDB2_REAL);
checkfortype(*sqlstr, "CSTRING", CDB2_CSTRING);
checkfortype(*sqlstr, "BLOB", CDB2_BLOB);
checkfortype(*sqlstr, "DATETIME", CDB2_DATETIME);
checkfortype(*sqlstr, "INTERVALYM", CDB2_INTERVALYM);
checkfortype(*sqlstr, "INTERVALDS", CDB2_INTERVALDS);
return -1;
}
char *get_parameter(const char **sqlstr)
{
while (isspace(**sqlstr))
(*sqlstr)++;
const char *end = *sqlstr;
while (!isspace(*end))
end++;
int len = end - (*sqlstr);
if (len < 1) {
printf("Parameter name expected after type\n");
return NULL;
}
char *copy = strndup(*sqlstr, len);
*sqlstr = end;
return copy;
}
void *get_val(const char **sqlstr, int type, int *vallen)
{
while (isspace(**sqlstr))
(*sqlstr)++;
const char *end = *sqlstr;
while (*end)
end++; // till \0
int len = end - (*sqlstr);
if (len < 1) {
printf("Value expected after parameter\n");
return NULL;
}
if (type == CDB2_INTEGER) {
int64_t i = atol(*sqlstr);
int64_t *val = malloc(sizeof(int64_t));
*val = i;
*vallen = sizeof(*val);
return val;
} else if (type == CDB2_REAL) {
double d = atof(*sqlstr);
double *val = malloc(sizeof(double));
*val = d;
*vallen = sizeof(*val);
return val;
} else if (type == CDB2_CSTRING) {
char *val = strndup(*sqlstr, end - (*sqlstr));
*vallen = len;
return val;
} else if (type == CDB2_DATETIME) {
cdb2_client_datetime_t *dt = calloc(sizeof(cdb2_client_datetime_t), 1);
int rc = sscanf(*sqlstr, "%04d-%02d-%02dT%02d:%02d:%02d",
&dt->tm.tm_year, &dt->tm.tm_mon, &dt->tm.tm_mday,
&dt->tm.tm_hour, &dt->tm.tm_min, &dt->tm.tm_sec);
/* timezone not supported for now */
if (rc != 6) {
fprintf(stderr,
"invalid datetime (need format YYYY-MM-ddThh:mm:ss\n");
return NULL;
}
dt->msec = 0;
dt->tzname[0] = 0;
dt->tm.tm_year -= 1900;
dt->tm.tm_mon--;
*vallen = sizeof(*dt);
return dt;
} else {
/* ?? */
}
return NULL;
}
static int process_escape(const char *cmdstr)
{
char copy[256];
char *lasts;
static const char *delims = " \r\n\t";
char *tok;
int len = strlen(cmdstr);
strncpy(copy, cmdstr, sizeof(copy));
copy[len] = '\0';
/* get first token, skip @ */
tok = strtok_r(copy + 1, delims, &lasts);
if (!tok)
return 0;
if (strcmp(tok, "cdb2_close") == 0) {
cdb2_close(cdb2h);
cdb2h = NULL;
} else if (strcmp(tok, "redirect") == 0) {
tok = strtok_r(NULL, delims, &lasts);
/* Close the redirect file. */
if (!tok && redirect) {
fclose(redirect);
redirect = NULL;
/* Move the saved stdout back to the real stdout. */
dup2(hold_stdout, 1);
close(hold_stdout);
hold_stdout = -1;
}
/* User didn't supply a filename. */
else if (!tok) {
fprintf(stderr, "expected redirect filename.\n");
return -1;
} else {
if (redirect)
fclose(redirect);
if (NULL == (redirect = fopen(tok, "w"))) {
fprintf(stderr, "error opening redirect file, %s.\n",
strerror(errno));
return -1;
}
if (-1 == hold_stdout) {
hold_stdout = dup(1);
}
dup2(fileno(redirect), 1);
}
} else if (strcmp(tok, "row_sleep") == 0) {
tok = strtok_r(NULL, delims, &lasts);
if (!tok) {
fprintf(stderr, "expected row sleep in seconds\n");
return -1;
}
rowsleep = atoi(tok);
} else if (strcmp(tok, "strblobs") == 0) {
string_blobs = 1;
printf("Blobs will be displayed as strings\n");
} else if (strcmp(tok, "hexblobs") == 0) {
string_blobs = 0;
printf("Blobs will be displayed as hex\n");
} else if (strcmp(tok, "time") == 0) {
time_mode = time_mode ? 0 : 1;
printf("Timing mode %s\n", time_mode ? "ON" : "OFF");
} else {
fprintf(stderr, "unknown command %s\n", tok);
return -1;
}
return 0;
}
void printCol(FILE *f, cdb2_hndl_tp *cdb2h, void *val, int col, int printmode)
{
switch (cdb2_column_type(cdb2h, col)) {
case CDB2_INTEGER:
if (printmode == DEFAULT)
fprintf(f, "%s=%lld", cdb2_column_name(cdb2h, col),
*(long long *)val);
else
fprintf(f, "%lld", *(long long *)val);
break;
case CDB2_REAL:
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, doublefmt, *(double *)val);
break;
case CDB2_CSTRING:
if (printmode == DEFAULT) {
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
dumpstring(f, (char *)val, 1, 0);
} else if (printmode & TABS)
dumpstring(f, (char *)val, 0, 0);
else
dumpstring(f, (char *)val, 1, 1);
break;
case CDB2_BLOB:
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
if (string_blobs) {
char *c = val;
int len = cdb2_column_size(cdb2h, col);
fputc('\'', stdout);
while (len > 0) {
if (isprint(*c) || *c == '\n' || *c == '\t') {
fputc(*c, stdout);
} else {
fprintf(f, "\\x%02x", (int)*c);
}
len--;
c++;
}
fputc('\'', stdout);
} else {
if (printmode == BINARY) {
write(1, val, cdb2_column_size(cdb2h, col));
exit(0);
} else {
fprintf(f, "x'");
hexdump(f, val, cdb2_column_size(cdb2h, col));
fprintf(f, "'");
}
}
break;
case CDB2_DATETIME: {
cdb2_client_datetime_t *cdt = (cdb2_client_datetime_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%4.4u-%2.2u-%2.2uT%2.2u%2.2u%2.2u.%3.3u %s\"",
cdt->tm.tm_year + 1900, cdt->tm.tm_mon + 1, cdt->tm.tm_mday,
cdt->tm.tm_hour, cdt->tm.tm_min, cdt->tm.tm_sec, cdt->msec,
cdt->tzname);
break;
}
case CDB2_DATETIMEUS: {
cdb2_client_datetimeus_t *cdt = (cdb2_client_datetimeus_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%4.4u-%2.2u-%2.2uT%2.2u%2.2u%2.2u.%6.6u %s\"",
cdt->tm.tm_year + 1900, cdt->tm.tm_mon + 1, cdt->tm.tm_mday,
cdt->tm.tm_hour, cdt->tm.tm_min, cdt->tm.tm_sec, cdt->usec,
cdt->tzname);
break;
}
case CDB2_INTERVALYM: {
cdb2_client_intv_ym_t *ym = (cdb2_client_intv_ym_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u-%u\"", (ym->sign < 0) ? "- " : "", ym->years,
ym->months);
break;
}
case CDB2_INTERVALDS: {
cdb2_client_intv_ds_t *ds = (cdb2_client_intv_ds_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u %2.2u:%2.2u:%2.2u.%3.3u\"",
(ds->sign < 0) ? "- " : "", ds->days, ds->hours, ds->mins,
ds->sec, ds->msec);
break;
}
case CDB2_INTERVALDSUS: {
cdb2_client_intv_dsus_t *ds = (cdb2_client_intv_dsus_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u %2.2u:%2.2u:%2.2u.%6.6u\"",
(ds->sign < 0) ? "- " : "", ds->days, ds->hours, ds->mins,
ds->sec, ds->usec);
break;
}
}
}
static int run_statement(const char *sql, int ntypes, int *types,
int *start_time, int *run_time)
{
int rc;
int ncols;
int col;
int cost;
FILE *out = stdout;
char cmd[60];
int startms, rowms, endms;
if (printmode & STDERR)
out = stderr;
startms = time_epochms();
*start_time = 0;
*run_time = 0;
if (cdb2h == NULL) {
if (dbhostname) {
rc = cdb2_open(&cdb2h, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h, dbname, dbtype, 0);
}
cdb2_push_context(cdb2h, "cdb2sql");
if (rc) {
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h);
cdb2h = NULL;
return 1;
}
if (debug_trace) {
cdb2_set_debug_trace(cdb2h);
}
if (show_ports) {
cdb2_dump_ports(cdb2h, stderr);
}
if (maxretries) {
cdb2_set_max_retries(maxretries);
}
if (docost) {
rc = cdb2_run_statement(cdb2h, "set getcost on");
if (rc) {
fprintf(stderr, "failed to run set getcost 1\n");
return 1;
}
}
/*
Check and set user and password if they have been specified using
the environment variables.
Note: It is good to report the user about the use of environment
variables to set user/password to avoid any surprises.
*/
int length;
if (getenv("COMDB2_USER")) {
length = snprintf(cmd, sizeof(cmd), "set user %s",
getenv("COMDB2_USER"));
if (length > sizeof(cmd)) {
fprintf(stderr, "COMDB2_USER too long, ignored\n");
} else {
if ((length < 0) || ((cdb2_run_statement(cdb2h, cmd)) != 0)) {
fprintf(stderr, "Failed to set user using COMDB2_USER, "
"exiting\n");
return 1;
} else {
printf("Set user using COMDB2_USER\n");
}
}
}
if (getenv("COMDB2_PASSWORD")) {
length = snprintf(cmd, sizeof(cmd), "set password %s",
getenv("COMDB2_PASSWORD"));
if (length > sizeof(cmd)) {
fprintf(stderr, "COMDB2_PASSWORD too long, ignored\n");
} else {
if ((length < 0) || ((cdb2_run_statement(cdb2h, cmd)) != 0)) {
fprintf(stderr, "Failed to set password using "
"COMDB2_PASSWORD, exiting\n");
return 1;
} else {
printf("Set password using COMDB2_PASSWORD\n");
}
}
}
}
/* Bind parameter ability -- useful for debugging */
if (sql[0] == '@') {
if (strncasecmp(sql, "@bind", 5) == 0) {
//@bind BINDTYPE parameter value
sql += 5;
int type = get_type(&sql);
if (type < 0)
return -1;
char *parameter = get_parameter(&sql);
if (parameter == NULL)
return -1;
int length;
void *value = get_val(&sql, type, &length);
rc = cdb2_bind_param(cdb2h, parameter, type, value, length);
/* we have to leak parameter here -- freeing breaks the bind */
} else
rc = process_escape(sql);
return rc;
}
{
int retries = 0;
while (retries < 10) {
rc = cdb2_run_statement_typed(cdb2h, sql, ntypes, types);
if (rc != CDB2ERR_IO_ERROR)
break;
retries++;
}
}
rowms = time_epochms();
*start_time = rowms - startms;
cdb2_clearbindings(cdb2h);
if (rc != CDB2_OK) {
const char *err = cdb2_errstr(cdb2h);
/* cdb2tcm mode needs to pass this info through stdout */
FILE *out = stderr;
fprintf(out, "[%s] failed with rc %d %s\n", sql, rc, err ? err : "");
return rc;
}
ncols = cdb2_numcolumns(cdb2h);
while ((rc = cdb2_next_record(cdb2h)) == CDB2_OK) {
if (printmode == DEFAULT)
fprintf(out, "(");
else if (printmode == GENSQL) {
printf("insert into %s (", gensql_tbl);
for (col = 0; col < ncols; col++) {
printf("%s", cdb2_column_name(cdb2h, col));
if (col != ncols - 1)
printf(", ");
}
printf(") values (");
}
for (col = 0; col < ncols; col++) {
void *val = cdb2_column_value(cdb2h, col);
if (val == NULL) {
if (printmode == DEFAULT)
fprintf(out, "%s=NULL", cdb2_column_name(cdb2h, col));
else
fprintf(out, "NULL");
} else {
printCol(out, cdb2h, val, col, printmode);
}
if (col != ncols - 1) {
if (printmode == DEFAULT)
fprintf(out, ", ");
else if (printmode & TABS)
fprintf(out, "\t");
else
fprintf(out, ", ");
}
}
switch (printmode) {
case DEFAULT:
fprintf(out, ")\n");
break;
case TABS:
fprintf(out, "\n");
break;
case GENSQL:
fprintf(out, ");\n");
break;
}
fflush(out);
if (rowsleep)
sleep(rowsleep);
if (pausemode) {
char input[128];
int cmd;
printf(">");
fflush(stdout);
if (fgets(input, sizeof(input), stdin) == input) {
cmd = atoi(input);
if (cmd == -1)
pausemode = 0;
}
}
}
endms = time_epochms();
*run_time = endms - startms;
if (rc != CDB2_OK_DONE) {
const char *err = cdb2_errstr(cdb2h);
fprintf(stderr, "[%s] failed with rc %d %s\n", sql, rc, err ? err : "");
return rc;
}
if (show_effects) {
cdb2_effects_tp effects;
if (cdb2_get_effects(cdb2h, &effects) == 0) {
printf("Number of rows affected %d\n", effects.num_affected);
printf("Number of rows selected %d\n", effects.num_selected);
printf("Number of rows deleted %d\n", effects.num_deleted);
printf("Number of rows updated %d\n", effects.num_updated);
printf("Number of rows inserted %d\n", effects.num_inserted);
} else {
printf("Effects not sent by comdb2 server. \n");
}
}
return 0;
}
static void process_line(char *sql, int ntypes, int *types)
{
char *sqlstr = sql;
int rc;
int len;
/* Trim whitespace and then ignore comments */
while (isspace(*sqlstr))
sqlstr++;
if (sqlstr[0] == '#' || sqlstr[0] == '\0')
return;
/* Lame hack - strip trailing ; so that we can understand the
* sql generated by our own gensql mode. Note that the sql
* parser in comdb2 is ok with semicolons - it stops after the
* first one it encounters. */
len = strlen(sqlstr);
while (len > 0 && isspace(sqlstr[len - 1]))
len--;
while (len > 0 && sqlstr[len - 1] == ';')
len--;
sqlstr[len] = '\0';
int start_time_ms, run_time_ms;
gbl_in_stmt = 1;
rc = run_statement(sqlstr, ntypes, types, &start_time_ms, &run_time_ms);
gbl_in_stmt = 0;
gbl_sent_cancel_cnonce = 0;
if (rc != 0) {
error++;
} else if (!scriptmode) {
printf("[%s] rc %d\n", sqlstr, rc);
if (time_mode) {
printf(" prep time %d ms\n", start_time_ms);
printf(" run time %d ms\n", run_time_ms);
}
}
if (docost) {
int saved_printmode = printmode;
printmode = TABS | STDERR;
const char *costSql = "SELECT comdb2_prevquerycost() as Cost";
run_statement(costSql, ntypes, types, &start_time_ms, &run_time_ms);
printmode = saved_printmode;
}
}
void load_readline_history()
{
char *home;
if ((home = getenv("HOME")) == NULL)
return;
char histfile[] = "/.cdb2sql_history";
if ((history_file = malloc(strlen(home) + sizeof(histfile))) == NULL)
return;
sprintf(history_file, "%s%s", home, histfile);
read_history(history_file);
}
#define HISTFILE_COMMANDS 200
void save_readline_history()
{
stifle_history(HISTFILE_COMMANDS);
write_history(history_file);
free(history_file);
}
static int *process_typed_statement_args(int ntypes, char **args)
{
int *types = NULL;
if (ntypes > 0)
types = malloc(ntypes * sizeof(int));
for (int i = 0; i < ntypes; i++) {
if (strcmp(args[i], "integer") == 0)
types[i] = CDB2_INTEGER;
else if (strcmp(args[i], "real") == 0)
types[i] = CDB2_REAL;
else if (strcmp(args[i], "cstring") == 0)
types[i] = CDB2_CSTRING;
else if (strcmp(args[i], "blob") == 0)
types[i] = CDB2_BLOB;
else {
char *endp;
types[i] = strtol(args[i], &endp, 10);
if (*endp != 0) {
fprintf(stderr, "Unknown type %s\n", args[i]);
exit(EXIT_FAILURE);
}
}
}
return types;
}
static int is_multi_line(const char *sql)
{
if (sql == NULL)
return 0;
while (isspace(*sql))
++sql;
if (strncasecmp(sql, "create", 6) == 0) {
sql += 6;
while (isspace(*sql))
++sql;
if (*sql == '\0' || strncasecmp(sql, "table", 5) == 0 ||
strncasecmp(sql, "procedure", 9) == 0)
return 1;
} else if (strncasecmp(sql, "alter", 5) == 0) {
sql += 5;
while (isspace(*sql))
++sql;
if (*sql == '\0' || strncasecmp(sql, "table", 5) == 0) {
return 1;
}
}
return 0;
}
static char *get_multi_line_statement(char *line)
{
char *stmt = NULL;
int slen = 0;
char *nl = ""; // new-line
int n = 0; // len of nl
char tmp_prompt[sizeof(main_prompt)];
int spaces = strlen(dbname) - 3, dots = 3;
if (spaces < 0) {
dots += spaces;
spaces = 0;
}
sprintf(tmp_prompt, "%.*s%.*s> ", spaces,
" ",
dots, "...");
prompt = tmp_prompt;
do {
int len = strlen(line);
int newlen = slen + len + n;
stmt = realloc(stmt, newlen + 1);
sprintf(&stmt[slen], "%s%s", nl, line);
slen = newlen;
if (stmt[slen - 2] == '$' && stmt[slen - 1] == '$') {
stmt[slen - 2] = '\0';
break;
}
nl = "\n";
n = 1;
} while ((line = read_line()) != NULL);
prompt = main_prompt;
return stmt;
}
static int dbtype_valid(char *type)
{
if (type && (type[0] == '@' || strcasecmp(type, "dev") == 0 ||
strcasecmp(type, "uat") == 0 ||
strcasecmp(type, "default") == 0 ||
strcasecmp(type, "alpha") == 0 ||
strcasecmp(type, "beta") == 0 ||
strcasecmp(type, "local") == 0 ||
strcasecmp(type, "prod") == 0)) {
return 1;
}
return 0;
}
static void replace_args(int argc, char *argv[])
{
int ii;
for (ii = 1; ii < argc; ii++) {
if (argv[ii][0] != '-')
continue;
if (!strcmp(argv[ii], "-pause"))
argv[ii] = "--pause";
else if (!strcmp(argv[ii], "-binary"))
argv[ii] = "--binary";
else if (!strcmp(argv[ii], "-tabs"))
argv[ii] = "--tabs";
else if (!strcmp(argv[ii], "-strblobs"))
argv[ii] = "--strblobs";
else if (!strcmp(argv[ii], "-debug"))
argv[ii] = "--debug";
else if (!strcmp(argv[ii], "-debugtrace"))
argv[ii] = "--debugtrace";
else if (!strcmp(argv[ii], "-showports"))
argv[ii] = "--showports";
else if (!strcmp(argv[ii], "-showeffects"))
argv[ii] = "--showeffects";
else if (!strcmp(argv[ii], "-cost"))
argv[ii] = "--cost";
else if (!strcmp(argv[ii], "-exponent"))
argv[ii] = "--exponent";
else if (!strcmp(argv[ii], "-isatty"))
argv[ii] = "--isatty";
else if (!strcmp(argv[ii], "-isnotatty"))
argv[ii] = "--isnotatty";
else if (!strcmp(argv[ii], "-help"))
argv[ii] = "--help";
else if (!strcmp(argv[ii], "-script"))
argv[ii] = "--script";
else if (!strcmp(argv[ii], "-maxretries"))
argv[ii] = "--maxretries";
else if (!strcmp(argv[ii], "-precision"))
argv[ii] = "--precision";
else if (!strcmp(argv[ii], "-cdb2cfg"))
argv[ii] = "--cdb2cfg";
else if (!strcmp(argv[ii], "-file"))
argv[ii] = "--file";
else if (!strcmp(argv[ii], "-gensql"))
argv[ii] = "--gensql";
else if (!strcmp(argv[ii], "-type"))
argv[ii] = "--type";
else if (!strcmp(argv[ii], "-host"))
argv[ii] = "--host";
}
}
void send_cancel_cnonce(const char *cnonce)
{
if (!gbl_in_stmt) return;
cdb2_hndl_tp *cdb2h_2 = NULL; // use a new db handle
int rc;
if (dbhostname) {
rc = cdb2_open(&cdb2h_2, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h_2, dbname, dbtype, 0);
}
if (rc) {
if (debug_trace)
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h_2);
return;
}
char expanded[256];
for (int i = 0; i < 256 / 2 && cnonce[i] != '\0'; i++) {
sprintf(&expanded[i * 2], "%2x", cnonce[i]);
}
char sql[256];
snprintf(sql, 255, "exec procedure sys.cmd.send('sql cancelcnonce %s')",
expanded);
if (debug_trace) printf("Cancel sql string '%s'\n", sql);
rc = cdb2_run_statement(cdb2h_2, sql);
if (!rc)
gbl_sent_cancel_cnonce = 1;
else if (debug_trace)
fprintf(stderr, "failed to cancel rc %d with '%s'\n", rc, sql);
cdb2_close(cdb2h_2);
}
/* If ctrl_c was pressed to clear existing line and go to new line
* If we see two ctrl_c in a row we exit.
* However, after a ctrl_c if user typed something
* (rl_line_buffer is not empty) and then issue a ctrl_c then dont exit.
*/
static void int_handler(int signum)
{
if (gbl_in_stmt && !gbl_sent_cancel_cnonce)
printf("Requesting to cancel query (press Ctrl-C to exit program). "
"Please wait...\n");
if (gbl_sent_cancel_cnonce) exit(1); // pressed ctrl-c again
if (!gbl_in_stmt) {
rl_crlf();
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
send_cancel_cnonce(cdb2_cnonce(cdb2h));
}
int main(int argc, char *argv[])
{
static char *filename = NULL;
static int precision = 0;
static int exponent = 0;
static int isttyarg = 0;
static char *sql = NULL;
int ntypes = 0;
int *types = NULL;
int opt_indx = 0;
int c;
comdb2ma_init(0, 0);
sigignore(SIGPIPE);
replace_args(argc, argv);
static struct option long_options[] = {
{"pause", no_argument, &pausemode, 1},
{"binary", no_argument, &printmode, BINARY},
{"tabs", no_argument, &printmode, TABS},
{"strblobs", no_argument, &string_blobs, 1},
{"debug", no_argument, &set_debug, 1},
{"debugtrace", no_argument, &debug_trace, 1},
{"showports", no_argument, &show_ports, 1},
{"showeffects",no_argument, &show_effects, 1},
{"cost", no_argument, &docost, 1},
{"exponent", no_argument, &exponent, 1},
{"isatty", no_argument, &isttyarg, 1},
{"isnotatty", no_argument, &isttyarg, 2},
{"help", no_argument, NULL, 'h'},
{"script", no_argument, NULL, 's'},
{"maxretries", required_argument, NULL, 'r'},
{"precision", required_argument, NULL, 'p'},
{"cdb2cfg", required_argument, NULL, 'c'},
{"file", required_argument, NULL, 'f'},
{"gensql", required_argument, NULL, 'g'},
{"type", required_argument, NULL, 't'},
{"host", required_argument, NULL, 'n'},
{0, 0, 0, 0}
};
while ((c = bb_getopt_long(argc, argv, "hsr:p:c:f:g:t:n:", long_options,
&opt_indx)) != -1) {
switch (c) {
case 0:
break;
case 'h':
cdb2sql_usage(EXIT_SUCCESS);
break;
case 's':
scriptmode = 1;
break;
case 'r':
maxretries = atoi(optarg);
break;
case 'p':
precision = atoi(optarg);
break;
case 'c':
cdb2_set_comdb2db_config(optarg);
break;
case 'f':
filename = optarg;
break;
case 'g':
printmode = GENSQL;
gensql_tbl = optarg;
break;
case 't':
dbtype = optarg;
break;
case 'n':
dbhostname = optarg;
break;
case '?':
cdb2sql_usage(EXIT_FAILURE);
break;
}
}
if (getenv("COMDB2_IOLBF")) {
setvbuf(stdout, 0, _IOLBF, 0);
setvbuf(stderr, 0, _IOLBF, 0);
}
if (getenv("COMDB2_SQL_COST"))
docost = 1;
if (exponent) {
if (precision > 0) {
snprintf(doublefmt, sizeof(doublefmt), "%%.%dg", precision);
} else {
snprintf(doublefmt, sizeof(doublefmt), "%%g");
}
} else if (precision > 0) {
snprintf(doublefmt, sizeof(doublefmt), "%%.%df", precision);
} else {
snprintf(doublefmt, sizeof(doublefmt), "%%f");
}
if (argc - optind < 1) {
cdb2sql_usage(EXIT_FAILURE);
}
if (strlen(argv[optind]) >= MAX_DBNAME_LENGTH) {
fprintf(stderr, "DB name \"%s\" too long\n", dbname);
return 1;
}
dbname = argv[optind];
optind++;
if (dbtype == NULL && dbtype_valid(argv[optind])) {
dbtype = argv[optind];
optind++;
} else {
dbtype = "local"; /* might want "default" here */
}
sql = (optind < argc ? argv[optind] : "-");
sprintf(main_prompt, "%s> ", dbname);
optind++;
ntypes = argc - optind;
if (ntypes > 0)
types = process_typed_statement_args(ntypes, &argv[optind]);
if (sql && *sql != '-') {
scriptmode = 1;
process_line(sql, ntypes, types);
if (cdb2h) {
cdb2_close(cdb2h);
}
return (error == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
if (filename) {
if (freopen(filename, "r", stdin) == NULL) {
fprintf(stderr, "Error opening %s: %s\n", filename,
strerror(errno));
return EXIT_FAILURE;
}
} else if (sql == NULL || *sql != '-') {
cdb2sql_usage(EXIT_FAILURE);
}
istty = isatty(0);
if (isttyarg == 1)
istty = 1;
if (isttyarg == 2)
istty = 0;
if (istty) {
rl_attempted_completion_function = my_completion;
load_readline_history();
struct sigaction sact;
sact.sa_handler = int_handler;
sigaction(SIGINT, &sact, NULL);
}
char *line;
int multi;
while ((line = read_line()) != NULL) {
if (strncmp(line, "quit", 4) == 0)
break;
if ((multi = is_multi_line(line)) != 0)
line = get_multi_line_statement(line);
process_line(line, 0, NULL);
if (multi)
free(line);
}
if (istty)
save_readline_history();
if (cdb2h) {
cdb2_close(cdb2h);
cdb2h = NULL;
}
return (error == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
| /*
Copyright 2015 Bloomberg Finance L.P.
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.
*/
/*
* Comdb2 sql command line client.
*
* $Id: client.c 88379 2013-12-11 20:11:12Z mkhullar $
*/
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <signal.h>
#include <unistd.h>
#include <bb_getopt_long.h>
#include <IMPORT_0>
#include <string.h>
#include <str0.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "cdb2api.h"
#include <pthread.h>
#include <assert.h>
#include "mem.h"
#include "cdb2_constants.h"
#include "epochlib.h"
static char *dbname = NULL;
static char *dbtype = NULL;
static char *dbhostname = NULL;
static char main_prompt[MAX_DBNAME_LENGTH + 2];
static unsigned char gbl_in_stmt = 0;
static unsigned char gbl_sent_cancel_cnonce = 0;
/* display mode */
enum {
DEFAULT = 0x0000, /* default output */
TABS = 0x0001, /* separate columns by tabs */
BINARY = 0x0002, /* output binary */
GENSQL = 0x0004, /* generate insert statements */
/* flags */
STDERR = 0x1000
};
static int show_ports = 0;
static int VAR_0 = 0;
static int pausemode = 0;
static int printmode = DEFAULT;
static int scriptmode = 0;
static int error = 0;
static int set_debug = 0;
static cdb2_hndl_tp *cdb2h = NULL;
static int time_mode = 0;
static int rowsleep = 0;
static int string_blobs = 0;
static int show_effects = 0;
static char doublefmt[32];
static int docost = 0;
static int maxretries = 0;
static FILE *redirect = NULL;
static int hold_stdout = -1;
static char *history_file = NULL;
static int istty = 0;
static char *gensql_tbl = NULL;
static char *prompt = main_prompt;
static void hexdump(FILE *f, void *datap, int len)
{
u_char *data = (u_char *)datap;
int i;
for (i = 0; i < len; i++)
fprintf(f, "%02x", (unsigned int)data[i]);
}
void dumpstring(FILE *f, char *s, int quotes, int quote_quotes)
{
if (quotes)
fprintf(f, "'");
while (*s) {
if (*s == '\'' && quote_quotes)
fprintf(f, "''");
else
fprintf(f, "%c", *s);
s++;
}
if (quotes)
fprintf(f, "'");
}
static const char *usage_text =
"Usage: cdb2sql [options] dbname [sql [type1 [type2 ...]]]\n"
"\n"
"Options:\n"
" -c, --cdb2cfg FL Set the config file to FL\n"
" --cost Log the cost of query in db trace files\n"
" --debugtrace Set debug trace flag on api handle\n"
" -f, --file FL Read queries from the specified file FL\n"
" -h, --help Help on usage \n"
" -n, --host HOST Host to connect to and run query.\n"
" -p, --precision # Set precision for floation point outputs\n"
" -s, --script Script mode (less verbose output)\n"
" --showeffects Show the effects of query at the end\n"
" --strblobs Display blobs as strings\n"
" --tabs Set column separator to tabs rather than commas\n"
" -t, --type TYPE Type of database or tier ('dev' or 'prod',"
" default 'local')\n"
"\n"
" Examples: \n"
" * Querying db with name mydb on local server \n"
" cdb2sql mydb 'select 1'\n"
" * Query db via interactive session:\n"
" cdb2sql mydb - \n"
" * Query db by connecting to a specific server:\n"
" cdb2sql mydb --host node1 'select 1'\n"
" * Query db by connecting to a known set of servers/ports:\n"
" cdb2sql mydb @node1:port=19007,node2:port=19000 'select 1'\n";
void FUNC_0(int exit_val)
{
fprintf((exit_val == EXIT_SUCCESS) ? stdout : stderr, usage_text);
exit(exit_val);
}
const char *words[] = {
"ALTER", "ANALYZE",
"BEGIN",
"COMMIT",
"CREATE",
"DELETE", "DROP", "DRYRUN",
"EXEC", "EXPLAIN",
"INSERT",
"PUT",
"REBUILD",
"ROLLBACK",
"SELECT", "SELECTV", "SET",
"TRUNCATE",
"UPDATE",
"WITH", NULL, }; // must be terminated by NULL
// Generator function for word completion.
char *level_one_generator (const char *text, int state)
{
static int list_index, len;
const char *name;
if (!state) { //if state is 0 get the length of text
list_index = 0;
len = strlen (text);
}
while (name = words[list_index]) {
list_index++;
if (len == 0 || strncasecmp (name, text, len) == 0) {
return strdup (name);
}
}
return ((char *) NULL); // If no names matched, then return NULL.
}
char *db_generator (int state, const char *sql)
{
static char **db_words;
static int list_index, len;
const char *name;
if (!state) { //if state is 0 get the completions from the db
cdb2_hndl_tp *cdb2h_2 = NULL; // use a new db handle
if (db_words) {
char *wrd;
list_index = 0;
while ((wrd = db_words[list_index])) {
free(wrd);
db_words[list_index] = NULL;
list_index++;
}
free(db_words);
db_words = NULL;
}
list_index = 0;
int rc;
if (dbhostname) {
rc = cdb2_open(&cdb2h_2, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h_2, dbname, dbtype, 0);
}
if (rc) {
if (VAR_0)
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h_2);
return ((char *) NULL);
}
rc = cdb2_run_statement(cdb2h_2, sql);
if (rc) {
if (VAR_0)
fprintf(stderr, "failed to run sql '%s'\n", sql);
return ((char *) NULL);
}
int ncols = cdb2_numcolumns(cdb2h_2);
assert(ncols == 1);
int count = 0;
int sz = 0;
while ((rc = cdb2_next_record(cdb2h_2)) == CDB2_OK) {
if ( sz < count + 1 ) {
sz = (sz == 0) ? 32 : sz * 2;
void * m = (char**) realloc(db_words, sz * sizeof(char *));
if (!m) {
fprintf(stderr, "error with malloc/realloc\n");
abort();
break;
}
db_words = m;
}
void *val = cdb2_column_value(cdb2h_2, 0);
assert(count < sz);
db_words[count] = strdup((char*) val);
count++;
}
if (db_words)
db_words[count] = NULL; //last one always NULL
cdb2_close(cdb2h_2);
}
if (!db_words)
return ((char *) NULL);
while (name = db_words[list_index]) {
list_index++;
return strdup(name);
}
return ((char *) NULL); // If no names matched, then return NULL.
}
char *tunables_generator (const char *text, int state)
{
char sql[256];
if (*text)
//TODO: escape text
snprintf(sql, sizeof(sql),
"SELECT DISTINCT name FROM comdb2_tunables WHERE name LIKE '%s%%'", text);
else
snprintf(sql, sizeof(sql),
"SELECT DISTINCT name FROM comdb2_tunables");
return db_generator(state, sql);
}
char *generic_generator(const char *text, int state)
{
char sql[256];
//TODO: escape text
snprintf(sql, sizeof(sql),
"SELECT DISTINCT candidate "
"FROM comdb2_completion('%s')", text);
return db_generator(state, sql);
}
// Custom completion function
static char **my_completion (const char *text, int start, int end)
{
VAR_1 = 1; // skip directory listing
char *bgn = rl_line_buffer;
while(*bgn && *bgn == ' ') bgn++; // skip beginning spaces
char *endptr = bgn;
while(*endptr) endptr++; //go to end
if(endptr == bgn)
return rl_completion_matches ((char *) text, &level_one_generator);
endptr--;
// find last space (or will hit bgn)
while(endptr != bgn && *endptr != ' ')
endptr--;
if(endptr == bgn)
return rl_completion_matches ((char *) text, &level_one_generator);
// find end of previous word
while(endptr != bgn && *endptr == ' ')
endptr--;
char *lastw = endptr;
// find begining of previous word
while(lastw != bgn && *lastw != ' ')
lastw--;
lastw++;
int l = sizeof("TUNABLE") - 1;
if(endptr - lastw + 1 == l && strncasecmp(lastw, "TUNABLE", l) == 0)
return rl_completion_matches ((char *) text, &tunables_generator);
else
return rl_completion_matches ((char *) text, &generic_generator);
}
static char *read_line()
{
static char *line = NULL;
if (istty) {
if (line) {
free(line);
line = NULL;
}
if ((line = readline(prompt)) != NULL && line[0] != 0)
add_history(line);
return line;
}
static size_t sz = 0;
ssize_t n = getline(&line, &sz, stdin);
if (n == -1) {
if (line) {
free(line);
line = NULL;
}
return NULL;
}
if (line[n - 1] == '\n')
line[n - 1] = 0;
return line;
}
#define checkfortype(str, STRTYPE, ret) \
do { \
int l = sizeof(STRTYPE) - 1; \
if (strncasecmp((str), STRTYPE, l) == 0) { \
(str) += l; \
return ret; \
} \
} while (0)
int get_type(const char **sqlstr)
{
// char * strptr = *sqlstr;
while (isspace(**sqlstr))
(*sqlstr)++;
if (strncasecmp(*sqlstr, "CDB2_", 5) != 0) {
printf("Type expected after @bind\n");
return -1;
}
*sqlstr += 5; // skip CDB2_
checkfortype(*sqlstr, "INTEGER", CDB2_INTEGER);
checkfortype(*sqlstr, "REAL", CDB2_REAL);
checkfortype(*sqlstr, "CSTRING", CDB2_CSTRING);
checkfortype(*sqlstr, "BLOB", CDB2_BLOB);
checkfortype(*sqlstr, "DATETIME", CDB2_DATETIME);
checkfortype(*sqlstr, "INTERVALYM", CDB2_INTERVALYM);
checkfortype(*sqlstr, "INTERVALDS", CDB2_INTERVALDS);
return -1;
}
char *get_parameter(const char **sqlstr)
{
while (isspace(**sqlstr))
(*sqlstr)++;
const char *end = *sqlstr;
while (!isspace(*end))
end++;
int len = end - (*sqlstr);
if (len < 1) {
printf("Parameter name expected after type\n");
return NULL;
}
char *copy = strndup(*sqlstr, len);
*sqlstr = end;
return copy;
}
void *get_val(const char **sqlstr, int type, int *vallen)
{
while (isspace(**sqlstr))
(*sqlstr)++;
const char *end = *sqlstr;
while (*end)
end++; // till \0
int len = end - (*sqlstr);
if (len < 1) {
printf("Value expected after parameter\n");
return NULL;
}
if (type == CDB2_INTEGER) {
int64_t i = atol(*sqlstr);
int64_t *val = malloc(sizeof(int64_t));
*val = i;
*vallen = sizeof(*val);
return val;
} else if (type == CDB2_REAL) {
double d = atof(*sqlstr);
double *val = malloc(sizeof(double));
*val = d;
*vallen = sizeof(*val);
return val;
} else if (type == CDB2_CSTRING) {
char *val = strndup(*sqlstr, end - (*sqlstr));
*vallen = len;
return val;
} else if (type == CDB2_DATETIME) {
cdb2_client_datetime_t *dt = calloc(sizeof(cdb2_client_datetime_t), 1);
int rc = sscanf(*sqlstr, "%04d-%02d-%02dT%02d:%02d:%02d",
&dt->tm.tm_year, &dt->tm.tm_mon, &dt->tm.tm_mday,
&dt->tm.tm_hour, &dt->tm.tm_min, &dt->tm.tm_sec);
/* timezone not supported for now */
if (rc != 6) {
fprintf(stderr,
"invalid datetime (need format YYYY-MM-ddThh:mm:ss\n");
return NULL;
}
dt->msec = 0;
dt->tzname[0] = 0;
dt->tm.tm_year -= 1900;
dt->tm.tm_mon--;
*vallen = sizeof(*dt);
return dt;
} else {
/* ?? */
}
return NULL;
}
static int process_escape(const char *cmdstr)
{
char copy[256];
char *lasts;
static const char *delims = " \r\n\t";
char *tok;
int len = strlen(cmdstr);
strncpy(copy, cmdstr, sizeof(copy));
copy[len] = '\0';
/* get first token, skip @ */
tok = strtok_r(copy + 1, delims, &lasts);
if (!tok)
return 0;
if (strcmp(tok, "cdb2_close") == 0) {
cdb2_close(cdb2h);
cdb2h = NULL;
} else if (strcmp(tok, "redirect") == 0) {
tok = strtok_r(NULL, delims, &lasts);
/* Close the redirect file. */
if (!tok && redirect) {
fclose(redirect);
redirect = NULL;
/* Move the saved stdout back to the real stdout. */
dup2(hold_stdout, 1);
close(hold_stdout);
hold_stdout = -1;
}
/* User didn't supply a filename. */
else if (!tok) {
fprintf(stderr, "expected redirect filename.\n");
return -1;
} else {
if (redirect)
fclose(redirect);
if (NULL == (redirect = fopen(tok, "w"))) {
fprintf(stderr, "error opening redirect file, %s.\n",
strerror(errno));
return -1;
}
if (-1 == hold_stdout) {
hold_stdout = dup(1);
}
dup2(fileno(redirect), 1);
}
} else if (strcmp(tok, "row_sleep") == 0) {
tok = strtok_r(NULL, delims, &lasts);
if (!tok) {
fprintf(stderr, "expected row sleep in seconds\n");
return -1;
}
rowsleep = atoi(tok);
} else if (strcmp(tok, "strblobs") == 0) {
string_blobs = 1;
printf("Blobs will be displayed as strings\n");
} else if (strcmp(tok, "hexblobs") == 0) {
string_blobs = 0;
printf("Blobs will be displayed as hex\n");
} else if (strcmp(tok, "time") == 0) {
time_mode = time_mode ? 0 : 1;
printf("Timing mode %s\n", time_mode ? "ON" : "OFF");
} else {
fprintf(stderr, "unknown command %s\n", tok);
return -1;
}
return 0;
}
void FUNC_1(FILE *f, cdb2_hndl_tp *cdb2h, void *val, int col, int printmode)
{
switch (cdb2_column_type(cdb2h, col)) {
case CDB2_INTEGER:
if (printmode == DEFAULT)
fprintf(f, "%s=%lld", cdb2_column_name(cdb2h, col),
*(long long *)val);
else
fprintf(f, "%lld", *(long long *)val);
break;
case CDB2_REAL:
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, doublefmt, *(double *)val);
break;
case CDB2_CSTRING:
if (printmode == DEFAULT) {
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
dumpstring(f, (char *)val, 1, 0);
} else if (printmode & TABS)
dumpstring(f, (char *)val, 0, 0);
else
dumpstring(f, (char *)val, 1, 1);
break;
case CDB2_BLOB:
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
if (string_blobs) {
char *c = val;
int len = cdb2_column_size(cdb2h, col);
fputc('\'', stdout);
while (len > 0) {
if (isprint(*c) || *c == '\n' || *c == '\t') {
fputc(*c, stdout);
} else {
fprintf(f, "\\x%02x", (int)*c);
}
len--;
c++;
}
fputc('\'', stdout);
} else {
if (printmode == BINARY) {
write(1, val, cdb2_column_size(cdb2h, col));
exit(0);
} else {
fprintf(f, "x'");
hexdump(f, val, cdb2_column_size(cdb2h, col));
fprintf(f, "'");
}
}
break;
case CDB2_DATETIME: {
cdb2_client_datetime_t *cdt = (cdb2_client_datetime_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%4.4u-%2.2u-%2.2uT%2.2u%2.2u%2.2u.%3.3u %s\"",
cdt->tm.tm_year + 1900, cdt->tm.tm_mon + 1, cdt->tm.tm_mday,
cdt->tm.tm_hour, cdt->tm.tm_min, cdt->tm.tm_sec, cdt->msec,
cdt->tzname);
break;
}
case CDB2_DATETIMEUS: {
cdb2_client_datetimeus_t *cdt = (cdb2_client_datetimeus_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%4.4u-%2.2u-%2.2uT%2.2u%2.2u%2.2u.%6.6u %s\"",
cdt->tm.tm_year + 1900, cdt->tm.tm_mon + 1, cdt->tm.tm_mday,
cdt->tm.tm_hour, cdt->tm.tm_min, cdt->tm.tm_sec, cdt->usec,
cdt->tzname);
break;
}
case CDB2_INTERVALYM: {
cdb2_client_intv_ym_t *ym = (cdb2_client_intv_ym_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u-%u\"", (ym->sign < 0) ? "- " : "", ym->years,
ym->months);
break;
}
case CDB2_INTERVALDS: {
cdb2_client_intv_ds_t *ds = (cdb2_client_intv_ds_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u %2.2u:%2.2u:%2.2u.%3.3u\"",
(ds->sign < 0) ? "- " : "", ds->days, ds->hours, ds->mins,
ds->sec, ds->msec);
break;
}
case CDB2_INTERVALDSUS: {
cdb2_client_intv_dsus_t *ds = (cdb2_client_intv_dsus_t *)val;
if (printmode == DEFAULT)
fprintf(f, "%s=", cdb2_column_name(cdb2h, col));
fprintf(f, "\"%s%u %2.2u:%2.2u:%2.2u.%6.6u\"",
(ds->sign < 0) ? "- " : "", ds->days, ds->hours, ds->mins,
ds->sec, ds->usec);
break;
}
}
}
static int run_statement(const char *sql, int ntypes, int *VAR_2,
int *start_time, int *run_time)
{
int rc;
int ncols;
int col;
int cost;
FILE *out = stdout;
char cmd[60];
int startms, rowms, endms;
if (printmode & STDERR)
out = stderr;
startms = time_epochms();
*start_time = 0;
*run_time = 0;
if (cdb2h == NULL) {
if (dbhostname) {
rc = cdb2_open(&cdb2h, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h, dbname, dbtype, 0);
}
cdb2_push_context(cdb2h, "cdb2sql");
if (rc) {
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h);
cdb2h = NULL;
return 1;
}
if (VAR_0) {
cdb2_set_debug_trace(cdb2h);
}
if (show_ports) {
cdb2_dump_ports(cdb2h, stderr);
}
if (maxretries) {
cdb2_set_max_retries(maxretries);
}
if (docost) {
rc = cdb2_run_statement(cdb2h, "set getcost on");
if (rc) {
fprintf(stderr, "failed to run set getcost 1\n");
return 1;
}
}
/*
Check and set user and password if they have been specified using
the environment variables.
Note: It is good to report the user about the use of environment
variables to set user/password to avoid any surprises.
*/
int length;
if (getenv("COMDB2_USER")) {
length = snprintf(cmd, sizeof(cmd), "set user %s",
getenv("COMDB2_USER"));
if (length > sizeof(cmd)) {
fprintf(stderr, "COMDB2_USER too long, ignored\n");
} else {
if ((length < 0) || ((cdb2_run_statement(cdb2h, cmd)) != 0)) {
fprintf(stderr, "Failed to set user using COMDB2_USER, "
"exiting\n");
return 1;
} else {
printf("Set user using COMDB2_USER\n");
}
}
}
if (getenv("COMDB2_PASSWORD")) {
length = snprintf(cmd, sizeof(cmd), "set password %s",
getenv("COMDB2_PASSWORD"));
if (length > sizeof(cmd)) {
fprintf(stderr, "COMDB2_PASSWORD too long, ignored\n");
} else {
if ((length < 0) || ((cdb2_run_statement(cdb2h, cmd)) != 0)) {
fprintf(stderr, "Failed to set password using "
"COMDB2_PASSWORD, exiting\n");
return 1;
} else {
printf("Set password using COMDB2_PASSWORD\n");
}
}
}
}
/* Bind parameter ability -- useful for debugging */
if (sql[0] == '@') {
if (strncasecmp(sql, "@bind", 5) == 0) {
//@bind BINDTYPE parameter value
sql += 5;
int type = get_type(&sql);
if (type < 0)
return -1;
char *parameter = get_parameter(&sql);
if (parameter == NULL)
return -1;
int length;
void *value = get_val(&sql, type, &length);
rc = cdb2_bind_param(cdb2h, parameter, type, value, length);
/* we have to leak parameter here -- freeing breaks the bind */
} else
rc = process_escape(sql);
return rc;
}
{
int retries = 0;
while (retries < 10) {
rc = cdb2_run_statement_typed(cdb2h, sql, ntypes, VAR_2);
if (rc != CDB2ERR_IO_ERROR)
break;
retries++;
}
}
rowms = time_epochms();
*start_time = rowms - startms;
cdb2_clearbindings(cdb2h);
if (rc != CDB2_OK) {
const char *err = cdb2_errstr(cdb2h);
/* cdb2tcm mode needs to pass this info through stdout */
FILE *out = stderr;
fprintf(out, "[%s] failed with rc %d %s\n", sql, rc, err ? err : "");
return rc;
}
ncols = cdb2_numcolumns(cdb2h);
while ((rc = cdb2_next_record(cdb2h)) == CDB2_OK) {
if (printmode == DEFAULT)
fprintf(out, "(");
else if (printmode == GENSQL) {
printf("insert into %s (", gensql_tbl);
for (col = 0; col < ncols; col++) {
printf("%s", cdb2_column_name(cdb2h, col));
if (col != ncols - 1)
printf(", ");
}
printf(") values (");
}
for (col = 0; col < ncols; col++) {
void *val = cdb2_column_value(cdb2h, col);
if (val == NULL) {
if (printmode == DEFAULT)
fprintf(out, "%s=NULL", cdb2_column_name(cdb2h, col));
else
fprintf(out, "NULL");
} else {
FUNC_1(out, cdb2h, val, col, printmode);
}
if (col != ncols - 1) {
if (printmode == DEFAULT)
fprintf(out, ", ");
else if (printmode & TABS)
fprintf(out, "\t");
else
fprintf(out, ", ");
}
}
switch (printmode) {
case DEFAULT:
fprintf(out, ")\n");
break;
case TABS:
fprintf(out, "\n");
break;
case GENSQL:
fprintf(out, ");\n");
break;
}
fflush(out);
if (rowsleep)
sleep(rowsleep);
if (pausemode) {
char input[128];
int cmd;
printf(">");
fflush(stdout);
if (fgets(input, sizeof(input), stdin) == input) {
cmd = atoi(input);
if (cmd == -1)
pausemode = 0;
}
}
}
endms = time_epochms();
*run_time = endms - startms;
if (rc != CDB2_OK_DONE) {
const char *err = cdb2_errstr(cdb2h);
fprintf(stderr, "[%s] failed with rc %d %s\n", sql, rc, err ? err : "");
return rc;
}
if (show_effects) {
cdb2_effects_tp effects;
if (cdb2_get_effects(cdb2h, &effects) == 0) {
printf("Number of rows affected %d\n", effects.num_affected);
printf("Number of rows selected %d\n", effects.num_selected);
printf("Number of rows deleted %d\n", effects.num_deleted);
printf("Number of rows updated %d\n", effects.num_updated);
printf("Number of rows inserted %d\n", effects.num_inserted);
} else {
printf("Effects not sent by comdb2 server. \n");
}
}
return 0;
}
static void process_line(char *sql, int ntypes, int *VAR_2)
{
char *sqlstr = sql;
int rc;
int len;
/* Trim whitespace and then ignore comments */
while (isspace(*sqlstr))
sqlstr++;
if (sqlstr[0] == '#' || sqlstr[0] == '\0')
return;
/* Lame hack - strip trailing ; so that we can understand the
* sql generated by our own gensql mode. Note that the sql
* parser in comdb2 is ok with semicolons - it stops after the
* first one it encounters. */
len = strlen(sqlstr);
while (len > 0 && isspace(sqlstr[len - 1]))
len--;
while (len > 0 && sqlstr[len - 1] == ';')
len--;
sqlstr[len] = '\0';
int start_time_ms, run_time_ms;
gbl_in_stmt = 1;
rc = run_statement(sqlstr, ntypes, VAR_2, &start_time_ms, &run_time_ms);
gbl_in_stmt = 0;
gbl_sent_cancel_cnonce = 0;
if (rc != 0) {
error++;
} else if (!scriptmode) {
printf("[%s] rc %d\n", sqlstr, rc);
if (time_mode) {
printf(" prep time %d ms\n", start_time_ms);
printf(" run time %d ms\n", run_time_ms);
}
}
if (docost) {
int saved_printmode = printmode;
printmode = TABS | STDERR;
const char *costSql = "SELECT comdb2_prevquerycost() as Cost";
run_statement(costSql, ntypes, VAR_2, &start_time_ms, &run_time_ms);
printmode = saved_printmode;
}
}
void load_readline_history()
{
char *home;
if ((home = getenv("HOME")) == NULL)
return;
char histfile[] = "/.cdb2sql_history";
if ((history_file = malloc(strlen(home) + sizeof(histfile))) == NULL)
return;
sprintf(history_file, "%s%s", home, histfile);
read_history(history_file);
}
#define HISTFILE_COMMANDS 200
void save_readline_history()
{
stifle_history(HISTFILE_COMMANDS);
write_history(history_file);
free(history_file);
}
static int *process_typed_statement_args(int ntypes, char **args)
{
int *VAR_2 = NULL;
if (ntypes > 0)
VAR_2 = malloc(ntypes * sizeof(int));
for (int i = 0; i < ntypes; i++) {
if (strcmp(args[i], "integer") == 0)
VAR_2[i] = CDB2_INTEGER;
else if (strcmp(args[i], "real") == 0)
VAR_2[i] = CDB2_REAL;
else if (strcmp(args[i], "cstring") == 0)
VAR_2[i] = CDB2_CSTRING;
else if (strcmp(args[i], "blob") == 0)
VAR_2[i] = CDB2_BLOB;
else {
char *endp;
VAR_2[i] = strtol(args[i], &endp, 10);
if (*endp != 0) {
fprintf(stderr, "Unknown type %s\n", args[i]);
exit(EXIT_FAILURE);
}
}
}
return VAR_2;
}
static int is_multi_line(const char *sql)
{
if (sql == NULL)
return 0;
while (isspace(*sql))
++sql;
if (strncasecmp(sql, "create", 6) == 0) {
sql += 6;
while (isspace(*sql))
++sql;
if (*sql == '\0' || strncasecmp(sql, "table", 5) == 0 ||
strncasecmp(sql, "procedure", 9) == 0)
return 1;
} else if (strncasecmp(sql, "alter", 5) == 0) {
sql += 5;
while (isspace(*sql))
++sql;
if (*sql == '\0' || strncasecmp(sql, "table", 5) == 0) {
return 1;
}
}
return 0;
}
static char *get_multi_line_statement(char *line)
{
char *stmt = NULL;
int slen = 0;
char *nl = ""; // new-line
int n = 0; // len of nl
char tmp_prompt[sizeof(main_prompt)];
int spaces = strlen(dbname) - 3, dots = 3;
if (spaces < 0) {
dots += spaces;
spaces = 0;
}
sprintf(tmp_prompt, "%.*s%.*s> ", spaces,
" ",
dots, "...");
prompt = tmp_prompt;
do {
int len = strlen(line);
int newlen = slen + len + n;
stmt = realloc(stmt, newlen + 1);
sprintf(&stmt[slen], "%s%s", nl, line);
slen = newlen;
if (stmt[slen - 2] == '$' && stmt[slen - 1] == '$') {
stmt[slen - 2] = '\0';
break;
}
nl = "\n";
n = 1;
} while ((line = read_line()) != NULL);
prompt = main_prompt;
return stmt;
}
static int dbtype_valid(char *type)
{
if (type && (type[0] == '@' || strcasecmp(type, "dev") == 0 ||
strcasecmp(type, "uat") == 0 ||
strcasecmp(type, "default") == 0 ||
strcasecmp(type, "alpha") == 0 ||
strcasecmp(type, "beta") == 0 ||
strcasecmp(type, "local") == 0 ||
strcasecmp(type, "prod") == 0)) {
return 1;
}
return 0;
}
static void replace_args(int argc, char *argv[])
{
int ii;
for (ii = 1; ii < argc; ii++) {
if (argv[ii][0] != '-')
continue;
if (!strcmp(argv[ii], "-pause"))
argv[ii] = "--pause";
else if (!strcmp(argv[ii], "-binary"))
argv[ii] = "--binary";
else if (!strcmp(argv[ii], "-tabs"))
argv[ii] = "--tabs";
else if (!strcmp(argv[ii], "-strblobs"))
argv[ii] = "--strblobs";
else if (!strcmp(argv[ii], "-debug"))
argv[ii] = "--debug";
else if (!strcmp(argv[ii], "-debugtrace"))
argv[ii] = "--debugtrace";
else if (!strcmp(argv[ii], "-showports"))
argv[ii] = "--showports";
else if (!strcmp(argv[ii], "-showeffects"))
argv[ii] = "--showeffects";
else if (!strcmp(argv[ii], "-cost"))
argv[ii] = "--cost";
else if (!strcmp(argv[ii], "-exponent"))
argv[ii] = "--exponent";
else if (!strcmp(argv[ii], "-isatty"))
argv[ii] = "--isatty";
else if (!strcmp(argv[ii], "-isnotatty"))
argv[ii] = "--isnotatty";
else if (!strcmp(argv[ii], "-help"))
argv[ii] = "--help";
else if (!strcmp(argv[ii], "-script"))
argv[ii] = "--script";
else if (!strcmp(argv[ii], "-maxretries"))
argv[ii] = "--maxretries";
else if (!strcmp(argv[ii], "-precision"))
argv[ii] = "--precision";
else if (!strcmp(argv[ii], "-cdb2cfg"))
argv[ii] = "--cdb2cfg";
else if (!strcmp(argv[ii], "-file"))
argv[ii] = "--file";
else if (!strcmp(argv[ii], "-gensql"))
argv[ii] = "--gensql";
else if (!strcmp(argv[ii], "-type"))
argv[ii] = "--type";
else if (!strcmp(argv[ii], "-host"))
argv[ii] = "--host";
}
}
void send_cancel_cnonce(const char *cnonce)
{
if (!gbl_in_stmt) return;
cdb2_hndl_tp *cdb2h_2 = NULL; // use a new db handle
int rc;
if (dbhostname) {
rc = cdb2_open(&cdb2h_2, dbname, dbhostname, CDB2_DIRECT_CPU);
} else {
rc = cdb2_open(&cdb2h_2, dbname, dbtype, 0);
}
if (rc) {
if (VAR_0)
fprintf(stderr, "cdb2_open rc %d %s\n", rc, cdb2_errstr(cdb2h));
cdb2_close(cdb2h_2);
return;
}
char expanded[256];
for (int i = 0; i < 256 / 2 && cnonce[i] != '\0'; i++) {
sprintf(&expanded[i * 2], "%2x", cnonce[i]);
}
char sql[256];
snprintf(sql, 255, "exec procedure sys.cmd.send('sql cancelcnonce %s')",
expanded);
if (VAR_0) printf("Cancel sql string '%s'\n", sql);
rc = cdb2_run_statement(cdb2h_2, sql);
if (!rc)
gbl_sent_cancel_cnonce = 1;
else if (VAR_0)
fprintf(stderr, "failed to cancel rc %d with '%s'\n", rc, sql);
cdb2_close(cdb2h_2);
}
/* If ctrl_c was pressed to clear existing line and go to new line
* If we see two ctrl_c in a row we exit.
* However, after a ctrl_c if user typed something
* (rl_line_buffer is not empty) and then issue a ctrl_c then dont exit.
*/
static void FUNC_2(int signum)
{
if (gbl_in_stmt && !gbl_sent_cancel_cnonce)
printf("Requesting to cancel query (press Ctrl-C to exit program). "
"Please wait...\n");
if (gbl_sent_cancel_cnonce) exit(1); // pressed ctrl-c again
if (!gbl_in_stmt) {
rl_crlf();
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
send_cancel_cnonce(cdb2_cnonce(cdb2h));
}
int main(int argc, char *argv[])
{
static char *filename = NULL;
static int precision = 0;
static int exponent = 0;
static int isttyarg = 0;
static char *sql = NULL;
int ntypes = 0;
int *VAR_2 = NULL;
int opt_indx = 0;
int c;
comdb2ma_init(0, 0);
sigignore(SIGPIPE);
replace_args(argc, argv);
static struct option long_options[] = {
{"pause", no_argument, &pausemode, 1},
{"binary", no_argument, &printmode, BINARY},
{"tabs", no_argument, &printmode, TABS},
{"strblobs", no_argument, &string_blobs, 1},
{"debug", no_argument, &set_debug, 1},
{"debugtrace", no_argument, &VAR_0, 1},
{"showports", no_argument, &show_ports, 1},
{"showeffects",no_argument, &show_effects, 1},
{"cost", no_argument, &docost, 1},
{"exponent", no_argument, &exponent, 1},
{"isatty", no_argument, &isttyarg, 1},
{"isnotatty", no_argument, &isttyarg, 2},
{"help", no_argument, NULL, 'h'},
{"script", no_argument, NULL, 's'},
{"maxretries", required_argument, NULL, 'r'},
{"precision", required_argument, NULL, 'p'},
{"cdb2cfg", required_argument, NULL, 'c'},
{"file", required_argument, NULL, 'f'},
{"gensql", required_argument, NULL, 'g'},
{"type", required_argument, NULL, 't'},
{"host", required_argument, NULL, 'n'},
{0, 0, 0, 0}
};
while ((c = bb_getopt_long(argc, argv, "hsr:p:c:f:g:t:n:", long_options,
&opt_indx)) != -1) {
switch (c) {
case 0:
break;
case 'h':
FUNC_0(EXIT_SUCCESS);
break;
case 's':
scriptmode = 1;
break;
case 'r':
maxretries = atoi(optarg);
break;
case 'p':
precision = atoi(optarg);
break;
case 'c':
cdb2_set_comdb2db_config(optarg);
break;
case 'f':
filename = optarg;
break;
case 'g':
printmode = GENSQL;
gensql_tbl = optarg;
break;
case 't':
dbtype = optarg;
break;
case 'n':
dbhostname = optarg;
break;
case '?':
FUNC_0(EXIT_FAILURE);
break;
}
}
if (getenv("COMDB2_IOLBF")) {
setvbuf(stdout, 0, _IOLBF, 0);
setvbuf(stderr, 0, _IOLBF, 0);
}
if (getenv("COMDB2_SQL_COST"))
docost = 1;
if (exponent) {
if (precision > 0) {
snprintf(doublefmt, sizeof(doublefmt), "%%.%dg", precision);
} else {
snprintf(doublefmt, sizeof(doublefmt), "%%g");
}
} else if (precision > 0) {
snprintf(doublefmt, sizeof(doublefmt), "%%.%df", precision);
} else {
snprintf(doublefmt, sizeof(doublefmt), "%%f");
}
if (argc - optind < 1) {
FUNC_0(EXIT_FAILURE);
}
if (strlen(argv[optind]) >= MAX_DBNAME_LENGTH) {
fprintf(stderr, "DB name \"%s\" too long\n", dbname);
return 1;
}
dbname = argv[optind];
optind++;
if (dbtype == NULL && dbtype_valid(argv[optind])) {
dbtype = argv[optind];
optind++;
} else {
dbtype = "local"; /* might want "default" here */
}
sql = (optind < argc ? argv[optind] : "-");
sprintf(main_prompt, "%s> ", dbname);
optind++;
ntypes = argc - optind;
if (ntypes > 0)
VAR_2 = process_typed_statement_args(ntypes, &argv[optind]);
if (sql && *sql != '-') {
scriptmode = 1;
process_line(sql, ntypes, VAR_2);
if (cdb2h) {
cdb2_close(cdb2h);
}
return (error == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
if (filename) {
if (freopen(filename, "r", stdin) == NULL) {
fprintf(stderr, "Error opening %s: %s\n", filename,
strerror(errno));
return EXIT_FAILURE;
}
} else if (sql == NULL || *sql != '-') {
FUNC_0(EXIT_FAILURE);
}
istty = isatty(0);
if (isttyarg == 1)
istty = 1;
if (isttyarg == 2)
istty = 0;
if (istty) {
rl_attempted_completion_function = my_completion;
load_readline_history();
struct sigaction sact;
sact.sa_handler = VAR_3;
sigaction(SIGINT, &sact, NULL);
}
char *line;
int multi;
while ((line = read_line()) != NULL) {
if (strncmp(line, "quit", 4) == 0)
break;
if ((multi = is_multi_line(line)) != 0)
line = get_multi_line_statement(line);
process_line(line, 0, NULL);
if (multi)
free(line);
}
if (istty)
save_readline_history();
if (cdb2h) {
cdb2_close(cdb2h);
cdb2h = NULL;
}
return (error == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
| 0.026407 | {'IMPORT_0': 'sbuf2.h', 'VAR_0': 'debug_trace', 'FUNC_0': 'cdb2sql_usage', 'VAR_1': 'rl_attempted_completion_over', 'FUNC_1': 'printCol', 'VAR_2': 'types', 'FUNC_2': 'int_handler', 'VAR_3': 'int_handler'} | c | error | 0 |
/*
* Copyright (C) 2013-2021 Canonical, Ltd.
* Copyright (C) 2022-2023 Colin Ian King.
*
* 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.
*
*/
#include "stress-ng.h"
#include "core-builtin.h"
static const stress_help_t help[] = {
{ NULL, "madvise N", "start N workers exercising madvise on memory" },
{ NULL, "madvise-ops N", "stop after N bogo madvise operations" },
{ NULL, "madvise-hwpoison", "enable hardware page poisoning (disabled by default)" },
{ NULL, NULL, NULL }
};
static int stress_set_madvise_hwpoison(const char *opt)
{
return stress_set_setting_true("madvise-hwpoison", opt);
}
static const stress_opt_set_func_t opt_set_funcs[] = {
{ OPT_madvise_hwpoison, stress_set_madvise_hwpoison },
{ 0, NULL }
};
#if defined(HAVE_MADVISE)
#define NUM_MEM_RETRIES_MAX (256)
#define NUM_HWPOISON_MAX (2)
#define NUM_PTHREADS (8)
#if defined(MADV_SOFT_OFFLINE)
#define NUM_SOFT_OFFLINE_MAX (2)
#endif
typedef struct madvise_ctxt {
const stress_args_t *args;
void *buf;
char *smaps;
size_t sz;
bool is_thread;
bool hwpoison;
} madvise_ctxt_t;
static sigjmp_buf jmp_env;
static uint64_t sigbus_count;
static const int madvise_options[] = {
#if defined(MADV_NORMAL)
MADV_NORMAL,
#endif
#if defined(MADV_RANDOM)
MADV_RANDOM,
#endif
#if defined(MADV_SEQUENTIAL)
MADV_SEQUENTIAL,
#endif
#if defined(MADV_WILLNEED)
MADV_WILLNEED,
#endif
#if defined(MADV_DONTNEED)
MADV_DONTNEED,
#endif
#if defined(MADV_REMOVE)
MADV_REMOVE,
#endif
#if defined(MADV_DONTFORK)
MADV_DONTFORK,
#endif
#if defined(MADV_DOFORK)
MADV_DOFORK,
#endif
#if defined(MADV_MERGEABLE)
MADV_MERGEABLE,
#endif
#if defined(MADV_UNMERGEABLE)
MADV_UNMERGEABLE,
#endif
#if defined(MADV_SOFT_OFFLINE)
MADV_SOFT_OFFLINE,
#endif
#if defined(MADV_HUGEPAGE)
MADV_HUGEPAGE,
#endif
#if defined(MADV_NOHUGEPAGE)
MADV_NOHUGEPAGE,
#endif
#if defined(MADV_DONTDUMP)
MADV_DONTDUMP,
#endif
#if defined(MADV_DODUMP)
MADV_DODUMP,
#endif
#if defined(MADV_FREE)
MADV_FREE,
#endif
#if defined(MADV_HWPOISON)
MADV_HWPOISON,
#endif
#if defined(MADV_WIPEONFORK)
MADV_WIPEONFORK,
#endif
#if defined(MADV_KEEPONFORK)
MADV_KEEPONFORK,
#endif
#if defined(MADV_INHERIT_ZERO)
MADV_INHERIT_ZERO,
#endif
#if defined(MADV_COLD)
MADV_COLD,
#endif
#if defined(MADV_PAGEOUT)
MADV_PAGEOUT,
#endif
#if defined(MADV_POPULATE_READ)
MADV_POPULATE_READ,
#endif
#if defined(MADV_POPULATE_WRITE)
MADV_POPULATE_WRITE,
#endif
#if defined(MADV_DONTNEED_LOCKED)
MADV_DONTNEED_LOCKED,
#endif
/* Linux 6.0 */
#if defined(MADV_COLLAPSE)
MADV_COLLAPSE,
#endif
/* FreeBSD */
#if defined(MADV_AUTOSYNC)
MADV_AUTOSYNC,
#endif
/* FreeBSD and DragonFlyBSD */
#if defined(MADV_CORE)
MADV_CORE,
#endif
/* FreeBSD */
#if defined(MADV_PROTECT)
MADV_PROTECT,
#endif
/* Linux 5.14 */
#if defined(MADV_POPULATE_READ)
MADV_POPULATE_READ,
#endif
/* Linux 5.14 */
#if defined(MADV_POPULATE_WRITE)
MADV_POPULATE_WRITE,
#endif
/* OpenBSD */
#if defined(MADV_SPACEAVAIL)
MADV_SPACEAVAIL,
#endif
/* OS X */
#if defined(MADV_ZERO_WIRED_PAGES)
MADV_ZERO_WIRED_PAGES,
#endif
/* Solaris */
#if defined(MADV_ACCESS_DEFAULT)
MADV_ACCESS_DEFAULT,
#endif
/* Solaris */
#if defined(MADV_ACCESS_LWP)
MADV_ACCESS_LWP,
#endif
/* Solaris */
#if defined(MADV_ACCESS_MANY)
MADV_ACCESS_MANY,
#endif
/* DragonFlyBSD */
#if defined(MADV_INVAL)
MADV_INVAL,
#endif
/* DragonFlyBSD */
#if defined(MADV_NOCORE)
MADV_NOCORE,
#endif
};
/*
* stress_sigbus_handler()
* SIGBUS handler
*/
static void NORETURN MLOCKED_TEXT stress_sigbus_handler(int signum)
{
(void)signum;
sigbus_count++;
siglongjmp(jmp_env, 1);
}
#if defined(MADV_FREE)
/*
* stress_read_proc_smaps()
* read smaps file for extra kernel exercising
*/
static void stress_read_proc_smaps(const char *smaps)
{
static bool ignore = false;
ssize_t ret;
char buffer[4096];
int fd;
if (ignore)
return;
fd = open(smaps, O_RDONLY);
if (fd < 0) {
ignore = true;
return;
}
do {
ret = read(fd, buffer, sizeof(buffer));
} while (ret == (ssize_t)sizeof(buffer));
(void)close(fd);
}
#endif
/*
* stress_random_advise()
* get a random advise option
*/
static int stress_random_advise(
const stress_args_t *args,
void *addr,
const size_t size,
const bool hwpoison)
{
const int idx = stress_mwc32modn((size_t)SIZEOF_ARRAY(madvise_options));
const int advise = madvise_options[idx];
#if defined(MADV_HWPOISON) || defined(MADV_SOFT_OFFLINE)
static int hwpoison_count = 0;
#if defined(MADV_NORMAL)
const int madv_normal = MADV_NORMAL;
#else
const int madv_normal = 0;
#endif
#endif
#if defined(MADV_HWPOISON)
if (advise == MADV_HWPOISON) {
if (hwpoison) {
const size_t page_size = args->page_size;
const size_t vec_size = (size + page_size - 1) / page_size;
unsigned char *vec;
const uint8_t *ptr = (uint8_t *)addr;
/*
* Try for another madvise option if
* we've poisoned too many pages.
* We really need to use this sparingly
* else we run out of free memory
*/
if ((args->instance > 0) ||
(hwpoison_count >= NUM_HWPOISON_MAX)) {
return madv_normal;
}
vec = (unsigned char *)calloc(vec_size, sizeof(*vec));
if (vec) {
size_t i;
int ret;
/*
* Don't poison mapping if it's not physically backed
*/
ret = shim_mincore(addr, size, vec);
if (ret < 0) {
free(vec);
return madv_normal;
}
for (i = 0; i < vec_size; i++) {
if (vec[i] == 0) {
free(vec);
return madv_normal;
}
}
/*
* Don't poison page if it's all zero as it may
* be mapped to the common zero page and poisoning
* this shared page can cause issues.
*/
for (i = 0; i < size; i++) {
if (ptr[i])
break;
}
/* ..all zero? then don't madvise it */
if (i == size) {
free(vec);
return madv_normal;
}
hwpoison_count++;
free(vec);
}
} else {
/* hwpoison disabled */
return madv_normal;
}
}
#else
UNEXPECTED
(void)hwpoison;
(void)args;
(void)addr;
(void)size;
#endif
#if defined(MADV_SOFT_OFFLINE)
if (advise == MADV_SOFT_OFFLINE) {
static int soft_offline_count;
/* ..and minimize number of soft offline pages */
if ((soft_offline_count >= NUM_SOFT_OFFLINE_MAX) ||
(hwpoison_count >= NUM_HWPOISON_MAX))
return madv_normal;
soft_offline_count++;
}
#endif
return advise;
}
/*
* stress_madvise_pages()
* exercise madvise settings
*/
static void *stress_madvise_pages(void *arg)
{
size_t n;
const madvise_ctxt_t *ctxt = (const madvise_ctxt_t *)arg;
const stress_args_t *args = ctxt->args;
void *buf = ctxt->buf;
const size_t sz = ctxt->sz;
const size_t page_size = args->page_size;
static void *nowt = NULL;
if (ctxt->is_thread) {
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGBUS);
(void)pthread_sigmask(SIG_SETMASK, &set, NULL);
}
for (n = 0; n < sz; n += page_size) {
void *ptr = (void *)(((uint8_t *)buf) + n);
const int advise = stress_random_advise(args, ptr, page_size, ctxt->hwpoison);
(void)shim_madvise(ptr, page_size, advise);
#if defined(MADV_FREE)
if (advise == MADV_FREE)
stress_read_proc_smaps(ctxt->smaps);
#endif
(void)shim_msync(ptr, page_size, MS_ASYNC);
}
for (n = 0; n < sz; n += page_size) {
size_t m = (size_t)(stress_mwc64modn_maybe_pwr2((uint64_t)sz) & ~(page_size - 1));
void *ptr = (void *)(((uint8_t *)buf) + m);
const int advise = stress_random_advise(args, ptr, page_size, ctxt->hwpoison);
(void)shim_madvise(ptr, page_size, advise);
(void)shim_msync(ptr, page_size, MS_ASYNC);
}
/*
* Exercise a highly likely bad advice option
*/
(void)shim_madvise(buf, page_size, ~0);
#if defined(MADV_NORMAL)
/*
* Exercise with non-page aligned address
*/
(void)shim_madvise(((uint8_t *)buf) + 1, page_size, MADV_NORMAL);
#endif
#if defined(_POSIX_MEMLOCK_RANGE) && \
defined(HAVE_MLOCK) && \
(defined(MADV_REMOVE) || defined(MADV_DONTNEED))
{
int ret;
/*
* Exercise MADV_REMOVE on locked page, should
* generate EINVAL
*/
ret = shim_mlock(buf, page_size);
if (ret == 0) {
#if defined(MADV_REMOVE)
(void)shim_madvise(buf, page_size, MADV_REMOVE);
#endif
#if defined(MADV_DONTNEED)
(void)shim_madvise(buf, page_size, MADV_DONTNEED);
#endif
shim_munlock(buf, page_size);
}
}
#endif
#if defined(MADV_NORMAL)
{
void *unmapped;
/*
* Exercise an unmapped page
*/
unmapped = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (unmapped != MAP_FAILED) {
(void)stress_munmap_retry_enomem(unmapped, page_size);
(void)shim_madvise(unmapped, page_size, MADV_NORMAL);
}
}
#endif
return &nowt;
}
static void stress_process_madvise(const pid_t pid, void *buf, const size_t sz)
{
int pidfd;
struct iovec vec;
(void)pid;
vec.iov_base = buf;
vec.iov_len = sz;
pidfd = shim_pidfd_open(pid, 0);
if (pidfd >= 0) {
#if defined(MADV_PAGEOUT)
VOID_RET(ssize_t, shim_process_madvise(pidfd, &vec, 1, MADV_PAGEOUT, 0));
#endif
#if defined(MADV_COLD)
VOID_RET(ssize_t, shim_process_madvise(pidfd, &vec, 1, MADV_COLD, 0));
#endif
/* exercise invalid behaviour */
VOID_RET(ssize_t, shim_process_madvise(pidfd, &vec, 1, ~0, 0));
#if defined(MADV_PAGEOUT)
/* exercise invalid flags */
VOID_RET(ssize_t, shim_process_madvise(pidfd, &vec, 1, MADV_PAGEOUT, ~0U));
#endif
(void)close(pidfd);
}
#if defined(MADV_PAGEOUT)
/* exercise invalid pidfd */
VOID_RET(ssize_t, shim_process_madvise(-1, &vec, 1, MADV_PAGEOUT, 0));
#endif
}
/*
* stress_madvise()
* stress madvise
*/
static int stress_madvise(const stress_args_t *args)
{
const size_t page_size = args->page_size;
const size_t sz = (4 * MB) & ~(page_size - 1);
const pid_t pid = getpid();
int fd = -1;
NOCLOBBER int ret;
NOCLOBBER int flags;
NOCLOBBER int num_mem_retries;
char filename[PATH_MAX];
char smaps[PATH_MAX];
char *page;
size_t n;
madvise_ctxt_t ctxt;
#if defined(MADV_FREE)
NOCLOBBER uint64_t madv_frees_raced;
NOCLOBBER uint64_t madv_frees;
NOCLOBBER uint8_t madv_tries;
#endif
(void)memset(&ctxt, 0, sizeof(ctxt));
(void)stress_get_setting("madvise-hwpoison", &ctxt.hwpoison);
flags = MAP_PRIVATE;
num_mem_retries = 0;
#if defined(MADV_FREE)
madv_frees_raced = 0;
madv_frees = 0;
madv_tries = 0;
#endif
page = (char *)mmap(NULL, page_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (page == MAP_FAILED) {
pr_inf_skip("%s: cannot allocate %zd byte page, skipping stressor\n",
args->name, page_size);
return EXIT_NO_RESOURCE;
}
(void)snprintf(smaps, sizeof(smaps), "/proc/%" PRIdMAX "/smaps", (intmax_t)pid);
ret = sigsetjmp(jmp_env, 1);
if (ret) {
pr_fail("%s: sigsetjmp failed\n", args->name);
(void)munmap((void *)page, page_size);
return EXIT_NO_RESOURCE;
}
if (stress_sighandler(args->name, SIGBUS, stress_sigbus_handler, NULL) < 0) {
(void)munmap((void *)page, page_size);
return EXIT_FAILURE;
}
#if defined(MAP_POPULATE)
flags |= MAP_POPULATE;
#endif
/* Make sure this is killable by OOM killer */
stress_set_oom_adjustment(args, true);
(void)shim_memset(page, 0xa5, page_size);
ret = stress_temp_dir_mk_args(args);
if (ret < 0) {
(void)munmap((void *)page, page_size);
return stress_exit_status(-ret);
}
(void)stress_temp_filename_args(args,
filename, sizeof(filename), stress_mwc32());
if ((fd = open(filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
ret = stress_exit_status(errno);
pr_fail("%s: open %s failed, errno=%d (%s)\n",
args->name, filename, errno, strerror(errno));
(void)shim_unlink(filename);
(void)stress_temp_dir_rm_args(args);
(void)munmap((void *)page, page_size);
return ret;
}
(void)shim_unlink(filename);
stress_file_rw_hint_short(fd);
for (n = 0; n < sz; n += page_size) {
VOID_RET(ssize_t, write(fd, page, page_size));
}
stress_set_proc_state(args->name, STRESS_STATE_RUN);
do {
NOCLOBBER uint8_t *buf;
NOCLOBBER bool file_mapped;
if (num_mem_retries >= NUM_MEM_RETRIES_MAX) {
pr_err("%s: gave up trying to mmap, no available memory\n",
args->name);
break;
}
if (!stress_continue_flag())
break;
file_mapped = stress_mwc1();
if (file_mapped) {
buf = (uint8_t *)mmap(NULL, sz, PROT_READ | PROT_WRITE, flags, fd, 0);
} else {
buf = (uint8_t *)mmap(NULL, sz, PROT_READ | PROT_WRITE,
flags | MAP_ANONYMOUS, 0, 0);
}
if (buf == MAP_FAILED) {
/* Force MAP_POPULATE off, just in case */
#if defined(MAP_POPULATE)
flags &= ~MAP_POPULATE;
#endif
num_mem_retries++;
if (num_mem_retries > 1)
(void)shim_usleep(100000);
continue; /* Try again */
}
ret = sigsetjmp(jmp_env, 1);
if (ret) {
(void)munmap((void *)buf, sz);
/* Try again */
continue;
}
(void)shim_memset(buf, 0xff, sz);
(void)stress_madvise_random(buf, sz);
(void)stress_mincore_touch_pages(buf, sz);
stress_process_madvise(pid, buf, sz);
ctxt.args = args;
ctxt.buf = buf;
ctxt.sz = sz;
ctxt.smaps = smaps;
#if defined(HAVE_LIB_PTHREAD)
{
pthread_t pthreads[NUM_PTHREADS];
int rets[NUM_PTHREADS];
size_t i;
ctxt.is_thread = true;
for (i = 0; i < NUM_PTHREADS; i++) {
rets[i] = pthread_create(&pthreads[i], NULL,
stress_madvise_pages, (void *)&ctxt);
}
for (i = 0; i < NUM_PTHREADS; i++) {
if (rets[i] == 0)
(void)pthread_join(pthreads[i], NULL);
}
}
#else
{
ctxt.is_thread = false;
stress_madvise_pages(&ctxt);
}
#endif
#if defined(MADV_NORMAL)
/* Exercise no-op madvise on 0 size */
(void)madvise((void *)buf, 0, MADV_NORMAL);
/* Invalid size, ENOMEM */
(void)madvise((void *)buf, 0xffff0000, MADV_NORMAL);
/* Invalid advice option, EINVAL */
(void)madvise((void *)buf, sz, ~0);
#endif
#if defined(MADV_FREE)
if (file_mapped) {
register uint8_t val;
madv_tries++;
if (madv_tries < 16)
goto madv_free_out;
madv_tries = 0;
val = stress_mwc8();
for (n = 0; n < sz; n += page_size) {
register uint8_t v = (uint8_t)(val + n);
buf[n] = v;
}
if (madvise((void *)buf, sz, MADV_FREE) != 0)
goto madv_free_out;
if (lseek(fd, 0, SEEK_SET) != 0)
goto madv_free_out;
if (read(fd, buf, sz) != (ssize_t)sz)
goto madv_free_out;
for (n = 0; n < sz; n += page_size) {
register uint8_t v = (uint8_t)(val + n);
if (buf[n] != v)
madv_frees_raced++;
}
madv_frees += sz / page_size;
}
madv_free_out:
#endif
(void)munmap((void *)buf, sz);
#if defined(MADV_NORMAL)
{
void *bad_addr = (void *)(~(uintptr_t)0 & ~(page_size -1));
/* Invalid madvise on unmapped pages */
(void)madvise((void *)buf, sz, MADV_NORMAL);
/* Invalid madvise on wrapped address */
(void)madvise(bad_addr, page_size * 2, MADV_NORMAL);
}
#endif
stress_bogo_inc(args);
} while (stress_continue(args));
stress_set_proc_state(args->name, STRESS_STATE_DEINIT);
(void)close(fd);
(void)stress_temp_dir_rm_args(args);
(void)munmap((void *)page, page_size);
#if defined(MADV_FREE)
if (madv_frees_raced)
pr_inf("%s: MADV_FREE: %" PRIu64" of %" PRIu64 " were racy\n",
args->name, madv_frees_raced, madv_frees);
#endif
if (sigbus_count)
pr_inf("%s: caught %" PRIu64 " SIGBUS signal%s\n",
args->name, sigbus_count, sigbus_count == 1 ? "" : "s");
return EXIT_SUCCESS;
}
stressor_info_t stress_madvise_info = {
.stressor = stress_madvise,
.class = CLASS_VM | CLASS_OS,
.opt_set_funcs = opt_set_funcs,
.help = help
};
#else
stressor_info_t stress_madvise_info = {
.stressor = stress_unimplemented,
.class = CLASS_VM | CLASS_OS,
.opt_set_funcs = opt_set_funcs,
.help = help,
.unimplemented_reason = "built without madvise() system call"
};
#endif
| /*
* Copyright (C) 2013-2021 Canonical, Ltd.
* Copyright (C) 2022-2023 Colin Ian King.
*
* 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.
*
*/
#include "IMPORT_0"
#include "IMPORT_1"
static const CLASS_0 VAR_0[] = {
{ NULL, "madvise N", "start N workers exercising madvise on memory" },
{ NULL, "madvise-ops N", "stop after N bogo madvise operations" },
{ NULL, "madvise-hwpoison", "enable hardware page poisoning (disabled by default)" },
{ NULL, NULL, NULL }
};
static int FUNC_0(const char *VAR_2)
{
return FUNC_1("madvise-hwpoison", VAR_2);
}
static const CLASS_1 VAR_3[] = {
{ VAR_4, VAR_1 },
{ 0, NULL }
};
#if defined(VAR_5)
#define VAR_6 (256)
#define VAR_7 (2)
#define VAR_8 (8)
#if defined(MADV_SOFT_OFFLINE)
#define VAR_9 (2)
#endif
typedef struct CLASS_2 {
const CLASS_3 *VAR_10;
void *VAR_11;
char *VAR_12;
size_t sz;
bool VAR_13;
bool VAR_14;
} ID_0;
static sigjmp_buf VAR_15;
static uint64_t sigbus_count;
static const int VAR_16[] = {
#if defined(VAR_17)
VAR_17,
#endif
#if defined(VAR_18)
VAR_18,
#endif
#if defined(VAR_19)
VAR_19,
#endif
#if defined(VAR_20)
VAR_20,
#endif
#if defined(MADV_DONTNEED)
MADV_DONTNEED,
#endif
#if defined(VAR_21)
VAR_21,
#endif
#if defined(MADV_DONTFORK)
MADV_DONTFORK,
#endif
#if defined(MADV_DOFORK)
MADV_DOFORK,
#endif
#if defined(MADV_MERGEABLE)
MADV_MERGEABLE,
#endif
#if defined(MADV_UNMERGEABLE)
MADV_UNMERGEABLE,
#endif
#if defined(MADV_SOFT_OFFLINE)
MADV_SOFT_OFFLINE,
#endif
#if defined(VAR_22)
VAR_22,
#endif
#if defined(VAR_23)
VAR_23,
#endif
#if defined(VAR_24)
VAR_24,
#endif
#if defined(VAR_25)
VAR_25,
#endif
#if defined(VAR_26)
VAR_26,
#endif
#if defined(VAR_27)
VAR_27,
#endif
#if defined(VAR_28)
VAR_28,
#endif
#if defined(VAR_29)
VAR_29,
#endif
#if defined(VAR_30)
VAR_30,
#endif
#if defined(VAR_31)
VAR_31,
#endif
#if defined(MADV_PAGEOUT)
MADV_PAGEOUT,
#endif
#if defined(VAR_32)
VAR_32,
#endif
#if defined(VAR_33)
VAR_33,
#endif
#if defined(VAR_34)
VAR_34,
#endif
/* Linux 6.0 */
#if defined(MADV_COLLAPSE)
MADV_COLLAPSE,
#endif
/* FreeBSD */
#if defined(MADV_AUTOSYNC)
MADV_AUTOSYNC,
#endif
/* FreeBSD and DragonFlyBSD */
#if defined(MADV_CORE)
MADV_CORE,
#endif
/* FreeBSD */
#if defined(VAR_35)
VAR_35,
#endif
/* Linux 5.14 */
#if defined(VAR_32)
VAR_32,
#endif
/* Linux 5.14 */
#if defined(VAR_33)
VAR_33,
#endif
/* OpenBSD */
#if defined(VAR_36)
VAR_36,
#endif
/* OS X */
#if defined(VAR_37)
VAR_37,
#endif
/* Solaris */
#if defined(VAR_38)
VAR_38,
#endif
/* Solaris */
#if defined(MADV_ACCESS_LWP)
MADV_ACCESS_LWP,
#endif
/* Solaris */
#if defined(VAR_39)
VAR_39,
#endif
/* DragonFlyBSD */
#if defined(VAR_40)
VAR_40,
#endif
/* DragonFlyBSD */
#if defined(VAR_41)
VAR_41,
#endif
};
/*
* stress_sigbus_handler()
* SIGBUS handler
*/
static void VAR_42 CLASS_5 FUNC_2(int VAR_44)
{
(void)VAR_44;
sigbus_count++;
siglongjmp(VAR_15, 1);
}
#if defined(VAR_26)
/*
* stress_read_proc_smaps()
* read smaps file for extra kernel exercising
*/
static void FUNC_3(const char *VAR_12)
{
static bool VAR_45 = false;
ssize_t VAR_46;
char VAR_47[4096];
int fd;
if (VAR_45)
return;
fd = FUNC_4(VAR_12, VAR_48);
if (fd < 0) {
VAR_45 = true;
return;
}
do {
VAR_46 = read(fd, VAR_47, sizeof(VAR_47));
} while (VAR_46 == (ssize_t)sizeof(VAR_47));
(void)close(fd);
}
#endif
/*
* stress_random_advise()
* get a random advise option
*/
static int stress_random_advise(
const CLASS_3 *VAR_10,
void *VAR_49,
const size_t VAR_50,
const bool VAR_14)
{
const int VAR_51 = stress_mwc32modn((size_t)FUNC_5(VAR_16));
const int advise = VAR_16[VAR_51];
#if defined(VAR_27) || defined(MADV_SOFT_OFFLINE)
static int VAR_52 = 0;
#if defined(VAR_17)
const int madv_normal = VAR_17;
#else
const int madv_normal = 0;
#endif
#endif
#if defined(VAR_27)
if (advise == VAR_27) {
if (VAR_14) {
const size_t VAR_53 = VAR_10->VAR_53;
const size_t vec_size = (VAR_50 + VAR_53 - 1) / VAR_53;
unsigned char *VAR_54;
const uint8_t *VAR_55 = (uint8_t *)VAR_49;
/*
* Try for another madvise option if
* we've poisoned too many pages.
* We really need to use this sparingly
* else we run out of free memory
*/
if ((VAR_10->VAR_56 > 0) ||
(VAR_52 >= VAR_7)) {
return madv_normal;
}
VAR_54 = (unsigned char *)FUNC_6(vec_size, sizeof(*VAR_54));
if (VAR_54) {
size_t i;
int VAR_46;
/*
* Don't poison mapping if it's not physically backed
*/
VAR_46 = FUNC_7(VAR_49, VAR_50, VAR_54);
if (VAR_46 < 0) {
FUNC_8(VAR_54);
return madv_normal;
}
for (i = 0; i < vec_size; i++) {
if (VAR_54[i] == 0) {
FUNC_8(VAR_54);
return madv_normal;
}
}
/*
* Don't poison page if it's all zero as it may
* be mapped to the common zero page and poisoning
* this shared page can cause issues.
*/
for (i = 0; i < VAR_50; i++) {
if (VAR_55[i])
break;
}
/* ..all zero? then don't madvise it */
if (i == VAR_50) {
FUNC_8(VAR_54);
return madv_normal;
}
VAR_52++;
FUNC_8(VAR_54);
}
} else {
/* hwpoison disabled */
return madv_normal;
}
}
#else
VAR_57
(void)VAR_14;
(void)VAR_10;
(void)VAR_49;
(void)VAR_50;
#endif
#if defined(MADV_SOFT_OFFLINE)
if (advise == MADV_SOFT_OFFLINE) {
static int VAR_58;
/* ..and minimize number of soft offline pages */
if ((VAR_58 >= VAR_9) ||
(VAR_52 >= VAR_7))
return madv_normal;
VAR_58++;
}
#endif
return advise;
}
/*
* stress_madvise_pages()
* exercise madvise settings
*/
static void *FUNC_9(void *VAR_60)
{
size_t VAR_61;
const CLASS_4 *VAR_62 = (const CLASS_4 *)VAR_60;
const CLASS_3 *VAR_10 = VAR_62->VAR_10;
void *VAR_11 = VAR_62->VAR_11;
const size_t sz = VAR_62->sz;
const size_t VAR_53 = VAR_10->VAR_53;
static void *VAR_63 = NULL;
if (VAR_62->VAR_13) {
sigset_t VAR_64;
FUNC_10(&VAR_64);
FUNC_11(&VAR_64, VAR_65);
(void)FUNC_12(VAR_66, &VAR_64, NULL);
}
for (VAR_61 = 0; VAR_61 < sz; VAR_61 += VAR_53) {
void *VAR_55 = (void *)(((uint8_t *)VAR_11) + VAR_61);
const int advise = stress_random_advise(VAR_10, VAR_55, VAR_53, VAR_62->VAR_14);
(void)FUNC_13(VAR_55, VAR_53, advise);
#if defined(VAR_26)
if (advise == VAR_26)
FUNC_3(VAR_62->VAR_12);
#endif
(void)FUNC_14(VAR_55, VAR_53, MS_ASYNC);
}
for (VAR_61 = 0; VAR_61 < sz; VAR_61 += VAR_53) {
size_t VAR_67 = (size_t)(FUNC_15((uint64_t)sz) & ~(VAR_53 - 1));
void *VAR_55 = (void *)(((uint8_t *)VAR_11) + VAR_67);
const int advise = stress_random_advise(VAR_10, VAR_55, VAR_53, VAR_62->VAR_14);
(void)FUNC_13(VAR_55, VAR_53, advise);
(void)FUNC_14(VAR_55, VAR_53, MS_ASYNC);
}
/*
* Exercise a highly likely bad advice option
*/
(void)FUNC_13(VAR_11, VAR_53, ~0);
#if defined(VAR_17)
/*
* Exercise with non-page aligned address
*/
(void)FUNC_13(((uint8_t *)VAR_11) + 1, VAR_53, VAR_17);
#endif
#if defined(VAR_68) && \
defined(VAR_69) && \
(defined(VAR_21) || defined(MADV_DONTNEED))
{
int VAR_46;
/*
* Exercise MADV_REMOVE on locked page, should
* generate EINVAL
*/
VAR_46 = FUNC_16(VAR_11, VAR_53);
if (VAR_46 == 0) {
#if defined(VAR_21)
(void)FUNC_13(VAR_11, VAR_53, VAR_21);
#endif
#if defined(MADV_DONTNEED)
(void)FUNC_13(VAR_11, VAR_53, MADV_DONTNEED);
#endif
FUNC_17(VAR_11, VAR_53);
}
}
#endif
#if defined(VAR_17)
{
void *VAR_70;
/*
* Exercise an unmapped page
*/
VAR_70 = FUNC_18(NULL, VAR_53, PROT_READ | VAR_71,
MAP_ANONYMOUS | VAR_72, -1, 0);
if (VAR_70 != VAR_73) {
(void)FUNC_19(VAR_70, VAR_53);
(void)FUNC_13(VAR_70, VAR_53, VAR_17);
}
}
#endif
return &VAR_63;
}
static void FUNC_20(const pid_t VAR_74, void *VAR_11, const size_t sz)
{
int pidfd;
struct CLASS_6 VAR_54;
(void)VAR_74;
VAR_54.VAR_75 = VAR_11;
VAR_54.VAR_76 = sz;
pidfd = FUNC_21(VAR_74, 0);
if (pidfd >= 0) {
#if defined(MADV_PAGEOUT)
FUNC_22(VAR_77, FUNC_23(pidfd, &VAR_54, 1, MADV_PAGEOUT, 0));
#endif
#if defined(VAR_31)
FUNC_22(VAR_77, FUNC_23(pidfd, &VAR_54, 1, VAR_31, 0));
#endif
/* exercise invalid behaviour */
FUNC_22(VAR_77, FUNC_23(pidfd, &VAR_54, 1, ~0, 0));
#if defined(MADV_PAGEOUT)
/* exercise invalid flags */
FUNC_22(VAR_77, FUNC_23(pidfd, &VAR_54, 1, MADV_PAGEOUT, ~0U));
#endif
(void)close(pidfd);
}
#if defined(MADV_PAGEOUT)
/* exercise invalid pidfd */
FUNC_22(VAR_77, FUNC_23(-1, &VAR_54, 1, MADV_PAGEOUT, 0));
#endif
}
/*
* stress_madvise()
* stress madvise
*/
static int stress_madvise(const CLASS_3 *VAR_10)
{
const size_t VAR_53 = VAR_10->VAR_53;
const size_t sz = (4 * VAR_78) & ~(VAR_53 - 1);
const pid_t VAR_74 = FUNC_24();
int fd = -1;
NOCLOBBER int VAR_46;
NOCLOBBER int flags;
NOCLOBBER int VAR_79;
char filename[VAR_80];
char VAR_12[VAR_80];
char *page;
size_t VAR_61;
CLASS_4 VAR_62;
#if defined(VAR_26)
NOCLOBBER VAR_81 madv_frees_raced;
NOCLOBBER VAR_81 VAR_82;
NOCLOBBER VAR_83 VAR_84;
#endif
(void)memset(&VAR_62, 0, sizeof(VAR_62));
(void)FUNC_25("madvise-hwpoison", &VAR_62.VAR_14);
flags = VAR_72;
VAR_79 = 0;
#if defined(VAR_26)
madv_frees_raced = 0;
VAR_82 = 0;
VAR_84 = 0;
#endif
page = (char *)FUNC_18(NULL, VAR_53, PROT_READ | VAR_71,
MAP_ANONYMOUS | VAR_72, -1, 0);
if (page == VAR_73) {
FUNC_26("%s: cannot allocate %zd byte page, skipping stressor\n",
VAR_10->VAR_85, VAR_53);
return VAR_86;
}
(void)FUNC_27(VAR_12, sizeof(VAR_12), "/proc/%" VAR_87 "/smaps", (ID_1)VAR_74);
VAR_46 = FUNC_28(VAR_15, 1);
if (VAR_46) {
FUNC_29("%s: sigsetjmp failed\n", VAR_10->VAR_85);
(void)FUNC_30((void *)page, VAR_53);
return VAR_86;
}
if (FUNC_31(VAR_10->VAR_85, VAR_65, VAR_43, NULL) < 0) {
(void)FUNC_30((void *)page, VAR_53);
return EXIT_FAILURE;
}
#if defined(MAP_POPULATE)
flags |= MAP_POPULATE;
#endif
/* Make sure this is killable by OOM killer */
FUNC_32(VAR_10, true);
(void)shim_memset(page, 0xa5, VAR_53);
VAR_46 = stress_temp_dir_mk_args(VAR_10);
if (VAR_46 < 0) {
(void)FUNC_30((void *)page, VAR_53);
return FUNC_33(-VAR_46);
}
(void)stress_temp_filename_args(VAR_10,
filename, sizeof(filename), stress_mwc32());
if ((fd = FUNC_4(filename, VAR_88 | VAR_89, VAR_90 | VAR_91)) < 0) {
VAR_46 = FUNC_33(VAR_92);
FUNC_29("%s: open %s failed, errno=%d (%s)\n",
VAR_10->VAR_85, filename, VAR_92, FUNC_34(VAR_92));
(void)FUNC_35(filename);
(void)stress_temp_dir_rm_args(VAR_10);
(void)FUNC_30((void *)page, VAR_53);
return VAR_46;
}
(void)FUNC_35(filename);
FUNC_36(fd);
for (VAR_61 = 0; VAR_61 < sz; VAR_61 += VAR_53) {
FUNC_22(VAR_77, write(fd, page, VAR_53));
}
stress_set_proc_state(VAR_10->VAR_85, VAR_93);
do {
NOCLOBBER VAR_83 *VAR_11;
NOCLOBBER bool VAR_94;
if (VAR_79 >= VAR_6) {
pr_err("%s: gave up trying to mmap, no available memory\n",
VAR_10->VAR_85);
break;
}
if (!FUNC_37())
break;
VAR_94 = FUNC_38();
if (VAR_94) {
VAR_11 = (uint8_t *)FUNC_18(NULL, sz, PROT_READ | VAR_71, flags, fd, 0);
} else {
VAR_11 = (uint8_t *)FUNC_18(NULL, sz, PROT_READ | VAR_71,
flags | MAP_ANONYMOUS, 0, 0);
}
if (VAR_11 == VAR_73) {
/* Force MAP_POPULATE off, just in case */
#if defined(MAP_POPULATE)
flags &= ~MAP_POPULATE;
#endif
VAR_79++;
if (VAR_79 > 1)
(void)FUNC_39(100000);
continue; /* Try again */
}
VAR_46 = FUNC_28(VAR_15, 1);
if (VAR_46) {
(void)FUNC_30((void *)VAR_11, sz);
/* Try again */
continue;
}
(void)shim_memset(VAR_11, 0xff, sz);
(void)FUNC_40(VAR_11, sz);
(void)FUNC_41(VAR_11, sz);
FUNC_20(VAR_74, VAR_11, sz);
VAR_62.VAR_10 = VAR_10;
VAR_62.VAR_11 = VAR_11;
VAR_62.sz = sz;
VAR_62.VAR_12 = VAR_12;
#if defined(VAR_95)
{
CLASS_7 VAR_96[VAR_8];
int VAR_97[VAR_8];
size_t i;
VAR_62.VAR_13 = true;
for (i = 0; i < VAR_8; i++) {
VAR_97[i] = pthread_create(&VAR_96[i], NULL,
VAR_59, (void *)&VAR_62);
}
for (i = 0; i < VAR_8; i++) {
if (VAR_97[i] == 0)
(void)FUNC_42(VAR_96[i], NULL);
}
}
#else
{
VAR_62.VAR_13 = false;
FUNC_9(&VAR_62);
}
#endif
#if defined(VAR_17)
/* Exercise no-op madvise on 0 size */
(void)FUNC_43((void *)VAR_11, 0, VAR_17);
/* Invalid size, ENOMEM */
(void)FUNC_43((void *)VAR_11, 0xffff0000, VAR_17);
/* Invalid advice option, EINVAL */
(void)FUNC_43((void *)VAR_11, sz, ~0);
#endif
#if defined(VAR_26)
if (VAR_94) {
register uint8_t VAR_98;
VAR_84++;
if (VAR_84 < 16)
goto madv_free_out;
VAR_84 = 0;
VAR_98 = FUNC_44();
for (VAR_61 = 0; VAR_61 < sz; VAR_61 += VAR_53) {
register uint8_t v = (uint8_t)(VAR_98 + VAR_61);
VAR_11[VAR_61] = v;
}
if (FUNC_43((void *)VAR_11, sz, VAR_26) != 0)
goto madv_free_out;
if (FUNC_45(fd, 0, SEEK_SET) != 0)
goto madv_free_out;
if (read(fd, VAR_11, sz) != (ssize_t)sz)
goto madv_free_out;
for (VAR_61 = 0; VAR_61 < sz; VAR_61 += VAR_53) {
register uint8_t v = (uint8_t)(VAR_98 + VAR_61);
if (VAR_11[VAR_61] != v)
madv_frees_raced++;
}
VAR_82 += sz / VAR_53;
}
madv_free_out:
#endif
(void)FUNC_30((void *)VAR_11, sz);
#if defined(VAR_17)
{
void *VAR_99 = (void *)(~(uintptr_t)0 & ~(VAR_53 -1));
/* Invalid madvise on unmapped pages */
(void)FUNC_43((void *)VAR_11, sz, VAR_17);
/* Invalid madvise on wrapped address */
(void)FUNC_43(VAR_99, VAR_53 * 2, VAR_17);
}
#endif
FUNC_46(VAR_10);
} while (FUNC_47(VAR_10));
stress_set_proc_state(VAR_10->VAR_85, STRESS_STATE_DEINIT);
(void)close(fd);
(void)stress_temp_dir_rm_args(VAR_10);
(void)FUNC_30((void *)page, VAR_53);
#if defined(VAR_26)
if (madv_frees_raced)
FUNC_48("%s: MADV_FREE: %" VAR_100" of %" VAR_100 " were racy\n",
VAR_10->VAR_85, madv_frees_raced, VAR_82);
#endif
if (sigbus_count)
FUNC_48("%s: caught %" VAR_100 " SIGBUS signal%s\n",
VAR_10->VAR_85, sigbus_count, sigbus_count == 1 ? "" : "s");
return VAR_101;
}
CLASS_8 VAR_102 = {
.stressor = stress_madvise,
.class = VAR_103 | VAR_104,
.VAR_3 = VAR_3,
.VAR_0 = VAR_0
};
#else
CLASS_8 VAR_102 = {
.stressor = stress_unimplemented,
.class = VAR_103 | VAR_104,
.VAR_3 = VAR_3,
.VAR_0 = VAR_0,
.VAR_105 = "built without madvise() system call"
};
#endif
| 0.745186 | {'IMPORT_0': 'stress-ng.h', 'IMPORT_1': 'core-builtin.h', 'CLASS_0': 'stress_help_t', 'VAR_0': 'help', 'FUNC_0': 'stress_set_madvise_hwpoison', 'VAR_1': 'stress_set_madvise_hwpoison', 'VAR_2': 'opt', 'FUNC_1': 'stress_set_setting_true', 'CLASS_1': 'stress_opt_set_func_t', 'VAR_3': 'opt_set_funcs', 'VAR_4': 'OPT_madvise_hwpoison', 'VAR_5': 'HAVE_MADVISE', 'VAR_6': 'NUM_MEM_RETRIES_MAX', 'VAR_7': 'NUM_HWPOISON_MAX', 'VAR_8': 'NUM_PTHREADS', 'VAR_9': 'NUM_SOFT_OFFLINE_MAX', 'CLASS_2': 'madvise_ctxt', 'CLASS_3': 'stress_args_t', 'VAR_10': 'args', 'VAR_11': 'buf', 'VAR_12': 'smaps', 'VAR_13': 'is_thread', 'VAR_14': 'hwpoison', 'ID_0': 'madvise_ctxt_t', 'CLASS_4': 'madvise_ctxt_t', 'VAR_15': 'jmp_env', 'VAR_16': 'madvise_options', 'VAR_17': 'MADV_NORMAL', 'VAR_18': 'MADV_RANDOM', 'VAR_19': 'MADV_SEQUENTIAL', 'VAR_20': 'MADV_WILLNEED', 'VAR_21': 'MADV_REMOVE', 'VAR_22': 'MADV_HUGEPAGE', 'VAR_23': 'MADV_NOHUGEPAGE', 'VAR_24': 'MADV_DONTDUMP', 'VAR_25': 'MADV_DODUMP', 'VAR_26': 'MADV_FREE', 'VAR_27': 'MADV_HWPOISON', 'VAR_28': 'MADV_WIPEONFORK', 'VAR_29': 'MADV_KEEPONFORK', 'VAR_30': 'MADV_INHERIT_ZERO', 'VAR_31': 'MADV_COLD', 'VAR_32': 'MADV_POPULATE_READ', 'VAR_33': 'MADV_POPULATE_WRITE', 'VAR_34': 'MADV_DONTNEED_LOCKED', 'VAR_35': 'MADV_PROTECT', 'VAR_36': 'MADV_SPACEAVAIL', 'VAR_37': 'MADV_ZERO_WIRED_PAGES', 'VAR_38': 'MADV_ACCESS_DEFAULT', 'VAR_39': 'MADV_ACCESS_MANY', 'VAR_40': 'MADV_INVAL', 'VAR_41': 'MADV_NOCORE', 'VAR_42': 'NORETURN', 'CLASS_5': 'MLOCKED_TEXT', 'FUNC_2': 'stress_sigbus_handler', 'VAR_43': 'stress_sigbus_handler', 'VAR_44': 'signum', 'FUNC_3': 'stress_read_proc_smaps', 'VAR_45': 'ignore', 'VAR_46': 'ret', 'VAR_47': 'buffer', 'FUNC_4': 'open', 'VAR_48': 'O_RDONLY', 'VAR_49': 'addr', 'VAR_50': 'size', 'VAR_51': 'idx', 'FUNC_5': 'SIZEOF_ARRAY', 'VAR_52': 'hwpoison_count', 'VAR_53': 'page_size', 'VAR_54': 'vec', 'VAR_55': 'ptr', 'VAR_56': 'instance', 'FUNC_6': 'calloc', 'FUNC_7': 'shim_mincore', 'FUNC_8': 'free', 'VAR_57': 'UNEXPECTED', 'VAR_58': 'soft_offline_count', 'FUNC_9': 'stress_madvise_pages', 'VAR_59': 'stress_madvise_pages', 'VAR_60': 'arg', 'VAR_61': 'n', 'VAR_62': 'ctxt', 'VAR_63': 'nowt', 'VAR_64': 'set', 'FUNC_10': 'sigemptyset', 'FUNC_11': 'sigaddset', 'VAR_65': 'SIGBUS', 'FUNC_12': 'pthread_sigmask', 'VAR_66': 'SIG_SETMASK', 'FUNC_13': 'shim_madvise', 'FUNC_14': 'shim_msync', 'VAR_67': 'm', 'FUNC_15': 'stress_mwc64modn_maybe_pwr2', 'VAR_68': '_POSIX_MEMLOCK_RANGE', 'VAR_69': 'HAVE_MLOCK', 'FUNC_16': 'shim_mlock', 'FUNC_17': 'shim_munlock', 'VAR_70': 'unmapped', 'FUNC_18': 'mmap', 'VAR_71': 'PROT_WRITE', 'VAR_72': 'MAP_PRIVATE', 'VAR_73': 'MAP_FAILED', 'FUNC_19': 'stress_munmap_retry_enomem', 'FUNC_20': 'stress_process_madvise', 'VAR_74': 'pid', 'CLASS_6': 'iovec', 'VAR_75': 'iov_base', 'VAR_76': 'iov_len', 'FUNC_21': 'shim_pidfd_open', 'FUNC_22': 'VOID_RET', 'VAR_77': 'ssize_t', 'FUNC_23': 'shim_process_madvise', 'VAR_78': 'MB', 'FUNC_24': 'getpid', 'VAR_79': 'num_mem_retries', 'VAR_80': 'PATH_MAX', 'VAR_81': 'uint64_t', 'VAR_82': 'madv_frees', 'VAR_83': 'uint8_t', 'VAR_84': 'madv_tries', 'FUNC_25': 'stress_get_setting', 'FUNC_26': 'pr_inf_skip', 'VAR_85': 'name', 'VAR_86': 'EXIT_NO_RESOURCE', 'FUNC_27': 'snprintf', 'VAR_87': 'PRIdMAX', 'ID_1': 'intmax_t', 'FUNC_28': 'sigsetjmp', 'FUNC_29': 'pr_fail', 'FUNC_30': 'munmap', 'FUNC_31': 'stress_sighandler', 'FUNC_32': 'stress_set_oom_adjustment', 'FUNC_33': 'stress_exit_status', 'VAR_88': 'O_CREAT', 'VAR_89': 'O_RDWR', 'VAR_90': 'S_IRUSR', 'VAR_91': 'S_IWUSR', 'VAR_92': 'errno', 'FUNC_34': 'strerror', 'FUNC_35': 'shim_unlink', 'FUNC_36': 'stress_file_rw_hint_short', 'VAR_93': 'STRESS_STATE_RUN', 'VAR_94': 'file_mapped', 'FUNC_37': 'stress_continue_flag', 'FUNC_38': 'stress_mwc1', 'FUNC_39': 'shim_usleep', 'FUNC_40': 'stress_madvise_random', 'FUNC_41': 'stress_mincore_touch_pages', 'VAR_95': 'HAVE_LIB_PTHREAD', 'CLASS_7': 'pthread_t', 'VAR_96': 'pthreads', 'VAR_97': 'rets', 'FUNC_42': 'pthread_join', 'FUNC_43': 'madvise', 'VAR_98': 'val', 'FUNC_44': 'stress_mwc8', 'FUNC_45': 'lseek', 'VAR_99': 'bad_addr', 'FUNC_46': 'stress_bogo_inc', 'FUNC_47': 'stress_continue', 'FUNC_48': 'pr_inf', 'VAR_100': 'PRIu64', 'VAR_101': 'EXIT_SUCCESS', 'CLASS_8': 'stressor_info_t', 'VAR_102': 'stress_madvise_info', 'VAR_103': 'CLASS_VM', 'VAR_104': 'CLASS_OS', 'VAR_105': 'unimplemented_reason'} | c | Procedural | 5.41% |
/*
* Copyright (c) 2017, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __PARAM_HEADER_H__
#define __PARAM_HEADER_H__
/* Param header types */
#define PARAM_EP 0x01
#define PARAM_IMAGE_BINARY 0x02
#define PARAM_BL31 0x03
#define PARAM_BL_LOAD_INFO 0x04
#define PARAM_BL_PARAMS 0x05
#define PARAM_PSCI_LIB_ARGS 0x06
#define PARAM_SP_IMAGE_BOOT_INFO 0x07
/* Param header version */
#define VERSION_1 0x01
#define VERSION_2 0x02
#define SET_PARAM_HEAD(_p, _type, _ver, _attr) do { \
(_p)->h.type = (uint8_t)(_type); \
(_p)->h.version = (uint8_t)(_ver); \
(_p)->h.size = (uint16_t)sizeof(*_p); \
(_p)->h.attr = (uint32_t)(_attr) ; \
} while (0)
/* Following is used for populating structure members statically. */
#define SET_STATIC_PARAM_HEAD(_p, _type, _ver, _p_type, _attr) \
._p.h.type = (uint8_t)(_type), \
._p.h.version = (uint8_t)(_ver), \
._p.h.size = (uint16_t)sizeof(_p_type), \
._p.h.attr = (uint32_t)(_attr)
#ifndef __ASSEMBLY__
#include <types.h>
/***************************************************************************
* This structure provides version information and the size of the
* structure, attributes for the structure it represents
***************************************************************************/
typedef struct param_header {
uint8_t type; /* type of the structure */
uint8_t version; /* version of this structure */
uint16_t size; /* size of this structure in bytes */
uint32_t attr; /* attributes: unused bits SBZ */
} param_header_t;
#endif /*__ASSEMBLY__*/
#endif /* __PARAM_HEADER_H__ */
| /*
* Copyright (c) 2017, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef VAR_0
#define VAR_0
/* Param header types */
#define VAR_1 0x01
#define VAR_2 0x02
#define VAR_3 0x03
#define VAR_4 0x04
#define VAR_5 0x05
#define VAR_6 0x06
#define VAR_7 0x07
/* Param header version */
#define VAR_8 0x01
#define VAR_9 0x02
#define FUNC_0(VAR_10, VAR_11, VAR_12, VAR_13) do { \
(_p)->h.type = (uint8_t)(_type); \
(_p)->h.version = (uint8_t)(_ver); \
(_p)->h.size = (uint16_t)sizeof(*_p); \
(_p)->h.attr = (uint32_t)(_attr) ; \
} while (0)
/* Following is used for populating structure members statically. */
#define FUNC_1(VAR_10, VAR_11, VAR_12, VAR_14, VAR_13) \
._p.h.type = (uint8_t)(_type), \
._p.h.version = (uint8_t)(_ver), \
._p.h.size = (uint16_t)sizeof(_p_type), \
._p.h.attr = (uint32_t)(_attr)
#ifndef VAR_15
#include <IMPORT_0>
/***************************************************************************
* This structure provides version information and the size of the
* structure, attributes for the structure it represents
***************************************************************************/
typedef struct CLASS_0 {
uint8_t VAR_16; /* type of the structure */
uint8_t VAR_17; /* version of this structure */
uint16_t VAR_18; /* size of this structure in bytes */
uint32_t VAR_19; /* attributes: unused bits SBZ */
} ID_0;
#endif /*__ASSEMBLY__*/
#endif /* __PARAM_HEADER_H__ */
| 0.960188 | {'VAR_0': '__PARAM_HEADER_H__', 'VAR_1': 'PARAM_EP', 'VAR_2': 'PARAM_IMAGE_BINARY', 'VAR_3': 'PARAM_BL31', 'VAR_4': 'PARAM_BL_LOAD_INFO', 'VAR_5': 'PARAM_BL_PARAMS', 'VAR_6': 'PARAM_PSCI_LIB_ARGS', 'VAR_7': 'PARAM_SP_IMAGE_BOOT_INFO', 'VAR_8': 'VERSION_1', 'VAR_9': 'VERSION_2', 'FUNC_0': 'SET_PARAM_HEAD', 'VAR_10': '_p', 'VAR_11': '_type', 'VAR_12': '_ver', 'VAR_13': '_attr', 'FUNC_1': 'SET_STATIC_PARAM_HEAD', 'VAR_14': '_p_type', 'VAR_15': '__ASSEMBLY__', 'IMPORT_0': 'types.h', 'CLASS_0': 'param_header', 'VAR_16': 'type', 'VAR_17': 'version', 'VAR_18': 'size', 'VAR_19': 'attr', 'ID_0': 'param_header_t'} | c | Procedural | 27.48% |
/*
* ===============================================================
* Description: Graph node class
*
* Created: Tuesday 16 October 2012 02:24:02 EDT
*
* Author: <NAME>, <EMAIL>
*
* Copyright (C) 2013, Cornell University, see the LICENSE file
* for licensing agreement
* ===============================================================
*/
#ifndef weaver_db_node_h_
#define weaver_db_node_h_
#include <stdint.h>
#include <vector>
#include <unordered_map>
#include <deque>
#include <po6/threads/mutex.h>
#include <po6/threads/cond.h>
#include "node_prog/node_prog_type.h"
#include "node_prog/node.h"
#include "node_prog/edge.h"
#include "node_prog/edge_list.h"
#include "node_prog/property.h"
#include "node_prog/base_classes.h"
#include "db/types.h"
#include "db/cache_entry.h"
#include "db/element.h"
#include "db/edge.h"
#include "db/shard_constants.h"
#include "client/datastructures.h"
namespace message
{
class message;
}
namespace db
{
struct migr_data
{
uint64_t new_loc;
std::vector<double> migr_score;
#ifdef WEAVER_CLDG
std::vector<uint32_t> msg_count;
#endif
#ifdef WEAVER_NEW_CLDG
std::vector<uint32_t> msg_count;
#endif
bool already_migr;
// queued requests, for the time when the node is marked in transit
// but requests cannot yet be forwarded to new location which is still
// setting up the node
std::vector<std::unique_ptr<message::message>> pending_requests;
migr_data();
};
class node : public node_prog::node
{
public:
node(const node_handle_t &handle, uint64_t shard, vclock_ptr_t &vclk, po6::threads::mutex *mtx);
~node();
public:
enum mode
{
NASCENT = 0,
STABLE,
MOVED
};
public:
element base;
uint64_t shard;
enum mode state;
data_map<std::vector<edge*>> out_edges;
po6::threads::cond cv; // for locking node
po6::threads::cond migr_cv; // make reads/writes wait while node is being migrated
std::deque<std::pair<uint64_t, uint64_t>> tx_queue; // queued txs, identified by <vt_id, queue timestamp> tuple
bool in_use;
uint32_t waiters; // count of number of waiters
bool permanently_deleted, evicted, to_evict;
std::unique_ptr<vc::vclock> last_perm_deletion; // vclock of last edge/property permanently deleted at this node
string_set aliases;
// for migration
std::unique_ptr<migr_data> migration;
// node program cache
std::unordered_map<cache_key_t, cache_entry> cache;
void add_cache_value(vclock_ptr_t vc,
std::shared_ptr<node_prog::Cache_Value_Base> cache_value,
std::shared_ptr<std::vector<remote_node>> watch_set,
cache_key_t key);
// node program state
typedef std::unordered_map<uint64_t, std::shared_ptr<node_prog::Node_State_Base>> id_to_state_t;
typedef std::pair<node_prog::prog_type, id_to_state_t> ptype_and_map_t;
typedef std::vector<ptype_and_map_t> prog_state_t;
prog_state_t prog_states;
// node eviction
bool empty_evicted_node_state();
// fault tolerance
std::unique_ptr<vc::vclock> last_upd_clk;
std::unique_ptr<vc::vclock_t> restore_clk;
// separate edge space
std::set<int64_t> edge_ids;
uint64_t max_edge_id;
public:
void add_edge_unique(edge *e); // bulk loading
void add_edge(edge *e);
bool edge_exists(const edge_handle_t&);
edge& get_edge(const edge_handle_t&);
node_prog::edge_list get_edges();
node_prog::prop_list get_properties();
bool has_property(std::pair<std::string, std::string> &p);
bool has_all_properties(std::vector<std::pair<std::string, std::string>> &props);
bool has_all_predicates(std::vector<predicate::prop_predicate> &preds);
void set_handle(const node_handle_t &_handle) { base.set_handle(_handle); }
const node_handle_t& get_handle() const { return base.get_handle(); }
void add_alias(const node_handle_t &alias);
bool del_alias(const node_handle_t &alias);
bool is_alias(const node_handle_t &alias) const;
void get_client_node(cl::node &n, bool, bool, bool);
};
using node_version_t = std::pair<node_handle_t, vclock_ptr_t>;
struct node_version_hash
{
size_t operator()(const node_version_t &nv) const
{
return weaver_util::murmur_hasher<std::string>()(nv.first);
}
};
struct evicted_node_state
{
std::deque<std::pair<uint64_t, uint64_t>> tx_queue;
vc::vclock last_perm_deletion;
node::prog_state_t prog_states;
};
}
#endif
| /*
* ===============================================================
* Description: Graph node class
*
* Created: Tuesday 16 October 2012 02:24:02 EDT
*
* Author: <NAME>, <EMAIL>
*
* Copyright (C) 2013, Cornell University, see the LICENSE file
* for licensing agreement
* ===============================================================
*/
#ifndef VAR_0
#define VAR_0
#include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
#include <deque>
#include <IMPORT_3>
#include <IMPORT_4>
#include "IMPORT_5"
#include "IMPORT_6"
#include "IMPORT_7"
#include "IMPORT_8"
#include "IMPORT_9"
#include "IMPORT_10"
#include "IMPORT_11"
#include "IMPORT_12"
#include "IMPORT_13"
#include "IMPORT_14"
#include "IMPORT_15"
#include "client/datastructures.h"
CLASS_0 message
{
CLASS_1 message;
}
CLASS_0 db
{
struct CLASS_2
{
uint64_t VAR_2;
CLASS_3::IMPORT_1<double> migr_score;
#ifdef VAR_4
CLASS_3::IMPORT_1<uint32_t> VAR_5;
#endif
#ifdef WEAVER_NEW_CLDG
CLASS_3::IMPORT_1<uint32_t> VAR_5;
#endif
bool VAR_6;
// queued requests, for the time when the node is marked in transit
// but requests cannot yet be forwarded to new location which is still
// setting up the node
CLASS_3::IMPORT_1<VAR_3::unique_ptr<message::message>> VAR_7;
VAR_1(ID_0);
};
CLASS_1 VAR_9 : VAR_10 node_prog::VAR_9
{
public:
FUNC_0(VAR_12 node_handle_t &VAR_13, VAR_14 shard, VAR_15 &VAR_16, po6::VAR_17::VAR_18 *VAR_19);
~FUNC_0();
public:
VAR_20 VAR_21
{
VAR_22 = 0,
VAR_23,
VAR_24
};
public:
VAR_25 VAR_26;
uint64_t shard;
enum CLASS_7 state;
data_map<VAR_3::IMPORT_1<VAR_27*>> VAR_28;
po6::threads::VAR_29 VAR_30; // for locking node
po6::threads::VAR_29 migr_cv; // make reads/writes wait while node is being migrated
std::deque<VAR_3::VAR_31<VAR_14, VAR_14>> VAR_32; // queued txs, identified by <vt_id, queue timestamp> tuple
bool VAR_33;
uint32_t VAR_34; // count of number of waiters
bool permanently_deleted, VAR_35, VAR_36;
std::unique_ptr<vc::vclock> VAR_37; // vclock of last edge/property permanently deleted at this node
CLASS_10 aliases;
// for migration
std::unique_ptr<VAR_1> VAR_38;
// node program cache
std::IMPORT_2<cache_key_t, VAR_39> VAR_40;
void FUNC_1(CLASS_6 vc,
CLASS_3::VAR_41<VAR_11::Cache_Value_Base> cache_value,
CLASS_3::VAR_41<VAR_3::IMPORT_1<VAR_42>> VAR_43,
cache_key_t VAR_44);
// node program state
typedef CLASS_3::IMPORT_2<uint64_t, CLASS_3::CLASS_11<CLASS_5::CLASS_12>> ID_1;
typedef CLASS_3::CLASS_9<CLASS_5::prog_type, CLASS_13> ID_2;
typedef CLASS_3::IMPORT_1<CLASS_14> ID_3;
CLASS_15 VAR_46;
// node eviction
bool FUNC_2();
// fault tolerance
std::unique_ptr<vc::vclock> VAR_47;
std::unique_ptr<vc::VAR_48> VAR_49;
// separate edge space
std::VAR_50<VAR_51> edge_ids;
uint64_t max_edge_id;
public:
VAR_52 FUNC_3(VAR_27 *VAR_53); // bulk loading
void FUNC_4(CLASS_8 *VAR_53);
bool FUNC_5(const CLASS_16&);
VAR_27& FUNC_6(VAR_12 VAR_54&);
node_prog::VAR_55 FUNC_7();
node_prog::prop_list FUNC_8();
bool FUNC_9(CLASS_3::VAR_31<VAR_3::VAR_56, CLASS_3::VAR_56> &p);
bool FUNC_10(CLASS_3::IMPORT_1<VAR_3::VAR_31<VAR_3::VAR_56, CLASS_3::VAR_56>> &VAR_57);
bool FUNC_11(CLASS_3::IMPORT_1<VAR_58::VAR_59> &preds);
void set_handle(const node_handle_t &VAR_60) { VAR_26.set_handle(VAR_60); }
const node_handle_t& get_handle() const { return VAR_26.get_handle(); }
void FUNC_12(const node_handle_t &VAR_61);
bool FUNC_13(const node_handle_t &VAR_61);
bool FUNC_14(const node_handle_t &VAR_61) VAR_12;
void FUNC_15(cl::VAR_9 &VAR_62, bool, bool, bool);
};
CLASS_17 node_version_t = VAR_3::VAR_31<node_handle_t, VAR_15>;
struct CLASS_18
{
size_t VAR_63()(const node_version_t &VAR_64) VAR_12
{
CLASS_19 VAR_65::VAR_66<VAR_3::VAR_56>(VAR_8)(VAR_64.VAR_67);
}
};
struct CLASS_20
{
CLASS_3::deque<VAR_3::VAR_31<VAR_14, VAR_14>> VAR_32;
vc::vclock VAR_37;
CLASS_4::VAR_45 VAR_46;
};
}
#endif
| 0.735552 | {'VAR_0': 'weaver_db_node_h_', 'IMPORT_0': 'stdint.h', 'IMPORT_1': 'vector', 'IMPORT_2': 'unordered_map', 'IMPORT_3': 'po6/threads/mutex.h', 'IMPORT_4': 'po6/threads/cond.h', 'IMPORT_5': 'node_prog/node_prog_type.h', 'IMPORT_6': 'node_prog/node.h', 'IMPORT_7': 'node_prog/edge.h', 'IMPORT_8': 'node_prog/edge_list.h', 'IMPORT_9': 'node_prog/property.h', 'IMPORT_10': 'node_prog/base_classes.h', 'IMPORT_11': 'db/types.h', 'IMPORT_12': 'db/cache_entry.h', 'IMPORT_13': 'db/element.h', 'IMPORT_14': 'db/edge.h', 'IMPORT_15': 'db/shard_constants.h', 'CLASS_0': 'namespace', 'CLASS_1': 'class', 'CLASS_2': 'migr_data', 'VAR_1': 'migr_data', 'VAR_2': 'new_loc', 'CLASS_3': 'std', 'VAR_3': 'std', 'VAR_4': 'WEAVER_CLDG', 'VAR_5': 'msg_count', 'VAR_6': 'already_migr', 'VAR_7': 'pending_requests', 'ID_0': '', 'VAR_8': '', 'VAR_9': 'node', 'FUNC_0': 'node', 'CLASS_4': 'node', 'VAR_10': 'public', 'VAR_11': 'node_prog', 'CLASS_5': 'node_prog', 'VAR_12': 'const', 'VAR_13': 'handle', 'VAR_14': 'uint64_t', 'VAR_15': 'vclock_ptr_t', 'CLASS_6': 'vclock_ptr_t', 'VAR_16': 'vclk', 'VAR_17': 'threads', 'VAR_18': 'mutex', 'VAR_19': 'mtx', 'VAR_20': 'enum', 'VAR_21': 'mode', 'CLASS_7': 'mode', 'VAR_22': 'NASCENT', 'VAR_23': 'STABLE', 'VAR_24': 'MOVED', 'VAR_25': 'element', 'VAR_26': 'base', 'VAR_27': 'edge', 'CLASS_8': 'edge', 'VAR_28': 'out_edges', 'VAR_29': 'cond', 'VAR_30': 'cv', 'VAR_31': 'pair', 'CLASS_9': 'pair', 'VAR_32': 'tx_queue', 'VAR_33': 'in_use', 'VAR_34': 'waiters', 'VAR_35': 'evicted', 'VAR_36': 'to_evict', 'VAR_37': 'last_perm_deletion', 'CLASS_10': 'string_set', 'VAR_38': 'migration', 'VAR_39': 'cache_entry', 'VAR_40': 'cache', 'FUNC_1': 'add_cache_value', 'VAR_41': 'shared_ptr', 'CLASS_11': 'shared_ptr', 'VAR_42': 'remote_node', 'VAR_43': 'watch_set', 'VAR_44': 'key', 'CLASS_12': 'Node_State_Base', 'ID_1': 'id_to_state_t', 'CLASS_13': 'id_to_state_t', 'ID_2': 'ptype_and_map_t', 'CLASS_14': 'ptype_and_map_t', 'ID_3': 'prog_state_t', 'CLASS_15': 'prog_state_t', 'VAR_45': 'prog_state_t', 'VAR_46': 'prog_states', 'FUNC_2': 'empty_evicted_node_state', 'VAR_47': 'last_upd_clk', 'VAR_48': 'vclock_t', 'VAR_49': 'restore_clk', 'VAR_50': 'set', 'VAR_51': 'int64_t', 'VAR_52': 'void', 'FUNC_3': 'add_edge_unique', 'VAR_53': 'e', 'FUNC_4': 'add_edge', 'FUNC_5': 'edge_exists', 'CLASS_16': 'edge_handle_t', 'VAR_54': 'edge_handle_t', 'FUNC_6': 'get_edge', 'VAR_55': 'edge_list', 'FUNC_7': 'get_edges', 'FUNC_8': 'get_properties', 'FUNC_9': 'has_property', 'VAR_56': 'string', 'FUNC_10': 'has_all_properties', 'VAR_57': 'props', 'FUNC_11': 'has_all_predicates', 'VAR_58': 'predicate', 'VAR_59': 'prop_predicate', 'VAR_60': '_handle', 'FUNC_12': 'add_alias', 'VAR_61': 'alias', 'FUNC_13': 'del_alias', 'FUNC_14': 'is_alias', 'FUNC_15': 'get_client_node', 'VAR_62': 'n', 'CLASS_17': 'using', 'CLASS_18': 'node_version_hash', 'VAR_63': 'operator', 'VAR_64': 'nv', 'CLASS_19': 'return', 'VAR_65': 'weaver_util', 'VAR_66': 'murmur_hasher', 'VAR_67': 'first', 'CLASS_20': 'evicted_node_state'} | c | OOP | 12.16% |
//
// CC_Monitor.h
// testbenchios
//
// Created by gwh on 2019/8/21.
// Copyright © 2019 gwh. All rights reserved.
//
#import "CC_Foundation.h"
NS_ASSUME_NONNULL_BEGIN
@interface CC_Monitor : CC_Object
// 启动监控 默认开启
@property (nonatomic,assign) BOOL startLaunchMonitor;
// 启动监控日志 默认开启
@property (nonatomic,assign) BOOL startLaunchMonitorLog;
// 定期检查 默认关闭
@property (nonatomic,assign) BOOL startPatrolMonitor;
// 定期检查日志 默认关闭
@property (nonatomic,assign) BOOL startPatrolMonitorLog;
+ (instancetype)shared;
- (void)watchStart:(NSString *)appDelegateName method:(NSString *)method;
- (void)watchEnd:(NSString *)appDelegateName method:(NSString *)method;
- (void)reviewLaunchFinish;
@end
NS_ASSUME_NONNULL_END
| //
// CC_Monitor.h
// testbenchios
//
// Created by gwh on 2019/8/21.
// Copyright © 2019 gwh. All rights reserved.
//
#import "CC_Foundation.h"
NS_ASSUME_NONNULL_BEGIN
@VAR_0 CC_Monitor : CC_Object
// 启动监控 默认开启
@VAR_1 (VAR_2,VAR_3) BOOL startLaunchMonitor;
// 启动监控日志 默认开启
@FUNC_0 (VAR_2,VAR_3) BOOL VAR_4;
// 定期检查 默认关闭
@FUNC_0 (VAR_2,VAR_3) BOOL VAR_5;
// 定期检查日志 默认关闭
@FUNC_0 (VAR_2,VAR_3) BOOL startPatrolMonitorLog;
+ (instancetype)shared;
- (void)VAR_6:(NSString *)appDelegateName method:(NSString *)method;
- (void)watchEnd:(NSString *)appDelegateName method:(NSString *)method;
- (void)VAR_7;
@end
VAR_8
| 0.403301 | {'VAR_0': 'interface', 'VAR_1': 'property', 'FUNC_0': 'property', 'VAR_2': 'nonatomic', 'VAR_3': 'assign', 'VAR_4': 'startLaunchMonitorLog', 'VAR_5': 'startPatrolMonitor', 'VAR_6': 'watchStart', 'VAR_7': 'reviewLaunchFinish', 'VAR_8': 'NS_ASSUME_NONNULL_END'} | c | Procedural | 100.00% |
#pragma once
#include <string>
// тип значения, добавляемого в список
typedef std::string TypeElement;
// список
struct List;
// возвращает указатель на новый список
List* createList();
// очищает список (удаляте все элементы списка)
void clearList(List* list);
// удаляет список
void deleteList(List* list);
// добавляет элемент в список по индексу
// (по умолчанию в конец списка)
void add(TypeElement value, List* list, int index = -1);
// удаляет элемент из list по индексу
// (по умочанию с конца списка)
// если индекс не найден, то возвращает -1, иначе 0
int pop(List* list, int index = -1);
// возвращает значение элемента в списке по индексу, но не удаляет его
// если индекс не найден, то возвращает -1
TypeElement getValue(List* list, int index);
// возвращает индекс первого вхождения value в lst
// если значение не найдено, возвращает -1
int getIndex(TypeElement value, List* list);
// возвращает размер списка
int getSize(List* list);
// проверяет, пуcт ли список
bool isEmpty(List* list);
// разворачивает список
void reverse(List*& list);
// печатает в консоль все значения списка через пробел
void printList(List* list);
// перемещает итератор list по индексу
void moveIterToPosition(List* list, int index);
// проверяет наличие элемента в list за O(n)
bool isInList(List* list, const TypeElement& str);
// возвращает список, составленный из уникальных элементов
List* getUnique(List* list);
bool isEnd(List* list);
| #pragma once
#include <string>
// тип значения, добавляемого в список
typedef std::string TypeElement;
// список
struct List;
// возвращает указатель на новый список
List* createList();
// очищает список (удаляте все элементы списка)
void clearList(List* list);
// удаляет список
void deleteList(List* list);
// добавляет элемент в список по индексу
// (по умолчанию в конец списка)
void FUNC_0(TypeElement value, List* list, int index = -1);
// удаляет элемент из list по индексу
// (по умочанию с конца списка)
// если индекс не найден, то возвращает -1, иначе 0
int pop(List* list, int index = -1);
// возвращает значение элемента в списке по индексу, но не удаляет его
// если индекс не найден, то возвращает -1
TypeElement FUNC_1(List* list, int index);
// возвращает индекс первого вхождения value в lst
// если значение не найдено, возвращает -1
int getIndex(TypeElement value, List* list);
// возвращает размер списка
int getSize(List* list);
// проверяет, пуcт ли список
bool isEmpty(List* list);
// разворачивает список
void reverse(List*& list);
// печатает в консоль все значения списка через пробел
void printList(List* list);
// перемещает итератор list по индексу
void moveIterToPosition(List* list, int index);
// проверяет наличие элемента в list за O(n)
bool isInList(List* list, const TypeElement& str);
// возвращает список, составленный из уникальных элементов
List* FUNC_2(List* list);
bool isEnd(List* list);
| 0.161455 | {'FUNC_0': 'add', 'FUNC_1': 'getValue', 'FUNC_2': 'getUnique'} | c | Hibrido | 100.00% |
// Copyright eeGeo Ltd (2012-2016), All Rights Reserved
#pragma once
#include "Types.h"
#include "Rendering.h"
#include "IRenderableFilter.h"
#include "VRDistortionIncludes.h"
namespace Eegeo
{
namespace VR
{
namespace Distortion
{
class VRDistortionRenderer : Eegeo::NonCopyable, public Eegeo::Rendering::IRenderableFilter
{
public:
VRDistortionRenderer(VRDistortionRenderable& renderable);
void EnqueueRenderables(const Eegeo::Rendering::RenderContext& renderContext, Eegeo::Rendering::RenderQueue& renderQueue);
private:
VRDistortionRenderable& m_renderable;
};
}
}
}
| // Copyright eeGeo Ltd (2012-2016), All Rights Reserved
#pragma once
#include "Types.h"
#include "Rendering.h"
#include "IMPORT_0"
#include "VRDistortionIncludes.h"
namespace Eegeo
{
namespace VR
{
namespace VAR_0
{
class VAR_1 : Eegeo::NonCopyable, VAR_2 Eegeo::Rendering::IRenderableFilter
{
public:
FUNC_0(VRDistortionRenderable& VAR_3);
void FUNC_1(const Eegeo::Rendering::RenderContext& renderContext, Eegeo::Rendering::RenderQueue& renderQueue);
private:
VRDistortionRenderable& m_renderable;
};
}
}
}
| 0.145053 | {'IMPORT_0': 'IRenderableFilter.h', 'VAR_0': 'Distortion', 'VAR_1': 'VRDistortionRenderer', 'FUNC_0': 'VRDistortionRenderer', 'VAR_2': 'public', 'VAR_3': 'renderable', 'FUNC_1': 'EnqueueRenderables'} | c | Procedural | 29.31% |
#include <stdio.h>
#include "tinyjpeg.h"
int main()
{
printf("========tinyjpeg===============================\n");
return 0;
}
| #include <stdio.h>
#include "tinyjpeg.h"
int FUNC_0()
{
printf("========tinyjpeg===============================\n");
return 0;
}
| 0.499391 | {'FUNC_0': 'main'} | c | Procedural | 100.00% |
#pragma once
/* Header files */
#cmakedefine HAVE_ATOMIC_H ${HAVE_ATOMIC_H}
/* various */
#define FORESTDB_VERSION "${FORESTDB_VERSION}"
#ifdef __GNUC__
#define HAVE_GCC_ATOMICS 1
#endif | #pragma once
/* Header files */
#cmakedefine HAVE_ATOMIC_H ${HAVE_ATOMIC_H}
/* various */
#define FORESTDB_VERSION "${FORESTDB_VERSION}"
#ifdef __GNUC__
#define HAVE_GCC_ATOMICS 1
#endif | 0.368189 | {} | c | Texto | 46.67% |
/* Remove ending fragment and compare types */
int
syck_tagcmp( const char *tag1, const char *tag2 )
{
if ( tag1 == tag2 ) return 1;
if ( tag1 == NULL || tag2 == NULL ) return 0;
else {
int i;
char *othorpe;
char *tmp1 = syck_strndup( tag1, strlen( tag1 ) );
char *tmp2 = syck_strndup( tag2, strlen( tag2 ) );
othorpe = strstr( tmp1, "#" );
if ( othorpe != NULL ) {
othorpe[0] = '\0';
}
othorpe = strstr( tmp2, "#" );
if ( othorpe != NULL ) {
othorpe[0] = '\0';
}
i = strcmp( tmp1, tmp2 );
S_FREE( tmp1 ); S_FREE( tmp2 );
return i;
}
} | /* Remove ending fragment and compare types */
int
syck_tagcmp( const char *VAR_0, const char *tag2 )
{
if ( VAR_0 == tag2 ) return 1;
if ( VAR_0 == NULL || tag2 == NULL ) return 0;
else {
int i;
char *othorpe;
char *VAR_1 = syck_strndup( VAR_0, strlen( VAR_0 ) );
char *VAR_2 = syck_strndup( tag2, strlen( tag2 ) );
othorpe = strstr( VAR_1, "#" );
if ( othorpe != NULL ) {
othorpe[0] = '\0';
}
othorpe = strstr( VAR_2, "#" );
if ( othorpe != NULL ) {
othorpe[0] = '\0';
}
i = strcmp( VAR_1, VAR_2 );
S_FREE( VAR_1 ); S_FREE( VAR_2 );
return i;
}
} | 0.278272 | {'VAR_0': 'tag1', 'VAR_1': 'tmp1', 'VAR_2': 'tmp2'} | c | Procedural | 100.00% |
/**
* Determines which numeric base the specified string should be parsed with.
* Strings with leading zeroes are not parsed as octal.
*/
static int
parse_num_base(const char *sval)
{
if (sval[0] == '+' || sval[0] == '-') {
sval++;
}
if (sval[0] == '0' && sval[1] == 'x') {
return 0;
} else {
return 10;
}
} | /**
* Determines which numeric base the specified string should be parsed with.
* Strings with leading zeroes are not parsed as octal.
*/
static int
FUNC_0(const char *sval)
{
if (sval[0] == '+' || sval[0] == '-') {
sval++;
}
if (sval[0] == '0' && sval[1] == 'x') {
return 0;
} else {
return 10;
}
} | 0.646504 | {'FUNC_0': 'parse_num_base'} | c | Procedural | 100.00% |
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
int main(int argc, char **argv) {
assert(argc == 2);
int n = atoi(argv[1]);
while(1) {
short *buf = (short*)malloc(sizeof(short) * n);
int m = fread(buf, 2, n, stdin);
if(m == 0) break;
fwrite(buf, 2, 1, stdout);
if(m != n) break;
}
return 0;
}
| #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
int FUNC_0(int argc, char **argv) {
assert(argc == 2);
int n = atoi(argv[1]);
while(1) {
short *buf = (short*)malloc(sizeof(short) * n);
int m = fread(buf, 2, n, stdin);
if(m == 0) break;
fwrite(buf, 2, 1, stdout);
if(m != n) break;
}
return 0;
}
| 0.119236 | {'FUNC_0': 'main'} | c | Procedural | 100.00% |
--- doinkd.c.intermediate 2019-12-26 13:25:48.000000000 +0000
+++ doinkd.c
@@ -289,7 +289,7 @@ int main(argc,argv)
(void) time (&tempus);
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
setutxent();
#else
if ((utmpfd = open (UTMP_FILE, O_RDONLY, 0)) == SYSERROR)
@@ -326,7 +326,7 @@ int main(argc,argv)
* examine him again.
*/
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
for (utmptr = 0, userptr = 0; utmp_ptr = getutxent();)
#else
#ifdef HAVE_UTMPX
@@ -342,7 +342,7 @@ int main(argc,argv)
break;
}
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
memcpy(&utmpbuf,utmp_ptr,sizeof(utmpbuf));
#else
#ifdef HAVE_UTMPX
@@ -363,7 +363,7 @@ int main(argc,argv)
if (strcmp(utmpbuf.ut_line,XDM_DEV) == 0)
{
/* This is the console. Is there a real name attached? */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (strlen(utmpbuf.ut_user) > 0)
#else
if (strlen(utmpbuf.ut_name) > 0)
@@ -374,21 +374,21 @@ int main(argc,argv)
}
#endif
-#if defined(SYSV) || (defined(__FreeBSD_version) && __FreeBSD_version >= 900007)
+#if defined(SYSV) || (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (utmpbuf.ut_type == USER_PROCESS || isConsole)
#else /* SYSV */
if (utmpbuf.ut_name[0] != NULL || isConsole)
#endif /* SYSV */
{
user = &users[utmptr];
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
(void) strncpy (tmpname, utmpbuf.ut_user, NAMELEN);
#else
(void) strncpy (tmpname, utmpbuf.ut_name, NAMELEN);
#endif
tmpname[NAMELEN] = 0;
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_tv.tv_sec)
#else
if (!strcmp (user->uid, tmpname) && user->time_on == utmpbuf.ut_xtime)
@@ -442,7 +442,7 @@ int main(argc,argv)
logfile ("Error: could not get info on supposed user %s.",user->uid);
else
getgroups_func (pswd->pw_name, user->groups, pswd->pw_gid);
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
user->time_on = utmpbuf.ut_tv.tv_sec;
#else
user->time_on = utmpbuf.ut_xtime;
| --- doinkd.c.intermediate 2019-12-26 13:25:48.000000000 +0000
+++ doinkd.c
@@ -289,7 +289,7 @@ int main(argc,argv)
(void) time (&VAR_0);
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
setutxent();
#else
if ((utmpfd = open (UTMP_FILE, O_RDONLY, 0)) == SYSERROR)
@@ -326,7 +326,7 @@ int main(argc,argv)
* VAR_1 him again.
*/
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
for (utmptr = 0, userptr = 0; utmp_ptr = getutxent();)
#else
#ifdef HAVE_UTMPX
@@ -342,7 +342,7 @@ int main(argc,argv)
break;
}
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
memcpy(&utmpbuf,utmp_ptr,sizeof(utmpbuf));
#else
#ifdef HAVE_UTMPX
@@ -363,7 +363,7 @@ int main(argc,argv)
if (strcmp(utmpbuf.ut_line,XDM_DEV) == 0)
{
/* This is the console. Is there a real name attached? */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (strlen(utmpbuf.ut_user) > 0)
#else
if (strlen(utmpbuf.ut_name) > 0)
@@ -374,21 +374,21 @@ int main(argc,argv)
}
#endif
-#if defined(SYSV) || (defined(__FreeBSD_version) && __FreeBSD_version >= 900007)
+#if defined(SYSV) || (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (utmpbuf.ut_type == USER_PROCESS || isConsole)
#else /* SYSV */
if (utmpbuf.ut_name[0] != NULL || isConsole)
#endif /* SYSV */
{
user = &users[utmptr];
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
(void) strncpy (tmpname, utmpbuf.ut_user, NAMELEN);
#else
(void) strncpy (tmpname, utmpbuf.ut_name, NAMELEN);
#endif
tmpname[NAMELEN] = 0;
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
if (!strcmp (user->VAR_2, tmpname) && user->VAR_3 == utmpbuf.ut_tv.tv_sec)
#else
if (!strcmp (user->VAR_2, tmpname) && user->VAR_3 == utmpbuf.ut_xtime)
@@ -442,7 +442,7 @@ int main(argc,argv)
logfile ("Error: could not get info on supposed user %s.",user->VAR_2);
else
getgroups_func (pswd->pw_name, user->groups, pswd->pw_gid);
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007
+#if (defined(__FreeBSD_version) && __FreeBSD_version >= 900007) || defined(__DragonFly__)
user->VAR_3 = utmpbuf.ut_tv.tv_sec;
#else
user->VAR_3 = utmpbuf.ut_xtime;
| 0.115088 | {'VAR_0': 'tempus', 'VAR_1': 'examine', 'VAR_2': 'uid', 'VAR_3': 'time_on'} | c | Procedural | 25.71% |
/*
* Copyright (C) 2012 - 2013 Michal Simek <[email protected]>
* Copyright (C) 2012 - 2013 Xilinx, Inc. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/io.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/hardware.h>
DECLARE_GLOBAL_DATA_PTR;
/* Control regsiter bitfield definitions */
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_MASK 0xC
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT 2
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT 1
/* ECC scrub regsiter definitions */
#define ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK 0x7
#define ZYNQ_DDRC_ECC_SCRUBREG_ECCMODE_SECDED 0x4
void zynq_ddrc_init(void)
{
u32 width, ecctype;
width = readl(&ddrc_base->ddrc_ctrl);
width = (width & ZYNQ_DDRC_CTRLREG_BUSWIDTH_MASK) >>
ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT;
ecctype = (readl(&ddrc_base->ecc_scrub) &
ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK);
/* ECC is enabled when memory is in 16bit mode and it is enabled */
if ((ecctype == ZYNQ_DDRC_ECC_SCRUBREG_ECCMODE_SECDED) &&
(width == ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT)) {
puts("Memory: ECC enabled\n");
/*
* Clear the first 1MB because it is not initialized from
* first stage bootloader. To get ECC to work all memory has
* been initialized by writing any value.
*/
memset(0, 0, 1 * 1024 * 1024);
} else {
puts("Memory: ECC disabled\n");
}
if (width == ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT)
gd->ram_size /= 2;
}
| /*
* Copyright (C) 2012 - 2013 Michal Simek <[email protected]>
* Copyright (C) 2012 - 2013 Xilinx, Inc. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/io.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/hardware.h>
DECLARE_GLOBAL_DATA_PTR;
/* Control regsiter bitfield definitions */
#define VAR_0 0xC
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT 2
#define ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT 1
/* ECC scrub regsiter definitions */
#define ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK 0x7
#define VAR_1 0x4
void FUNC_0(void)
{
u32 width, ecctype;
width = readl(&ddrc_base->ddrc_ctrl);
width = (width & VAR_0) >>
ZYNQ_DDRC_CTRLREG_BUSWIDTH_SHIFT;
ecctype = (readl(&ddrc_base->VAR_2) &
ZYNQ_DDRC_ECC_SCRUBREG_ECC_MODE_MASK);
/* ECC is enabled when memory is in 16bit mode and it is enabled */
if ((ecctype == VAR_1) &&
(width == ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT)) {
FUNC_1("Memory: ECC enabled\n");
/*
* Clear the first 1MB because it is not initialized from
* first stage bootloader. To get ECC to work all memory has
* been initialized by writing any value.
*/
FUNC_2(0, 0, 1 * 1024 * 1024);
} else {
FUNC_1("Memory: ECC disabled\n");
}
if (width == ZYNQ_DDRC_CTRLREG_BUSWIDTH_16BIT)
gd->ram_size /= 2;
}
| 0.307145 | {'VAR_0': 'ZYNQ_DDRC_CTRLREG_BUSWIDTH_MASK', 'VAR_1': 'ZYNQ_DDRC_ECC_SCRUBREG_ECCMODE_SECDED', 'FUNC_0': 'zynq_ddrc_init', 'VAR_2': 'ecc_scrub', 'FUNC_1': 'puts', 'FUNC_2': 'memset'} | c | Procedural | 100.00% |
#include <console.h>
#include <timer.h>
#include <trap.h>
#include <types.h>
#include <x86.h>
/**
* 在工作方式3下,方波的频率是输入时钟频率的N分之一,又因为计数器的输入时钟频率是
* 1.193180MHz=1193180Hz,所以 1193180/N = 方波的频率(Hz)
* 如果想让计数器每10ms(=100Hz)发出一个方波上升沿用以产生中断请求信号的话,那么
* N = 1193180/100
* */
#define TIMER_FREQ 1193180
#define FREQUENCY 100
void timer_interrupt_handler(struct trapframe *);
void timerinit(void) {
register_interrupt_handler(T_IRQ0 + IRQ_TIMER, timer_interrupt_handler);
uint32_t timer_frequency = TIMER_FREQ / FREQUENCY;
// 设置 8253/8254 芯片工作在模式 3 下
outb(0x43, 0x36);
// 分别写入低字节和高字节
outb(0x40, (uint8_t)(timer_frequency & 0xff));
outb(0x40, (uint8_t)(timer_frequency >> 8) & 0xff);
}
void timer_interrupt_handler(struct trapframe *tf) {
static uint32_t tick = 0;
cprintf("tick: %d\n", tick++);
eoi(tf->trapno);
}
| #include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
#include <types.h>
#include <IMPORT_3>
/**
* 在工作方式3下,方波的频率是输入时钟频率的N分之一,又因为计数器的输入时钟频率是
* 1.193180MHz=1193180Hz,所以 1193180/N = 方波的频率(Hz)
* 如果想让计数器每10ms(=100Hz)发出一个方波上升沿用以产生中断请求信号的话,那么
* N = 1193180/100
* */
#define VAR_0 1193180
#define VAR_1 100
void FUNC_0(struct CLASS_0 *);
void FUNC_1(void) {
FUNC_2(VAR_3 + VAR_4, VAR_2);
uint32_t timer_frequency = VAR_0 / VAR_1;
// 设置 8253/8254 芯片工作在模式 3 下
FUNC_3(0x43, 0x36);
// 分别写入低字节和高字节
FUNC_3(0x40, (uint8_t)(timer_frequency & 0xff));
FUNC_3(0x40, (uint8_t)(timer_frequency >> 8) & 0xff);
}
void FUNC_0(struct CLASS_0 *tf) {
static uint32_t VAR_5 = 0;
FUNC_4("tick: %d\n", VAR_5++);
FUNC_5(tf->VAR_6);
}
| 0.809339 | {'IMPORT_0': 'console.h', 'IMPORT_1': 'timer.h', 'IMPORT_2': 'trap.h', 'IMPORT_3': 'x86.h', 'VAR_0': 'TIMER_FREQ', 'VAR_1': 'FREQUENCY', 'FUNC_0': 'timer_interrupt_handler', 'VAR_2': 'timer_interrupt_handler', 'CLASS_0': 'trapframe', 'FUNC_1': 'timerinit', 'FUNC_2': 'register_interrupt_handler', 'VAR_3': 'T_IRQ0', 'VAR_4': 'IRQ_TIMER', 'FUNC_3': 'outb', 'VAR_5': 'tick', 'FUNC_4': 'cprintf', 'FUNC_5': 'eoi', 'VAR_6': 'trapno'} | c | Procedural | 31.63% |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.