hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
df490937f8a5030938fe3b24918d9bf13cf1434c | 625 | h | C | RecoBTag/FeatureTools/interface/JetConverter.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | RecoBTag/FeatureTools/interface/JetConverter.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | RecoBTag/FeatureTools/interface/JetConverter.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | #ifndef RecoBTag_FeatureTools_JetConverter_h
#define RecoBTag_FeatureTools_JetConverter_h
#include "DataFormats/BTauReco/interface/JetFeatures.h"
#include "DataFormats/JetReco/interface/Jet.h"
namespace btagbtvdeep {
class JetConverter {
public:
static void jetToFeatures(const reco::Jet& jet, JetFeatures& jet_features) {
jet_features.pt = jet.pt(); // uncorrected
jet_features.eta = jet.eta();
jet_features.phi = jet.phi();
jet_features.mass = jet.mass();
jet_features.energy = jet.energy();
}
};
} // namespace btagbtvdeep
#endif //RecoBTag_FeatureTools_JetConverter_h
| 26.041667 | 80 | 0.7296 |
8db0d2936ae5d942484a352ce02a3b0a76428b63 | 4,537 | c | C | assignment2/src/readlib.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | assignment2/src/readlib.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | assignment2/src/readlib.c | kv13/Parallel-And-Distributed-Systems | d3f91cf8ffc41a7beae0d3dc3017960efc5b8b3c | [
"MIT"
] | null | null | null | //%%%%% dumb read datasets functions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../inc/readlib.h"
double *read_1(char *file_path, int *n, int *d){
if(strstr(file_path,"ColorH")!=NULL){
*n=68040;
*d=32;
}else if(strstr(file_path,"ColorM")!=NULL){
*n = 68040;
*d = 9;
}else{
printf("ONLY ColorHistogram and ColorMoments read\n");
exit(1);
}
double *X;
X = (double *)malloc((*n) * (*d) * sizeof(double));
//open the file
FILE *fp;
fp = fopen(file_path,"r");
if(fp == NULL){
printf("CANNOT OPEN THE FILE...EXITING\n");
exit(1);
}
//initialize variables
char *line = NULL;
size_t len = 0;
ssize_t read;
char delim[] = " ";
char *ptr ;
//READ THE FILE
int counter=0;
while(read = getline(&line, &len, fp)!= -1){
ptr = strtok(line,delim);
//skip first element which is the index;
ptr = strtok(NULL,delim);
while(ptr!=NULL){
X[counter] = atof(ptr);
counter ++;
ptr = strtok(NULL,delim);
}
}
return X;
}
double *read_2(char *file_path, int *n, int *d){
//set the number of points and the dimensions
*n = 130065;
*d = 50;
double *X;
X = (double *)malloc((*n) * (*d) * sizeof(double));
//open the file
FILE *fp;
fp = fopen(file_path,"r");
if(fp == NULL){
printf("CANNOT OPEN THE FILE...EXITING\n");
exit(1);
}
//initialize variables
char *line = NULL;
size_t len = 0;
ssize_t read;
char delim[] = " ";
char *ptr ;
//READ data
//skip the first line
read = getline(&line,&len,fp);
//printf("%s\n",line);
int counter = 0;
while(read = getline(&line,&len,fp)!=-1){
ptr = strtok(line,delim);
while(ptr!=NULL){
X[counter] = atof(ptr);
counter++;
ptr = strtok(NULL,delim);
}
}
return X;
}
double *read_3(char *file_path, int *n, int *d){
//set the number of points and the dimensions
*n = 106574;
*d = 518;
double *X;
X = (double *)malloc((*n) * (*d) * sizeof(double));
//open the file
FILE *fp;
fp = fopen(file_path,"r");
if(fp == NULL){
printf("CANNOT OPEN THE FILE...EXITING\n");
exit(1);
}
//initialize variables
char *line = NULL;
size_t len = 0;
ssize_t read;
char delim[] = ",";
char *ptr;
//READ data
//skip the first 4 line
read = getline(&line,&len,fp);
//printf("%s\n",line);
read = getline(&line,&len,fp);
//printf("%s\n",line);
read = getline(&line,&len,fp);
//printf("%s\n",line);
read = getline(&line,&len,fp);
//printf("%s\n",line);
int counter = 0;
while(read = getline(&line,&len,fp)!=-1){
ptr = strtok(line,delim);
//skip the first element which is the index
ptr = strtok(NULL,delim);
while(ptr != NULL){
X[counter] = atof(ptr);
counter ++;
ptr = strtok(NULL,delim);
}
}
return X;
}
double *read_4(char *file_path, int *n, int *d){
if (strstr(file_path,"BBC") != NULL) *n = 17720;
else if (strstr(file_path,"CNN.") != NULL) *n = 22545;
else if (strstr(file_path,"CNNI") != NULL) *n = 33117;
else if (strstr(file_path,"NDTV") != NULL) *n = 17051;
else if (strstr(file_path,"TIMES") != NULL) *n = 39252;
*d = 17;
int d_min = 17;
double *X;
X = (double *)malloc((*n) * (*d) * sizeof(double));
//open file
FILE *fp;
fp = fopen(file_path,"r");
if(fp == NULL){
printf("CANNOT OPEN THE FILE...EXITING\n");
exit(1);
}
//initialize variables
char *line = NULL;
size_t len = 0;
ssize_t read;
char delim[] = ":";
char delim_2[]= " ";
char delim_3[] = " ";
char *ptr;
int counter = 0;
int d_counter;
while(read = getline(&line,&len,fp)!=-1){
ptr = strtok(line,delim);
d_counter = 0;
while(ptr != NULL){
ptr = strtok(NULL,delim_3);
//printf("%s\n",ptr);
X[counter] = atof(ptr);
counter ++;
d_counter ++;
if(d_counter >= d_min)break;
ptr = strtok(NULL,delim);
}
}
return X;
}
double *read_data(char *file_path, int *n, int *d){
double *X;
if (strstr(file_path, "Co") != NULL) X = read_1(file_path,n,d);
else if (strstr(file_path, "Mini") != NULL) X = read_2(file_path,n,d);
else if (strstr(file_path, "feat") != NULL) X = read_3(file_path,n,d);
else if (strstr(file_path,"BBC") != NULL) X = read_4(file_path,n,d);
else if (strstr(file_path,"CNN") != NULL) X = read_4(file_path,n,d);
else if (strstr(file_path,"NDTV") != NULL) X = read_4(file_path,n,d);
else if (strstr(file_path,"TIMES") != NULL) X = read_4(file_path,n,d);
else{
printf("CANNOT RECOGNIZE THE FILE...=>EXITING\n");
exit(1);
}
return X;
}
| 19.899123 | 74 | 0.581001 |
5c1e16fa37c1bc7afaefdd7e3d989f52a00a8193 | 1,830 | h | C | src/gbpLib/gbpCalc/gbpCalc.h | gbpoole/gbpCode | 5157d2e377edbd4806258d1c16b329373186d43a | [
"MIT"
] | 1 | 2015-10-20T11:39:53.000Z | 2015-10-20T11:39:53.000Z | src/gbpLib/gbpCalc/gbpCalc.h | gbpoole/gbpCode | 5157d2e377edbd4806258d1c16b329373186d43a | [
"MIT"
] | 2 | 2017-07-30T11:10:49.000Z | 2019-06-18T00:40:46.000Z | src/gbpLib/gbpCalc/gbpCalc.h | gbpoole/gbpCode | 5157d2e377edbd4806258d1c16b329373186d43a | [
"MIT"
] | 4 | 2015-01-23T00:50:40.000Z | 2016-08-01T08:14:24.000Z | #ifndef GBPCALC_H
#define GBPCALC_H
#define CALC_MODE_DEFAULT SID_DEFAULT_MODE
#define CALC_MODE_RETURN_DOUBLE SID_TTTP00
#define CALC_MODE_ABS SID_TTTP01
#define CALC_STAT_DEFAULT SID_DEFAULT_MODE
#define CALC_STAT_RETURN_DOUBLE SID_TTTP00
#define CALC_STAT_GLOBAL SID_TTTP01
#define CALC_STAT_SUM SID_TTTP02
#define CALC_STAT_MIN SID_TTTP03
#define CALC_STAT_MAX SID_TTTP04
#define CALC_STAT_MEAN SID_TTTP05
#define CALC_STAT_MEDIAN SID_TTTP06
#define CALC_STAT_STDDEV SID_TTTP07
// Function declarations
#ifdef __cplusplus
extern "C" {
#endif
void calc_max(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_max_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
void calc_mean(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_mean_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
void calc_min(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_min_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
void calc_stddev(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_stddev_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
void calc_sum(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_sum_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
void calc_median(void *data, void *result, size_t n_data, SID_Datatype type, int mode);
void calc_median_global(void *data_local, void *result, size_t n_data_local, SID_Datatype type, int mode, SID_Comm *comm);
#ifdef __cplusplus
}
#endif
#endif
| 45.75 | 122 | 0.809836 |
e1b8c7a7d8d214f1d4fc17900a00a28451342a7a | 1,903 | h | C | library/math/matrixPowerSum.h | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 40 | 2017-11-26T05:29:18.000Z | 2020-11-13T00:29:26.000Z | library/math/matrixPowerSum.h | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 101 | 2019-02-09T06:06:09.000Z | 2021-12-25T16:55:37.000Z | library/math/matrixPowerSum.h | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 6 | 2017-01-03T14:17:58.000Z | 2021-01-22T10:37:04.000Z | #pragma once
#include "matrixMod.h"
/*
n
SUM A^(p*i) , n >= 0, A^0 = I
i=0
*/
template <int mod = 1'000'000'007>
struct MatrixPowerSumMod {
int K; // A is K x K matrix
vector<MatrixMod<mod>> baseDP; // A^p
vector<MatrixMod<mod>> sumDP; //
// O(K^3 * logMAXN)
void prepare(const MatrixMod<mod>& A, long long p, long long maxN) {
K = A.N;
int logN = 1;
while ((1ll << logN) <= maxN)
logN++;
MatrixMod<mod> base(K), curr(K);
base = MatrixMod<mod>::pow(A, p);
curr = base;
baseDP.resize(logN);
sumDP.resize(logN);
baseDP[0] = curr;
sumDP[0] = curr;
for (int i = 1; i < logN; i++) {
auto next = curr * curr;
baseDP[i] = next;
sumDP[i] = sumDP[i - 1] + sumDP[i - 1] * curr;
swap(next.mat, curr.mat);
}
}
// O(K^3 * logN)
MatrixMod<mod> powerSum(long long N) {
MatrixMod<mod> res(K);
if (N < 0)
return res;
res.identity();
MatrixMod<mod> scale(K);
scale.identity();
for (int i = 0; N; i++, N >>= 1) {
if (N & 1) {
res += sumDP[i] * scale;
scale *= baseDP[i];
}
}
return res;
}
static MatrixMod<mod> powerSum(const MatrixMod<mod>& A, long long N) {
int K = A.N;
MatrixMod<mod> res(K);
if (N < 0)
return res;
res.identity();
MatrixMod<mod> scale(K);
scale.identity();
MatrixMod<mod> sum(A), curr(A);
for (int i = 0; N; i++, N >>= 1) {
if (N & 1) {
res += sum * scale;
scale *= curr;
}
sum = sum + sum * curr;
curr = curr * curr;
}
return res;
}
};
| 21.873563 | 74 | 0.425118 |
6d9e432c57f26c1fdc1890d77251292b919d6c88 | 2,974 | h | C | tightvnc/ft-common/FileInfo.h | jjzhang166/qmlvncviewer2 | b888c416ab88b81fe802ab0559bb87361833a0b5 | [
"Apache-2.0"
] | 47 | 2016-08-17T03:18:32.000Z | 2022-01-14T01:33:15.000Z | tightvnc/ft-common/FileInfo.h | jjzhang166/qmlvncviewer2 | b888c416ab88b81fe802ab0559bb87361833a0b5 | [
"Apache-2.0"
] | 3 | 2018-06-29T06:13:28.000Z | 2020-11-26T02:31:49.000Z | tightvnc/ft-common/FileInfo.h | jjzhang166/qmlvncviewer2 | b888c416ab88b81fe802ab0559bb87361833a0b5 | [
"Apache-2.0"
] | 15 | 2016-08-17T07:03:55.000Z | 2021-08-02T14:42:02.000Z | // Copyright (C) 2009,2010,2011,2012 GlavSoft LLC.
// All rights reserved.
//
//-------------------------------------------------------------------------
// This file is part of the TightVNC software. Please visit our Web site:
//
// http://www.tightvnc.com/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//-------------------------------------------------------------------------
//
#ifndef _FILE_INFO_H_
#define _FILE_INFO_H_
#include "util/StringStorage.h"
#include "util/inttypes.h"
#include "file-lib/File.h"
//
// Contains information about file in file transfer protocol
// format.
//
class FileInfo
{
public:
//
// Combination of flags that can be used in m_flags
// class members
//
const static int DIRECTORY = 0x1;
const static int EXECUTABLE = 0x2;
public:
//
// Creates FileInfo class with empty file information (no flags,
// no size, name is set to "").
//
FileInfo();
//
// Creates FileInfo class with members with values specified
// in constructor's arguments.
//
FileInfo(UINT64 size, UINT64 modTime,
UINT16 flags, const TCHAR *fileName);
//
// Creates FileInfo class with name, size, flags that will be
// retrieved from file argument.
//
FileInfo(const File *file);
//
// Returns true if DIRECTORY flag is set
//
bool isDirectory() const;
//
// Returns true if EXECUTABLE flag is set
//
bool isExecutable() const;
//
// Sets last modification time (in seconds from unix epoch)
//
void setLastModified(UINT64 time);
//
// Sets file size (in bytes)
//
void setSize(UINT64 size);
//
// Sets file flags (see static FileInfo constants)
//
void setFlags(UINT16 flags);
//
// Sets relative (from parent folder) file name
//
void setFileName(const TCHAR *fileName);
//
// Returns file last modified time (in secords, starts from unix epoch)
//
UINT64 lastModified() const;
//
// Returns file size in bytes
//
UINT64 getSize() const;
//
// Returns file flags (see FileInfo static constants)
//
UINT16 getFlags() const;
//
// Returns file name
//
const TCHAR *getFileName() const;
protected:
UINT64 m_sizeInBytes;
UINT64 m_lastModified;
UINT16 m_flags;
StringStorage m_fileName;
};
#endif
| 21.092199 | 75 | 0.645595 |
a64fe32d446dd13c85302beac9b67a08a9f44f20 | 2,956 | h | C | listmodel.h | TRAPTAProject/traptaviewer | 1e66c63026e7a16ed0b151d192159db0162b5f83 | [
"MIT"
] | null | null | null | listmodel.h | TRAPTAProject/traptaviewer | 1e66c63026e7a16ed0b151d192159db0162b5f83 | [
"MIT"
] | null | null | null | listmodel.h | TRAPTAProject/traptaviewer | 1e66c63026e7a16ed0b151d192159db0162b5f83 | [
"MIT"
] | null | null | null | #ifndef LISTMODEL_H
#define LISTMODEL_H
#include <QObject>
#include <QAbstractListModel>
#include "rowmodel.h"
#include <QSettings>
class ListModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int rowHeight READ rowHeight NOTIFY rowHeightChanged)
Q_PROPERTY(bool scroll READ scroll NOTIFY scrollChanged) // true if list is to be scrolled
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
Q_PROPERTY(int advertLineCount READ advertLineCount NOTIFY advertLineCountChanged)
Q_PROPERTY(bool displayAdvert READ displayAdvert NOTIFY displayAdvertChanged)
Q_PROPERTY(QString advertFile READ advertFile NOTIFY advertFileChanged)
public:
explicit ListModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const;
void displayDemoContent(const QString &filename);
int rowHeight() const { return _rowHeight; }
bool scroll() const { return _scroll; }
QString title() const { return _title; }
QString subtitle() const { return _subtitle; }
int advertLineCount() const { return _advertLineCount; }
bool displayAdvert(); const
QString advertFile() const { return _advertFile; }
signals:
void rowHeightChanged(int rowHeight);
void scrollChanged(bool scroll);
void titleChanged(QString title);
void subtitleChanged(QString subtitle);
void advertLineCountChanged(int advertLineCount);
void displayAdvertChanged(bool display);
void advertFileChanged(QString advertFile);
public slots:
void processJsonDocument(const QJsonDocument& jsonDoc);
void setScrollAreaHeight(int scrollAreaHeight);
void decRowHeight();
void incRowHeight();
void setCurrentRowIndex(int index);
void decAdvertLineCount();
void incAdvertLineCount();
void setAdvertFile(const QString& advertFile);
void setDisplayAdvert(bool display);
private:
QSettings _settings;
QList<RowModel> _rowList;
QList<RowModel> _advertList;
QString _displayType;
QString _title;
int _rowHeight;
int _scrollAreaHeight;
QList<RowModel> parseRanking(const QJsonArray& jsonArray);
QList<RowModel> parseTeam(const QJsonObject& jsonObject);
QList<RowModel> parsePosition(const QJsonArray& jsonArray);
QList<RowModel> parseMatch(const QJsonArray &jsonArray);
QVariant rowData(int rowIndex, int role) const;
void setAdvertLineCount(int advertLineCount);
void setRowHeight(int rowHeight);
void checkScroll(); // check if scrolling is needed
bool _scroll;
bool _displayAdvert;
QString _subtitle;
int _advertLineCount;
QString _advertFile;
void updateAdBanner();
};
#endif // LISTMODEL_H
| 29.56 | 95 | 0.721922 |
54b3930d4287a953b1c7697ce2a0d5e250b23044 | 2,239 | h | C | gtsam/slam/KarcherMeanFactor.h | kvmanohar22/gtsam | 8194b931fe07fb1bd346cdcf116a35f9c4e208ba | [
"BSD-3-Clause"
] | 3 | 2020-08-13T20:25:43.000Z | 2021-03-05T22:24:43.000Z | gtsam/slam/KarcherMeanFactor.h | kvmanohar22/gtsam | 8194b931fe07fb1bd346cdcf116a35f9c4e208ba | [
"BSD-3-Clause"
] | 1 | 2020-10-21T09:54:08.000Z | 2020-10-21T09:54:08.000Z | gtsam/slam/KarcherMeanFactor.h | kvmanohar22/gtsam | 8194b931fe07fb1bd346cdcf116a35f9c4e208ba | [
"BSD-3-Clause"
] | 1 | 2020-08-12T20:46:15.000Z | 2020-08-12T20:46:15.000Z | /* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/*
* @file KarcherMeanFactor.h
* @author Frank Dellaert
* @date March 2019
*/
#pragma once
#include <gtsam/base/Matrix.h>
#include <gtsam/linear/JacobianFactor.h>
#include <map>
#include <vector>
namespace gtsam {
/**
* Optimize for the Karcher mean, minimizing the geodesic distance to each of
* the given rotations, by constructing a factor graph out of simple
* PriorFactors.
*/
template <class T>
T FindKarcherMean(const std::vector<T, Eigen::aligned_allocator<T>>& rotations);
template <class T>
T FindKarcherMean(std::initializer_list<T>&& rotations);
/**
* The KarcherMeanFactor creates a constraint on all SO(n) variables with
* given keys that the Karcher mean (see above) will stay the same. Note the
* mean itself is irrelevant to the constraint and is not a parameter: the
* constraint is implemented as enforcing that the sum of local updates is
* equal to zero, hence creating a rank-dim constraint. Note it is implemented as
* a soft constraint, as typically it is used to fix a gauge freedom.
* */
template <class T>
class KarcherMeanFactor : public NonlinearFactor {
/// Constant Jacobian made of d*d identity matrices
boost::shared_ptr<JacobianFactor> jacobian_;
enum {D = traits<T>::dimension};
public:
/// Construct from given keys.
template <typename CONTAINER>
KarcherMeanFactor(const CONTAINER& keys, int d=D);
/// Destructor
virtual ~KarcherMeanFactor() {}
/// Calculate the error of the factor: always zero
double error(const Values& c) const override { return 0; }
/// get the dimension of the factor (number of rows on linearization)
size_t dim() const override { return D; }
/// linearize to a GaussianFactor
boost::shared_ptr<GaussianFactor> linearize(const Values& c) const override {
return jacobian_;
}
};
// \KarcherMeanFactor
} // namespace gtsam
| 30.256757 | 81 | 0.681554 |
54e4b7498550110ac3c9a43a91ee246d029ad469 | 7,855 | c | C | src/guacenc/ffmpeg-compat.c | dev-ddoe/guacamole-server | 8ecdedb05aed4aa9c282ce11d0d1fc8b247265cb | [
"Apache-2.0"
] | 1,450 | 2017-11-29T07:18:10.000Z | 2022-03-30T04:20:50.000Z | src/guacenc/ffmpeg-compat.c | dev-ddoe/guacamole-server | 8ecdedb05aed4aa9c282ce11d0d1fc8b247265cb | [
"Apache-2.0"
] | 122 | 2017-12-19T09:17:49.000Z | 2022-03-22T19:58:49.000Z | src/guacenc/ffmpeg-compat.c | dev-ddoe/guacamole-server | 8ecdedb05aed4aa9c282ce11d0d1fc8b247265cb | [
"Apache-2.0"
] | 431 | 2017-12-05T16:35:42.000Z | 2022-03-31T22:49:20.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "config.h"
#include "ffmpeg-compat.h"
#include "log.h"
#include "video.h"
#include <libavcodec/avcodec.h>
#include <libavutil/common.h>
#include <libavutil/imgutils.h>
#include <guacamole/client.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
/**
* Writes a single packet of video data to the current output file. If an error
* occurs preventing the packet from being written, messages describing the
* error are logged.
*
* @param video
* The video associated with the output file that the given packet should
* be written to.
*
* @param data
* The buffer of data containing the video packet which should be written.
*
* @param size
* The number of bytes within the video packet.
*
* @return
* Zero if the packet was written successfully, non-zero otherwise.
*/
static int guacenc_write_packet(guacenc_video* video, void* data, int size) {
int ret;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,1,0)
AVPacket pkt;
/* Have to create a packet around the encoded data we have */
av_init_packet(&pkt);
if (video->context->coded_frame->pts != AV_NOPTS_VALUE) {
pkt.pts = av_rescale_q(video->context->coded_frame->pts,
video->context->time_base,
video->output_stream->time_base);
}
if (video->context->coded_frame->key_frame) {
pkt->flags |= AV_PKT_FLAG_KEY;
}
pkt.data = data;
pkt.size = size;
pkt.stream_index = video->output_stream->index;
ret = av_interleaved_write_frame(video->container_format_context, &pkt);
#else
/* We know data is already a packet if we're using a newer libavcodec */
AVPacket* pkt = (AVPacket*) data;
av_packet_rescale_ts(pkt, video->context->time_base, video->output_stream->time_base);
pkt->stream_index = video->output_stream->index;
ret = av_interleaved_write_frame(video->container_format_context, pkt);
#endif
if (ret != 0) {
guacenc_log(GUAC_LOG_ERROR, "Unable to write frame "
"#%" PRId64 ": %s", video->next_pts, strerror(errno));
return -1;
}
/* Data was written successfully */
guacenc_log(GUAC_LOG_DEBUG, "Frame #%08" PRId64 ": wrote %i bytes",
video->next_pts, size);
return ret;
}
int guacenc_avcodec_encode_video(guacenc_video* video, AVFrame* frame) {
/* For libavcodec < 54.1.0: packets were handled as raw malloc'd buffers */
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,1,0)
AVCodecContext* context = video->context;
/* Calculate appropriate buffer size */
int length = FF_MIN_BUFFER_SIZE + 12 * context->width * context->height;
/* Allocate space for output */
uint8_t* data = malloc(length);
if (data == NULL)
return -1;
/* Encode packet of video data */
int used = avcodec_encode_video(context, data, length, frame);
if (used < 0) {
guacenc_log(GUAC_LOG_WARNING, "Error encoding frame #%" PRId64,
video->next_pts);
free(data);
return -1;
}
/* Report if no data needs to be written */
if (used == 0) {
free(data);
return 0;
}
/* Write data, logging any errors */
guacenc_write_packet(video, data, used);
free(data);
return 1;
#else
/* For libavcodec < 57.37.100: input/output was not decoupled and static
* allocation of AVPacket was supported.
*
* NOTE: Since dynamic allocation of AVPacket was added before this point (in
* 57.12.100) and static allocation was deprecated later (in 58.133.100), it is
* convenient to tie static vs. dynamic allocation to the old vs. new I/O
* mechanism and avoid further complicating the version comparison logic. */
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
/* Init video packet */
AVPacket packet;
av_init_packet(&packet);
/* Request that encoder allocate data for packet */
packet.data = NULL;
packet.size = 0;
/* Write frame to video */
int got_data;
if (avcodec_encode_video2(video->context, &packet, frame, &got_data) < 0) {
guacenc_log(GUAC_LOG_WARNING, "Error encoding frame #%" PRId64,
video->next_pts);
return -1;
}
/* Write corresponding data to file */
if (got_data) {
guacenc_write_packet(video, (void*) &packet, packet.size);
av_packet_unref(&packet);
}
#else
/* Write frame to video */
int result = avcodec_send_frame(video->context, frame);
/* Stop once encoded has been flushed */
if (result == AVERROR_EOF)
return 0;
/* Abort on error */
else if (result < 0) {
guacenc_log(GUAC_LOG_WARNING, "Error encoding frame #%" PRId64,
video->next_pts);
return -1;
}
AVPacket* packet = av_packet_alloc();
if (packet == NULL)
return -1;
/* Flush all available packets */
int got_data = 0;
while (avcodec_receive_packet(video->context, packet) == 0) {
/* Data was received */
got_data = 1;
/* Attempt to write data to output file */
guacenc_write_packet(video, (void*) packet, packet->size);
av_packet_unref(packet);
}
av_packet_free(&packet);
#endif
/* Frame may have been queued for later writing / reordering */
if (!got_data)
guacenc_log(GUAC_LOG_DEBUG, "Frame #%08" PRId64 ": queued for later",
video->next_pts);
return got_data;
#endif
}
AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec,
int bitrate, int width, int height, int gop_size, int qmax, int qmin,
int pix_fmt, AVRational time_base) {
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 33, 100)
stream->codec->bit_rate = bitrate;
stream->codec->width = width;
stream->codec->height = height;
stream->codec->gop_size = gop_size;
stream->codec->qmax = qmax;
stream->codec->qmin = qmin;
stream->codec->pix_fmt = pix_fmt;
stream->codec->time_base = time_base;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(55, 44, 100)
stream->time_base = time_base;
#endif
return stream->codec;
#else
AVCodecContext* context = avcodec_alloc_context3(codec);
if (context) {
context->bit_rate = bitrate;
context->width = width;
context->height = height;
context->gop_size = gop_size;
context->qmax = qmax;
context->qmin = qmin;
context->pix_fmt = pix_fmt;
context->time_base = time_base;
stream->time_base = time_base;
}
return context;
#endif
}
int guacenc_open_avcodec(AVCodecContext *avcodec_context,
AVCodec *codec, AVDictionary **options,
AVStream* stream) {
int ret = avcodec_open2(avcodec_context, codec, options);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 33, 100)
/* Copy stream parameters to the muxer */
int codecpar_ret = avcodec_parameters_from_context(stream->codecpar, avcodec_context);
if (codecpar_ret < 0)
return codecpar_ret;
#endif
return ret;
}
| 29.419476 | 90 | 0.662126 |
902686a0949cc68b26d5093c2880f7077f355622 | 1,305 | c | C | libft/src/ft_strnstr.c | madvid/42_wolf3d | b55c9baeae50f63870f62db97385d8c1a8374109 | [
"MIT"
] | null | null | null | libft/src/ft_strnstr.c | madvid/42_wolf3d | b55c9baeae50f63870f62db97385d8c1a8374109 | [
"MIT"
] | null | null | null | libft/src/ft_strnstr.c | madvid/42_wolf3d | b55c9baeae50f63870f62db97385d8c1a8374109 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mpivet-p <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/07 16:32:50 by mpivet-p #+# #+# */
/* Updated: 2018/11/17 14:24:44 by mpivet-p ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *haystack, const char *needle, size_t len)
{
size_t i;
size_t j;
i = 0;
j = 0;
if (needle[i] == '\0')
return ((char*)haystack);
while (haystack[i] != '\0' && j < len)
{
while (haystack[i + j] == needle[j] && haystack[i + j] && i + j < len)
{
j++;
if (needle[j] == '\0')
return ((char*)&haystack[i]);
}
j = 0;
i++;
}
return (NULL);
}
| 35.27027 | 80 | 0.233716 |
c2b091817bdf6e58d6f15d21bdd22a31b119db4c | 1,282 | c | C | src/common/tests/path-test.c | 01org/murphy | d9866aaf9c94c086ce84ffedfbad9eea8c53e3f5 | [
"BSD-3-Clause"
] | 10 | 2015-10-25T00:10:27.000Z | 2019-03-25T00:49:43.000Z | src/common/tests/path-test.c | intel/murphy | d9866aaf9c94c086ce84ffedfbad9eea8c53e3f5 | [
"BSD-3-Clause"
] | 6 | 2020-01-09T03:57:18.000Z | 2020-03-02T01:04:56.000Z | src/common/tests/path-test.c | 01org/murphy | d9866aaf9c94c086ce84ffedfbad9eea8c53e3f5 | [
"BSD-3-Clause"
] | 8 | 2015-01-02T05:17:00.000Z | 2018-06-26T11:05:15.000Z | #include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <murphy/common/file-utils.h>
int main(int argc, char *argv[])
{
int i;
size_t size;
char *p, buf[PATH_MAX];
struct stat ost, nst;
if (argc > 1) {
size = strtoul(argv[1], &p, 10);
if (*p || size > sizeof(buf))
size = sizeof(buf);
}
else
size = sizeof(buf);
for (i = 1; i < argc; i++) {
printf("'%s':\n", argv[i]);
if ((p = mrp_normalize_path(buf, size, argv[i])) != NULL) {
printf(" -> '%s'\n", p);
if (stat(argv[i], &ost) < 0)
printf(" Non-existing path, can't test in practice...\n");
else{
if (stat(buf, &nst) == 0 &&
ost.st_dev == nst.st_dev && ost.st_ino == nst.st_ino)
printf(" Filesystem-equality check: OK.\n");
else {
printf(" Filesystem-equality check: FAILED\n");
exit(1);
}
}
}
else {
printf(" failed (%d: %s)\n", errno, strerror(errno));
exit(1);
}
}
return 0;
}
| 25.137255 | 77 | 0.446178 |
0a7776a99282976995ebb1cf6927b145c6cd9fb1 | 643 | h | C | set1/single_byte_xor_cipher.h | guzhoucan/cryptopals | a45280158867a86b5d8c61bf7194277d05abdf14 | [
"MIT"
] | 1 | 2020-08-07T22:38:27.000Z | 2020-08-07T22:38:27.000Z | set1/single_byte_xor_cipher.h | guzhoucan/cryptopals | a45280158867a86b5d8c61bf7194277d05abdf14 | [
"MIT"
] | null | null | null | set1/single_byte_xor_cipher.h | guzhoucan/cryptopals | a45280158867a86b5d8c61bf7194277d05abdf14 | [
"MIT"
] | null | null | null | #ifndef CRYPTOPALS_SET1_SINGLE_BYTE_XOR_CIPHER_H_
#define CRYPTOPALS_SET1_SINGLE_BYTE_XOR_CIPHER_H_
#include <cstdlib>
#include <string>
#include <string_view>
#include <vector>
namespace cryptopals {
struct SingleByteXorPlaintext {
uint8_t key;
std::string plaintext;
double score; // averaged score per character
size_t pos; // only used in DetectSingleByteXorCipher
};
SingleByteXorPlaintext DecodeSingleByteXorCipher(std::string_view ciphertext);
SingleByteXorPlaintext DetectSingleByteXorCipher(
std::vector<std::string> ciphertexts);
} // namespace cryptopals
#endif // CRYPTOPALS_SET1_SINGLE_BYTE_XOR_CIPHER_H_
| 24.730769 | 78 | 0.807154 |
116c02cf37d01bb72ef5e7e9dddd6829c5049491 | 349 | h | C | include/win.h | manila/tic-tac-toe | 58d7d4e18800f14d64f71c5aad245e043e9e85ab | [
"MIT"
] | null | null | null | include/win.h | manila/tic-tac-toe | 58d7d4e18800f14d64f71c5aad245e043e9e85ab | [
"MIT"
] | null | null | null | include/win.h | manila/tic-tac-toe | 58d7d4e18800f14d64f71c5aad245e043e9e85ab | [
"MIT"
] | null | null | null | #ifndef WIN_H
# define WIN_H
/*
These functions return a truth value (greater than 0)
if there are three set bits in a row
*/
int check_win(BITBOARD bitboard);
int check_win_horizontal(BITBOARD bitboard);
int check_win_verticle(BITBOARD bitboard);
int check_win_diag_right(BITBOARD bitboard);
int check_win_diag_left(BITBOARD bitboard);
#endif
| 21.8125 | 54 | 0.799427 |
da938289a198b1187d282b273673d34876192211 | 373 | h | C | src/kernel/fs/buffer.h | cashlisa/mos | 75165d1a63a6aa172001bbd9a1df441ff9c15038 | [
"MIT"
] | 302 | 2019-05-20T12:45:37.000Z | 2022-03-29T07:27:43.000Z | src/kernel/fs/buffer.h | huytd/mos | a9d8f925b87fcc56b94ff5933403f46a3146e1bf | [
"MIT"
] | 12 | 2020-03-27T13:04:53.000Z | 2021-12-07T12:26:29.000Z | src/kernel/fs/buffer.h | huytd/mos | a9d8f925b87fcc56b94ff5933403f46a3146e1bf | [
"MIT"
] | 33 | 2020-04-08T15:40:44.000Z | 2022-03-12T03:26:07.000Z | #ifndef FS_BUFFER_H
#define FS_BUFFER_H
#include <include/types.h>
#include <stdint.h>
// FIXME: MQ 2019-07-16 Is it safe to assume 512 b/s, it's fairly safe for hard disk but CD ROM might use 2048 b/s
#define BYTES_PER_SECTOR 512
char *bread(char *dev_name, sector_t block, uint32_t size);
void bwrite(char *dev_name, sector_t block, char *buf, uint32_t size);
#endif
| 26.642857 | 114 | 0.75067 |
dd97ba27f6c45e5d3d0b36fc75f4632bd8a49eca | 1,034 | h | C | GrowingTracker/GrowingSwizzle/GrowingSwizzle.h | raojunbo/growingio-sdk-ios-autotracker | e0c6cd62159654fcce11a66b1e004ccae96ec952 | [
"Apache-2.0"
] | 1 | 2021-08-23T13:04:23.000Z | 2021-08-23T13:04:23.000Z | GrowingTracker/GrowingSwizzle/GrowingSwizzle.h | raojunbo/growingio-sdk-ios-autotracker | e0c6cd62159654fcce11a66b1e004ccae96ec952 | [
"Apache-2.0"
] | null | null | null | GrowingTracker/GrowingSwizzle/GrowingSwizzle.h | raojunbo/growingio-sdk-ios-autotracker | e0c6cd62159654fcce11a66b1e004ccae96ec952 | [
"Apache-2.0"
] | null | null | null | //
// GrowingSwizzle.h
// GrowingTrack
//
// Created by GrowingIO on 2020/7/22.
// Copyright (C) 2020 Beijing Yishu Technology 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.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSObject (GrowingSwizzle)
+ (BOOL)growing_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError **)error_;
+ (BOOL)growing_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError **)error_;
@end
NS_ASSUME_NONNULL_END
| 32.3125 | 103 | 0.748549 |
ddb2f69c4958b00cd074180d85439c6438609d7f | 1,389 | h | C | CocosBCXWallet/CocosBCXWallet/Toos/CCWEncryptTool/AES128/NSData+AES128.h | zhangxiaozheng/iOSWallet | b195d9d169365bc9ab9943952adf9b5b3669012f | [
"Apache-2.0"
] | 1 | 2019-08-21T15:30:25.000Z | 2019-08-21T15:30:25.000Z | CocosBCXWallet/CocosBCXWallet/Toos/CCWEncryptTool/AES128/NSData+AES128.h | zack3140/iOSWallet | 61663a25691e614e836059e223596e16f912c728 | [
"Apache-2.0"
] | null | null | null | CocosBCXWallet/CocosBCXWallet/Toos/CCWEncryptTool/AES128/NSData+AES128.h | zack3140/iOSWallet | 61663a25691e614e836059e223596e16f912c728 | [
"Apache-2.0"
] | 1 | 2021-03-31T16:28:54.000Z | 2021-03-31T16:28:54.000Z | //
// NSData+AES128.h
// LYTSoketSDKDemo
//
// Created by Shangen Zhang on 2017/9/4.
// Copyright © 2017年 深圳柒壹思诺科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
#define Option_CBC_MODE 0x0001
#define Option_ECB_MODE 0x0002
#define OptionMode uint32_t
@interface NSData (AES128)
/**
AES 16位 加密 (AES128)
@param key 密钥
@param Iv 向量
@param mode 加密方式(kCCOptionPKCS7Padding = 0x0001, kCCOptionECBMode = 0x0002)
@return 加密后的data
*/
- (NSData *)AES128EncryptWithKey:(NSString *)key iv:(NSString *)Iv option:(OptionMode)mode;
/**
AES 16位 解密 (AES128)
@param key 密钥
@param Iv 向量
@param mode 加密方式 (kCCOptionPKCS7Padding = 0x0001, kCCOptionECBMode = 0x0002)
@return 解密后的data
*/
- (NSData *)AES128DecryptWithKey:(NSString *)key iv:(NSString *)Iv option:(OptionMode)mode;
@end
@interface NSString (AES128)
/**
AES 16位 加密 (AES128)
@param key 密钥
@param Iv 向量
@param mode 加密方式 (kCCOptionPKCS7Padding = 0x0001, kCCOptionECBMode = 0x0002)
@return 加密后的string
*/
- (NSString *)AES128EncryptWithKey:(NSString *)key iv:(NSString *)Iv option:(OptionMode)mode;
/**
AES 16位 解密 (AES128)
@param key 密钥
@param Iv 向量
@param mode 加密方式 (kCCOptionPKCS7Padding = 0x0001, kCCOptionECBMode = 0x0002)
@return 解密后的string
*/
- (NSString *)AES128DecryptWithKey:(NSString *)key iv:(NSString *)Iv option:(OptionMode)mode;
@end
| 21.369231 | 93 | 0.701944 |
5adc5f0deece7910c4ae680a0b3006dbd1b8decf | 548 | h | C | main.h | Dremora/psxt001z | 141c705a415f1620b7256a1ecf3e43d7454cd61d | [
"MIT"
] | 5 | 2015-12-05T12:34:11.000Z | 2022-01-09T23:32:37.000Z | main.h | Dremora/psxt001z | 141c705a415f1620b7256a1ecf3e43d7454cd61d | [
"MIT"
] | null | null | null | main.h | Dremora/psxt001z | 141c705a415f1620b7256a1ecf3e43d7454cd61d | [
"MIT"
] | 14 | 2015-11-28T02:55:24.000Z | 2022-03-31T15:25:23.000Z | #ifndef __MAIN_H__
#define __MAIN_H__
class crc32{
protected:
unsigned table[256];
public:
unsigned m_crc32;
crc32();
void ProcessCRC(void* pData, register int nLen);
};
void antizektor(s8 * filename);
u8 checksums(int argc, char *argv[]);
void dump();
void generate(u32 argc, s8 * argv[]);
void m3s(s8 * filename);
void matrix(s8 * argv[]);
void scanfix(char *filename, int fix);
void str(s8 * argv[]);
void str2bs(s8 * argv[]);
void sub(s8 * filename, s8 * strsectors);
u8 umd(int argc, char *argv[]);
void zektor(s8 * filename);
#endif | 18.896552 | 49 | 0.691606 |
2dfefaf0df15e6d4a299a504be82fcedf198e718 | 2,274 | h | C | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.h | Andruxin52rus/openvino | d824e371fe7dffb90e6d3d58e4e34adecfce4606 | [
"Apache-2.0"
] | 1 | 2022-01-19T15:36:45.000Z | 2022-01-19T15:36:45.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.h | Andruxin52rus/openvino | d824e371fe7dffb90e6d3d58e4e34adecfce4606 | [
"Apache-2.0"
] | 22 | 2021-02-03T12:41:51.000Z | 2022-02-21T13:04:48.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.h | mmakridi/openvino | 769bb7709597c14debdaa356dd60c5a78bdfa97e | [
"Apache-2.0"
] | 1 | 2021-07-28T17:30:46.000Z | 2021-07-28T17:30:46.000Z | // Copyright (c) 2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "gemm_kernel_base.h"
#include <vector>
namespace kernel_selector {
class GemmKernelMMADslmInt8 : public GemmKernelBase {
public:
using Parent = GemmKernelBase;
using DispatchData = CommonDispatchData;
struct GemmTuningData {
size_t size_m;
size_t size_n;
size_t size_k;
const size_t slm_tile_size = 32;
const size_t simd_size = 8;
const size_t pack_size = 4;
const size_t max_slm_preloading_size = 256;
size_t slm_decimation_factor = 2;
};
GemmKernelMMADslmInt8() : GemmKernelBase("gemm_mmad_int8_slm") {}
KernelsData GetKernelsData(const Params& params, const optional_params& options) const override;
KernelsPriority GetKernelsPriority(const Params& params, const optional_params& options) const override;
ParamsKey GetSupportedKey() const override;
protected:
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return { FusedOpType::QUANTIZE,
FusedOpType::ACTIVATION,
FusedOpType::SCALE,
FusedOpType::ELTWISE };
}
bool Validate(const Params& params, const optional_params& options) const override;
JitConstants GetJitConstants(const gemm_params& params) const override;
DispatchData SetDefault(const gemm_params& params) const override;
GemmTuningData InitGemmTuningData(const gemm_params& params) const;
GemmTuningData SetTuningParams(const gemm_params& params) const;
size_t GetMmadOperationsNumber(const GemmTuningData& tuning_data) const;
bool HasLeftovers(const GemmTuningData& tuning_data) const;
};
} // namespace kernel_selector
| 38.542373 | 108 | 0.73175 |
11f6b793f2d222a10dbfb1a0481c1ae2f052e353 | 1,016 | c | C | src/test-apps/ledtape-test1/ledtape.c | ana104-collab/Wacky-Racer-Embedded-Systems | 3a0ef3e75e5ca20a0aceb037306e8de5571602f7 | [
"MIT"
] | null | null | null | src/test-apps/ledtape-test1/ledtape.c | ana104-collab/Wacky-Racer-Embedded-Systems | 3a0ef3e75e5ca20a0aceb037306e8de5571602f7 | [
"MIT"
] | null | null | null | src/test-apps/ledtape-test1/ledtape.c | ana104-collab/Wacky-Racer-Embedded-Systems | 3a0ef3e75e5ca20a0aceb037306e8de5571602f7 | [
"MIT"
] | null | null | null | #include "delay.h"
#include "pio.h"
#ifndef LEDTAPE_PIO
#define LEDTAPE_PIO PA19_PIO
#endif
void ledtape_init (void)
{
pio_config_set (LEDTAPE_PIO, PIO_OUTPUT_LOW);
}
__attribute__((optimize (2)))
__always_inline__
static void ledtape_write_byte (uint8_t byte)
{
int j;
for (j = 0; j < 8; j++)
{
pio_output_high (LEDTAPE_PIO);
DELAY_US (0.3);
// MSB first
if (! (byte & 0x80))
pio_output_low (LEDTAPE_PIO);
DELAY_US (0.3);
pio_output_low (LEDTAPE_PIO);
DELAY_US (0.6);
byte <<= 1;
}
}
__attribute__((optimize (2)))
void ledtape_write (uint8_t *buffer, uint16_t size)
{
int i;
// The data order is R G B per LED
for (i = 0; i < size; i++)
{
ledtape_write_byte (buffer[i]);
}
// Send reset code
pio_output_high (LEDTAPE_PIO);
DELAY_US (50);
pio_output_low (LEDTAPE_PIO);
}
| 19.538462 | 52 | 0.541339 |
91e759d992e27b3c4a6c62c1cb7a51394e9e256d | 3,736 | c | C | tests/copper/CopperSplit.c | khval/BetterFakeMode | aace8a1355e36a6cf2591a88c2859987f506c4bc | [
"MIT"
] | 1 | 2021-05-30T19:48:11.000Z | 2021-05-30T19:48:11.000Z | tests/copper/CopperSplit.c | khval/BetterFakeMode | aace8a1355e36a6cf2591a88c2859987f506c4bc | [
"MIT"
] | 25 | 2021-04-23T21:02:44.000Z | 2021-08-03T22:15:51.000Z | tests/copper/CopperSplit.c | khval/BetterFakeMode | aace8a1355e36a6cf2591a88c2859987f506c4bc | [
"MIT"
] | null | null | null | // OSCopper.e
// Native graphics example using OS friendly copperlist
#include <stdbool.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/copper.h>
#include <graphics/view.h>
#include <hardware/custom.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <exec/memory.h>
#include "common.h"
//struct RastPort *rport;
#define CMOVEA(c,a,b) { CMove(c,a,b);CBump(c); }
#define BPLCON0 0x100
#define BPLCON1 0x102
#define BPLCON2 0x104
#define BPLCON3 0x106
#define BPL1MOD 0x108
#define BPL2MOD 0x10A
#define BPLPT 0x0E0
#define SetColour(src,a,r,g,b) SetRGB32( &(src -> ViewPort), (ULONG) a*0x01010101, (ULONG) r*0x01010101,(ULONG) g*0x01010101,(ULONG) b*0x01010101 )
#define Shr(x,n) (x << n)
bool initScreen()
{
screen=OpenScreenTags(NULL,
SA_Title,"OS Copper",
// SA_Pens,,
SA_Depth,4,
SA_Width, 320,
SA_Height, 256,
TAG_END);
if (!screen) return false;
window=OpenWindowTags(NULL,
WA_IDCMP,IDCMP_MOUSEBUTTONS,
WA_Flags,WFLG_NOCAREREFRESH |
WFLG_ACTIVATE |
WFLG_BORDERLESS |
WFLG_BACKDROP,
WA_CustomScreen,screen,
TAG_END);
if (!window) return false;
#ifdef __amigaos3__
myucoplist=AllocVec(sizeof(struct UCopList),MEMF_PUBLIC | MEMF_CLEAR);
#endif
#ifdef __amigaos4__
myucoplist=AllocVecTags(sizeof(struct UCopList),
AVT_Type, MEMF_SHARED,
AVT_Alignment, 16,
AVT_ClearWithValue, 0,
TAG_DONE);
#endif
if (!myucoplist) return false;
return true;
}
void errors()
{
if (!screen) Printf("Unable to open screen.\n");
if (!window) Printf("Unable to open window.\n");
if (!myucoplist) Printf("Unable to allocate myucoplist memory.\n");
}
int main_prog()
{
if (initScreen())
{
int i;
int x,y;
uint32 backrgb;
int linestart=screen -> BarHeight+1;
int lines=screen -> Height-linestart;
int width=screen -> Width;
struct RastPort *rport=window -> RPort;
struct BitMap *bitmap=screen -> RastPort.BitMap;
uint32 modulo=bitmap -> BytesPerRow-40;
uint32 planesize=modulo*screen -> Height;
ULONG bitplane=(ULONG) bitmap -> Planes[0];
viewport=ViewPortAddress(window);
backrgb= ((ULONG *) viewport -> ColorMap -> ColorTable)[0];
SetColour(screen,0,0,0,0);
SetColour(screen,1,255,255,255);
SetRast(rport,1);
Box(rport,0,linestart,width-1,screen -> Height-1,1);
for (y=0;y<64;y+=64)
{
for (x=0;x<256;x+=64)
{
RectFill(rport,x,y,x+31,y+31);
Box(rport,x,y,32,32,1);
}
for (x=32;x<288;x+=64)
{
RectFill(rport,x,y+32,x+31,y+63);
Box(rport,x,y+32,32,32,1);
}
}
CINIT(myucoplist, 1+ (lines*(1+3+4)) + 3 );
CMOVEA(myucoplist,COLOR(1),0xFFF); // +1
for (i=linestart;i<lines;i++)
{
CWAIT(myucoplist,i,0); // +1
switch (i)
{
case 127:
CMOVEA(myucoplist,BPL1MOD,-1*(planesize/2)); // +3
CMOVEA(myucoplist,BPLPT,Shr(bitplane,16));
CMOVEA(myucoplist,BPLPT+2,bitplane & 0xFFFF);
break;
case 128:
CMOVEA(myucoplist,BPL1MOD,modulo);
break;
}
CMOVEA(myucoplist,BPLCON3,0); // +4
CMOVEA(myucoplist,COLOR(1),(i-linestart)&0xFFF);
CMOVEA(myucoplist,BPLCON3,0x200);
CMOVEA(myucoplist,COLOR(1),(0xFFF-i)&0xFFF);
}
// +3
CWAIT(myucoplist,i,0);
CMOVEA(myucoplist,COLOR(1),backrgb);
CEND(myucoplist);
Forbid();
viewport -> UCopIns = myucoplist;
Permit();
RethinkDisplay();
WaitLeftMouse(window);
}
else
{
errors();
}
closeDown();
return 0;
}
int main()
{
int ret;
if (open_libs()==FALSE)
{
Printf("failed to open libs!\n");
close_libs();
return 0;
}
ret = main_prog();
close_libs();
return 0;
}
| 19.158974 | 147 | 0.661938 |
8109b6ac84d70495551ed491774def82ba4fd070 | 5,442 | h | C | firmware/system/libraries/gpio.h | mfkiwl/tinysdr | 8b77d522eb9c017a8dfbe3b1f75b777ab109b8b2 | [
"MIT"
] | 112 | 2020-02-23T20:51:02.000Z | 2022-03-08T21:10:16.000Z | firmware/system/libraries/gpio.h | mfkiwl/tinysdr | 8b77d522eb9c017a8dfbe3b1f75b777ab109b8b2 | [
"MIT"
] | null | null | null | firmware/system/libraries/gpio.h | mfkiwl/tinysdr | 8b77d522eb9c017a8dfbe3b1f75b777ab109b8b2 | [
"MIT"
] | 12 | 2020-06-18T06:12:57.000Z | 2022-01-24T08:53:44.000Z | /*
_____ _ _____ ______ ______
|_ _|(_) / ___|| _ \| ___ \
| | _ _ __ _ _ \ `--. | | | || |_/ /
| | | || '_ \ | | | | `--. \| | | || /
| | | || | | || |_| |/\__/ /| |/ / | |\ \
\_/ |_||_| |_| \__, |\____/ |___/ \_| \_|
__/ |
|___/
Description: Implements the generic gpio driver
License: see LICENSE.TXT file include in the project
Maintainer: Mehrdad Hessar, Ali Najafi
*/
#ifndef _SYSTEM_GPIO_H_
#define _SYSTEM_GPIO_H_
#include <msp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <stddef.h>
#include <driverlib.h>
/**########################Variables and Types############################**/
#define P1_0 &P1OUT , &P1IN , &P1DIR , BIT0
#define P1_1 &P1OUT , &P1IN , &P1DIR , BIT1
#define P1_2 &P1OUT , &P1IN , &P1DIR , BIT2
#define P1_3 &P1OUT , &P1IN , &P1DIR , BIT3
#define P1_4 &P1OUT , &P1IN , &P1DIR , BIT4
#define P1_5 &P1OUT , &P1IN , &P1DIR , BIT5
#define P1_6 &P1OUT , &P1IN , &P1DIR , BIT6
#define P1_7 &P1OUT , &P1IN , &P1DIR , BIT7
#define P2_0 &P2OUT , &P2IN , &P2DIR , BIT0
#define P2_1 &P2OUT , &P2IN , &P2DIR , BIT1
#define P2_2 &P2OUT , &P2IN , &P2DIR , BIT2
#define P2_3 &P2OUT , &P2IN , &P2DIR , BIT3
#define P2_4 &P2OUT , &P2IN , &P2DIR , BIT4
#define P2_5 &P2OUT , &P2IN , &P2DIR , BIT5
#define P2_6 &P2OUT , &P2IN , &P2DIR , BIT6
#define P2_7 &P2OUT , &P2IN , &P2DIR , BIT7
#define P3_0 &P3OUT , &P3IN , &P3DIR , BIT0
#define P3_1 &P3OUT , &P3IN , &P3DIR , BIT1
#define P3_2 &P3OUT , &P3IN , &P3DIR , BIT2
#define P3_3 &P3OUT , &P3IN , &P3DIR , BIT3
#define P3_4 &P3OUT , &P3IN , &P3DIR , BIT4
#define P3_5 &P3OUT , &P3IN , &P3DIR , BIT5
#define P3_6 &P3OUT , &P3IN , &P3DIR , BIT6
#define P3_7 &P3OUT , &P3IN , &P3DIR , BIT7
#define P4_0 &P4OUT , &P4IN , &P4DIR , BIT0
#define P4_1 &P4OUT , &P4IN , &P4DIR , BIT1
#define P4_2 &P4OUT , &P4IN , &P4DIR , BIT2
#define P4_3 &P4OUT , &P4IN , &P4DIR , BIT3
#define P4_4 &P4OUT , &P4IN , &P4DIR , BIT4
#define P4_5 &P4OUT , &P4IN , &P4DIR , BIT5
#define P4_6 &P4OUT , &P4IN , &P4DIR , BIT6
#define P4_7 &P4OUT , &P4IN , &P4DIR , BIT7
#define P5_0 &P5OUT , &P5IN , &P5DIR , BIT0
#define P5_1 &P5OUT , &P5IN , &P5DIR , BIT1
#define P5_2 &P5OUT , &P5IN , &P5DIR , BIT2
#define P5_3 &P5OUT , &P5IN , &P5DIR , BIT3
#define P5_4 &P5OUT , &P5IN , &P5DIR , BIT4
#define P5_5 &P5OUT , &P5IN , &P5DIR , BIT5
#define P5_6 &P5OUT , &P5IN , &P5DIR , BIT6
#define P5_7 &P5OUT , &P5IN , &P5DIR , BIT7
#define P6_0 &P6OUT , &P6IN , &P6DIR , BIT0
#define P6_1 &P6OUT , &P6IN , &P6DIR , BIT1
#define P6_2 &P6OUT , &P6IN , &P6DIR , BIT2
#define P6_3 &P6OUT , &P6IN , &P6DIR , BIT3
#define P6_4 &P6OUT , &P6IN , &P6DIR , BIT4
#define P6_5 &P6OUT , &P6IN , &P6DIR , BIT5
#define P6_6 &P6OUT , &P6IN , &P6DIR , BIT6
#define P6_7 &P6OUT , &P6IN , &P6DIR , BIT7
#define P7_0 &P7OUT , &P7IN , &P7DIR , BIT0
#define P7_1 &P7OUT , &P7IN , &P7DIR , BIT1
#define P7_2 &P7OUT , &P7IN , &P7DIR , BIT2
#define P7_3 &P7OUT , &P7IN , &P7DIR , BIT3
#define P7_4 &P7OUT , &P7IN , &P7DIR , BIT4
#define P7_5 &P7OUT , &P7IN , &P7DIR , BIT5
#define P7_6 &P7OUT , &P7IN , &P7DIR , BIT6
#define P7_7 &P7OUT , &P7IN , &P7DIR , BIT7
#define P8_0 &P8OUT , &P8IN , &P8DIR , BIT0
#define P8_1 &P8OUT , &P8IN , &P8DIR , BIT1
#define P8_2 &P8OUT , &P8IN , &P8DIR , BIT2
#define P8_3 &P8OUT , &P8IN , &P8DIR , BIT3
#define P8_4 &P8OUT , &P8IN , &P8DIR , BIT4
#define P8_5 &P8OUT , &P8IN , &P8DIR , BIT5
#define P8_6 &P8OUT , &P8IN , &P8DIR , BIT6
#define P8_7 &P8OUT , &P8IN , &P8DIR , BIT7
#define PJIN_L (HWREG8(0x40004D20)) /*!< Port J Input */
#define PJOUT_L (HWREG8(0x40004D22)) /*!< Port J Output */
#define PJDIR_L (HWREG8(0x40004D24)) /*!< Port J Direction */
#define PJ_0 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT0
#define PJ_1 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT1
#define PJ_2 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT2
#define PJ_3 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT3
#define PJ_4 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT4
#define PJ_5 &PJOUT_L , &PJIN_L , &PJDIR_L , BIT5
/* Operation Mode for the GPIO */
typedef enum {
PIN_INPUT = 0,
PIN_OUTPUT,
PIN_ALTERNATE_FCT,
PIN_ANALOGIC
} PinModes;
/* Add a pull-up, a pull-down or nothing on the GPIO line */
typedef enum {
PIN_NO_PULL = 0,
PIN_PULL_UP,
PIN_PULL_DOWN
} PinTypes;
/* Define the GPIO IRQ on a rising, falling or both edges */
typedef enum {
NO_IRQ = 0,
IRQ_RISING_EDGE,
IRQ_FALLING_EDGE,
IRQ_RISING_FALLING_EDGE
} IrqModes;
/* Define the IRQ priority on the GPIO */
typedef enum {
IRQ_VERY_LOW_PRIORITY = 0,
IRQ_LOW_PRIORITY,
IRQ_MEDIUM_PRIORITY,
IRQ_HIGH_PRIORITY,
IRQ_VERY_HIGH_PRIORITY
} IrqPriorities;
/* Structure for the GPIO */
typedef struct {
volatile uint8_t* out;
volatile uint8_t* in;
uint8_t pin;
uint8_t portNumber;
} Gpio_t;
/* GPIO IRQ handler function prototype */
typedef void( GpioIrqHandler )( void );
/**########################External Functions############################**/
void GpioInit(Gpio_t* g, volatile uint8_t* portOut, volatile uint8_t* portIn,
volatile uint8_t* portDir, uint8_t pin, uint8_t portNumber, PinModes mode, bool value);
void GpioSetInterrupt(Gpio_t* g, IrqModes irqMode, GpioIrqHandler* irqHandler);
void GpioRemoveInterrupt(Gpio_t* g);
void GpioWrite(Gpio_t* g, bool value);
void GpioToggle(Gpio_t* g);
bool GpioRead(Gpio_t* g);
#endif
| 33.182927 | 89 | 0.620728 |
87aff03c93fb918cd9386a8c9b536034b36cc7fc | 1,227 | c | C | src/codegen/lib/UpdateThetaBetaAprx_LargeData/xrot.c | Emory-CBIS/HINT | b3e5113671aa447ec60e102229480db2e9ec5cf2 | [
"MIT"
] | 5 | 2019-11-20T13:31:26.000Z | 2021-05-17T20:00:50.000Z | src/codegen/lib/UpdateThetaBetaAprx_LargeData/xrot.c | Emory-CBIS/HINT | b3e5113671aa447ec60e102229480db2e9ec5cf2 | [
"MIT"
] | 17 | 2018-11-15T20:34:20.000Z | 2022-03-25T16:29:38.000Z | src/codegen/lib/UpdateThetaBetaAprx_LargeData/xrot.c | Emory-CBIS/HINT | b3e5113671aa447ec60e102229480db2e9ec5cf2 | [
"MIT"
] | 2 | 2018-11-15T20:45:15.000Z | 2020-01-03T03:24:33.000Z | /*
* Academic License - for use in teaching, academic research, and meeting
* course requirements at degree granting institutions only. Not for
* government, commercial, or other organizational use.
*
* xrot.c
*
* Code generation for function 'xrot'
*
*/
/* Include files */
#include "rt_nonfinite.h"
#include "UpdateThetaBetaAprx_LargeData.h"
#include "xrot.h"
/* Function Definitions */
void b_xrot(int n, emxArray_real_T *x, int ix0, int iy0, double c, double s)
{
int ix;
int iy;
int k;
double temp;
if (!(n < 1)) {
ix = ix0 - 1;
iy = iy0 - 1;
for (k = 1; k <= n; k++) {
temp = c * x->data[ix] + s * x->data[iy];
x->data[iy] = c * x->data[iy] - s * x->data[ix];
x->data[ix] = temp;
iy++;
ix++;
}
}
}
void xrot(int n, emxArray_real_T *x, int ix0, int incx, int iy0, int incy,
double c, double s)
{
int ix;
int iy;
int k;
double temp;
if (!(n < 1)) {
ix = ix0 - 1;
iy = iy0 - 1;
for (k = 1; k <= n; k++) {
temp = c * x->data[ix] + s * x->data[iy];
x->data[iy] = c * x->data[iy] - s * x->data[ix];
x->data[ix] = temp;
iy += incx;
ix += incy;
}
}
}
/* End of code generation (xrot.c) */
| 21.155172 | 76 | 0.537082 |
4033ac6fcb9bf29999a1c059eedaf8b8f8eb19d6 | 728 | h | C | source/App/EnmPgEtCutoffPage.h | Borrk/Enzyme-labeled-instrument | a7c8f4459511c774f7e0c4fee1fe05baf1ae2a5f | [
"MIT"
] | null | null | null | source/App/EnmPgEtCutoffPage.h | Borrk/Enzyme-labeled-instrument | a7c8f4459511c774f7e0c4fee1fe05baf1ae2a5f | [
"MIT"
] | null | null | null | source/App/EnmPgEtCutoffPage.h | Borrk/Enzyme-labeled-instrument | a7c8f4459511c774f7e0c4fee1fe05baf1ae2a5f | [
"MIT"
] | null | null | null | // EnmPgEtCutoffPage.h: interface for the CEnmPgEtCutoffPage class.
//
//////////////////////////////////////////////////////////////////////
#ifndef __EnmPgEtCutoffPage_H
#define __EnmPgEtCutoffPage_H
#include "EnmBasePage.hpp"
class CEnmPgEtCutoffPage : public CEnmBasePage
{
typedef CEnmBasePage inherited;
public:
CEnmPgEtCutoffPage();
BOOLEAN OnForward();
BOOLEAN OnExit();
protected:
void CreateControl();
void FocusOn();
void OnKeyOK();
protected:
void SyncProtocol2UI();
void SelectFormat( INT8U type, BOOLEAN bSel );
protected:
MigEditBox *mpCutoff;
MigEditBox *mpGrayP;
MigEditBox *mpGrayN;
MigRadioBox *mpFormat1, *mpFormat2, *mpFormat3;
};
#endif ///< __EnmPgEtCutoffPage_H
| 19.157895 | 70 | 0.673077 |
7b40db911c6c2e3a98a5fdf95d52fc393b0181bb | 52 | h | C | I2C_LCD1602/delay.h | wang19930902/stm32f103c8t6_example | 76b1c6e02c2aef779cac9ebf708889c2f8d5708d | [
"MIT"
] | null | null | null | I2C_LCD1602/delay.h | wang19930902/stm32f103c8t6_example | 76b1c6e02c2aef779cac9ebf708889c2f8d5708d | [
"MIT"
] | null | null | null | I2C_LCD1602/delay.h | wang19930902/stm32f103c8t6_example | 76b1c6e02c2aef779cac9ebf708889c2f8d5708d | [
"MIT"
] | null | null | null | void Delay(uint32_t ms);
void DelayMC(uint32_t mc);
| 17.333333 | 26 | 0.769231 |
f41ffe47bbeffc8747fe50931aac1d71e9dec26c | 175 | c | C | genlib/delput.c | jwmatthys/RTcmix | c9ba0c5bee2cd5e091c81333cf819d267008635b | [
"Apache-2.0"
] | 40 | 2015-01-14T20:52:42.000Z | 2022-03-09T00:50:45.000Z | genlib/delput.c | jwmatthys/RTcmix | c9ba0c5bee2cd5e091c81333cf819d267008635b | [
"Apache-2.0"
] | 20 | 2015-01-26T19:02:59.000Z | 2022-01-30T18:00:39.000Z | genlib/delput.c | jwmatthys/RTcmix | c9ba0c5bee2cd5e091c81333cf819d267008635b | [
"Apache-2.0"
] | 14 | 2015-01-14T20:52:43.000Z | 2021-09-24T02:24:32.000Z | /* put value in delay line. See delset. x is float */
void
delput(float x, float *a, int *l)
{
int index = l[0];
a[index] = x;
l[0]++;
if (l[0] >= l[2])
l[0] -= l[2];
}
| 15.909091 | 53 | 0.52 |
3c719c72a3c777c425b0d40fc2c5b563e875c53b | 200 | h | C | Source/FSDEngine/Public/EFNRotationType3D.h | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | Source/FSDEngine/Public/EFNRotationType3D.h | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | Source/FSDEngine/Public/EFNRotationType3D.h | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | #pragma once
#include "CoreMinimal.h"
#include "EFNRotationType3D.generated.h"
UENUM(BlueprintType)
enum class EFNRotationType3D : uint8 {
NONE,
IMPROVE_XY_PLANES,
IMPROVE_XZ_PLANES,
};
| 16.666667 | 40 | 0.75 |
bc7c2096ca5a25a8dc89819b011fde6fb59fd60a | 7,356 | h | C | lib/djvSystem/FileInfo.h | belzecue/DJV | 94fb63a2f56cc0c41ab5d518ef9f2e0590c295c0 | [
"BSD-3-Clause"
] | 456 | 2018-10-06T00:07:14.000Z | 2022-03-31T06:14:22.000Z | lib/djvSystem/FileInfo.h | belzecue/DJV | 94fb63a2f56cc0c41ab5d518ef9f2e0590c295c0 | [
"BSD-3-Clause"
] | 438 | 2018-10-31T15:05:51.000Z | 2022-03-31T09:01:24.000Z | lib/djvSystem/FileInfo.h | belzecue/DJV | 94fb63a2f56cc0c41ab5d518ef9f2e0590c295c0 | [
"BSD-3-Clause"
] | 54 | 2018-10-29T10:18:36.000Z | 2022-03-23T06:56:11.000Z | // SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2004-2020 Darby Johnston
// All rights reserved.
#pragma once
#include <djvSystem/Path.h>
#include <djvMath/FrameNumber.h>
#include <djvCore/Enum.h>
#include <djvCore/RapidJSON.h>
#include <set>
#include <sstream>
#include <sys/types.h>
#if defined(DJV_PLATFORM_WINDOWS)
typedef int uid_t;
#endif // DJV_PLATFORM_WINDOWS
namespace djv
{
namespace System
{
namespace File
{
//! File types.
enum class Type
{
File, //!< Regular file
Sequence, //!< File sequence
Directory, //!< Directory
Count,
First = File
};
DJV_ENUM_HELPERS(Type);
//! File permissions.
enum class Permissions
{
Read = 1, //!< Readable
Write = 2, //!< Writable
Exec = 4, //!< Executable
};
//! Directory listing sort options.
enum class DirectoryListSort
{
Name,
Size,
Time,
Count,
First = Name
};
DJV_ENUM_HELPERS(DirectoryListSort);
//! Directory listing options.
struct DirectoryListOptions
{
std::set<std::string> extensions;
bool sequences = false;
std::set<std::string> sequenceExtensions;
bool showHidden = false;
DirectoryListSort sort = DirectoryListSort::Name;
bool reverseSort = false;
bool sortDirectoriesFirst = true;
std::string filter;
bool operator == (const DirectoryListOptions&) const;
};
//! File and file sequence information.
//!
//! A file sequence is a list of file names that share a common name and
//! have frame numbers. File sequences are used to store animation or movie
//! footage where each frame is an individual file.
//!
//! A file sequence is expressed as a file name with a start and end frame
//! separated with a dash ('-'), for example "render.1-100.exr". Multiple
//! start and end frames and individual frames are separated with a comma
//! (','), for example "render.1-10,20-30,33,35,37.exr". File sequences
//! are always sorted in ascending order.
//!
//! File sequences may also have frames with padded zeroes, for example
//! "render.0001-0100.exr".
//!
//! Note the file sequences return information for the entire sequence.
class Info
{
public:
Info();
Info(const Path&, bool stat = true);
Info(const std::string&, bool stat = true);
Info(const Path&, Type, const Math::Frame::Sequence&, bool stat = true);
//! \name Path
///@{
const Path& getPath() const noexcept;
bool isEmpty() const noexcept;
void setPath(const Path& path, bool stat = true);
void setPath(const Path& path, Type, const Math::Frame::Sequence&, bool stat = true);
//! Get the file name.
//! \param frame Specify a frame number or Math::Frame::invalid for the entire sequence.
//! \param path Include the path in the file name.
std::string getFileName(Math::Frame::Number = Math::Frame::invalid, bool path = true) const;
//! Get whether this file exists.
bool doesExist() const noexcept;
///@}
//! \name Information
///@{
Type getType() const noexcept;
uint64_t getSize() const noexcept;
uid_t getUser() const noexcept;
int getPermissions() const noexcept;
time_t getTime() const noexcept;
//! Get information from the file system.
bool stat(std::string* error = nullptr);
///@}
//! \name Sequences
///@{
const Math::Frame::Sequence& getSequence() const noexcept;
bool isCompatible(const Info&) const;
void setSequence(const Math::Frame::Sequence&);
bool addToSequence(const Info&);
///@}
bool operator == (const Info&) const;
bool operator != (const Info&) const;
bool operator < (const Info&) const;
explicit operator std::string() const;
private:
static Math::Frame::Sequence _parseSequence(const std::string&);
Path _path;
bool _exists = false;
Type _type = Type::File;
uint64_t _size = 0;
uid_t _user = 0;
int _permissions = 0;
time_t _time = 0;
Math::Frame::Sequence _sequence;
};
//! \name Utility
///@{
//! Get the contents of the given directory.
std::vector<Info> directoryList(const Path& path, const DirectoryListOptions& options = DirectoryListOptions());
///@}
//! \name Sequences
///@{
//! Test whether the string contains all '#' characters.
bool isSequenceWildcard(const std::string&) noexcept;
//! Get the file sequence for the given file.
Info getSequence(const Path&, const std::set<std::string>& extensions);
///@}
//! \name Conversion
///@{
//! Get file permissions labels.
std::string getPermissionsLabel(int);
///@}
} // namespace File
} // namespace System
DJV_ENUM_SERIALIZE_HELPERS(System::File::Type);
DJV_ENUM_SERIALIZE_HELPERS(System::File::DirectoryListSort);
rapidjson::Value toJSON(System::File::Type, rapidjson::Document::AllocatorType&);
rapidjson::Value toJSON(System::File::DirectoryListSort, rapidjson::Document::AllocatorType&);
rapidjson::Value toJSON(const System::File::Info&, rapidjson::Document::AllocatorType&);
//! Throws:
//! - std::exception
void fromJSON(const rapidjson::Value&, System::File::Type&);
//! Throws:
//! - std::exception
void fromJSON(const rapidjson::Value&, System::File::DirectoryListSort&);
//! Throws:
//! - std::exception
void fromJSON(const rapidjson::Value&, System::File::Info&);
std::ostream& operator << (std::ostream&, const System::File::Info&);
} // namespace djv
#include <djvSystem/FileInfoInline.h>
| 33.898618 | 124 | 0.49565 |
29688e1d1d45db86e0672d5795687208902cd4ba | 547 | h | C | engine/src/common/pixelboost/db/entity.h | pixelballoon/pixelboost | 085873310050ce62493df61142b7d4393795bdc2 | [
"MIT"
] | 6 | 2015-04-21T11:30:52.000Z | 2020-04-29T00:10:04.000Z | engine/src/common/pixelboost/db/entity.h | pixelballoon/pixelboost | 085873310050ce62493df61142b7d4393795bdc2 | [
"MIT"
] | null | null | null | engine/src/common/pixelboost/db/entity.h | pixelballoon/pixelboost | 085873310050ce62493df61142b7d4393795bdc2 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include "glm/glm.hpp"
#include "pixelboost/db/struct.h"
namespace pb
{
class DbEntity : public DbStruct
{
public:
DbEntity(Uid uid, Uid type, DbStructData* data);
virtual ~DbEntity();
void Load();
const glm::vec3& GetPosition() const;
const glm::vec3& GetRotation() const;
const glm::vec3& GetScale() const;
private:
glm::vec3 _Position;
glm::vec3 _Rotation;
glm::vec3 _Scale;
};
}
| 17.645161 | 56 | 0.552102 |
5d4cf7eb8272c1823cdb6f75d4af97991f6d4036 | 1,307 | h | C | PyCommon/modules/Renderer/csVpRenderer.h | snumrl/DataDrivenBipedController | 68ecaa17790ebf3039ae8c0b91d21fab4829bb8c | [
"Apache-2.0",
"MIT"
] | 7 | 2018-08-17T10:25:56.000Z | 2021-09-01T11:28:56.000Z | PyCommon/modules/Renderer/csVpRenderer.h | snumrl/DataDrivenBipedController | 68ecaa17790ebf3039ae8c0b91d21fab4829bb8c | [
"Apache-2.0",
"MIT"
] | null | null | null | PyCommon/modules/Renderer/csVpRenderer.h | snumrl/DataDrivenBipedController | 68ecaa17790ebf3039ae8c0b91d21fab4829bb8c | [
"Apache-2.0",
"MIT"
] | 5 | 2017-01-05T09:22:58.000Z | 2021-07-26T15:13:19.000Z | // +-------------------------------------------------------------------------
// | csVpRenderer.h
// |
// | Author: Yoonsang Lee
// +-------------------------------------------------------------------------
// | COPYRIGHT:
// | Copyright Yoonsang Lee 2013
// | See the included COPYRIGHT.txt file for further details.
// |
// | This file is part of the DataDrivenBipedController.
// | DataDrivenBipedController is free software: you can redistribute it and/or modify
// | it under the terms of the MIT License.
// |
// | You should have received a copy of the MIT License
// | along with DataDrivenBipedController. If not, see <mit-license.org>.
// +-------------------------------------------------------------------------
#pragma once
#include <windows.h>
#include <gl/gl.h>
const int POLYGON_LINE = 0;
const int POLYGON_FILL = 1;
const int RENDER_OBJECT = 0;
const int RENDER_SHADOW = 1;
const int RENDER_REFLECTION = 2;
class VpModel;
class VpModelRenderer
{
private:
VpModel* _pModel;
GLubyte _color[3];
int _polygonStyle;
double _lineWidth;
public: // expose to python
VpModelRenderer(VpModel* pModel, const tuple& color, int polygonStyle=POLYGON_FILL, double lineWidth=1.);
void render(int renderType=RENDER_OBJECT);
}; | 30.395349 | 107 | 0.566182 |
b671fcd8b7585ec90ab5c80e1d09ddb4948a7f9e | 8,915 | c | C | i2c.c | jreyesr/yarrrduino | a1d5fc52992344ae5861e6eb8007d1abc2c87a94 | [
"CC0-1.0"
] | null | null | null | i2c.c | jreyesr/yarrrduino | a1d5fc52992344ae5861e6eb8007d1abc2c87a94 | [
"CC0-1.0"
] | null | null | null | i2c.c | jreyesr/yarrrduino | a1d5fc52992344ae5861e6eb8007d1abc2c87a94 | [
"CC0-1.0"
] | null | null | null | #include "i2c.h"
#ifdef BP_ENABLE_I2C_SUPPORT
#include "aux_pin.h"
#include "base.h"
#include "bitbang.h"
#include "core.h"
#include "proc_menu.h"
/**
Use a software I2C communication implementation
*/
#define I2C_TYPE_SOFTWARE 0
/**
Use the built-in hardware I2C communication implementation
*/
#define I2C_TYPE_HARDWARE 1
/**
I2C ACK bit value.
*/
#define I2C_ACK_BIT 0
/**
I2C NACK bit value.
*/
#define I2C_NACK_BIT 1
#define I2C_SNIFFER_ESCAPE '\\'
#define I2C_SNIFFER_NACK '-'
#define I2C_SNIFFER_ACK '+'
#define I2C_SNIFFER_START '['
#define I2C_SNIFFER_STOP ']'
typedef struct {
/**
Flag indicating whether a software-only I2C implementation should be
used instead of the built-in hardware I2C interface.
@see I2C_TYPE_SOFTWARE
@see I2C_TYPE_HARDWARE
*/
uint8_t mode : 1;
/**
Flag indicating whether there is either an ACK/NACK to be received.
*/
uint8_t acknowledgment_pending : 1;
} i2c_state_t;
/**
Current I2C module state.
*/
static i2c_state_t i2c_state = {0};
#define SCL BP_CLK
#define SCL_TRIS BP_CLK_DIR
#define SDA BP_MOSI
#define SDA_TRIS BP_MOSI_DIR
extern bus_pirate_configuration_t bus_pirate_configuration;
extern mode_configuration_t mode_configuration;
extern command_t last_command;
/**
Handles a pending acknowledgement by sending either an ACK or a NACK on the
bus.
@param[in] bus_bit false for sending an ACK, true for sending a NACK.
@see I2C_ACK_BIT
@see I2C_NACK_BIT
*/
static void handle_pending_ack(const bool bus_bit);
/**
Performs the bulk of the write-then-read I2C binary IO command.
@return true if the operation was successful, false otherwise.
*/
static bool i2c_write_then_read(void);
uint16_t i2c_read(void) {
uint8_t value;
if (i2c_state.acknowledgment_pending) {
handle_pending_ack(I2C_ACK_BIT);
bpSP;
MSG_ACK;
bpSP;
}
value = bitbang_read_value();
i2c_state.acknowledgment_pending = true;
return value;
}
unsigned int i2c_write(unsigned int c) {
if (i2c_state.acknowledgment_pending) {
bpSP;
MSG_ACK;
bpSP;
handle_pending_ack(I2C_ACK_BIT);
}
bitbang_write_value(c);
c = bitbang_read_bit();
bpSP;
if (c == 0) {
MSG_ACK;
return 0x300; // bit 9=ack
}
MSG_NACK;
return 0x100; // bit 9=ack
}
void i2c_start(void) {
/* Reset the bus state if an acknowledgement is pending. */
if (i2c_state.acknowledgment_pending) {
MSG_NACK;
bpBR;
handle_pending_ack(I2C_NACK_BIT);
}
/* Send a start signal on the bus. */
if (bitbang_i2c_start(BITBANG_I2C_START_ONE_SHOT)) {
/* There is a short or pull-ups are wrong. */
MSG_WARNING_HEADER;
MSG_WARNING_SHORT_OR_NO_PULLUP;
bpBR;
}
MSG_I2C_START_BIT;
}
void i2c_stop(void) {
if (i2c_state.acknowledgment_pending) {
MSG_NACK;
bpBR;
handle_pending_ack(I2C_NACK_BIT);
}
bitbang_i2c_stop();
MSG_I2C_STOP_BIT;
}
void i2c_print_settings(void) {
BPMSG1068;
bp_write_dec_byte(0);
bpSP;
bp_write_dec_byte(mode_configuration.speed);
bp_write_line(" )");
}
void i2c_setup_prepare(void) {
int speed;
i2c_state.mode = I2C_TYPE_SOFTWARE;
consumewhitechars();
speed = getint();
if ((speed > 0) && (speed <= 4)) {
mode_configuration.speed = speed - 1;
} else {
speed = 0;
}
if (speed == 0) {
mode_configuration.command_error = NO;
i2c_state.mode = I2C_TYPE_SOFTWARE;
MSG_SOFTWARE_MODE_SPEED_PROMPT;
mode_configuration.speed = (getnumber(1, 1, 4, 0) - 1);
} else {
i2c_print_settings();
i2c_state.acknowledgment_pending = false;
}
mode_configuration.high_impedance = ON;
}
void i2c_setup_execute(void) {
SDA_TRIS = INPUT;
SCL_TRIS = INPUT;
SCL = LOW;
SDA = LOW;
bitbang_setup(2, mode_configuration.speed);
}
void i2c_cleanup(void) {
/* Clear any pending ACK from previous use. */
i2c_state.acknowledgment_pending = false;
}
void i2c_macro(unsigned int c) {
int i;
switch (c) {
case 0:
BPMSG1069;
break;
case 1:
// setup both lines high first
bitbang_set_pins_high(MOSI | CLK, 0);
BPMSG1070;
if ((BP_CLK == LOW) || (BP_MOSI == LOW)) {
MSG_WARNING_HEADER;
MSG_WARNING_SHORT_OR_NO_PULLUP;
bpBR;
return;
}
for (i = 0; i < 0x100; i++) {
bitbang_i2c_start(BITBANG_I2C_START_ONE_SHOT); // send start
bitbang_write_value(i); // send address
c = bitbang_read_bit(); // look for ack
if (c == I2C_ACK_BIT) {
bp_write_formatted_integer(i);
user_serial_transmit_character('(');
bp_write_formatted_integer((i >> 1));
/* If the first bit is set, this is a read address. */
if ((i & 1) == 0) {
MSG_I2C_WRITE_ADDRESS_END;
} else {
if (i2c_state.mode == I2C_TYPE_SOFTWARE) {
bitbang_read_value();
bitbang_write_bit(HIGH);
} else {
}
MSG_I2C_READ_ADDRESS_END;
}
}
bitbang_i2c_stop();
}
bpBR;
break;
case 2:
i2c_cleanup();
MSG_SNIFFER_MESSAGE;
MSG_ANY_KEY_TO_EXIT_PROMPT;
MSG_UNKNOWN_MACRO_ERROR;
break;
default:
MSG_UNKNOWN_MACRO_ERROR;
break;
}
}
void i2c_pins_state(void) {
MSG_I2C_PINS_STATE;
}
void handle_pending_ack(const bool bus_bit) {
bitbang_write_bit(bus_bit);
i2c_state.acknowledgment_pending = false;
}
bool i2c_write_then_read(void) {
/* Read the amount of bytes to write. */
size_t bytes_to_write = user_serial_read_big_endian_word();
/* Read the amount of bytes to read. */
size_t bytes_to_read = user_serial_read_big_endian_word();
#ifndef BP_I2C_ENABLE_STREAMING_WRITE
/* Make sure data fits in the internal buffer. */
if (bytes_to_write > BP_TERMINAL_BUFFER_SIZE) {
return false;
}
#endif /* !BP_I2C_ENABLE_STREAMING_WRITE */
#ifndef BP_I2C_ENABLE_STREAMING_READ
/* Make sure data fits in the internal buffer. */
if (bytes_to_write > BP_TERMINAL_BUFFER_SIZE) {
return false;
}
#endif /* !BP_I2C_ENABLE_STREAMING_READ */
if ((bytes_to_write == 0) && (bytes_to_read == 0)) {
return false;
}
uint8_t i2c_address = 0;
#ifdef BP_I2C_ENABLE_STREAMING_WRITE
/* Read I2C address. */
i2c_address = user_serial_read_byte();
/* Start streaming. */
bitbang_i2c_start(BITBANG_I2C_START_ONE_SHOT);
/* Stream data from the serial port. */
bitbang_write_value(i2c_address);
for (size_t counter = 1; counter < bytes_to_write; counter++) {
bitbang_write_value(user_serial_read_byte());
if (bitbang_read_bit() == HIGH) {
/* No ACK read on the bus, bailing out. */
return false;
}
}
#else
/* Read payload. */
for (size_t index = 0; index < bytes_to_write; index++) {
bus_pirate_configuration.terminal_input[index] = user_serial_read_byte();
}
/* Get I2C address. */
i2c_address = bus_pirate_configuration.terminal_input[0];
/* Signal write start. */
bitbang_i2c_start(BITBANG_I2C_START_ONE_SHOT);
/* Write the payload to the I2C bus. */
for (size_t index = 0; index < bytes_to_write; index++) {
bitbang_write_value(bus_pirate_configuration.terminal_input[index]);
if (bitbang_read_bit() == HIGH) {
/* No ACK read on the bus, bailing out. */
return false;
}
}
#endif /* BP_I2C_ENABLE_STREAMING_WRITE */
if ((bytes_to_read > 0) && (bytes_to_write > 1)) {
/* Send a restart signal on the I2C bus. */
bitbang_i2c_start(BITBANG_I2C_RESTART);
/* Send the I2C address. */
bitbang_write_value(i2c_address | 0x01);
if (bitbang_read_bit() == HIGH) {
/* No ACK read on the bus, bailing out. */
return false;
}
}
/* Read the rest of the data. */
bytes_to_write = bytes_to_read - 1;
#ifdef BP_I2C_ENABLE_STREAMING_READ
/* Start streaming data. */
REPORT_IO_SUCCESS();
for (size_t counter = 0; counter < bytes_to_read; counter++) {
/* Read byte from the I2C bus. */
user_serial_transmit_character(bitbang_read_value());
/* Acknowledge read operation. */
bitbang_write_bit(counter >= bytes_to_write ? HIGH : LOW);
}
/* Stop the I2C bus. */
bitbang_i2c_stop();
#else
for (size_t index = 0; index < bytes_to_read; index++) {
/* Read the byte from the I2C bus. */
bus_pirate_configuration.terminal_input[index] = bitbang_read_value();
/* Report ACK or NACK depending on the length. */
bitbang_write_bit(index >= bytes_to_write ? HIGH : LOW);
}
/* Stop the I2C bus operations. */
bitbang_i2c_stop();
/* Report operation status. */
REPORT_IO_SUCCESS();
/* And send the I2C data over to the UART. */
bp_write_buffer(&bus_pirate_configuration.terminal_input[0], bytes_to_read);
#endif /* BP_I2C_ENABLE_STREAMING_READ */
return true;
}
#endif /* BP_ENABLE_I2C_SUPPORT */
| 22.012346 | 78 | 0.668761 |
5e5494223f42164e0bc8d406419a81957f32055e | 180 | h | C | SwiftLearn/SwiftDemo/SwiftDemo/Common.h | 1457792186/JWSwift | 1e2a0e1c43df4c7b168608f3da1df613eb7c9faa | [
"Apache-2.0"
] | null | null | null | SwiftLearn/SwiftDemo/SwiftDemo/Common.h | 1457792186/JWSwift | 1e2a0e1c43df4c7b168608f3da1df613eb7c9faa | [
"Apache-2.0"
] | null | null | null | SwiftLearn/SwiftDemo/SwiftDemo/Common.h | 1457792186/JWSwift | 1e2a0e1c43df4c7b168608f3da1df613eb7c9faa | [
"Apache-2.0"
] | null | null | null | //
// Common.h
// SwiftDemo
//
// Created by apple on 17/5/4.
// Copyright © 2017年 UgoMedia. All rights reserved.
//
#ifndef Common_h
#define Common_h
#endif /* Common_h */
| 12.857143 | 52 | 0.644444 |
16f41d4709747c8f2e9bbd6317d7df9cb4e1a0c8 | 396 | h | C | RubetekIOS-CPP.framework/Versions/A/Headers/imc/cl/ihap_constants.h | yklishevich/RubetekIOS-CPP-releases | 7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb | [
"MIT"
] | null | null | null | RubetekIOS-CPP.framework/Versions/A/Headers/imc/cl/ihap_constants.h | yklishevich/RubetekIOS-CPP-releases | 7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb | [
"MIT"
] | null | null | null | RubetekIOS-CPP.framework/Versions/A/Headers/imc/cl/ihap_constants.h | yklishevich/RubetekIOS-CPP-releases | 7dfbbb45b8de7dbb6fa995ff5dcbca4ec06c2bdb | [
"MIT"
] | null | null | null | /**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef ihap_CONSTANTS_H
#define ihap_CONSTANTS_H
#include "ihap_types.h"
namespace rubetek { namespace proto { namespace ihap {
class ihapConstants {
public:
ihapConstants();
};
extern const ihapConstants g_ihap_constants;
}}} // namespace
#endif
| 15.84 | 67 | 0.727273 |
229b5ba332f363f641c5e1259029adfcca040f02 | 327 | h | C | openkit/libproj/OpenKit/OKAchievementsListVC.h | hyukjae87/robovm-ios-bindings | 7c359f0a4644a9181920fbb8309f9057c35b8f42 | [
"Apache-2.0"
] | 7 | 2015-02-01T07:47:54.000Z | 2021-09-21T16:42:32.000Z | openkit/libproj/OpenKit/OKAchievementsListVC.h | hyukjae87/robovm-ios-bindings | 7c359f0a4644a9181920fbb8309f9057c35b8f42 | [
"Apache-2.0"
] | 3 | 2016-08-26T21:29:21.000Z | 2021-05-03T20:33:44.000Z | openkit/libproj/OpenKit/OKAchievementsListVC.h | hyukjae87/robovm-ios-bindings | 7c359f0a4644a9181920fbb8309f9057c35b8f42 | [
"Apache-2.0"
] | 1 | 2017-05-28T17:08:04.000Z | 2017-05-28T17:08:04.000Z | //
// OKAchievementsListVC.h
// OpenKit
//
// Created by Suneet Shah on 12/11/13.
// Copyright (c) 2013 OpenKit. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface OKAchievementsListVC : UIViewController<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *achievementsList;
@end
| 19.235294 | 94 | 0.746177 |
660b3c244ad5f489ef9bf3bc706ba33ed72c37b9 | 4,470 | h | C | src/thirdparty/boost_python_stdout.h | craftyjon/firelight | 3ea9fa16ece48fd68716b486b08b3fc9a2fa84a2 | [
"CC-BY-4.0"
] | 1 | 2018-01-05T14:40:20.000Z | 2018-01-05T14:40:20.000Z | src/thirdparty/boost_python_stdout.h | craftyjon/firelight | 3ea9fa16ece48fd68716b486b08b3fc9a2fa84a2 | [
"CC-BY-4.0"
] | null | null | null | src/thirdparty/boost_python_stdout.h | craftyjon/firelight | 3ea9fa16ece48fd68716b486b08b3fc9a2fa84a2 | [
"CC-BY-4.0"
] | null | null | null | // Adapted from emb.cpp
// Copyright (C) 2011 Mateusz Loskot <mateusz@loskot.net>
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
//
// Blog article: http://mateusz.loskot.net/?p=2819
#ifndef _BOOST_PYTHON_STDOUT_H
#define _BOOST_PYTHON_STDOUT_H
#include <string>
#include <boost/python.hpp>
namespace firelight {
namespace thirdparty {
namespace stdout_buffer {
// Internal state
PyObject *g_stdout;
PyObject *g_stderr;
PyObject *g_stdout_saved;
PyObject *g_stderr_saved;
std::string *g_buffer;
struct Stdout
{
PyObject_HEAD
void* write;
};
PyObject* Stdout_write(PyObject* self, PyObject* args)
{
Q_UNUSED(self);
Q_UNUSED(args);
std::size_t written(0);
if (g_buffer)
{
char* data;
if (!PyArg_ParseTuple(args, "s", &data))
return 0;
std::string str(data);
(*g_buffer) += str;
written = str.size();
}
return PyLong_FromSize_t(written);
}
PyObject* Stdout_flush(PyObject* self, PyObject* args)
{
Q_UNUSED(self);
Q_UNUSED(args);
// no-op
return Py_BuildValue("");
}
PyMethodDef Stdout_methods[] =
{
{"write", Stdout_write, METH_VARARGS, "sys.stdout.write"},
{"flush", Stdout_flush, METH_VARARGS, "sys.stdout.write"},
{0, 0, 0, 0} // sentinel
};
PyTypeObject StdoutType =
{
PyVarObject_HEAD_INIT(0, 0)
"stdout_buffer.StdoutType", /* tp_name */
sizeof(Stdout), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"stdout_buffer.Stdout objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Stdout_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
};
PyMODINIT_FUNC PyInit_stdout_buffer(void)
{
g_stdout = 0;
g_stdout_saved = 0;
g_stderr = 0;
g_stderr_saved = 0;
StdoutType.tp_new = PyType_GenericNew;
if (PyType_Ready(&StdoutType) < 0)
return;
PyObject* m = Py_InitModule("stdout_buffer", Stdout_methods);
if (m)
{
Py_INCREF(&StdoutType);
PyModule_AddObject(m, "Stdout", reinterpret_cast<PyObject*>(&StdoutType));
}
}
void set_stdout()
{
if (!g_stdout)
{
g_stdout_saved = PySys_GetObject("stdout"); // borrowed
g_stdout = StdoutType.tp_new(&StdoutType, 0, 0);
}
if (!g_stderr)
{
g_stdout_saved = PySys_GetObject("stderr"); // borrowed
g_stdout = StdoutType.tp_new(&StdoutType, 0, 0);
}
Stdout* impl = reinterpret_cast<Stdout*>(g_stdout);
PySys_SetObject("stdout", g_stdout);
PySys_SetObject("stderr", g_stdout);
}
void reset_stdout()
{
if (g_stdout_saved)
PySys_SetObject("stdout", g_stdout_saved);
if (g_stdout_saved)
PySys_SetObject("stderr", g_stderr_saved);
Py_XDECREF(g_stdout);
g_stdout = 0;
g_stderr = 0;
}
void initPythonStdout()
{
PyImport_AppendInittab("stdout_buffer", PyInit_stdout_buffer);
}
void enablePythonStdout(std::string *buffer)
{
PyImport_ImportModule("stdout_buffer");
g_buffer = buffer;
set_stdout();
}
void disablePythonStdout()
{
g_buffer = NULL;
}
}}} // namespaces
#endif
| 23.160622 | 82 | 0.527964 |
06bc44a09a22cb36299b72117697069aa99dffc6 | 855 | h | C | 3.15/src/libCom/osi/epicsSpin.h | A2-Collaboration/epics | b764a53bf449d9f6b54a1173c5e75a22cf95098c | [
"OML"
] | null | null | null | 3.15/src/libCom/osi/epicsSpin.h | A2-Collaboration/epics | b764a53bf449d9f6b54a1173c5e75a22cf95098c | [
"OML"
] | null | null | null | 3.15/src/libCom/osi/epicsSpin.h | A2-Collaboration/epics | b764a53bf449d9f6b54a1173c5e75a22cf95098c | [
"OML"
] | null | null | null | /*************************************************************************\
* Copyright (c) 2012 Helmholtz-Zentrum Berlin
* fuer Materialien und Energie GmbH.
* Copyright (c) 2012 ITER Organization.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#ifndef epicsSpinh
#define epicsSpinh
#include "shareLib.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct epicsSpin *epicsSpinId;
epicsShareFunc epicsSpinId epicsSpinCreate();
epicsShareFunc void epicsSpinDestroy(epicsSpinId);
epicsShareFunc void epicsSpinLock(epicsSpinId);
epicsShareFunc int epicsSpinTryLock(epicsSpinId);
epicsShareFunc void epicsSpinUnlock(epicsSpinId);
#ifdef __cplusplus
}
#endif
#endif /* epicsSpinh */
| 26.71875 | 75 | 0.65848 |
7905e07b9841e1a2747bf29a1b57433a24682e45 | 7,455 | h | C | NS3-master/src/lte/model/epc-sgw-application.h | legendPerceptor/blockchain | 615ba331ae5ec53c683dfe6a16992a5181be0fea | [
"Apache-2.0"
] | 1 | 2021-09-20T07:05:25.000Z | 2021-09-20T07:05:25.000Z | NS3-master/src/lte/model/epc-sgw-application.h | legendPerceptor/blockchain | 615ba331ae5ec53c683dfe6a16992a5181be0fea | [
"Apache-2.0"
] | null | null | null | NS3-master/src/lte/model/epc-sgw-application.h | legendPerceptor/blockchain | 615ba331ae5ec53c683dfe6a16992a5181be0fea | [
"Apache-2.0"
] | 2 | 2021-09-02T08:25:16.000Z | 2022-01-03T08:48:38.000Z | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2017-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Manuel Requena <manuel.requena@cttc.es>
*/
#ifndef EPC_SGW_APPLICATION_H
#define EPC_SGW_APPLICATION_H
#include "ns3/application.h"
#include "ns3/address.h"
#include "ns3/socket.h"
#include "ns3/epc-gtpc-header.h"
namespace ns3 {
/**
* \ingroup lte
*
* This application implements the Serving Gateway Entity (SGW)
* according to the 3GPP TS 23.401 document.
*
* This Application implements the SGW side of the S5 interface between
* the SGW node and the PGW node and the SGW side of the S11 interface between
* the SGW node and the MME node hosts. It supports the following functions and messages:
*
* - S5 connectivity (i.e. GTPv2-C signalling and GTP-U data plane)
* - Bearer management functions including dedicated bearer establishment
* - UL and DL bearer binding
* - Tunnel Management messages
*
* Others functions enumerated in section 4.4.3.2 of 3GPP TS 23.401 are not supported.
*/
class EpcSgwApplication : public Application
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
virtual void DoDispose ();
/**
* Constructor that binds callback methods of sockets.
*
* \param s1uSocket socket used to send/receive GTP-U packets to/from the eNBs
* \param s5Addr IPv4 address of the S5 interface
* \param s5uSocket socket used to send/receive GTP-U packets to/from the PGW
* \param s5cSocket socket used to send/receive GTP-C packets to/from the PGW
*/
EpcSgwApplication (const Ptr<Socket> s1uSocket, Ipv4Address s5Addr,
const Ptr<Socket> s5uSocket, const Ptr<Socket> s5cSocket);
/** Destructor */
virtual ~EpcSgwApplication (void);
/**
* Let the SGW be aware of an MME
*
* \param mmeS11Addr the address of the MME
* \param s11Socket the socket to send/receive messages from the MME
*/
void AddMme (Ipv4Address mmeS11Addr, Ptr<Socket> s11Socket);
/**
* Let the SGW be aware of a PGW
*
* \param pgwAddr the address of the PGW
*/
void AddPgw (Ipv4Address pgwAddr);
/**
* Let the SGW be aware of a new eNB
*
* \param cellId the cell identifier
* \param enbAddr the address of the eNB
* \param sgwAddr the address of the SGW
*/
void AddEnb (uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
private:
/**
* Method to be assigned to the recv callback of the S11 socket.
* It is called when the SGW receives a control packet from the MME.
*
* \param socket pointer to the S11 socket
*/
void RecvFromS11Socket (Ptr<Socket> socket);
/**
* Method to be assigned to the recv callback of the S5-U socket.
* It is called when the SGW receives a data packet from the PGW
* that is to be forwarded to an eNB.
*
* \param socket pointer to the S5-U socket
*/
void RecvFromS5uSocket (Ptr<Socket> socket);
/**
* Method to be assigned to the recv callback of the S5-C socket.
* It is called when the SGW receives a control packet from the PGW.
*
* \param socket pointer to the S5-C socket
*/
void RecvFromS5cSocket (Ptr<Socket> socket);
/**
* Method to be assigned to the recv callback of the S1-U socket.
* It is called when the SGW receives a data packet from the eNB
* that is to be forwarded to the PGW.
*
* \param socket pointer to the S1-U socket
*/
void RecvFromS1uSocket (Ptr<Socket> socket);
/**
* Send a data packet to the PGW via the S5 interface
*
* \param packet packet to be sent
* \param pgwAddr the address of the PGW
* \param teid the Tunnel Enpoint Identifier
*/
void SendToS5uSocket (Ptr<Packet> packet, Ipv4Address pgwAddr, uint32_t teid);
/**
* Send a data packet to an eNB via the S1-U interface
*
* \param packet packet to be sent
* \param enbS1uAddress the address of the eNB
* \param teid the Tunnel Enpoint IDentifier
*/
void SendToS1uSocket (Ptr<Packet> packet, Ipv4Address enbS1uAddress, uint32_t teid);
// Process messages received from the MME
/**
* Process GTP-C Create Session Request message
* \param packet the packet containing the message
*/
void DoRecvCreateSessionRequest (Ptr<Packet> packet);
/**
* Process GTP-C Modify Bearer Request message
* \param packet the packet containing the message
*/
void DoRecvModifyBearerRequest (Ptr<Packet> packet);
/**
* Process GTP-C Delete Bearer Command message
* \param packet the packet containing the message
*/
void DoRecvDeleteBearerCommand (Ptr<Packet> packet);
/**
* Process GTP-C Delete Bearer Response message
* \param packet the packet containing the message
*/
void DoRecvDeleteBearerResponse (Ptr<Packet> packet);
// Process messages received from the PGW
/**
* Process GTP-C Create Session Response message
* \param packet the packet containing the message
*/
void DoRecvCreateSessionResponse (Ptr<Packet> packet);
/**
* Process GTP-C Modify Bearer Response message
* \param packet the packet containing the message
*/
void DoRecvModifyBearerResponse (Ptr<Packet> packet);
/**
* Process GTP-C Delete Bearer Request message
* \param packet the packet containing the message
*/
void DoRecvDeleteBearerRequest (Ptr<Packet> packet);
/**
* SGW address in the S5 interface
*/
Ipv4Address m_s5Addr;
/**
* MME address in the S11 interface
*/
Ipv4Address m_mmeS11Addr;
/**
* UDP socket to send/receive control messages to/from the S11 interface
*/
Ptr<Socket> m_s11Socket;
/**
* PGW address in the S5 interface
*/
Ipv4Address m_pgwAddr;
/**
* UDP socket to send/receive GTP-U packets to/from the S5 interface
*/
Ptr<Socket> m_s5uSocket;
/**
* UDP socket to send/receive GTP-C packets to/from the S5 interface
*/
Ptr<Socket> m_s5cSocket;
/**
* UDP socket to send/receive GTP-U packets to/from the S1-U interface
*/
Ptr<Socket> m_s1uSocket;
/**
* UDP port to be used for GTP-U
*/
uint16_t m_gtpuUdpPort;
/**
* UDP port to be used for GTP-C
*/
uint16_t m_gtpcUdpPort;
/**
* TEID count
*/
uint32_t m_teidCount;
/// EnbInfo structure
struct EnbInfo
{
Ipv4Address enbAddr; ///< eNB address
Ipv4Address sgwAddr; ///< SGW address
};
/**
* Map for eNB info by cell ID
*/
std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
/**
* Map for eNB address by TEID
*/
std::map<uint32_t, Ipv4Address> m_enbByTeidMap;
/**
* MME S11 FTEID by SGW S5C TEID
*/
std::map<uint32_t, GtpcHeader::Fteid_t> m_mmeS11FteidBySgwS5cTeid;
};
} // namespace ns3
#endif // EPC_SGW_APPLICATION_H
| 26.816547 | 89 | 0.691214 |
0586556b4cc1bf3bfdc8184d4ec551cfa64118a2 | 552 | h | C | components/qtmaterialappbar_p.h | mtimaj/qt-material-widgets | cf10616230eb1e1f63f8608b4e49645688e0f315 | [
"BSD-3-Clause"
] | 1,558 | 2016-03-28T08:24:06.000Z | 2022-03-31T10:24:55.000Z | components/qtmaterialappbar_p.h | mtimaj/qt-material-widgets | cf10616230eb1e1f63f8608b4e49645688e0f315 | [
"BSD-3-Clause"
] | 39 | 2016-04-25T07:06:23.000Z | 2022-03-20T11:04:11.000Z | components/qtmaterialappbar_p.h | mtimaj/qt-material-widgets | cf10616230eb1e1f63f8608b4e49645688e0f315 | [
"BSD-3-Clause"
] | 426 | 2016-03-28T08:23:26.000Z | 2022-03-30T01:48:41.000Z | #ifndef QTMATERIALAPPBAR_P_H
#define QTMATERIALAPPBAR_P_H
#include <QtGlobal>
#include <QColor>
class QtMaterialAppBar;
class QtMaterialAppBarPrivate
{
Q_DISABLE_COPY(QtMaterialAppBarPrivate)
Q_DECLARE_PUBLIC(QtMaterialAppBar)
public:
QtMaterialAppBarPrivate(QtMaterialAppBar *q);
~QtMaterialAppBarPrivate();
void init();
QtMaterialAppBar *const q_ptr;
bool useThemeColors;
QColor foregroundColor;
QColor backgroundColor;
};
#endif // QTMATERIALAPPBAR_P_H
| 20.444444 | 49 | 0.699275 |
f95e60cb69cab1af370ac28e7c1ab292fd307e7f | 146 | h | C | Example/Pods/Target Support Files/AZBannerView/AZBannerView-umbrella.h | windless/AZBannerView | aae5b6aeeb668518bc4064ba067527960ed603cf | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/AZBannerView/AZBannerView-umbrella.h | windless/AZBannerView | aae5b6aeeb668518bc4064ba067527960ed603cf | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/AZBannerView/AZBannerView-umbrella.h | windless/AZBannerView | aae5b6aeeb668518bc4064ba067527960ed603cf | [
"MIT"
] | null | null | null | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double AZBannerViewVersionNumber;
FOUNDATION_EXPORT const unsigned char AZBannerViewVersionString[];
| 20.857143 | 66 | 0.849315 |
a7ad768504dd2bc46e20a20287bcd95e05d478a8 | 224 | h | C | src/oledfont.h | lukehiga/oled_gui | 4bc524b873ead2020ef0f3148971ac413ed358f1 | [
"MIT"
] | null | null | null | src/oledfont.h | lukehiga/oled_gui | 4bc524b873ead2020ef0f3148971ac413ed358f1 | [
"MIT"
] | null | null | null | src/oledfont.h | lukehiga/oled_gui | 4bc524b873ead2020ef0f3148971ac413ed358f1 | [
"MIT"
] | 1 | 2020-04-29T09:53:16.000Z | 2020-04-29T09:53:16.000Z | #ifndef _OLEDFONT_
#define _OLEDFONT_
#include <avr/pgmspace.h>
#define FONT_PIXEL_WIDTH 5
#define FONT_PIXEL_HEIGHT 8
#define ASCII_OFFSET 32
#define MAX_CHARS 94
extern const int8_t font_bytes[];
#endif | 14.933333 | 34 | 0.745536 |
d5d3a620e19843e270b1f63950612cb6ddd5ec27 | 782 | h | C | endpoints/mongodb/mongodb_endpoint.h | gdshaw/libholmes-horace | 6a7d8365f01e165853fc967ce8eae45b82102fdf | [
"BSD-3-Clause"
] | null | null | null | endpoints/mongodb/mongodb_endpoint.h | gdshaw/libholmes-horace | 6a7d8365f01e165853fc967ce8eae45b82102fdf | [
"BSD-3-Clause"
] | null | null | null | endpoints/mongodb/mongodb_endpoint.h | gdshaw/libholmes-horace | 6a7d8365f01e165853fc967ce8eae45b82102fdf | [
"BSD-3-Clause"
] | null | null | null | // This file is part of libholmes.
// Copyright 2019 Graham Shaw
// Redistribution and modification are permitted within the terms of the
// BSD-3-Clause licence as defined by v3.4 of the SPDX Licence List.
#ifndef LIBHOLMES_HORACE_MONGODB_ENDPOINT
#define LIBHOLMES_HORACE_MONGODB_ENDPOINT
#include "horace/endpoint.h"
#include "horace/session_writer_endpoint.h"
namespace horace {
/** An endpoint class to represent a MongoDB database. */
class mongodb_endpoint:
public endpoint,
public session_writer_endpoint {
public:
/** Construct MongoDB endpoint.
* @param name the name of this endpoint
*/
mongodb_endpoint(const std::string& name);
virtual std::unique_ptr<session_writer> make_session_writer(
const std::string& srcid);
};
} /* namespace horace */
#endif
| 25.225806 | 72 | 0.7711 |
41346474cde303c68b293e64dae6f258d7786199 | 2,684 | h | C | source/engine/components/component_physics.h | biomorphs/lean | b28dac32b3aea0f0cf65e396a265c7b99aeb1fb0 | [
"MIT"
] | 1 | 2021-06-15T04:38:49.000Z | 2021-06-15T04:38:49.000Z | source/engine/components/component_physics.h | biomorphs/lean | b28dac32b3aea0f0cf65e396a265c7b99aeb1fb0 | [
"MIT"
] | null | null | null | source/engine/components/component_physics.h | biomorphs/lean | b28dac32b3aea0f0cf65e396a265c7b99aeb1fb0 | [
"MIT"
] | null | null | null | #pragma once
#include "entity/component.h"
#include "core/glm_headers.h"
#include "engine/physics_handle.h"
namespace physx
{
class PxRigidActor;
}
namespace Engine
{
class DebugGuiSystem;
class DebugRender;
}
class Physics
{
public:
Physics();
~Physics();
Physics(Physics&&) = default;
Physics& operator=(Physics&&) = default;
Physics(const Physics&) = delete;
Physics& operator=(const Physics&) = delete;
COMPONENT(Physics);
COMPONENT_INSPECTOR(Engine::DebugGuiSystem& gui, Engine::DebugRender& render, class World& w);
void AddForce(glm::vec3 force);
bool IsStatic() { return m_isStatic; }
void SetStatic(bool s) { m_isStatic = s; }
bool IsKinematic() { return m_isKinematic; }
void SetKinematic(bool k) { m_isKinematic = k; }
float GetDensity() { return m_density; }
void SetDensity(float d) { m_density = d; }
float GetStaticFriction() { return m_staticFriction; }
void SetStaticFriction(float s) { m_staticFriction = s; }
float GetDynamicFriction() { return m_dynamicFriction; }
void SetDynamicFriction(float s) { m_dynamicFriction = s; }
float GetRestitution() { return m_restitution; }
void SetRestitution(float s) { m_restitution = s; }
using PlaneColliders = std::vector < std::tuple < glm::vec3, glm::vec3 >>; // normal, origin
void AddPlaneCollider(glm::vec3 normal, glm::vec3 origin) { m_planeColliders.push_back({normal,origin}); }
PlaneColliders& GetPlaneColliders() { return m_planeColliders; }
using SphereColliders = std::vector< std::tuple<glm::vec3, float> >; // offset, radius
void AddSphereCollider(glm::vec3 offset, float radius) { m_sphereColliders.push_back({offset, radius}); }
SphereColliders& GetSphereColliders() { return m_sphereColliders; }
using BoxColliders = std::vector< std::tuple<glm::vec3, glm::vec3> >; // offset, dimensions
void AddBoxCollider(glm::vec3 offset, glm::vec3 dim) { m_boxColliders.push_back({ offset, dim }); }
BoxColliders& GetBoxColliders() { return m_boxColliders; }
void Rebuild() { m_needsRebuild = true; }
bool NeedsRebuild() { return m_needsRebuild; }
void SetNeedsRebuild(bool b) { m_needsRebuild = b; }
Engine::PhysicsHandle<physx::PxRigidActor>& GetActor() { return m_actor; }
void SetActor(Engine::PhysicsHandle<physx::PxRigidActor>&& a) { m_actor = std::move(a); }
private:
bool m_needsRebuild = false;
bool m_isStatic = false;
bool m_isKinematic = false;
// Material parameters
float m_density = 1.0f;
float m_staticFriction = 0.5f;
float m_dynamicFriction = 0.5f;
float m_restitution = 0.6f;
PlaneColliders m_planeColliders;
SphereColliders m_sphereColliders;
BoxColliders m_boxColliders;
Engine::PhysicsHandle<physx::PxRigidActor> m_actor;
}; | 31.209302 | 107 | 0.736587 |
4171a365aa172f09c22f7d360c7fc83428fa7e20 | 6,038 | h | C | Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/inputmethodservice/CExtractEditLayout.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 7 | 2017-07-13T10:34:54.000Z | 2021-04-16T05:40:35.000Z | Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/inputmethodservice/CExtractEditLayout.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/inputmethodservice/CExtractEditLayout.h | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 9 | 2017-07-13T12:33:20.000Z | 2021-06-19T02:46:48.000Z | //=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// 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 __ELASTOS_DROID_INPUTMETHODSERVICE_ELASTOS_DROID_INPUTMEHTODSERVICE_CEXTRACTEDITLAYOUT_H__
#define __ELASTOS_DROID_INPUTMETHODSERVICE_ELASTOS_DROID_INPUTMEHTODSERVICE_CEXTRACTEDITLAYOUT_H__
#include "Elastos.Droid.Internal.h"
#include "_Elastos_Droid_InputMethodService_CExtractEditLayout.h"
#include "elastos/droid/widget/LinearLayout.h"
#include "elastos/droid/view/ActionMode.h"
#include <elastos/core/Object.h>
using Elastos::Droid::Content::IContext;
using Elastos::Droid::Widget::LinearLayout;
using Elastos::Droid::Widget::IButton;
using Elastos::Droid::View::IMenu;
using Elastos::Droid::View::ActionMode;
using Elastos::Droid::View::IMenuItem;
using Elastos::Droid::View::IMenuInflater;
using Elastos::Droid::View::IViewOnClickListener;
using Elastos::Droid::View::IView;
using Elastos::Droid::View::IActionMode;
using Elastos::Droid::View::IActionModeCallback;
using Elastos::Droid::View::Accessibility::IAccessibilityEvent;
using Elastos::Droid::Internal::View::Menu::IMenuBuilder;
using Elastos::Droid::Internal::View::Menu::IMenuBuilderCallback;
using Elastos::Droid::Utility::IAttributeSet;
namespace Elastos {
namespace Droid {
namespace InputMethodService {
/**
* CExtractEditLayout provides an ActionMode presentation for the
* limited screen real estate in extract mode.
*
* @hide
*/
CarClass(CExtractEditLayout)
, public LinearLayout
, public IExtractEditLayout
{
protected:
class ExtractActionMode
: public ActionMode
{
private:
class MenuBuilderCallback
: public Object
, public IMenuBuilderCallback
{
public:
CAR_INTERFACE_DECL()
MenuBuilderCallback(
/* [in] */ ExtractActionMode* host);
//@Override
CARAPI OnMenuItemSelected(
/* [in] */ IMenuBuilder* menu,
/* [in] */ IMenuItem* item,
/* [out] */ Boolean* result);
//@Override
CARAPI OnMenuModeChange(
/* [in] */ IMenuBuilder* menu);
private:
ExtractActionMode* mHost;
};
public:
ExtractActionMode(
/* [in] */ IActionModeCallback* cb,
/* [in] */ CExtractEditLayout* host);
//@Override
CARAPI SetTitle(
/* [in] */ ICharSequence* title);
//@Override
CARAPI SetTitle(
/* [in] */ Int32 resId);
//@Override
CARAPI SetSubtitle(
/* [in] */ ICharSequence* subtitle);
//@Override
CARAPI SetSubtitle(
/* [in] */ Int32 resId);
//@Override
CARAPI IsTitleOptional(
/* [out] */ Boolean* result);
//@Override
CARAPI SetCustomView(
/* [in] */ IView* view);
//@Override
CARAPI Invalidate();
CARAPI_(Boolean) DispatchOnCreate();
//@Override
CARAPI Finish();
//@Override
CARAPI GetMenu(
/* [out] */ IMenu** menu);
//@Override
CARAPI GetTitle(
/* [out] */ ICharSequence** title);
//@Override
CARAPI GetSubtitle(
/* [out] */ ICharSequence** subtitle);
//@Override
CARAPI GetCustomView(
/* [out] */ IView** view);
//@Override
CARAPI GetMenuInflater(
/* [out] */ IMenuInflater** inflater);
//@Override
CARAPI OnMenuItemSelected(
/* [in] */ IMenuBuilder* menu,
/* [in] */ IMenuItem* item,
/* [out] */ Boolean* result);
//@Override
CARAPI OnMenuModeChange(
/* [in] */ IMenuBuilder* menu);
private:
AutoPtr<IActionModeCallback> mCallback;
AutoPtr<IMenuBuilder> mMenu;
AutoPtr<IMenuBuilderCallback> mMenuCallback;
CExtractEditLayout* mHost;
friend class CExtractEditLayout;
};
class _OnClickListener
: public Object
, public IViewOnClickListener
{
public:
CAR_INTERFACE_DECL()
_OnClickListener(
/* [in] */ CExtractEditLayout* host);
CARAPI OnClick(
/* [in] */ IView* clicked);
private:
CExtractEditLayout* mHost;
};
public:
CAR_OBJECT_DECL()
CAR_INTERFACE_DECL()
CARAPI constructor(
/* [in] */ IContext* ctx);
CARAPI constructor(
/* [in] */ IContext* ctx,
/* [in] */ IAttributeSet* attrs);
/**
* @return true if an action mode is currently active.
*/
CARAPI IsActionModeStarted(
/* [out] */ Boolean* started);
/**
* Finishes a possibly started action mode.
*/
CARAPI FinishActionMode();
//@Override
CARAPI StartActionModeForChild(
/* [in] */ IView* sourceView,
/* [in] */ IActionModeCallback* cb,
/* [out] */ IActionMode** mode);
//@Override
CARAPI OnFinishInflate();
protected:
AutoPtr<ExtractActionMode> mActionMode;
AutoPtr<IButton> mExtractActionButton;
AutoPtr<IButton> mEditButton;
};
} // namespace InputMethodService
} // namespace Droid
} // namespace Elastos
#endif // __ELASTOS_DROID_INPUTMETHODSERVICE_ELASTOS_DROID_INPUTMEHTODSERVICE_CEXTRACTEDITLAYOUT_H__
| 27.321267 | 101 | 0.604339 |
5726dcdd3930346fb23a8eae0f2de0a017078a6f | 7,714 | h | C | sr/lsri/include/signal.h | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | 2 | 2018-03-01T13:45:41.000Z | 2018-03-01T14:11:47.000Z | src.clean/include/signal.h | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | null | null | null | src.clean/include/signal.h | ducis/operating-system-labs | 7df84f3dae792ee96461497b7d47414d24d233ee | [
"MIT"
] | null | null | null | /* The <signal.h> header defines all the ANSI and POSIX signals.
* MINIX supports all the signals required by POSIX. They are defined below.
* Some additional signals are also supported.
*/
#ifndef _SIGNAL_H
#define _SIGNAL_H
#ifndef _ANSI_H
#include <ansi.h>
#endif
#ifdef _POSIX_SOURCE
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#endif
/* Here are types that are closely associated with signal handling. */
typedef int sig_atomic_t;
#ifdef _POSIX_SOURCE
#ifndef _SIGSET_T
#define _SIGSET_T
typedef unsigned long sigset_t;
#endif
#endif
/* Regular signals. */
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt (DEL) */
#define SIGQUIT 3 /* quit (ASCII FS) */
#define SIGILL 4 /* illegal instruction */
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#define SIGABRT 6 /* IOT instruction */
#define SIGBUS 7 /* bus error */
#define SIGFPE 8 /* floating point exception */
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#define SIGUSR1 10 /* user defined signal # 1 */
#define SIGSEGV 11 /* segmentation violation */
#define SIGUSR2 12 /* user defined signal # 2 */
#define SIGPIPE 13 /* write on a pipe with no one to read it */
#define SIGALRM 14 /* alarm clock */
#define SIGTERM 15 /* software termination signal from kill */
#define SIGEMT 16 /* EMT instruction */
#define SIGCHLD 17 /* child process terminated or stopped */
#define SIGWINCH 21 /* window size has changed */
#define SIGVTALRM 24 /* virtual alarm */
#define SIGPROF 25 /* profiler alarm */
/* POSIX requires the following signals to be defined, even if they are
* not supported. Here are the definitions, but they are not supported.
*/
#define SIGCONT 18 /* continue if stopped */
#define SIGSTOP 19 /* stop signal */
#define SIGTSTP 20 /* interactive stop signal */
#define SIGTTIN 22 /* background process wants to read */
#define SIGTTOU 23 /* background process wants to write */
#define _NSIG 26 /* highest signal number plus one */
#define NSIG _NSIG
#ifdef _MINIX
#define SIGIOT SIGABRT /* for people who speak PDP-11 */
/* MINIX specific signals. These signals are not used by user proceses,
* but meant to inform system processes, like the PM, about system events.
* The order here determines the order signals are processed by system
* processes in user-space. Higher-priority signals should be first.
*/
/* Signals delivered by a signal manager. */
#define SIGSNDELAY 26 /* end of delay for signal delivery */
#define SIGS_FIRST SIGHUP /* first system signal */
#define SIGS_LAST SIGSNDELAY /* last system signal */
#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
/* Signals delivered by the kernel. */
#define SIGKMEM 27 /* kernel memory request pending */
#define SIGKMESS 28 /* new kernel message */
#define SIGKSIGSM 29 /* kernel signal pending for signal manager */
#define SIGKSIG 30 /* kernel signal pending */
#define SIGK_FIRST SIGKMEM /* first kernel signal */
#define SIGK_LAST SIGKSIG /* last kernel signal */
#define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST)
/* Termination signals for Minix system processes. */
#define SIGS_IS_LETHAL(sig) \
(sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \
|| sig == SIGEMT || sig == SIGABRT)
#define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
|| (sig == SIGKILL || sig == SIGPIPE))
#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
#endif
/* The sighandler_t type is not allowed unless _POSIX_SOURCE is defined. */
typedef void _PROTOTYPE( (*__sighandler_t), (int) );
/* Macros used as function pointers. */
#define SIG_ERR ((__sighandler_t) -1) /* error return */
#define SIG_DFL ((__sighandler_t) 0) /* default signal handling */
#define SIG_IGN ((__sighandler_t) 1) /* ignore signal */
#define SIG_HOLD ((__sighandler_t) 2) /* block signal */
#define SIG_CATCH ((__sighandler_t) 3) /* catch signal */
#ifdef _POSIX_SOURCE
struct sigaction {
__sighandler_t sa_handler; /* SIG_DFL, SIG_IGN, or pointer to function */
sigset_t sa_mask; /* signals to be blocked during handler */
int sa_flags; /* special flags */
};
/* Fields for sa_flags. */
#define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */
#define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */
#define SA_NODEFER 0x0004 /* don't block signal while catching it */
#define SA_RESTART 0x0008 /* automatic system call restart */
#define SA_SIGINFO 0x0010 /* extended signal handling */
#define SA_NOCLDWAIT 0x0020 /* don't create zombies */
#define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */
/* POSIX requires these values for use with sigprocmask(2). */
#define SIG_BLOCK 0 /* for blocking signals */
#define SIG_UNBLOCK 1 /* for unblocking signals */
#define SIG_SETMASK 2 /* for setting the signal mask */
#define SIG_INQUIRE 4 /* for internal use only */
/* codes for SIGFPE */
#define FPE_INTOVF 1 /* integer divide by zero */
#define FPE_INTDIV 2 /* integer overflow */
#define FPE_FLTDIV 3 /* floating-point divide by zero */
#define FPE_FLTOVF 4 /* floating-point overflow */
#define FPE_FLTUND 5 /* floating-point underflow */
#define FPE_FLTRES 6 /* floating-point inexact result */
#define FPE_FLTINV 7 /* floating-point invalid operation */
#define FPE_FLTSUB 8 /* subscript out of range */
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
} stack_t;
#define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */
/* Fields for ss_flags */
#define SS_ONSTACK 1 /* Process is executing on an alternate stack */
#define SS_DISABLE 2 /* Alternate stack is disabled */
#endif /* _POSIX_SOURCE */
/* POSIX and ANSI function prototypes. */
_PROTOTYPE( int raise, (int _sig) );
_PROTOTYPE( __sighandler_t signal, (int _sig, __sighandler_t _func) );
#ifdef _POSIX_SOURCE
_PROTOTYPE( int kill, (pid_t _pid, int _sig) );
_PROTOTYPE( int killpg, (pid_t _pgrp, int _sig) );
_PROTOTYPE( int sigaction,
(int _sig, const struct sigaction *_act, struct sigaction *_oact) );
_PROTOTYPE( int sigpending, (sigset_t *_set) );
_PROTOTYPE( int sigprocmask,
(int _how, const sigset_t *_set, sigset_t *_oset) );
_PROTOTYPE( int sigsuspend, (const sigset_t *_sigmask) );
/* For the sigset functions, only use the library version with error
* checking from user programs. System programs need to be able to use
* nonstanard signals.
*/
#ifndef _SYSTEM
_PROTOTYPE( int sigaddset, (sigset_t *_set, int _sig) );
_PROTOTYPE( int sigdelset, (sigset_t *_set, int _sig) );
_PROTOTYPE( int sigemptyset, (sigset_t *_set) );
_PROTOTYPE( int sigfillset, (sigset_t *_set) );
_PROTOTYPE( int sigismember, (const sigset_t *_set, int _sig) );
#else
#define sigaddset(set, sig) ((int) ((*(set) |= (1 << (sig))) && 0))
#define sigdelset(set, sig) ((int) ((*(set) &= ~(1 << (sig))) && 0))
#define sigemptyset(set) ((int) (*(set) = 0))
#define sigfillset(set) ((int) ((*(set) = ~0) && 0))
#define sigismember(set, sig) ((*(set) & (1 << (sig))) ? 1 : 0)
#endif
#endif
#endif /* _SIGNAL_H */
| 40.814815 | 80 | 0.650246 |
b62e815aaeaad5c080e231de561458cf2f158d45 | 46,998 | c | C | core/mem.c | kgllewellyn/shoebill | d276b9501829dbd4e070d88f6043a0af3abf1d95 | [
"BSD-2-Clause"
] | 255 | 2015-01-28T05:04:51.000Z | 2022-03-25T17:32:47.000Z | core/mem.c | aristocratos/shoebill | 2b4768daee2227cf19e9556c73afd318f0e8bf8c | [
"BSD-2-Clause"
] | 13 | 2015-05-08T03:31:34.000Z | 2021-07-19T07:06:36.000Z | core/mem.c | aristocratos/shoebill | 2b4768daee2227cf19e9556c73afd318f0e8bf8c | [
"BSD-2-Clause"
] | 63 | 2015-02-09T17:12:53.000Z | 2022-03-09T04:32:46.000Z | /*
* Copyright (c) 2013, Peter Rutenbar <pruten@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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.
*/
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "../core/shoebill.h"
/* --- Physical_get jump table --- */
#pragma mark Physical_get jump table
void _physical_get_ram (void)
{
uint64_t *addr;
if slikely(shoe.physical_addr < shoe.physical_mem_size)
addr = (uint64_t*)&shoe.physical_mem_base[shoe.physical_addr];
else
addr = (uint64_t*)&shoe.physical_mem_base[shoe.physical_addr % shoe.physical_mem_size];
const uint8_t bits = (8 - shoe.physical_size) * 8;
shoe.physical_dat = ntohll(*addr) >> bits;
}
void _physical_get_rom (void)
{
uint64_t *addr = (uint64_t*)&shoe.physical_rom_base[shoe.physical_addr & (shoe.physical_rom_size-1)];
const uint8_t bits = (8 - shoe.physical_size) * 8;
shoe.physical_dat = ntohll(*addr) >> bits;
}
void _physical_get_io (void)
{
switch (shoe.physical_addr & 0x5003ffff) {
case 0x50000000 ... 0x50003fff: // VIA1 + VIA2
via_read_raw();
return ;
case 0x50004000 ... 0x50005fff: {// SCC
//slog("physical_get: got read to SCC\n");
const uint32_t a = shoe.physical_addr & 0x1fff;
if (a == 2 && shoe.physical_size==1)
shoe.physical_dat = 0x4; // R0TXRDY
return ;
}
case 0x50006000 ... 0x50007fff: // SCSI (pseudo-DMA with DRQ?)
assert(shoe.logical_size == 4);
shoe.physical_dat = scsi_dma_read_long();
return ;
case 0x50010000 ... 0x50011fff: // SCSI (normal mode?)
scsi_reg_read();
return ;
case 0x50012000 ... 0x50013fff: // SCSI (pseudo-DMA with no DRQ?)
assert(shoe.logical_size == 1);
shoe.physical_dat = scsi_dma_read();
return ;
case 0x50014000 ... 0x50015fff: // Sound
// slog("physical_get: got read to sound\n");
shoe.physical_dat = sound_dma_read_raw(shoe.physical_addr & 0x1fff, shoe.physical_size);
// slog("soundsound read : register 0x%04x sz=%u\n",
//shoe.physical_addr - 0x50014000, shoe.physical_size);
// shoe.physical_dat = 0;
return ;
case 0x50016000 ... 0x50017fff: // SWIM (IWM?)
// slog("physical_get: got read to IWM\n");
shoe.physical_dat = iwm_dma_read();
return ;
default:
//slog("physical_get: got read to UNKNOWN IO ADDR %x\n", shoe.physical_addr);
return ;
}
}
void _physical_get_super_slot (void)
{
const uint32_t slot = shoe.physical_addr >> 28;
if slikely(shoe.slots[slot].connected)
shoe.physical_dat = shoe.slots[slot].read_func(shoe.physical_addr,
shoe.physical_size,
slot);
else
shoe.abort = 1; // throw a bus error for reads to disconnected slots
// XXX: Do super slot accesses raise bus errors?
}
void _physical_get_standard_slot (void)
{
const uint32_t slot = (shoe.physical_addr >> 24) & 0xf;
if slikely(shoe.slots[slot].connected)
shoe.physical_dat = shoe.slots[slot].read_func(shoe.physical_addr,
shoe.physical_size,
slot);
else
shoe.abort = 1; // throw a bus error for reads to disconnected slots
}
const physical_get_ptr physical_get_jump_table[16] = {
_physical_get_ram, // 0x0
_physical_get_ram, // 0x1
_physical_get_ram, // 0x2
_physical_get_ram, // 0x3
_physical_get_rom, // 0x4
_physical_get_io, // 0x5
_physical_get_super_slot, // 0x6
_physical_get_super_slot, // 0x7
_physical_get_super_slot, // 0x8
_physical_get_super_slot, // 0x9
_physical_get_super_slot, // 0xa
_physical_get_super_slot, // 0xb
_physical_get_super_slot, // 0xc
_physical_get_super_slot, // 0xd
_physical_get_super_slot, // 0xe
_physical_get_standard_slot // 0xf
};
/* --- Physical_set jump table --- */
#pragma mark Physical_set jump table
void _physical_set_ram (void)
{
uint8_t *addr;
if (shoe.physical_addr >= shoe.physical_mem_size)
addr = &shoe.physical_mem_base[shoe.physical_addr % shoe.physical_mem_size];
else
addr = &shoe.physical_mem_base[shoe.physical_addr];
if ((shoe.physical_addr >= 0x100) && (shoe.physical_addr < (0x8000))) {
slog("LOMEM set: *0x%08x = 0x%x\n", shoe.physical_addr, (uint32_t)chop(shoe.physical_dat, shoe.physical_size));
}
const uint32_t sz = shoe.physical_size;
switch (sz) {
case 1:
*addr = (uint8_t)shoe.physical_dat;
return ;
case 2:
*((uint16_t*)addr) = htons((uint16_t)shoe.physical_dat);
return ;
case 4:
*((uint32_t*)addr) = htonl((uint32_t)shoe.physical_dat);
return ;
case 8:
*(uint64_t*)addr = ntohll(shoe.physical_dat);
return ;
default: {
uint64_t q = shoe.physical_dat;
uint8_t i;
for (i=1; i<=sz; i++) {
addr[sz-i] = (uint8_t)q;
q >>= 8;
}
return ;
}
}
}
void _physical_set_rom (void)
{
// nothing happens when you try to modify ROM
}
void _physical_set_io (void)
{
switch (shoe.physical_addr & 0x5003ffff) {
case 0x50000000 ... 0x50003fff: // VIA1 + VIA2
via_write_raw();
return ;
case 0x50004000 ... 0x50005fff: // SCC
//slog("physical_set: got write to SCC\n");
return ;
case 0x50006000 ... 0x50007fff: // SCSI (pseudo-DMA with DRQ?)
assert(shoe.physical_size == 4);
scsi_dma_write_long(shoe.physical_dat);
return ;
case 0x50010000 ... 0x50011fff: // SCSI (normal mode?)
scsi_reg_write();
return ;
case 0x50012000 ... 0x50013fff: // SCSI (pseudo-DMA with no DRQ?)
assert(shoe.physical_size == 1);
scsi_dma_write(shoe.physical_dat);
return ;
case 0x50014000 ... 0x50015fff: // Sound
sound_dma_write_raw(shoe.physical_addr & 0x1fff, shoe.physical_size, shoe.physical_dat);
// slog("soundsound write: register 0x%04x sz=%u dat=0x%x\n",
// shoe.physical_addr - 0x50014000, shoe.physical_size, (uint32_t)shoe.physical_dat);
// slog("physical_set: got write to sound\n");
return ;
case 0x50016000 ... 0x50017fff: // SWIM (IWM?)
//slog("physical_set: got write to IWM\n");
iwm_dma_write();
return ;
default:
//slog("physical_set: got write to UNKNOWN IO ADDR %x\n", shoe.physical_addr);
return ;
}
}
void _physical_set_super_slot (void)
{
const uint32_t slot = shoe.physical_addr >> 28;
if (shoe.slots[slot].connected)
shoe.slots[slot].write_func(shoe.physical_addr,
shoe.physical_size,
shoe.physical_dat,
slot);
}
void _physical_set_standard_slot (void)
{
const uint32_t slot = (shoe.physical_addr >> 24) & 0xf;
if (shoe.slots[slot].connected)
shoe.slots[slot].write_func(shoe.physical_addr,
shoe.physical_size,
shoe.physical_dat,
slot);
}
const physical_set_ptr physical_set_jump_table[16] = {
_physical_set_ram, // 0x0
_physical_set_ram, // 0x1
_physical_set_ram, // 0x2
_physical_set_ram, // 0x3
_physical_set_rom, // 0x4
_physical_set_io, // 0x5
_physical_set_super_slot, // 0x6
_physical_set_super_slot, // 0x7
_physical_set_super_slot, // 0x8
_physical_set_super_slot, // 0x9
_physical_set_super_slot, // 0xa
_physical_set_super_slot, // 0xb
_physical_set_super_slot, // 0xc
_physical_set_super_slot, // 0xd
_physical_set_super_slot, // 0xe
_physical_set_standard_slot // 0xf
};
/* --- PMMU logical address translation --- */
#pragma mark PMMU logical address translation
#define PMMU_CACHE_CRP 0
#define PMMU_CACHE_SRP 1
/*typedef struct {
uint32_t logical_value : 24; // At most the high 24 bits of the logical address
uint32_t used_bits : 5;
uint32_t wp : 1; // whether the page is write protected
uint32_t modified : 1; // whether the page has been modified
uint32_t unused1 : 1;
uint32_t unused2 : 8;
uint32_t physical_addr : 24;
} pmmu_cache_entry;
struct {
pmmu_cache_entry entry[512];
uint8_t valid_map[512 / 8];
} pmmu_cache[2];*/
#define write_back_desc() { \
if (desc_addr < 0) { \
*rootp_ptr = desc; \
} else { \
pset((uint32_t)desc_addr, 4<<desc_size, desc); \
} \
}
static _Bool check_pmmu_cache_write(void)
{
const _Bool use_srp = (shoe.tc_sre && (shoe.logical_fc >= 5));
// logical addr [is]xxxxxxxxxxxx[ps] -> value xxxxxxxxxxxx
const uint32_t value = (shoe.logical_addr << shoe.tc_is) >> shoe.tc_is_plus_ps;
// value xxx[xxxxxxxxx] -> key xxxxxxxxx
const uint32_t key = value & (PMMU_CACHE_SIZE - 1); // low PMMU_CACHE_KEY_BITS bits
const pmmu_cache_entry_t entry = shoe.pmmu_cache[use_srp].entry[key];
const _Bool is_set = (shoe.pmmu_cache[use_srp].valid_map[key >> 3] >> (key & 7)) & 1;
const uint32_t ps_mask = 0xffffffff >> entry.used_bits;
const uint32_t v_mask = ~~ps_mask;
shoe.physical_addr = ((entry.physical_addr<<8) & v_mask) | (shoe.logical_addr & ps_mask);
return is_set && (entry.logical_value == value) && entry.modified && !entry.wp;
}
static _Bool check_pmmu_cache_read(void)
{
const _Bool use_srp = (shoe.tc_sre && (shoe.logical_fc >= 5));
// logical addr [is]xxxxxxxxxxxx[ps] -> value xxxxxxxxxxxx
const uint32_t value = (shoe.logical_addr << shoe.tc_is) >> shoe.tc_is_plus_ps;
// value xxx[xxxxxxxxx] -> key xxxxxxxxx
const uint32_t key = value & (PMMU_CACHE_SIZE - 1); // low PMMU_CACHE_KEY_BITS bits
const pmmu_cache_entry_t entry = shoe.pmmu_cache[use_srp].entry[key];
const _Bool is_set = (shoe.pmmu_cache[use_srp].valid_map[key >> 3] >> (key & 7)) & 1;
const uint32_t ps_mask = 0xffffffff >> entry.used_bits;
const uint32_t v_mask = ~~ps_mask;
shoe.physical_addr = ((entry.physical_addr<<8) & v_mask) | (shoe.logical_addr & ps_mask);
return is_set && (entry.logical_value == value);
}
static void translate_logical_addr()
{
const uint8_t use_srp = (shoe.tc_sre && (shoe.logical_fc >= 5));
assert((0x66 >> shoe.logical_fc) & 1); // we only support these FCs for now
uint64_t *rootp_ptr = (use_srp ? (&shoe.srp) : (&shoe.crp));
const uint64_t rootp = *rootp_ptr;
uint8_t desc_did_change = 0;
uint8_t desc_level = 0;
int64_t desc_addr = -1; // address of the descriptor (-1 -> register)
uint8_t wp = 0; // Whether any descriptor in the search has wp (write protected) set
uint8_t i;
uint64_t desc = rootp; // Initial descriptor is the root pointer descriptor
uint8_t desc_size = 1; // And the root pointer descriptor is always 8 bytes (1==8 bytes, 0==4 bytes)
uint8_t used_bits = shoe.tc_is; // Keep track of how many bits will be the effective "page size"
// (If the table search terminates early (before used_bits == ts_ps()),
// then (32 - used_bits) will be the effective page size. That is, the number of bits
// we or into the physical addr from the virtual addr)
desc_addr = -1; // address of the descriptor (-1 -> register)
/* We'll keep shifting logical_addr such that its most significant bits are the next ti-index */
uint32_t logical_addr = shoe.logical_addr << used_bits;
// TODO: Check limit here
// If root descriptor is invalid, throw a bus error
if sunlikely(rp_dt(rootp) == 0) {
throw_bus_error(shoe.logical_addr, shoe.logical_is_write);
return ;
}
// desc is a page descriptor, skip right ahead to search_done:
if (rp_dt(rootp) == 1)
goto search_done;
// for (i=0; i < 4; i++) { // (the condition is unnecessary - just leaving it in for clarity)
for (i=0; 1; i++) {
// desc must be a table descriptor here
const uint8_t ti = tc_ti(i);
used_bits += ti;
// TODO: do the limit check here
// Find the index into our current i-level table
const uint32_t index = logical_addr >> (32-ti);
logical_addr <<= ti;
// load the child descriptor
const uint32_t table_base_addr = desc_table_addr(desc);
const uint8_t s = desc_dt(desc, desc_size) & 1;
// desc = pget(table_base_addr + (4 << s)*index, (4 << s));
get_desc(table_base_addr + (4 << s)*index, (4 << s));
desc_size = s;
// Desc may be a table descriptor, page descriptor, indirect descriptor, or invalid descriptor
const uint8_t dt = desc_dt(desc, desc_size);
// If this descriptor is invalid, throw a bus error
if sunlikely(dt == 0) {
throw_bus_error(shoe.logical_addr, shoe.logical_is_write);
return ;
}
if (dt == 1) {
// TODO: do a limit check here
goto search_done; // it's a page descriptor
}
else if ((i==3) || (tc_ti(i+1)==0)) {
desc_size = desc_dt(desc, s) & 1;
/* Otherwise, if this is a leaf in the tree, it's an indirect descriptor.
The size of the page descriptor is indicated by DT in the indirect descriptor. (or is it???) */
//desc = pget(desc & 0xfffffff0, (4 << desc_size));
get_desc(desc & 0xfffffff0, (4 << desc_size));
// I think it's possible for an indirect descriptor to point to an invalid descriptor...
if sunlikely(desc_dt(desc, desc_size) == 0) {
throw_bus_error(shoe.logical_addr, shoe.logical_is_write);
return ;
}
goto search_done;
}
// Now it must be a table descriptor
// TODO: set the U (used) bit in this table descriptor
wp |= desc_wp(desc, desc_size); // or in the wp flag for this table descriptor
}
// never get here
assert(!"translate_logical_addr: never get here");
search_done:
// Desc must be a page descriptor
// NOTE: The limit checks have been done already
// (or would be, if they were implemented yet)
// TODO: update U (used) bit
wp |= desc_wp(desc, desc_size); // or in the wp flag for this page descriptor
// And finally throw a bus error
if sunlikely(wp && shoe.logical_is_write) {
throw_bus_error(shoe.logical_addr, shoe.logical_is_write);
return ;
}
// If we're writing, set the modified flag
if (shoe.logical_is_write && !(desc & ( desc_size ? desc_m_long : desc_m_short ))) {
desc |= ( desc_size ? desc_m_long : desc_m_short );
write_back_desc();
}
const uint32_t ps_mask = 0xffffffff >> used_bits;
const uint32_t v_mask = ~~ps_mask;
const uint32_t paddr = (desc_page_addr(desc) & v_mask) | (shoe.logical_addr & ps_mask);
shoe.physical_addr = paddr;
/* --- insert this translation into pmmu_cache --- */
// logical addr [is]xxxxxxxxxxxx[ps] -> value xxxxxxxxxxxx
const uint32_t value = (shoe.logical_addr << shoe.tc_is) >> shoe.tc_is_plus_ps;
// value xxx[xxxxxxxxx] -> key xxxxxxxxx
const uint32_t key = value & (PMMU_CACHE_SIZE-1); // low PMMU_CACHE_KEY_BITS bits
pmmu_cache_entry_t entry;
shoe.pmmu_cache[use_srp].valid_map[key/8] |= (1 << (key & 7));
entry.logical_value = value;
entry.physical_addr = (desc_page_addr(desc)) >> 8;
entry.wp = wp;
entry.modified = desc_m(desc, desc_size);
entry.used_bits = used_bits;
shoe.pmmu_cache[use_srp].entry[key] = entry;
}
void logical_get (void)
{
// If address translation isn't enabled, this is a physical address
if sunlikely(!shoe.tc_enable) {
shoe.physical_addr = shoe.logical_addr;
shoe.physical_size = shoe.logical_size;
physical_get();
if sunlikely(shoe.abort) {
shoe.abort = 0;
throw_long_bus_error(shoe.logical_addr, 0);
return ;
}
shoe.logical_dat = shoe.physical_dat;
return ;
}
const uint32_t logical_size = shoe.logical_size;
const uint32_t logical_addr = shoe.logical_addr;
const uint32_t pagemask = shoe.tc_pagemask;
const uint32_t pageoffset = logical_addr & pagemask;
// Common case: the read is contained entirely within a page
if slikely(!((pageoffset + logical_size - 1) >> shoe.tc_ps)) {
if sunlikely(!check_pmmu_cache_read()) {
shoe.logical_is_write = 0;
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
if slikely(shoe.physical_addr < shoe.physical_mem_size) {
// Fast path
shoe.logical_dat = ntohll(*(uint64_t*)&shoe.physical_mem_base[shoe.physical_addr]) >> ((8-logical_size)*8);
}
else {
shoe.physical_size = logical_size;
physical_get();
if sunlikely(shoe.abort) {
shoe.abort = 0;
throw_long_bus_error(logical_addr, 0);
return ;
}
shoe.logical_dat = shoe.physical_dat;
}
}
else { // This read crosses a page boundary
const uint32_t addr_a = logical_addr;
const uint32_t size_b = (pageoffset + logical_size) & pagemask;
const uint32_t size_a = logical_size - size_b;
const uint32_t addr_b = addr_a + size_a;
shoe.logical_is_write = 0;
shoe.logical_addr = addr_a;
shoe.logical_size = size_a;
if sunlikely(!check_pmmu_cache_read()) {
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
const uint32_t p_addr_a = shoe.physical_addr;
shoe.logical_addr = addr_b;
shoe.logical_size = size_b;
if sunlikely(!check_pmmu_cache_read()) {
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
const uint32_t p_addr_b = shoe.physical_addr;
shoe.physical_size = size_b;
physical_get();
if sunlikely(shoe.abort) {
shoe.abort = 0;
throw_long_bus_error(shoe.logical_addr, 0);
return ;
}
const uint64_t fetch_b = shoe.physical_dat;
shoe.physical_addr = p_addr_a;
shoe.physical_size = size_a;
physical_get();
if sunlikely(shoe.abort) {
shoe.abort = 0;
throw_long_bus_error(shoe.logical_addr, 0);
return ;
}
shoe.logical_dat = (shoe.physical_dat << (size_b*8)) | fetch_b;
}
}
void logical_set (void)
{
// If address translation isn't enabled, this is a physical address
if sunlikely(!shoe.tc_enable) {
shoe.physical_addr = shoe.logical_addr;
shoe.physical_size = shoe.logical_size;
shoe.physical_dat = shoe.logical_dat;
physical_set();
return ;
}
const uint32_t logical_size = shoe.logical_size;
const uint32_t logical_addr = shoe.logical_addr;
const uint32_t pagemask = shoe.tc_pagemask;
const uint32_t pageoffset = logical_addr & pagemask;
// Make the translate function fail if the page is write-protected
shoe.logical_is_write = 1;
// Common case: this write is contained entirely in one page
if slikely(!((pageoffset + logical_size - 1) >> shoe.tc_ps)) {
// Common case: the write is contained entirely within a page
if sunlikely(!check_pmmu_cache_write()) {
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
shoe.physical_size = shoe.logical_size;
shoe.physical_dat = shoe.logical_dat;
physical_set();
}
else { // This write crosses a page boundary
const uint32_t addr_a = shoe.logical_addr;
const uint32_t size_b = (pageoffset + logical_size) & pagemask;
const uint32_t size_a = shoe.logical_size - size_b;
const uint32_t addr_b = addr_a + size_a;
const uint64_t data_a = shoe.logical_dat >> (size_b*8);
const uint64_t data_b = bitchop_64(shoe.logical_dat, size_b*8);
shoe.logical_addr = addr_a;
shoe.logical_size = size_a;
if sunlikely(!check_pmmu_cache_write()) {
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
const uint32_t p_addr_a = shoe.physical_addr;
shoe.logical_addr = addr_b;
shoe.logical_size = size_b;
if sunlikely(!check_pmmu_cache_write()) {
translate_logical_addr();
if sunlikely(shoe.abort)
return ;
}
const uint32_t p_addr_b = shoe.physical_addr;
shoe.physical_addr = p_addr_a;
shoe.physical_size = size_a;
shoe.physical_dat = data_a;
physical_set();
shoe.physical_addr = p_addr_b;
shoe.physical_size = size_b;
shoe.physical_dat = data_b;
physical_set();
return ;
}
}
/* --- PC cache routines --- */
#pragma mark PC cache routines
static uint16_t pccache_miss(const uint32_t pc)
{
const uint32_t pagemask = shoe.tc_pagemask;
const uint32_t pageoffset = pc & pagemask;
uint32_t paddr;
/*
* I think the instruction decoder uses these
* these function codes:
* 6 -> supervisor program space,
* 2 -> user program space
*/
shoe.logical_fc = sr_s() ? 6 : 2;
shoe.logical_addr = pc;
if sunlikely(!check_pmmu_cache_read()) {
shoe.logical_is_write = 0;
translate_logical_addr();
if sunlikely(shoe.abort)
goto fail;
}
paddr = shoe.physical_addr ^ pageoffset;
shoe.pccache_use_srp = shoe.tc_sre && sr_s();
shoe.pccache_logical_page = pc ^ pageoffset;
if (paddr < 0x40000000) {
/* Address in RAM */
if sunlikely(paddr >= shoe.physical_mem_size)
paddr %= shoe.physical_mem_size;
shoe.pccache_ptr = &shoe.physical_mem_base[paddr];
return ntohs(*(uint16_t*)(shoe.pccache_ptr + pageoffset));
}
else if (paddr < 0x50000000) {
/* Address in ROM */
shoe.pccache_ptr = &shoe.physical_rom_base[paddr & (shoe.physical_rom_size - 1)];
return ntohs(*(uint16_t*)(shoe.pccache_ptr + pageoffset));
}
/*
* For now, only supporting reads from RAM and ROM.
* This could easily be supported by just calling
* physical_get() and leaving the cache invalid,
* but I don't think A/UX ever tries to execute outside
* RAM/ROM.
*/
assert(!"pccache_miss: neither RAM nor ROM!\n");
fail:
invalidate_pccache();
return 0;
}
uint16_t pccache_nextword(const uint32_t pc)
{
if (sunlikely(pc & 1))
goto odd_addr;
if slikely(shoe.tc_enable) {
const uint32_t pc_offset = pc & shoe.tc_pagemask;
const uint32_t pc_page = pc ^ pc_offset;
const uint32_t use_srp = shoe.tc_sre && sr_s();
/* If the cache exists and is valid */
if slikely((shoe.pccache_use_srp == use_srp) && (shoe.pccache_logical_page == pc_page)) {
// printf("pccache_nextword: hit: pc=%x\n", pc);
return ntohs(*(uint16_t*)(shoe.pccache_ptr + pc_offset));
}
// printf("pccache_nextword: miss: pc=%x\n", pc);
return pccache_miss(pc);
}
else {
uint32_t paddr = pc;
if (paddr < 0x40000000) {
/* Address in RAM */
if sunlikely(paddr >= shoe.physical_mem_size)
paddr %= shoe.physical_mem_size;
return ntohs(*(uint16_t*)(&shoe.physical_mem_base[paddr]));
}
else if (paddr < 0x50000000) {
/* Address in ROM */
return ntohs(*(uint16_t*)&shoe.physical_rom_base[paddr & (shoe.physical_rom_size - 1)]);
}
assert(!"!tc_enable: neither RAM nor RAM\n");
}
odd_addr:
assert(!"odd pc address!\n");
return 0;
}
uint32_t pccache_nextlong(const uint32_t pc)
{
if slikely(shoe.tc_enable) {
const uint32_t lastpage = shoe.pccache_logical_page;
const uint32_t pc_offset = pc & shoe.tc_pagemask;
const uint32_t pc_page = pc ^ pc_offset;
const uint32_t use_srp = shoe.tc_sre && sr_s();
/* If the cache exists, is valid, and the read is contained entirely within 1 page */
if slikely((shoe.pccache_use_srp == use_srp) && (lastpage == pc_page) && !((pc_offset + 3) >> shoe.tc_ps)) {
const uint32_t result = ntohl(*(uint32_t*)(shoe.pccache_ptr + pc_offset));
if (sunlikely(pc_offset & 1))
goto odd_addr;
return result;
}
const uint32_t result_high = pccache_nextword(pc) << 16;
if sunlikely(shoe.abort)
return 0;
return result_high | pccache_nextword(pc + 2);
}
else {
uint32_t paddr = pc;
if sunlikely(paddr & 1)
goto odd_addr;
if (paddr < 0x40000000) {
/* Address in RAM */
if sunlikely(paddr >= shoe.physical_mem_size)
paddr %= shoe.physical_mem_size;
return ntohl(*(uint32_t*)(&shoe.physical_mem_base[paddr]));
}
else if (paddr < 0x50000000) {
/* Address in ROM */
return ntohl(*(uint32_t*)&shoe.physical_rom_base[paddr & (shoe.physical_rom_size - 1)]);
}
assert(!"!tc_enable: neither RAM nor RAM\n");
}
odd_addr:
assert(!"odd pc address!\n");
return 0;
}
/* --- EA routines --- */
#pragma mark EA routines
#define nextword(pc) ({const uint16_t w = pccache_nextword(pc); if sunlikely(shoe.abort) return; (pc) += 2; w;})
#define nextlong(pc) ({const uint32_t L = pccache_nextlong(pc); if sunlikely(shoe.abort) return; (pc) += 4; L;})
// ea_decode_extended() - find the EA for those hiddeous 68020 addr modes
static void ea_decode_extended()
{
const uint32_t start_pc = shoe.pc; // the original PC
uint32_t mypc = start_pc; // our local PC (don't modify up the real PC)
const uint32_t ext_a = nextword(mypc); // the extension word
~decompose(ext_a, d rrr w ss F b i zz 0 III)
// d == index register type
// r == index register
// w == word/long-word index size
// s == scale factor
// F == extension word format (0==brief, 1==full)
// b == base register suppress
// i == index suppress
// z == base displacement size
// I == index/indirect selection
if (F == 0) { // If this is the brief extension word
// use the sign-extended least significant byte in the extension word
uint32_t base_disp = (int8_t)(ext_a & 0xff);
// load the base_address
uint32_t base_addr;
if (~bmatch(shoe.mr, 00xx1xxx)) { // consult the MR, use the PC?
base_addr = start_pc; // start at the beginning of the extension word
}
else { // otherwise, it's shoe.a[shoe.mr&7]
base_addr = shoe.a[shoe.mr&7];
}
// load the index value
uint32_t index_val;
if (w==0) { // use signed-extended lower word of the register
if (d==0) // shoe.d[]
index_val = (int16_t)(get_d(r, 2));
else // shoe.a[]
index_val = (int16_t)(get_a(r, 2));
} else { // use entire register
if (d==0) index_val = shoe.d[r];
else index_val = shoe.a[r];
}
// Scale the index value
index_val <<= s;
// the brief extension word is implicitly preindexed
shoe.extended_addr = base_addr + base_disp + index_val;
shoe.extended_len = mypc - start_pc;
//slog("I found address 0x%x\n", shoe.extended_addr);
return ;
}
else { // If this is a full extension word,
// first find the base address, which may be shoe.a[?] or shoe.pc
uint32_t base_addr = 0;
if (b == 0) { // only if it isn't suppressed
if (~bmatch(shoe.mr, 00xx1xxx)) { // consult the MR,
base_addr = start_pc; // start at the beginning of the extension word
}
else { // otherwise, it's shoe.a[shoe.mr&7]
base_addr = shoe.a[shoe.mr&7];
}
}
// Find the index value
uint32_t index_val = 0;
if (i == 0) { // only if it isn't suppressed
if (w==0) { // use signed-extended lower word of the register
if (d==0) // shoe.d[]
index_val = (int16_t)(get_d(r, 2));
else // shoe.a[]
index_val = (int16_t)(get_a(r, 2));
} else { // use entire register
if (d==0) index_val = shoe.d[r];
else index_val = shoe.a[r];
}
// Scale the index value
index_val <<= s;
}
// Find the base displacement
uint32_t base_disp = 0;
// ... but only if the size is > null
if (z > 1) {
if (z == 2) { // if word-length, fetch nextword() and sign-extend
base_disp = (int16_t)(nextword(mypc));
} else { // otherwise, it's a longword
base_disp = nextlong(mypc);
}
}
// Find the outer displacement
uint32_t outer_disp = 0;
// based on the I/IS behavior
switch ((i<<3)|I) {
case ~b(0010): case ~b(0110): case ~b(1010):
// sign-extended word-length outer displacement
outer_disp = (int16_t)nextword(mypc);
break;
case ~b(0011): case ~b(0111): case ~b(1011): {
// long word outer displacement
outer_disp = nextlong(mypc);
break ;
}
}
//slog("D/A=%u, reg=%u, W/L=%u, Scale=%u, F=%u, BS=%u, IS=%u, BDSize=%u, I/IS=%u\n",
//d, r, w, s, F, b, i, z, I);
//slog("base_addr=%x, index_val=%x, base_disp=%x, outer_disp=%x\n",
//base_addr, index_val, base_disp, outer_disp);
// Now mash all these numbers together to get an EA
switch ((i<<3)|I) {
case ~b(0001): case ~b(0010): case ~b(0011):
case ~b(1001): case ~b(1010): case ~b(1011): {
// Indirect preindexed
const uint32_t intermediate = lget(base_addr + base_disp + index_val, 4);
if sunlikely(shoe.abort) return ;
shoe.extended_addr = intermediate + outer_disp;
shoe.extended_len = mypc - start_pc;
// slog("addr=0x%x len=%u\n", shoe.extended_addr, shoe.extended_len);
return ;
}
case ~b(0101): case ~b(0110): case ~b(0111): {
// Indirect postindexed
const uint32_t intermediate = lget(base_addr + base_disp, 4);
if sunlikely(shoe.abort) return ;
shoe.extended_addr = intermediate + index_val + outer_disp;
shoe.extended_len = mypc - start_pc;
return ;
}
case ~b(1000): case ~b(0000): {
// No memory indirect action
// EA = base_addr + base_disp + index
shoe.extended_addr = base_addr + base_disp + index_val;
shoe.extended_len = mypc - start_pc;
return ;
}
default:
assert(!"ea_decode_extended: oh noes! invalid I/IS!\n");
// I think that 68040 *doesn't* throw an exception here...
// FIXME: figure out what actually happens here
break;
}
}
}
// Data register direct mode
void _ea_000_read (void)
{
shoe.dat = get_d(shoe.mr & 7, shoe.sz);
}
void _ea_000_write (void)
{
set_d(shoe.mr & 7, shoe.dat, shoe.sz);
}
// address register direct mode
void _ea_001_read (void)
{
shoe.dat = get_a(shoe.mr & 7, shoe.sz);
}
void _ea_001_write (void)
{
assert(shoe.sz==4);
shoe.a[shoe.mr & 7] = shoe.dat;
}
// address register indirect mode
void _ea_010_read (void)
{
shoe.dat = lget(shoe.a[shoe.mr & 7], shoe.sz);
}
void _ea_010_write (void)
{
lset(shoe.a[shoe.mr & 7], shoe.sz, shoe.dat);
}
void _ea_010_addr (void)
{
shoe.dat = shoe.a[shoe.mr & 7];
}
// address register indirect with postincrement mode
void _ea_011_read (void)
{
shoe.dat = lget(shoe.a[shoe.mr & 7], shoe.sz);
}
void _ea_011_read_commit (void)
{
const uint8_t reg = shoe.mr & 7;
shoe.a[reg] += (((reg==7) && (shoe.sz==1)) ? 2 : shoe.sz);
}
void _ea_011_write (void)
{
const uint8_t reg = shoe.mr & 7;
const uint8_t delta = ((reg==7) && (shoe.sz==1)) ? 2 : shoe.sz;
lset(shoe.a[reg], shoe.sz, shoe.dat);
if slikely(!shoe.abort)
shoe.a[reg] += delta;
}
// address register indirect with predecrement mode
void _ea_100_read (void)
{
const uint8_t reg = shoe.mr & 7;
const uint8_t delta = ((reg==7) && (shoe.sz==1))?2:shoe.sz;
shoe.dat = lget(shoe.a[reg]-delta, shoe.sz);
}
void _ea_100_read_commit (void)
{
const uint8_t reg = shoe.mr & 7;
shoe.a[reg] -= (((reg==7) && (shoe.sz==1)) ? 2 : shoe.sz);
}
void _ea_100_write (void)
{
const uint8_t reg = shoe.mr & 7;
const uint8_t delta = ((reg==7) && (shoe.sz==1)) ? 2 : shoe.sz;
lset(shoe.a[reg] - delta, shoe.sz, shoe.dat);
if slikely(!shoe.abort)
shoe.a[reg] -= delta;
}
// address register indirect with displacement mode
void _ea_101_read (void)
{
shoe.uncommitted_ea_read_pc = shoe.pc;
const int16_t disp = nextword(shoe.uncommitted_ea_read_pc);
shoe.dat = lget(shoe.a[shoe.mr & 7] + disp, shoe.sz);
}
void _ea_101_read_commit (void)
{
shoe.pc += 2;
}
void _ea_101_write (void)
{
const int16_t disp = nextword(shoe.pc);
lset(shoe.a[shoe.mr & 7] + disp, shoe.sz, shoe.dat);
}
void _ea_101_addr (void)
{
const int16_t disp = nextword(shoe.pc);
shoe.dat = shoe.a[shoe.mr & 7] + disp;
}
// memory/address register indirect with index
void _ea_110_read (void)
{
ea_decode_extended();
if slikely(!shoe.abort)
shoe.dat = lget(shoe.extended_addr, shoe.sz);
shoe.uncommitted_ea_read_pc = shoe.pc + shoe.extended_len;
}
void _ea_110_read_commit (void)
{
shoe.pc = shoe.uncommitted_ea_read_pc;
}
void _ea_110_write (void)
{
ea_decode_extended();
if slikely(!shoe.abort) {
lset(shoe.extended_addr, shoe.sz, shoe.dat);
if slikely(!shoe.abort)
shoe.pc += shoe.extended_len;
}
}
void _ea_110_addr (void)
{
ea_decode_extended();
if slikely(!shoe.abort) {
shoe.dat = shoe.extended_addr;
shoe.pc += shoe.extended_len;
}
}
// absolute short addressing mode
void _ea_111_000_read (void)
{
shoe.uncommitted_ea_read_pc = shoe.pc;
const int32_t addr = (int16_t)nextword(shoe.uncommitted_ea_read_pc);
shoe.dat = lget((uint32_t)addr, shoe.sz);
}
void _ea_111_000_read_commit (void)
{
shoe.pc += 2;
}
void _ea_111_000_write (void)
{
const int32_t addr = (int16_t)nextword(shoe.pc);
lset((uint32_t)addr, shoe.sz, shoe.dat);
}
void _ea_111_000_addr (void)
{
const int32_t addr = (int16_t)nextword(shoe.pc);
shoe.dat = (uint32_t)addr;
}
// absolute long addressing mode
void _ea_111_001_read (void)
{
shoe.uncommitted_ea_read_pc = shoe.pc;
const uint32_t addr = nextlong(shoe.uncommitted_ea_read_pc);
shoe.dat = lget(addr, shoe.sz);
}
void _ea_111_001_read_commit (void)
{
shoe.pc += 4;
}
void _ea_111_001_write (void)
{
const uint32_t addr = nextlong(shoe.pc);
lset(addr, shoe.sz, shoe.dat);
}
void _ea_111_001_addr (void)
{
const uint32_t addr = nextlong(shoe.pc);
shoe.dat = addr;
}
// program counter indirect with displacement mode
void _ea_111_010_read (void)
{
const uint32_t base_pc = shoe.pc;
shoe.uncommitted_ea_read_pc = base_pc;
const int16_t disp = nextword(shoe.uncommitted_ea_read_pc);
shoe.dat = lget(base_pc + disp, shoe.sz);
}
void _ea_111_010_read_commit (void)
{
shoe.pc += 2;
}
void _ea_111_010_addr (void)
{
const uint32_t oldpc = shoe.pc;
const int16_t displacement = nextword(shoe.pc);
shoe.dat = oldpc + displacement;
}
// (program counter ...)
void _ea_111_011_read (void)
{
ea_decode_extended();
if slikely(!shoe.abort)
shoe.dat = lget(shoe.extended_addr, shoe.sz);
shoe.uncommitted_ea_read_pc = shoe.pc + shoe.extended_len;
}
void _ea_111_011_read_commit (void)
{
shoe.pc = shoe.uncommitted_ea_read_pc;
}
void _ea_111_011_addr (void)
{
ea_decode_extended();
if slikely(!shoe.abort) {
shoe.dat = shoe.extended_addr;
shoe.pc += shoe.extended_len;
}
}
// immediate data
void _ea_111_100_read (void)
{
if (shoe.sz == 1) {
shoe.uncommitted_ea_read_pc = shoe.pc + 2;
shoe.dat = lget(shoe.pc, 2) & 0xff;
}
else {
shoe.uncommitted_ea_read_pc = shoe.pc + shoe.sz;
shoe.dat = lget(shoe.pc, shoe.sz);
}
}
void _ea_111_100_read_commit (void)
{
shoe.pc = shoe.uncommitted_ea_read_pc;
}
// illegal EA mode
void _ea_illegal (void)
{
throw_illegal_instruction();
}
// nothing to do
void _ea_nop (void)
{
}
const _ea_func ea_read_jump_table[64] = {
// Data register direct mode
_ea_000_read,
_ea_000_read,
_ea_000_read,
_ea_000_read,
_ea_000_read,
_ea_000_read,
_ea_000_read,
_ea_000_read,
// address register direct mode
_ea_001_read,
_ea_001_read,
_ea_001_read,
_ea_001_read,
_ea_001_read,
_ea_001_read,
_ea_001_read,
_ea_001_read,
// address register indirect mode
_ea_010_read,
_ea_010_read,
_ea_010_read,
_ea_010_read,
_ea_010_read,
_ea_010_read,
_ea_010_read,
_ea_010_read,
// address register indirect with postincrement mode
_ea_011_read,
_ea_011_read,
_ea_011_read,
_ea_011_read,
_ea_011_read,
_ea_011_read,
_ea_011_read,
_ea_011_read,
// address register indirect with predecrement mode
_ea_100_read,
_ea_100_read,
_ea_100_read,
_ea_100_read,
_ea_100_read,
_ea_100_read,
_ea_100_read,
_ea_100_read,
// address register indirect with displacement mode
_ea_101_read,
_ea_101_read,
_ea_101_read,
_ea_101_read,
_ea_101_read,
_ea_101_read,
_ea_101_read,
_ea_101_read,
// memory/address register indirect with index
_ea_110_read,
_ea_110_read,
_ea_110_read,
_ea_110_read,
_ea_110_read,
_ea_110_read,
_ea_110_read,
_ea_110_read,
// absolute short addressing mode
_ea_111_000_read,
// absolute long addressing mode
_ea_111_001_read,
// program counter indirect with displacement mode
_ea_111_010_read,
// program counter indirect with index
_ea_111_011_read,
// immediate
_ea_111_100_read,
// The rest are illegal EA modes
_ea_illegal,
_ea_illegal,
_ea_illegal
};
const _ea_func ea_read_commit_jump_table[64] = {
// Data register direct mode
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
// address register direct mode
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
// address register indirect mode
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
_ea_nop,
// address register indirect with postincrement mode
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
_ea_011_read_commit,
// address register indirect with predecrement mode
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
_ea_100_read_commit,
// address register indirect with displacement mode
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
_ea_101_read_commit,
// memory/address register indirect with index
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
_ea_110_read_commit,
// absolute short addressing mode
_ea_111_000_read_commit,
// absolute long addressing mode
_ea_111_001_read_commit,
// program counter indirect with displacement mode
_ea_111_010_read_commit,
// program counter indirect with index
_ea_111_011_read_commit,
// immediate
_ea_111_100_read_commit,
// The rest are illegal EA modes
NULL,
NULL,
NULL
};
const _ea_func ea_write_jump_table[64] = {
// Data register direct mode
_ea_000_write,
_ea_000_write,
_ea_000_write,
_ea_000_write,
_ea_000_write,
_ea_000_write,
_ea_000_write,
_ea_000_write,
// address register direct mode
_ea_001_write,
_ea_001_write,
_ea_001_write,
_ea_001_write,
_ea_001_write,
_ea_001_write,
_ea_001_write,
_ea_001_write,
// address register indirect mode
_ea_010_write,
_ea_010_write,
_ea_010_write,
_ea_010_write,
_ea_010_write,
_ea_010_write,
_ea_010_write,
_ea_010_write,
// address register indirect with postincrement mode
_ea_011_write,
_ea_011_write,
_ea_011_write,
_ea_011_write,
_ea_011_write,
_ea_011_write,
_ea_011_write,
_ea_011_write,
// address register indirect with predecrement mode
_ea_100_write,
_ea_100_write,
_ea_100_write,
_ea_100_write,
_ea_100_write,
_ea_100_write,
_ea_100_write,
_ea_100_write,
// address register indirect with displacement mode
_ea_101_write,
_ea_101_write,
_ea_101_write,
_ea_101_write,
_ea_101_write,
_ea_101_write,
_ea_101_write,
_ea_101_write,
// memory/address register indirect with index
_ea_110_write,
_ea_110_write,
_ea_110_write,
_ea_110_write,
_ea_110_write,
_ea_110_write,
_ea_110_write,
_ea_110_write,
// absolute short addressing mode
_ea_111_000_write,
// absolute long addressing mode
_ea_111_001_write,
// program counter indirect with displacement mode
_ea_illegal,
// program counter indirect with index
_ea_illegal,
// immediate
_ea_illegal,
// The rest are illegal EA modes
_ea_illegal,
_ea_illegal,
_ea_illegal
};
const _ea_func ea_addr_jump_table[64] = {
// Data register direct mode
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
// address register direct mode
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
// address register indirect mode
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
_ea_010_addr,
// address register indirect with postincrement mode
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
// address register indirect with predecrement mode
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
_ea_illegal,
// address register indirect with displacement mode
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
_ea_101_addr,
// memory/address register indirect with index
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
_ea_110_addr,
// absolute short addressing mode
_ea_111_000_addr,
// absolute long addressing mode
_ea_111_001_addr,
// program counter indirect with displacement mode
_ea_111_010_addr,
// program counter indirect with index
_ea_111_011_addr,
// immediate
_ea_illegal,
// The rest are illegal EA modes
_ea_illegal,
_ea_illegal,
_ea_illegal
};
| 30.458846 | 119 | 0.608834 |
47c77ba9ac84793ff5c0416b3dbf7ef21a2ad6f7 | 211 | h | C | ZHDatePicker/ViewController.h | zhhlmr/ZHDatePicker | 9b65f24090b6d6610f2fa3fd906e068ab74c4bd0 | [
"MIT"
] | 7 | 2016-04-30T04:51:32.000Z | 2021-03-16T06:47:50.000Z | ZHDatePicker/ViewController.h | zhhlmr/ZHDatePicker | 9b65f24090b6d6610f2fa3fd906e068ab74c4bd0 | [
"MIT"
] | 1 | 2017-07-19T15:03:47.000Z | 2017-07-21T06:53:57.000Z | ZHDatePicker/ViewController.h | zhhlmr/ZHDatePicker | 9b65f24090b6d6610f2fa3fd906e068ab74c4bd0 | [
"MIT"
] | 3 | 2016-04-30T04:51:32.000Z | 2016-07-11T10:45:32.000Z | //
// ViewController.h
// ZHDatePicker
//
// Created by heyz3a on 16/4/19.
// Copyright © 2016年 heyz3a. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
| 13.1875 | 50 | 0.687204 |
df8c4cdcf69e7049e7ef654fd868ddb0049e9e90 | 857 | c | C | algoritmi/esercizi/2021-11-12/notazione/infissa_to_postfissa.c | Daniele001/university | 86c216ec0122863d4a20ba45c3a97019d0253409 | [
"MIT"
] | null | null | null | algoritmi/esercizi/2021-11-12/notazione/infissa_to_postfissa.c | Daniele001/university | 86c216ec0122863d4a20ba45c3a97019d0253409 | [
"MIT"
] | null | null | null | algoritmi/esercizi/2021-11-12/notazione/infissa_to_postfissa.c | Daniele001/university | 86c216ec0122863d4a20ba45c3a97019d0253409 | [
"MIT"
] | null | null | null | #include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "../item/item.h"
#include "../stack/stack.h"
int main() {
char ch;
while((ch = getchar()) != '\n') {
char *str = malloc(2 * sizeof(char));
str[1] = '\0';
if(isdigit(ch)) {
*str = ch;
print_item(atoitem(str));
printf(" ");
} else {
switch(ch) {
case '/':
case '*':
case '-':
case '+':
*str = ch;
push(atoitem(str));
break;
case ')':
str = pop();
print_item(atoitem(str));
printf(" ");
free(str);
break;
}
}
}
}
| 20.404762 | 45 | 0.334889 |
f175f29ef137489cde3fcd00316de1ac67802b3f | 449 | c | C | bsearch.c | gonearewe/C-Learning | a107eea96edda1e0f54adde83e91c90f32b910c7 | [
"MIT"
] | null | null | null | bsearch.c | gonearewe/C-Learning | a107eea96edda1e0f54adde83e91c90f32b910c7 | [
"MIT"
] | null | null | null | bsearch.c | gonearewe/C-Learning | a107eea96edda1e0f54adde83e91c90f32b910c7 | [
"MIT"
] | null | null | null | /* bsearch example */
#include <stdio.h>
#include <stdlib.h>
int cmp (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int values[] = { 10, 20, 25, 40, 90, 100 };
int main ()
{
int * pItem;
int key = 40;
pItem = (int*) bsearch (&key, values, 6, sizeof (int), cmp);
if (pItem!=NULL)
printf ("%d is in the array.\n",*pItem);
else
printf ("%d is not in the array.\n",key);
return 0;
} //40 is in the array | 20.409091 | 62 | 0.556793 |
47f0aa128ed25909a5f6464f4cc1c21846c0e1a8 | 777 | h | C | LearnDemo/LearnDemo/HcdGuideView/HcdGuideViewManager.h | Gaolili/GuideToolDemo | f629a8c7bd48d7da12b3d2a8a4b869d7a76bf2ce | [
"MIT"
] | null | null | null | LearnDemo/LearnDemo/HcdGuideView/HcdGuideViewManager.h | Gaolili/GuideToolDemo | f629a8c7bd48d7da12b3d2a8a4b869d7a76bf2ce | [
"MIT"
] | null | null | null | LearnDemo/LearnDemo/HcdGuideView/HcdGuideViewManager.h | Gaolili/GuideToolDemo | f629a8c7bd48d7da12b3d2a8a4b869d7a76bf2ce | [
"MIT"
] | null | null | null | //
// HcdGuideViewManager.h
// HcdGuideViewDemo
//
// Created by polesapp-hcd on 16/7/12.
// Copyright © 2016年 Polesapp. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface HcdGuideViewManager : UIViewController
/**
* 创建单例模式
*
* @return 单例
*/
+ (instancetype)sharedInstance;
/**
* 引导页图片
*
* @param images 引导页图片
* @param title 按钮文字
* @param titleColor 文字颜色
* @param bgColor 按钮背景颜色
* @param borderColor 按钮边框颜色
*/
- (UIViewController *)showGuideViewWithImages:(NSArray *)images
andButtonTitle:(NSString *)title
andButtonTitleColor:(UIColor *)titleColor
andButtonBGColor:(UIColor *)bgColor
andButtonBorderColor:(UIColor *)borderColor;
@end
| 21 | 63 | 0.656371 |
a8a91390bd2ec0db7a72611a3b7cb6717905de89 | 3,721 | h | C | include/thread_binding.h | eth-cscs/DLA-interface | 78e24b875601e8830df7bfac18d2f47de39acb9b | [
"BSD-3-Clause"
] | 9 | 2018-05-14T12:31:07.000Z | 2022-01-14T10:09:27.000Z | include/thread_binding.h | eth-cscs/DLA-interface | 78e24b875601e8830df7bfac18d2f47de39acb9b | [
"BSD-3-Clause"
] | 42 | 2018-01-23T13:17:04.000Z | 2022-02-25T13:47:02.000Z | include/thread_binding.h | eth-cscs/DLA-interface | 78e24b875601e8830df7bfac18d2f47de39acb9b | [
"BSD-3-Clause"
] | 2 | 2018-04-27T07:33:47.000Z | 2019-04-11T14:06:56.000Z | #ifndef DLA_INTERFACE_THREAD_BINDING_H
#define DLA_INTERFACE_THREAD_BINDING_H
#ifdef DLAI_WITH_HWLOC
#include <hwloc.h>
#endif
#include <cstdlib>
#include <iostream>
#include <string>
namespace dla_interface {
namespace thread {
#ifdef DLAI_WITH_HWLOC
class CpuSet {
public:
CpuSet() : cpuset_(hwloc_bitmap_alloc()) {}
CpuSet(const CpuSet& rhs) : cpuset_(hwloc_bitmap_dup(rhs.cpuset_)) {}
CpuSet(CpuSet&& rhs) : cpuset_(rhs.cpuset_) {
rhs.cpuset_ = nullptr;
}
~CpuSet() {
if (cpuset_) {
hwloc_bitmap_free(cpuset_);
}
}
CpuSet& operator=(const CpuSet& rhs) {
hwloc_bitmap_copy(cpuset_, rhs.cpuset_);
return *this;
}
CpuSet& operator=(CpuSet&& rhs) {
std::swap(cpuset_, rhs.cpuset_);
return *this;
}
bool operator==(const CpuSet& rhs) const {
return hwloc_bitmap_compare(cpuset_, rhs.cpuset_) == 0;
}
bool operator!=(const CpuSet& rhs) const {
return !operator==(rhs);
}
void add(unsigned int id) {
hwloc_bitmap_set(cpuset_, id);
}
void remove(unsigned int id) {
hwloc_bitmap_clr(cpuset_, id);
}
std::string str() const {
char* tmp;
hwloc_bitmap_asprintf(&tmp, cpuset_);
std::string str(tmp);
std::free(tmp);
return str;
}
const hwloc_cpuset_t hwlocPtr() const {
return cpuset_;
}
hwloc_cpuset_t hwlocPtr() {
return cpuset_;
}
private:
hwloc_cpuset_t cpuset_;
};
class SystemTopology {
public:
SystemTopology() {
hwloc_topology_init(&topo_);
hwloc_topology_load(topo_);
}
SystemTopology(const SystemTopology& rhs) : topo_(nullptr) {
hwloc_topology_dup(&topo_, rhs.topo_);
}
SystemTopology(SystemTopology&& rhs) : topo_(rhs.topo_) {
rhs.topo_ = nullptr;
}
~SystemTopology() {
if (topo_) {
hwloc_topology_destroy(topo_);
}
}
SystemTopology& operator=(const SystemTopology& rhs) {
hwloc_topology_destroy(topo_);
hwloc_topology_dup(&topo_, rhs.topo_);
return *this;
}
SystemTopology& operator=(SystemTopology&& rhs) {
std::swap(topo_, rhs.topo_);
return *this;
}
CpuSet getCpuBind() {
CpuSet cpuset;
hwloc_get_cpubind(topo_, cpuset.hwlocPtr(), HWLOC_CPUBIND_THREAD);
return cpuset;
}
void setCpuBind(const CpuSet& cpuset) {
printThreadBindingDebugInfo("setCpuBind called:\n Previous value:");
hwloc_set_cpubind(topo_, cpuset.hwlocPtr(), HWLOC_CPUBIND_THREAD);
printThreadBindingDebugInfo(" New value:");
}
hwloc_topology_t hwlocPtr() {
return topo_;
}
private:
void printThreadBindingDebugInfo(const char* str) {
#ifdef DLA_THREAD_DEBUG_INFO
auto tmp = getCpuBind();
std::cout << str << " " << tmp.str() << std::endl;
#endif
}
hwloc_topology_t topo_;
};
#else
class CpuSet {
public:
bool operator==(const CpuSet& /*rhs*/) const {
return true;
}
bool operator!=(const CpuSet& /*rhs*/) const {
return false;
}
void add(unsigned int /*id*/) {}
void remove(unsigned int /*id*/) {}
std::string str() const {
return "<Warning: Cpu binding not Enabled>";
}
};
class SystemTopology {
public:
CpuSet getCpuBind() {
return CpuSet();
}
void setCpuBind(const CpuSet& /*cpuset*/) {}
};
#endif
}
}
#endif // DLA_INTERFACE_THREAD_BINDING_H
| 23.550633 | 77 | 0.58237 |
4dcbea8b7c33ea567956fde58942228307de46d0 | 167 | h | C | TianmushanV1.1/Tianmushan/Classs/EditTemplate/SZCalendarPicker/TimeItem.h | jzxyouok/Tianmushan | 5f9f7c225b94a4d860039da4a903ac3a8dbbcdc7 | [
"Apache-2.0"
] | 2 | 2019-06-24T10:26:09.000Z | 2021-07-30T09:34:26.000Z | TianmushanV1.1/Tianmushan/Classs/EditTemplate/SZCalendarPicker/TimeItem.h | jzxyouok/Tianmushan | 5f9f7c225b94a4d860039da4a903ac3a8dbbcdc7 | [
"Apache-2.0"
] | null | null | null | TianmushanV1.1/Tianmushan/Classs/EditTemplate/SZCalendarPicker/TimeItem.h | jzxyouok/Tianmushan | 5f9f7c225b94a4d860039da4a903ac3a8dbbcdc7 | [
"Apache-2.0"
] | null | null | null |
#import <UIKit/UIKit.h>
@interface TimeItem : UICollectionViewCell
@property (nonatomic, strong) NSString *hour;
@property (nonatomic, assign) BOOL isSelect;
@end
| 16.7 | 45 | 0.760479 |
9e2fad9ce5e0f74563ba28958aa45ca4d2b550d5 | 2,327 | h | C | src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h | AlphaBu/XRT | 72d34d637d3292e56871f9384888e6aed73b5969 | [
"Apache-2.0"
] | 1 | 2020-09-24T09:43:25.000Z | 2020-09-24T09:43:25.000Z | src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h | AlphaBu/XRT | 72d34d637d3292e56871f9384888e6aed73b5969 | [
"Apache-2.0"
] | 11 | 2018-10-04T23:12:51.000Z | 2018-12-03T05:46:55.000Z | src/runtime_src/xdp/profile/plugin/hal_api_interface/xdp_api_interface.h | AlphaBu/XRT | 72d34d637d3292e56871f9384888e6aed73b5969 | [
"Apache-2.0"
] | 3 | 2021-03-12T00:39:52.000Z | 2021-03-25T20:42:22.000Z | /**
* Copyright (C) 2016-2020 Xilinx, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located 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 XDP_API_INTERFACE_DOT_H
#define XDP_API_INTERFACE_DOT_H
#include <string>
#include <map>
#include <vector>
#include "xdp/profile/device/device_intf.h"
#include "xdp/profile/database/database.h"
#include "core/include/experimental/xrt-next.h"
namespace xdp {
class HALAPIInterface
{
private:
std::map<xclDeviceHandle, DeviceIntf*> devices;
std::map<std::string, xclCounterResults> mFinalCounterResultsMap;
std::map<std::string, xclCounterResults> mRolloverCounterResultsMap;
std::map<std::string, xclCounterResults> mRolloverCountsMap;
private:
void calculateAIMRolloverResult(const std::string& key,
unsigned int numAIM,
xclCounterResults& counterResult,
bool firstReadAfterProgram);
void calculateAMRolloverResult(const std::string& key,
unsigned int numAM,
xclCounterResults& counterResults,
bool firstReadAfterProgram);
void recordAMResult(ProfileResults* results,
DeviceIntf* currDevice,
const std::string& key);
void recordAIMResult(ProfileResults* results,
DeviceIntf* currDevice,
const std::string& key);
void recordASMResult(ProfileResults* results,
DeviceIntf* currDevice,
const std::string& key);
public:
HALAPIInterface() ;
~HALAPIInterface();
void startProfiling(xclDeviceHandle);
void endProfiling();
void createProfileResults(xclDeviceHandle, void*);
void getProfileResults(xclDeviceHandle, void*);
void destroyProfileResults(xclDeviceHandle, void*);
void startCounters();
void stopCounters();
void readCounters();
void startTrace();
void stopTrace();
void readTrace();
} ;
}
#endif
| 28.378049 | 76 | 0.713795 |
9e630ead2fd18dee7e77a7cda930cb644049bde2 | 2,079 | h | C | src/include/R-libproj/wkt2_parser.h | jeroen/libproj | 993fc4f3531a7f902a7e518c4ce7b6d12ddd5c47 | [
"MIT"
] | 12 | 2020-08-06T07:08:24.000Z | 2021-10-06T15:08:21.000Z | src/include/R-libproj/wkt2_parser.h | jeroen/libproj | 993fc4f3531a7f902a7e518c4ce7b6d12ddd5c47 | [
"MIT"
] | 19 | 2020-08-11T15:44:19.000Z | 2022-01-16T00:06:03.000Z | src/include/R-libproj/wkt2_parser.h | jeroen/libproj | 993fc4f3531a7f902a7e518c4ce7b6d12ddd5c47 | [
"MIT"
] | 2 | 2020-08-07T02:32:32.000Z | 2020-08-27T10:57:21.000Z | /******************************************************************************
* Project: PROJ
* Purpose: WKT2 parser grammar
* Author: Even Rouault, <even.rouault at spatialys.com>
*
******************************************************************************
* Copyright (c) 2018 Even Rouault, <even.rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef PJ_WKT2_PARSER_H_INCLUDED
#define PJ_WKT2_PARSER_H_INCLUDED
#ifndef DOXYGEN_SKIP
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pj_wkt2_parse_context pj_wkt2_parse_context;
#include "R-libproj/wkt2_generated_parser.h"
void pj_wkt2_error( pj_wkt2_parse_context *context, const char *msg );
int pj_wkt2_lex(YYSTYPE* pNode, pj_wkt2_parse_context *context);
int pj_wkt2_parse(pj_wkt2_parse_context *context);
#ifdef __cplusplus
}
std::string pj_wkt2_parse(const std::string& wkt);
#endif
#endif /* #ifndef DOXYGEN_SKIP */
#endif /* PJ_WKT2_PARSER_H_INCLUDED */
| 37.8 | 79 | 0.683502 |
961ed5d2d175e0b93bd7521cbcdf0ec5028d941d | 15,144 | h | C | play-core-native-sdk/include/play/asset_pack.h | TeikyungKim/native-gamepad | 899ebdc4115a11d8a3539e19f71a5db73b3c7dc9 | [
"Apache-2.0"
] | null | null | null | play-core-native-sdk/include/play/asset_pack.h | TeikyungKim/native-gamepad | 899ebdc4115a11d8a3539e19f71a5db73b3c7dc9 | [
"Apache-2.0"
] | null | null | null | play-core-native-sdk/include/play/asset_pack.h | TeikyungKim/native-gamepad | 899ebdc4115a11d8a3539e19f71a5db73b3c7dc9 | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 Google LLC
//
// The Play Core Native SDK is licensed to you under the Play Core Software
// Development Kit Terms of Service -
// https://developer.android.com/guide/playcore/license.
// By using the Play Core Native SDK, you agree to the Play Core Software
// Development Kit Terms of Service.
#ifndef PLAY_ASSET_PACK_H_
#define PLAY_ASSET_PACK_H_
#include <jni.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/// @defgroup assetpack Play Asset Delivery
/// Native API for Play Asset Delivery
/// @{
/// An error code associated with asset pack operations.
enum AssetPackErrorCode {
//// There was no error with the request.
ASSET_PACK_NO_ERROR = 0,
/// The requesting app is unavailable.
///
/// This could be caused by multiple reasons:
/// - The app isn't published in the Play Store.
/// - The app version code isn't published in the Play Store. Note: an older
/// version may exist.
/// - The app is only available on a testing track that the user doesn't have
/// access to, for example internal testing.
ASSET_PACK_APP_UNAVAILABLE = -1,
/// The requested asset pack isn't available for this app version.
///
/// This can happen if the asset pack wasn't included in the Android App
/// Bundle that was published to the Play Store.
ASSET_PACK_UNAVAILABLE = -2,
/// The request is invalid.
ASSET_PACK_INVALID_REQUEST = -3,
/// The requested download isn't found.
ASSET_PACK_DOWNLOAD_NOT_FOUND = -4,
/// The Asset Pack API is unavailable.
ASSET_PACK_API_NOT_AVAILABLE = -5,
/// Network error. Unable to obtain asset pack details.
ASSET_PACK_NETWORK_ERROR = -6,
/// Download isn't permitted under current device circumstances, for example
/// the app is running in the background or the device isn't signed into a
/// Google account.
ASSET_PACK_ACCESS_DENIED = -7,
/// Asset packs download failed due to insufficient storage.
ASSET_PACK_INSUFFICIENT_STORAGE = -10,
/// The Play Store app is either not installed or not the official version.
ASSET_PACK_PLAY_STORE_NOT_FOUND = -11,
/// Returned if showCellularDataConfirmation is called but no asset packs are
/// waiting for Wi-Fi.
ASSET_PACK_NETWORK_UNRESTRICTED = -12,
/// The app isn't owned by any user on this device. An app is "owned" if it
/// has been acquired from the Play Store.
ASSET_PACK_APP_NOT_OWNED = -13,
/// Unknown error downloading asset pack.
ASSET_PACK_INTERNAL_ERROR = -100,
/// The requested operation failed: need to call AssetPackManager_init()
/// first.
ASSET_PACK_INITIALIZATION_NEEDED = -101,
/// There was an error initializing the Asset Pack API.
ASSET_PACK_INITIALIZATION_FAILED = -102,
};
/// The status associated with asset pack download operations.
enum AssetPackDownloadStatus {
/// Nothing is known about the asset pack. Call AssetPackManager_requestInfo()
/// to check its size or AssetPackManager_requestDownload() start a download.
ASSET_PACK_UNKNOWN = 0,
/// An AssetPackManager_requestDownload() async request is pending.
ASSET_PACK_DOWNLOAD_PENDING = 1,
/// The asset pack download is in progress.
ASSET_PACK_DOWNLOADING = 2,
/// The asset pack is being transferred to the app.
ASSET_PACK_TRANSFERRING = 3,
/// Download and transfer are complete; the assets are available to the app.
ASSET_PACK_DOWNLOAD_COMPLETED = 4,
/// An AssetPackManager_requestDownload() has failed.
///
/// AssetPackErrorCode will be the corresponding error, never
/// ASSET_PACK_NO_ERROR. The bytes_downloaded and total_bytes_to_download
/// fields are unreliable given this status.
ASSET_PACK_DOWNLOAD_FAILED = 5,
/// Asset pack download has been canceled.
ASSET_PACK_DOWNLOAD_CANCELED = 6,
/// The asset pack download is waiting for Wi-Fi to proceed.
///
/// Optionally, call AssetPackManager_showCellularDataConfirmation() to ask
/// the user to confirm downloading over cellular data.
ASSET_PACK_WAITING_FOR_WIFI = 7,
/// The asset pack isn't installed.
ASSET_PACK_NOT_INSTALLED = 8,
/// An AssetPackManager_requestInfo() async request started, but the result
/// isn't known yet.
ASSET_PACK_INFO_PENDING = 100,
/// An AssetPackManager_requestInfo() async request has failed.
///
/// AssetPackErrorCode will be the corresponding error, never
/// ASSET_PACK_NO_ERROR. The bytes_downloaded and total_bytes_to_download
/// fields are unreliable given this status.
ASSET_PACK_INFO_FAILED = 101,
/// An AssetPackManager_requestRemoval() async request started.
ASSET_PACK_REMOVAL_PENDING = 110,
/// An AssetPackManager_requestRemoval() async request has failed.
ASSET_PACK_REMOVAL_FAILED = 111,
};
/// The method used to store an asset pack on the device.
enum AssetPackStorageMethod {
/// The asset pack is unpacked into a folder containing individual asset
/// files.
///
/// Assets can be accessed via standard File APIs.
ASSET_PACK_STORAGE_FILES = 0,
/// The asset pack is installed as an APK containing packed asset files.
///
/// Assets can be accessed via AAssetManager.
ASSET_PACK_STORAGE_APK = 1,
/// Nothing is known, perhaps due to an error.
ASSET_PACK_STORAGE_UNKNOWN = 100,
/// The asset pack isn't installed.
ASSET_PACK_STORAGE_NOT_INSTALLED = 101,
};
/// The status associated with a request to display a cellular data confirmation
/// dialog.
enum ShowCellularDataConfirmationStatus {
/// AssetPackManager_showCellularDataConfirmation() has not been called.
ASSET_PACK_CONFIRM_UNKNOWN = 0,
/// AssetPackManager_showCellularDataConfirmation() has been called, but the
/// user hasn't made a choice.
ASSET_PACK_CONFIRM_PENDING = 1,
/// The user approved of downloading asset packs over cellular data.
ASSET_PACK_CONFIRM_USER_APPROVED = 2,
/// The user declined to download asset packs over cellular data.
ASSET_PACK_CONFIRM_USER_CANCELED = 3,
};
/// An opaque struct used to access the state of an individual asset pack
/// including download status and download size.
typedef struct AssetPackDownloadState_ AssetPackDownloadState;
/// An opaque struct used to access how and where an asset pack's assets
/// are stored on the device.
typedef struct AssetPackLocation_ AssetPackLocation;
/// Initialize the Asset Pack API, making the other functions available to call.
///
/// In case of failure the Asset Pack API is unavailable, and there will be an
/// error in logcat. The most common reason for failure is that the PlayCore AAR
/// is missing or some of its classes/methods weren't retained by ProGuard.
/// @param jvm The app's single JavaVM, for example from ANativeActivity's "vm"
/// field.
/// @param android_context An Android Context, for example from
/// ANativeActivity's "clazz" field.
/// @return ASSET_PACK_NO_ERROR if initialization succeeded.
/// @see AssetPackManager_destroy
AssetPackErrorCode AssetPackManager_init(JavaVM* jvm, jobject android_context);
/// Frees up memory allocated for the Asset Pack API. Does nothing if
/// AssetPackManager_init() hasn't been called.
void AssetPackManager_destroy();
/// Registers an internal state update listener. Must be called in
/// ANativeActivity ANativeActivityCallbacks's onResume, or equivalent.
/// @return ASSET_PACK_NO_ERROR if the call succeeded, or an error if not.
AssetPackErrorCode AssetPackManager_onResume();
/// Deregisters an internal state update listener. Must be called in
/// ANativeActivity ANativeActivityCallbacks's onPause, or equivalent.
/// @return ASSET_PACK_NO_ERROR if the call succeeded, or an error if not.
AssetPackErrorCode AssetPackManager_onPause();
/// Asynchronously requests download info about the specified asset packs. Use
/// AssetPackManager_getDownloadState() to monitor progress and get the result.
/// @param asset_packs An array of asset pack names.
/// @param num_asset_packs The length of the asset_packs array.
/// @return ASSET_PACK_NO_ERROR if the request started successfully.
AssetPackErrorCode AssetPackManager_requestInfo(const char** asset_packs,
size_t num_asset_packs);
/// Asynchronously requests to start downloading the specified asset packs.
/// Use AssetPackManager_getDownloadState() to monitor download progress.
/// This request will fail if the app isn't in the foreground.
/// @param asset_packs An array of asset pack names.
/// @param num_asset_packs The length of the asset_packs array.
/// @return ASSET_PACK_NO_ERROR if the request started successfully.
AssetPackErrorCode AssetPackManager_requestDownload(const char** asset_packs,
size_t num_asset_packs);
/// Cancels downloading the specified asset packs.
///
/// Note: Only active downloads will be canceled. Asset packs with a status of
/// ASSET_PACK_DOWNLOAD_COMPLETED or ASSET_PACK_NOT_INSTALLED are unaffected by
/// this method.
/// @param asset_packs An array of asset pack names.
/// @param num_asset_packs The length of the asset_packs array.
/// @return Always ASSET_PACK_NO_ERROR, except in the case of an invalid call
/// such as ASSET_PACK_INITIALIZATION_NEEDED or ASSET_PACK_INVALID_REQUEST.
AssetPackErrorCode AssetPackManager_cancelDownload(const char** asset_packs,
size_t num_asset_packs);
/// Asynchronously requests to delete the specified asset pack from internal
/// storage. Use AssetPackManager_getDownloadState() to check deletion progress.
///
/// Use this function to delete asset packs instead of deleting the files
/// manually. This ensures that the asset pack won't be re-downloaded during an
/// app update.
///
/// If the asset pack is currently being downloaded or installed, this function
/// won't cancel that operation.
/// @param name An asset pack name.
/// @return ASSET_PACK_NO_ERROR if the request started successfully.
AssetPackErrorCode AssetPackManager_requestRemoval(const char* name);
/// Gets the download state of the specified asset pack.
///
/// The last known error code is returned directly, whereas other state can be
/// obtained via the AssetPackDownloadState out parameter by using functions
/// such as AssetPackDownloadState_getStatus().
///
/// This function can be used to monitor progress or get the final result of a
/// call to AssetPackManager_requestInfo(), AssetPackManager_requestDownload(),
/// or AssetPackManager_requestRemoval(). This method does not make any JNI
/// calls and can be called every frame.
/// @param name An asset pack name.
/// @param out_state An out parameter for receiving the result.
/// @return ASSET_PACK_NO_ERROR if the request started successfully.
/// @see AssetPackDownloadState_destroy
AssetPackErrorCode AssetPackManager_getDownloadState(
const char* name, AssetPackDownloadState** out_state);
/// Releases the specified AssetPackDownloadState and any references it holds.
/// @param state The state to free.
void AssetPackDownloadState_destroy(AssetPackDownloadState* state);
/// Gets the AssetPackDownloadStatus for the specified AssetPackDownloadState.
/// @param state The state for which to get status.
/// @return The AssetPackDownloadStatus.
AssetPackDownloadStatus AssetPackDownloadState_getStatus(
AssetPackDownloadState* state);
/// Gets the total number of bytes already downloaded for the asset pack
/// associated with the specified AssetPackDownloadState.
/// @param state The state for which to get bytes downloaded.
/// @return The total number of bytes already downloaded.
uint64_t AssetPackDownloadState_getBytesDownloaded(
AssetPackDownloadState* state);
/// Gets the total size in bytes for the asset pack associated with the
/// specified AssetPackDownloadState.
/// @param state The state for which to get total bytes to download.
/// @return The total size in bytes for the asset pack.
uint64_t AssetPackDownloadState_getTotalBytesToDownload(
AssetPackDownloadState* state);
/// Shows a confirmation dialog to resume all asset pack downloads that are
/// currently in the ASSET_PACK_WAITING_FOR_WIFI state. If the user agrees to
/// the dialog prompt, asset packs are downloaded over cellular data.
//
/// The status of an asset pack is set to ASSET_PACK_WAITING_FOR_WIFI if the
/// user is currently not on a Wi-Fi connection and the asset pack is large or
/// the user has set their download preference in the Play Store to only
/// download apps over Wi-Fi. By showing this dialog, your app can ask the user
/// if they accept downloading the asset pack over cellular data instead of
/// waiting for Wi-Fi.
/// @param android_activity An Android Activity, for example from
/// ANativeActivity's "clazz" field.
/// @return ASSET_PACK_NO_ERROR if the dialog is shown. Call
/// AssetPackManager_getShowCellularDataConfirmationStatus() to get the dialog
/// result.
AssetPackErrorCode AssetPackManager_showCellularDataConfirmation(
jobject android_activity);
/// Gets the status of AssetPackManager_showCellularDataConfirmation() requests.
///
/// This function does not make any JNI calls and can be called every frame.
/// @param out_status An out parameter for receiving the result.
/// @return An AssetPackErrorCode, which if not ASSET_PACK_NO_ERROR indicates
/// that the out parameter should not be used.
AssetPackErrorCode AssetPackManager_getShowCellularDataConfirmationStatus(
ShowCellularDataConfirmationStatus* out_status);
/// Obtains an AssetPackLocation for the specified asset pack that can be used
/// to query how and where the asset pack's assets are stored on the device.
/// @param name An asset pack name.
/// @param out_location An out parameter for receiving the result.
/// @return An AssetPackErrorCode, which if not ASSET_PACK_NO_ERROR indicates
/// that the out parameter shouldn't be used.
/// @see AssetPackLocation_destroy
AssetPackErrorCode AssetPackManager_getAssetPackLocation(
const char* name, AssetPackLocation** out_location);
/// Releases the specified AssetPackLocation and any references it holds.
/// @param location The location to free.
void AssetPackLocation_destroy(AssetPackLocation* location);
/// Gets the AssetPackStorageMethod for the specified asset pack.
/// @param location The location for which to get a storage method.
/// @return The AssetPackStorageMethod for the specified asset pack.
AssetPackStorageMethod AssetPackLocation_getStorageMethod(
AssetPackLocation* location);
/// Gets a file path to the directory containing the asset pack's unpackaged
/// assets. The files found in this path should not be modified.
///
/// The string returned here is owned by the AssetPackManager implementation and
/// will be freed by calling AssetPackLocation_destroy().
/// @param location The location from which to obtain the assets path.
/// @return A file path to the directory containing the asset pack's unpackaged
/// assets, provided that the asset pack's storage method is
/// ASSET_PACK_STORAGE_FILES. Otherwise, returns a null pointer.
const char* AssetPackLocation_getAssetsPath(AssetPackLocation* location);
/// @}
#ifdef __cplusplus
}; // extern "C"
#endif
#endif // PLAY_ASSET_PACK_H_
| 41.950139 | 80 | 0.763339 |
9644db0753ad3db8f2dbfa2090b0792123bc919c | 1,348 | h | C | src/xenia/gpu/gl4/gl4_graphics_system.h | Hevmo79/ninja- | d35ee68d678935f230a4461099fca8523ede5aa5 | [
"BSD-3-Clause"
] | 1 | 2016-12-28T08:15:30.000Z | 2016-12-28T08:15:30.000Z | src/xenia/gpu/gl4/gl4_graphics_system.h | Hevmo79/ninja- | d35ee68d678935f230a4461099fca8523ede5aa5 | [
"BSD-3-Clause"
] | null | null | null | src/xenia/gpu/gl4/gl4_graphics_system.h | Hevmo79/ninja- | d35ee68d678935f230a4461099fca8523ede5aa5 | [
"BSD-3-Clause"
] | 1 | 2021-03-30T08:41:12.000Z | 2021-03-30T08:41:12.000Z | /**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_GPU_GL4_GL4_GRAPHICS_SYSTEM_H_
#define XENIA_GPU_GL4_GL4_GRAPHICS_SYSTEM_H_
#include <memory>
#include "xenia/gpu/graphics_system.h"
#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {
namespace gl4 {
class GL4GraphicsSystem : public GraphicsSystem {
public:
GL4GraphicsSystem();
~GL4GraphicsSystem() override;
std::wstring name() const override { return L"GL4"; }
X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state,
ui::Window* target_window) override;
void Shutdown() override;
private:
std::unique_ptr<CommandProcessor> CreateCommandProcessor() override;
void Swap(xe::ui::UIEvent* e) override;
xe::ui::gl::GLContext* display_context_ = nullptr;
};
} // namespace gl4
} // namespace gpu
} // namespace xe
#endif // XENIA_GPU_GL4_GL4_GRAPHICS_SYSTEM_H_
| 29.304348 | 79 | 0.570475 |
fde8167f37530c038f5f738226e7e975c9e1377c | 639 | h | C | hashtable/libcuckoo.h | WqyJh/libhashtable | deddc946419d2a9b16235ee92f60f0100e5e6fa3 | [
"MIT"
] | null | null | null | hashtable/libcuckoo.h | WqyJh/libhashtable | deddc946419d2a9b16235ee92f60f0100e5e6fa3 | [
"MIT"
] | null | null | null | hashtable/libcuckoo.h | WqyJh/libhashtable | deddc946419d2a9b16235ee92f60f0100e5e6fa3 | [
"MIT"
] | null | null | null |
#ifndef _LIBCUCKOO_HASH_H_
#define _LIBCUCKOO_HASH_H_
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct cuckoo_hash;
struct cuckoo_hash *cuckoo_hash_create(int capacity);
void cuckoo_hash_free(struct cuckoo_hash *h);
bool cuckoo_hash_insert(struct cuckoo_hash *h, const void *key, void *data);
bool cuckoo_hash_erase(struct cuckoo_hash *h, const void *key);
bool cuckoo_hash_find(struct cuckoo_hash *h, const void *key, void **data);
int32_t cuckoo_hash_iterate(struct cuckoo_hash *h, const void **key, void **data, uint32_t *next);
#ifdef __cplusplus
}
#endif
#endif // _LIBCUCKOO_HASH_H_
| 20.612903 | 98 | 0.774648 |
ca6cf1ba4b57a956d3bdcafc47af8b2025451033 | 3,047 | h | C | tests/binutils-2.30/src/include/aout/dynix3.h | sillywalk/grazz | a0adb1a90d41ff9006d8c1476546263f728b3c83 | [
"Apache-2.0"
] | null | null | null | tests/binutils-2.30/src/include/aout/dynix3.h | sillywalk/grazz | a0adb1a90d41ff9006d8c1476546263f728b3c83 | [
"Apache-2.0"
] | null | null | null | tests/binutils-2.30/src/include/aout/dynix3.h | sillywalk/grazz | a0adb1a90d41ff9006d8c1476546263f728b3c83 | [
"Apache-2.0"
] | null | null | null | /* a.out specifics for Sequent Symmetry running Dynix 3.x
Copyright (C) 2001-2018 Free Software Foundation, Inc.
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 3 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. */
#ifndef A_OUT_DYNIX3_H
#define A_OUT_DYNIX3_H
#define external_exec dynix_external_exec
/* struct exec for Dynix 3
a_gdtbl and a_bootstrap are only for standalone binaries.
Shared data fields are not supported by the kernel as of Dynix 3.1,
but are supported by Dynix compiler programs. */
struct dynix_external_exec
{
unsigned char e_info[4];
unsigned char e_text[4];
unsigned char e_data[4];
unsigned char e_bss[4];
unsigned char e_syms[4];
unsigned char e_entry[4];
unsigned char e_trsize[4];
unsigned char e_drsize[4];
unsigned char e_g_code[8];
unsigned char e_g_data[8];
unsigned char e_g_desc[8];
unsigned char e_shdata[4];
unsigned char e_shbss[4];
unsigned char e_shdrsize[4];
unsigned char e_bootstrap[44];
unsigned char e_reserved[12];
unsigned char e_version[4];
};
#define EXEC_BYTES_SIZE (128)
/* All executables under Dynix are demand paged with read-only text,
Thus no NMAGIC.
ZMAGIC has a page of 0s at virtual 0,
XMAGIC has an invalid page at virtual 0. */
#define OMAGIC 0x12eb /* .o */
#define ZMAGIC 0x22eb /* zero @ 0, demand load */
#define XMAGIC 0x32eb /* invalid @ 0, demand load */
#define SMAGIC 0x42eb /* standalone, not supported here */
#define N_BADMAG(x) ((OMAGIC != N_MAGIC(x)) && \
(ZMAGIC != N_MAGIC(x)) && \
(XMAGIC != N_MAGIC(x)) && \
(SMAGIC != N_MAGIC(x)))
#define N_ADDRADJ(x) ((ZMAGIC == N_MAGIC(x) || XMAGIC == N_MAGIC(x)) ? 0x1000 : 0)
#define N_TXTOFF(x) (EXEC_BYTES_SIZE)
#define N_DATOFF(x) (N_TXTOFF(x) + N_TXTSIZE(x))
#define N_SHDATOFF(x) (N_DATOFF(x) + (x)->a_data)
#define N_TRELOFF(x) (N_SHDATOFF(x) + (x)->a_shdata)
#define N_DRELOFF(x) (N_TRELOFF(x) + (x)->a_trsize)
#define N_SHDRELOFF(x) (N_DRELOFF(x) + (x)->a_drsize)
#define N_SYMOFF(x) (N_SHDRELOFF(x) + (x)->a_shdrsize)
#define N_STROFF(x) (N_SYMOFF(x) + (x)->a_syms)
#define N_TXTADDR(x) \
(((OMAGIC == N_MAGIC(x)) || (SMAGIC == N_MAGIC(x))) ? 0 \
: TEXT_START_ADDR + EXEC_BYTES_SIZE)
#define N_TXTSIZE(x) \
(((OMAGIC == N_MAGIC(x)) || (SMAGIC == N_MAGIC(x))) ? ((x)->a_text) \
: ((x)->a_text - N_ADDRADJ(x) - EXEC_BYTES_SIZE))
#endif /* A_OUT_DYNIX3_H */
| 34.625 | 82 | 0.689859 |
a6162930d6757e4d890c72e01b1977e7a043ce7a | 931 | h | C | externals/LuaCore.framework/Versions/A/Headers/LCLuaFoundation.h | AlloSphere-Research-Group/DeviceServer | 6c7e55f445d30c646bdf6d124f68823564af60d0 | [
"MIT"
] | null | null | null | externals/LuaCore.framework/Versions/A/Headers/LCLuaFoundation.h | AlloSphere-Research-Group/DeviceServer | 6c7e55f445d30c646bdf6d124f68823564af60d0 | [
"MIT"
] | null | null | null | externals/LuaCore.framework/Versions/A/Headers/LCLuaFoundation.h | AlloSphere-Research-Group/DeviceServer | 6c7e55f445d30c646bdf6d124f68823564af60d0 | [
"MIT"
] | null | null | null |
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
extern int luaToNSString (lua_State *lua);
extern int nsToLuaString (lua_State *lua);
extern int luaToNSRange(lua_State *lua);
extern int nsToLuaRange(lua_State *lua);
extern int luaToNSPoint(lua_State *lua);
extern int nsToLuaPoint(lua_State *lua);
extern int luaToNSRect(lua_State *lua);
extern int nsToLuaRect(lua_State *lua);
extern int luaNSMakeRect(lua_State *lua);
extern int nsBeep(lua_State *lua);
extern int nsAlert(lua_State *lua);
NSString *stringFromArgument(lua_State *lua, int idx);
NSDictionary * dictionaryFromCurrentTable(lua_State *lua);
NSArray * arrayFromCurrentTable(lua_State *lua);
NSArray * arrayFromTable(lua_State *lua, int argIdx) ;
void lerror (lua_State *L, const char *fmt, ...);
void lua_objc_help_init(lua_State* state);
void lua_extrastring_init(lua_State* state);
| 23.871795 | 58 | 0.769066 |
e77d7bc68510a36fb839fec6be507db96e6d6503 | 3,372 | h | C | naoqi_driver/src/naoqi_joints_analyzer.h | k-okada/naoqi_bridge | adc7e0484edf324f1f21016664b7c5b30ad81dc9 | [
"BSD-3-Clause"
] | null | null | null | naoqi_driver/src/naoqi_joints_analyzer.h | k-okada/naoqi_bridge | adc7e0484edf324f1f21016664b7c5b30ad81dc9 | [
"BSD-3-Clause"
] | null | null | null | naoqi_driver/src/naoqi_joints_analyzer.h | k-okada/naoqi_bridge | adc7e0484edf324f1f21016664b7c5b30ad81dc9 | [
"BSD-3-Clause"
] | null | null | null | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright 2011 Stefan Osswald, University of Freiburg
* 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 the University of Freiburg 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.
*********************************************************************/
#ifndef NAO_JOINTS_ANALYZER_H
#define NAO_JOINTS_ANALYZER_H
#include <ros/ros.h>
#include <diagnostic_aggregator/analyzer.h>
#include <diagnostic_aggregator/status_item.h>
#include <diagnostic_msgs/DiagnosticStatus.h>
#include <pluginlib/class_list_macros.h>
#include <string>
#include <map>
namespace diagnostic_aggregator {
/**
* @brief Analyzes diagnostic messages about Nao's joints from nao_diagnostic/nao_diagnostic_updater.
*/
class NaoqiJointsAnalyzer: public Analyzer {
public:
NaoqiJointsAnalyzer();
~NaoqiJointsAnalyzer();
bool init(const std::string base_name, const ros::NodeHandle &n);
bool match(const std::string name);
bool analyze(const boost::shared_ptr<StatusItem> item);
std::vector<boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> > report();
std::string getPath() const {
return m_path;
}
std::string getName() const {
return m_niceName;
}
private:
std::string m_path, m_niceName;
boost::shared_ptr<StatusItem> m_jointsMasterItem;
boost::shared_ptr<StatusItem> m_statusItems;
ros::Time m_lastSeen;
struct JointData {
std::string name;
double temperature, stiffness;
boost::shared_ptr<diagnostic_aggregator::StatusItem> status;
};
typedef std::map<std::string, JointData> JointsMapType;
JointsMapType m_joints;
template<typename T> void addValue(boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> joint_stat, const std::string& key, const T& value) const;
static bool compareByTemperature(const NaoqiJointsAnalyzer::JointData& a, const NaoqiJointsAnalyzer::JointData& b);
};
}
#endif //NAO_JOINTS_ANALYZER_H
| 39.209302 | 147 | 0.742289 |
b77abf5e459cf1e76fe89167a8d6dad02cf19a2a | 2,638 | h | C | Analyzer/Link.h | jambolo/Sudoku | 786499bfd6a8c948e91a1cfff7d65d38330b9efb | [
"MIT"
] | 1 | 2021-12-24T07:29:41.000Z | 2021-12-24T07:29:41.000Z | Analyzer/Link.h | jambolo/Sudoku | 786499bfd6a8c948e91a1cfff7d65d38330b9efb | [
"MIT"
] | 1 | 2021-12-24T07:45:37.000Z | 2021-12-24T08:40:57.000Z | Analyzer/Link.h | jambolo/Sudoku | 786499bfd6a8c948e91a1cfff7d65d38330b9efb | [
"MIT"
] | null | null | null | #if !defined(ANALYZER_LINK_H_INCLUDED)
#define ANALYZER_LINK_H_INCLUDED 1
#pragma once
#include "Candidates.h"
#include <vector>
namespace Link
{
// In the solution, (*i0 == v0) ^ (*i1 == v1)
// Note that if i0 == i1, then v0 != v1 (the cell is a bi-value)
class Strong
{
public:
using List = std::vector<Strong>;
int v0; // Candidate value at i0
int v1; // Candidate value at i1
int i0; // Index of one node in the link
int i1; // Index of the other node in the link
// Returns all strong links to cell i
static List find(Candidates::List const & candidates, int i);
// Returns all strong links in the given group
static List find(Candidates::List const & candidates, std::vector<int> const & group);
// Returns true if a strong link exists between the two cells for the given value
static bool exists(Candidates::List const & candidates,
int i0,
int i1,
Candidates::Type mask,
std::vector<int> const & group);
// Returns true if a strong link exists between the two cells for the given value
static bool existsIncremental(Candidates::List const & candidates,
int u0,
int u1,
Candidates::Type mask,
std::vector<int> const & group);
private:
static List find(Candidates::List const & candidates, int i0, std::vector<int> const & group);
};
// In the solution, (*i0 != v0) | (*i1 != v0)
// Note that i0 != i1
class Weak
{
public:
using List = std::vector<Weak>;
int v0; // Value in common
int i0; // Index of one node in the link
int i1; // Index of the other node in the link
// Returns all weak links to cell i
static List find(Candidates::List const & candidates, int i);
// Returns all weak links in the given group
static List find(Candidates::List const & candidates, std::vector<int> const & group);
private:
static List find(Candidates::List const & candidates, int u0, std::vector<int> const & group);
static bool exists(Candidates::List const & candidates, int i0, int i1, Candidates::Type mask);
};
bool operator < (Strong const & lhs, Strong const & rhs);
bool operator == (Strong const & lhs, Strong const & rhs);
bool operator < (Weak const & lhs, Weak const & rhs);
bool operator == (Weak const & lhs, Weak const & rhs);
} // namespace Link
#endif // defined(ANALYZER_LINK_H_INCLUDED)
| 35.173333 | 99 | 0.598939 |
2be878f3908b271a84580154e3a4b093abdc89ac | 657 | h | C | DataCollector/mozilla/xulrunner-sdk/include/mozilla/jsipc/CpowHolder.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | 1 | 2016-04-20T08:35:44.000Z | 2016-04-20T08:35:44.000Z | DataCollector/mozilla/xulrunner-sdk/include/mozilla/jsipc/CpowHolder.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | null | null | null | DataCollector/mozilla/xulrunner-sdk/include/mozilla/jsipc/CpowHolder.h | andrasigneczi/TravelOptimiser | b08805f97f0823fd28975a36db67193386aceb22 | [
"Apache-2.0"
] | null | null | null | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sw=4 et tw=80:
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_jsipc_CpowHolder_h__
#define mozilla_jsipc_CpowHolder_h__
#include "js/TypeDecls.h"
namespace mozilla {
namespace jsipc {
class CpowHolder
{
public:
virtual bool ToObject(JSContext* cx, JS::MutableHandle<JSObject*> objp) = 0;
};
} // namespace jsipc
} // namespace mozilla
#endif // mozilla_jsipc_CpowHolder_h__
| 25.269231 | 80 | 0.709285 |
ffe86fc534e5949f2df434987455a734426cb0b0 | 716 | h | C | src/phreeqcpp/Dictionary.h | AbelHeinsbroek/VIPhreeqc | 30d6e10ed9c7f375a5d8f9cdeccfc1c2353d3604 | [
"Apache-2.0"
] | 5 | 2017-08-07T19:35:30.000Z | 2021-01-27T04:30:49.000Z | src/phreeqcpp/Dictionary.h | AbelHeinsbroek/VIPhreeqc | 30d6e10ed9c7f375a5d8f9cdeccfc1c2353d3604 | [
"Apache-2.0"
] | 2 | 2020-04-28T15:59:17.000Z | 2021-06-24T21:10:32.000Z | src/phreeqcpp/Dictionary.h | AbelHeinsbroek/VIPhreeqc | 30d6e10ed9c7f375a5d8f9cdeccfc1c2353d3604 | [
"Apache-2.0"
] | 3 | 2018-11-26T12:08:07.000Z | 2020-09-03T20:00:49.000Z | #if !defined(DICTIONARY_H_INCLUDED)
#define DICTIONARY_H_INCLUDED
#include <iostream>
#include <map>
#include <vector>
#include <sstream>
class Phreeqc;
class Dictionary
{
public:
Dictionary(void);
Dictionary(std::string & words_string);
~Dictionary(void);
int Find(std::string str);
int MapSize() {return (int) this->dictionary_map.size();}
int OssSize() {return (int) this->dictionary_oss.str().size();}
std::ostringstream &GetDictionaryOss() {return this->dictionary_oss;}
std::vector<std::string> &GetWords() {return this->words;}
protected:
std::map<std::string, int> dictionary_map;
std::vector<std::string> words;
std::ostringstream dictionary_oss;
};
#endif // !defined(DICTIONARY_H_INCLUDED)
| 24.689655 | 70 | 0.738827 |
fff9ba01b660a2041942df53275083899f865cf7 | 2,581 | c | C | tests/test_numbers.c | setivolkylany/c-utils | b0dfab7dac867179672de239e5e802f29ecb8cf9 | [
"BSD-3-Clause"
] | null | null | null | tests/test_numbers.c | setivolkylany/c-utils | b0dfab7dac867179672de239e5e802f29ecb8cf9 | [
"BSD-3-Clause"
] | null | null | null | tests/test_numbers.c | setivolkylany/c-utils | b0dfab7dac867179672de239e5e802f29ecb8cf9 | [
"BSD-3-Clause"
] | null | null | null |
#include "../utils/tests.h"
#include "../utils/numbers.h"
static void
test_decToBin() {
assertStringEqual(decToBin(-23432412), "-1011001011000110011011100");
assertStringEqual(decToBin(-1134245412), "-1000011100110110011011000100100");
assertStringEqual(decToBin(-7813422), "-11101110011100100101110");
assertStringEqual(decToBin(-7812), "-1111010000100");
assertStringEqual(decToBin(-20), "-10100");
assertStringEqual(decToBin(-19), "-10011");
assertStringEqual(decToBin(-18), "-10010");
assertStringEqual(decToBin(-17), "-10001");
assertStringEqual(decToBin(-16), "-10000");
assertStringEqual(decToBin(-15), "-1111");
assertStringEqual(decToBin(-14), "-1110");
assertStringEqual(decToBin(-13), "-1101");
assertStringEqual(decToBin(-12), "-1100");
assertStringEqual(decToBin(-11), "-1011");
assertStringEqual(decToBin(-10), "-1010");
assertStringEqual(decToBin(-9), "-1001");
assertStringEqual(decToBin(-8), "-1000");
assertStringEqual(decToBin(-7), "-111");
assertStringEqual(decToBin(-6), "-110");
assertStringEqual(decToBin(-5), "-101");
assertStringEqual(decToBin(-4), "-100");
assertStringEqual(decToBin(-3), "-11");
assertStringEqual(decToBin(-2), "-10");
assertStringEqual(decToBin(-1), "-1");
assertStringEqual(decToBin(0), "0");
assertStringEqual(decToBin(1), "1");
assertStringEqual(decToBin(2), "10");
assertStringEqual(decToBin(3), "11");
assertStringEqual(decToBin(4), "100");
assertStringEqual(decToBin(5), "101");
assertStringEqual(decToBin(6), "110");
assertStringEqual(decToBin(7), "111");
assertStringEqual(decToBin(8), "1000");
assertStringEqual(decToBin(9), "1001");
assertStringEqual(decToBin(10), "1010");
assertStringEqual(decToBin(11), "1011");
assertStringEqual(decToBin(12), "1100");
assertStringEqual(decToBin(13), "1101");
assertStringEqual(decToBin(14), "1110");
assertStringEqual(decToBin(15), "1111");
assertStringEqual(decToBin(16), "10000");
assertStringEqual(decToBin(17), "10001");
assertStringEqual(decToBin(18), "10010");
assertStringEqual(decToBin(19), "10011");
assertStringEqual(decToBin(20), "10100");
assertStringEqual(decToBin(7812), "1111010000100");
assertStringEqual(decToBin(7813422), "11101110011100100101110");
assertStringEqual(decToBin(1134245412), "1000011100110110011011000100100");
assertStringEqual(decToBin(23432412), "1011001011000110011011100");
}
int main (int argv, char **argc)
{
test_decToBin();
return 0;
}
| 39.106061 | 81 | 0.69043 |
4f5164e63ca9b2a960fde4419add60a319e804ba | 8,756 | c | C | machine/qemu/sources/u-boot/board/keymile/kmcent2/kmcent2.c | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | 1 | 2021-11-21T19:56:29.000Z | 2021-11-21T19:56:29.000Z | machine/qemu/sources/u-boot/board/keymile/kmcent2/kmcent2.c | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | machine/qemu/sources/u-boot/board/keymile/kmcent2/kmcent2.c | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | // SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2016 Keymile AG
* Rainer Boschung <rainer.boschung@keymile.com>
*
* Copyright 2013 Freescale Semiconductor, Inc.
*/
#include <asm/cache.h>
#include <asm/fsl_fdt.h>
#include <asm/fsl_law.h>
#include <asm/fsl_liodn.h>
#include <asm/fsl_portals.h>
#include <asm/fsl_serdes.h>
#include <asm/immap_85xx.h>
#include <asm/mmu.h>
#include <asm/processor.h>
#include <fdt_support.h>
#include <fm_eth.h>
#include <hwconfig.h>
#include <image.h>
#include <linux/compiler.h>
#include <net.h>
#include <netdev.h>
#include <vsc9953.h>
#include "../common/common.h"
#include "../common/qrio.h"
DECLARE_GLOBAL_DATA_PTR;
static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
int checkboard(void)
{
printf("Board: Hitachi Power Grids %s\n", KM_BOARD_NAME);
return 0;
}
#define RSTRQSR1_WDT_RR 0x00200000
#define RSTRQSR1_SW_RR 0x00100000
int board_early_init_f(void)
{
struct fsl_ifc ifc = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
bool cpuwd_flag = false;
/* board specific IFC configuration: increased bus turnaround time */
setbits_be32(&ifc.gregs->ifc_gcr, 8 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
/* configure mode for uP reset request */
qrio_uprstreq(UPREQ_CORE_RST);
/* board only uses the DDR_MCK0, so disable the DDR_MCK1 */
setbits_be32(&gur->ddrclkdr, 0x40000000);
/* set reset reason according CPU register */
if ((gur->rstrqsr1 & (RSTRQSR1_WDT_RR | RSTRQSR1_SW_RR)) ==
RSTRQSR1_WDT_RR)
cpuwd_flag = true;
qrio_cpuwd_flag(cpuwd_flag);
/* clear CPU bits by writing 1 */
setbits_be32(&gur->rstrqsr1, RSTRQSR1_WDT_RR | RSTRQSR1_SW_RR);
/* configure PRST lines for the application: */
/*
* ETHSW_DDR_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_ETHSW_DDR_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_ETHSW_DDR_RST, true);
/*
* XES_PHY_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_XES_PHY_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_XES_PHY_RST, true);
/*
* ES_PHY_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_ES_PHY_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_ES_PHY_RST, true);
/*
* EFE_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_EFE_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_EFE_RST, true);
/*
* BFTIC4_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_BFTIC4_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_BFTIC4_RST, true);
/*
* DPAXE_RST:
* reset at power-up and unit reset only and enable WD on it
*/
qrio_prstcfg(KM_DPAXE_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_DPAXE_RST, true);
/*
* PEXSW_RST:
* reset at power-up and unit reset only, deassert reset w/o WD
*/
qrio_prstcfg(KM_PEXSW_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_prst(KM_PEXSW_RST, false, false);
/*
* PEXSW_NT_RST:
* reset at power-up and unit reset only, deassert reset w/o WD
*/
qrio_prstcfg(KM_PEXSW_NT_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_prst(KM_PEXSW_NT_RST, false, false);
/*
* BOBCAT_RST:
* reset at power-up and unit reset only, deassert reset w/o WD
*/
qrio_prstcfg(KM_BOBCAT_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_prst(KM_BOBCAT_RST, false, false);
/*
* FEMT_RST:
* reset at power-up and unit reset only and enable WD
*/
qrio_prstcfg(KM_FEMT_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_FEMT_RST, true);
/*
* FOAM_RST:
* reset at power-up and unit reset only and enable WD
*/
qrio_prstcfg(KM_FOAM_RST, PRSTCFG_POWUP_UNIT_RST);
qrio_wdmask(KM_FOAM_RST, true);
return 0;
}
int board_early_init_r(void)
{
int ret = 0;
const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
int flash_esel = find_tlb_idx((void *)flashbase, 1);
/*
* Remap Boot flash region to caching-inhibited
* so that flash can be erased properly.
*/
/* Flush d-cache and invalidate i-cache of any FLASH data */
flush_dcache();
invalidate_icache();
if (flash_esel == -1) {
/* very unlikely unless something is messed up */
puts("Error: Could not find TLB for FLASH BASE\n");
flash_esel = 2; /* give our best effort to continue */
} else {
/* invalidate existing TLB entry for flash */
disable_tlb(flash_esel);
}
set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G,
0, flash_esel, BOOKE_PAGESZ_256M, 1);
set_liodns();
setup_qbman_portals();
qrio_set_leds();
/* enable Application Buffer */
qrio_enable_app_buffer();
return ret;
}
unsigned long get_serial_clock(unsigned long dummy)
{
return (gd->bus_clk / 2);
}
unsigned long get_board_sys_clk(unsigned long dummy)
{
return 66666666;
}
int misc_init_f(void)
{
/* configure QRIO pis for i2c deblocking */
i2c_deblock_gpio_cfg();
/*
* CFE_RST (front phy):
* reset at power-up, unit and core reset, deasset reset w/o WD
*/
qrio_prstcfg(KM_CFE_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
qrio_prst(KM_CFE_RST, false, false);
/*
* ZL30158_RST (PTP clock generator):
* reset at power-up only, deassert reset and enable WD on it
*/
qrio_prstcfg(KM_ZL30158_RST, PRSTCFG_POWUP_RST);
qrio_prst(KM_ZL30158_RST, false, false);
/*
* ZL30364_RST (EEC generator):
* reset at power-up only, deassert reset and enable WD on it
*/
qrio_prstcfg(KM_ZL30364_RST, PRSTCFG_POWUP_RST);
qrio_prst(KM_ZL30364_RST, false, false);
return 0;
}
#define USED_SRDS_BANK 0
#define EXPECTED_SRDS_RFCK SRDS_PLLCR0_RFCK_SEL_100
#define BRG01_IOCLK12 0x02000000
#define EC2_GTX_CLK125 0x08000000
int misc_init_r(void)
{
serdes_corenet_t *regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_MPC85xx_SCFG;
ccsr_gur_t __iomem *gur = (ccsr_gur_t __iomem *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
/* check SERDES bank 0 reference clock */
u32 actual = in_be32(®s->bank[USED_SRDS_BANK].pllcr0);
if (actual & SRDS_PLLCR0_POFF)
printf("Warning: SERDES bank %u pll is off\n", USED_SRDS_BANK);
if ((actual & SRDS_PLLCR0_RFCK_SEL_MASK) != EXPECTED_SRDS_RFCK) {
printf("Warning: SERDES bank %u expects %sMHz clock, is %sMHz\n",
USED_SRDS_BANK,
serdes_clock_to_string(EXPECTED_SRDS_RFCK),
serdes_clock_to_string(actual));
}
/* QE IO clk : BRG01 is used over clk12 for HDLC clk (20 MhZ) */
out_be32(&scfg->qeioclkcr,
in_be32(&scfg->qeioclkcr) | BRG01_IOCLK12);
ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
CONFIG_PIGGY_MAC_ADDRESS_OFFSET);
/* Fix polarity of Card Detect and Write Protect */
out_be32(&gur->sdhcpcr, 0xFFFFFFFF);
/*
* EC1 is disabled in our design, so we must explicitly set GTXCLKSEL
* to EC2
*/
out_be32(&scfg->emiiocr, in_be32(&scfg->emiiocr) | EC2_GTX_CLK125);
return 0;
}
int hush_init_var(void)
{
ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
return 0;
}
int last_stage_init(void)
{
const char *kmem;
/* DIP switch support on BFTIC */
struct bfticu_iomap *bftic4 =
(struct bfticu_iomap *)SYS_BFTIC_BASE;
u8 dip_switch = in_8((u8 *)&bftic4->mswitch) & BFTICU_DIPSWITCH_MASK;
if (dip_switch != 0) {
/* start bootloader */
puts("DIP: Enabled\n");
env_set("actual_bank", "0");
}
set_km_env();
/*
* bootm_size is used to fixup the FDT memory node
* set it to kernelmem that has the same value
*/
kmem = env_get("kernelmem");
if (kmem)
env_set("bootm_size", kmem);
return 0;
}
void fdt_fixup_fman_mac_addresses(void *blob)
{
int node, ret;
char path[24];
unsigned char mac_addr[6];
/*
* Just the fm1-mac5 must be set by us, u-boot handle the 2 others,
* get the mac addr from env
*/
if (!eth_env_get_enetaddr_by_index("eth", 4, mac_addr)) {
printf("eth4addr env variable not defined\n");
return;
}
/* local management port */
strcpy(path, "/soc/fman/ethernet@e8000");
node = fdt_path_offset(blob, path);
if (node < 0) {
printf("no %s\n", path);
return;
}
ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
if (ret) {
printf("%s\n\terror setting local-mac-address property\n",
path);
}
}
int ft_board_setup(void *blob, struct bd_info *bd)
{
phys_addr_t base;
phys_size_t size;
ft_cpu_setup(blob, bd);
base = env_get_bootm_low();
size = env_get_bootm_size();
fdt_fixup_memory(blob, (u64)base, (u64)size);
fdt_fixup_liodn(blob);
fdt_fixup_fman_mac_addresses(blob);
if (hwconfig("qe-tdm"))
fdt_del_diu(blob);
return 0;
}
/* DIC26_SELFTEST GPIO used to start factory test sw */
#define SELFTEST_PORT QRIO_GPIO_A
#define SELFTEST_PIN 0
int post_hotkeys_pressed(void)
{
qrio_gpio_direction_input(SELFTEST_PORT, SELFTEST_PIN);
return qrio_get_gpio(SELFTEST_PORT, SELFTEST_PIN);
}
| 24.734463 | 78 | 0.726359 |
9eff3b67403efc78d19fc794ed899d0b29a24a8e | 22,128 | h | C | PhysicsTools/UtilAlgos/interface/CachingVariable.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 6 | 2017-09-08T14:12:56.000Z | 2022-03-09T23:57:01.000Z | PhysicsTools/UtilAlgos/interface/CachingVariable.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 545 | 2017-09-19T17:10:19.000Z | 2022-03-07T16:55:27.000Z | PhysicsTools/UtilAlgos/interface/CachingVariable.h | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 14 | 2017-10-04T09:47:21.000Z | 2019-10-23T18:04:45.000Z | #ifndef ConfigurableAnalysis_CachingVariable_H
#define ConfigurableAnalysis_CachingVariable_H
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/Utils/interface/StringObjectFunction.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/InputTagDistributor.h"
namespace edm {
class EventSetup;
}
#include <vector>
#include "TString.h"
class Description {
public:
Description() {}
Description(std::vector<std::string>& d) : d_(d) {}
std::string text() const {
std::string text;
for (unsigned int i = 0; i != d_.size(); ++i)
text += d_[i] + "\n";
return text;
}
const std::vector<std::string> lines() { return d_; }
void addLine(const std::string& l) { d_.push_back(l); }
private:
std::vector<std::string> d_;
};
class VariableComputer;
class CachingVariable {
public:
//every variable return double values
typedef double valueType;
typedef std::pair<bool, valueType> evalType;
typedef std::map<std::string, const CachingVariable*> vMap;
struct CachingVariableFactoryArg {
CachingVariableFactoryArg(const CachingVariableFactoryArg& copy) : n(copy.n), m(copy.m), iConfig(copy.iConfig) {}
CachingVariableFactoryArg(std::string& N, CachingVariable::vMap& M, edm::ParameterSet& P)
: n(N), m(M), iConfig(P) {}
std::string& n;
CachingVariable::vMap& m;
edm::ParameterSet& iConfig;
};
CachingVariable(std::string m, std::string n, const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC)
: cache_(std::make_pair(false, 0)), method_(m), name_(n), conf_(iConfig) {}
virtual ~CachingVariable() {}
//does the variable computes
bool compute(const edm::Event& iEvent) const { return baseEval(iEvent).first; }
//accessor to the computed/cached value
valueType operator()(const edm::Event& iEvent) const { return baseEval(iEvent).second; }
const std::string& name() const { return name_; }
const std::string& method() const { return method_; }
const Description& description() const { return d_; }
void addDescriptionLine(const std::string& s) { d_.addLine(s); }
const std::string& holderName() const { return holderName_; }
void setHolder(std::string hn) const { holderName_ = hn; }
void print() const { edm::LogVerbatim("CachingVariable") << name() << "\n" << description().text(); }
protected:
mutable evalType cache_;
mutable edm::Event::CacheIdentifier_t eventCacheID_ = 0;
std::string method_;
std::string name_;
mutable std::string holderName_;
void setCache(valueType& v) const {
cache_.first = true;
cache_.second = v;
}
void setNotCompute() const {
cache_.first = false;
cache_.second = 0;
}
evalType& baseEval(const edm::Event& iEvent) const {
if (notSeenThisEventAlready(iEvent)) {
LogDebug("CachingVariable") << name_ + ":" + holderName_ << " is checking once";
cache_ = eval(iEvent);
}
return cache_;
}
bool notSeenThisEventAlready(const edm::Event& iEvent) const {
bool retValue = (std::numeric_limits<edm::Event::CacheIdentifier_t>::max() != eventCacheID_ and
eventCacheID_ != iEvent.cacheIdentifier());
if (retValue) {
eventCacheID_ = iEvent.cacheIdentifier();
}
return retValue;
}
//cannot be made purely virtual otherwise one cannot have purely CachingVariableObjects
virtual evalType eval(const edm::Event& iEvent) const { return std::make_pair(false, 0); };
Description d_;
edm::ParameterSet conf_;
friend class VariableComputer;
};
class ComputedVariable;
class VariableComputer {
public:
VariableComputer(const CachingVariable::CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC);
virtual ~VariableComputer() {}
virtual void compute(const edm::Event& iEvent) const = 0;
const std::string& name() const { return name_; }
void declare(std::string var, edm::ConsumesCollector& iC);
void assign(std::string var, double& value) const;
void doesNotCompute() const;
void doesNotCompute(std::string var) const;
bool notSeenThisEventAlready(const edm::Event& iEvent) const {
bool retValue = (std::numeric_limits<edm::Event::CacheIdentifier_t>::max() != eventCacheID_ and
eventCacheID_ != iEvent.cacheIdentifier());
if (retValue) {
eventCacheID_ = iEvent.cacheIdentifier();
}
return retValue;
}
protected:
const CachingVariable::CachingVariableFactoryArg& arg_;
std::string name_;
std::string method_;
mutable std::map<std::string, const ComputedVariable*> iCompute_;
std::string separator_;
mutable edm::Event::CacheIdentifier_t eventCacheID_ = 0;
};
#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
typedef edmplugin::PluginFactory<CachingVariable*(CachingVariable::CachingVariableFactoryArg,
edm::ConsumesCollector& iC)>
CachingVariableFactory;
typedef edmplugin::PluginFactory<VariableComputer*(CachingVariable::CachingVariableFactoryArg,
edm::ConsumesCollector& iC)>
VariableComputerFactory;
class ComputedVariable : public CachingVariable {
public:
ComputedVariable(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC);
ComputedVariable(
const std::string& M, std::string& N, edm::ParameterSet& P, const VariableComputer* c, edm::ConsumesCollector& iC)
: CachingVariable(M, N, P, iC), myComputer(c) {}
~ComputedVariable() override{};
evalType eval(const edm::Event& iEvent) const override {
if (myComputer->notSeenThisEventAlready(iEvent))
myComputer->compute(iEvent);
return cache_;
}
private:
std::unique_ptr<const VariableComputer> myComputer;
};
class VariableComputerTest : public VariableComputer {
public:
VariableComputerTest(const CachingVariable::CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC);
~VariableComputerTest() override{};
void compute(const edm::Event& iEvent) const override;
};
class Splitter : public CachingVariable {
public:
Splitter(std::string method, std::string n, const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC)
: CachingVariable(method, n, iConfig, iC) {}
//purely virtual here
CachingVariable::evalType eval(const edm::Event& iEvent) const override = 0;
unsigned int maxIndex() const { return maxSlots() - 1; }
//maximum NUMBER of slots: counting over/under flows
virtual unsigned int maxSlots() const { return labels_.size(); }
const std::string shortLabel(unsigned int i) const {
if (i >= short_labels_.size()) {
edm::LogError("Splitter") << "trying to access slots short_label at index: " << i
<< "while of size: " << short_labels_.size() << "\n"
<< conf_.dump();
return short_labels_.back();
} else
return short_labels_[i];
}
const std::string& label(unsigned int i) const {
if (i >= labels_.size()) {
edm::LogError("Splitter") << "trying to access slots label at index: " << i << "while of size: " << labels_.size()
<< "\n"
<< conf_.dump();
return labels_.back();
} else
return labels_[i];
}
protected:
std::vector<std::string> labels_;
std::vector<std::string> short_labels_;
};
class VarSplitter : public Splitter {
public:
VarSplitter(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: Splitter("VarSplitter", arg.n, arg.iConfig, iC) {
var_ = arg.iConfig.getParameter<std::string>("var");
useUnderFlow_ = arg.iConfig.getParameter<bool>("useUnderFlow");
useOverFlow_ = arg.iConfig.getParameter<bool>("useOverFlow");
slots_ = arg.iConfig.getParameter<std::vector<double> >("slots");
if (useUnderFlow_) {
labels_.push_back("underflow");
short_labels_.push_back("_" + arg.n + "_underflow");
}
std::vector<std::string> confLabels;
if (arg.iConfig.exists("labels")) {
confLabels = arg.iConfig.getParameter<std::vector<std::string> >("labels");
} else {
std::string labelFormat = arg.iConfig.getParameter<std::string>("labelsFormat");
for (unsigned int is = 0; is != slots_.size() - 1; ++is) {
std::string l(Form(labelFormat.c_str(), slots_[is], slots_[is + 1]));
confLabels.push_back(l);
}
}
for (unsigned int i = 0; i != confLabels.size(); ++i) {
labels_.push_back(confLabels[i]);
std::stringstream ss;
ss << "_" << arg.n << "_" << i;
short_labels_.push_back(ss.str());
}
if (useOverFlow_) {
labels_.push_back("overFlow");
short_labels_.push_back("_" + arg.n + "_overFlow");
}
//check consistency
if (labels_.size() != maxSlots())
edm::LogError("Splitter") << "splitter with name: " << name() << " has inconsistent configuration\n"
<< conf_.dump();
arg.m[arg.n] = this;
}
CachingVariable::evalType eval(const edm::Event& iEvent) const override;
//redefine the maximum number of slots
unsigned int maxSlots() const override {
unsigned int s = slots_.size() - 1;
if (useUnderFlow_)
s++;
if (useOverFlow_)
s++;
return s;
}
protected:
std::string var_;
bool useUnderFlow_;
bool useOverFlow_;
std::vector<double> slots_;
};
template <typename Object, const char* label>
class ExpressionVariable : public CachingVariable {
public:
ExpressionVariable(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: CachingVariable(std::string(label) + "ExpressionVariable", arg.n, arg.iConfig, iC),
f_(nullptr),
forder_(nullptr) {
srcTag_ = edm::Service<InputTagDistributorService>()->retrieve("src", arg.iConfig);
src_ = iC.consumes<edm::View<Object> >(srcTag_);
//old style constructor
if (arg.iConfig.exists("expr") && arg.iConfig.exists("index")) {
std::string expr = arg.iConfig.getParameter<std::string>("expr");
index_ = arg.iConfig.getParameter<unsigned int>("index");
f_ = new StringObjectFunction<Object>(expr);
addDescriptionLine("calculating: " + expr);
std::stringstream ss;
ss << "on object at index: " << index_ << " of: " << srcTag_;
if (arg.iConfig.exists("order")) {
std::string order = arg.iConfig.getParameter<std::string>("order");
forder_ = new StringObjectFunction<Object>(order);
ss << " after sorting according to: " << order;
} else
forder_ = nullptr;
if (arg.iConfig.exists("selection")) {
std::string selection = arg.iConfig.getParameter<std::string>("selection");
selector_ = new StringCutObjectSelector<Object>(selection);
ss << " and selecting only: " << selection;
} else
selector_ = nullptr;
addDescriptionLine(ss.str());
ss.str("");
arg.m[arg.n] = this;
} else {
//multiple instance constructor
std::map<std::string, edm::Entry> indexEntry;
if (arg.n.find("_N") != std::string::npos) {
//will have to loop over indexes
std::vector<unsigned int> indexes = arg.iConfig.getParameter<std::vector<unsigned int> >("indexes");
for (unsigned int iI = 0; iI != indexes.size(); ++iI) {
edm::ParameterSet toUse = arg.iConfig;
edm::Entry e("unsigned int", indexes[iI], true);
std::stringstream ss;
//add +1 0->1, 1->2, ... in the variable label
ss << indexes[iI] + 1;
indexEntry.insert(std::make_pair(ss.str(), e));
}
} //contains "_N"
std::map<std::string, edm::Entry> varEntry;
if (arg.n.find("_V") != std::string::npos) {
//do something fancy for multiple variable from one PSet
std::vector<std::string> vars = arg.iConfig.getParameter<std::vector<std::string> >("vars");
for (unsigned int v = 0; v != vars.size(); ++v) {
unsigned int sep = vars[v].find(":");
std::string name = vars[v].substr(0, sep);
std::string expr = vars[v].substr(sep + 1);
edm::Entry e("string", expr, true);
varEntry.insert(std::make_pair(name, e));
}
} //contains "_V"
std::string radical = arg.n;
//remove the "_V";
if (!varEntry.empty())
radical = radical.substr(0, radical.size() - 2);
//remove the "_N";
if (!indexEntry.empty())
radical = radical.substr(0, radical.size() - 2);
if (varEntry.empty()) {
//loop only the indexes
for (std::map<std::string, edm::Entry>::iterator iIt = indexEntry.begin(); iIt != indexEntry.end(); ++iIt) {
edm::ParameterSet toUse = arg.iConfig;
toUse.insert(true, "index", iIt->second);
std::string newVname = radical + iIt->first;
// std::cout<<"in the loop, creating variable with name: "<<newVname<<std::endl;
// the constructor auto log the new variable in the map
new ExpressionVariable(CachingVariable::CachingVariableFactoryArg(newVname, arg.m, toUse), iC);
}
} else {
for (std::map<std::string, edm::Entry>::iterator vIt = varEntry.begin(); vIt != varEntry.end(); ++vIt) {
if (indexEntry.empty()) {
edm::ParameterSet toUse = arg.iConfig;
toUse.insert(true, "expr", vIt->second);
std::string newVname = radical + vIt->first;
// std::cout<<"in the loop, creating variable with name: "<<newVname<<std::endl;
// the constructor auto log the new variable in the map
new ExpressionVariable(CachingVariable::CachingVariableFactoryArg(newVname, arg.m, toUse), iC);
} else {
for (std::map<std::string, edm::Entry>::iterator iIt = indexEntry.begin(); iIt != indexEntry.end(); ++iIt) {
edm::ParameterSet toUse = arg.iConfig;
toUse.insert(true, "expr", vIt->second);
toUse.insert(true, "index", iIt->second);
std::string newVname = radical + iIt->first + vIt->first;
// std::cout<<"in the loop, creating variable with name: "<<newVname<<std::endl;
// the constructor auto log the new variable in the map
new ExpressionVariable(CachingVariable::CachingVariableFactoryArg(newVname, arg.m, toUse), iC);
}
}
}
}
//there is a memory leak here, because the object we are in is not logged in the arg.m, the variable is not valid
// anyways, but reside in memory with no ways of de-allocating it.
// since the caching variables are actually "global" objects, it does not matter.
// we cannot add it to the map, otherwise, it would be considered for eventV ntupler
}
}
~ExpressionVariable() override {
if (f_)
delete f_;
if (forder_)
delete forder_;
if (selector_)
delete selector_;
}
CachingVariable::evalType eval(const edm::Event& iEvent) const override {
if (!f_) {
edm::LogError(method()) << " no parser attached.";
return std::make_pair(false, 0);
}
edm::Handle<edm::View<Object> > oH;
iEvent.getByToken(src_, oH);
if (index_ >= oH->size()) {
LogDebug(method()) << "fail to get object at index: " << index_ << " in collection: " << srcTag_;
return std::make_pair(false, 0);
}
//get the ordering right first. if required
if (selector_ || forder_) {
std::vector<const Object*> copyToSort(0);
copyToSort.reserve(oH->size());
for (unsigned int i = 0; i != oH->size(); ++i) {
if (selector_ && !((*selector_)((*oH)[i])))
continue;
copyToSort.push_back(&(*oH)[i]);
}
if (index_ >= copyToSort.size())
return std::make_pair(false, 0);
if (forder_)
std::sort(copyToSort.begin(), copyToSort.end(), sortByStringFunction<Object>(forder_));
const Object* o = copyToSort[index_];
return std::make_pair(true, (*f_)(*o));
} else {
const Object& o = (*oH)[index_];
return std::make_pair(true, (*f_)(o));
}
}
private:
edm::InputTag srcTag_;
edm::EDGetTokenT<edm::View<Object> > src_;
unsigned int index_;
StringObjectFunction<Object>* f_;
StringObjectFunction<Object>* forder_;
StringCutObjectSelector<Object>* selector_;
};
template <typename LHS, const char* lLHS, typename RHS, const char* lRHS, typename Calculator>
class TwoObjectVariable : public CachingVariable {
public:
TwoObjectVariable(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: CachingVariable(Calculator::calculationType() + std::string(lLHS) + std::string(lRHS), arg.n, arg.iConfig, iC),
srcLhsTag_(edm::Service<InputTagDistributorService>()->retrieve("srcLhs", arg.iConfig)),
srcLhs_(iC.consumes<std::vector<LHS> >(srcLhsTag_)),
indexLhs_(arg.iConfig.getParameter<unsigned int>("indexLhs")),
srcRhsTag_(edm::Service<InputTagDistributorService>()->retrieve("srcRhs", arg.iConfig)),
srcRhs_(iC.consumes<std::vector<RHS> >(srcRhsTag_)),
indexRhs_(arg.iConfig.getParameter<unsigned int>("indexRhs")) {
std::stringstream ss;
addDescriptionLine(Calculator::description());
ss << "with Obj1 at index: " << indexLhs_ << " of: " << srcLhs_;
addDescriptionLine(ss.str());
ss.str("");
ss << "with Obj2 at index: " << indexRhs_ << " of: " << srcRhs_;
addDescriptionLine(ss.str());
ss.str("");
arg.m[arg.n] = this;
}
class getObject {
public:
getObject() : test(false), lhs(0), rhs(0) {}
bool test;
const LHS* lhs;
const RHS* rhs;
};
getObject objects(const edm::Event& iEvent) const {
getObject failed;
edm::Handle<std::vector<LHS> > lhsH;
iEvent.getByToken(srcLhs_, lhsH);
if (lhsH.failedToGet()) {
LogDebug("TwoObjectVariable") << name() << " could not get a collection with label: " << srcLhsTag_;
return failed;
}
if (indexLhs_ >= lhsH->size()) {
LogDebug("TwoObjectVariable") << name() << " tries to access index: " << indexLhs_ << " of: " << srcLhsTag_
<< " with: " << lhsH->size() << " entries.";
return failed;
}
const LHS& lhs = (*lhsH)[indexLhs_];
edm::Handle<std::vector<RHS> > rhsH;
iEvent.getByToken(srcRhs_, rhsH);
if (rhsH.failedToGet()) {
LogDebug("TwoObjectVariable") << name() << " could not get a collection with label: " << srcLhsTag_;
return failed;
}
if (indexRhs_ >= rhsH->size()) {
LogDebug("TwoObjectVariable") << name() << " tries to access index: " << indexRhs_ << " of: " << srcRhsTag_
<< " with: " << rhsH->size() << " entries.";
return failed;
}
const RHS& rhs = (*rhsH)[indexRhs_];
failed.test = true;
failed.lhs = &lhs;
failed.rhs = &rhs;
return failed;
}
//to be overloaded by the user
virtual CachingVariable::valueType calculate(getObject& o) const {
Calculator calc;
return calc(*o.lhs, *o.rhs);
}
CachingVariable::evalType eval(const edm::Event& iEvent) const override {
getObject o = objects(iEvent);
if (!o.test)
return std::make_pair(false, 0);
return std::make_pair(true, calculate(o));
}
private:
edm::InputTag srcLhsTag_;
edm::EDGetTokenT<std::vector<LHS> > srcLhs_;
unsigned int indexLhs_;
edm::InputTag srcRhsTag_;
edm::EDGetTokenT<std::vector<RHS> > srcRhs_;
unsigned int indexRhs_;
};
class VariablePower : public CachingVariable {
public:
VariablePower(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: CachingVariable("Power", arg.n, arg.iConfig, iC) {
power_ = arg.iConfig.getParameter<double>("power");
var_ = arg.iConfig.getParameter<std::string>("var");
std::stringstream ss("Calculare X^Y, with X=");
ss << var_ << " and Y=" << power_;
addDescriptionLine(ss.str());
arg.m[arg.n] = this;
}
~VariablePower() override {}
//concrete calculation of the variable
CachingVariable::evalType eval(const edm::Event& iEvent) const override;
private:
double power_;
std::string var_;
};
template <typename TYPE>
class SimpleValueVariable : public CachingVariable {
public:
SimpleValueVariable(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: CachingVariable("SimpleValueVariable", arg.n, arg.iConfig, iC),
src_(iC.consumes<TYPE>(edm::Service<InputTagDistributorService>()->retrieve("src", arg.iConfig))) {
arg.m[arg.n] = this;
}
CachingVariable::evalType eval(const edm::Event& iEvent) const override {
edm::Handle<TYPE> value;
iEvent.getByToken(src_, value);
if (value.failedToGet() || !value.isValid())
return std::make_pair(false, 0);
else
return std::make_pair(true, *value);
}
private:
edm::EDGetTokenT<TYPE> src_;
};
template <typename TYPE>
class SimpleValueVectorVariable : public CachingVariable {
public:
SimpleValueVectorVariable(const CachingVariableFactoryArg& arg, edm::ConsumesCollector& iC)
: CachingVariable("SimpleValueVectorVariable", arg.n, arg.iConfig, iC),
src_(iC.consumes<TYPE>(edm::Service<InputTagDistributorService>()->retrieve("src", arg.iConfig))),
index_(arg.iConfig.getParameter<unsigned int>("index")) {
arg.m[arg.n] = this;
}
CachingVariable::evalType eval(const edm::Event& iEvent) const override {
edm::Handle<std::vector<TYPE> > values;
iEvent.getByToken(src_, values);
if (values.failedToGet() || !values.isValid())
return std::make_pair(false, 0);
else if (index_ >= values->size())
return std::make_pair(false, 0);
else
return std::make_pair(true, (*values)[index_]);
}
private:
edm::EDGetTokenT<TYPE> src_;
unsigned int index_;
};
#endif
| 37.127517 | 120 | 0.645653 |
9ae8bb40ee7ccf8beadfad0b3700e4d662446a21 | 4,230 | h | C | Userland/Applications/PixelPaint/Image.h | Camron/serenity | 7debc2879d160f7cb65d7b03a8fdb77ddb19e361 | [
"BSD-2-Clause"
] | null | null | null | Userland/Applications/PixelPaint/Image.h | Camron/serenity | 7debc2879d160f7cb65d7b03a8fdb77ddb19e361 | [
"BSD-2-Clause"
] | null | null | null | Userland/Applications/PixelPaint/Image.h | Camron/serenity | 7debc2879d160f7cb65d7b03a8fdb77ddb19e361 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashTable.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Result.h>
#include <AK/Vector.h>
#include <LibCore/File.h>
#include <LibGUI/Command.h>
#include <LibGUI/Forward.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Forward.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Size.h>
namespace PixelPaint {
class Layer;
class Selection;
class ImageClient {
public:
virtual void image_did_add_layer(size_t) { }
virtual void image_did_remove_layer(size_t) { }
virtual void image_did_modify_layer_properties(size_t) { }
virtual void image_did_modify_layer_bitmap(size_t) { }
virtual void image_did_modify_layer_stack() { }
virtual void image_did_change(Gfx::IntRect const&) { }
virtual void image_did_change_rect(Gfx::IntRect const&) { }
virtual void image_select_layer(Layer*) { }
virtual void image_did_change_title(String const&) { }
protected:
virtual ~ImageClient() = default;
};
class Image : public RefCounted<Image> {
public:
static RefPtr<Image> try_create_with_size(Gfx::IntSize const&);
static Result<NonnullRefPtr<Image>, String> try_create_from_pixel_paint_json(JsonObject const&);
static RefPtr<Image> try_create_from_bitmap(NonnullRefPtr<Gfx::Bitmap>);
static RefPtr<Gfx::Bitmap> try_decode_bitmap(const ByteBuffer& bitmap_data);
// This generates a new Bitmap with the final image (all layers composed according to their attributes.)
RefPtr<Gfx::Bitmap> try_compose_bitmap(Gfx::BitmapFormat format) const;
RefPtr<Gfx::Bitmap> try_copy_bitmap(Selection const&) const;
size_t layer_count() const { return m_layers.size(); }
Layer const& layer(size_t index) const { return m_layers.at(index); }
Layer& layer(size_t index) { return m_layers.at(index); }
Gfx::IntSize const& size() const { return m_size; }
Gfx::IntRect rect() const { return { {}, m_size }; }
void add_layer(NonnullRefPtr<Layer>);
RefPtr<Image> take_snapshot() const;
void restore_snapshot(Image const&);
void paint_into(GUI::Painter&, Gfx::IntRect const& dest_rect) const;
void serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const;
Result<void, String> write_to_file(String const& file_path) const;
Result<void, String> export_bmp_to_fd_and_close(int fd, bool preserve_alpha_channel);
Result<void, String> export_png_to_fd_and_close(int fd, bool preserve_alpha_channel);
void move_layer_to_front(Layer&);
void move_layer_to_back(Layer&);
void move_layer_up(Layer&);
void move_layer_down(Layer&);
void change_layer_index(size_t old_index, size_t new_index);
void remove_layer(Layer&);
void select_layer(Layer*);
void flatten_all_layers();
void merge_visible_layers();
void merge_active_layer_down(Layer& layer);
void add_client(ImageClient&);
void remove_client(ImageClient&);
void layer_did_modify_bitmap(Badge<Layer>, Layer const&, Gfx::IntRect const& modified_layer_rect);
void layer_did_modify_properties(Badge<Layer>, Layer const&);
size_t index_of(Layer const&) const;
String const& path() const { return m_path; }
void set_path(String);
String const& title() const { return m_title; }
void set_title(String);
void flip(Gfx::Orientation orientation);
void rotate(Gfx::RotationDirection direction);
private:
explicit Image(Gfx::IntSize const&);
void did_change(Gfx::IntRect const& modified_rect = {});
void did_change_rect();
void did_modify_layer_stack();
String m_path;
String m_title;
Gfx::IntSize m_size;
NonnullRefPtrVector<Layer> m_layers;
HashTable<ImageClient*> m_clients;
};
class ImageUndoCommand : public GUI::Command {
public:
ImageUndoCommand(Image& image);
virtual void undo() override;
virtual void redo() override;
private:
RefPtr<Image> m_snapshot;
Image& m_image;
};
}
| 31.567164 | 108 | 0.73026 |
7f51acc1ecfa2f2d7514787843d8ee69aaba1454 | 24,964 | h | C | Pcap++/header/PcapLiveDevice.h | fkorotkov/PcapPlusPlus | cb6ee56b31ad36966e39425ed22b6a950707fb07 | [
"Unlicense"
] | 101 | 2020-03-24T09:36:01.000Z | 2022-03-07T08:41:57.000Z | Pcap++/header/PcapLiveDevice.h | fkorotkov/PcapPlusPlus | cb6ee56b31ad36966e39425ed22b6a950707fb07 | [
"Unlicense"
] | 22 | 2020-03-25T21:58:29.000Z | 2021-09-29T06:58:13.000Z | Pcap++/header/PcapLiveDevice.h | fkorotkov/PcapPlusPlus | cb6ee56b31ad36966e39425ed22b6a950707fb07 | [
"Unlicense"
] | 142 | 2020-03-24T02:30:11.000Z | 2021-12-16T10:48:56.000Z | //TODO: replace all these defines with #pragma once
#ifndef PCAPPP_LIVE_DEVICE
#define PCAPPP_LIVE_DEVICE
#include "PcapDevice.h"
#include <vector>
#include <string.h>
#include "IpAddress.h"
#include "Packet.h"
/// @file
/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{
class PcapLiveDevice;
/**
* @typedef OnPacketArrivesCallback
* A callback that is called when a packet is captured by PcapLiveDevice
* @param[in] pPacket A pointer to the raw packet
* @param[in] pDevice A pointer to the PcapLiveDevice instance
* @param[in] userCookie A pointer to the object put by the user when packet capturing stared
*/
typedef void (*OnPacketArrivesCallback)(RawPacket* pPacket, PcapLiveDevice* pDevice, void* userCookie);
/**
* @typedef OnPacketArrivesStopBlocking
* A callback that is called when a packet is captured by PcapLiveDevice
* @param[in] pPacket A pointer to the raw packet
* @param[in] pDevice A pointer to the PcapLiveDevice instance
* @param[in] userCookie A pointer to the object put by the user when packet capturing stared
* @return True when main thread should stop blocking or false otherwise
*/
typedef bool (*OnPacketArrivesStopBlocking)(RawPacket* pPacket, PcapLiveDevice* pDevice, void* userData);
/**
* @typedef OnStatsUpdateCallback
* A callback that is called periodically for stats collection if user asked to start packet capturing with periodic stats collection
* @param[in] stats A reference to the most updated stats
* @param[in] userCookie A pointer to the object put by the user when packet capturing stared
*/
typedef void (*OnStatsUpdateCallback)(pcap_stat& stats, void* userCookie);
// for internal use only
typedef void* (*ThreadStart)(void*);
struct PcapThread;
/**
* @class PcapLiveDevice
* A class that wraps a network interface (each of the interfaces listed in ifconfig/ipconfig).
* This class wraps the libpcap capabilities of capturing packets from the network, filtering packets and sending packets back to the network.
* This class is relevant for Linux applications only. On Windows the WinPcapLiveDevice (which inherits this class) is used. Both classes are
* almost similar in capabilities, the main difference between them is adapting some capabilities to the specific OS.
* This class cannot be instantiated by the user (it has a private constructor), as network interfaces aren't dynamic. Instances of
* this class (one instance per network interface) are created by PcapLiveDeviceList singleton on application startup and the user can get
* access to them by using PcapLiveDeviceList public methods such as PcapLiveDeviceList#getPcapLiveDeviceByIp()<BR>
* Main capabilities of this class:
* - Get all available information for this network interfaces such as name, IP addresses, MAC address, MTU, etc. This information is taken
* from both libpcap and the OS
* - Capture packets from the network. Capturing is always conducted on a different thread. PcapPlusPlus creates this
* thread when capturing starts and kills it when capturing ends. This prevents the application from being stuck while waiting for packets or
* processing them. Currently only one capturing thread is allowed, so when the interface is in capture mode, no further capturing is allowed.
* In addition to capturing the user can get stats on packets that were received by the application, dropped by the NIC (due to full
* NIC buffers), etc. Stats collection can be initiated by the user by calling getStatistics() or be pushed to the user periodically by
* supplying a callback and a timeout to startCapture()
* - Send packets back to the network. Sending the packets is done on the caller thread. No additional threads are created for this task
*/
class PcapLiveDevice : public IPcapDevice
{
friend class PcapLiveDeviceList;
protected:
// This is a second descriptor for the same device. It is needed because of a bug
// that occurs in libpcap on Linux (on Windows using WinPcap it works well):
// It's impossible to capture packets sent by the same descriptor
pcap_t* m_PcapSendDescriptor;
const char* m_Name;
const char* m_Description;
bool m_IsLoopback;
uint16_t m_DeviceMtu;
std::vector<pcap_addr_t> m_Addresses;
MacAddress m_MacAddress;
IPv4Address m_DefaultGateway;
PcapThread* m_CaptureThread;
bool m_CaptureThreadStarted;
PcapThread* m_StatsThread;
bool m_StatsThreadStarted;
bool m_StopThread;
OnPacketArrivesCallback m_cbOnPacketArrives;
void* m_cbOnPacketArrivesUserCookie;
OnStatsUpdateCallback m_cbOnStatsUpdate;
void* m_cbOnStatsUpdateUserCookie;
OnPacketArrivesStopBlocking m_cbOnPacketArrivesBlockingMode;
void* m_cbOnPacketArrivesBlockingModeUserCookie;
int m_IntervalToUpdateStats;
RawPacketVector* m_CapturedPackets;
bool m_CaptureCallbackMode;
LinkLayerType m_LinkType;
// c'tor is not public, there should be only one for every interface (created by PcapLiveDeviceList)
PcapLiveDevice(pcap_if_t* pInterface, bool calculateMTU, bool calculateMacAddress, bool calculateDefaultGateway);
// copy c'tor is not public
PcapLiveDevice( const PcapLiveDevice& other );
PcapLiveDevice& operator=(const PcapLiveDevice& other);
void setDeviceMtu();
void setDeviceMacAddress();
void setDefaultGateway();
static void* captureThreadMain(void* ptr);
static void* statsThreadMain(void* ptr);
static void onPacketArrives(uint8_t* user, const struct pcap_pkthdr* pkthdr, const uint8_t* packet);
static void onPacketArrivesNoCallback(uint8_t* user, const struct pcap_pkthdr* pkthdr, const uint8_t* packet);
static void onPacketArrivesBlockingMode(uint8_t* user, const struct pcap_pkthdr* pkthdr, const uint8_t* packet);
std::string printThreadId(PcapThread* id);
virtual ThreadStart getCaptureThreadStart();
public:
/**
* The type of the live device
*/
enum LiveDeviceType
{
/** libPcap live device */
LibPcapDevice,
/** WinPcap live device */
WinPcapDevice,
/** WinPcap Remote Capture device */
RemoteDevice
};
/**
* Device capturing mode
*/
enum DeviceMode
{
/** Only packets that their destination is this NIC are captured */
Normal = 0,
/** All packets that arrive to the NIC are captured, even packets that their destination isn't this NIC */
Promiscuous = 1
};
/**
* Set direction for capturing packets (you can read more here: <https://www.tcpdump.org/manpages/pcap.3pcap.html#lbAI>)
*/
enum PcapDirection
{
/** Capture traffics both incoming and outgoing */
PCPP_INOUT = 0,
/** Only capture incoming traffics */
PCPP_IN,
/** Only capture outgoing traffics */
PCPP_OUT
};
/**
* @struct DeviceConfiguration
* A struct that contains user configurable parameters for opening a device. All parameters have default values so
* the user isn't expected to set all parameters or understand exactly how they work
*/
struct DeviceConfiguration
{
/** Indicates whether to open the device in promiscuous or normal mode */
DeviceMode mode;
/** Set the packet buffer timeout in milliseconds. You can read more here:
* https://www.tcpdump.org/manpages/pcap.3pcap.html .
* Any value above 0 is considered legal, otherwise a value of 1 or -1 is used (depends on the platform)
*/
int packetBufferTimeoutMs;
/**
* Set the packet buffer size. You can read more about the packet buffer here:
* https://www.tcpdump.org/manpages/pcap.3pcap.html .
* Any value of 100 or above is considered valid, otherwise the default value is used (which varies between different OS's).
* However, please notice that setting values which are too low or two high may result in failure to open the device.
* These too low or too high thresholds may vary between OS's, as an example please refer to this thread:
* https://stackoverflow.com/questions/11397367/issue-in-pcap-set-buffer-size
*/
int packetBufferSize;
/**
* Set the direction for capturing packets. You can read more here:
* <https://www.tcpdump.org/manpages/pcap.3pcap.html#lbAI>.
*/
PcapDirection direction;
/**
* A c'tor for this struct
* @param[in] mode The mode to open the device: promiscuous or non-promiscuous. Default value is promiscuous
* @param[in] packetBufferTimeoutMs Buffer timeout in millisecond. Default value is 0 which means set timeout of
* 1 or -1 (depends on the platform)
* @param[in] packetBufferSize The packet buffer size. Default value is 0 which means use the default value
* (varies between different OS's)
* @param[in] direction Direction for capturing packtes. Default value is INOUT which means capture both incoming
* and outgoing packets (not all platforms support this)
*/
DeviceConfiguration(DeviceMode mode = Promiscuous, int packetBufferTimeoutMs = 0, int packetBufferSize = 0, PcapDirection direction = PCPP_INOUT)
{
this->mode = mode;
this->packetBufferTimeoutMs = packetBufferTimeoutMs;
this->packetBufferSize = packetBufferSize;
this->direction = PCPP_INOUT;
}
};
/**
* A destructor for this class
*/
virtual ~PcapLiveDevice();
/**
* @return The type of the device (libPcap, WinPcap or a remote device)
*/
virtual LiveDeviceType getDeviceType() const { return LibPcapDevice; }
/**
* @return The name of the device (e.g eth0), taken from pcap_if_t->name
*/
const char* getName() const { return m_Name; }
/**
* @return A human-readable description of the device, taken from pcap_if_t->description. May be NULL in some interfaces
*/
const char* getDesc() const { return m_Description; }
/**
* @return True if this interface is a loopback interface, false otherwise
*/
bool getLoopback() const { return m_IsLoopback; }
/**
* @return The device's maximum transmission unit (MTU) in bytes
*/
virtual uint16_t getMtu() const { return m_DeviceMtu; }
/**
* @return The device's link layer type
*/
virtual LinkLayerType getLinkType() const { return m_LinkType; }
/**
* @return A vector containing all addresses defined for this interface, each in pcap_addr_t struct
*/
const std::vector<pcap_addr_t>& getAddresses() const { return m_Addresses; }
/**
* @return The MAC address for this interface
*/
virtual MacAddress getMacAddress() const { return m_MacAddress; }
/**
* @return The IPv4 address for this interface. If multiple IPv4 addresses are defined for this interface, the first will be picked.
* If no IPv4 addresses are defined, a zeroed IPv4 address (IPv4Address#Zero) will be returned
*/
IPv4Address getIPv4Address() const;
/**
* @return The default gateway defined for this interface. If no default gateway is defined, if it's not IPv4 or if couldn't extract
* default gateway IPv4Address#Zero will be returned. If multiple gateways were defined the first one will be returned
*/
IPv4Address getDefaultGateway() const;
/**
* @return A list of all DNS servers defined for this machine. If this list is empty it means no DNS servers were defined or they
* couldn't be extracted from some reason. This list is created in PcapLiveDeviceList class and can be also retrieved from there.
* This method exists for convenience - so it'll be possible to get this list from PcapLiveDevice as well
*/
const std::vector<IPv4Address>& getDnsServers() const;
/**
* Start capturing packets on this network interface (device). Each time a packet is captured the onPacketArrives callback is called.
* The capture is done on a new thread created by this method, meaning all callback calls are done in a thread other than the
* caller thread. Capture process will stop and this capture thread will be terminated when calling stopCapture(). This method must be
* called after the device is opened (i.e the open() method was called), otherwise an error will be returned.
* @param[in] onPacketArrives A callback that is called each time a packet is captured
* @param[in] onPacketArrivesUserCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
* each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
* objects that counts packets, manages flow state or manages the application state according to the packet that was captured
* @return True if capture started successfully, false if (relevant log error is printed in any case):
* - Capture is already running
* - Device is not opened
* - Capture thread could not be created
*/
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void* onPacketArrivesUserCookie);
/**
* Start capturing packets on this network interface (device) with periodic stats collection. Each time a packet is captured the onPacketArrives
* callback is called. In addition, each intervalInSecondsToUpdateStats seconds stats are collected from the device and the onStatsUpdate
* callback is called. Both the capture and periodic stats collection are done on new threads created by this method, each on a different thread,
* meaning all callback calls are done in threads other than the caller thread. Capture process and stats collection will stop and threads will be
* terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called), otherwise an
* error will be returned.
* @param[in] onPacketArrives A callback that is called each time a packet is captured
* @param[in] onPacketArrivesUserCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
* each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
* objects that counts packets, manages flow state or manages the application state according to the packet that was captured
* @param[in] intervalInSecondsToUpdateStats The interval in seconds to activate periodic stats collection
* @param[in] onStatsUpdate A callback that will be called each time intervalInSecondsToUpdateStats expires and stats are collected. This
* callback will contain the collected stats
* @param[in] onStatsUpdateUserCookie A pointer to a user provided object. This object will be transferred to the onStatsUpdate callback
* each time it is called
* @return True if capture started successfully, false if (relevant log error is printed in any case):
* - Capture is already running
* - Device is not opened
* - Capture thread could not be created
* - Stats collection thread could not be created
*/
virtual bool startCapture(OnPacketArrivesCallback onPacketArrives, void* onPacketArrivesUserCookie, int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUserCookie);
/**
* Start capturing packets on this network interface (device) with periodic stats collection only. This means that packets arriving to the
* network interface aren't delivered to the user but only counted. Each intervalInSecondsToUpdateStats seconds stats are collected from the
* device and the onStatsUpdate callback is called with the updated counters. The periodic stats collection is done on a new thread created
* by this method, meaning all callback calls are done in threads other than the caller thread. Stats collection will stop and threads will
* be terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called),
* otherwise an error will be returned.
* @param[in] intervalInSecondsToUpdateStats The interval in seconds to activate periodic stats collection
* @param[in] onStatsUpdate A callback that will be called each time intervalInSecondsToUpdateStats expires and stats are collected. This
* callback will contain the collected stats
* @param[in] onStatsUpdateUserCookie A pointer to a user provided object. This object will be transferred to the onStatsUpdate callback
* each time it is called
* @return True if capture started successfully, false if (relevant log error is printed in any case):
* - Capture is already running
* - Device is not opened
* - Stats collection thread could not be created
*/
virtual bool startCapture(int intervalInSecondsToUpdateStats, OnStatsUpdateCallback onStatsUpdate, void* onStatsUpdateUserCookie);
/**
* Start capturing packets on this network interface (device). All captured packets are added to capturedPacketsVector, so at the end of
* the capture (when calling stopCapture()) this vector contains pointers to all captured packets in the form of RawPacket. The capture
* is done on a new thread created by this method, meaning capturedPacketsVector is updated from another thread other than the caller
* thread (so user should avoid changing or iterating this vector while capture is on). Capture process will stop and this capture thread
* will be terminated when calling stopCapture(). This method must be called after the device is opened (i.e the open() method was called),
* otherwise an error will be returned.
* @param[in] capturedPacketsVector A reference to a RawPacketVector, meaning a vector of pointer to RawPacket objects
* @return True if capture started successfully, false if (relevant log error is printed in any case):
* - Capture is already running
* - Device is not opened
* - Capture thread could not be created
*/
virtual bool startCapture(RawPacketVector& capturedPacketsVector);
/**
* Start capturing packets on this network interface (device) in blocking mode, meaning this method blocks and won't return until
* the user frees the blocking (via onPacketArrives callback) or until a user defined timeout expires.
* Whenever a packets is captured the onPacketArrives callback is called and lets the user handle the packet. In each callback call
* the user should return true if he wants to release the block or false if it wants it to keep blocking. Regardless of this callback
* a timeout is defined when start capturing. When this timeout expires the method will return.<BR>
* Please notice that stopCapture() isn't needed here because when the method returns (after timeout or per user decision) capturing
* on the device is stopped
* @param[in] onPacketArrives A callback given by the user for handling incoming packets. After handling each packet the user needs to
* return a boolean value. True value indicates stop capturing and stop blocking and false value indicates continue capturing and blocking
* @param[in] userCookie A pointer to a user provided object. This object will be transferred to the onPacketArrives callback
* each time it is called. This cookie is very useful for transferring objects that give context to the capture callback, for example:
* objects that counts packets, manages flow state or manages the application state according to the packet that was captured
* @param[in] timeout A timeout in seconds for the blocking to stop even if the user didn't return "true" in the onPacketArrives callback
* If this timeout is set to 0 or less the timeout will be ignored, meaning the method will keep blocking until the user frees it via
* the onPacketArrives callback
* @return -1 if timeout expired, 1 if blocking was stopped via onPacketArrives callback or 0 if an error occurred (such as device
* not open etc.). When returning 0 an appropriate error message is printed to log
*/
virtual int startCaptureBlockingMode(OnPacketArrivesStopBlocking onPacketArrives, void* userCookie, int timeout);
/**
* Stop a currently running packet capture. This method terminates gracefully both packet capture thread and periodic stats collection
* thread (both if exist)
*/
void stopCapture();
/**
* Check if a capture thread is running
* @return True if a capture thread is currently running
*/
bool captureActive();
/**
* Send a RawPacket to the network
* @param[in] rawPacket A reference to the raw packet to send. This method treats the raw packet as read-only, it doesn't change anything
* in it
* @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
* - Device is not opened
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
bool sendPacket(RawPacket const& rawPacket);
/**
* Send a buffer containing packet raw data (including all layers) to the network
* @param[in] packetData The buffer containing the packet raw data
* @param[in] packetDataLength The length of the buffer
* @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
* - Device is not opened
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
bool sendPacket(const uint8_t* packetData, int packetDataLength);
/**
* Send a parsed Packet to the network
* @param[in] packet A pointer to the packet to send. This method treats the packet as read-only, it doesn't change anything in it
* @return True if packet was sent successfully. False will be returned in the following cases (relevant log error is printed in any case):
* - Device is not opened
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
bool sendPacket(Packet* packet);
/**
* Send an array of RawPacket objects to the network
* @param[in] rawPacketsArr The array of RawPacket objects to send. This method treats all packets as read-only, it doesn't change anything
* in them
* @param[in] arrLength The length of the array
* @return The number of packets sent successfully. Sending a packet can fail if:
* - Device is not opened. In this case no packets will be sent, return value will be 0
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
virtual int sendPackets(RawPacket* rawPacketsArr, int arrLength);
/**
* Send an array of pointers to Packet objects to the network
* @param[in] packetsArr The array of pointers to Packet objects to send. This method treats all packets as read-only, it doesn't change
* anything in them
* @param[in] arrLength The length of the array
* @return The number of packets sent successfully. Sending a packet can fail if:
* - Device is not opened. In this case no packets will be sent, return value will be 0
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
virtual int sendPackets(Packet** packetsArr, int arrLength);
/**
* Send a vector of pointers to RawPacket objects to the network
* @param[in] rawPackets The array of pointers to RawPacket objects to send. This method treats all packets as read-only, it doesn't change
* anything in them
* @return The number of packets sent successfully. Sending a packet can fail if:
* - Device is not opened. In this case no packets will be sent, return value will be 0
* - Packet length is 0
* - Packet length is larger than device MTU
* - Packet could not be sent due to some error in libpcap/WinPcap
*/
virtual int sendPackets(const RawPacketVector& rawPackets);
// implement abstract methods
/**
* Open the device using libpcap pcap_open_live. Opening the device only makes the device ready for use, it doesn't start packet capturing.
* For packet capturing the user should call startCapture(). This implies that calling this method is a must before calling startCapture()
* (otherwise startCapture() will fail with a "device not open" error). The device is opened in promiscuous mode
* @return True if the device was opened successfully, false otherwise. When opening the device fails an error will be printed to log
* as well
*/
bool open();
/**
* Enables to open a device in a non-default configuration. Configuration has parameters like packet buffer timeout & size, open in
* promiscuous/non-promiscuous mode, etc. Please check DeviceConfiguration for more details
* @param[in] config The requested configuration
* @return Same as open()
*/
bool open(const DeviceConfiguration& config);
void close();
virtual void getStatistics(pcap_stat& stats) const;
protected:
pcap_t* doOpen(const DeviceConfiguration& config);
};
} // namespace pcpp
#endif
| 50.843177 | 206 | 0.750361 |
fa5818cec8991313a45a7c9dac5adc8a54186903 | 796 | h | C | MMOCoreORB/src/server/status/StatusHandler.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 18 | 2017-02-09T15:36:05.000Z | 2021-12-21T04:22:15.000Z | MMOCoreORB/src/server/status/StatusHandler.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 61 | 2016-12-30T21:51:10.000Z | 2021-12-10T20:25:56.000Z | MMOCoreORB/src/server/status/StatusHandler.h | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 71 | 2017-01-01T05:34:38.000Z | 2022-03-29T01:04:00.000Z | /*
* StatusHandler.h
*
* Created on: Oct 5, 2010
* Author: oru
*/
#ifndef STATUSHANDLER_H_
#define STATUSHANDLER_H_
#include "StatusServer.h"
class StatusHandler: public ServiceHandler {
StatusServer* statusServerRef;
public:
StatusHandler(StatusServer* server) {
statusServerRef = server;
}
void initialize() {
}
ServiceClient* createConnection(Socket* sock, SocketAddress& addr) {
return statusServerRef->createConnection(sock, addr);
}
bool deleteConnection(ServiceClient* client) {
return false;
}
void handleMessage(ServiceClient* client, Packet* message) {
}
void processMessage(Message* message) {
}
bool handleError(ServiceClient* client, Exception& e) {
return false;
}
};
using namespace server::zone;
#endif /* STATUSHANDLER_H_ */
| 14.740741 | 69 | 0.719849 |
cfce04786666c7e079c2d2c8627b6f7e6a5fbef4 | 7,879 | h | C | new/shlr/qnx/include/gdb_signals.h | benbenwt/lisa_docker | 0b851223dbaecef9b27c418eae05890fea752d49 | [
"Apache-2.0"
] | null | null | null | new/shlr/qnx/include/gdb_signals.h | benbenwt/lisa_docker | 0b851223dbaecef9b27c418eae05890fea752d49 | [
"Apache-2.0"
] | 1 | 2021-12-17T00:14:27.000Z | 2021-12-17T00:14:27.000Z | new/shlr/qnx/include/gdb_signals.h | benbenwt/lisa_docker | 0b851223dbaecef9b27c418eae05890fea752d49 | [
"Apache-2.0"
] | null | null | null | /* Target signal numbers for GDB and the GDB remote protocol.
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
This file is part of GDB.
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef GDB_SIGNALS_H
#define GDB_SIGNALS_H
/* The numbering of these signals is chosen to match traditional unix
signals (insofar as various unices use the same numbers, anyway).
It is also the numbering of the GDB remote protocol. Other remote
protocols, if they use a different numbering, should make sure to
translate appropriately.
Since these numbers have actually made it out into other software
(stubs, etc.), you mustn't disturb the assigned numbering. If you
need to add new signals here, add them to the end of the explicitly
numbered signals, at the comment marker. Add them unconditionally,
not within any #if or #ifdef.
This is based strongly on Unix/POSIX signals for several reasons:
(1) This set of signals represents a widely-accepted attempt to
represent events of this sort in a portable fashion, (2) we want a
signal to make it from wait to child_wait to the user intact, (3) many
remote protocols use a similar encoding. However, it is
recognized that this set of signals has limitations (such as not
distinguishing between various kinds of SIGSEGV, or not
distinguishing hitting a breakpoint from finishing a single step).
So in the future we may get around this either by adding additional
signals for breakpoint, single-step, etc., or by adding signal
codes; the latter seems more in the spirit of what BSD, System V,
etc. are doing to address these issues. */
/* For an explanation of what each signal means, see
target_signal_to_string. */
enum target_signal {
/* Used some places (e.g. stop_signal) to record the concept that
there is no signal. */
TARGET_SIGNAL_0 = 0,
TARGET_SIGNAL_FIRST = 0,
TARGET_SIGNAL_HUP = 1,
TARGET_SIGNAL_INT = 2,
TARGET_SIGNAL_QUIT = 3,
TARGET_SIGNAL_ILL = 4,
TARGET_SIGNAL_TRAP = 5,
TARGET_SIGNAL_ABRT = 6,
TARGET_SIGNAL_EMT = 7,
TARGET_SIGNAL_FPE = 8,
TARGET_SIGNAL_KILL = 9,
TARGET_SIGNAL_BUS = 10,
TARGET_SIGNAL_SEGV = 11,
TARGET_SIGNAL_SYS = 12,
TARGET_SIGNAL_PIPE = 13,
TARGET_SIGNAL_ALRM = 14,
TARGET_SIGNAL_TERM = 15,
TARGET_SIGNAL_URG = 16,
TARGET_SIGNAL_STOP = 17,
TARGET_SIGNAL_TSTP = 18,
TARGET_SIGNAL_CONT = 19,
TARGET_SIGNAL_CHLD = 20,
TARGET_SIGNAL_TTIN = 21,
TARGET_SIGNAL_TTOU = 22,
TARGET_SIGNAL_IO = 23,
TARGET_SIGNAL_XCPU = 24,
TARGET_SIGNAL_XFSZ = 25,
TARGET_SIGNAL_VTALRM = 26,
TARGET_SIGNAL_PROF = 27,
TARGET_SIGNAL_WINCH = 28,
TARGET_SIGNAL_LOST = 29,
TARGET_SIGNAL_USR1 = 30,
TARGET_SIGNAL_USR2 = 31,
TARGET_SIGNAL_PWR = 32,
/* Similar to SIGIO. Perhaps they should have the same number. */
TARGET_SIGNAL_POLL = 33,
TARGET_SIGNAL_WIND = 34,
TARGET_SIGNAL_PHONE = 35,
TARGET_SIGNAL_WAITING = 36,
TARGET_SIGNAL_LWP = 37,
TARGET_SIGNAL_DANGER = 38,
TARGET_SIGNAL_GRANT = 39,
TARGET_SIGNAL_RETRACT = 40,
TARGET_SIGNAL_MSG = 41,
TARGET_SIGNAL_SOUND = 42,
TARGET_SIGNAL_SAK = 43,
TARGET_SIGNAL_PRIO = 44,
TARGET_SIGNAL_REALTIME_33 = 45,
TARGET_SIGNAL_REALTIME_34 = 46,
TARGET_SIGNAL_REALTIME_35 = 47,
TARGET_SIGNAL_REALTIME_36 = 48,
TARGET_SIGNAL_REALTIME_37 = 49,
TARGET_SIGNAL_REALTIME_38 = 50,
TARGET_SIGNAL_REALTIME_39 = 51,
TARGET_SIGNAL_REALTIME_40 = 52,
TARGET_SIGNAL_REALTIME_41 = 53,
TARGET_SIGNAL_REALTIME_42 = 54,
TARGET_SIGNAL_REALTIME_43 = 55,
TARGET_SIGNAL_REALTIME_44 = 56,
TARGET_SIGNAL_REALTIME_45 = 57,
TARGET_SIGNAL_REALTIME_46 = 58,
TARGET_SIGNAL_REALTIME_47 = 59,
TARGET_SIGNAL_REALTIME_48 = 60,
TARGET_SIGNAL_REALTIME_49 = 61,
TARGET_SIGNAL_REALTIME_50 = 62,
TARGET_SIGNAL_REALTIME_51 = 63,
TARGET_SIGNAL_REALTIME_52 = 64,
TARGET_SIGNAL_REALTIME_53 = 65,
TARGET_SIGNAL_REALTIME_54 = 66,
TARGET_SIGNAL_REALTIME_55 = 67,
TARGET_SIGNAL_REALTIME_56 = 68,
TARGET_SIGNAL_REALTIME_57 = 69,
TARGET_SIGNAL_REALTIME_58 = 70,
TARGET_SIGNAL_REALTIME_59 = 71,
TARGET_SIGNAL_REALTIME_60 = 72,
TARGET_SIGNAL_REALTIME_61 = 73,
TARGET_SIGNAL_REALTIME_62 = 74,
TARGET_SIGNAL_REALTIME_63 = 75,
/* Used internally by Solaris threads. See signal(5) on Solaris. */
TARGET_SIGNAL_CANCEL = 76,
/* Yes, this pains me, too. But LynxOS didn't have SIG32, and now
GNU/Linux does, and we can't disturb the numbering, since it's
part of the remote protocol. Note that in some GDB's
TARGET_SIGNAL_REALTIME_32 is number 76. */
TARGET_SIGNAL_REALTIME_32,
/* Yet another pain, IRIX 6 has SIG64. */
TARGET_SIGNAL_REALTIME_64,
/* Yet another pain, GNU/Linux MIPS might go up to 128. */
TARGET_SIGNAL_REALTIME_65,
TARGET_SIGNAL_REALTIME_66,
TARGET_SIGNAL_REALTIME_67,
TARGET_SIGNAL_REALTIME_68,
TARGET_SIGNAL_REALTIME_69,
TARGET_SIGNAL_REALTIME_70,
TARGET_SIGNAL_REALTIME_71,
TARGET_SIGNAL_REALTIME_72,
TARGET_SIGNAL_REALTIME_73,
TARGET_SIGNAL_REALTIME_74,
TARGET_SIGNAL_REALTIME_75,
TARGET_SIGNAL_REALTIME_76,
TARGET_SIGNAL_REALTIME_77,
TARGET_SIGNAL_REALTIME_78,
TARGET_SIGNAL_REALTIME_79,
TARGET_SIGNAL_REALTIME_80,
TARGET_SIGNAL_REALTIME_81,
TARGET_SIGNAL_REALTIME_82,
TARGET_SIGNAL_REALTIME_83,
TARGET_SIGNAL_REALTIME_84,
TARGET_SIGNAL_REALTIME_85,
TARGET_SIGNAL_REALTIME_86,
TARGET_SIGNAL_REALTIME_87,
TARGET_SIGNAL_REALTIME_88,
TARGET_SIGNAL_REALTIME_89,
TARGET_SIGNAL_REALTIME_90,
TARGET_SIGNAL_REALTIME_91,
TARGET_SIGNAL_REALTIME_92,
TARGET_SIGNAL_REALTIME_93,
TARGET_SIGNAL_REALTIME_94,
TARGET_SIGNAL_REALTIME_95,
TARGET_SIGNAL_REALTIME_96,
TARGET_SIGNAL_REALTIME_97,
TARGET_SIGNAL_REALTIME_98,
TARGET_SIGNAL_REALTIME_99,
TARGET_SIGNAL_REALTIME_100,
TARGET_SIGNAL_REALTIME_101,
TARGET_SIGNAL_REALTIME_102,
TARGET_SIGNAL_REALTIME_103,
TARGET_SIGNAL_REALTIME_104,
TARGET_SIGNAL_REALTIME_105,
TARGET_SIGNAL_REALTIME_106,
TARGET_SIGNAL_REALTIME_107,
TARGET_SIGNAL_REALTIME_108,
TARGET_SIGNAL_REALTIME_109,
TARGET_SIGNAL_REALTIME_110,
TARGET_SIGNAL_REALTIME_111,
TARGET_SIGNAL_REALTIME_112,
TARGET_SIGNAL_REALTIME_113,
TARGET_SIGNAL_REALTIME_114,
TARGET_SIGNAL_REALTIME_115,
TARGET_SIGNAL_REALTIME_116,
TARGET_SIGNAL_REALTIME_117,
TARGET_SIGNAL_REALTIME_118,
TARGET_SIGNAL_REALTIME_119,
TARGET_SIGNAL_REALTIME_120,
TARGET_SIGNAL_REALTIME_121,
TARGET_SIGNAL_REALTIME_122,
TARGET_SIGNAL_REALTIME_123,
TARGET_SIGNAL_REALTIME_124,
TARGET_SIGNAL_REALTIME_125,
TARGET_SIGNAL_REALTIME_126,
TARGET_SIGNAL_REALTIME_127,
TARGET_SIGNAL_INFO,
/* Some signal we don't know about. */
TARGET_SIGNAL_UNKNOWN,
/* Use whatever signal we use when one is not specifically specified
(for passing to proceed and so on). */
TARGET_SIGNAL_DEFAULT,
/* Mach exceptions. In versions of GDB before 5.2, these were just before
TARGET_SIGNAL_INFO if you were compiling on a Mach host (and missing
otherwise). */
TARGET_EXC_BAD_ACCESS,
TARGET_EXC_BAD_INSTRUCTION,
TARGET_EXC_ARITHMETIC,
TARGET_EXC_EMULATION,
TARGET_EXC_SOFTWARE,
TARGET_EXC_BREAKPOINT,
/* If you are adding a new signal, add it just above this comment. */
/* Last and unused enum value, for sizing arrays, etc. */
TARGET_SIGNAL_LAST
};
#endif /* #ifndef GDB_SIGNALS_H */
| 33.67094 | 78 | 0.787663 |
82e95f24d11b17ba8517884e3770b9ccc47a3806 | 22,937 | c | C | kernel/tasks.c | mincheolsung/VT_Project3_Hermitcore | f5390e2468a3070f541ab0a50df23803bca1390f | [
"BSD-3-Clause"
] | null | null | null | kernel/tasks.c | mincheolsung/VT_Project3_Hermitcore | f5390e2468a3070f541ab0a50df23803bca1390f | [
"BSD-3-Clause"
] | null | null | null | kernel/tasks.c | mincheolsung/VT_Project3_Hermitcore | f5390e2468a3070f541ab0a50df23803bca1390f | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2010, Stefan Lankes, RWTH Aachen University
* 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 the University 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 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hermit/stddef.h>
#include <hermit/stdlib.h>
#include <hermit/stdio.h>
#include <hermit/string.h>
#include <hermit/tasks.h>
#include <hermit/tasks_types.h>
#include <hermit/spinlock.h>
#include <hermit/time.h>
#include <hermit/errno.h>
#include <hermit/syscall.h>
#include <hermit/memory.h>
#include <hermit/logging.h>
#include <asm/processor.h>
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
*/
extern atomic_int32_t cpu_online;
volatile uint32_t go_down = 0;
#define TLS_OFFSET 8
/** @brief Array of task structures (aka PCB)
*
* A task's id will be its position in this array.
*/
static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_IDLE, 0, NULL, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, 0, NULL, 0, NULL, NULL, 0, 0, 0, NULL, FPU_STATE_INIT}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, NULL, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, 0, NULL, 0, NULL, NULL, 0, 0, 0, NULL, FPU_STATE_INIT}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
#if MAX_CORES > 1
static readyqueues_t readyqueues[MAX_CORES] = { \
[0 ... MAX_CORES-1] = {NULL, NULL, 0, 0, 0, {[0 ... MAX_PRIO-2] = {NULL, NULL}}, {NULL, NULL}, SPINLOCK_IRQSAVE_INIT}};
#else
static readyqueues_t readyqueues[1] = {[0] = {task_table+0, NULL, 0, 0, 0, {[0 ... MAX_PRIO-2] = {NULL, NULL}}, {NULL, NULL}, SPINLOCK_IRQSAVE_INIT}};
#endif
DEFINE_PER_CORE(task_t*, current_task, task_table+0);
#if MAX_CORES > 1
DEFINE_PER_CORE(uint32_t, __core_id, 0);
#endif
extern const void boot_stack;
extern const void boot_ist;
static void update_timer(task_t* first)
{
if(first) {
if(first->timeout > get_clock_tick()) {
timer_deadline((uint32_t) (first->timeout - get_clock_tick()));
} else {
// workaround: start timer so new head will be serviced
timer_deadline(1);
}
} else {
// prevent spurious interrupts
timer_disable();
}
}
static void timer_queue_remove(uint32_t core_id, task_t* task)
{
if(BUILTIN_EXPECT(!task, 0)) {
return;
}
task_list_t* timer_queue = &readyqueues[core_id].timers;
#ifdef DYNAMIC_TICKS
// if task is first in timer queue, we need to update the oneshot
// timer for the next task
if(timer_queue->first == task) {
update_timer(task->next);
}
#endif
task_list_remove_task(timer_queue, task);
}
static void timer_queue_push(uint32_t core_id, task_t* task)
{
task_list_t* timer_queue = &readyqueues[core_id].timers;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
task_t* first = timer_queue->first;
if(!first) {
timer_queue->first = timer_queue->last = task;
task->next = task->prev = NULL;
#ifdef DYNAMIC_TICKS
update_timer(task);
#endif
} else {
// lookup position where to insert task
task_t* tmp = first;
while(tmp && (task->timeout >= tmp->timeout))
tmp = tmp->next;
if(!tmp) {
// insert at the end of queue
task->next = NULL;
task->prev = timer_queue->last;
// there has to be a last element because there is also a first one
timer_queue->last->next = task;
timer_queue->last = task;
} else {
task->next = tmp;
task->prev = tmp->prev;
tmp->prev = task;
if(task->prev)
task->prev->next = task;
if(timer_queue->first == tmp) {
timer_queue->first = task;
#ifdef DYNAMIC_TICKS
update_timer(task);
#endif
}
}
}
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
}
static inline void readyqueues_push_back(uint32_t core_id, task_t* task)
{
// idle task (prio=0) doesn't have a queue
task_list_t* readyqueue = &readyqueues[core_id].queue[task->prio - 1];
task_list_push_back(readyqueue, task);
// update priority bitmap
readyqueues[core_id].prio_bitmap |= (1 << task->prio);
}
static inline void readyqueues_remove(uint32_t core_id, task_t* task)
{
// idle task (prio=0) doesn't have a queue
task_list_t* readyqueue = &readyqueues[core_id].queue[task->prio - 1];
task_list_remove_task(readyqueue, task);
// no valid task in queue => update priority bitmap
if (readyqueue->first == NULL)
readyqueues[core_id].prio_bitmap &= ~(1 << task->prio);
}
void fpu_handler(void)
{
task_t* task = per_core(current_task);
uint32_t core_id = CORE_ID;
task->flags |= TASK_FPU_USED;
if (!(task->flags & TASK_FPU_INIT)) {
// use the FPU at the first time => Initialize FPU
fpu_init(&task->fpu);
task->flags |= TASK_FPU_INIT;
}
if (readyqueues[core_id].fpu_owner == task->id)
return;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
// did another already use the the FPU? => save FPU state
if (readyqueues[core_id].fpu_owner) {
save_fpu_state(&(task_table[readyqueues[core_id].fpu_owner].fpu));
task_table[readyqueues[core_id].fpu_owner].flags &= ~TASK_FPU_USED;
}
readyqueues[core_id].fpu_owner = task->id;
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
restore_fpu_state(&task->fpu);
}
void check_scheduling(void)
{
if (!is_irq_enabled())
return;
uint32_t prio = get_highest_priority();
task_t* curr_task = per_core(current_task);
if (prio > curr_task->prio) {
reschedule();
#ifdef DYNAMIC_TICKS
} else if ((prio > 0) && (prio == curr_task->prio)) {
// if a task is ready, check if the current task runs already one tick (one time slice)
// => reschedule to realize round robin
const uint64_t diff_cycles = get_rdtsc() - curr_task->last_tsc;
const uint64_t cpu_freq_hz = 1000000ULL * (uint64_t) get_cpu_frequency();
if (((diff_cycles * (uint64_t) TIMER_FREQ) / cpu_freq_hz) > 0) {
LOG_DEBUG("Time slice expired for task %d on core %d. New task has priority %u.\n", curr_task->id, CORE_ID, prio);
reschedule();
}
#endif
}
}
uint32_t get_highest_priority(void)
{
uint32_t prio = msb(readyqueues[CORE_ID].prio_bitmap);
if (prio > MAX_PRIO)
return 0;
return prio;
}
void* get_readyqueue(void)
{
return &readyqueues[CORE_ID];
}
int multitasking_init(void)
{
uint32_t core_id = CORE_ID;
if (BUILTIN_EXPECT(task_table[0].status != TASK_IDLE, 0)) {
LOG_ERROR("Task 0 is not an idle task\n");
return -ENOMEM;
}
task_table[0].prio = IDLE_PRIO;
task_table[0].stack = (char*) ((size_t)&boot_stack + core_id * KERNEL_STACK_SIZE);
task_table[0].ist_addr = (char*)&boot_ist;
set_per_core(current_task, task_table+0);
arch_init_task(task_table+0);
readyqueues[core_id].idle = task_table+0;
return 0;
}
int set_idle_task(void)
{
uint32_t i, core_id = CORE_ID;
int ret = -ENOMEM;
spinlock_irqsave_lock(&table_lock);
for(i=0; i<MAX_TASKS; i++) {
if (task_table[i].status == TASK_INVALID) {
task_table[i].id = i;
task_table[i].status = TASK_IDLE;
task_table[i].last_core = core_id;
task_table[i].last_stack_pointer = NULL;
task_table[i].stack = (char*) ((size_t)&boot_stack + core_id * KERNEL_STACK_SIZE);
task_table[i].ist_addr = create_stack(KERNEL_STACK_SIZE);
task_table[i].prio = IDLE_PRIO;
task_table[i].heap = NULL;
readyqueues[core_id].idle = task_table+i;
set_per_core(current_task, readyqueues[core_id].idle);
arch_init_task(task_table+i);
ret = 0;
break;
}
}
spinlock_irqsave_unlock(&table_lock);
return ret;
}
void finish_task_switch(void)
{
task_t* old;
const uint32_t core_id = CORE_ID;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
if ((old = readyqueues[core_id].old_task) != NULL) {
readyqueues[core_id].old_task = NULL;
if (old->status == TASK_FINISHED) {
/* cleanup task */
if (old->stack) {
LOG_INFO("Release stack at 0x%zx\n", old->stack);
destroy_stack(old->stack, DEFAULT_STACK_SIZE);
old->stack = NULL;
}
if (!old->parent && old->heap) {
kfree(old->heap);
old->heap = NULL;
}
if (old->ist_addr) {
destroy_stack(old->ist_addr, KERNEL_STACK_SIZE);
old->ist_addr = NULL;
}
old->last_stack_pointer = NULL;
if (readyqueues[core_id].fpu_owner == old->id)
readyqueues[core_id].fpu_owner = 0;
/* signalizes that this task could be reused */
old->status = TASK_INVALID;
} else {
// re-enqueue old task
readyqueues_push_back(core_id, old);
}
}
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
}
void NORETURN do_exit(int arg)
{
task_t* curr_task = per_core(current_task);
void* tls_addr = NULL;
const uint32_t core_id = CORE_ID;
LOG_INFO("Terminate task: %u, return value %d\n", curr_task->id, arg);
uint8_t flags = irq_nested_disable();
// decrease the number of active tasks
spinlock_irqsave_lock(&readyqueues[core_id].lock);
readyqueues[core_id].nr_tasks--;
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
// do we need to release the TLS?
tls_addr = (void*)get_tls();
if (tls_addr) {
LOG_INFO("Release TLS at %p\n", (char*)tls_addr - curr_task->tls_size);
kfree((char*)tls_addr - curr_task->tls_size - TLS_OFFSET);
}
curr_task->status = TASK_FINISHED;
reschedule();
irq_nested_enable(flags);
LOG_ERROR("Kernel panic: scheduler found no valid task\n");
while(1) {
HALT;
}
}
void NORETURN leave_kernel_task(void) {
int result;
result = 0; //get_return_value();
do_exit(result);
}
void NORETURN do_abort(void) {
do_exit(-1);
}
static uint32_t get_next_core_id(void)
{
uint32_t i;
static uint32_t core_id = MAX_CORES;
if (core_id >= MAX_CORES)
core_id = CORE_ID;
// we assume OpenMP applications
// => number of threads is (normaly) equal to the number of cores
// => search next available core
for(i=0, core_id=(core_id+1)%MAX_CORES; i<2*MAX_CORES; i++, core_id=(core_id+1)%MAX_CORES)
if (readyqueues[core_id].idle)
break;
if (BUILTIN_EXPECT(!readyqueues[core_id].idle, 0)) {
LOG_ERROR("BUG: no core available!\n");
return MAX_CORES;
}
return core_id;
}
int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
{
int ret = -EINVAL;
uint32_t i;
void* stack = NULL;
void* ist = NULL;
task_t* curr_task;
uint32_t core_id;
if (BUILTIN_EXPECT(!ep, 0))
return -EINVAL;
if (BUILTIN_EXPECT(prio == IDLE_PRIO, 0))
return -EINVAL;
if (BUILTIN_EXPECT(prio > MAX_PRIO, 0))
return -EINVAL;
curr_task = per_core(current_task);
stack = create_stack(DEFAULT_STACK_SIZE);
if (BUILTIN_EXPECT(!stack, 0))
return -ENOMEM;
ist = create_stack(KERNEL_STACK_SIZE);
if (BUILTIN_EXPECT(!ist, 0)) {
destroy_stack(stack, DEFAULT_STACK_SIZE);
return -ENOMEM;
}
spinlock_irqsave_lock(&table_lock);
core_id = get_next_core_id();
if (BUILTIN_EXPECT(core_id >= MAX_CORES, 0))
{
spinlock_irqsave_unlock(&table_lock);
ret = -EINVAL;
goto out;
}
for(i=0; i<MAX_TASKS; i++) {
if (task_table[i].status == TASK_INVALID) {
task_table[i].id = i;
task_table[i].status = TASK_READY;
task_table[i].last_core = core_id;
task_table[i].last_stack_pointer = NULL;
task_table[i].stack = stack;
task_table[i].prio = prio;
task_table[i].heap = curr_task->heap;
task_table[i].start_tick = get_clock_tick();
task_table[i].last_tsc = 0;
task_table[i].parent = curr_task->id;
task_table[i].tls_addr = curr_task->tls_addr;
task_table[i].tls_size = curr_task->tls_size;
task_table[i].ist_addr = ist;
task_table[i].lwip_err = 0;
task_table[i].signal_handler = NULL;
if (id)
*id = i;
ret = create_default_frame(task_table+i, ep, arg, core_id);
if (ret)
goto out;
// add task in the readyqueues
spinlock_irqsave_lock(&readyqueues[core_id].lock);
readyqueues[core_id].prio_bitmap |= (1 << prio);
readyqueues[core_id].nr_tasks++;
if (!readyqueues[core_id].queue[prio-1].first) {
task_table[i].next = task_table[i].prev = NULL;
readyqueues[core_id].queue[prio-1].first = task_table+i;
readyqueues[core_id].queue[prio-1].last = task_table+i;
} else {
task_table[i].prev = readyqueues[core_id].queue[prio-1].last;
task_table[i].next = NULL;
readyqueues[core_id].queue[prio-1].last->next = task_table+i;
readyqueues[core_id].queue[prio-1].last = task_table+i;
}
// should we wakeup the core?
if (readyqueues[core_id].nr_tasks == 1)
wakeup_core(core_id);
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
break;
}
}
spinlock_irqsave_unlock(&table_lock);
if (!ret) {
LOG_DEBUG("start new thread %d on core %d with stack address %p\n", i, core_id, stack);
}
out:
if (ret) {
destroy_stack(stack, DEFAULT_STACK_SIZE);
destroy_stack(ist, KERNEL_STACK_SIZE);
}
return ret;
}
int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t core_id)
{
int ret = -ENOMEM;
uint32_t i;
void* stack = NULL;
void* ist = NULL;
void* counter = NULL;
if (BUILTIN_EXPECT(!ep, 0))
return -EINVAL;
if (BUILTIN_EXPECT(prio == IDLE_PRIO, 0))
return -EINVAL;
if (BUILTIN_EXPECT(prio > MAX_PRIO, 0))
return -EINVAL;
if (BUILTIN_EXPECT(core_id >= MAX_CORES, 0))
return -EINVAL;
if (BUILTIN_EXPECT(!readyqueues[core_id].idle, 0))
return -EINVAL;
stack = create_stack(DEFAULT_STACK_SIZE);
if (BUILTIN_EXPECT(!stack, 0))
return -ENOMEM;
ist = create_stack(KERNEL_STACK_SIZE);
if (BUILTIN_EXPECT(!ist, 0)) {
destroy_stack(stack, DEFAULT_STACK_SIZE);
return -ENOMEM;
}
counter = kmalloc(sizeof(atomic_int64_t));
if (BUILTIN_EXPECT(!counter, 0)) {
destroy_stack(stack, KERNEL_STACK_SIZE);
destroy_stack(stack, DEFAULT_STACK_SIZE);
return -ENOMEM;
}
atomic_int64_set((atomic_int64_t*) counter, 0);
spinlock_irqsave_lock(&table_lock);
for(i=0; i<MAX_TASKS; i++) {
if (task_table[i].status == TASK_INVALID) {
task_table[i].id = i;
task_table[i].status = TASK_READY;
task_table[i].last_core = core_id;
task_table[i].last_stack_pointer = NULL;
task_table[i].stack = stack;
task_table[i].prio = prio;
task_table[i].heap = NULL;
task_table[i].start_tick = get_clock_tick();
task_table[i].last_tsc = 0;
task_table[i].parent = 0;
task_table[i].ist_addr = ist;
task_table[i].tls_addr = 0;
task_table[i].tls_size = 0;
task_table[i].lwip_err = 0;
task_table[i].signal_handler = NULL;
if (id)
*id = i;
ret = create_default_frame(task_table+i, ep, arg, core_id);
if (ret)
goto out;
// add task in the readyqueues
spinlock_irqsave_lock(&readyqueues[core_id].lock);
readyqueues[core_id].prio_bitmap |= (1 << prio);
readyqueues[core_id].nr_tasks++;
if (!readyqueues[core_id].queue[prio-1].first) {
task_table[i].next = task_table[i].prev = NULL;
readyqueues[core_id].queue[prio-1].first = task_table+i;
readyqueues[core_id].queue[prio-1].last = task_table+i;
} else {
task_table[i].prev = readyqueues[core_id].queue[prio-1].last;
task_table[i].next = NULL;
readyqueues[core_id].queue[prio-1].last->next = task_table+i;
readyqueues[core_id].queue[prio-1].last = task_table+i;
}
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
break;
}
}
if (!ret)
LOG_INFO("start new task %d on core %d with stack address %p\n", i, core_id, stack);
out:
spinlock_irqsave_unlock(&table_lock);
if (ret) {
destroy_stack(stack, DEFAULT_STACK_SIZE);
destroy_stack(ist, KERNEL_STACK_SIZE);
kfree(counter);
}
return ret;
}
int create_kernel_task_on_core(tid_t* id, entry_point_t ep, void* args, uint8_t prio, uint32_t core_id)
{
if (prio > MAX_PRIO)
prio = NORMAL_PRIO;
return create_task(id, ep, args, prio, core_id);
}
int create_kernel_task(tid_t* id, entry_point_t ep, void* args, uint8_t prio)
{
if (prio > MAX_PRIO)
prio = NORMAL_PRIO;
return create_task(id, ep, args, prio, CORE_ID);
}
int wakeup_task(tid_t id)
{
task_t* task;
uint32_t core_id;
int ret = -EINVAL;
uint8_t flags;
flags = irq_nested_disable();
task = &task_table[id];
core_id = task->last_core;
if (task->status == TASK_BLOCKED) {
LOG_DEBUG("wakeup task %d on core %d\n", id, core_id);
task->status = TASK_READY;
ret = 0;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
// if task is in timer queue, remove it
if (task->flags & TASK_TIMER) {
task->flags &= ~TASK_TIMER;
timer_queue_remove(core_id, task);
}
// add task to the ready queue
readyqueues_push_back(core_id, task);
// increase the number of ready tasks
readyqueues[core_id].nr_tasks++;
// should we wakeup the core?
if (readyqueues[core_id].nr_tasks == 1)
wakeup_core(core_id);
LOG_DEBUG("update nr_tasks on core %d to %d\n", core_id, readyqueues[core_id].nr_tasks);
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
}
irq_nested_enable(flags);
return ret;
}
int block_task(tid_t id)
{
task_t* task;
uint32_t core_id;
int ret = -EINVAL;
uint8_t flags;
flags = irq_nested_disable();
task = &task_table[id];
core_id = task->last_core;
if (task->status == TASK_RUNNING) {
LOG_DEBUG("block task %d on core %d\n", id, core_id);
task->status = TASK_BLOCKED;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
// remove task from ready queue
readyqueues_remove(core_id, task);
// reduce the number of ready tasks
readyqueues[core_id].nr_tasks--;
LOG_DEBUG("update nr_tasks on core %d to %d\n", core_id, readyqueues[core_id].nr_tasks);
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
ret = 0;
}
irq_nested_enable(flags);
return ret;
}
int block_current_task(void)
{
return block_task(per_core(current_task)->id);
}
int set_timer(uint64_t deadline)
{
task_t* curr_task;
uint32_t core_id;
uint8_t flags;
int ret = -EINVAL;
flags = irq_nested_disable();
curr_task = per_core(current_task);
core_id = CORE_ID;
if (curr_task->status == TASK_RUNNING) {
// blocks task and removes from ready queue
block_task(curr_task->id);
curr_task->flags |= TASK_TIMER;
curr_task->timeout = deadline;
timer_queue_push(core_id, curr_task);
ret = 0;
} else {
LOG_INFO("Task is already blocked. No timer will be set!\n");
}
irq_nested_enable(flags);
return ret;
}
void check_timers(void)
{
readyqueues_t* readyqueue = &readyqueues[CORE_ID];
spinlock_irqsave_lock(&readyqueue->lock);
// since IRQs are disabled, get_clock_tick() won't increase here
const uint64_t current_tick = get_clock_tick();
// wakeup tasks whose deadline has expired
task_t* task;
while ((task = readyqueue->timers.first) && (task->timeout <= current_tick))
{
// pops task from timer queue, so next iteration has new first element
wakeup_task(task->id);
}
spinlock_irqsave_unlock(&readyqueue->lock);
}
size_t** scheduler(void)
{
task_t* orig_task;
task_t* curr_task;
const uint32_t core_id = CORE_ID;
uint64_t prio;
orig_task = curr_task = per_core(current_task);
curr_task->last_core = core_id;
spinlock_irqsave_lock(&readyqueues[core_id].lock);
/* signalizes that this task could be realized */
if (curr_task->status == TASK_FINISHED)
readyqueues[core_id].old_task = curr_task;
else readyqueues[core_id].old_task = NULL; // reset old task
// do we receive a shutdown IPI => only the idle task should get the core
if (BUILTIN_EXPECT(go_down, 0)) {
if (curr_task->status == TASK_IDLE)
goto get_task_out;
curr_task = readyqueues[core_id].idle;
set_per_core(current_task, curr_task);
}
// determine highest priority
prio = msb(readyqueues[core_id].prio_bitmap);
const int readyqueue_empty = prio > MAX_PRIO;
if (readyqueue_empty) {
if ((curr_task->status == TASK_RUNNING) || (curr_task->status == TASK_IDLE))
goto get_task_out;
curr_task = readyqueues[core_id].idle;
set_per_core(current_task, curr_task);
} else {
// Does the current task have an higher priority? => no task switch
if ((curr_task->prio > prio) && (curr_task->status == TASK_RUNNING))
goto get_task_out;
// mark current task for later cleanup by finish_task_switch()
if (curr_task->status == TASK_RUNNING) {
curr_task->status = TASK_READY;
readyqueues[core_id].old_task = curr_task;
}
// get new task from its ready queue
curr_task = task_list_pop_front(&readyqueues[core_id].queue[prio-1]);
if(BUILTIN_EXPECT(curr_task == NULL, 0)) {
LOG_ERROR("Kernel panic: No task in readyqueue\n");
while(1);
}
if (BUILTIN_EXPECT(curr_task->status == TASK_INVALID, 0)) {
LOG_ERROR("Kernel panic: Got invalid task %d, orig task %d\n",
curr_task->id, orig_task->id);
while(1);
}
// if we removed the last task from queue, update priority bitmap
if(readyqueues[core_id].queue[prio-1].first == NULL) {
readyqueues[core_id].prio_bitmap &= ~(1 << prio);
}
// finally make it the new current task
curr_task->status = TASK_RUNNING;
#ifdef DYNAMIC_TICKS
curr_task->last_tsc = get_rdtsc();
#endif
set_per_core(current_task, curr_task);
}
get_task_out:
spinlock_irqsave_unlock(&readyqueues[core_id].lock);
if (curr_task != orig_task) {
LOG_DEBUG("schedule on core %d from %u to %u with prio %u\n", core_id, orig_task->id, curr_task->id, (uint32_t)curr_task->prio);
return (size_t**) &(orig_task->last_stack_pointer);
}
return NULL;
}
int get_task(tid_t id, task_t** task)
{
if (BUILTIN_EXPECT(task == NULL, 0)) {
return -ENOMEM;
}
if (BUILTIN_EXPECT(id >= MAX_TASKS, 0)) {
return -ENOENT;
}
if (BUILTIN_EXPECT(task_table[id].status == TASK_INVALID, 0)) {
return -EINVAL;
}
*task = &task_table[id];
return 0;
}
void reschedule(void)
{
size_t** stack;
uint8_t flags;
flags = irq_nested_disable();
if ((stack = scheduler()))
switch_context(stack);
irq_nested_enable(flags);
}
| 25.316777 | 154 | 0.699089 |
d20600d64d6e12f65d515898de2343f9df99d9d3 | 861 | h | C | src/CLIArg.h | dibenso/Hexdump | e8ae5acfade95097441e5ba668b903ea71b71b85 | [
"MIT"
] | null | null | null | src/CLIArg.h | dibenso/Hexdump | e8ae5acfade95097441e5ba668b903ea71b71b85 | [
"MIT"
] | null | null | null | src/CLIArg.h | dibenso/Hexdump | e8ae5acfade95097441e5ba668b903ea71b71b85 | [
"MIT"
] | null | null | null | #ifndef _CLI_ARG_H_
#define _CLI_ARG_H_
#include <string>
enum ArgType {
NoArg,
BooleanArg,
IntArg,
FloatArg,
DoubleArg,
CharArg,
StringArg,
RangeArg
};
class CLIArg {
private:
ArgType _arg_type;
bool _resolved;
std::string _value;
std::string _long_name;
std::string _short_name;
std::string _description;
public:
CLIArg(ArgType arg_type, const char* long_name, const char* short_name, const char* description);
inline ArgType arg_type() { return _arg_type; }
inline bool resolved() { return _resolved; }
inline std::string value() { return _value; }
inline std::string long_name() { return _long_name; }
inline std::string short_name() { return _short_name; }
inline void resolve() { _resolved = true; }
void resolve(std::string value);
bool operator==(CLIArg arg);
};
#endif | 23.27027 | 101 | 0.68525 |
65ae3ee25615714d48b6ef8c3ed263842c549829 | 994 | h | C | MySampleApp/MySampleApp/Sdk/Aws/extras/AWSCognito.framework/Headers/AWSCognito.h | masaki-kamachi/cheers-ios | 29e86ebd83dbdd3665d1666607382a1b92b80923 | [
"CC0-1.0"
] | 3 | 2020-11-19T00:45:14.000Z | 2021-09-01T06:01:55.000Z | MySampleApp/MySampleApp/Sdk/Aws/extras/AWSCognito.framework/Headers/AWSCognito.h | masaki-kamachi/cheers-ios | 29e86ebd83dbdd3665d1666607382a1b92b80923 | [
"CC0-1.0"
] | null | null | null | MySampleApp/MySampleApp/Sdk/Aws/extras/AWSCognito.framework/Headers/AWSCognito.h | masaki-kamachi/cheers-ios | 29e86ebd83dbdd3665d1666607382a1b92b80923 | [
"CC0-1.0"
] | null | null | null | //
// Copyright 2014-2016 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Amazon Software License (the "License").
// You may not use this file except in compliance with the
// License. A copy of the License is located at
//
// http://aws.amazon.com/asl/
//
// or in the "license" file accompanying this file. This file is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, express or implied. See the License
// for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
//! Project version number for AWSCognito.
FOUNDATION_EXPORT double AWSCognitoVersionNumber;
//! Project version string for AWSCognito.
FOUNDATION_EXPORT const unsigned char AWSCognitoVersionString[];
#import "AWSCognitoService.h"
#import "AWSCognitoDataset.h"
#import "AWSCognitoRecord.h"
#import "AWSCognitoHandlers.h"
#import "AWSCognitoConflict.h"
#import "AWSCognitoSync.h"
| 31.0625 | 64 | 0.759557 |
d0b20c5cd8a60b980e26c58ce288db82a6eb4f22 | 2,927 | h | C | chrome/utility/media_galleries/iapps_xml_utils.h | google-ar/chromium | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 777 | 2017-08-29T15:15:32.000Z | 2022-03-21T05:29:41.000Z | chrome/utility/media_galleries/iapps_xml_utils.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 66 | 2017-08-30T18:31:18.000Z | 2021-08-02T10:59:35.000Z | chrome/utility/media_galleries/iapps_xml_utils.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 123 | 2017-08-30T01:19:34.000Z | 2022-03-17T22:55:31.000Z | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_
#define CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_
#include <stdint.h>
#include <set>
#include <string>
#include "base/files/file.h"
#include "base/macros.h"
#include "base/stl_util.h"
class XmlReader;
namespace iapps {
// Like XmlReader::SkipToElement, but will advance to the next open tag if the
// cursor is on a close tag.
bool SkipToNextElement(XmlReader* reader);
// Traverse |reader| looking for a node named |name| at the current depth
// of |reader|.
bool SeekToNodeAtCurrentDepth(XmlReader* reader, const std::string& name);
// Search within a "dict" node for |key|. The cursor must be on the starting
// "dict" node when entering this function.
bool SeekInDict(XmlReader* reader, const std::string& key);
// Get the value out of a string node.
bool ReadString(XmlReader* reader, std::string* result);
// Get the value out of an integer node.
bool ReadInteger(XmlReader* reader, uint64_t* result);
// Read in the contents of the given library xml |file| and return as a string.
std::string ReadFileAsString(base::File file);
// Contains the common code and main loop for reading the key/values
// of an XML dict. The derived class must implement |HandleKeyImpl()|
// which is called with each key, and may re-implement |ShouldLoop()|,
// |FinishedOk()| and/or |AllowRepeats()|.
class XmlDictReader {
public:
explicit XmlDictReader(XmlReader* reader);
virtual ~XmlDictReader();
// The main loop of this class. Reads all the keys in the
// current element and calls |HandleKey()| with each.
bool Read();
// Re-implemented by derived class if it should bail from the
// loop earlier, such as if it encountered all required fields.
virtual bool ShouldLoop();
// Called by |Read()| with each key. Calls derived |HandleKeyImpl()|.
bool HandleKey(const std::string& key);
virtual bool HandleKeyImpl(const std::string& key) = 0;
// Re-implemented by the derived class (to return true) if
// it should allow fields to be repeated, but skipped.
virtual bool AllowRepeats();
// Re-implemented by derived class if it should test for required
// fields instead of just returning true.
virtual bool FinishedOk();
// A convenience function for the derived classes.
// Skips to next element.
bool SkipToNext();
// A convenience function for the derived classes.
// Used to test if all required keys have been encountered.
bool Found(const std::string& key) const;
protected:
XmlReader* reader_;
private:
// The keys that the reader has run into in this element.
std::set<std::string> found_;
DISALLOW_COPY_AND_ASSIGN(XmlDictReader);
};
} // namespace iapps
#endif // CHROME_UTILITY_MEDIA_GALLERIES_IAPPS_XML_UTILS_H_
| 31.473118 | 79 | 0.740007 |
aa478d74cb2fe829e6a15cb5986d161ad89a9d7c | 1,168 | c | C | PInvoke/PlatformInvoke/Dump/demo.c | Library-Starlight/ProgramerCore | cb5412cd808a8fd59b4faaec2cb574fd62031b09 | [
"Apache-2.0"
] | null | null | null | PInvoke/PlatformInvoke/Dump/demo.c | Library-Starlight/ProgramerCore | cb5412cd808a8fd59b4faaec2cb574fd62031b09 | [
"Apache-2.0"
] | 1 | 2020-11-04T17:50:52.000Z | 2020-11-04T17:50:52.000Z | PInvoke/PlatformInvoke/Dump/demo.c | Library-Starlight/ProgramerCore | cb5412cd808a8fd59b4faaec2cb574fd62031b09 | [
"Apache-2.0"
] | null | null | null | #include <stdio.h>
#include "HeyThings_interface.h"
#include "HeyThings_log.h"
int main(void)
{
printf("libHeythings version: %d.%d.%d\n",
HEYTHINGS_VERSION_MAJOR, HEYTHINGS_VSERION_MINOR,
HEYTHINGS_VERSION_PATCH);
return 0;
}
void Print()
{
printf("Hello World!\n");
}
typedef enum
{
state1,
state2,
state3
} status_enum;
void Invoke(status_enum status)
{
printf("Invoke Successded: %d\n", status);
}
typedef struct StatusCallback
{
void (*online_callback)(uint32_t value);
void (*ext_callback1)(uint32_t value);
void (*ext_callback2)(uint32_t value);
void (*ext_callback3)(uint32_t value);
void (*ext_callback4)(uint32_t value);
void (*ext_callback5)(uint32_t value);
void (*ext_callback6)(uint32_t value);
void (*ext_callback7)(uint32_t value);
void (*ext_callback8)(uint32_t value);
void (*ext_callback9)(uint32_t value);
} StatusCallback;
void SetCallback(StatusCallback callback)
{
// callback.online_callback(500);
// callback.ext_callback9(500);
// callback.ext_callback1(100);
// callback.ext_callback2(200);
// callback.ext_callback3(300);
} | 22.461538 | 60 | 0.686644 |
343b70b9c38e7e048143ff4d1a4a17a691afce71 | 997 | h | C | CGWork/Model.h | MetalYos/CG1_HW2 | 7b3f7a2a49ae4daf3eb5f904b5bb53685fb2a389 | [
"MIT"
] | null | null | null | CGWork/Model.h | MetalYos/CG1_HW2 | 7b3f7a2a49ae4daf3eb5f904b5bb53685fb2a389 | [
"MIT"
] | null | null | null | CGWork/Model.h | MetalYos/CG1_HW2 | 7b3f7a2a49ae4daf3eb5f904b5bb53685fb2a389 | [
"MIT"
] | null | null | null | #pragma once
#include "ALMath.h"
#include "Geometry.h"
class Model
{
private:
std::vector<Geometry*> geos;
Mat4 transform;
Mat4 normalTransform;
Vec4 color;
Vec4 normalColor;
// BBox parameters
std::vector<Poly*> bbox;
Vec4 minCoord;
Vec4 maxCoord;
public:
Model() : color(AL_WHITE), normalColor(AL_RED) { }
~Model();
void AddGeometry(Geometry* geo);
const Mat4& GetTransform() const;
const Mat4& GetNormalTransform() const;
void Translate(const Mat4& T);
void Scale(const Mat4& S);
void Rotate(const Mat4& R);
const std::vector<Geometry*>& GetGeometries() const;
const std::vector<Poly*>& GetBBox() const;
void SetColor(int r, int g, int b);
void SetColor(const Vec4& color);
const Vec4& GetColor() const;
void SetNormalColor(int r, int g, int b);
void SetNormalColor(const Vec4& color);
const Vec4& GetNormalColor() const;
void BuildBoundingBox();
Vec4 GetBBoxDimensions() const;
Vec4 GetBBoxCenter() const;
void DeleteGeometries();
//void Draw();
};
| 19.173077 | 53 | 0.711133 |
43a6dd69011bf086ea31076faadc52f529a0629a | 2,053 | h | C | Merrymen/GameScene.h | Mertank/ToneArm | 40c62b0de89ac506bea6674e43578bf4e2631f93 | [
"Zlib",
"BSD-2-Clause"
] | null | null | null | Merrymen/GameScene.h | Mertank/ToneArm | 40c62b0de89ac506bea6674e43578bf4e2631f93 | [
"Zlib",
"BSD-2-Clause"
] | null | null | null | Merrymen/GameScene.h | Mertank/ToneArm | 40c62b0de89ac506bea6674e43578bf4e2631f93 | [
"Zlib",
"BSD-2-Clause"
] | null | null | null | /*
------------------------------------------------------------------------------------------
Copyright (c) 2014 Vinyl Games Studio
Author: Mikhail Kutuzov
Date: 5/16/2014 12:31:56 PM
------------------------------------------------------------------------------------------
*/
#ifndef __GAME_SCENE_H__
#define __GAME_SCENE_H__
#include "../ToneArmEngine/Scene.h"
#include "../ToneArmEngine/FreeLookCamera.h"
#include "../ToneArmEngine/FixedCamera.h"
#include "GameSceneGUI.h"
#include "Character.h"
using namespace vgs;
namespace vgs
{
class LevelNode;
}
namespace merrymen
{
class TeamDeathMatchMH;
class ScoreTableGUI;
/*
------------------------------------------------------------------------------------------
GameScene
A class for the main in-game scene.
------------------------------------------------------------------------------------------
*/
class GameScene : public Scene {
public:
DECLARE_RTTI;
~GameScene();
//bool Init() override;
void Update(float dt) override;
virtual void EnterScene( void );
virtual void ExitScene( void );
void InitGUI();
void UpdateGUI();
// accessors
const std::vector<Character*>& GetPlayers() const { return m_players; }
void AddPlayer(Character* player) { m_players.push_back(player);
AddChild(player); }
void RemovePlayer(Character* player);
LevelNode* const GetLevel() const { return m_level; }
void SetLevel(LevelNode* level);
virtual Character* const GetLocalCharacter() const = 0;
virtual void CreateReticle();
virtual void ShowReticle(const bool show);
//DECLARE_DEBUG_COMMAND_CALLBACK( merrymen::GameScene, playAnim )
protected:
GameScene();
std::vector<Character*> m_players;
LevelNode* m_level;
GameSceneGUI* m_gamesceneGUI;
bool m_pausePressed;
bool m_pauseMenuOpened;
};
} // namespace merrymen
#endif __GAME_SCENE_H__ | 22.811111 | 90 | 0.531417 |
b77352f3e8ae9b90064f8ee5c6bb59371a426cae | 1,212 | h | C | HexEdit/UserTool.h | the-nerbs/HexEdit | deefee7cf19c46bfb43674a892f51d885d0ba4ca | [
"MIT"
] | 166 | 2015-09-23T05:47:26.000Z | 2022-02-17T21:46:44.000Z | HexEdit/UserTool.h | the-nerbs/HexEdit | deefee7cf19c46bfb43674a892f51d885d0ba4ca | [
"MIT"
] | 27 | 2015-09-21T10:41:56.000Z | 2020-07-17T04:51:11.000Z | HexEdit/UserTool.h | the-nerbs/HexEdit | deefee7cf19c46bfb43674a892f51d885d0ba4ca | [
"MIT"
] | 62 | 2015-09-21T01:21:52.000Z | 2021-12-21T19:57:12.000Z | #if !defined(AFX_USERTOOL_H__E825A24A_BAE6_44EB_AE30_986F0355F2F3__INCLUDED_)
#define AFX_USERTOOL_H__E825A24A_BAE6_44EB_AE30_986F0355F2F3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// UserTool.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CHexEditUserTool window
class CHexEditUserTool : public CUserTool
{
// Unless we add serialization we get the run-time error
// "An unsupported operation was attempted", presumably
// because BCG serializes objects of this class to the registry.
DECLARE_SERIAL(CHexEditUserTool)
// Construction
public:
CHexEditUserTool();
virtual ~CHexEditUserTool();
// Attributes
public:
// Operations
public:
// Overrides
// virtual void Serialize(CArchive& ar); // Just use base class version as we added no extra members variables
virtual BOOL Invoke();
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_USERTOOL_H__E825A24A_BAE6_44EB_AE30_986F0355F2F3__INCLUDED_)
| 28.857143 | 112 | 0.661716 |
bd7147188b29f96098f2938b85ff4a553c556bef | 3,556 | h | C | Other/Headers/MMViewerWindow.h | XWJACK/WeChatPlugin-MacOS | 4241ddb10ccce9484fcf6d5bd51a6afa3b446632 | [
"MIT"
] | 2 | 2019-01-11T02:02:55.000Z | 2020-04-23T02:42:01.000Z | Other/Headers/MMViewerWindow.h | XWJACK/WeChatPlugin-MacOS | 4241ddb10ccce9484fcf6d5bd51a6afa3b446632 | [
"MIT"
] | null | null | null | Other/Headers/MMViewerWindow.h | XWJACK/WeChatPlugin-MacOS | 4241ddb10ccce9484fcf6d5bd51a6afa3b446632 | [
"MIT"
] | 1 | 2021-01-09T14:54:27.000Z | 2021-01-09T14:54:27.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <AppKit/NSWindowController.h>
#import "NSWindowDelegate-Protocol.h"
@class MMPreviewTitleButton, MMViewerContentWindow, NSProgressIndicator, NSString, NSTrackingArea, NSView;
@protocol MMViewerWindowDelegate;
@interface MMViewerWindow : NSWindowController <NSWindowDelegate>
{
NSTrackingArea *_mainTrackingArea;
BOOL _isFullScreen;
id <MMViewerWindowDelegate> _delegate;
id _context;
NSView *_containerView;
NSView *_toolbar;
NSProgressIndicator *_loadingIndicator;
MMPreviewTitleButton *_addToFavoritesButton;
MMPreviewTitleButton *_openWithButton;
id _mouseEvent;
}
@property(retain, nonatomic) id mouseEvent; // @synthesize mouseEvent=_mouseEvent;
@property(nonatomic) BOOL isFullScreen; // @synthesize isFullScreen=_isFullScreen;
@property(retain, nonatomic) MMPreviewTitleButton *openWithButton; // @synthesize openWithButton=_openWithButton;
@property(retain, nonatomic) MMPreviewTitleButton *addToFavoritesButton; // @synthesize addToFavoritesButton=_addToFavoritesButton;
@property(retain, nonatomic) NSProgressIndicator *loadingIndicator; // @synthesize loadingIndicator=_loadingIndicator;
@property(retain, nonatomic) NSView *toolbar; // @synthesize toolbar=_toolbar;
@property(retain, nonatomic) NSView *containerView; // @synthesize containerView=_containerView;
@property(retain, nonatomic) id context; // @synthesize context=_context;
@property(nonatomic) __weak id <MMViewerWindowDelegate> delegate; // @synthesize delegate=_delegate;
- (void).cxx_destruct;
- (void)windowDidMove:(id)arg1;
- (void)windowDidResize:(id)arg1;
- (void)_updateTrackingAreas;
- (void)_updateToolbarVisibility;
- (void)mouseExited:(id)arg1;
- (void)mouseEntered:(id)arg1;
- (void)manualSetupMainMenuToSupportCopyAndPaste;
- (id)contentForSharing;
- (void)openWith:(id)arg1;
- (void)nextItem:(id)arg1;
- (void)previousItem:(id)arg1;
- (void)openInExternalBrowser:(id)arg1;
- (void)share:(id)arg1;
- (void)deleteItem:(id)arg1;
- (void)addToFavorites:(id)arg1;
- (void)forwardContent:(id)arg1;
- (void)exportContent:(id)arg1;
- (BOOL)showInWindowsMenu;
- (id)title;
- (struct CGRect)window:(id)arg1 willPositionSheet:(id)arg2 usingRect:(struct CGRect)arg3;
- (BOOL)windowShouldClose:(id)arg1;
- (id)supportedActions;
- (void)loadContent;
- (void)_configureButton:(id)arg1 forAction:(unsigned long long)arg2;
- (void)stopLoading;
- (void)startLoading;
- (BOOL)showLoadingIndicator;
- (void)updateOpenWithButton:(id)arg1;
- (void)_setupToolbar;
- (void)didFinishClosing:(BOOL)arg1;
- (void)willStartClosing:(BOOL)arg1;
- (void)didFinishOpening:(BOOL)arg1;
- (void)willStartOpening:(BOOL)arg1;
- (struct CGRect)toobarFrame;
- (struct CGRect)addToFavoritesButtonFrame;
- (void)refreshContent;
- (BOOL)useEscKeyForClose;
- (BOOL)useSpaceKeyForClose;
- (BOOL)toolbarAutohides;
- (struct CGSize)minimumSize;
- (struct CGSize)sizeForContent;
- (void)closeWindowAnimated:(BOOL)arg1;
- (void)showWindowAnimated:(BOOL)arg1;
- (void)windowDidLoad;
- (void)toggleFullScreen:(id)arg1;
- (void)_setupTrafficlightButtons;
- (void)dealloc;
- (void)loadWindow;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@property(retain) MMViewerContentWindow *window; // @dynamic window;
@end
| 37.041667 | 131 | 0.775309 |
08ec57436b30926184e56ec2822014c8de632807 | 1,733 | h | C | EnjoyCamera/Utilities/Categorys/UIImage/UIImage+Resize.h | bamboolife/EnjoyCamera | b66bbbde5fa3142d71dfa58b47113b1f9fba3b85 | [
"Apache-2.0"
] | 220 | 2018-02-03T14:05:01.000Z | 2022-03-21T12:16:31.000Z | EnjoyCamera/Utilities/Categorys/UIImage/UIImage+Resize.h | bamboolife/EnjoyCamera | b66bbbde5fa3142d71dfa58b47113b1f9fba3b85 | [
"Apache-2.0"
] | 2 | 2019-07-22T08:59:23.000Z | 2019-08-08T07:45:03.000Z | EnjoyCamera/Utilities/Categorys/UIImage/UIImage+Resize.h | bamboolife/EnjoyCamera | b66bbbde5fa3142d71dfa58b47113b1f9fba3b85 | [
"Apache-2.0"
] | 58 | 2018-04-07T01:25:46.000Z | 2022-03-09T12:53:58.000Z | // UIImage+Resize.h
// EnjoyCamera
//
// Created by qinmin on 2017/4/13.
// Copyright © 2017年 qinmin. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef enum
{
NYXCropModeTopLeft,
NYXCropModeTopCenter,
NYXCropModeTopRight,
NYXCropModeBottomLeft,
NYXCropModeBottomCenter,
NYXCropModeBottomRight,
NYXCropModeLeftCenter,
NYXCropModeRightCenter,
NYXCropModeCenter
} NYXCropMode;
@interface UIImage (Resize)
- (UIImage *)resizedCameraIconImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedAndClipImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)croppedImage:(CGRect)bounds;
- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize
transparentBorder:(NSUInteger)borderSize
cornerRadius:(NSUInteger)cornerRadius
interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImage:(CGSize)newSize
interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode
bounds:(CGSize)bounds
interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImage:(CGSize)newSize
transform:(CGAffineTransform)transform
drawTransposed:(BOOL)transpose
interpolationQuality:(CGInterpolationQuality)quality;
- (CGAffineTransform)transformForOrientation:(CGSize)newSize;
- (UIImage *)setImageScale:(float)scale;
-(UIImage*)cropToSize:(CGSize)newSize usingMode:(NYXCropMode)cropMode;
+ (CGSize)getSizeWithRate:(float)rate limitSize:(CGSize)size;
+ (CGSize)getSizeWithRate:(float)rate limitLargeSize:(CGSize)size;
@end
| 33.980392 | 105 | 0.751875 |
31265555b467441507fd9bbc5975c6742e6c74a4 | 705 | h | C | p.h | sdsykes/p | 2f4539bb49ebdcf288f3d5c94cc17b4d47ed5aae | [
"MIT"
] | 2 | 2015-06-29T19:26:38.000Z | 2018-04-25T03:46:53.000Z | p.h | sdsykes/p | 2f4539bb49ebdcf288f3d5c94cc17b4d47ed5aae | [
"MIT"
] | null | null | null | p.h | sdsykes/p | 2f4539bb49ebdcf288f3d5c94cc17b4d47ed5aae | [
"MIT"
] | null | null | null | //
// p.h
// p
//
// Created by Stephen Sykes on 03/10/13.
// Copyright (c) 2013. All rights reserved.
//
// Defines a macro p(arg) that will NSLog almost any type.
//
// The type is determined using the Objective C type encoding
// information from @encoding(). Objects, simple numeric types,
// C strings, and types that can be converted using the NSStringFrom...
// functions are supported.
//
// Compiler type errors are avoided by passing the argument
// through va_args.
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
NSString *npStringFromAnyType(char *typeCode, ...);
#define p(arg) NSLog(@"%@", npStringFromAnyType(@encode(typeof(arg)), (arg)))
| 25.178571 | 77 | 0.697872 |
31363594a9de07dace5cea239fd7d3ab91577e38 | 2,074 | h | C | FreeBSD/contrib/llvm/tools/lldb/tools/lldb-mi/MICmdMgr.h | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 4 | 2016-08-22T22:02:55.000Z | 2017-03-04T22:56:44.000Z | FreeBSD/contrib/llvm/tools/lldb/tools/lldb-mi/MICmdMgr.h | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 21 | 2016-08-11T09:43:43.000Z | 2017-01-29T12:52:56.000Z | FreeBSD/contrib/llvm/tools/lldb/tools/lldb-mi/MICmdMgr.h | TigerBSD/TigerBSD | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | null | null | null | //===-- MICmdMgr.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#pragma once
// Third party headers
#include <set>
// In-house headers:
#include "MICmnBase.h"
#include "MICmdBase.h"
#include "MICmdMgrSetCmdDeleteCallback.h"
#include "MIUtilSingletonBase.h"
// Declarations:
class CMICmdInterpreter;
class CMICmdFactory;
class CMICmdInvoker;
class CMICmdBase;
//++ ============================================================================
// Details: MI command manager. Oversees command operations, controls command
// production and the running of commands.
// Command Invoker, Command Factory and Command Monitor while independent
// units are overseen/managed by *this manager.
// A singleton class.
//--
class CMICmdMgr : public CMICmnBase, public MI::ISingleton<CMICmdMgr>
{
friend class MI::ISingleton<CMICmdMgr>;
// Methods:
public:
bool Initialize() override;
bool Shutdown() override;
bool CmdInterpret(const CMIUtilString &vTextLine, bool &vwbYesValid, bool &vwbCmdNotInCmdFactor, SMICmdData &rwCmdData);
bool CmdExecute(const SMICmdData &vCmdData);
bool CmdDelete(SMICmdData vCmdData);
bool CmdRegisterForDeleteNotification(CMICmdMgrSetCmdDeleteCallback::ICallback &vObject);
bool CmdUnregisterForDeleteNotification(CMICmdMgrSetCmdDeleteCallback::ICallback &vObject);
// Methods:
private:
/* ctor */ CMICmdMgr();
/* ctor */ CMICmdMgr(const CMICmdMgr &);
void operator=(const CMICmdMgr &);
// Overridden:
public:
// From CMICmnBase
/* dtor */ ~CMICmdMgr() override;
// Attributes:
private:
CMICmdInterpreter &m_interpretor;
CMICmdFactory &m_factory;
CMICmdInvoker &m_invoker;
CMICmdMgrSetCmdDeleteCallback::CSetClients m_setCmdDeleteCallback;
};
| 30.955224 | 124 | 0.641273 |
d937ac9be325d87c0a76784c94968873e013e9f0 | 2,952 | c | C | tests/cfp/testCfpArray2f.c | halehawk/zfp | f1709a4ee59eb8b3443f94c60e6ff6fc895b0a69 | [
"BSD-3-Clause"
] | 1 | 2022-01-30T00:22:55.000Z | 2022-01-30T00:22:55.000Z | tests/cfp/testCfpArray2f.c | halehawk/zfp | f1709a4ee59eb8b3443f94c60e6ff6fc895b0a69 | [
"BSD-3-Clause"
] | 1 | 2022-03-03T14:48:04.000Z | 2022-03-03T14:51:03.000Z | tests/cfp/testCfpArray2f.c | halehawk/zfp | f1709a4ee59eb8b3443f94c60e6ff6fc895b0a69 | [
"BSD-3-Clause"
] | null | null | null | #include "src/traitsf.h"
#include "src/block2.h"
#include "constants/2dFloat.h"
#define CFP_ARRAY_TYPE cfp_array2f
#define SUB_NAMESPACE array2f
#define SCALAR float
#include "testCfpArray_source.c"
#include "testCfpArray2_source.c"
int main()
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches),
cmocka_unit_test(given_cfp_array2f_when_defaultCtor_expect_returnsNonNullPtr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_ctor_expect_paramsSet, setupCfpArrLargeComplete, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_copyCtor_expect_paramsCopied, setupCfpArrLargeComplete, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_copyCtor_expect_cacheCopied, setupCfpArrLargeComplete, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setRate_expect_rateSet, setupCfpArrMinimal, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setCacheSize_expect_cacheSizeSet, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_with_dirtyCache_when_flushCache_expect_cacheEntriesPersistedToMemory, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_clearCache_expect_cacheCleared, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_resize_expect_sizeChanged, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setFlat_expect_entryWrittenToCacheOnly, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_getFlat_expect_entryReturned, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_set_expect_entryWrittenToCacheOnly, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_get_expect_entryReturned, setupCfpArrSmall, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setArray_expect_compressedStreamChecksumMatches, setupFixedRate0, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setArray_expect_compressedStreamChecksumMatches, setupFixedRate1, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_setArray_expect_compressedStreamChecksumMatches, setupFixedRate2, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_getArray_expect_decompressedArrChecksumMatches, setupFixedRate0, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_getArray_expect_decompressedArrChecksumMatches, setupFixedRate1, teardownCfpArr),
cmocka_unit_test_setup_teardown(given_cfp_array2f_when_getArray_expect_decompressedArrChecksumMatches, setupFixedRate2, teardownCfpArr),
};
return cmocka_run_group_tests(tests, prepCommonSetupVars, teardownCommonSetupVars);
}
| 65.6 | 158 | 0.890583 |
d9477093ae5117d7f7b027e8b2d98dcf4f576658 | 821 | h | C | HomeWork/LearningOutcome/1/lo1.h | Patrick1993G/LLP2HomeWork | c39e05b9f144432cad717255a3e4ee9380f7bf56 | [
"MIT"
] | null | null | null | HomeWork/LearningOutcome/1/lo1.h | Patrick1993G/LLP2HomeWork | c39e05b9f144432cad717255a3e4ee9380f7bf56 | [
"MIT"
] | null | null | null | HomeWork/LearningOutcome/1/lo1.h | Patrick1993G/LLP2HomeWork | c39e05b9f144432cad717255a3e4ee9380f7bf56 | [
"MIT"
] | null | null | null |
#ifndef lo1
#define lo1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int count(char text[]){
int count=1;
for (size_t i = 0; i < strlen(text); i++)
{
if(*(text+i)== ' '){
count++;
}else{
continue;
}
}
return count;
}
int countLetters(char text[]){
int count=0;
for (size_t i = 0; i < strlen(text); i++)
{
if(*(text+i)!= ' ' && *(text+i)!= '\n'){
count++;
}else{
continue;
}
}
return count;
}
bool should_count_chars(int argc, char* argv[]){
if(*argv[1] == 'c'){
return true;
}else{
return false;
}
}
bool is_space(char cchar){
if( cchar == ' '){
return true;
}else{
return false;
}
}
#endif
| 16.098039 | 48 | 0.464068 |
8adfb055d65742d7d5cc6a4ce0a32be945c2eaa2 | 678 | c | C | libraries/mmlibc/src/strings.c | betopp/pathetix | a18a1211f6f3ca3c9ebd0e3de6784ae0591d1265 | [
"MIT"
] | null | null | null | libraries/mmlibc/src/strings.c | betopp/pathetix | a18a1211f6f3ca3c9ebd0e3de6784ae0591d1265 | [
"MIT"
] | null | null | null | libraries/mmlibc/src/strings.c | betopp/pathetix | a18a1211f6f3ca3c9ebd0e3de6784ae0591d1265 | [
"MIT"
] | null | null | null | //strings.c
//Extra string functions for DUCK's libc
//Bryan E. Topp <betopp@betopp.com> 2020
#include <limits.h>
#include <stdint.h>
#include <strings.h>
#include <ctype.h>
int strcasecmp(const char *s1, const char *s2)
{
return strncasecmp(s1, s2, SIZE_MAX);
}
int strncasecmp(const char *s1, const char *s2, size_t n)
{
for(size_t bb = 0; bb < n; bb++)
{
char s1_lower = tolower(s1[bb]);
char s2_lower = tolower(s2[bb]);
if(s1_lower != s2_lower)
{
return s1_lower - s2_lower;
}
if(s1_lower == '\0' || s2_lower == '\0')
break;
}
return 0;
}
int ffs(int i)
{
for(int bb = 0; bb < 64; bb++)
{
if(i & (1<<bb))
return bb+1;
}
return 0;
}
| 15.767442 | 57 | 0.610619 |
fce32cecaa5934513f8ffe2a356911fc65a61db5 | 12,582 | c | C | src/ClientServer/services/bgenc/channel_mgr_1.c | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | 8 | 2018-09-28T16:03:55.000Z | 2021-09-23T09:07:10.000Z | src/ClientServer/services/bgenc/channel_mgr_1.c | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/ClientServer/services/bgenc/channel_mgr_1.c | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-04-28T08:32:27.000Z | 2020-04-28T08:32:27.000Z | /*
* Licensed to Systerel under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Systerel 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.
*/
/******************************************************************************
File Name : channel_mgr_1.c
Date : 06/03/2020 14:49:08
C Translator Version : tradc Java V1.0 (14/03/2012)
******************************************************************************/
/*------------------------
Exported Declarations
------------------------*/
#include "channel_mgr_1.h"
/*----------------------------
CONCRETE_VARIABLES Clause
----------------------------*/
constants__t_timeref_i channel_mgr_1__a_channel_connected_time_i[constants__t_channel_i_max+1];
constants__t_channel_config_idx_i channel_mgr_1__a_config_i[constants__t_channel_i_max+1];
constants__t_channel_i channel_mgr_1__a_config_inv_i[constants__t_channel_config_idx_i_max+1];
constants__t_endpoint_config_idx_i channel_mgr_1__a_endpoint_i[constants__t_channel_i_max+1];
t_entier4 channel_mgr_1__card_channel_connected_i;
t_entier4 channel_mgr_1__card_cli_channel_connecting_i;
t_bool channel_mgr_1__s_channel_connected_i[constants__t_channel_i_max+1];
t_bool channel_mgr_1__s_cli_channel_connecting_i[constants__t_channel_config_idx_i_max+1];
t_bool channel_mgr_1__s_cli_channel_disconnecting_i[constants__t_channel_config_idx_i_max+1];
/*------------------------
INITIALISATION Clause
------------------------*/
void channel_mgr_1__INITIALISATION(void) {
{
t_entier4 i;
for (i = constants__t_channel_config_idx_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__s_cli_channel_connecting_i[i] = false;
}
}
channel_mgr_1__card_cli_channel_connecting_i = 0;
{
t_entier4 i;
for (i = constants__t_channel_config_idx_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__s_cli_channel_disconnecting_i[i] = false;
}
}
{
t_entier4 i;
for (i = constants__t_channel_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__s_channel_connected_i[i] = false;
}
}
channel_mgr_1__card_channel_connected_i = 0;
{
t_entier4 i;
for (i = constants__t_channel_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__a_channel_connected_time_i[i] = constants__c_timeref_indet;
}
}
{
t_entier4 i;
for (i = constants__t_channel_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__a_config_i[i] = constants__c_channel_config_idx_indet;
}
}
{
t_entier4 i;
for (i = constants__t_channel_config_idx_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__a_config_inv_i[i] = constants__c_channel_indet;
}
}
{
t_entier4 i;
for (i = constants__t_channel_i_max; 0 <= i; i = i - 1) {
channel_mgr_1__a_endpoint_i[i] = constants__c_endpoint_config_idx_indet;
}
}
}
/*--------------------
OPERATIONS Clause
--------------------*/
void channel_mgr_1__is_connected_channel(
const constants__t_channel_i channel_mgr_1__channel,
t_bool * const channel_mgr_1__bres) {
*channel_mgr_1__bres = channel_mgr_1__s_channel_connected_i[channel_mgr_1__channel];
}
void channel_mgr_1__is_disconnecting_channel(
const constants__t_channel_config_idx_i channel_mgr_1__config_idx,
t_bool * const channel_mgr_1__bres) {
*channel_mgr_1__bres = channel_mgr_1__s_cli_channel_disconnecting_i[channel_mgr_1__config_idx];
}
void channel_mgr_1__get_connected_channel(
const constants__t_channel_config_idx_i channel_mgr_1__config_idx,
constants__t_channel_i * const channel_mgr_1__channel) {
{
t_bool channel_mgr_1__l_res;
*channel_mgr_1__channel = channel_mgr_1__a_config_inv_i[channel_mgr_1__config_idx];
constants__is_t_channel(*channel_mgr_1__channel,
&channel_mgr_1__l_res);
if (channel_mgr_1__l_res == false) {
*channel_mgr_1__channel = constants__c_channel_indet;
}
}
}
void channel_mgr_1__get_channel_info(
const constants__t_channel_i channel_mgr_1__channel,
constants__t_channel_config_idx_i * const channel_mgr_1__config_idx) {
{
t_bool channel_mgr_1__l_res;
*channel_mgr_1__config_idx = channel_mgr_1__a_config_i[channel_mgr_1__channel];
constants__is_t_channel_config_idx(*channel_mgr_1__config_idx,
&channel_mgr_1__l_res);
if (channel_mgr_1__l_res == false) {
*channel_mgr_1__config_idx = constants__c_channel_config_idx_indet;
}
}
}
void channel_mgr_1__is_client_channel(
const constants__t_channel_i channel_mgr_1__channel,
t_bool * const channel_mgr_1__bres) {
{
constants__t_endpoint_config_idx_i channel_mgr_1__l_endpoint;
t_bool channel_mgr_1__l_bres;
channel_mgr_1__l_endpoint = channel_mgr_1__a_endpoint_i[channel_mgr_1__channel];
constants__is_t_endpoint_config_idx(channel_mgr_1__l_endpoint,
&channel_mgr_1__l_bres);
if (channel_mgr_1__l_bres == true) {
*channel_mgr_1__bres = false;
}
else {
*channel_mgr_1__bres = true;
}
}
}
void channel_mgr_1__server_get_endpoint_config(
const constants__t_channel_i channel_mgr_1__channel,
constants__t_endpoint_config_idx_i * const channel_mgr_1__endpoint_config_idx) {
{
t_bool channel_mgr_1__l_res;
*channel_mgr_1__endpoint_config_idx = channel_mgr_1__a_endpoint_i[channel_mgr_1__channel];
constants__is_t_endpoint_config_idx(*channel_mgr_1__endpoint_config_idx,
&channel_mgr_1__l_res);
if (channel_mgr_1__l_res == false) {
*channel_mgr_1__endpoint_config_idx = constants__c_endpoint_config_idx_indet;
}
}
}
void channel_mgr_1__getall_config_inv(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx,
t_bool * const channel_mgr_1__p_dom,
constants__t_channel_i * const channel_mgr_1__p_channel) {
*channel_mgr_1__p_channel = channel_mgr_1__a_config_inv_i[channel_mgr_1__p_config_idx];
constants__is_t_channel(*channel_mgr_1__p_channel,
channel_mgr_1__p_dom);
if (*channel_mgr_1__p_dom == false) {
*channel_mgr_1__p_channel = constants__c_channel_indet;
}
}
void channel_mgr_1__get_card_cli_channel_connecting(
t_entier4 * const channel_mgr_1__p_card_connecting) {
*channel_mgr_1__p_card_connecting = channel_mgr_1__card_cli_channel_connecting_i;
}
void channel_mgr_1__get_card_channel_connected(
t_entier4 * const channel_mgr_1__p_card_connected) {
*channel_mgr_1__p_card_connected = channel_mgr_1__card_channel_connected_i;
}
void channel_mgr_1__get_card_channel_used(
t_entier4 * const channel_mgr_1__p_card_used) {
*channel_mgr_1__p_card_used = channel_mgr_1__card_cli_channel_connecting_i +
channel_mgr_1__card_channel_connected_i;
}
void channel_mgr_1__add_cli_channel_connecting(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx) {
{
t_bool channel_mgr_1__l_res;
channel_mgr_1__l_res = channel_mgr_1__s_cli_channel_connecting_i[channel_mgr_1__p_config_idx];
if (channel_mgr_1__l_res == false) {
channel_mgr_1__s_cli_channel_connecting_i[channel_mgr_1__p_config_idx] = true;
channel_mgr_1__card_cli_channel_connecting_i = channel_mgr_1__card_cli_channel_connecting_i +
1;
}
}
}
void channel_mgr_1__is_channel_connected(
const constants__t_channel_i channel_mgr_1__p_channel,
t_bool * const channel_mgr_1__p_con) {
*channel_mgr_1__p_con = channel_mgr_1__s_channel_connected_i[channel_mgr_1__p_channel];
}
void channel_mgr_1__add_channel_connected(
const constants__t_channel_i channel_mgr_1__p_channel,
const constants__t_timeref_i channel_mgr_1__p_timeref) {
channel_mgr_1__s_channel_connected_i[channel_mgr_1__p_channel] = true;
channel_mgr_1__card_channel_connected_i = channel_mgr_1__card_channel_connected_i +
1;
channel_mgr_1__a_channel_connected_time_i[channel_mgr_1__p_channel] = channel_mgr_1__p_timeref;
}
void channel_mgr_1__set_config(
const constants__t_channel_i channel_mgr_1__p_channel,
const constants__t_channel_config_idx_i channel_mgr_1__p_channel_config_idx) {
channel_mgr_1__a_config_i[channel_mgr_1__p_channel] = channel_mgr_1__p_channel_config_idx;
channel_mgr_1__a_config_inv_i[channel_mgr_1__p_channel_config_idx] = channel_mgr_1__p_channel;
}
void channel_mgr_1__set_endpoint(
const constants__t_channel_i channel_mgr_1__p_channel,
const constants__t_endpoint_config_idx_i channel_mgr_1__p_endpoint_config_idx) {
channel_mgr_1__a_endpoint_i[channel_mgr_1__p_channel] = channel_mgr_1__p_endpoint_config_idx;
}
void channel_mgr_1__getall_channel_connected(
const constants__t_channel_i channel_mgr_1__p_channel,
t_bool * const channel_mgr_1__p_dom,
constants__t_channel_config_idx_i * const channel_mgr_1__p_config_idx) {
*channel_mgr_1__p_config_idx = channel_mgr_1__a_config_i[channel_mgr_1__p_channel];
constants__is_t_channel_config_idx(*channel_mgr_1__p_config_idx,
channel_mgr_1__p_dom);
if (*channel_mgr_1__p_dom == false) {
*channel_mgr_1__p_config_idx = constants__c_channel_config_idx_indet;
}
}
void channel_mgr_1__is_cli_channel_connecting(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx,
t_bool * const channel_mgr_1__p_is_channel_connecting) {
*channel_mgr_1__p_is_channel_connecting = channel_mgr_1__s_cli_channel_connecting_i[channel_mgr_1__p_config_idx];
}
void channel_mgr_1__add_cli_channel_disconnecting(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx) {
channel_mgr_1__s_cli_channel_disconnecting_i[channel_mgr_1__p_config_idx] = true;
}
void channel_mgr_1__remove_channel_connected(
const constants__t_channel_i channel_mgr_1__p_channel) {
{
t_bool channel_mgr_1__l_res;
channel_mgr_1__l_res = channel_mgr_1__s_channel_connected_i[channel_mgr_1__p_channel];
if (channel_mgr_1__l_res == true) {
channel_mgr_1__s_channel_connected_i[channel_mgr_1__p_channel] = false;
channel_mgr_1__card_channel_connected_i = channel_mgr_1__card_channel_connected_i -
1;
channel_mgr_1__a_channel_connected_time_i[channel_mgr_1__p_channel] = constants__c_timeref_indet;
}
}
}
void channel_mgr_1__remove_cli_channel_disconnecting(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx) {
channel_mgr_1__s_cli_channel_disconnecting_i[channel_mgr_1__p_config_idx] = false;
}
void channel_mgr_1__reset_config(
const constants__t_channel_i channel_mgr_1__p_channel) {
{
constants__t_channel_config_idx_i channel_mgr_1__l_config_idx;
channel_mgr_1__l_config_idx = channel_mgr_1__a_config_i[channel_mgr_1__p_channel];
channel_mgr_1__a_config_inv_i[channel_mgr_1__l_config_idx] = constants__c_channel_indet;
channel_mgr_1__a_config_i[channel_mgr_1__p_channel] = constants__c_channel_config_idx_indet;
}
}
void channel_mgr_1__reset_endpoint(
const constants__t_channel_i channel_mgr_1__p_channel) {
channel_mgr_1__a_endpoint_i[channel_mgr_1__p_channel] = constants__c_endpoint_config_idx_indet;
}
void channel_mgr_1__remove_cli_channel_connecting(
const constants__t_channel_config_idx_i channel_mgr_1__p_config_idx) {
{
t_bool channel_mgr_1__l_res;
channel_mgr_1__l_res = channel_mgr_1__s_cli_channel_connecting_i[channel_mgr_1__p_config_idx];
if (channel_mgr_1__l_res == true) {
channel_mgr_1__s_cli_channel_connecting_i[channel_mgr_1__p_config_idx] = false;
channel_mgr_1__card_cli_channel_connecting_i = channel_mgr_1__card_cli_channel_connecting_i -
1;
}
}
}
void channel_mgr_1__get_connection_time(
const constants__t_channel_i channel_mgr_1__p_channel,
constants__t_timeref_i * const channel_mgr_1__p_timeref) {
*channel_mgr_1__p_timeref = channel_mgr_1__a_channel_connected_time_i[channel_mgr_1__p_channel];
}
| 38.595092 | 116 | 0.769115 |
6cabb709dd710ec8d5a4e820fa10b7263f21a152 | 4,016 | h | C | src/include/ubiq/fpe/ff1.h | ubiqsecurity/ubiq-fpe-c | 43b500f51b4ce3980543fc89475ff9825cb4e992 | [
"MIT"
] | 7 | 2021-04-16T07:52:28.000Z | 2022-02-01T21:11:17.000Z | src/include/ubiq/fpe/ff1.h | ubiqsecurity/ubiq-fpe-c | 43b500f51b4ce3980543fc89475ff9825cb4e992 | [
"MIT"
] | null | null | null | src/include/ubiq/fpe/ff1.h | ubiqsecurity/ubiq-fpe-c | 43b500f51b4ce3980543fc89475ff9825cb4e992 | [
"MIT"
] | null | null | null | #ifndef UBIQ_FPE_FF1_H
#define UBIQ_FPE_FF1_H
#include <sys/cdefs.h>
#include <stdint.h>
#include <stddef.h>
__BEGIN_DECLS
struct ff1_ctx;
/*
* Create a context instance for use with the FF1 algorithm
*
* The created instance can be used for encryption or decryption
* or both. The instance is not thread-safe, though. For example,
* multiple instances can be created and used in different, individual
* threads. However, a single instance cannot be used for simultaneous
* encryptions/decryptions in multiple threads.
*
* @ctx: Pointer to location to store pointer to context data
* Caller supplies the address to a pointer. This function
* will fill it in
* @keybuf: Pointer to key data
* @keylen: Number of bytes in the key (must be 16, 24, 32)
* @twkbuf: Pointer to tweak data (may be NULL)
* @twklen: Number of bytes of tweak data (may be 0)
* @mintwklen: The minimum number of bytes allowed for the tweak data
* @maxtwklen: The maximum number of bytes allowed for the tweak data
* This number may be 0 to indicate that the maximum is unlimited
* @radix: The radix of the plain/cipher text data
*
* @return 0 on success or a negative error number on failure
*/
int ff1_ctx_create(struct ff1_ctx ** const ctx,
const uint8_t * const keybuf, const size_t keylen,
const uint8_t * const twkbuf, const size_t twklen,
const size_t mintwklen, const size_t maxtwklen,
const unsigned int radix);
/*
* Encrypt data using the FF1 algorithm
*
* Encryption is a "one-shot" operation. The entire plain text must
* be passed in, and the entire cipher text is returned. The cipher
* text uses the same "alphabet" as the plain text and will be the
* same length as the plain text.
*
* @ctx: The pointer returned by the create function
* @Y: A pointer to the location to output the cipher text. This space
* is allocated by the caller and must be at least as long as the
* plain text. The parameter must include space for a nul-terminator.
* @X: A pointer to the location of the plain text. The plain text must
* be nul-terminated
* @T: A pointer to the "tweak" parameter. This is a sequence of bytes
* and may be NULL. In the event that the tweak is NULL, the tweak
* supplied to the create function will be used.
* @t: The number of bytes pointed to by @T. If T is NULL, t is a
* don't-care
*
* @return 0 on success or a negative error number on failure
*/
int ff1_encrypt(struct ff1_ctx * const ctx,
char * const Y,
const char * const X,
const uint8_t * const T, const size_t t);
/*
* Decrypt data using the FF1 algorithm
*
* Decryption is a "one-shot" operation. The entire cipher text must
* be passed in, and the entire plain text is returned.
*
* @ctx: The pointer returned by the create function
* @Y: A pointer to the location to output the plain text. This space
* is allocated by the caller and must be at least as long as the
* cipher text. The parameter must include space for a nul-terminator.
* @X: A pointer to the location of the cipher text. The cipher text must
* be nul-terminated
* @T: A pointer to the "tweak" parameter. This is a sequence of bytes
* and may be NULL. In the event that the tweak is NULL, the tweak
* supplied to the create function will be used. The tweak must be
* the same as that used to perform the encryption
* @t: The number of bytes pointed to by @T. If T is NULL, t must be zero.
*
* @return 0 on success or a negative error number on failure
*/
int ff1_decrypt(struct ff1_ctx * const ctx,
char * const Y,
const char * const X,
const uint8_t * const T, const size_t t);
/*
* Destroy the context structure associated with the FF1 algorithm
*
* @ctx: The pointer returned by the create function
*/
void ff1_ctx_destroy(struct ff1_ctx * const ctx);
__END_DECLS
#endif
| 39.372549 | 77 | 0.689492 |
96bfd5b3eed6508ea06bd799bfc54214abc45654 | 4,375 | c | C | source/target/onsemi/ncs36510/flash_blob.c | yinglangli/ARMmbed_DAPLink | ec1e4ba495925c392baf1fad1695682af16c5445 | [
"Apache-2.0"
] | 708 | 2018-10-07T05:51:03.000Z | 2022-03-31T08:24:21.000Z | software/v2.3c/source/target/onsemi/ncs36510/flash_blob.c | fsyinghua/nanoDAP | abb2576144f368c224b653192094c20ed8aa74d7 | [
"Apache-2.0"
] | 18 | 2019-01-20T16:07:00.000Z | 2022-03-20T04:27:34.000Z | software/v2.3c/source/target/onsemi/ncs36510/flash_blob.c | fsyinghua/nanoDAP | abb2576144f368c224b653192094c20ed8aa74d7 | [
"Apache-2.0"
] | 209 | 2018-12-27T12:49:11.000Z | 2022-03-29T13:16:35.000Z | /* Flash OS Routines (Automagically Generated)
* Copyright (c) 2009-2015 ARM Limited
*
* 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.
*/
static const uint32_t ncs36510_flash_prog_blob[] = {
0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
0x4770ba40, 0x4770bac0, 0x4770ba40, 0x4770bac0, 0x49876842, 0x68016111, 0xf4116840, 0x49851f80,
0x6181bf14, 0x47706141, 0x68406801, 0x1f80f411, 0x6801d004, 0x0f02f011, 0x4770d1fb, 0xf0116801,
0xd1fb0f01, 0x68014770, 0xf4116840, 0x68411f80, 0xf041bf14, 0xf0410101, 0x60410102, 0x68014770,
0xf4116840, 0x68411f80, 0xf021bf14, 0xf0210101, 0x60410102, 0x68434770, 0x611a4a6d, 0x68436802,
0x1f80f412, 0xbf144a6b, 0x615a619a, 0x60d16842, 0x21016842, 0xe7c76091, 0xf4116801, 0x68411f80,
0xf44fbf14, 0xf44f1281, 0x60ca5200, 0x49606842, 0x68016111, 0xf4116842, 0x495e1f80, 0x6191bf14,
0x21026151, 0x60916842, 0x4770e7ae, 0x1e5b6808, 0xf810d305, 0xf802cb01, 0x1e5bcb01, 0x6008d2f9,
0x47702001, 0x4604b510, 0x46116808, 0x5f00f5b0, 0x020af3c0, 0xb132d20b, 0x020af3c0, 0x6200f5c2,
0xd205429a, 0xf5b3e00a, 0xd8076f00, 0xb13ae00b, 0x020af3c0, 0x6200f5c2, 0xd204429a, 0xbd102000,
0x6f00f5b3, 0x6862d8fa, 0xc004f8d2, 0x0c40f04c, 0xc004f8c2, 0xc004f8d4, 0xf8cc4a3d, 0x68222010,
0xc004f8d4, 0x1f80f412, 0xbf144a3a, 0x2018f8cc, 0x2014f8cc, 0xf000461a, 0x4620f8f7, 0xff64f7ff,
0xbd102001, 0x4d32b530, 0x46844c32, 0xd2562906, 0xf001e8df, 0x421f0355, 0x68015334, 0x1f80f411,
0xf44fbf14, 0xf44f1181, 0x68425100, 0x684160d1, 0x6801610d, 0x1f80f411, 0xbf146841, 0x614c618c,
0x68422102, 0xf7ff6091, 0x4660ff3f, 0xff3cf7ff, 0x6811e035, 0x61156842, 0xf4126802, 0x68421f80,
0x6194bf14, 0x68426154, 0x684260d1, 0x60912101, 0xff2af7ff, 0xf7ff4660, 0xe020ff27, 0x0000f8dc,
0x1f80f410, 0x0004f8dc, 0xbf146841, 0x0101f041, 0x0102f041, 0xe0126041, 0x0000f8dc, 0x1f80f410,
0x0004f8dc, 0xbf146841, 0x0101f021, 0x0102f021, 0x46606041, 0xff08f7ff, 0xf7ffe001, 0x2001ff05,
0x69c1bd30, 0x0f01f011, 0x69c0bf18, 0x00004770, 0xbb781ae9, 0xb56d9099, 0xb5104838, 0xf4216901,
0x61010100, 0xf0216901, 0x61014180, 0x49354834, 0xf04f6001, 0x211f20e0, 0x1180f8c0, 0x1280f8c0,
0xf04f4931, 0x60086020, 0x22004830, 0x44782103, 0xff78f7ff, 0xbd102000, 0x47702000, 0x47702000,
0xb510482b, 0xf7ff4478, 0x482aff07, 0xf7ff4478, 0x2000ff03, 0xb501bd10, 0xf5b09800, 0xbf3c5f00,
0xbd082001, 0x5100f5a0, 0x2fa0f5b1, 0x4822d204, 0x2102466a, 0xe0084478, 0x1081f5a0, 0x2fa0f5b0,
0x481ed205, 0x2102466a, 0xf7ff4478, 0x2000ff4b, 0xb507bd08, 0xf5b09800, 0xd3165f00, 0x5c00f5a0,
0x2fa0f5bc, 0x4816d204, 0x4669460b, 0xe0084478, 0x1081f5a0, 0x2fa0f5b0, 0x4812d20a, 0x4669460b,
0xf7ff4478, 0x2801feef, 0xb003d002, 0xbd002001, 0x2000b003, 0x2000bd00, 0x00004770, 0x4001b000,
0x4001e000, 0x2082353f, 0xe000ed04, 0x00000106, 0x000000e4, 0x000000e8, 0x000000b4, 0x000000ac,
0x0000007c, 0x00000074, 0x0301ea40, 0xd003079b, 0xc908e009, 0xc0081f12, 0xd2fa2a04, 0xf811e003,
0xf8003b01, 0x1e523b01, 0x4770d2f9, 0x00000000, 0x40017000, 0x00000008, 0x00100000, 0x40017000,
0x00000008, 0x00000000, 0x00000000, 0x00000000, 0x00000000
};
static const program_target_t flash = {
0x3fff4259, // Init
0x3fff4299, // UnInit
0x3fff42a1, // EraseChip
0x3fff42b7, // EraseSector
0x3fff42f3, // ProgramPage
0x0, // Verify
// BKPT : start of blob + 1
// RSB : blob start + header + rw data offset
// RSP : stack pointer
{
0x3fff4001,
0x3fff43a4,
0x3fff4800
},
0x3fff4000 + 0x00000A00, // mem buffer location
0x3fff4000, // location to write prog_blob in target RAM
sizeof(ncs36510_flash_prog_blob), // prog_blob size
ncs36510_flash_prog_blob, // address of prog_blob
0x00000200 // ram_to_flash_bytes_to_be_written
};
| 59.931507 | 99 | 0.760229 |
531cb5948cbd990c1afb27b9c9a3f406b039b128 | 2,269 | h | C | NoCoChat/handle.h | mickelfeng/qt_learning | 1f565754c36f0c09888cf4fbffa6271298d0678b | [
"Apache-2.0"
] | 1 | 2016-01-05T07:24:32.000Z | 2016-01-05T07:24:32.000Z | NoCoChat/handle.h | mickelfeng/qt_learning | 1f565754c36f0c09888cf4fbffa6271298d0678b | [
"Apache-2.0"
] | null | null | null | NoCoChat/handle.h | mickelfeng/qt_learning | 1f565754c36f0c09888cf4fbffa6271298d0678b | [
"Apache-2.0"
] | null | null | null | #ifndef HANDLE_H
#define HANDLE_H
/**
* 文件名:handle.h
* 文件功能:定义handle类的相关成员和声明所有成员函数
* 类的作用:所有界面的业务操作函数集合
* 类的继承:QObejct
* 作者:NoCo_jancojie
*/
#include <QObject>
#include "tcpnet.h"
#include "config.h"
#include <QRegExp>
#include <QMap>
#include <QStringList>
#include <QDebug>
#include <QList>
#include <QMessageBox>
#include "QMainWindow"
class Handle : public QObject
{
Q_OBJECT
public:
explicit Handle(QObject *parent = 0);
// 设置主窗口
void setWindow(QMainWindow *m);
// 信息提取
QString changeMessage(QString message);
// 单协议处理
QMap<QString, QString> getCommand(QString command);
// 多协议处理
QList<QMap<QString,QString> >getCommand(QString command,QString head);
// 注册处理
bool registered(QString userId,QString userName,QString pwd);
// 创建聊天室
bool creatTalkroom(QString userId, QString talkroomid, QString talkroomname);
// 登录处理
QString signIn(QString userId, QString pwd,int port);
// 获取用户列表
QList<QMap<QString, QString> > getUserList(QString userId);
// 获取聊天室列表
QList<QMap<QString,QString> >getRoomList();
// 获取聊天室列表
QList<QMap<QString,QString> >getRoomList(QString roomId,QString roomName="_empty_");
// 获取个人聊天室列表
QList<QMap<QString,QString> >getMyRoomList(QString userid);
// 添加好友
QMap<QString,QString> addFriend(QString userId, QString adduserid);
// 创建聊天室
QMap<QString,QString> creatRoom(QString userId, QString roomId,QString roomName);
// 获取所有好友列表
QList<QMap<QString,QString> >getFriendList(QString userid);
// 获取聊天室成员列表
QList<QMap<QString,QString> >getRoomFriendList(QString userid,QString roomid);
// 加入聊天室
QMap<QString,QString> addRoom(QString userId, QString roomId);
// 添加好友进入聊天室
int requestFriendToRoom(QString friendId,QString userId,QString roomName, QString roomId);
// 下线
void lamdownline(QString userId);
// 离线好友申请信息的添加
void reactionCacheRequest(QString userId);
// 获取邀请进群离线信息
void reactionCacheRoomRequest(QString userId);
signals:
public slots:
private:
protected:
// tcp对象
TcpNet tcp;
// 配置文件对象
Config config;
QString ip;
int port;
QMainWindow *window;
};
#endif // HANDLE_H
| 26.383721 | 95 | 0.68268 |
1b7c473d0b90b6e331ac4695feef2ccf0c60edf6 | 1,600 | c | C | hw/fake-rtc.c | apopple/skiboot | 4073798ccf03c63917d76fb522ba03a9a2b798a9 | [
"Apache-2.0"
] | null | null | null | hw/fake-rtc.c | apopple/skiboot | 4073798ccf03c63917d76fb522ba03a9a2b798a9 | [
"Apache-2.0"
] | null | null | null | hw/fake-rtc.c | apopple/skiboot | 4073798ccf03c63917d76fb522ba03a9a2b798a9 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2013-2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <skiboot.h>
#include <opal.h>
#include <mem_region.h>
static uint32_t *fake_ymd;
static uint64_t *fake_hmsm;
static int64_t fake_rtc_write(uint32_t ymd, uint64_t hmsm)
{
*fake_ymd = ymd;
*fake_hmsm = hmsm;
return OPAL_SUCCESS;
}
static int64_t fake_rtc_read(uint32_t *ymd, uint64_t *hmsm)
{
if (!ymd || !hmsm)
return OPAL_PARAMETER;
*ymd = *fake_ymd;
*hmsm = *fake_hmsm;
return OPAL_SUCCESS;
}
void fake_rtc_init(void)
{
struct mem_region *rtc_region = NULL;
uint32_t *rtc = NULL;
/* Read initial values from reserved memory */
rtc_region = find_mem_region("ibm,fake-rtc");
/* Should we register anyway? */
if (!rtc_region) {
prlog(PR_TRACE, "No initial RTC value found\n");
return;
}
rtc = (uint32_t *) rtc_region->start;
fake_ymd = rtc;
fake_hmsm = ((uint64_t *) &rtc[1]);
prlog(PR_TRACE, "Init fake RTC to 0x%x 0x%llx\n",
*fake_ymd, *fake_hmsm);
opal_register(OPAL_RTC_READ, fake_rtc_read, 2);
opal_register(OPAL_RTC_WRITE, fake_rtc_write, 2);
}
| 23.529412 | 70 | 0.71625 |
88f3dca56940f58be047112170ff443602f660e5 | 3,307 | c | C | src/common/io/fd.c | pgmasters/pgbackrest | 665da12ae7f519077512e60ce3a5ec6c6a9997fd | [
"MIT"
] | null | null | null | src/common/io/fd.c | pgmasters/pgbackrest | 665da12ae7f519077512e60ce3a5ec6c6a9997fd | [
"MIT"
] | null | null | null | src/common/io/fd.c | pgmasters/pgbackrest | 665da12ae7f519077512e60ce3a5ec6c6a9997fd | [
"MIT"
] | null | null | null | /***********************************************************************************************************************************
File Descriptor Functions
***********************************************************************************************************************************/
#include "build.auto.h"
#ifdef __sun__ // Illumos needs sys/siginfo for sigset_t inside poll.h
#include <sys/siginfo.h>
#endif
#include <poll.h>
#include "common/debug.h"
#include "common/io/fd.h"
#include "common/log.h"
#include "common/wait.h"
/***********************************************************************************************************************************
Use poll() to determine when data is ready to read/write on a socket. Retry after EINTR with whatever time is left on the timer.
***********************************************************************************************************************************/
// Helper to determine when poll() should be retried
static bool
fdReadyRetry(int pollResult, int errNo, bool first, TimeMSec *timeout, TimeMSec timeEnd)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(INT, pollResult);
FUNCTION_TEST_PARAM(INT, errNo);
FUNCTION_TEST_PARAM(BOOL, first);
FUNCTION_TEST_PARAM_P(TIME_MSEC, timeout);
FUNCTION_TEST_PARAM(TIME_MSEC, timeEnd);
FUNCTION_TEST_END();
ASSERT(timeout != NULL);
// No retry by default
bool result = false;
// Process errors
if (pollResult == -1)
{
// Don't error on an interrupt. If the interrupt lasts long enough there may be a timeout, though.
if (errNo != EINTR)
THROW_SYS_ERROR_CODE(errNo, KernelError, "unable to poll socket");
// Always retry on the first iteration
if (first)
{
result = true;
}
// Else retry if there is time left
else
{
TimeMSec timeCurrent = timeMSec();
if (timeEnd > timeCurrent)
{
*timeout = timeEnd - timeCurrent;
result = true;
}
}
}
FUNCTION_TEST_RETURN(BOOL, result);
}
bool
fdReady(int fd, bool read, bool write, TimeMSec timeout)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(INT, fd);
FUNCTION_LOG_PARAM(BOOL, read);
FUNCTION_LOG_PARAM(BOOL, write);
FUNCTION_LOG_PARAM(TIME_MSEC, timeout);
FUNCTION_LOG_END();
ASSERT(fd >= 0);
ASSERT(read || write);
ASSERT(timeout < INT_MAX);
// Poll settings
struct pollfd inputFd = {.fd = fd};
if (read)
inputFd.events |= POLLIN;
if (write)
inputFd.events |= POLLOUT;
// Wait for ready or timeout
TimeMSec timeEnd = timeMSec() + timeout;
bool first = true;
// Initialize result and errno to look like a retryable error. We have no good way to test this function with interrupts so this
// at least ensures that the condition is retried.
int result = -1;
int errNo = EINTR;
while (fdReadyRetry(result, errNo, first, &timeout, timeEnd))
{
result = poll(&inputFd, 1, (int)timeout);
errNo = errno;
first = false;
}
FUNCTION_LOG_RETURN(BOOL, result > 0);
}
| 31.198113 | 132 | 0.517992 |
4b6e857807725a4d2f794fdf0f2ba956ea78157d | 1,659 | h | C | src/include/parser/insert_statement.h | Nov11/15-721 | b52c173d4be6838faa86b69959c0c341748f3e58 | [
"Apache-2.0"
] | 2 | 2021-03-29T01:29:18.000Z | 2022-02-27T11:22:15.000Z | src/include/parser/insert_statement.h | lym953/15721-p3 | c5ba8004c6f0f10472aa004303c04be1c860ade9 | [
"Apache-2.0"
] | null | null | null | src/include/parser/insert_statement.h | lym953/15721-p3 | c5ba8004c6f0f10472aa004303c04be1c860ade9 | [
"Apache-2.0"
] | null | null | null | //===----------------------------------------------------------------------===//
//
// Peloton
//
// statement_insert.h
//
// Identification: src/include/parser/statement_insert.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#pragma once
#include "common/sql_node_visitor.h"
#include "parser/sql_statement.h"
#include "select_statement.h"
namespace peloton {
namespace parser {
/**
* @class InsertStatement
* @brief Represents "INSERT INTO students VALUES ('Max', 1112233,
* 'Musterhausen', 2.3)"
*/
class InsertStatement : public SQLStatement {
public:
InsertStatement(InsertType type)
: SQLStatement(StatementType::INSERT), type(type), select(nullptr) {}
virtual ~InsertStatement() {}
virtual void Accept(SqlNodeVisitor *v) override { v->Visit(this); }
inline std::string GetTableName() const { return table_ref_->GetTableName(); }
inline void TryBindDatabaseName(std::string default_database_name) {
table_ref_->TryBindDatabaseName(default_database_name);
}
inline std::string GetDatabaseName() const {
return table_ref_->GetDatabaseName();
}
const std::string GetInfo(int num_indent) const override;
const std::string GetInfo() const override;
InsertType type;
std::vector<std::string> columns;
std::vector<std::vector<std::unique_ptr<expression::AbstractExpression>>>
insert_values;
std::unique_ptr<SelectStatement> select;
// Which table are we inserting into
std::unique_ptr<TableRef> table_ref_;
};
} // namespace parser
} // namespace peloton
| 26.758065 | 80 | 0.649186 |
c62c5df491cefef500dff966fed592496ee80cd4 | 288 | h | C | _KaramayEngine/karamay_engine_graphics_unit/karamay_engine_graphics_unit/source/graphics/mesh/material/gl_material.h | MorphingDev/karamay_engine | 044aaf7af813b01dbc26185852865c8a0369efca | [
"MIT"
] | null | null | null | _KaramayEngine/karamay_engine_graphics_unit/karamay_engine_graphics_unit/source/graphics/mesh/material/gl_material.h | MorphingDev/karamay_engine | 044aaf7af813b01dbc26185852865c8a0369efca | [
"MIT"
] | null | null | null | _KaramayEngine/karamay_engine_graphics_unit/karamay_engine_graphics_unit/source/graphics/mesh/material/gl_material.h | MorphingDev/karamay_engine | 044aaf7af813b01dbc26185852865c8a0369efca | [
"MIT"
] | 1 | 2022-01-29T08:34:51.000Z | 2022-01-29T08:34:51.000Z | #pragma once
#include "graphics/texture/gl_texture.h"
struct gl_material
{
std::unordered_map<std::string, std::shared_ptr<gl_texture_2d>> texture_2ds_map;
std::unordered_map<std::string, std::float_t> float_uniforms_map;
std::unordered_map<std::string, glm::vec3> vec3s_map;
};
| 19.2 | 81 | 0.763889 |
5b948e0602ca49ddb1a85b7bab89ec1da5cbd9d6 | 21,300 | h | C | coreLibrary_200/source/physics/dgBody.h | rastullahs-lockenpracht/newton | 99b82478f3de9ee7c8d17c8ebefe62e46283d857 | [
"Zlib"
] | null | null | null | coreLibrary_200/source/physics/dgBody.h | rastullahs-lockenpracht/newton | 99b82478f3de9ee7c8d17c8ebefe62e46283d857 | [
"Zlib"
] | null | null | null | coreLibrary_200/source/physics/dgBody.h | rastullahs-lockenpracht/newton | 99b82478f3de9ee7c8d17c8ebefe62e46283d857 | [
"Zlib"
] | null | null | null | /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*/
#if !defined(AFX_DGBODY_H__C16EDCD6_53C4_4C6F_A70A_591819F7187E__INCLUDED_)
#define AFX_DGBODY_H__C16EDCD6_53C4_4C6F_A70A_591819F7187E__INCLUDED_
#include "dgPhysicsStdafx.h"
#include "dgBodyMasterList.h"
class dgLink;
class dgBody;
class dgWorld;
class dgCollision;
class dgBroadPhaseCell;
#define DG_MIN_SPEED_ATT dgFloat32(0.0f)
#define DG_MAX_SPEED_ATT dgFloat32(0.02f)
#define DG_INFINITE_MASS dgFloat32(1.0e15f)
#define DG_FREEZE_MAG dgFloat32(0.1f)
#define DG_FREEZE_MAG2 dgFloat32(DG_FREEZE_MAG * DG_FREEZE_MAG)
#define DG_ErrTolerance (1.0e-2f)
#define DG_ErrTolerance2 (DG_ErrTolerance * DG_ErrTolerance)
DG_MSC_VECTOR_ALIGMENT
struct dgLineBox
{
dgVector m_l0;
dgVector m_l1;
dgVector m_boxL0;
dgVector m_boxL1;
} DG_GCC_VECTOR_ALIGMENT;
class dgConvexCastReturnInfo
{
public:
dgFloat32 m_point[4]; // collision point in global space
dgFloat32 m_normal[4]; // surface normal at collision point in global space
dgFloat32 m_normalOnHitPoint[4]; // surface normal at the surface of the hit body,
// is the same as the normal calculate by a raycast passing by the hit point in the direction of the cast
dgFloat32 m_penetration; // contact penetration at collision point
dgInt32 m_contaID; // collision ID at contact point
const dgBody* m_hitBody; // body hit at contact point
};
typedef void (dgApi *OnBodyDestroy) (dgBody& me);
typedef void (dgApi *OnApplyExtForceAndTorque) (dgBody& me, dgFloat32 timestep, dgInt32 threadIndex);
typedef void (dgApi *OnMatrixUpdateCallback) (const dgBody& me, const dgMatrix& matrix, dgInt32 threadIndex);
typedef dgUnsigned32 (dgApi *OnRayPrecastAction) (const dgBody* const body, const dgCollision* const collision, void* const userData);
typedef dgFloat32 (dgApi *OnRayCastAction) (const dgBody* const body, const dgVector& normal, dgInt32 collisionID, void* const userData, dgFloat32 intersetParam);
typedef dgUnsigned32 (dgApi *GetBuoyancyPlane) (void* collisionID, void* context, const dgMatrix& matrix, dgPlane& plane);
#define OverlapTest(body0,body1) dgOverlapTest ((body0)->m_minAABB, (body0)->m_maxAABB, (body1)->m_minAABB, (body1)->m_maxAABB)
//#define OverlapTest_SSE(body0,body1) dgOverlapTest_SSE ((body0)->m_minAABB, (body0)->m_maxAABB, (body1)->m_minAABB, (body1)->m_maxAABB)
class dgBroadPhaseList
{
public:
dgBroadPhaseCell* m_cell;
void* m_axisArrayNode[3];
};
DG_MSC_VECTOR_ALIGMENT
class dgBody
{
public:
DG_CLASS_ALLOCATOR(allocator)
dgBody();
~dgBody();
void AddForce (const dgVector& force);
void AddTorque (const dgVector& torque);
void AttachCollision (dgCollision* collision);
void SetGroupID (dgUnsigned32 id);
void SetMatrix(const dgMatrix& matrix);
void SetMatrixIgnoreSleep(const dgMatrix& matrix);
void SetUserData (void* const userData);
void SetForce (const dgVector& force);
void SetTorque (const dgVector& torque);
void SetOmega (const dgVector& omega);
void SetVelocity (const dgVector& velocity);
void SetLinearDamping (dgFloat32 linearDamp);
void SetAngularDamping (const dgVector& angularDamp);
void SetCentreOfMass (const dgVector& com);
void SetAparentMassMatrix (const dgVector& massMatrix);
void SetMassMatrix (dgFloat32 mass, dgFloat32 Ix, dgFloat32 Iy, dgFloat32 Iz);
// void SetGyroscopicTorqueMode (bool mode);
void SetCollisionWithLinkedBodies (bool state);
// void SetFreezeTreshhold (dgFloat32 freezeAccel2, dgFloat32 freezeAlpha2, dgFloat32 freezeSpeed2, dgFloat32 freezeOmega2);
void SetContinuesCollisionMode (bool mode);
void SetDestructorCallback (OnBodyDestroy destructor);
void SetMatrixUpdateCallback (OnMatrixUpdateCallback callback);
OnMatrixUpdateCallback GetMatrixUpdateCallback ();
// void SetAutoactiveNotify (OnActivation activate);
void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback);
OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const;
dgConstraint* GetFirstJoint() const;
dgConstraint* GetNextJoint(dgConstraint* joint) const;
dgConstraint* GetFirstContact() const;
dgConstraint* GetNextContact(dgConstraint* joint) const;
void* GetUserData() const;
dgWorld* GetWorld() const;
const dgVector& GetMass() const;
const dgVector& GetInvMass() const;
const dgVector& GetAparentMass() const;
const dgVector& GetOmega() const;
const dgVector& GetVelocity() const;
const dgVector& GetForce() const;
const dgVector& GetTorque() const;
const dgVector& GetNetForce() const;
const dgVector& GetNetTorque() const;
dgCollision* GetCollision () const;
dgUnsigned32 GetGroupID () const;
const dgMatrix& GetMatrix() const;
const dgVector& GetPosition() const;
const dgQuaternion& GetRotation() const;
dgFloat32 GetLinearDamping () const;
dgVector GetAngularDamping () const;
dgVector GetCentreOfMass () const;
bool IsInEquelibrium () const;
void GetAABB (dgVector &p0, dgVector &p1) const;
bool GetSleepState () const;
bool GetAutoSleep () const;
void SetAutoSleep (bool state);
bool GetFreeze () const;
void SetFreeze (bool state);
void Freeze ();
void Unfreeze ();
dgInt32 GetUniqueID () const;
bool GetCollisionWithLinkedBodies () const;
bool GetContinuesCollisionMode () const;
void AddBuoyancyForce (dgFloat32 fluidDensity, dgFloat32 fluidLinearViscousity, dgFloat32 fluidAngularViscousity,
const dgVector& gravityVector, GetBuoyancyPlane buoyancyPlane, void* const context);
dgVector CalculateInverseDynamicForce (const dgVector& desiredVeloc, dgFloat32 timestep) const;
// dgFloat32 RayCast (const dgVector& globalP0, const dgVector& globalP1,
dgFloat32 RayCast (const dgLineBox& line,
OnRayCastAction filter, OnRayPrecastAction preFilter, void* const userData, dgFloat32 minT) const;
// dgFloat32 RayCastSimd (const dgVector& globalP0, const dgVector& globalP1,
// OnRayCastAction filter, OnRayPrecastAction preFilter, void* userData, dgFloat32 minT) const;
void CalcInvInertiaMatrix ();
void CalcInvInertiaMatrixSimd ();
const dgMatrix& GetCollisionMatrix () const;
dgBodyMasterList::dgListNode* GetMasterList() const;
void InvalidateCache ();
private:
void SetMatrixOriginAndRotation(const dgMatrix& matrix);
void CalculateContinueVelocity (dgFloat32 timestep, dgVector& veloc, dgVector& omega) const;
void CalculateContinueVelocitySimd (dgFloat32 timestep, dgVector& veloc, dgVector& omega) const;
dgVector GetTrajectory (const dgVector& veloc, const dgVector& omega) const;
void IntegrateVelocity (dgFloat32 timestep);
void UpdateMatrix (dgFloat32 timestep, dgInt32 threadIndex);
void UpdateCollisionMatrix (dgFloat32 timestep, dgInt32 threadIndex);
void UpdateCollisionMatrixSimd (dgFloat32 timestep, dgInt32 threadIndex);
void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex);
void AddImpulse (const dgVector& pointVeloc, const dgVector& pointPosit);
void ApplyImpulseArray (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray);
// void AddGyroscopicTorque();
void AddDamingAcceleration();
dgMatrix CalculateInertiaMatrix () const;
dgMatrix CalculateInvInertiaMatrix () const;
dgMatrix m_matrix;
dgMatrix m_collisionWorldMatrix;
dgMatrix m_invWorldInertiaMatrix;
dgQuaternion m_rotation;
dgVector m_veloc;
dgVector m_omega;
dgVector m_accel;
dgVector m_alpha;
dgVector m_netForce;
dgVector m_netTorque;
dgVector m_prevExternalForce;
dgVector m_prevExternalTorque;
dgVector m_mass;
dgVector m_invMass;
dgVector m_aparentMass;
dgVector m_localCentreOfMass;
dgVector m_globalCentreOfMass;
dgVector m_minAABB;
dgVector m_maxAABB;
dgVector m_dampCoef;
dgInt32 m_index;
dgInt32 m_uniqueID;
dgInt32 m_bodyGroupId;
dgInt32 m_genericLRUMark;
dgInt32 m_sleepingCounter;
dgUnsigned32 m_dynamicsLru;
dgUnsigned32 m_isInDerstruionArrayLRU;
dgUnsigned32 m_freeze : 1;
dgUnsigned32 m_sleeping : 1;
dgUnsigned32 m_autoSleep : 1;
dgUnsigned32 m_isInWorld : 1;
dgUnsigned32 m_equilibrium : 1;
dgUnsigned32 m_continueCollisionMode : 1;
dgUnsigned32 m_spawnnedFromCallback : 1;
dgUnsigned32 m_collideWithLinkedBodies : 1;
dgUnsigned32 m_solverInContinueCollision: 1;
dgUnsigned32 m_inCallback : 1;
void* m_userData;
dgWorld* m_world;
dgCollision* m_collision;
dgBroadPhaseList m_collisionCell;
dgBodyMasterList::dgListNode* m_masterNode;
OnBodyDestroy m_destructor;
OnMatrixUpdateCallback m_matrixUpdate;
OnApplyExtForceAndTorque m_applyExtForces;
friend class dgWorld;
friend class dgContact;
friend class dgCollision;
friend class dgBodyChunk;
friend class dgSortArray;
friend class dgConstraint;
friend class dgContactArray;
friend class dgContactSolver;
friend class dgBroadPhaseCell;
friend class dgCollisionConvex;
friend class dgCollisionEllipse;
friend class dgCollisionCompound;
friend class dgCollisionUserMesh;
friend class dgWorldDynamicUpdate;
friend class dgCollisionConvexHull;
friend class dgCollisionScene;
friend class dgCollisionBVH;
friend class dgBodyMasterList;
friend class dgJacobianMemory;
friend class dgBilateralConstraint;
friend class dgBroadPhaseCollision;
friend class dgSolverWorlkerThreads;
friend class dgCollisionConvexModifier;
friend class dgCollidingPairCollector;
friend class dgAABBOverlapPairList;
friend class dgParallelSolverClear;
friend class dgParallelSolverUpdateForce;
friend class dgParallelSolverUpdateVeloc;
friend class dgParallelSolverBodyInertia;
friend class dgBroadPhaseApplyExternalForce;
friend class dgParallelSolverBuildJacobianRows;
friend class dgParallelSolverBuildJacobianMatrix;
}DG_GCC_VECTOR_ALIGMENT;
// *****************************************************************************
//
// Implementation
//
// *****************************************************************************
inline void dgBody::SetAutoSleep (bool state)
{
m_autoSleep = dgUnsigned32 (state);
if (m_autoSleep == 0) {
m_sleeping = false;
}
}
inline bool dgBody::GetAutoSleep () const
{
return m_autoSleep;
}
inline bool dgBody::GetSleepState () const
{
return m_sleeping;
}
/*
inline bool dgBody::GetActive () const
{
return m_active;
}
*/
inline bool dgBody::GetCollisionWithLinkedBodies () const
{
return m_collideWithLinkedBodies;
}
inline void dgBody::SetCollisionWithLinkedBodies (bool state)
{
m_collideWithLinkedBodies = dgUnsigned32 (state);
}
inline void dgBody::SetUserData(void* const userData)
{
m_userData = userData;
}
inline void* dgBody::GetUserData() const
{
return m_userData;
}
inline dgWorld* dgBody::GetWorld() const
{
return m_world;
}
inline dgUnsigned32 dgBody::GetGroupID () const
{
return dgUnsigned32 (m_bodyGroupId);
}
inline void dgBody::SetGroupID (dgUnsigned32 id)
{
m_bodyGroupId = dgInt32 (id);
}
inline void dgBody::SetDestructorCallback (OnBodyDestroy destructor)
{
m_destructor = destructor;
}
inline void dgBody::SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback)
{
m_applyExtForces = callback;
}
inline OnApplyExtForceAndTorque dgBody::GetExtForceAndTorqueCallback () const
{
return m_applyExtForces;
}
/*
inline void dgBody::SetAutoactiveNotify (OnActivation activate)
{
m_activation = activate;
if (m_activation) {
m_activation (*this, m_active ? 1 : 0);
}
}
*/
inline void dgBody::SetMatrixUpdateCallback (OnMatrixUpdateCallback callback)
{
m_matrixUpdate = callback;
}
inline OnMatrixUpdateCallback dgBody::GetMatrixUpdateCallback ()
{
return m_matrixUpdate;
}
/*
inline void dgBody::SetFreezeTreshhold (dgFloat32 freezeAccel2, dgFloat32 freezeAlpha2, dgFloat32 freezeSpeed2, dgFloat32 freezeOmega2)
{
m_freezeAccel2 = GetMax (freezeAccel2, dgFloat32(DG_FREEZE_MAG2));
m_freezeAlpha2 = GetMax (freezeAlpha2, dgFloat32(DG_FREEZE_MAG2));
m_freezeSpeed2 = GetMax (freezeSpeed2, dgFloat32(DG_FREEZE_MAG2));
m_freezeOmega2 = GetMax (freezeOmega2, dgFloat32(DG_FREEZE_MAG2));
}
inline void dgBody::GetFreezeTreshhold (dgFloat32& freezeAccel2, dgFloat32& freezeAlpha2, dgFloat32& freezeSpeed2, dgFloat32& freezeOmega2) const
{
freezeAccel2 = m_freezeAccel2;
freezeAlpha2 = m_freezeAlpha2;
freezeSpeed2 = m_freezeSpeed2;
freezeOmega2 = m_freezeOmega2;
}
*/
inline void dgBody::SetOmega (const dgVector& omega)
{
m_omega = omega;
}
inline void dgBody::SetVelocity (const dgVector& velocity)
{
m_veloc = velocity;
}
inline void dgBody::SetCentreOfMass (const dgVector& com)
{
m_localCentreOfMass.m_x = com.m_x;
m_localCentreOfMass.m_y = com.m_y;
m_localCentreOfMass.m_z = com.m_z;
m_localCentreOfMass.m_w = dgFloat32 (1.0f);
m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass);
}
inline void dgBody::AddForce (const dgVector& force)
{
SetForce (m_accel + force);
}
inline void dgBody::AddTorque (const dgVector& torque)
{
SetTorque (torque + m_alpha);
}
inline const dgVector& dgBody::GetMass() const
{
return m_mass;
}
inline const dgVector& dgBody::GetAparentMass() const
{
return m_aparentMass;
}
inline const dgVector& dgBody::GetInvMass() const
{
return m_invMass;
}
inline const dgVector& dgBody::GetOmega() const
{
return m_omega;
}
inline const dgVector& dgBody::GetVelocity() const
{
return m_veloc;
}
inline const dgVector& dgBody::GetForce() const
{
return m_accel;
}
inline const dgVector& dgBody::GetTorque() const
{
return m_alpha;
}
inline const dgVector& dgBody::GetNetForce() const
{
return m_netForce;
}
inline const dgVector& dgBody::GetNetTorque() const
{
return m_netTorque;
}
inline dgCollision* dgBody::GetCollision () const
{
return m_collision;
}
inline const dgVector& dgBody::GetPosition() const
{
return m_matrix.m_posit;
}
inline const dgQuaternion& dgBody::GetRotation() const
{
return m_rotation;
}
inline const dgMatrix& dgBody::GetMatrix() const
{
return m_matrix;
}
inline dgVector dgBody::GetCentreOfMass () const
{
return m_localCentreOfMass;
}
inline void dgBody::GetAABB (dgVector &p0, dgVector &p1) const
{
p0.m_x = m_minAABB.m_x;
p0.m_y = m_minAABB.m_y;
p0.m_z = m_minAABB.m_z;
p1.m_x = m_maxAABB.m_x;
p1.m_y = m_maxAABB.m_y;
p1.m_z = m_maxAABB.m_z;
}
/*
inline void dgBody::SetGyroscopicTorqueMode (bool mode)
{
m_applyGyroscopic = mode;
}
inline bool dgBody::GetGyroscopicTorqueMode () const
{
return m_applyGyroscopic;
}
*/
inline const dgMatrix& dgBody::GetCollisionMatrix () const
{
return m_collisionWorldMatrix;
}
inline void dgBody::SetContinuesCollisionMode (bool mode)
{
m_continueCollisionMode = dgUnsigned32 (mode);
}
inline bool dgBody::GetContinuesCollisionMode () const
{
return m_continueCollisionMode;
}
inline void dgBody::ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex)
{
m_accel = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
m_alpha = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
if (m_applyExtForces) {
m_applyExtForces(*this, timestep, threadIndex);
}
}
inline dgFloat32 dgBody::GetLinearDamping () const
{
// return (m_linearDampCoef - DG_MIN_SPEED_ATT) / (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT);
return (m_dampCoef.m_w - DG_MIN_SPEED_ATT) / (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT);
}
inline dgVector dgBody::GetAngularDamping () const
{
return dgVector ((m_dampCoef.m_x - DG_MIN_SPEED_ATT) / (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT),
(m_dampCoef.m_y - DG_MIN_SPEED_ATT) / (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT),
(m_dampCoef.m_z - DG_MIN_SPEED_ATT) / (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT), dgFloat32 (0.0f));
}
inline void dgBody::SetLinearDamping (dgFloat32 linearDamp)
{
linearDamp = ClampValue (linearDamp, dgFloat32(0.0f), dgFloat32(1.0f));
m_dampCoef.m_w = DG_MIN_SPEED_ATT + (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT) * linearDamp;
}
inline void dgBody::SetAngularDamping (const dgVector& angularDamp)
{
dgFloat32 tmp;
tmp = ClampValue (angularDamp.m_x, dgFloat32(0.0f), dgFloat32(1.0f));
m_dampCoef.m_x = DG_MIN_SPEED_ATT + (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT) * tmp;
tmp = ClampValue (angularDamp.m_y, dgFloat32(0.0f), dgFloat32(1.0f));
m_dampCoef.m_y = DG_MIN_SPEED_ATT + (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT) * tmp;
tmp = ClampValue (angularDamp.m_z, dgFloat32(0.0f), dgFloat32(1.0f));
m_dampCoef.m_z = DG_MIN_SPEED_ATT + (DG_MAX_SPEED_ATT - DG_MIN_SPEED_ATT) * tmp;
}
inline void dgBody::AddDamingAcceleration()
{
m_veloc -= m_veloc.Scale (m_dampCoef.m_w);
dgVector omega (m_matrix.UnrotateVector (m_omega));
omega -= omega.CompProduct (m_dampCoef);
m_omega = m_matrix.RotateVector (omega);
}
/*
inline void dgBody::AddGyroscopicTorque()
{
_ASSERTE (0);
if (m_applyGyroscopic) {
const dgVector inertia = m_mass;
dgVector omega (m_matrix.UnrotateVector (m_omega));
m_alpha -= m_matrix.RotateVector(omega.CompProduct(inertia) * omega);
}
}
*/
inline void dgBody::SetForce (const dgVector& force)
{
dgFloat32 errMag2;
dgVector error;
m_accel = force;
error = m_accel - m_prevExternalForce;
errMag2 = (error % error) * m_invMass[3] * m_invMass[3];
if (errMag2 > DG_ErrTolerance2) {
m_sleepingCounter = 0;
}
}
inline void dgBody::SetTorque (const dgVector& torque)
{
dgFloat32 errMag2;
dgVector error;
m_alpha = torque;
error = m_alpha - m_prevExternalTorque;
errMag2 = (error % error) * m_invMass[3] * m_invMass[3];
if (errMag2 > DG_ErrTolerance2) {
m_sleepingCounter = 0;
}
}
//inline int dgBody::GetApplicationFreezeState() const
//{
// return m_aplycationFreeze ? 1 : 0;
//}
//inline void dgBody::SetApplicationFreezeState(dgInt32 state)
//{
// m_aplycationFreeze = state ? true : false;
//}
inline dgBodyMasterList::dgListNode* dgBody::GetMasterList() const
{
return m_masterNode;
}
inline bool dgBody::GetFreeze () const
{
return m_freeze;
}
inline dgInt32 dgBody::GetUniqueID () const
{
return m_uniqueID;
}
inline bool dgBody::IsInEquelibrium () const
{
dgFloat32 invMassMag2 = m_invMass[3] * m_invMass[3];
if (m_equilibrium) {
dgVector error (m_accel - m_prevExternalForce);
dgFloat32 errMag2 = (error % error) * invMassMag2;
if (errMag2 < DG_ErrTolerance2) {
error = m_alpha - m_prevExternalTorque;
errMag2 = (error % error) * invMassMag2;
if (errMag2 < DG_ErrTolerance2) {
errMag2 = (m_netForce % m_netForce) * invMassMag2;
if (errMag2 < DG_ErrTolerance2) {
errMag2 = (m_netTorque % m_netTorque) * invMassMag2;
if (errMag2 < DG_ErrTolerance2) {
errMag2 = m_veloc % m_veloc;
if (errMag2 < DG_ErrTolerance2) {
errMag2 = m_omega % m_omega;
if (errMag2 < DG_ErrTolerance2) {
return true;
}
}
}
}
}
}
}
return false;
}
inline void dgBody::SetMatrixOriginAndRotation(const dgMatrix& matrix)
{
m_matrix = matrix;
#ifdef _DEBUG
for (int i = 0; i < 4; i ++) {
for (int j = 0; j < 4; j ++) {
_ASSERTE (dgCheckFloat(m_matrix[i][j]));
}
}
int j0 = 1;
int j1 = 2;
for (dgInt32 i = 0; i < 3; i ++) {
dgFloat32 val;
_ASSERTE (m_matrix[i][3] == 0.0f);
val = m_matrix[i] % m_matrix[i];
_ASSERTE (dgAbsf (val - 1.0f) < 1.0e-5f);
dgVector tmp (m_matrix[j0] * m_matrix[j1]);
val = tmp % m_matrix[i];
_ASSERTE (dgAbsf (val - 1.0f) < 1.0e-5f);
j0 = j1;
j1 = i;
}
#endif
m_rotation = dgQuaternion (m_matrix);
m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass);
// matrix.m_front = matrix.m_front.Scale (dgRsqrt (matrix.m_front % matrix.m_front));
// matrix.m_right = matrix.m_front * matrix.m_up;
// matrix.m_right = matrix.m_right.Scale (dgRsqrt (matrix.m_right % matrix.m_right));
// matrix.m_up = matrix.m_right * matrix.m_front;
}
#endif // !defined(AFX_DGBODY_H__C16EDCD6_53C4_4C6F_A70A_591819F7187E__INCLUDED_)
| 27.952756 | 163 | 0.730188 |
176b01b4942d4224c72338f9e4ba0bba44bd7906 | 264 | h | C | rcnn/box.h | kurff/caffe-ssd-kurff | bdf259991cf977a736fafcae9b28938096325a36 | [
"MIT"
] | 1 | 2019-03-13T07:30:29.000Z | 2019-03-13T07:30:29.000Z | rcnn/box.h | kurff/caffe-ssd-kurff | bdf259991cf977a736fafcae9b28938096325a36 | [
"MIT"
] | null | null | null | rcnn/box.h | kurff/caffe-ssd-kurff | bdf259991cf977a736fafcae9b28938096325a36 | [
"MIT"
] | null | null | null | #ifndef __BOX_H__
#define __BOX_H__
#include <string>
namespace rcnn{
typedef struct Box_{
float x;
float y;
float width;
float height;
int label;
std::string label_name;
float score;
}Box;
}
#endif | 15.529412 | 31 | 0.57197 |
c0e5bedcb9c3adf096fe3c0e4a90abd44168b222 | 3,510 | h | C | src/copyright.h | fstltna/Battletech-MUX | eb6e785d8790b68add046a4f64419bb5afe99316 | [
"Artistic-1.0"
] | 3 | 2017-05-20T01:41:10.000Z | 2020-04-15T20:14:40.000Z | src/copyright.h | fstltna/Battletech-MUX | eb6e785d8790b68add046a4f64419bb5afe99316 | [
"Artistic-1.0"
] | null | null | null | src/copyright.h | fstltna/Battletech-MUX | eb6e785d8790b68add046a4f64419bb5afe99316 | [
"Artistic-1.0"
] | null | null | null |
/* copyright.h */
/* -*-C-*- */
/* $Id: copyright.h 1.1 02/01/03 01:00:15-00:00 twouters@ $ */
/*
* TinyMUX 1.0, 1.1 and 1.2 Source code is maintained by David Passmore
* (Lauren@Children of the Atom).
* Comments should be sent to lauren@ranger.range.orst.edu.
* TinyMUX is Copyright (c) 1995 by David Passmore.
*
* Many parts of the source code, and the help text were derived from
* TinyMUSH 2.2:
* TinyMUSH 2.2 Source was written in part by
* Jean Marie Diaz, Lydia Leong, and Devin Hooker
* 2.2 initial alpha release 9/21/94.
* final beta snapshot (hopefully) 3/4/95
*
* Many parts of the source code, and the help text were derived from
* PennMUSH 1.50:
*
* Patchlevel 12 is based on PennMUSH pl10, the last version of PennMUSH
* released by Amberyl. All copyright notices above continue to apply.
* Versions of PennMUSH prior to pl10 are written in part by
* Alan Schwartz
* Thanks and praise are due to:
* Ralph Melton (Rhyanna@Castle D'Image) for bugs reports, patches, ideas,
* and extensions
* T. Alexander Popiel for bug reports, patches, ideas, and extensions, too.
* Al Brown (Kalkin@DarkZone) for many clever ideas
* The many other people who've sent in bug reports
* The admin and players of Dune II, who put up with a lot of broken code
* Special thanks to Amberyl for all her help.
* - Paul/Javelin (Alan Schwartz, alansz@mellers1.psych.berkeley.edu)
*
* Based on TinyMUSH 2.0 Source code
* Copyright (c) 1991 Joseph Traub and Glenn Crocker
*
* Based on TinyMUD code
* Copyright (c) 1989, 1990 by David Applegate, James Aspnes, Timothy Freeman,
* and Bennet Yee.
*
* This material was developed by the above-mentioned authors. Permission to
* copy this software, to redistribute it, and to use it for any purpose is
* granted, subject to the following restrictions and understandings.
*
* 1. Any copy made of this software must include this copyright notice in
* full.
*
* 2. Users of this software agree to make their best efforts
* (a) to return to the above-mentioned authors any improvements or
* extensions that they make, so that these may be included in future
* releases; and
* (b) to inform the authors of noteworthy uses of this software.
*
* 3. All materials developed as a consequence of the use of this software
* shall duly acknowledge such use, in accordance with the usual standards
* of acknowledging credit in academic research.
*
* 4. The authors have made no warrantee or representation that the operation
* of this software will be error-free, and the authors are under no
* obligation to provide any services, by way of maintenance, update, or
* otherwise.
*
* 5. In conjunction with products arising from the use of this material,
* there shall be no use of the names of the authors, of Carnegie-Mellon
* University, nor of any adaptation thereof in any advertising,
* promotional, or sales literature without prior written consent from
* the authors and both Carnegie-Mellon University Case Wester Reserve
* University in each case.
*
* Credits:
* Lawrence Foard:
* Wrote the original TinyMUSH 1.0 code from which this later derived.
* Jin (and MicroMUSH):
* Made many, many changes to the code that improved it immensely.
* Lachesis:
* Introduced the idea of property lists to TinyMUCK
* Many others:
* Many features borrowed from other muds.
*/
| 41.785714 | 78 | 0.706553 |
02431844a5bd3e8a1c56c5fb0e344db735ee4e55 | 27,681 | c | C | oss_c_sdk_test/test_oss_live.c | zhengbincesc/aliyun-oss-c-sdk | 264839ac8dd355b2b586e2359c4324d3a991c39e | [
"MIT"
] | 1 | 2019-03-28T08:12:37.000Z | 2019-03-28T08:12:37.000Z | oss_c_sdk_test/test_oss_live.c | zhengbincesc/aliyun-oss-c-sdk | 264839ac8dd355b2b586e2359c4324d3a991c39e | [
"MIT"
] | null | null | null | oss_c_sdk_test/test_oss_live.c | zhengbincesc/aliyun-oss-c-sdk | 264839ac8dd355b2b586e2359c4324d3a991c39e | [
"MIT"
] | null | null | null | #include "CuTest.h"
#include "aos_log.h"
#include "aos_util.h"
#include "aos_string.h"
#include "aos_status.h"
#include "aos_transport.h"
#include "aos_http_io.h"
#include "oss_auth.h"
#include "oss_util.h"
#include "oss_xml.h"
#include "oss_api.h"
#include "oss_config.h"
#include "oss_test_util.h"
#include "apr_time.h"
void test_live_setup(CuTest *tc)
{
aos_pool_t *p = NULL;
int is_cname = 0;
aos_status_t *s = NULL;
oss_request_options_t *options = NULL;
oss_acl_e oss_acl = OSS_ACL_PRIVATE;
//create test bucket
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, is_cname);
s = create_test_bucket(options, TEST_BUCKET_NAME, oss_acl);
CuAssertIntEquals(tc, 200, s->code);
aos_pool_destroy(p);
}
void test_live_cleanup(CuTest *tc)
{
aos_pool_t *p = NULL;
int is_cname = 0;
aos_string_t bucket;
oss_request_options_t *options = NULL;
aos_table_t *resp_headers = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, is_cname);
//delete test bucket
aos_str_set(&bucket, TEST_BUCKET_NAME);
oss_delete_bucket(options, &bucket, &resp_headers);
apr_sleep(apr_time_from_sec(3));
aos_pool_destroy(p);
}
void test_create_live_channel_default(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_list_t publish_url_list;
aos_list_t play_url_list;
oss_live_channel_configuration_t *config = NULL;
oss_live_channel_configuration_t info;
char *live_channel_name = "test_live_channel_create_def";
char *live_channel_desc = "my test live channel";
aos_string_t bucket;
aos_string_t channel_name;
oss_live_channel_publish_url_t *publish_url;
oss_live_channel_play_url_t *play_url;
char *content = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
config = oss_create_live_channel_configuration_content(options->pool);
aos_str_set(&config->name, live_channel_name);
aos_str_set(&config->description, live_channel_desc);
// create
aos_list_init(&publish_url_list);
aos_list_init(&play_url_list);
s = oss_create_live_channel(options, &bucket, config, &publish_url_list,
&play_url_list, NULL);
CuAssertIntEquals(tc, 200, s->code);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len,
publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
CuAssertIntEquals(tc, 1, aos_ends_with(&publish_url->publish_url, &channel_name));
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len,
play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
CuAssertIntEquals(tc, 1, aos_ends_with(&play_url->play_url, &config->target.play_list_name));
}
// get info
s = oss_get_live_channel_info(options, &bucket, &channel_name, &info, NULL);
CuAssertIntEquals(tc, 200, s->code);
content = apr_psprintf(p, "%.*s", info.name.len, info.name.data);
CuAssertStrEquals(tc, live_channel_name, content);
content = apr_psprintf(p, "%.*s", info.description.len, info.description.data);
CuAssertStrEquals(tc, live_channel_desc, content);
content = apr_psprintf(p, "%.*s", info.status.len, info.status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
content = apr_psprintf(p, "%.*s", info.target.type.len, info.target.type.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_DEFAULT_TYPE, content);
content = apr_psprintf(p, "%.*s", info.target.play_list_name.len, info.target.play_list_name.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_DEFAULT_PLAYLIST, content);
CuAssertIntEquals(tc, LIVE_CHANNEL_DEFAULT_FRAG_DURATION, info.target.frag_duration);
CuAssertIntEquals(tc, LIVE_CHANNEL_DEFAULT_FRAG_COUNT, info.target.frag_count);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_create_live_channel_default ok\n");
}
void test_create_live_channel(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_list_t publish_url_list;
aos_list_t play_url_list;
oss_live_channel_configuration_t *config = NULL;
oss_live_channel_configuration_t info;
char *live_channel_name = "test_live_channel_create";
char *live_channel_desc = "my test live channel,<>{}=?//&";
aos_string_t bucket;
aos_string_t channel_name;
oss_live_channel_publish_url_t *publish_url;
oss_live_channel_play_url_t *play_url;
aos_table_t *resp_headers = NULL;
char *content = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
config = oss_create_live_channel_configuration_content(options->pool);
aos_str_set(&config->name, live_channel_name);
aos_str_set(&config->description, live_channel_desc);
aos_str_set(&config->status, LIVE_CHANNEL_STATUS_DISABLED);
aos_str_set(&config->target.type, "HLS");
aos_str_set(&config->target.play_list_name, "myplay.m3u8");
config->target.frag_duration = 100;
config->target.frag_count = 99;
// create
aos_list_init(&publish_url_list);
aos_list_init(&play_url_list);
s = oss_create_live_channel(options, &bucket, config, &publish_url_list,
&play_url_list, &resp_headers);
CuAssertIntEquals(tc, 200, s->code);
CuAssertPtrNotNull(tc, resp_headers);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len,
publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
CuAssertIntEquals(tc, 1, aos_ends_with(&publish_url->publish_url, &channel_name));
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len,
play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
CuAssertIntEquals(tc, 1, aos_ends_with(&play_url->play_url, &config->target.play_list_name));
}
// get info
s = oss_get_live_channel_info(options, &bucket, &channel_name, &info, NULL);
CuAssertIntEquals(tc, 200, s->code);
content = apr_psprintf(p, "%.*s", info.name.len, info.name.data);
CuAssertStrEquals(tc, live_channel_name, content);
content = apr_psprintf(p, "%.*s", info.description.len, info.description.data);
CuAssertStrEquals(tc, live_channel_desc, content);
content = apr_psprintf(p, "%.*s", info.status.len, info.status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_DISABLED, content);
content = apr_psprintf(p, "%.*s", info.target.type.len, info.target.type.data);
CuAssertStrEquals(tc, "HLS", content);
content = apr_psprintf(p, "%.*s", info.target.play_list_name.len, info.target.play_list_name.data);
CuAssertStrEquals(tc, "myplay.m3u8", content);
CuAssertIntEquals(tc, 100, info.target.frag_duration);
CuAssertIntEquals(tc, 99, info.target.frag_count);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_create_live_channel ok\n");
}
void test_get_live_channel_stat(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_list_t publish_url_list;
aos_list_t play_url_list;
oss_live_channel_configuration_t *config = NULL;
oss_live_channel_stat_t live_stat;
char *live_channel_name = "test_live_channel_stat";
char *live_channel_desc = "my test live channel";
aos_string_t bucket;
aos_string_t channel_name;
char *content = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
config = oss_create_live_channel_configuration_content(options->pool);
aos_str_set(&config->name, live_channel_name);
aos_str_set(&config->description, live_channel_desc);
// create
aos_list_init(&publish_url_list);
aos_list_init(&play_url_list);
s = oss_create_live_channel(options, &bucket, config, &publish_url_list,
&play_url_list, NULL);
CuAssertIntEquals(tc, 200, s->code);
// get stat
s = oss_get_live_channel_stat(options, &bucket, &channel_name, &live_stat, NULL);
CuAssertIntEquals(tc, 200, s->code);
content = apr_psprintf(p, "%.*s", live_stat.pushflow_status.len, live_stat.pushflow_status.data);
CuAssertStrEquals(tc, "Idle", content);
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_get_live_channel_stat ok\n");
}
void test_put_live_channel_status(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
char *live_channel_name = "test_live_channel_status";
aos_string_t bucket;
aos_string_t channel_name;
aos_string_t channel_stutus;
oss_live_channel_configuration_t info;
char *content = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
// create
s = create_test_live_channel(options, TEST_BUCKET_NAME, live_channel_name);
CuAssertIntEquals(tc, 200, s->code);
// put status
aos_str_set(&channel_stutus, LIVE_CHANNEL_STATUS_DISABLED);
s= oss_put_live_channel_status(options, &bucket, &channel_name, &channel_stutus, NULL);
CuAssertIntEquals(tc, 200, s->code);
// check by get info
s = oss_get_live_channel_info(options, &bucket, &channel_name, &info, NULL);
CuAssertIntEquals(tc, 200, s->code);
content = apr_psprintf(p, "%.*s", info.name.len, info.name.data);
CuAssertStrEquals(tc, live_channel_name, content);
content = apr_psprintf(p, "%.*s", info.status.len, info.status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_DISABLED, content);
// put status
aos_str_set(&channel_stutus, LIVE_CHANNEL_STATUS_ENABLED);
s= oss_put_live_channel_status(options, &bucket, &channel_name, &channel_stutus, NULL);
CuAssertIntEquals(tc, 200, s->code);
// check by get info
s = oss_get_live_channel_info(options, &bucket, &channel_name, &info, NULL);
CuAssertIntEquals(tc, 200, s->code);
content = apr_psprintf(p, "%.*s", info.name.len, info.name.data);
CuAssertStrEquals(tc, live_channel_name, content);
content = apr_psprintf(p, "%.*s", info.status.len, info.status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_put_live_channel_status ok\n");
}
void test_delete_live_channel(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_list_t publish_url_list;
aos_list_t play_url_list;
oss_live_channel_configuration_t *config = NULL;
oss_live_channel_stat_t live_stat;
char *live_channel_name = "test_live_channel_del";
char *live_channel_desc = "my test live channel";
aos_string_t bucket;
aos_string_t channel_name;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
config = oss_create_live_channel_configuration_content(options->pool);
aos_str_set(&config->name, live_channel_name);
aos_str_set(&config->description, live_channel_desc);
// create
aos_list_init(&publish_url_list);
aos_list_init(&play_url_list);
s = oss_create_live_channel(options, &bucket, config, &publish_url_list,
&play_url_list, NULL);
CuAssertIntEquals(tc, 200, s->code);
// get stat
s = oss_get_live_channel_stat(options, &bucket, &channel_name, &live_stat, NULL);
CuAssertIntEquals(tc, 200, s->code);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
// get stat
s = oss_get_live_channel_stat(options, &bucket, &channel_name, &live_stat, NULL);
CuAssertIntEquals(tc, 404, s->code);
CuAssertStrEquals(tc, "NoSuchLiveChannel", s->error_code);
aos_pool_destroy(p);
printf("test_delete_live_channel ok\n");
}
void test_list_live_channel(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_string_t bucket;
oss_list_live_channel_params_t *params = NULL;
oss_live_channel_content_t *live_chan;
char *content = NULL;
oss_live_channel_publish_url_t *publish_url;
oss_live_channel_play_url_t *play_url;
int channel_count = 0;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
// create
s = create_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list1");
CuAssertIntEquals(tc, 200, s->code);
s = create_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list2");
CuAssertIntEquals(tc, 200, s->code);
s = create_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list3");
CuAssertIntEquals(tc, 200, s->code);
s = create_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list4");
CuAssertIntEquals(tc, 200, s->code);
s = create_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list5");
CuAssertIntEquals(tc, 200, s->code);
// list
params = oss_create_list_live_channel_params(options->pool);
aos_str_set(¶ms->prefix, "test_live_channel_list");
s = oss_list_live_channel(options, &bucket, params, NULL);
CuAssertIntEquals(tc, 200, s->code);
channel_count = 0;
aos_list_for_each_entry(oss_live_channel_content_t, live_chan, ¶ms->live_channel_list, node) {
channel_count++;
content = apr_psprintf(p, "%.*s", live_chan->name.len, live_chan->name.data);
CuAssertStrEquals(tc, apr_psprintf(p, "test_live_channel_list%d", channel_count), content);
content = apr_psprintf(p, "%.*s", live_chan->description.len, live_chan->description.data);
CuAssertStrEquals(tc, "live channel description", content);
content = apr_psprintf(p, "%.*s", live_chan->status.len, live_chan->status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
content = apr_psprintf(p, "%.*s", live_chan->last_modified.len, live_chan->last_modified.data);
CuAssertStrnEquals(tc, "201", strlen("201"), content);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &live_chan->publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len, publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &live_chan->play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len, play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
}
}
CuAssertIntEquals(tc, 5, channel_count);
// list by prefix
params = oss_create_list_live_channel_params(options->pool);
aos_str_set(¶ms->prefix, "test_live_channel_list2");
s = oss_list_live_channel(options, &bucket, params, NULL);
CuAssertIntEquals(tc, 200, s->code);
channel_count = 0;
aos_list_for_each_entry(oss_live_channel_content_t, live_chan, ¶ms->live_channel_list, node) {
channel_count++;
content = apr_psprintf(p, "%.*s", live_chan->name.len, live_chan->name.data);
CuAssertStrEquals(tc, "test_live_channel_list2", content);
content = apr_psprintf(p, "%.*s", live_chan->description.len, live_chan->description.data);
CuAssertStrEquals(tc, "live channel description", content);
content = apr_psprintf(p, "%.*s", live_chan->status.len, live_chan->status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
content = apr_psprintf(p, "%.*s", live_chan->last_modified.len, live_chan->last_modified.data);
CuAssertStrnEquals(tc, "201", strlen("201"), content);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &live_chan->publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len, publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &live_chan->play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len, play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
}
}
CuAssertIntEquals(tc, 1, channel_count);
// list by mark
params = oss_create_list_live_channel_params(options->pool);
aos_str_set(¶ms->prefix, "test_live_channel_list");
aos_str_set(¶ms->marker, "test_live_channel_list2");
s = oss_list_live_channel(options, &bucket, params, NULL);
CuAssertIntEquals(tc, 200, s->code);
channel_count = 0;
aos_list_for_each_entry(oss_live_channel_content_t, live_chan, ¶ms->live_channel_list, node) {
channel_count++;
content = apr_psprintf(p, "%.*s", live_chan->name.len, live_chan->name.data);
CuAssertStrEquals(tc, apr_psprintf(p, "test_live_channel_list%d", channel_count + 2), content);
content = apr_psprintf(p, "%.*s", live_chan->description.len, live_chan->description.data);
CuAssertStrEquals(tc, "live channel description", content);
content = apr_psprintf(p, "%.*s", live_chan->status.len, live_chan->status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
content = apr_psprintf(p, "%.*s", live_chan->last_modified.len, live_chan->last_modified.data);
CuAssertStrnEquals(tc, "201", strlen("201"), content);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &live_chan->publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len,
publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &live_chan->play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len, play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
}
}
CuAssertIntEquals(tc, 3, channel_count);
// list by max keys
params = oss_create_list_live_channel_params(options->pool);
aos_str_set(¶ms->prefix, "test_live_channel_list");
params->max_keys = 3;
s = oss_list_live_channel(options, &bucket, params, NULL);
CuAssertIntEquals(tc, 200, s->code);
channel_count = 0;
aos_list_for_each_entry(oss_live_channel_content_t, live_chan, ¶ms->live_channel_list, node) {
channel_count++;
content = apr_psprintf(p, "%.*s", live_chan->name.len, live_chan->name.data);
CuAssertStrEquals(tc, apr_psprintf(p, "test_live_channel_list%d", channel_count), content);
content = apr_psprintf(p, "%.*s", live_chan->description.len, live_chan->description.data);
CuAssertStrEquals(tc, "live channel description", content);
content = apr_psprintf(p, "%.*s", live_chan->status.len, live_chan->status.data);
CuAssertStrEquals(tc, LIVE_CHANNEL_STATUS_ENABLED, content);
content = apr_psprintf(p, "%.*s", live_chan->last_modified.len, live_chan->last_modified.data);
CuAssertStrnEquals(tc, "201", strlen("201"), content);
aos_list_for_each_entry(oss_live_channel_publish_url_t, publish_url, &live_chan->publish_url_list, node) {
content = apr_psprintf(p, "%.*s", publish_url->publish_url.len, publish_url->publish_url.data);
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), content);
}
aos_list_for_each_entry(oss_live_channel_play_url_t, play_url, &live_chan->play_url_list, node) {
content = apr_psprintf(p, "%.*s", play_url->play_url.len, play_url->play_url.data);
CuAssertStrnEquals(tc, AOS_HTTP_PREFIX, strlen(AOS_HTTP_PREFIX), content);
}
}
CuAssertIntEquals(tc, 3, channel_count);
s = delete_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list1");
CuAssertIntEquals(tc, 204, s->code);
s = delete_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list2");
CuAssertIntEquals(tc, 204, s->code);
s = delete_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list3");
CuAssertIntEquals(tc, 204, s->code);
s = delete_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list4");
CuAssertIntEquals(tc, 204, s->code);
s = delete_test_live_channel(options, TEST_BUCKET_NAME, "test_live_channel_list5");
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_list_live_channel ok\n");
}
void test_get_live_channel_history(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
aos_list_t live_record_list;
oss_live_record_content_t *live_record;
char *live_channel_name = "test_live_channel_hist";
aos_string_t bucket;
aos_string_t channel_name;
aos_string_t content;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
// create
s = create_test_live_channel(options, TEST_BUCKET_NAME, live_channel_name);
CuAssertIntEquals(tc, 200, s->code);
// get history
aos_list_init(&live_record_list);
s = oss_get_live_channel_history(options, &bucket, &channel_name, &live_record_list, NULL);
CuAssertIntEquals(tc, 200, s->code);
aos_list_for_each_entry(oss_live_record_content_t, live_record, &live_record_list, node) {
aos_str_set(&content, ".000Z");
CuAssertIntEquals(tc, 1, aos_ends_with(&live_record->start_time, &content));
CuAssertIntEquals(tc, 1, aos_ends_with(&live_record->end_time, &content));
CuAssertTrue(tc, live_record->remote_addr.len >= (int)strlen("0.0.0.0:0"));
}
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_get_live_channel_history ok\n");
}
/**
* Note: the case need put rtmp stream, use command:
* ffmpeg \-re \-i allstar.flv \-c copy \-f flv "rtmp://oss-live-channel.demo-oss-cn-shenzhen.aliyuncs.com/live/test_live_channel_vod?playlistName=play.m3u8"
*/
void test_gen_vod_play_list(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
char *live_channel_name = "test_live_channel_vod";
aos_string_t bucket;
aos_string_t channel_name;
aos_string_t play_list_name;
int64_t start_time = 0;
int64_t end_time = 0;
oss_acl_e oss_acl;
aos_table_t *resp_headers = NULL;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
oss_acl = OSS_ACL_PUBLIC_READ_WRITE;
s = oss_put_bucket_acl(options, &bucket, oss_acl, &resp_headers);
// create
s = create_test_live_channel(options, TEST_BUCKET_NAME, live_channel_name);
CuAssertIntEquals(tc, 200, s->code);
// post vod
aos_str_set(&play_list_name, "play.m3u8");
start_time = apr_time_now() / 1000000 - 3600;
end_time = apr_time_now() / 1000000 + 3600;
s = oss_gen_vod_play_list(options, &bucket, &channel_name, &play_list_name,
start_time, end_time, NULL);
CuAssertIntEquals(tc, 400, s->code);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_post_vod_play_list ok\n");
}
void test_gen_rtmp_signed_url(CuTest *tc)
{
aos_pool_t *p = NULL;
oss_request_options_t *options = NULL;
aos_status_t *s = NULL;
char *live_channel_name = "test_live_channel_url";
aos_string_t bucket;
aos_string_t channel_name;
aos_string_t play_list_name;
oss_acl_e oss_acl;
aos_table_t *resp_headers = NULL;
char *rtmp_url = NULL;
int64_t expires = 0;
aos_pool_create(&p, NULL);
options = oss_request_options_create(p);
init_test_request_options(options, 0);
aos_str_set(&bucket, TEST_BUCKET_NAME);
aos_str_set(&channel_name, live_channel_name);
oss_acl = OSS_ACL_PRIVATE;
s = oss_put_bucket_acl(options, &bucket, oss_acl, &resp_headers);
// create
s = create_test_live_channel(options, TEST_BUCKET_NAME, live_channel_name);
CuAssertIntEquals(tc, 200, s->code);
// gen url
aos_str_set(&play_list_name, "play.m3u8");
expires = apr_time_now() / 1000000 + 60 * 30;
rtmp_url = oss_gen_rtmp_signed_url(options, &bucket, &channel_name,
&play_list_name, expires);
// manual check passed
CuAssertStrnEquals(tc, AOS_RTMP_PREFIX, strlen(AOS_RTMP_PREFIX), rtmp_url);
// delete
s = oss_delete_live_channel(options, &bucket, &channel_name, NULL);
CuAssertIntEquals(tc, 204, s->code);
aos_pool_destroy(p);
printf("test_gen_rtmp_signed_url ok\n");
}
CuSuite *test_oss_live()
{
CuSuite* suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_live_setup);
SUITE_ADD_TEST(suite, test_create_live_channel_default);
SUITE_ADD_TEST(suite, test_create_live_channel);
SUITE_ADD_TEST(suite, test_put_live_channel_status);
SUITE_ADD_TEST(suite, test_get_live_channel_stat);
SUITE_ADD_TEST(suite, test_delete_live_channel);
SUITE_ADD_TEST(suite, test_list_live_channel);
SUITE_ADD_TEST(suite, test_get_live_channel_history);
SUITE_ADD_TEST(suite, test_gen_vod_play_list);
SUITE_ADD_TEST(suite, test_gen_rtmp_signed_url);
SUITE_ADD_TEST(suite, test_live_cleanup);
return suite;
}
| 41.008889 | 158 | 0.718363 |
9d6ce67540e6033cdd84a261446970f25b1f9647 | 9,362 | h | C | src/test/SwitchCaseTest/ArrayMessageFactory.h | shines77/ConcurrentTest | d351d2ef929c6d33f5b340a747e4cb3fc7a33376 | [
"MIT"
] | null | null | null | src/test/SwitchCaseTest/ArrayMessageFactory.h | shines77/ConcurrentTest | d351d2ef929c6d33f5b340a747e4cb3fc7a33376 | [
"MIT"
] | null | null | null | src/test/SwitchCaseTest/ArrayMessageFactory.h | shines77/ConcurrentTest | d351d2ef929c6d33f5b340a747e4cb3fc7a33376 | [
"MIT"
] | null | null | null | //
// Created by skyinno on 2/14/2016.
//
#ifndef CEPH_ARRAY_MESSAGEFACTORY_H
#define CEPH_ARRAY_MESSAGEFACTORY_H
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <vector>
#include <functional>
#include <memory>
#include <algorithm> // For std::max
#include "Message.h"
#include "FastQueue/basic/stddef.h"
class ArrayMessageFactory
{
public:
template <typename T>
struct register_t
{
register_t(unsigned int key)
{
ArrayMessageFactory & factory = ArrayMessageFactory::get();
factory.reserve_key(key);
if (factory.array_)
factory.array_[key] = ®ister_t<T>::create;
}
template <typename... Args>
register_t(unsigned int key, Args... args)
{
ArrayMessageFactory & factory = ArrayMessageFactory::get();
factory.reserve_key(key);
if (factory.array_)
factory.array_[key] = ®ister_t<T>::create<Args...>;
}
static inline Message * create() {
return new T();
}
//template <typename U>
//inline static Message * create() { return new T(U); }
template <typename... Args>
static inline Message * create(Args... args)
{
return new T(std::forward<Args...>(args...));
}
//template <typename... Args>
//inline static Message * create<void, Args...>() { return new T(); }
};
inline Message * createMessage(unsigned int key)
{
//assert(key < max_capacity_);
assert(max_key_ < (int)max_capacity_);
if ((int)key <= max_key_) {
assert(array_ != nullptr);
//FuncPtr createFunc = array_[key];
FuncPtr createFunc = *(array_ + key);
if (createFunc)
return createFunc();
}
return nullptr;
}
/*
std::unique_ptr<Message> produce_unique(const std::string & key)
{
return std::unique_ptr<Message>(produce(key));
}
std::shared_ptr<Message> produce_shared(const std::string & key)
{
return std::shared_ptr<Message>(produce(key));
}
//*/
typedef Message *(*FuncPtr)();
static inline ArrayMessageFactory & get()
{
static ArrayMessageFactory instance;
return instance;
}
void reserve(unsigned capacity) {
#if 1
// Use realloc() to implement reserve the old data.
if (capacity > max_capacity_) {
FuncPtr * new_array = (FuncPtr *)std::realloc(array_, sizeof(FuncPtr) * capacity);
if (new_array) {
array_ = new_array;
max_capacity_ = capacity;
}
}
#else
if (capacity > max_capacity_) {
FuncPtr * new_array = (FuncPtr *)std::malloc(sizeof(FuncPtr) * capacity);
if (new_array) {
if (array_) {
// If array_ and new_array is different, reserve the old data.
if (new_array != array_) {
for (unsigned i = 0; i < max_capacity_; ++i) {
new_array[i] = array_[i];
}
}
std::free(array_);
}
array_ = new_array;
max_capacity_ = capacity;
}
}
#endif
}
void reserve_key(unsigned int key)
{
if ((int)key > max_key_) {
max_key_ = (int)key;
if (key >= max_capacity_) {
unsigned new_capacity = std::max<unsigned>(max_capacity_ * 2, 1);
if (key >= new_capacity)
new_capacity *= 2;
this->reserve(new_capacity);
}
}
}
void resize(unsigned capacity, bool force_shrink = true, bool force_clear = false) {
if (force_shrink || (capacity > max_capacity_)) {
FuncPtr * new_array;
// If you need clear the data, needn't to use realloc(),
// because realloc() maybe copy the old data to new data area.
if (!force_clear) {
new_array = (FuncPtr *)std::realloc(array_, sizeof(FuncPtr) * capacity);
if (new_array) {
array_ = new_array;
max_capacity_ = capacity;
}
else {
array_ = nullptr;
max_capacity_ = 0;
}
// Adjust the max key value by max_capacity_.
if (max_key_ >= (int)max_capacity_)
max_key_ = max_capacity_ - 1;
}
else {
if (array_) {
std::free(array_);
array_ = nullptr;
max_capacity_ = 0;
}
new_array = (FuncPtr *)std::malloc(sizeof(FuncPtr) * capacity);
if (new_array) {
::memset(new_array, 0, sizeof(FuncPtr) * capacity);
array_ = new_array;
max_capacity_ = capacity;
}
else {
array_ = nullptr;
max_capacity_ = 0;
}
// Adjust the max key value by max_capacity_.
if (max_key_ >= (int)max_capacity_)
max_key_ = max_capacity_ - 1;
}
}
}
protected:
void force_resize(unsigned capacity, bool clear = true) {
if (array_) {
std::free(array_);
array_ = nullptr;
max_capacity_ = 0;
}
FuncPtr * new_array = (FuncPtr *)std::malloc(sizeof(FuncPtr) * capacity);
if (new_array) {
if (clear)
::memset(new_array, 0, sizeof(FuncPtr) * capacity);
array_ = new_array;
max_capacity_ = capacity;
}
// Adjust the max key value by max_capacity_.
if (max_key_ >= (int)max_capacity_)
max_key_ = max_capacity_ - 1;
}
private:
ArrayMessageFactory() : max_key_(-1), max_capacity_(0), array_(nullptr) {
this->force_resize(128, true);
};
ArrayMessageFactory(const ArrayMessageFactory &) = delete;
ArrayMessageFactory(ArrayMessageFactory &&) = delete;
virtual ~ArrayMessageFactory() {
if (array_) {
std::free(array_);
#if !defined(NDEBUG)
array_ = nullptr;
max_key_ = 0;
max_capacity_ = 0;
#endif
}
};
FuncPtr * array_;
int max_key_;
unsigned max_capacity_;
};
#define ARRAY_REGISTER_MESSAGE_VNAME(T) array_reg_msg_##T##_
#define ARRAY_REGISTER_MESSAGE(T, key, ...) static ArrayMessageFactory::register_t<T> ARRAY_REGISTER_MESSAGE_VNAME(T)(key, ##__VA_ARGS__);
#define ARRAY_REGISTER_MESSAGE_01(T, key, arg_type, ...) \
static ArrayMessageFactory::register_t<T, arg_type> ARRAY_REGISTER_MESSAGE_VNAME(T)(key, ##__VA_ARGS__);
#include "Messages.h"
ARRAY_REGISTER_MESSAGE(CephMessage00, CEPH_MSG_ID_0);
ARRAY_REGISTER_MESSAGE(CephMessage01, CEPH_MSG_ID_1);
ARRAY_REGISTER_MESSAGE(CephMessage02, CEPH_MSG_ID_2);
ARRAY_REGISTER_MESSAGE(CephMessage03, CEPH_MSG_ID_3);
ARRAY_REGISTER_MESSAGE(CephMessage04, CEPH_MSG_ID_4);
ARRAY_REGISTER_MESSAGE(CephMessage05, CEPH_MSG_ID_5);
ARRAY_REGISTER_MESSAGE(CephMessage06, CEPH_MSG_ID_6);
ARRAY_REGISTER_MESSAGE(CephMessage07, CEPH_MSG_ID_7);
ARRAY_REGISTER_MESSAGE(CephMessage08, CEPH_MSG_ID_8);
ARRAY_REGISTER_MESSAGE(CephMessage09, CEPH_MSG_ID_9);
ARRAY_REGISTER_MESSAGE(CephMessage10, CEPH_MSG_ID_10);
//ARRAY_REGISTER_MESSAGE_01(CephMessage10, CEPH_MSG_ID_10, int, 1);
ARRAY_REGISTER_MESSAGE(CephMessage11, CEPH_MSG_ID_11);
ARRAY_REGISTER_MESSAGE(CephMessage12, CEPH_MSG_ID_12);
ARRAY_REGISTER_MESSAGE(CephMessage13, CEPH_MSG_ID_13);
ARRAY_REGISTER_MESSAGE(CephMessage14, CEPH_MSG_ID_14);
ARRAY_REGISTER_MESSAGE(CephMessage15, CEPH_MSG_ID_15);
ARRAY_REGISTER_MESSAGE(CephMessage16, CEPH_MSG_ID_16);
ARRAY_REGISTER_MESSAGE(CephMessage17, CEPH_MSG_ID_17);
ARRAY_REGISTER_MESSAGE(CephMessage18, CEPH_MSG_ID_18);
ARRAY_REGISTER_MESSAGE(CephMessage19, CEPH_MSG_ID_19);
ARRAY_REGISTER_MESSAGE(CephMessage20, CEPH_MSG_ID_20);
ARRAY_REGISTER_MESSAGE(CephMessage21, CEPH_MSG_ID_21);
ARRAY_REGISTER_MESSAGE(CephMessage22, CEPH_MSG_ID_22);
ARRAY_REGISTER_MESSAGE(CephMessage23, CEPH_MSG_ID_23);
ARRAY_REGISTER_MESSAGE(CephMessage24, CEPH_MSG_ID_24);
ARRAY_REGISTER_MESSAGE(CephMessage25, CEPH_MSG_ID_25);
ARRAY_REGISTER_MESSAGE(CephMessage26, CEPH_MSG_ID_26);
ARRAY_REGISTER_MESSAGE(CephMessage27, CEPH_MSG_ID_27);
ARRAY_REGISTER_MESSAGE(CephMessage28, CEPH_MSG_ID_28);
ARRAY_REGISTER_MESSAGE(CephMessage29, CEPH_MSG_ID_29);
ARRAY_REGISTER_MESSAGE(CephMessage30, CEPH_MSG_ID_30);
ARRAY_REGISTER_MESSAGE(CephMessage31, CEPH_MSG_ID_31);
ARRAY_REGISTER_MESSAGE(CephMessage32, CEPH_MSG_ID_32);
ARRAY_REGISTER_MESSAGE(CephMessage33, CEPH_MSG_ID_33);
ARRAY_REGISTER_MESSAGE(CephMessage34, CEPH_MSG_ID_34);
ARRAY_REGISTER_MESSAGE(CephMessage35, CEPH_MSG_ID_35);
ARRAY_REGISTER_MESSAGE(CephMessage36, CEPH_MSG_ID_36);
ARRAY_REGISTER_MESSAGE(CephMessage37, CEPH_MSG_ID_37);
ARRAY_REGISTER_MESSAGE(CephMessage38, CEPH_MSG_ID_38);
ARRAY_REGISTER_MESSAGE(CephMessage39, CEPH_MSG_ID_39);
#endif // CEPH_ARRAY_MESSAGEFACTORY_H
| 34.043636 | 151 | 0.609485 |
7780956011df98642a24ac9d09a65c13093e0161 | 447 | h | C | QNShortVideoKit-bytedance-iOS/PLShortVideoKitDemo/ByteEffects/Classes/Record/Views/BEModernFaceVerifyView.h | KevinHuo/QNShortVideo-ByteDance | 5a01efe78861ab8868355741e44f0845036f436f | [
"MIT"
] | null | null | null | QNShortVideoKit-bytedance-iOS/PLShortVideoKitDemo/ByteEffects/Classes/Record/Views/BEModernFaceVerifyView.h | KevinHuo/QNShortVideo-ByteDance | 5a01efe78861ab8868355741e44f0845036f436f | [
"MIT"
] | null | null | null | QNShortVideoKit-bytedance-iOS/PLShortVideoKitDemo/ByteEffects/Classes/Record/Views/BEModernFaceVerifyView.h | KevinHuo/QNShortVideo-ByteDance | 5a01efe78861ab8868355741e44f0845036f436f | [
"MIT"
] | null | null | null | // Copyright (C) 2019 Beijing Bytedance Network Technology Co., Ltd.
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol BEModernFaceVerifyViewDelegate <NSObject>
@required
- (void)openSystemAlbumButtonClicked;
@end
@interface BEModernFaceVerifyView : UIView
@property (nonatomic, weak) id <BEModernFaceVerifyViewDelegate> delegate;
-(void)imageViewSetImage:(UIImage*) image;
-(void) setCellsUnSelected;
@end
NS_ASSUME_NONNULL_END
| 18.625 | 73 | 0.800895 |
a035411633a623c8b843946fac0d5c76c6a4f24a | 705 | h | C | System/Library/PrivateFrameworks/MediaRemote.framework/MRRemoteTextInputMessage.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/MediaRemote.framework/MRRemoteTextInputMessage.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/MediaRemote.framework/MRRemoteTextInputMessage.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:40:30 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/MediaRemote.framework/MediaRemote
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <MediaRemote/MRProtocolMessage.h>
@class NSData;
@interface MRRemoteTextInputMessage : MRProtocolMessage
@property (nonatomic,readonly) unsigned long long version;
@property (nonatomic,readonly) NSData * data;
-(unsigned long long)version;
-(id)initWithVersion:(unsigned long long)arg1 data:(id)arg2 ;
-(NSData *)data;
-(unsigned long long)type;
@end
| 30.652174 | 83 | 0.77305 |
410ecc6dd5f8c7ef306c1cb303495c71ecd490bc | 3,074 | h | C | 3_Implementation/inc/pattern.h | lohithbhargav/Mini_Project_LTTS | dc40d99ddd967a3877a8ad645d14fc0dbbb68da3 | [
"CC0-1.0"
] | null | null | null | 3_Implementation/inc/pattern.h | lohithbhargav/Mini_Project_LTTS | dc40d99ddd967a3877a8ad645d14fc0dbbb68da3 | [
"CC0-1.0"
] | 15 | 2021-04-14T18:28:10.000Z | 2021-04-16T07:53:10.000Z | 3_Implementation/inc/pattern.h | lohithbhargav/Mini_Project_LTTS | dc40d99ddd967a3877a8ad645d14fc0dbbb68da3 | [
"CC0-1.0"
] | 3 | 2021-04-14T18:47:08.000Z | 2021-04-15T16:04:13.000Z | /**
* @file patterns.h
* @author D.Lohith Bhargav (dlohithbhargav28@gmail.com)
* @brief
* @version 0.1
* @date 2021-04-13
*
* @copyright Copyright (c) 2021
*
*/
/**
* @file pattern.h
* pattern's application with 23 different pattern with user input size
*/
#ifndef __PATTERN_H__
#define __PATTERN_H__
/**
* @brief square star pattern with user input size
* Test case 1
* @param n
* @return int
*/
int square_star(int n);
/**
* @brief rhombus star pattern with user input size
* Test case 2
* @param n
* @return int
*/
int rhombus_star(int n);
/**
* @brief square star pattern with user input size
*/
void square_star_pattern();
/**
* @brief hollow square star pattern with diagonal with user input size
*/
void hollow_square_star_pattern_with_diagonal();
/**
* @brief rhombus star pattern with user input size
*/
void rhombus_star_pattern();
/**
* @brief hollow rhombus star pattern with user input size
*/
void hollow_rhombus_star_pattern();
/**
* @brief mirrored rhombus star pattern with user input size
*/
void mirrored_rhombus_star_pattern();
/**
* @brief hollow mirrored rhombus star pattern with user input size
*/
void hollow_mirrored_rhombus_star_pattern();
/**
* @brief right triangle star pattern with user input size
*/
void right_triangle_star_pattern();
/**
* @brief mirrored right triangle star pattern with user input size
*/
void mirrored_right_triangle_star_pattern();
/**
* @brief hollow right triangle star pattern with user input size
*/
void hollow_right_triangle_star_pattern();
/**
* @brief hollow inverted mirrored right triangle star pattern with user input size
*/
void hollow_inverted_mirrored_right_triangle_star_pattern();
/**
* @brief hollow inverted right triangle star pattern with user input size
*/
void hollow_inverted_right_triangle_star_pattern();
/**
* @brief inverted right triangle star pattern with user input size
*/
void inverted_right_triangle_star_pattern();
/**
* @brief inverted mirrored right triangle star pattern with user input size
*/
void inverted_mirrored_right_triangle_star_pattern();
/**
* @brief hollow square star pattern with user input size
*/
void hollow_square_star_pattern();
/**
* @brief pyramid star pattern with user input size
*/
void pyramid_star_pattern();
/**
* @brief hollow pyramid star pattern with user input size
*/
void hollow_pyramid_star_pattern();
/**
* @brief inverted pyramid star pattern with user input size
*/
void inverted_pyramid_star_pattern();
/**
* @brief right arrow star pattern with user input size
*/
void right_arrow_star_pattern();
/**
* @brief half diamond star pattern with user input size
*/
void half_diamond_star_pattern();
/**
* @brief left arrow star pattern with user input size
*/
void left_arrow_star_pattern();
/**
* @brief plus star pattern with user input size
*/
void plus_star_pattern();
/**
* @brief diamond star pattern with user input size
*/
void diamond_star_pattern();
/**
* @brief X star pattern with user input size
*/
void x_star_pattern();
#endif /*#define __PATTERN_H__*/
| 24.015625 | 83 | 0.735849 |
991b498e9b4ae8ad99726c28aca4a2c22e4b5dbc | 7,193 | c | C | contrib/ntp/libntp/log.c | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 4 | 2017-04-06T21:39:15.000Z | 2019-10-09T17:34:14.000Z | contrib/ntp/libntp/log.c | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | contrib/ntp/libntp/log.c | TrustedBSD/sebsd | fd5de6f587183087cf930779701d5713e8ca64cc | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2020-01-04T06:36:39.000Z | 2020-01-04T06:36:39.000Z | /* Microsoft Developer Support Copyright (c) 1993 Microsoft Corporation. */
/* Skip asynch rpc inclusion */
#ifndef __RPCASYNC_H__
#define __RPCASYNC_H__
#endif
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "messages.h"
#include "log.h"
#define PERR(bSuccess, api) {if(!(bSuccess)) printf("%s: Error %d from %s \
on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
/*********************************************************************
* FUNCTION: addSourceToRegistry(LPSTR pszAppname, LPSTR pszMsgDLL) *
* *
* PURPOSE: Add a source name key, message DLL name value, and *
* message type supported value to the registry *
* *
* INPUT: source name, path of message DLL *
* *
* RETURNS: none *
*********************************************************************/
void addSourceToRegistry(LPSTR pszAppname, LPSTR pszMsgDLL)
{
HKEY hk; /* registry key handle */
DWORD dwData;
BOOL bSuccess;
char regarray[200];
char *lpregarray = regarray;
/* When an application uses the RegisterEventSource or OpenEventLog
function to get a handle of an event log, the event loggging service
searches for the specified source name in the registry. You can add a
new source name to the registry by opening a new registry subkey
under the Application key and adding registry values to the new
subkey. */
strcpy(lpregarray, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
strcat(lpregarray, pszAppname);
/* Create a new key for our application */
bSuccess = RegCreateKey(HKEY_LOCAL_MACHINE,lpregarray, &hk);
PERR(bSuccess == ERROR_SUCCESS, "RegCreateKey");
/* Add the Event-ID message-file name to the subkey. */
bSuccess = RegSetValueEx(hk, /* subkey handle */
"EventMessageFile", /* value name */
0, /* must be zero */
REG_EXPAND_SZ, /* value type */
(LPBYTE) pszMsgDLL, /* address of value data */
strlen(pszMsgDLL) + 1); /* length of value data */
PERR(bSuccess == ERROR_SUCCESS, "RegSetValueEx");
/* Set the supported types flags and addit to the subkey. */
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
EVENTLOG_INFORMATION_TYPE;
bSuccess = RegSetValueEx(hk, /* subkey handle */
"TypesSupported", /* value name */
0, /* must be zero */
REG_DWORD, /* value type */
(LPBYTE) &dwData, /* address of value data */
sizeof(DWORD)); /* length of value data */
PERR(bSuccess == ERROR_SUCCESS, "RegSetValueEx");
RegCloseKey(hk);
return;
}
/*********************************************************************
* FUNCTION: reportAnEvent(DWORD dwIdEvent, WORD cStrings, *
* LPTSTR *ppszStrings); *
* *
* PURPOSE: add the event to the event log *
* *
* INPUT: the event ID to report in the log, the number of insert *
* strings, and an array of null-terminated insert strings *
* *
* RETURNS: none *
*********************************************************************/
void reportAnIEvent(DWORD dwIdEvent, WORD cStrings, LPTSTR *pszStrings)
{
HANDLE hAppLog;
BOOL bSuccess;
/* Get a handle to the Application event log */
hAppLog = RegisterEventSource(NULL, /* use local machine */
"NTP"); /* source name */
PERR(hAppLog, "RegisterEventSource");
/* Now report the event, which will add this event to the event log */
bSuccess = ReportEvent(hAppLog, /* event-log handle */
EVENTLOG_INFORMATION_TYPE, /* event type */
0, /* category zero */
dwIdEvent, /* event ID */
NULL, /* no user SID */
cStrings, /* number of substitution strings */
0, /* no binary data */
pszStrings, /* string array */
NULL); /* address of data */
PERR(bSuccess, "ReportEvent");
DeregisterEventSource(hAppLog);
return;
}
void reportAnWEvent(DWORD dwIdEvent, WORD cStrings, LPTSTR *pszStrings)
{
HANDLE hAppLog;
BOOL bSuccess;
/* Get a handle to the Application event log */
hAppLog = RegisterEventSource(NULL, /* use local machine */
"NTP"); /* source name */
PERR(hAppLog, "RegisterEventSource");
/* Now report the event, which will add this event to the event log */
bSuccess = ReportEvent(hAppLog, /* event-log handle */
EVENTLOG_WARNING_TYPE, /* event type */
0, /* category zero */
dwIdEvent, /* event ID */
NULL, /* no user SID */
cStrings, /* number of substitution strings */
0, /* no binary data */
pszStrings, /* string array */
NULL); /* address of data */
PERR(bSuccess, "ReportEvent");
DeregisterEventSource(hAppLog);
return;
}
void reportAnEEvent(DWORD dwIdEvent, WORD cStrings, LPTSTR *pszStrings)
{
HANDLE hAppLog;
BOOL bSuccess;
/* Get a handle to the Application event log */
hAppLog = RegisterEventSource(NULL, /* use local machine */
"NTP"); /* source name */
PERR(hAppLog, "RegisterEventSource");
/* Now report the event, which will add this event to the event log */
bSuccess = ReportEvent(hAppLog, /* event-log handle */
EVENTLOG_ERROR_TYPE, /* event type */
0, /* category zero */
dwIdEvent, /* event ID */
NULL, /* no user SID */
cStrings, /* number of substitution strings */
0, /* no binary data */
pszStrings, /* string array */
NULL); /* address of data */
PERR(bSuccess, "ReportEvent");
DeregisterEventSource(hAppLog);
return;
}
| 44.401235 | 85 | 0.472265 |
48d13f56fc372cd906a2a0b9f29072c10d2d81fd | 1,183 | h | C | src/gpu/GrVx.h | fourgrad/skia | b9b550e9bb1b73001088ba89483e2f9bbe46c3db | [
"BSD-3-Clause"
] | 6,304 | 2015-01-05T23:45:12.000Z | 2022-03-31T09:48:13.000Z | src/gpu/GrVx.h | Wal1e/skia | eda97288bdc8e87afea817b25d561724c2b6a2f8 | [
"BSD-3-Clause"
] | 67 | 2016-04-18T13:30:02.000Z | 2022-03-31T23:06:55.000Z | src/gpu/GrVx.h | Wal1e/skia | eda97288bdc8e87afea817b25d561724c2b6a2f8 | [
"BSD-3-Clause"
] | 1,231 | 2015-01-05T03:17:39.000Z | 2022-03-31T22:54:58.000Z | /*
* Copyright 2020 Google LLC.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrVx_DEFINED
#define GrVx_DEFINED
#include "include/core/SkTypes.h"
#include "include/private/SkVx.h"
// grvx is Ganesh's addendum to skvx, Skia's SIMD library. Here we introduce functions that are
// approximate and/or have LSB differences from platform to platform (e.g., by using hardware FMAs
// when available). When a function is approximate, its error range is well documented and tested.
namespace grvx {
// Use familiar type names and functions from SkSL and GLSL.
template<int N> using vec = skvx::Vec<N, float>;
using float2 = vec<2>;
using float4 = vec<4>;
template<int N> using ivec = skvx::Vec<N, int32_t>;
using int2 = ivec<2>;
using int4 = ivec<4>;
template<int N> using uvec = skvx::Vec<N, uint32_t>;
using uint2 = uvec<2>;
using uint4 = uvec<4>;
static SK_ALWAYS_INLINE float dot(float2 a, float2 b) {
float2 ab = a*b;
return ab[0] + ab[1];
}
static SK_ALWAYS_INLINE float cross(float2 a, float2 b) {
float2 x = a*skvx::shuffle<1,0>(b);
return x[0] - x[1];
}
}; // namespace grvx
#endif
| 26.886364 | 98 | 0.702451 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.